Skip to content

Commit

Permalink
Switch from wasRemoved to isSupported for Darwin codegen. (#26146)
Browse files Browse the repository at this point in the history
* Update ZAP to v2023.04.18-nightly to pick up isSupported.

* Switch from wasRemoved to isSupported for Darwin codegen.

isSupported allows things to be marked as "provisional", which unlike "removed"
can be overridden by a later "introduced" annotation.

* Stop depending on controller-clusters.zap state entirely, now that we can.
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 29, 2023
1 parent 7d5e5c9 commit 1461282
Show file tree
Hide file tree
Showing 20 changed files with 277 additions and 257 deletions.
48 changes: 24 additions & 24 deletions examples/darwin-framework-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

{{> clusters_header}}

{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
{{#zcl_clusters}}
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
{{> cluster_header}}

{{#zcl_commands}}
{{#if (is_str_equal source 'client')}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
/*
* Command {{asUpperCamelCase name}}
*/
Expand Down Expand Up @@ -90,12 +90,12 @@ private:
{{/zcl_command_arguments}}
};

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

{{#zcl_attributes_server removeKeys='isOptional'}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#*inline "cluster"}}Cluster{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}}
{{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}}

Expand Down Expand Up @@ -247,16 +247,16 @@ public:
};

{{/if}}
{{/unless}}
{{/if}}
{{/zcl_attributes_server}}
{{/unless}}
{{/all_user_clusters}}
{{/if}}
{{/zcl_clusters}}

/*----------------------------------------------------------------------------*\
| Register all Clusters commands |
\*----------------------------------------------------------------------------*/
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
{{#zcl_clusters}}
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
void registerCluster{{asUpperCamelCase name}}(Commands & commands)
{
using namespace chip::app::Clusters::{{asUpperCamelCase name}};
Expand All @@ -267,34 +267,34 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)
make_unique<ClusterCommand>(Id), //
{{#zcl_commands}}
{{#if (is_str_equal source 'client')}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
make_unique<{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/unless}}
{{/if}}
{{/if}}
{{/zcl_commands}}
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#first}}
make_unique<ReadAttribute>(Id), //
{{/first}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
make_unique<Read{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/unless}}
{{/if}}
{{#first}}
make_unique<WriteAttribute>(Id), //
{{/first}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if isWritableAttribute}}
make_unique<Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/if}}
{{/unless}}
{{/if}}
{{#first}}
make_unique<SubscribeAttribute>(Id), //
{{/first}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if isReportableAttribute}}
make_unique<SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/if}}
{{/unless}}
{{/if}}
{{/zcl_attributes_server}}
{{#zcl_events}}
{{#first}}
Expand All @@ -306,8 +306,8 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)

commands.Register(clusterName, clusterCommands);
}
{{/unless}}
{{/all_user_clusters}}
{{/if}}
{{/zcl_clusters}}

void registerClusterAny(Commands & commands)
{
Expand All @@ -329,9 +329,9 @@ void registerClusterAny(Commands & commands)
void registerClusters(Commands & commands)
{
registerClusterAny(commands);
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
{{#zcl_clusters}}
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
registerCluster{{asUpperCamelCase name}}(commands);
{{/unless}}
{{/all_user_clusters}}
{{/if}}
{{/zcl_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.04.05-nightly
ARG ZAP_VERSION=v2023.04.18-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.04.05-nightly.1"]
"tags": ["version:2@v2023.04.18-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.4.5'
MIN_ZAP_VERSION = '2023.4.18'


class ZapTool:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader &
{
switch (aPath.mClusterId)
{
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
{{#zcl_clusters}}
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
case Clusters::{{asUpperCamelCase name}}::Id: {
using namespace Clusters::{{asUpperCamelCase name}};
switch (aPath.mAttributeId)
{
{{#zcl_attributes_server removeKeys='isOptional'}}
{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
case Attributes::{{asUpperCamelCase name}}::Id: {
using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo;
TypeInfo::DecodableType cppValue;
Expand All @@ -38,16 +38,16 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader &
{{>decode_value target="value" source="cppValue" cluster=parent.name errorCode="*aError = err; return nil;" depth=0}}
return value;
}
{{/unless}}
{{/if}}
{{/zcl_attributes_server}}
default:
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
}
break;
}
{{/unless}}
{{/all_user_clusters}}
{{/if}}
{{/zcl_clusters}}
default: {
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
Expand Down
38 changes: 19 additions & 19 deletions src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ using chip::System::Clock::Timeout;
using chip::System::Clock::Seconds16;

// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects.
{{#all_user_clusters side='client'}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
{{#zcl_clusters}}
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
@implementation MTRBaseCluster{{asUpperCamelCase name preserveAcronyms=true}}

- (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
Expand All @@ -50,15 +50,15 @@ using chip::System::Clock::Seconds16;
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
{{#*inline "commandImpl"}}
{{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }}
{{#unless (and (wasRemoved cluster command=command)
(wasRemoved (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}}
{{#if (or (isSupported cluster command=command)
(isSupported (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}}
{{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}}
{{#*inline "paramsType"}}
{{#if (wasRemoved cluster command=command)}}
{{#unless (isSupported cluster command=command)}}
MTR{{compatClusterNameRemapping parent.name}}Cluster{{compatCommandNameRemapping parent.name name}}Params
{{else}}
MTR{{cluster}}Cluster{{command}}Params
{{/if}}
{{/unless}}
{{/inline}}
{{#unless hasArguments}}
- (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion
Expand Down Expand Up @@ -124,7 +124,7 @@ MTR{{cluster}}Cluster{{command}}Params
});
std::move(*bridge).DispatchAction(self.device);
}
{{/unless}}
{{/if}}
{{/inline}}
{{> commandImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true)
command=(asUpperCamelCase name preserveAcronyms=true)}}
Expand All @@ -133,9 +133,9 @@ MTR{{cluster}}Cluster{{command}}Params

{{#zcl_attributes_server removeKeys='isOptional'}}
{{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }}
{{#unless (and (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))
(or (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))
(not wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}}
{{#if (or (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))
(and (isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))
(wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}}
{{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}}
- (void)read{{>attribute}}With
{{~#if_is_fabric_scoped_struct type~}}
Expand Down Expand Up @@ -233,28 +233,28 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value
}

{{/if}}
{{/unless}}
{{/if}}
{{/zcl_attributes_server}}

@end
{{/unless}}
{{/if}}
{{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatClusterNameRemapping name))}}
{{#unless (wasRemoved (compatClusterNameRemapping name))}}
{{#if (isSupported (compatClusterNameRemapping name))}}

@implementation MTRBaseCluster{{compatClusterNameRemapping name}}
@end
{{/unless}}
{{/if}}
{{/unless}}

{{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name))
(not (wasRemoved (compatClusterNameRemapping name))))}}
(isSupported (compatClusterNameRemapping name)))}}
@implementation MTRBaseCluster{{compatClusterNameRemapping name}} (Deprecated)

{{#zcl_commands}}
{{#if (is_str_equal source 'client')}}
{{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }}
{{#*inline "commandImpl"}}
{{#unless (wasRemoved cluster command=command)}}
{{#if (isSupported cluster command=command)}}
- (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless commandHasRequiredField}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler
{
[self {{asLowerCamelCase name}}WithParams:params completion:
Expand All @@ -274,7 +274,7 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value
[self {{asLowerCamelCase command}}WithParams:nil completionHandler:completionHandler];
}
{{/unless}}
{{/unless}}
{{/if}}
{{/inline}}
{{> commandImpl cluster=(compatClusterNameRemapping parent.name)
command=(compatCommandNameRemapping parent.name name)}}
Expand All @@ -283,7 +283,7 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value

{{#zcl_attributes_server removeKeys='isOptional'}}
{{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))
(not (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}}
(isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)))}}
{{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}}
- (void)read{{>attribute}}With
{{~#if_is_fabric_scoped_struct type~}}
Expand Down Expand Up @@ -349,6 +349,6 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio
@end
{{/if}}

{{/all_user_clusters}}
{{/zcl_clusters}}

// NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks)
Loading

0 comments on commit 1461282

Please sign in to comment.