Skip to content

Commit

Permalink
Disable the ClientMonitoring cluster APIs on Darwin for now.
Browse files Browse the repository at this point in the history
It's not quite stable enough to ship as public API yet.

Adds wasRemoved checks to various places so we handle removals better
in our codegen.
  • Loading branch information
bzbarsky-apple committed Jan 10, 2023
1 parent d08e56e commit e373c74
Show file tree
Hide file tree
Showing 33 changed files with 182 additions and 2,970 deletions.
14 changes: 14 additions & 0 deletions examples/darwin-framework-tool/templates/commands.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
{{> clusters_header}}

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

{{#chip_cluster_commands}}
Expand Down Expand Up @@ -92,6 +93,7 @@ private:
{{/chip_cluster_commands}}

{{#chip_server_cluster_attributes}}
{{#unless (wasRemoved (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 @@ -243,13 +245,16 @@ public:
};

{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/unless}}
{{/chip_client_clusters}}

/*----------------------------------------------------------------------------*\
| Register all Clusters commands |
\*----------------------------------------------------------------------------*/
{{#chip_client_clusters includeAll=true}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
void registerCluster{{asUpperCamelCase name}}(Commands & commands)
{
using namespace chip::app::Clusters::{{asUpperCamelCase name}};
Expand All @@ -267,24 +272,31 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands)
{{#first}}
make_unique<ReadAttribute>(Id), //
{{/first}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
make_unique<Read{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/unless}}
{{#first}}
make_unique<WriteAttribute>(Id), //
{{/first}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if isWritableAttribute}}
make_unique<Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/if}}
{{/unless}}
{{#first}}
make_unique<SubscribeAttribute>(Id), //
{{/first}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if isReportableAttribute}}
make_unique<SubscribeAttribute{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), //
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
};

commands.Register(clusterName, clusterCommands);
}
{{/unless}}
{{/chip_client_clusters}}

void registerClusterAny(Commands & commands)
Expand All @@ -306,6 +318,8 @@ void registerClusters(Commands & commands)
{
registerClusterAny(commands);
{{#chip_client_clusters includeAll=true}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
registerCluster{{asUpperCamelCase name}}(commands);
{{/unless}}
{{/chip_client_clusters}}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"include": "../../../../src/app/tests/suites/ciTests.json",
"disable": [
"TestClientMonitoringCluster",
"Test_TC_SC_4_2",
"TestClusterComplexTypes",
"TestEvents",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader &
switch (aPath.mClusterId)
{
{{#chip_client_clusters includeAll=true}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
case Clusters::{{asUpperCamelCase name}}::Id: {
using namespace Clusters::{{asUpperCamelCase name}};
switch (aPath.mAttributeId)
{
{{#chip_server_cluster_attributes}}
{{#unless (wasRemoved (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 @@ -36,13 +38,15 @@ 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}}
{{/chip_server_cluster_attributes}}
default:
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
break;
}
break;
}
{{/unless}}
{{/chip_client_clusters}}
default: {
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
Expand Down
14 changes: 13 additions & 1 deletion src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ using chip::SessionHandle;

// NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects.
{{#chip_client_clusters includeAll=true}}
{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
@implementation MTRBaseCluster{{asUpperCamelCase name preserveAcronyms=true}}

- (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue
Expand Down Expand Up @@ -117,6 +118,9 @@ MTR{{cluster}}Cluster{{command}}Params
{{/chip_cluster_commands}}

{{#chip_server_cluster_attributes}}
{{! 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) command=(asUpperCamelCase name preserveAcronyms=true))
(wasRemoved (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping 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 @@ -214,15 +218,21 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value
}

{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}

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

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

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

{{#chip_cluster_commands}}
Expand Down Expand Up @@ -255,7 +265,8 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value
{{/chip_cluster_commands}}

{{#chip_server_cluster_attributes}}
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))}}
{{#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))))}}
{{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}}
- (void)read{{>attribute}}With
{{~#if_is_fabric_scoped_struct type~}}
Expand Down Expand Up @@ -319,6 +330,7 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio
}

@end
{{/if}}

{{/chip_client_clusters}}

Expand Down
12 changes: 10 additions & 2 deletions src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN
{{#chip_client_clusters includeAll=true}}


{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
/**
* Cluster {{name}}
*
Expand Down Expand Up @@ -44,6 +45,7 @@ NS_ASSUME_NONNULL_BEGIN
{{/chip_cluster_commands}}

{{#chip_server_cluster_attributes}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}}
- (void)read{{>attribute}}With
{{~#if_is_fabric_scoped_struct type~}}
Expand All @@ -61,21 +63,25 @@ NS_ASSUME_NONNULL_BEGIN
subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))reportHandler {{availability (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}};
+ (void) read{{>attribute}}WithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))completion {{availability (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}};
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

@end
{{/unless}}

{{/chip_client_clusters}}

{{#chip_client_clusters includeAll=true}}
{{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatClusterNameRemapping name))}}
{{#unless (wasRemoved (compatClusterNameRemapping name))}}
{{availability (compatClusterNameRemapping name) deprecationMessage=(concat "Please use MTRBaseCluster" (asUpperCamelCase name preserveAcronyms=true))}}
@interface MTRBaseCluster{{compatClusterNameRemapping name}} : MTRBaseCluster{{asUpperCamelCase name preserveAcronyms=true}}
@end

{{/unless}}
{{/unless}}
{{/chip_client_clusters}}

Expand Down Expand Up @@ -168,7 +174,8 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitm
{{/zcl_clusters}}

{{#chip_client_clusters includeAll=true}}
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name))}}
{{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name))
(not (wasRemoved (compatClusterNameRemapping name))))}}
@interface MTRBaseCluster{{compatClusterNameRemapping name}} (Deprecated)

- (nullable instancetype)initWithDevice:(MTRBaseDevice *)device
Expand All @@ -193,7 +200,8 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitm
{{/chip_cluster_commands}}

{{#chip_server_cluster_attributes}}
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))}}
{{#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))))}}
{{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}}
- (void)read{{>attribute}}With
{{~#if_is_fabric_scoped_struct type~}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

{{#chip_client_clusters includeAll=true}}

{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}}
@interface MTRBaseCluster{{asUpperCamelCase name preserveAcronyms=true}} ()
@property (nonatomic, strong, readonly) MTRBaseDevice * device;
@property (nonatomic, assign, readonly) chip::EndpointId endpoint;
@end
{{/unless}}

{{/chip_client_clusters}}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

{{#chip_client_clusters includeAll=true}}
{{#chip_server_cluster_attributes}}
{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if isArray}}
{{#>MTRCallbackBridge ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}ListAttributeCallback{{/MTRCallbackBridge}}
{{else}}
Expand All @@ -49,18 +50,23 @@
{{#>MTRCallbackBridge ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}}
{{/if_is_strongly_typed_bitmap}}
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/chip_client_clusters}}

{{#chip_client_clusters includeAll=true}}
{{#chip_cluster_responses}}
{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
{{#>MTRCallbackBridge partial-type="Command" }}{{asUpperCamelCase ../../name preserveAcronyms=true}}Cluster{{asUpperCamelCase ../name preserveAcronyms=true}}Callback{{/MTRCallbackBridge}}
{{/unless}}
{{/chip_cluster_responses}}
{{/chip_client_clusters}}

{{#zcl_clusters}}
{{#zcl_enums}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}}
{{#>MTRCallbackBridge type=(asType label) isNullable=false ns=parent.name}}{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}}
{{#>MTRCallbackBridge type=(asType label) isNullable=true ns=parent.name}}Nullable{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}}
{{/unless}}
{{/zcl_enums}}
{{/zcl_clusters}}
12 changes: 12 additions & 0 deletions src/darwin/Framework/CHIP/templates/MTRCallbackBridge.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,24 @@ typedef void (*NullableVendorIdAttributeCallback)(void *, const chip::app::DataM

{{#chip_client_clusters includeAll=true}}
{{#chip_cluster_responses}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}CallbackType)(void *, const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType &);
{{/unless}}
{{/chip_cluster_responses}}
{{/chip_client_clusters}}

{{#zcl_clusters}}
{{#zcl_enums}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}}
typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback)(void *, chip::app::Clusters::{{asUpperCamelCase parent.name}}::{{asType label}});
typedef void (*Nullable{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback)(void *, const chip::app::DataModel::Nullable<chip::app::Clusters::{{asUpperCamelCase parent.name}}::{{asType label}}> &);
{{/unless}}
{{/zcl_enums}}
{{/zcl_clusters}}

{{#chip_client_clusters includeAll=true}}
{{#chip_server_cluster_attributes}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if isArray}}
typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCamelCase name preserveAcronyms=true}}ListAttributeCallback)(void * context, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true}} data);
{{else}}
Expand All @@ -39,6 +44,7 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa
typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback)(void *, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true forceNotOptional=true}});
{{/if_is_strongly_typed_bitmap}}
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/chip_client_clusters}}

Expand Down Expand Up @@ -75,6 +81,7 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa

{{#chip_client_clusters includeAll=true}}
{{#chip_server_cluster_attributes}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
{{#if isArray}}
{{#>MTRCallbackBridge header="1" ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}ListAttributeCallback{{/MTRCallbackBridge}}
{{else}}
Expand All @@ -85,18 +92,23 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa
{{#>MTRCallbackBridge header="1" ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}}
{{/if_is_strongly_typed_bitmap}}
{{/if}}
{{/unless}}
{{/chip_server_cluster_attributes}}
{{/chip_client_clusters}}

{{#chip_client_clusters includeAll=true}}
{{#chip_cluster_responses}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
{{#>MTRCallbackBridge header="1" partial-type="Command" }}{{asUpperCamelCase ../../name preserveAcronyms=true}}Cluster{{asUpperCamelCase ../name preserveAcronyms=true}}Callback{{/MTRCallbackBridge}}
{{/unless}}
{{/chip_cluster_responses}}
{{/chip_client_clusters}}

{{#zcl_clusters}}
{{#zcl_enums}}
{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}}
{{#>MTRCallbackBridge header="1" type=(asType label) isNullable=false ns=parent.name}}{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}}
{{#>MTRCallbackBridge header="1" type=(asType label) isNullable=true ns=parent.name}}Nullable{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}}
{{/unless}}
{{/zcl_enums}}
{{/zcl_clusters}}
Loading

0 comments on commit e373c74

Please sign in to comment.