Skip to content

Commit dbf76dc

Browse files
committed
Keep the jclass reference inside a scope to prevent
duplicate definition error when multiple variables of the same struct type are present.
1 parent bd3d3e1 commit dbf76dc

File tree

3 files changed

+1822
-1366
lines changed

3 files changed

+1822
-1366
lines changed

src/controller/java/templates/partials/decode_value.zapt

+7-5
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ if ({{source}}.IsNull()) {
3131
{{>decode_value target=(concat ../target "_" (asLowerCamelCase label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) omitDeclaration=false earlyReturn=../earlyReturn}}
3232
{{/zcl_struct_items_by_struct_and_cluster_name}}
3333

34-
jclass {{asLowerCamelCase type}}StructClass_{{depth}};
35-
err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}});
36-
if (err != CHIP_NO_ERROR) {
37-
ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}");
38-
return {{earlyReturn}};
34+
{
35+
jclass {{asLowerCamelCase type}}StructClass_{{depth}};
36+
err = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}});
37+
if (err != CHIP_NO_ERROR) {
38+
ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}");
39+
return {{earlyReturn}};
40+
}
3941
}
4042

4143
jmethodID {{asLowerCamelCase type}}StructCtor_{{depth}};

0 commit comments

Comments
 (0)