Skip to content

Commit

Permalink
[Darwin] Implement MTREventNameForID function (#34653)
Browse files Browse the repository at this point in the history
* Implement MTREventNameForID in darwin

* Restyled by whitespace

---------

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Oct 25, 2024
1 parent 2127061 commit 3731779
Show file tree
Hide file tree
Showing 3 changed files with 1,919 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/darwin/Framework/CHIP/MTRClusterNames.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ MTR_EXTERN MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)) NSSt
* will be returned.
*/
MTR_EXTERN MTR_AVAILABLE(ios(17.6), macos(14.6), watchos(10.6), tvos(17.6)) NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID);

/**
* Resolve Matter event IDs into a descriptive string.
*
* For unknown IDs, a string '<Unknown clusterID %d>' (if the cluster ID is not known)
* or '<Unknown eventID %d>' (if the cluster ID is known but the event ID is not known)
* will be returned.
*/
MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTREventNameForID(MTRClusterIDType clusterID, MTREventIDType eventID);
56 changes: 56 additions & 0 deletions src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,62 @@ NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType
result = [NSString stringWithFormat:@"<Unknown attributeID %d>", attributeID];
break;
}
break;
{{/if}}

{{/zcl_clusters}}
default:
result = [NSString stringWithFormat:@"<Unknown clusterID %d>", clusterID];
break;
}

return result;
}


#pragma mark - Event IDs

NSString * MTREventNameForID(MTRClusterIDType clusterID, MTREventIDType eventID)
{
NSString * result = nil;

switch (clusterID) {

{{#zcl_clusters}}
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
case MTRClusterIDType{{>cluster}}ID:

switch (eventID) {

{{/if}}

{{#*inline "eventIDs"}}
{{#zcl_events}}
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}}
{{~#*inline "event"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}}
{{#first}}
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}}
// Cluster {{> cluster}} events
{{/if}}
{{/first}}
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) isForIds=true)}}
case MTREventIDTypeCluster{{>cluster}}Event{{>event}}ID:
result = @"{{>event}}";
break;

{{/if}}
{{/zcl_events}}
{{/inline}}

{{> eventIDs clusterName=label}}

{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
default:
result = [NSString stringWithFormat:@"<Unknown eventID %d>", eventID];
break;
}
break;
{{/if}}

{{/zcl_clusters}}
Expand Down
Loading

0 comments on commit 3731779

Please sign in to comment.