From 4553ee0527b605524f6c71a114c3689e35628177 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 12:00:31 -0400 Subject: [PATCH] Switch to using zcl_struct_items_by_struct_and_cluster_name in templates. Our existing uses of zcl_struct_items_by_struct_name were broken if two different clusters used structs with the same name: we would end up enumerating all the struct fields from both structs in a bunch of places. The fix is to use zcl_struct_items_by_struct_and_cluster_name, which takes as input the struct name _and_ the cluster name. No visible codegen changes for now, because we have no such name collisions so far, due to it leading to incorrect codegen. Instead we have been working around it by having our naming not match the spec. This required a few changes other than just the change of helper: 1. The valueEquals in chip-tool did not use to take a cluster name. That needed to be added, and threaded through the call-chain from the place where a cluster name is available, as well as through the recursive invocations of valueEquals. 2. In the java codegen, the cluster name being passed in to encode_value and decode_value was the already-upper-camel-cased version, which does not work as input to zcl_struct_items_by_struct_and_cluster_name. Callsites were changed to pass in the raw cluster name, and actual uses of the name were changed to asUpperCamelCase as needed. 3. While testing, using actual name collisions, a bug was found in the Python codegen: the id of the command being processed was being used when the id of the cluster was intended. --- .../checks/maybeCheckExpectedValue.zapt | 2 +- .../tests/partials/command_value.zapt | 4 ++-- .../tests/partials/test_step_response.zapt | 2 +- .../tests/partials/value_equals.zapt | 18 +++++++------- .../templates/partials/decodable_value.zapt | 4 ++-- .../tests/partials/check_test_value.zapt | 4 ++-- .../templates/tests/partials/test_value.zapt | 4 ++-- .../docker/images/chip-cert-bins/Dockerfile | 2 +- scripts/setup/zap.json | 2 +- scripts/tools/zap/zap_execution.py | 2 +- .../CHIPAttributeTLVValueDecoder-src.zapt | 2 +- .../java/templates/CHIPClustersWrite-JNI.zapt | 2 +- .../CHIPEventTLVValueDecoder-src.zapt | 2 +- .../templates/CHIPInvokeCallbacks-src.zapt | 2 +- .../java/templates/CHIPReadCallbacks-src.zapt | 4 ++-- .../java/templates/partials/decode_value.zapt | 24 +++++++++---------- .../java/templates/partials/encode_value.zapt | 6 ++--- .../templates/python-CHIPClusters-py.zapt | 8 +++---- .../CHIP/templates/partials/decode_value.zapt | 4 ++-- .../CHIP/templates/partials/encode_value.zapt | 4 ++-- 20 files changed, 51 insertions(+), 51 deletions(-) diff --git a/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt b/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt index e303eda9cd7a99..a75e7d7be6bcd3 100644 --- a/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt +++ b/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt @@ -1,3 +1,3 @@ {{~#if hasExpectedValue}} - {{~>valueEquals actual=(asPropertyValue dontUnwrapValue=true) label=(asLowerCamelCase name) expected=expectedValue depth=0~}} + {{~>valueEquals actual=(asPropertyValue dontUnwrapValue=true) label=(asLowerCamelCase name) expected=expectedValue cluster=cluster depth=0~}} {{~/if~}} diff --git a/examples/chip-tool/templates/tests/partials/command_value.zapt b/examples/chip-tool/templates/tests/partials/command_value.zapt index d5a1159cceb7fb..150b34294e5e2c 100644 --- a/examples/chip-tool/templates/tests/partials/command_value.zapt +++ b/examples/chip-tool/templates/tests/partials/command_value.zapt @@ -29,11 +29,11 @@ {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type ns}} {{#if_include_struct_item_value ../definedValue name}} {{>commandValue ns=parent.ns container=(concat parent.container "." (asLowerCamelCase label)) definedValue=(lookup ../definedValue name) depth=(incrementDepth ../depth)}} {{/if_include_struct_item_value}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{container}} = diff --git a/examples/chip-tool/templates/tests/partials/test_step_response.zapt b/examples/chip-tool/templates/tests/partials/test_step_response.zapt index eae82bf13bc463..0f520b856794e7 100644 --- a/examples/chip-tool/templates/tests/partials/test_step_response.zapt +++ b/examples/chip-tool/templates/tests/partials/test_step_response.zapt @@ -29,7 +29,7 @@ switch(mTestSubStepIndex) {{asDecodableType}} value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); {{#chip_tests_item_response_parameters}} - {{>maybeCheckExpectedValue}} + {{>maybeCheckExpectedValue cluster=../cluster}} {{>maybeCheckExpectedConstraints}} {{>maybeSaveAs}} {{/chip_tests_item_response_parameters}} diff --git a/examples/chip-tool/templates/tests/partials/value_equals.zapt b/examples/chip-tool/templates/tests/partials/value_equals.zapt index 5cda33b2b92df9..614ed51ffc9ba4 100644 --- a/examples/chip-tool/templates/tests/partials/value_equals.zapt +++ b/examples/chip-tool/templates/tests/partials/value_equals.zapt @@ -1,6 +1,6 @@ {{#if isOptional}} VerifyOrReturn(CheckValuePresent("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isOptional=false depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isOptional=false cluster=cluster depth=(incrementDepth depth)}} {{else if isNullable}} {{#if (isLiteralNull expected)}} VerifyOrReturn(CheckValueNull("{{label}}", {{actual}})); @@ -14,15 +14,15 @@ else { VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=(concat expected ".Value()") isNullable=false keepAsExpected=true depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=(concat expected ".Value()") isNullable=false keepAsExpected=true cluster=cluster depth=(incrementDepth depth)}} } {{else}} VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false keepAsExpected=true depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false keepAsExpected=true cluster=cluster depth=(incrementDepth depth)}} {{/if}} {{else}} VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false cluster=cluster depth=(incrementDepth depth)}} {{/if}} {{/if}} {{else if isArray}} @@ -31,14 +31,14 @@ auto iter_{{depth}} = {{actual}}.begin(); {{#each expected}} VerifyOrReturn(CheckNextListItemDecodes("{{../label}}", iter_{{../depth}}, {{@index}})); - {{>valueEquals label=(concat ../label "[" @index "]") actual=(concat "iter_" ../depth ".GetValue()") expected=this isArray=false type=../type chipType=../chipType depth=(incrementDepth ../depth) parent=../parent}} + {{>valueEquals label=(concat ../label "[" @index "]") actual=(concat "iter_" ../depth ".GetValue()") expected=this isArray=false type=../type chipType=../chipType cluster=../cluster depth=(incrementDepth ../depth) parent=../parent}} {{/each}} VerifyOrReturn(CheckNoMoreListItems("{{label}}", iter_{{depth}}, {{expected.length}})); } {{else if isEvent}} {{#zcl_events_fields_by_event_name type}} {{#if (hasProperty ../expected label)}} - {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) depth=(incrementDepth ../depth)}} + {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if}} {{/zcl_events_fields_by_event_name}} {{else}} @@ -46,11 +46,11 @@ {{! Iterate over the actual types in the struct, so we pick up the right type/optionality/nullability information for them for our recursive call. }} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if (hasProperty ../expected label)}} - {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) depth=(incrementDepth ../depth)}} + {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{! Maybe we should add a check for properties in the expected object (other than "global") that are not present in the struct ? }} {{else}} diff --git a/examples/darwin-framework-tool/templates/partials/decodable_value.zapt b/examples/darwin-framework-tool/templates/partials/decodable_value.zapt index 76a8e54369f509..8d0442000a070c 100644 --- a/examples/darwin-framework-tool/templates/partials/decodable_value.zapt +++ b/examples/darwin-framework-tool/templates/partials/decodable_value.zapt @@ -23,9 +23,9 @@ {{else}} {{#if_is_struct type}} {{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decodable_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) }} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; diff --git a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt index e84e485fcdb792..26aa91ac9ce056 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt @@ -28,11 +28,11 @@ {{! Iterate over the actual types in the struct, so we pick up the right type/optionality/nullability information for them for our recursive call. }} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if (hasProperty ../expected label)}} {{>check_test_value actual=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../actual ")." (asStructPropertyName label)) expected=(lookup ../expected label) cluster=../cluster}} {{/if}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{! Maybe we should add a check for properties in the expected object (other than "global") that are not present in the struct ? }} {{else}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt index 623f5e0e6c38d2..30c342cecb809d 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt @@ -19,14 +19,14 @@ {{else}} {{#if_is_struct type}} {{target}} = [[MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} alloc] init]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if_include_struct_item_value ../definedValue name}} {{! target may be some place where we lost type information (e.g. an id), so add explicit cast when trying to assign to our properties. }} {{>test_value target=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../target ")." (asStructPropertyName label)) definedValue=(lookup ../definedValue name) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if_include_struct_item_value}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{target}} = diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index 8e9db74f22455a..218438bb81ec79 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb # ZAP Development install, so that it runs on both x64 and arm64 # Generally this should match with the ZAP version that is used for codegen within the # specified SHA -ARG ZAP_VERSION=v2023.04.18-nightly +ARG ZAP_VERSION=v2023.04.21-nightly # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ diff --git a/scripts/setup/zap.json b/scripts/setup/zap.json index 4ed3e0d4ab1ce2..df3f76ff5b5d0f 100644 --- a/scripts/setup/zap.json +++ b/scripts/setup/zap.json @@ -8,7 +8,7 @@ "mac-arm64", "windows-amd64" ], - "tags": ["version:2@v2023.04.18-nightly.1"] + "tags": ["version:2@v2023.04.21-nightly.1"] } ] } diff --git a/scripts/tools/zap/zap_execution.py b/scripts/tools/zap/zap_execution.py index 29d8e83c957d37..3fdeeab5a1da93 100644 --- a/scripts/tools/zap/zap_execution.py +++ b/scripts/tools/zap/zap_execution.py @@ -23,7 +23,7 @@ # Use scripts/tools/zap/version_update.py to manage ZAP versioning as many # files may need updating for versions # -MIN_ZAP_VERSION = '2023.4.18' +MIN_ZAP_VERSION = '2023.4.21' class ZapTool: diff --git a/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt b/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt index ce42d5d1140680..c4ecf0256ace49 100644 --- a/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt +++ b/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt @@ -51,7 +51,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR { return nullptr; } - {{>decode_value target="value" source="cppValue" cluster=(asUpperCamelCase parent.name) depth=0 earlyReturn="nullptr"}} + {{>decode_value target="value" source="cppValue" cluster=parent.name depth=0 earlyReturn="nullptr"}} return value; } {{/zcl_attributes_server}} diff --git a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt index 9be7cfb69dcd39..2a77e14c42d1bb 100644 --- a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt +++ b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt @@ -45,7 +45,7 @@ JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase na std::vector> cleanupByteArrays; std::vector> cleanupStrings; - {{>encode_value target="cppValue" source="value" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>encode_value target="cppValue" source="value" cluster=parent.name depth=0}} std::unique_ptr onSuccess(Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); diff --git a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt index 58554412612858..a9e78ba6590ff8 100644 --- a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt +++ b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt @@ -51,7 +51,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } {{#zcl_event_fields}} - {{>decode_value target=(concat "value_" (asLowerCamelCase name)) source=(concat "cppValue." (asLowerCamelCase name)) cluster=(asUpperCamelCase parent.parent.name) depth=0 earlyReturn="nullptr"}} + {{>decode_value target=(concat "value_" (asLowerCamelCase name)) source=(concat "cppValue." (asLowerCamelCase name)) cluster=parent.parent.name depth=0 earlyReturn="nullptr"}} {{/zcl_event_fields}} jclass {{asLowerCamelCase name}}StructClass; diff --git a/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt b/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt index 9f4d999174ce21..29a6769214ee7e 100644 --- a/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt +++ b/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt @@ -64,7 +64,7 @@ void CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callbac VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); {{#zcl_command_arguments}} - {{>decode_value source=(concat "dataResponse." (asLowerCamelCase name)) target=(asSymbol label) cluster=(asUpperCamelCase parent.parent.name) depth=0}} + {{>decode_value source=(concat "dataResponse." (asLowerCamelCase name)) target=(asSymbol label) cluster=parent.parent.name depth=0}} {{/zcl_command_arguments}} env->CallVoidMethod(javaCallbackRef, javaMethod{{#zcl_command_arguments}}, {{asSymbol label}}{{/zcl_command_arguments}}); diff --git a/src/controller/java/templates/CHIPReadCallbacks-src.zapt b/src/controller/java/templates/CHIPReadCallbacks-src.zapt index 60bc0b09447780..5a643e5369079d 100644 --- a/src/controller/java/templates/CHIPReadCallbacks-src.zapt +++ b/src/controller/java/templates/CHIPReadCallbacks-src.zapt @@ -139,7 +139,7 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - {{>decode_value source="list" target="arrayListObj" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>decode_value source="list" target="arrayListObj" cluster=parent.name depth=0}} env->ExceptionClear(); env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); @@ -165,7 +165,7 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "({{#if isArray}}{{else if isStruct}}{{else if isOptional}}Ljava/util/Optional;{{else if (isOctetString type)}}[B{{else if (isCharString type)}}Ljava/lang/String;{{else}}{{asJniSignatureBasic type true}}{{/if}})V", &javaMethod); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - {{>decode_value source="value" target="javaValue" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>decode_value source="value" target="javaValue" cluster=parent.name depth=0}} env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); } diff --git a/src/controller/java/templates/partials/decode_value.zapt b/src/controller/java/templates/partials/decode_value.zapt index d1c51b5edeee33..8837a43711e578 100644 --- a/src/controller/java/templates/partials/decode_value.zapt +++ b/src/controller/java/templates/partials/decode_value.zapt @@ -27,32 +27,32 @@ if ({{source}}.IsNull()) { } {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>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_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} jclass {{asLowerCamelCase type}}StructClass_{{depth}}; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}}); + err = chip::JniReferences::GetInstance().GetClassRef(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${{cluster}}Cluster{{asUpperCamelCase type}}"); + ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}"); return {{earlyReturn}}; } jmethodID {{asLowerCamelCase type}}StructCtor_{{depth}} = env->GetMethodID({{asLowerCamelCase type}}StructClass_{{depth}}, "" - , "({{#zcl_struct_items_by_struct_name type}}{{asJniSignature type null ../cluster true}}{{/zcl_struct_items_by_struct_name}})V"); + , "({{#zcl_struct_items_by_struct_and_cluster_name type cluster}}{{asJniSignature type null (asUpperCamelCase ../cluster) true}}{{/zcl_struct_items_by_struct_and_cluster_name}})V"); if ({{asLowerCamelCase type}}StructCtor_{{depth}} == nullptr) { - ChipLogError(Zcl, "Could not find ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}} constructor"); + ChipLogError(Zcl, "Could not find ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} constructor"); return {{earlyReturn}}; } {{target}} = env->NewObject({{asLowerCamelCase type}}StructClass_{{depth}}, {{asLowerCamelCase type}}StructCtor_{{depth}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} , {{../target}}_{{asLowerCamelCase label}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} ); {{else}} {{#if_is_strongly_typed_chip_enum type}} - std::string {{target}}ClassName = "{{asJniClassName type null cluster}}"; - std::string {{target}}CtorSignature = "({{asJniSignature type null cluster false}})V"; + std::string {{target}}ClassName = "{{asJniClassName type null (asUpperCamelCase cluster)}}"; + std::string {{target}}CtorSignature = "({{asJniSignature type null (asUpperCamelCase cluster) false}})V"; chip::JniReferences::GetInstance().CreateBoxedObject<{{asUnderlyingBasicType type}}>({{target}}ClassName.c_str(), {{target}}CtorSignature.c_str(), static_cast<{{asUnderlyingBasicType type}}>({{source}}), {{target}}); {{else}} {{#if (isOctetString type)}} @@ -62,8 +62,8 @@ if ({{source}}.IsNull()) { {{else if (isCharString type)}} LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF({{source}}, {{target}})); {{else}} - std::string {{target}}ClassName = "{{asJniClassName type null cluster}}"; - std::string {{target}}CtorSignature = "({{asJniSignature type null cluster false}})V"; + std::string {{target}}ClassName = "{{asJniClassName type null (asUpperCamelCase cluster)}}"; + std::string {{target}}CtorSignature = "({{asJniSignature type null (asUpperCamelCase cluster) false}})V"; {{#if_is_strongly_typed_bitmap type}} chip::JniReferences::GetInstance().CreateBoxedObject<{{asUnderlyingBasicType type}}>({{target}}ClassName.c_str(), {{target}}CtorSignature.c_str(), {{source}}.Raw(), {{target}}); {{else}} diff --git a/src/controller/java/templates/partials/encode_value.zapt b/src/controller/java/templates/partials/encode_value.zapt index 181688acb2c6f0..8540e487d9ca58 100644 --- a/src/controller/java/templates/partials/encode_value.zapt +++ b/src/controller/java/templates/partials/encode_value.zapt @@ -42,11 +42,11 @@ {{target}} = cleanupStrings.back()->charSpan(); {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} jobject {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}; - chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null ../cluster true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); + chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null (asUpperCamelCase ../cluster) true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "_" (asLowerCamelCase label) "Item_" ../depth) cluster=../cluster depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_chip_enum type}} {{target}} = static_cast>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}})); diff --git a/src/controller/python/templates/python-CHIPClusters-py.zapt b/src/controller/python/templates/python-CHIPClusters-py.zapt index 4b1443e7211de4..9917fecb1ba5b2 100644 --- a/src/controller/python/templates/python-CHIPClusters-py.zapt +++ b/src/controller/python/templates/python-CHIPClusters-py.zapt @@ -27,11 +27,11 @@ class ChipClusters: "args": { {{#zcl_command_arguments}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} - "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../id}}{{/if}}", - {{/zcl_struct_items_by_struct_name}} + {{#zcl_struct_items_by_struct_and_cluster_name type ../../name}} + "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../../id}}{{/if}}", + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} - "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../id}}{{/if}}", + "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../id}}{{/if}}", {{/if_is_struct}} {{/zcl_command_arguments}} }, diff --git a/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt b/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt index 50477cd01d70a4..29e64683ba5062 100644 --- a/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt @@ -29,9 +29,9 @@ {{else}} {{#if_is_struct type}} {{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decode_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster errorCode=../errorCode depth=(incrementDepth ../depth) }} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; diff --git a/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt b/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt index 0c54e8124e19a1..79d38dc87f3c91 100644 --- a/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt @@ -45,9 +45,9 @@ {{target}} = [self asCharSpan:{{source}}]; {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "." (asStructPropertyName label)) cluster=../cluster errorCode=../errorCode depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = static_cast>({{source}}.{{asObjectiveCNumberType source type true}}Value);