Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing stateful helpers with stateless helpers #25850

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions examples/chip-tool/templates/logging/DataModelLogger-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const {{
{{/zcl_events}}
{{/zcl_clusters}}

{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#zcl_commands_source_server}}
CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const {{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType & value)
{
Expand All @@ -58,7 +58,7 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const {{
return CHIP_NO_ERROR;
}
{{/zcl_commands_source_server}}
{{/chip_client_clusters}}
{{/all_user_clusters}}

CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader * data)
{
Expand All @@ -67,7 +67,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP

switch (path.mClusterId)
{
{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#zcl_attributes_server}}
{{#first}}
case {{asUpperCamelCase parent.name}}::Id:
Expand All @@ -87,7 +87,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP
}
{{/last}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
default:
break;
}
Expand All @@ -102,7 +102,7 @@ CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & pa

switch (path.mClusterId)
{
{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#zcl_commands_source_server}}
{{#first}}
case {{asUpperCamelCase parent.name}}::Id:
Expand All @@ -122,7 +122,7 @@ CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & pa
}
{{/last}}
{{/zcl_commands_source_server}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
default:
break;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip

switch (header.mPath.mClusterId)
{
{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#chip_server_cluster_events}}
{{#first}}
case {{asUpperCamelCase parent.name}}::Id:
Expand All @@ -178,7 +178,7 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip
}
{{/last}}
{{/chip_server_cluster_events}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions examples/chip-tool/templates/logging/DataModelLogger.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::C
{{/zcl_events}}
{{/zcl_clusters}}

{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#zcl_commands_source_server}}
static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType & value);
{{/zcl_commands_source_server}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
58 changes: 31 additions & 27 deletions examples/darwin-framework-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,30 @@

{{> clusters_header}}

{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
{{> cluster_header}}

{{#chip_cluster_commands}}
{{#unless (wasRemoved (asUpperCamelCase clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
{{#zcl_commands}}
{{#if (is_str_equal source 'client')}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
/*
* Command {{asUpperCamelCase name}}
*/
class {{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}: public ClusterCommand
class {{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public ClusterCommand
{
public:
{{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}}
{{asUpperCamelCase parent.name}}{{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}}
{{#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}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &mRequest.{{asLowerCamelCase label}});
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
{{/zcl_command_arguments}}
ClusterCommand::AddArguments();
}

Expand All @@ -48,19 +49,19 @@ public:
ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) command ({{asHex code 8}}) on endpoint %u", endpointId);

dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL);
__auto_type * cluster = [[MTRBaseCluster{{asUpperCamelCase clusterName preserveAcronyms=true}} alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue];
__auto_type * params = [[MTR{{asUpperCamelCase clusterName preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params alloc] init];
__auto_type * cluster = [[MTRBaseCluster{{asUpperCamelCase parent.name preserveAcronyms=true}} alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue];
__auto_type * params = [[MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Params alloc] init];
params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil;
{{#chip_cluster_command_arguments}}
{{>decodable_value target=(concat "params." (asStructPropertyName label)) source=(concat "mRequest." (asLowerCamelCase label)) cluster=parent.clusterName type=type depth=0}}
{{/chip_cluster_command_arguments}}
{{#zcl_command_arguments}}
{{>decodable_value target=(concat "params." (asStructPropertyName label)) source=(concat "mRequest." (asLowerCamelCase label)) cluster=parent.parent.name type=type depth=0}}
{{/zcl_command_arguments}}
uint16_t repeatCount = mRepeatCount.ValueOr(1);
uint16_t __block responsesNeeded = repeatCount;
while (repeatCount--)
{
[cluster {{asLowerCamelCase name}}WithParams:params completion:
{{#if hasSpecificResponse}}
^(MTR{{asUpperCamelCase clusterName preserveAcronyms=true}}Cluster{{asUpperCamelCase responseName}}Params * _Nullable values, NSError * _Nullable error) {
^(MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase responseName}}Params * _Nullable values, NSError * _Nullable error) {
NSLog(@"Values: %@", values);
{{else}}
^(NSError * _Nullable error) {
Expand All @@ -79,18 +80,19 @@ public:
}

private:
{{#if (hasArguments)}}
chip::app::Clusters::{{asUpperCamelCase clusterName}}::Commands::{{asUpperCamelCase name}}::Type mRequest;
{{#if hasArguments}}
chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::Type mRequest;
{{/if}}
{{#chip_cluster_command_arguments}}
{{#zcl_command_arguments}}
{{#if_chip_complex}}
TypedComplexArgument<{{zapTypeToEncodableClusterObjectType type ns=parent.parent.name}}> mComplex_{{asUpperCamelCase label}};
{{/if_chip_complex}}
{{/chip_cluster_command_arguments}}
{{/zcl_command_arguments}}
};

{{/unless}}
{{/chip_cluster_commands}}
{{/if}}
{{/zcl_commands}}

{{#zcl_attributes_server removeKeys='isOptional'}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
Expand Down Expand Up @@ -248,12 +250,12 @@ public:
{{/unless}}
{{/zcl_attributes_server}}
{{/unless}}
{{/chip_client_clusters}}
{{/all_user_clusters}}

/*----------------------------------------------------------------------------*\
| Register all Clusters commands |
\*----------------------------------------------------------------------------*/
{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
void registerCluster{{asUpperCamelCase name}}(Commands & commands)
{
Expand All @@ -263,11 +265,13 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)

commands_list clusterCommands = {
make_unique<ClusterCommand>(Id), //
{{#chip_cluster_commands}}
{{#unless (wasRemoved (asUpperCamelCase clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
make_unique<{{asUpperCamelCase clusterName}}{{asUpperCamelCase name}}>(), //
{{#zcl_commands}}
{{#if (is_str_equal source 'client')}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
make_unique<{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/unless}}
{{/chip_cluster_commands}}
{{/if}}
{{/zcl_commands}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#first}}
make_unique<ReadAttribute>(Id), //
Expand Down Expand Up @@ -303,7 +307,7 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)
commands.Register(clusterName, clusterCommands);
}
{{/unless}}
{{/chip_client_clusters}}
{{/all_user_clusters}}

void registerClusterAny(Commands & commands)
{
Expand All @@ -325,9 +329,9 @@ void registerClusterAny(Commands & commands)
void registerClusters(Commands & commands)
{
registerClusterAny(commands);
{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
registerCluster{{asUpperCamelCase name}}(commands);
{{/unless}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
}
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:2@v2023.03.27-nightly.1"]
"tags": ["version:2@v2023.03.30-nightly.1"]
}
]
}
2 changes: 1 addition & 1 deletion scripts/tools/sdk.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"meta": {
"sdkRoot": "../..",
"description": "Matter SDK",
"requiredFeatureLevel": 77
"requiredFeatureLevel": 95
},
"zcl": {
"main": "src/app/zap-templates/zcl/zcl.json",
Expand Down
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
4 changes: 2 additions & 2 deletions src/app/zap-templates/templates/app/CHIPClientCallbacks.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
#include <lib/support/Span.h>

// List specific responses
{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if isArray}}
typedef void (*{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}ListAttributeCallback)(void * context, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true}} data);
{{/if}}
{{/zcl_attributes_server}}
{{/chip_client_clusters}}
{{/all_user_clusters}}

{{/if}}
4 changes: 2 additions & 2 deletions src/app/zap-templates/templates/app/CHIPClusters.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
namespace chip {
namespace Controller {

{{#chip_client_clusters}}
{{#all_user_clusters side='client'}}
class DLL_EXPORT {{asUpperCamelCase name}}Cluster : public ClusterBase
{
public:
{{asUpperCamelCase name}}Cluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, EndpointId endpoint) : ClusterBase(exchangeManager, session, endpoint) {}
~{{asUpperCamelCase name}}Cluster() {}
};

{{/chip_client_clusters}}
{{/all_user_clusters}}
} // namespace Controller
} // namespace chip
{{/if}}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader &
{
switch (aPath.mClusterId)
{
{{#chip_client_clusters includeAll=true}}
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
case Clusters::{{asUpperCamelCase name}}::Id: {
using namespace Clusters::{{asUpperCamelCase name}};
Expand Down Expand Up @@ -47,7 +47,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader &
break;
}
{{/unless}}
{{/chip_client_clusters}}
{{/all_user_clusters}}
default: {
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
Expand Down
Loading