Skip to content

Commit

Permalink
[darwin] Make sure the prefixes on the enum names match the type (#22673
Browse files Browse the repository at this point in the history
)

* [darwin] Make sure the prefixes on the enum names match the type

* Update generated code
  • Loading branch information
vivien-apple authored Sep 15, 2022
1 parent 74e171a commit bae0bc7
Show file tree
Hide file tree
Showing 4 changed files with 4,729 additions and 4,480 deletions.
18 changes: 9 additions & 9 deletions src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

typedef NS_ENUM(uint32_t, MTRClusterIDType) {
{{#zcl_clusters}}
MTRCluster{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
MTRClusterIDType{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{/zcl_clusters}}
};

#pragma mark - Attributes IDs

typedef NS_ENUM(uint32_t, MTRClusterAttributeIDType) {
typedef NS_ENUM(uint32_t, MTRAttributeIDType) {
// Global attributes
{{#zcl_attributes_server}}
{{#unless clusterRef}}
MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
MTRAttributeIDTypeGlobalAttribute{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{/unless}}
{{/zcl_attributes_server}}

Expand All @@ -27,9 +27,9 @@ MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode
// Cluster {{asUpperCamelCase parent.label}} attributes
{{/first}}
{{#if clusterRef}}
MTRCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
MTRAttributeIDTypeCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{else}}
MTRCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID = MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID,
MTRAttributeIDTypeCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID = MTRAttributeIDTypeGlobalAttribute{{asUpperCamelCase label}}ID,
{{/if}}
{{#last}}

Expand All @@ -40,13 +40,13 @@ MTRCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID

#pragma mark - Commands IDs

typedef NS_ENUM(uint32_t, MTRClusterCommandIDType) {
typedef NS_ENUM(uint32_t, MTRCommandIDType) {
{{#zcl_clusters}}
{{#zcl_commands}}
{{#first}}
// Cluster {{asUpperCamelCase parent.label}} commands
{{/first}}
MTRCluster{{asUpperCamelCase parent.label}}Command{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
MTRCommandIDTypeCluster{{asUpperCamelCase parent.label}}Command{{asUpperCamelCase label}}ID = {{asMEI manufacturerCode code}},
{{#last}}

{{/last}}
Expand All @@ -56,13 +56,13 @@ MTRCluster{{asUpperCamelCase parent.label}}Command{{asUpperCamelCase label}}ID =

#pragma mark - Events IDs

typedef NS_ENUM(uint32_t, MTRClusterEventIDType) {
typedef NS_ENUM(uint32_t, MTREventIDType) {
{{#zcl_clusters}}
{{#zcl_events}}
{{#first}}
// Cluster {{asUpperCamelCase parent.label}} events
{{/first}}
MTRCluster{{asUpperCamelCase parent.label}}Event{{asUpperCamelCase name}}ID = {{asMEI manufacturerCode code}},
MTREventIDTypeCluster{{asUpperCamelCase parent.label}}Event{{asUpperCamelCase name}}ID = {{asMEI manufacturerCode code}},
{{#last}}

{{/last}}
Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ using chip::SessionHandle;
{{#chip_server_cluster_attributes}}
{{#*inline "attribute"}}Attribute{{asUpperCamelCase name}}{{/inline}}
- (NSDictionary<NSString *, id> *)read{{>attribute}}WithParams:(MTRReadParams * _Nullable)params {
return [self.device readAttributeWithEndpointID:@(_endpoint) clusterID:@(MTRCluster{{asUpperCamelCase parent.name}}ID) attributeID:@(MTRCluster{{asUpperCamelCase parent.name}}Attribute{{asUpperCamelCase name}}ID) params:params];
return [self.device readAttributeWithEndpointID:@(_endpoint) clusterID:@(MTRClusterIDType{{asUpperCamelCase parent.name}}ID) attributeID:@(MTRAttributeIDTypeCluster{{asUpperCamelCase parent.name}}Attribute{{asUpperCamelCase name}}ID) params:params];
}

{{#if isWritableAttribute}}
Expand All @@ -128,7 +128,7 @@ using chip::SessionHandle;
}
{{/if}}

[self.device writeAttributeWithEndpointID:@(_endpoint) clusterID:@(MTRCluster{{asUpperCamelCase parent.name}}ID) attributeID:@(MTRCluster{{asUpperCamelCase parent.name}}Attribute{{asUpperCamelCase name}}ID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout];
[self.device writeAttributeWithEndpointID:@(_endpoint) clusterID:@(MTRClusterIDType{{asUpperCamelCase parent.name}}ID) attributeID:@(MTRAttributeIDTypeCluster{{asUpperCamelCase parent.name}}Attribute{{asUpperCamelCase name}}ID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout];
}

{{/if}}
Expand Down
Loading

0 comments on commit bae0bc7

Please sign in to comment.