forked from project-chip/connectedhomeip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Darwin: cluster & attribute introspection (project-chip#31026)
* darwin: ability to map from ID to name * Restyled by whitespace * change to standalone functions * generated files * Apply suggestions from code review breaks in default cases. Co-authored-by: Boris Zbarsky <[email protected]> * Make the header not auto-generated add code comments * add files to Xcode project * Updated generated file after rebase * Fix compilation fails * Add new API to Matter.h * Remove not generated header file. * Apply suggestions from code review Co-authored-by: Boris Zbarsky <[email protected]> * updated generated file after rebase * Restyled by whitespace * Restyled by clang-format * regen after rebase * add missing includes * Restyled by clang-format * make the clusterNames header public * Apply suggestions from code review Co-authored-by: Boris Zbarsky <[email protected]> * regen --------- Co-authored-by: Restyled.io <[email protected]> Co-authored-by: Boris Zbarsky <[email protected]>
- Loading branch information
1 parent
8834be1
commit e59f2ad
Showing
6 changed files
with
8,801 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* | ||
* Copyright (c) 2023 Project CHIP Authors | ||
* All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#import <Matter/MTRClusterConstants.h> | ||
#import <Matter/MTRDefines.h> | ||
|
||
/** | ||
* This file defines functions to resolve Matter cluster and attribute IDs into | ||
* strings. | ||
*/ | ||
|
||
/** | ||
* Resolve Matter cluster IDs into a descriptive string. | ||
* | ||
* For unknown IDs, a string '<Unknown clusterID %d>' will be returned. | ||
*/ | ||
MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRClusterNameForID(MTRClusterIDType clusterID); | ||
|
||
/** | ||
* Resolve Matter attribute IDs into a descriptive string. | ||
* | ||
* For unknown IDs, a string '<Unknown clusterID %d>' (if the cluster ID is not known) | ||
* or '<Unknown attributeID %d>' (if the cluster ID is known but the attribute ID is not known) | ||
* will be returned. | ||
*/ | ||
MTR_EXTERN MTR_NEWLY_AVAILABLE NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
src/darwin/Framework/CHIP/templates/MTRClusterNames-src.zapt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
{{> header excludeZapComment=true}} | ||
|
||
|
||
#import <Matter/MTRClusterNames.h> | ||
|
||
// @implementation MTRClusterAttributeIDType | ||
|
||
#pragma mark - Clusters IDs | ||
|
||
NSString * MTRClusterNameForID(MTRClusterIDType clusterID) | ||
{ | ||
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: | ||
result = @"{{>cluster}}"; | ||
break; | ||
{{/if}} | ||
{{/zcl_clusters}} | ||
|
||
default: | ||
result = [NSString stringWithFormat:@"<Unknown clusterID %d>", clusterID]; | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
||
#pragma mark - Attributes IDs | ||
|
||
NSString * MTRAttributeNameForID(MTRClusterIDType clusterID, MTRAttributeIDType attributeID) | ||
{ | ||
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 (attributeID) { | ||
|
||
{{/if}} | ||
|
||
{{#*inline "attributeIDs"}} | ||
{{#zcl_attributes_server}} | ||
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}} | ||
{{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} | ||
{{#first}} | ||
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}} | ||
// Cluster {{> cluster}} attributes | ||
{{/if}} | ||
{{/first}} | ||
{{#if (and (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true) | ||
(or clusterRef | ||
(isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)))}} | ||
case MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID: | ||
result = @"{{>attribute}}"; | ||
break; | ||
|
||
{{/if}} | ||
{{/zcl_attributes_server}} | ||
{{/inline}} | ||
|
||
{{> attributeIDs clusterName=label}} | ||
|
||
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} | ||
default: | ||
result = [NSString stringWithFormat:@"<Unknown attributeID %d>", attributeID]; | ||
break; | ||
} | ||
{{/if}} | ||
|
||
{{/zcl_clusters}} | ||
default: | ||
result = [NSString stringWithFormat:@"<Unknown clusterID %d>", clusterID]; | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
// @end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.