From 3919d1157b0d89bf54c947113a605075a78ae773 Mon Sep 17 00:00:00 2001 From: David Pearce Date: Mon, 4 Nov 2024 14:30:30 +1300 Subject: [PATCH] fix: column setters in trace template (#290) The generated column setters were invalid because they were iterating over BesuColumn instances which didn't (previously) include the `class` attribute. --- src/exporters/besu.rs | 2 ++ src/exporters/besu_trace_columns.java | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/exporters/besu.rs b/src/exporters/besu.rs index d24d924..4c5653e 100644 --- a/src/exporters/besu.rs +++ b/src/exporters/besu.rs @@ -21,6 +21,7 @@ const TRACE_COLUMNS_TEMPLATE: &str = include_str!("besu_trace_columns.java"); #[derive(Serialize)] struct BesuColumn { + class: String, corset_name: String, java_name: String, appender: String, @@ -240,6 +241,7 @@ pub fn render( let r = c.register.unwrap(); let register = reg_to_string(&cs.columns.registers[r], r).to_case(Case::Camel); Some(BesuColumn { + class: class.to_owned(), corset_name: c.handle.to_string(), java_name: c.handle.name.to_case(Case::Camel), appender: handle_to_appender(&c.handle), diff --git a/src/exporters/besu_trace_columns.java b/src/exporters/besu_trace_columns.java index 4e1ee26..10a8e6d 100644 --- a/src/exporters/besu_trace_columns.java +++ b/src/exporters/besu_trace_columns.java @@ -31,7 +31,7 @@ *

Any modifications to this code may be overwritten and could lead to unexpected behavior. * Please DO NOT ATTEMPT TO MODIFY this code directly. */ -public class {{ class }} { +public class {{ this.class }} { {{#each constants}} public static final {{ this.tupe }} {{ this.name }} = {{ this.value }}; {{/each}} @@ -51,7 +51,7 @@ static List headers(int length) { return headers; } - public {{ class }} (List buffers) { + public {{ this.class }} (List buffers) { {{ #each registers }} this.{{ java_name }} = buffers.get({{ @index }}); {{ /each }} @@ -66,7 +66,7 @@ public int size() { } {{#each columns}} - public {{ class }} {{ this.appender }}(final {{ this.tupe }} b) { + public {{ this.class }} {{ this.appender }}(final {{ this.tupe }} b) { if (filled.get({{ this.reg_id }})) { throw new IllegalStateException("{{ this.corset_name }} already set"); } else { @@ -79,7 +79,7 @@ public int size() { } {{/each}} - public {{ class }} validateRow() { + public {{ this.class }} validateRow() { {{#each registers}} if (!filled.get({{ this.id }})) { throw new IllegalStateException("{{ this.corset_name }} has not been filled"); @@ -92,7 +92,7 @@ public int size() { return this; } - public {{ class }} fillAndValidateRow() { + public {{ this.class }} fillAndValidateRow() { {{#each registers}} if (!filled.get({{ this.id }})) { {{ this.java_name }}.position({{ this.java_name }}.position() + {{ this.bytes_width }});