Skip to content

Commit

Permalink
Keep the jclass reference inside a scope to prevent
Browse files Browse the repository at this point in the history
duplicate definition error when multiple variables of the same struct
type are present.
  • Loading branch information
pidarped committed Oct 5, 2024
1 parent bd3d3e1 commit dbf76dc
Show file tree
Hide file tree
Showing 3 changed files with 1,822 additions and 1,366 deletions.
12 changes: 7 additions & 5 deletions src/controller/java/templates/partials/decode_value.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ if ({{source}}.IsNull()) {
{{>decode_value target=(concat ../target "_" (asLowerCamelCase label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) omitDeclaration=false earlyReturn=../earlyReturn}}
{{/zcl_struct_items_by_struct_and_cluster_name}}

jclass {{asLowerCamelCase type}}StructClass_{{depth}};
err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}});
if (err != CHIP_NO_ERROR) {
ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}");
return {{earlyReturn}};
{
jclass {{asLowerCamelCase type}}StructClass_{{depth}};
err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}});
if (err != CHIP_NO_ERROR) {
ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}");
return {{earlyReturn}};
}
}

jmethodID {{asLowerCamelCase type}}StructCtor_{{depth}};
Expand Down
Loading

0 comments on commit dbf76dc

Please sign in to comment.