Skip to content

Commit

Permalink
Fix column setters in trace template
Browse files Browse the repository at this point in the history
The generated column setters were invalid because they were iterating
over BesuColumn instances which didn't (previously) include the `class`
attribute.
  • Loading branch information
DavePearce committed Nov 4, 2024
1 parent b292759 commit a72d0b1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/exporters/besu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand Down
10 changes: 5 additions & 5 deletions src/exporters/besu_trace_columns.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* <p>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}}
Expand All @@ -51,7 +51,7 @@ static List<ColumnHeader> headers(int length) {
return headers;
}

public {{ class }} (List<MappedByteBuffer> buffers) {
public {{ this.class }} (List<MappedByteBuffer> buffers) {
{{ #each registers }}
this.{{ java_name }} = buffers.get({{ @index }});
{{ /each }}
Expand All @@ -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 {
Expand All @@ -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");
Expand All @@ -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 }});
Expand Down

0 comments on commit a72d0b1

Please sign in to comment.