Skip to content

Commit

Permalink
Deprecating Stateful Helpers (#25883)
Browse files Browse the repository at this point in the history
* Replacing chip_client_clusters, chip_cluster_commands, chip_cluster_responses and chip_cluster_command_arguments with all_user_clusters, zcl_commands, zcl_command_responses and zcl_command_arguments respectively in templates
- Updating minimum zap vesion
- Github: ZAP#971

* Using all_user_cluster_generated_commands instead of zcl_commands
Github: ZAP#971

* updating minimum version of zap
Github: ZAP#971
  • Loading branch information
brdandu authored and pull[bot] committed Feb 12, 2024
1 parent c9a155e commit 2417144
Show file tree
Hide file tree
Showing 14 changed files with 110 additions and 80 deletions.
2 changes: 1 addition & 1 deletion integrations/docker/images/chip-cert-bins/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.03.27-nightly
ARG ZAP_VERSION=v2023.03.30-nightly

# Ensure TARGETPLATFORM is set
RUN case ${TARGETPLATFORM} in \
Expand Down
2 changes: 1 addition & 1 deletion scripts/setup/zap.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"mac-arm64",
"windows-amd64"
],
"tags": ["version:[email protected].27-nightly.1"]
"tags": ["version:[email protected].30-nightly.1"]
}
]
}
2 changes: 1 addition & 1 deletion scripts/tools/zap/zap_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.27'
MIN_ZAP_VERSION = '2023.3.30'


class ZapTool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR

switch (aPath.mClusterId)
{
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
case app::Clusters::{{asUpperCamelCase name}}::Id: {
using namespace app::Clusters::{{asUpperCamelCase name}};
switch (aPath.mAttributeId)
Expand All @@ -61,7 +61,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR
}
break;
}
{{/chip_client_clusters}}
{{/all_user_clusters}}
default:
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/controller/java/templates/CHIPClustersWrite-JNI.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
using namespace chip;
using namespace chip::Controller;

{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if_unsupported_attribute_callback type isArray ../id}}
{{else}}
Expand Down Expand Up @@ -77,7 +77,7 @@ JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase na
{{/if}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
{{/if}}

#pragma clang diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader &

switch (aPath.mClusterId)
{
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
case app::Clusters::{{asUpperCamelCase name}}::Id: {
using namespace app::Clusters::{{asUpperCamelCase name}};
switch (aPath.mEventId)
Expand Down Expand Up @@ -82,7 +82,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader &
}
break;
}
{{/chip_client_clusters}}
{{/all_user_clusters}}
default:
*aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB;
break;
Expand Down
4 changes: 2 additions & 2 deletions src/controller/java/templates/CHIPReadCallbacks-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void CHIP{{chipCallback.name}}AttributeCallback::CallbackFn(void * context, {{ch
{{/unless}}
{{/chip_server_global_responses}}

{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{! TODO: Add support for struct-typed attributes }}
{{#if_unsupported_attribute_callback type isArray ../id}}
Expand Down Expand Up @@ -173,6 +173,6 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb
{{/if}}
{{/if_unsupported_attribute_callback}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}
{{/all_user_clusters}}

{{/if}}
40 changes: 26 additions & 14 deletions src/controller/java/templates/ChipClusters-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class ChipClusters {
}
}

{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
public static class {{asUpperCamelCase name}}Cluster extends BaseChipCluster {
public static final long CLUSTER_ID = {{code}}L;

Expand All @@ -112,34 +112,46 @@ public class ChipClusters {

@Override
public native long initWithDevice(long devicePtr, int endpointId);
{{#chip_cluster_commands}}
{{#all_user_cluster_generated_commands}}
{{#if_compare clusterId ../id operator='=='}}
{{#if (is_str_equal commandSource 'client')}}

{{#unless mustUseTimedInvoke}}
public void {{asLowerCamelCase name}}({{#if hasSpecificResponse}}{{asUpperCamelCase responseName}}Callback{{else}}DefaultClusterCallback{{/if}} callback
{{#chip_cluster_command_arguments}}, {{asJavaType type chipType parent.parent.name includeAnnotations=true}} {{asLowerCamelCase label}}{{/chip_cluster_command_arguments}}) {
{{asLowerCamelCase name}}(chipClusterPtr, callback{{#chip_cluster_command_arguments}}, {{asLowerCamelCase label}}{{/chip_cluster_command_arguments}}, null);
{{#zcl_command_arguments}}, {{asJavaType type chipType parent.parent.name includeAnnotations=true clusterId=parent.parent.id}} {{asLowerCamelCase label}}{{/zcl_command_arguments}}) {
{{asLowerCamelCase name}}(chipClusterPtr, callback{{#zcl_command_arguments}}, {{asLowerCamelCase label}}{{/zcl_command_arguments}}, null);
}
{{/unless}}

public void {{asLowerCamelCase name}}({{#if hasSpecificResponse}}{{asUpperCamelCase responseName}}Callback{{else}}DefaultClusterCallback{{/if}} callback
{{#chip_cluster_command_arguments}}, {{asJavaType type chipType parent.parent.name includeAnnotations=true}} {{asLowerCamelCase label}}{{/chip_cluster_command_arguments}}
{{#zcl_command_arguments}}, {{asJavaType type chipType parent.parent.name includeAnnotations=true clusterId=parent.parent.id}} {{asLowerCamelCase label}}{{/zcl_command_arguments}}
, int timedInvokeTimeoutMs) {
{{asLowerCamelCase name}}(chipClusterPtr, callback{{#chip_cluster_command_arguments}}, {{asLowerCamelCase label}}{{/chip_cluster_command_arguments}}, timedInvokeTimeoutMs);
{{asLowerCamelCase name}}(chipClusterPtr, callback{{#zcl_command_arguments}}, {{asLowerCamelCase label}}{{/zcl_command_arguments}}, timedInvokeTimeoutMs);
}
{{/chip_cluster_commands}}
{{#chip_cluster_commands}}
{{/if}}
{{/if_compare}}
{{/all_user_cluster_generated_commands}}
{{#all_user_cluster_generated_commands}}
{{#if_compare clusterId ../id operator='=='}}
{{#if (is_str_equal commandSource 'client')}}
private native void {{asLowerCamelCase name}}(long chipClusterPtr, {{#if hasSpecificResponse}}{{asUpperCamelCase responseName}}Callback{{else}}DefaultClusterCallback{{/if}} Callback
{{#chip_cluster_command_arguments}}, {{asJavaType type chipType parent.parent.name includeAnnotations=true}} {{asLowerCamelCase label}}{{/chip_cluster_command_arguments}}
{{#zcl_command_arguments}}, {{asJavaType type chipType parent.parent.name includeAnnotations=true clusterId=parent.parent.id}} {{asLowerCamelCase label}}{{/zcl_command_arguments}}
, @Nullable Integer timedInvokeTimeoutMs);
{{/chip_cluster_commands}}
{{#chip_cluster_responses}}
{{/if}}
{{/if_compare}}
{{/all_user_cluster_generated_commands}}
{{#all_user_cluster_generated_commands}}
{{#if_compare clusterId ../id operator='=='}}
{{#if (is_str_equal commandSource 'server')}}
public interface {{asUpperCamelCase name}}Callback {
void onSuccess({{#chip_cluster_response_arguments}}{{#not_first}}, {{/not_first}}{{asJavaType type chipType parent.parent.name includeAnnotations=true}} {{asLowerCamelCase label}}{{/chip_cluster_response_arguments}});
void onSuccess({{#zcl_command_arguments}}{{#not_first}}, {{/not_first}}{{asJavaType type chipType parent.parent.name includeAnnotations=true clusterId=parent.parent.id}} {{asLowerCamelCase label}}{{/zcl_command_arguments}});

void onError(Exception error);
}

{{/chip_cluster_responses}}
{{/if}}
{{/if_compare}}
{{/all_user_cluster_generated_commands}}

{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if_unsupported_attribute_callback type isArray ../id}}
Expand Down Expand Up @@ -233,6 +245,6 @@ public class ChipClusters {
{{#not_last}}

{{/not_last}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
}
{{/if}}
4 changes: 2 additions & 2 deletions src/controller/java/templates/ChipEventStructs-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.Optional;
{{! TODO: Use AutoValue for inner classes. }}
public class ChipEventStructs {
{{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
{{#zcl_events}}
public static class {{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Event {
{{#zcl_event_fields}}
Expand Down Expand Up @@ -54,6 +54,6 @@ public {{asJavaType type null parent.parent.name includeAnnotations=true}} {{asL
}

{{/zcl_events}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
{{/if}}
}
12 changes: 6 additions & 6 deletions src/controller/java/templates/ChipIdLookup-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public final class ChipIdLookup {
* ID is found, returns an empty string.
*/
public static String clusterIdToName(long clusterId) {
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
if (clusterId == {{code}}L) {
return "{{asUpperCamelCase name}}";
}
{{/chip_client_clusters}}
{{/all_user_clusters}}
return "";
}

Expand All @@ -22,7 +22,7 @@ public final class ChipIdLookup {
* If no matching IDs are found, returns an empty string.
*/
public static String attributeIdToName(long clusterId, long attributeId) {
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
if (clusterId == {{code}}L) {
{{#zcl_attributes_server}}
if (attributeId == {{code}}L) {
Expand All @@ -31,7 +31,7 @@ public final class ChipIdLookup {
{{/zcl_attributes_server}}
return "";
}
{{/chip_client_clusters}}
{{/all_user_clusters}}
return "";
}

Expand All @@ -40,7 +40,7 @@ public final class ChipIdLookup {
* If no matching IDs are found, returns an empty string.
*/
public static String eventIdToName(long clusterId, long eventId) {
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
if (clusterId == {{code}}L) {
{{#chip_server_cluster_events}}
if (eventId == {{code}}L) {
Expand All @@ -49,7 +49,7 @@ public final class ChipIdLookup {
{{/chip_server_cluster_events}}
return "";
}
{{/chip_client_clusters}}
{{/all_user_clusters}}
return "";
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/controller/java/templates/ChipStructs-java.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import java.util.Optional;
{{! TODO: Use AutoValue for inner classes. }}
public class ChipStructs {
{{#if (chip_has_client_clusters)}}
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
{{#zcl_structs}}
{{#if itemCnt}}
public static class {{asUpperCamelCase parent.name}}Cluster{{asUnderlyingType name}} {
Expand Down Expand Up @@ -52,6 +52,6 @@ public {{asJavaType type null parent.parent.name includeAnnotations=true}} {{asL
{{/if}}

{{/zcl_structs}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
{{/if}}
}
Loading

0 comments on commit 2417144

Please sign in to comment.