Skip to content

Commit

Permalink
Matter Cleanup for Chip Tool Repo (#22762)
Browse files Browse the repository at this point in the history
* Switching templates to generic zap helpers and avoiding helpers which are language specific and hard coded.

- The new helpers take the logic into the templates and can be used across different kinds of templates
- There are generation changes to structs which have multiple clusters. These now generate CHIP_ERROR per cluster instead of using detail. Need to validate if that is ok.
- updating the zap to point to the zap branch which has changes associated with this
- Github: ZAP#679

* Updating the zap templates with the updated helpers. Simplifying an overly complicated zap template in the previous commit
Github: ZAP#679

* Cleaning up a missed template change
Gihub: ZAP#679

* regening after rebase
Github: ZAP#679

* Updating the pointer to zap repo
Github: ZAP#679

* Moving the handlebar template complexity into the helper:

- Get rid of if_is_underlying_zcl_type_signed, if_is_float_or_double_data_type and as_underlying_zcl_type_size. Instead updating the functionality of asTypeMinValue and asTypeMaxValue into as_type_max_value and as_type_min_value
- Cleaning up the zap templates reflect the above.
- GIthub: ZAP#679

* Cleaning up typos
Github: ZAP#679

* Updating zap submodule
GIthub: ZAP#679

* updating the zap repo
Github: ZAP#679

* bumping the pointer to zap repo
Github:ZAP#679

* Updating the za[ repo
Github: ZAP#679

* Reverting the formatting on these files
Github: ZAP#679

* Updating the zap repo
Gihub: ZAP#679
  • Loading branch information
brdandu authored and pull[bot] committed Nov 23, 2022
1 parent baacbc8 commit 2069033
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions examples/chip-tool/templates/ComplexArgumentParser-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <commands/clusters/ComplexArgument.h>

{{#structs_with_cluster_name}}
CHIP_ERROR ComplexArgumentParser::Setup(const char * label, {{zapTypeToEncodableClusterObjectType name ns=clusterName}} & request, Json::Value & value)
{{#structs_with_clusters groupByStructName=1}}
CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request, Json::Value & value)
{
VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT);

Expand Down Expand Up @@ -38,11 +38,11 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, {{zapTypeToEncodable
return CHIP_NO_ERROR;
}

void ComplexArgumentParser::Finalize({{zapTypeToEncodableClusterObjectType name ns=clusterName}} & request)
void ComplexArgumentParser::Finalize(chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request)
{
{{#zcl_struct_items}}
ComplexArgumentParser::Finalize(request.{{asLowerCamelCase label}});
{{/zcl_struct_items}}
}
{{/structs_with_cluster_name}}
{{/structs_with_clusters}}

8 changes: 4 additions & 4 deletions examples/chip-tool/templates/ComplexArgumentParser.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <lib/core/CHIPError.h>
#include <app-common/zap-generated/cluster-objects.h>

{{#structs_with_cluster_name}}
static CHIP_ERROR Setup(const char * label, {{zapTypeToEncodableClusterObjectType name ns=clusterName}} & request, Json::Value & value);
{{#structs_with_clusters groupByStructName=1}}
static CHIP_ERROR Setup(const char * label, chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request, Json::Value & value);

static void Finalize({{zapTypeToEncodableClusterObjectType name ns=clusterName}} & request);
{{/structs_with_cluster_name}}
static void Finalize(chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request);
{{/structs_with_clusters}}
18 changes: 9 additions & 9 deletions examples/chip-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
class {{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public ClusterCommand
{
public:
{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(CredentialIssuerCommands * credsIssuerConfig): ClusterCommand("{{asDelimitedCommand name}}", credsIssuerConfig){{#zcl_command_arguments}}{{#if_chip_complex}}, mComplex_{{asUpperCamelCase label}}(&mRequest.{{asLowerCamelCase label}}){{/if_chip_complex}}{{/zcl_command_arguments}}
{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(CredentialIssuerCommands * credsIssuerConfig): ClusterCommand("{{cleanse_label_as_kebab_case name}}", credsIssuerConfig){{#zcl_command_arguments}}{{#if_chip_complex}}, mComplex_{{asUpperCamelCase label}}(&mRequest.{{asLowerCamelCase label}}){{/if_chip_complex}}{{/zcl_command_arguments}}
{
{{#zcl_command_arguments}}
{{#if_chip_complex}}
AddArgument("{{asUpperCamelCase label}}", &mComplex_{{asUpperCamelCase label}});
{{else if (isString type)}}
AddArgument("{{asUpperCamelCase label}}", &mRequest.{{asLowerCamelCase label}});
{{else}}
AddArgument("{{asUpperCamelCase label}}", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &mRequest.{{asLowerCamelCase label}});
AddArgument("{{asUpperCamelCase label}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &mRequest.{{asLowerCamelCase label}});
{{/if_chip_complex}}
{{/zcl_command_arguments}}
ClusterCommand::AddArguments();
Expand Down Expand Up @@ -89,7 +89,7 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands, CredentialIss
//
make_unique<ReadAttribute>(Id, credsIssuerConfig), //
{{#zcl_attributes_server}}
make_unique<ReadAttribute>(Id, "{{asDelimitedCommand (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
make_unique<ReadAttribute>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
{{! TODO: Remove after 1.0. See https://github.com/project-chip/connectedhomeip/issues/22341 }}
{{#if (isStrEqual (asUpperCamelCase name) "ColorTemperatureMireds")}}
make_unique<ReadAttribute>(Id, "color-temperature", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
Expand All @@ -103,18 +103,18 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands, CredentialIss
{{#zcl_attributes_server}}
{{#if isWritable}}
{{#if_chip_complex}}
make_unique<WriteAttributeAsComplex<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{asDelimitedCommand (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
make_unique<WriteAttributeAsComplex<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
{{else if (isString type)}}
make_unique<WriteAttribute<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{asDelimitedCommand (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
make_unique<WriteAttribute<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
{{else}}
make_unique<WriteAttribute<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{asDelimitedCommand (asUpperCamelCase name)}}", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
make_unique<WriteAttribute<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
{{/if_chip_complex}}
{{/if}}
{{/zcl_attributes_server}}
make_unique<SubscribeAttribute>(Id, credsIssuerConfig), //
{{#zcl_attributes_server}}
{{#if isReportable}}
make_unique<SubscribeAttribute>(Id, "{{asDelimitedCommand (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
make_unique<SubscribeAttribute>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
{{! TODO: Remove after 1.0. See https://github.com/project-chip/connectedhomeip/issues/22341 }}
{{#if (isStrEqual (asUpperCamelCase name) "ColorTemperatureMireds")}}
make_unique<SubscribeAttribute>(Id, "color-temperature", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
Expand All @@ -130,11 +130,11 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands, CredentialIss
//
make_unique<ReadEvent>(Id, credsIssuerConfig), //
{{#zcl_events}}
make_unique<ReadEvent>(Id, "{{asDelimitedCommand (asUpperCamelCase name)}}", Events::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
make_unique<ReadEvent>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Events::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
{{/zcl_events}}
make_unique<SubscribeEvent>(Id, credsIssuerConfig), //
{{#zcl_events}}
make_unique<SubscribeEvent>(Id, "{{asDelimitedCommand (asUpperCamelCase name)}}", Events::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
make_unique<SubscribeEvent>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Events::{{asUpperCamelCase name}}::Id, credsIssuerConfig), //
{{/zcl_events}}
};

Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/templates/logging/DataModelLogger-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

using namespace chip::app::Clusters;

{{#structs_with_cluster_name}}
CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, {{zapTypeToDecodableClusterObjectType name ns=clusterName isArgument=true}} value)
{{#structs_with_clusters groupByStructName=1}}
CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::DecodableType & value)
{
DataModelLogger::LogString(label, indent, "{");
{{#zcl_struct_items}}
Expand All @@ -22,7 +22,7 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, {{zapTyp

return CHIP_NO_ERROR;
}
{{/structs_with_cluster_name}}
{{/structs_with_clusters}}

{{#zcl_clusters}}
{{#zcl_events}}
Expand Down
6 changes: 3 additions & 3 deletions examples/chip-tool/templates/logging/DataModelLogger.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
#include <lib/core/CHIPError.h>
#include <app-common/zap-generated/cluster-objects.h>

{{#structs_with_cluster_name}}
static CHIP_ERROR LogValue(const char * label, size_t indent, {{zapTypeToDecodableClusterObjectType name ns=clusterName isArgument=true}} value);
{{/structs_with_cluster_name}}
{{#structs_with_clusters groupByStructName=1}}
static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::DecodableType & value);
{{/structs_with_clusters}}

{{#zcl_clusters}}
{{#zcl_events}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public:
{{#if (isString type)}}
AddArgument("{{name}}", &m{{asUpperCamelCase name}});
{{else}}
AddArgument("{{name}}", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &m{{asUpperCamelCase name}});
AddArgument("{{name}}",{{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &m{{asUpperCamelCase name}});
{{/if}}
{{/chip_tests_config}}
}
Expand Down
14 changes: 7 additions & 7 deletions examples/darwin-framework-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
class {{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}: public ClusterCommand
{
public:
{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}(): ClusterCommand("{{asDelimitedCommand name}}"){{#zcl_command_arguments}}{{#if_chip_complex}}, mComplex_{{asUpperCamelCase label}}(&mRequest.{{asLowerCamelCase label}}){{/if_chip_complex}}{{/zcl_command_arguments}}
{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}(): ClusterCommand("{{cleanse_label_as_kebab_case name}}"){{#zcl_command_arguments}}{{#if_chip_complex}}, mComplex_{{asUpperCamelCase label}}(&mRequest.{{asLowerCamelCase label}}){{/if_chip_complex}}{{/zcl_command_arguments}}
{
{{#chip_cluster_command_arguments}}
{{#if_chip_complex}}
AddArgument("{{asUpperCamelCase label}}", &mComplex_{{asUpperCamelCase label}});
{{else if (isString type)}}
AddArgument("{{asUpperCamelCase label}}", &mRequest.{{asLowerCamelCase label}});
{{else}}
AddArgument("{{asUpperCamelCase label}}", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &mRequest.{{asLowerCamelCase label}});
AddArgument("{{asUpperCamelCase label}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &mRequest.{{asLowerCamelCase label}});
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
ClusterCommand::AddArguments();
Expand Down Expand Up @@ -99,7 +99,7 @@ private:
class Read{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public ReadAttribute
{
public:
Read{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): ReadAttribute("{{asDelimitedCommand (asUpperCamelCase name)}}")
Read{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): ReadAttribute("{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}")
{
}

Expand Down Expand Up @@ -143,15 +143,15 @@ public:
class Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public WriteAttribute
{
public:
Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): WriteAttribute("{{asDelimitedCommand (asUpperCamelCase name)}}"){{#if_chip_complex}}, mComplex(&mValue){{/if_chip_complex}}
Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): WriteAttribute("{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}"){{#if_chip_complex}}, mComplex(&mValue){{/if_chip_complex}}
{
AddArgument("attr-name", "{{asDelimitedCommand (asUpperCamelCase name)}}");
AddArgument("attr-name", "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}");
{{#if_chip_complex}}
AddArgument("attr-value", &mComplex);
{{else if (isString type)}}
AddArgument("attr-value", &mValue);
{{else}}
AddArgument("attr-value", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &mValue);
AddArgument("attr-value", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &mValue);
{{/if_chip_complex}}
WriteAttribute::AddArguments();
}
Expand Down Expand Up @@ -206,7 +206,7 @@ private:
class SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public SubscribeAttribute
{
public:
SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): SubscribeAttribute("{{asDelimitedCommand (asUpperCamelCase name)}}")
SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(): SubscribeAttribute("{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}")
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class {{filename}}: public TestCommandBridge
{{#if (isString type)}}
AddArgument("{{name}}", &m{{asUpperCamelCase name}});
{{else}}
AddArgument("{{name}}", {{asTypeMinValue type}}, {{asTypeMaxValue type}}, &m{{asUpperCamelCase name}});
AddArgument("{{name}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &m{{asUpperCamelCase name}});
{{/if}}
{{/chip_tests_config}}
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/zap/repo
Submodule repo updated 50 files
+1 −1 apack.json
+4 −3 cypress/integration/clusters/cluster-filter.spec.js
+2 −2 cypress/integration/clusters/dimmable-light.spec.js
+174 −40,451 package-lock.json
+15 −9 package.json
+2 −0 src-electron/db/db-mapping.js
+8 −10 src-electron/db/query-package.js
+49 −0 src-electron/db/query-struct.js
+2 −0 src-electron/db/query-zcl.js
+4 −2 src-electron/generator/helper-c.js
+197 −0 src-electron/generator/helper-zcl.js
+17 −7 src-electron/generator/helper-zigbee-zcl.js
+18 −4 src-electron/generator/matter/chip-tool/templates/helper.js
+56 −26 src-electron/importexport/import-json.js
+1 −1 src-electron/rest/static-zcl.js
+2 −2 src-electron/server/ipc-server.ts
+6 −4 src-electron/util/args.ts
+4 −10 src-electron/util/env.ts
+20 −2 src-electron/zcl/zcl-loader-silabs.js
+16 −10 src-script/script-util.js
+5 −39 src-script/zap-convert.js
+6 −10 src-script/zap-generate.js
+7 −3 src-script/zap-start.js
+7 −5 src-script/zap-update-package-version.js
+5 −0 src/App.vue
+1 −1 src/components/ZclAttributeManager.vue
+1 −1 src/components/ZclAttributeReportingManager.vue
+20 −4 src/components/ZclClusterManager.vue
+17 −3 src/components/ZclClusterView.vue
+1 −1 src/components/ZclCommandManager.vue
+54 −39 src/components/ZclCreateModifyEndpoint.vue
+5 −4 src/components/ZclCustomZclView.vue
+12 −1 src/components/ZclDomainClusterView.vue
+1 −0 src/components/ZclEndpointCard.vue
+17 −6 src/components/ZclEndpointManager.vue
+11 −0 src/layouts/ZclConfiguratorLayout.vue
+11 −4 src/layouts/ZclLayout.vue
+2 −0 src/router/routes.js
+3 −1 src/store/index.js
+4 −3 src/store/zap/actions.js
+47 −10 src/store/zap/mutations.js
+11 −1 src/store/zap/state.js
+366 −0 src/tutorials/VueTour.vue
+166 −0 src/tutorials/tutorialConfig.json
+8 −0 test/gen-matter.test.js
+7 −0 test/gen-template/matter/chip-tool-helpers.zapt
+5 −0 test/gen-template/matter/gen-test.json
+107 −0 test/gen-zigbee-2.test.js
+3,907 −0 test/resource/zap-file-with-custom-xml.zap
+1 −1 test/test-util.js

0 comments on commit 2069033

Please sign in to comment.