Skip to content

Commit edc3ed9

Browse files
authored
additional codegen templates (project-chip#42786)
1 parent c72246f commit edc3ed9

34 files changed

Lines changed: 1412 additions & 26 deletions

src/darwin/Framework/CHIP/templates/MTRAttributeSpecifiedCheck-src.zapt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ using namespace chip;
99
using namespace chip::app;
1010

1111
{{#zcl_clusters}}
12+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
1213
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
1314
static BOOL AttributeIsSpecifiedIn{{asUpperCamelCase name preserveAcronyms=true}}Cluster(AttributeId aAttributeId)
1415
{
@@ -28,18 +29,21 @@ static BOOL AttributeIsSpecifiedIn{{asUpperCamelCase name preserveAcronyms=true}
2829
}
2930
}
3031
{{/if}}
32+
{{/unless}}
3133
{{/zcl_clusters}}
3234

3335
BOOL MTRAttributeIsSpecified(ClusterId aClusterId, AttributeId aAttributeId)
3436
{
3537
switch (aClusterId)
3638
{
3739
{{#zcl_clusters}}
40+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
3841
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
3942
case Clusters::{{asUpperCamelCase name}}::Id: {
4043
return AttributeIsSpecifiedIn{{asUpperCamelCase name preserveAcronyms=true}}Cluster(aAttributeId);
4144
}
4245
{{/if}}
46+
{{/unless}}
4347
{{/zcl_clusters}}
4448
default: {
4549
return NO;
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{{> header excludeZapComment=true}}
2+
3+
#import "MTRAttributeSpecifiedCheck.h"
4+
5+
#include <app-common/zap-generated/ids/Attributes.h>
6+
#include <app-common/zap-generated/ids/Clusters.h>
7+
8+
using namespace chip;
9+
using namespace chip::app;
10+
11+
{{#zcl_clusters}}
12+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
13+
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
14+
static BOOL AttributeIsSpecifiedIn{{asUpperCamelCase name preserveAcronyms=true}}Cluster(AttributeId aAttributeId)
15+
{
16+
using namespace Clusters::{{asUpperCamelCase name}};
17+
switch (aAttributeId) {
18+
{{#zcl_attributes_server}}
19+
{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
20+
case Attributes::{{asUpperCamelCase name}}::Id: {
21+
return YES;
22+
}
23+
{{/if}}
24+
{{/zcl_attributes_server}}
25+
default: {
26+
// Not a known {{asUpperCamelCase name preserveAcronyms=true}} attribute.
27+
return NO;
28+
}
29+
}
30+
}
31+
{{/if}}
32+
{{/if}}
33+
{{/zcl_clusters}}
34+
35+
BOOL MTRPrivateAttributeIsSpecified(ClusterId aClusterId, AttributeId aAttributeId)
36+
{
37+
switch (aClusterId)
38+
{
39+
{{#zcl_clusters}}
40+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
41+
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
42+
case Clusters::{{asUpperCamelCase name}}::Id: {
43+
return AttributeIsSpecifiedIn{{asUpperCamelCase name preserveAcronyms=true}}Cluster(aAttributeId);
44+
}
45+
{{/if}}
46+
{{/if}}
47+
{{/zcl_clusters}}
48+
default: {
49+
return NO;
50+
}
51+
}
52+
}

src/darwin/Framework/CHIP/templates/MTRAttributeTLVValueDecoder-src.zapt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ static id _Nullable DecodeGlobalAttributeValue(AttributeId aAttributeId, TLV::TL
4949
}
5050

5151
{{#zcl_clusters}}
52+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
5253
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
5354
static id _Nullable DecodeAttributeValueFor{{asUpperCamelCase name preserveAcronyms=true}}Cluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
5455
{
@@ -82,6 +83,7 @@ static id _Nullable DecodeAttributeValueFor{{asUpperCamelCase name preserveAcron
8283
return nil;
8384
}
8485
{{/if}}
86+
{{/unless}}
8587
{{/zcl_clusters}}
8688

8789
id _Nullable MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & aReader, CHIP_ERROR * aError)
@@ -92,11 +94,13 @@ id _Nullable MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::T
9294

9395
switch (aPath.mClusterId) {
9496
{{#zcl_clusters}}
97+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
9598
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
9699
case Clusters::{{asUpperCamelCase name}}::Id: {
97100
return DecodeAttributeValueFor{{asUpperCamelCase name preserveAcronyms=true}}Cluster(aPath.mAttributeId, aReader, aError);
98101
}
99102
{{/if}}
103+
{{/unless}}
100104
{{/zcl_clusters}}
101105
default: {
102106
break;
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
{{> header excludeZapComment=true}}
2+
3+
#import "MTRAttributeTLVValueDecoder_Internal.h"
4+
5+
#import "MTRStructsObjc.h"
6+
#import "MTRStructsObjc_Private.h"
7+
#import "NSStringSpanConversion.h"
8+
#import "NSDataSpanConversion.h"
9+
10+
#include <app/data-model/Decode.h>
11+
#include <app/data-model/DecodableList.h>
12+
#include <app-common/zap-generated/cluster-objects.h>
13+
#include <app-common/zap-generated/ids/Attributes.h>
14+
#include <app-common/zap-generated/ids/Clusters.h>
15+
#include <lib/support/TypeTraits.h>
16+
#include <lib/core/DataModelTypes.h>
17+
18+
using namespace chip;
19+
using namespace chip::app;
20+
21+
static id _Nullable DecodeGlobalAttributeValue(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
22+
{
23+
using namespace Clusters::Globals;
24+
switch (aAttributeId) {
25+
{{#zcl_attributes_server removeKeys='isOptional'}}
26+
{{#unless clusterRef}}
27+
{{#if (isSupported "" globalAttribute=(asUpperCamelCase name preserveAcronyms=true))}}
28+
case Attributes::{{asUpperCamelCase name}}::Id: {
29+
using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo;
30+
TypeInfo::DecodableType cppValue;
31+
*aError = DataModel::Decode(aReader, cppValue);
32+
if (*aError != CHIP_NO_ERROR)
33+
{
34+
return nil;
35+
}
36+
{{asObjectiveCType type ""}} value;
37+
{{>decode_value target="value" source="cppValue" cluster="" errorCode="*aError = err; return nil;" depth=0}}
38+
return value;
39+
}
40+
{{/if}}
41+
{{/unless}}
42+
{{/zcl_attributes_server}}
43+
default: {
44+
break;
45+
}
46+
}
47+
48+
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
49+
return nil;
50+
}
51+
52+
{{#zcl_clusters}}
53+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
54+
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
55+
static id _Nullable DecodeAttributeValueFor{{asUpperCamelCase name preserveAcronyms=true}}Cluster(AttributeId aAttributeId, TLV::TLVReader & aReader, CHIP_ERROR * aError)
56+
{
57+
using namespace Clusters::{{asUpperCamelCase name}};
58+
switch (aAttributeId) {
59+
{{#zcl_attributes_server removeKeys='isOptional'}}
60+
{{#if clusterRef}}
61+
{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}}
62+
case Attributes::{{asUpperCamelCase name}}::Id: {
63+
using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo;
64+
TypeInfo::DecodableType cppValue;
65+
*aError = DataModel::Decode(aReader, cppValue);
66+
if (*aError != CHIP_NO_ERROR)
67+
{
68+
return nil;
69+
}
70+
{{asObjectiveCType type parent.name}} value;
71+
{{>decode_value target="value" source="cppValue" cluster=parent.name errorCode="*aError = err; return nil;" depth=0}}
72+
return value;
73+
}
74+
{{/if}}
75+
{{/if}}
76+
{{/zcl_attributes_server}}
77+
default: {
78+
// Not a known {{asUpperCamelCase name preserveAcronyms=true}} attribute.
79+
break;
80+
}
81+
}
82+
83+
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
84+
return nil;
85+
}
86+
{{/if}}
87+
{{/if}}
88+
{{/zcl_clusters}}
89+
90+
id _Nullable MTRPrivateDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & aReader, CHIP_ERROR * aError)
91+
{
92+
if (IsGlobalAttribute(aPath.mAttributeId)) {
93+
return DecodeGlobalAttributeValue(aPath.mAttributeId, aReader, aError);
94+
}
95+
96+
switch (aPath.mClusterId) {
97+
{{#zcl_clusters}}
98+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
99+
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
100+
case Clusters::{{asUpperCamelCase name}}::Id: {
101+
return DecodeAttributeValueFor{{asUpperCamelCase name preserveAcronyms=true}}Cluster(aPath.mAttributeId, aReader, aError);
102+
}
103+
{{/if}}
104+
{{/if}}
105+
{{/zcl_clusters}}
106+
default: {
107+
break;
108+
}
109+
}
110+
*aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB;
111+
return nil;
112+
}

src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,20 @@
77

88
typedef NS_ENUM(uint32_t, MTRClusterIDType) {
99
{{#zcl_clusters}}
10+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
1011
{{#if (and (wasIntroducedBeforeRelease "267F4B03-3256-4056-A62D-5237640FDCFE" (compatClusterNameRemapping name) isForIds=true)
1112
(isSupported (compatClusterNameRemapping name) isForIds=true))}}
1213
MTRCluster{{compatClusterNameRemapping label}}ID {{availability (compatClusterNameRemapping name) deprecatedRelease="267F4B03-3256-4056-A62D-5237640FDCFE" deprecationMessage=(concat "Please use MTRClusterIDType" (asUpperCamelCase label preserveAcronyms=true) "ID") isForIds=true}} = {{asMEI manufacturerCode code}},
1314
{{/if}}
15+
{{/unless}}
1416
{{/zcl_clusters}}
1517
{{#zcl_clusters}}
18+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
1619
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
1720
{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
1821
MTRClusterIDType{{>cluster}}ID {{availability (asUpperCamelCase label preserveAcronyms=true) minimalRelease="267F4B03-3256-4056-A62D-5237640FDCFE" isForIds=true deprecationMessage=(concat "The " (asUpperCamelCase label preserveAcronyms=true) " cluster will be removed")}} = {{asMEI manufacturerCode code}},
1922
{{/if}}
23+
{{/unless}}
2024
{{/zcl_clusters}}
2125

2226
{{> cluster_id_shims}}
@@ -47,6 +51,7 @@ MTRAttributeIDTypeGlobalAttribute{{>attribute}}ID {{availability "" globalAttrib
4751
{{/zcl_attributes_server}}
4852

4953
{{#zcl_clusters}}
54+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
5055
{{#*inline "attributeIDs"}}
5156
{{#zcl_attributes_server}}
5257
{{#first}}
@@ -113,6 +118,7 @@ MTRAttributeIDTypeCluster{{compatClusterNameRemapping ../clusterName}}Attribute{
113118
{{/inline}}
114119

115120
{{> attributeIDs clusterName=label}}
121+
{{/unless}}
116122
{{/zcl_clusters}}
117123

118124
{{> attribute_id_shims}}
@@ -122,6 +128,7 @@ MTRAttributeIDTypeCluster{{compatClusterNameRemapping ../clusterName}}Attribute{
122128

123129
typedef NS_ENUM(uint32_t, MTRCommandIDType) {
124130
{{#zcl_clusters}}
131+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
125132
{{#*inline "commandIDs"}}
126133
{{#zcl_commands}}
127134
{{#first}}
@@ -177,6 +184,7 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{availability cluster co
177184
{{/inline}}
178185

179186
{{> commandIDs clusterName=label}}
187+
{{/unless}}
180188
{{/zcl_clusters}}
181189

182190
{{> command_id_shims}}
@@ -186,6 +194,7 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{availability cluster co
186194

187195
typedef NS_ENUM(uint32_t, MTREventIDType) {
188196
{{#zcl_clusters}}
197+
{{#unless (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
189198
{{#*inline "eventIDs"}}
190199
{{#zcl_events}}
191200
{{#first}}
@@ -223,6 +232,7 @@ MTREventIDTypeCluster{{>cluster}}Event{{>event}}ID {{availability (asUpperCamelC
223232
{{/inline}}
224233

225234
{{> eventIDs clusterName=label}}
235+
{{/unless}}
226236
{{/zcl_clusters}}
227237
};
228238

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
{{> header excludeZapComment=true}}
2+
3+
#import <Matter/MTRDefines.h>
4+
#import <Matter/MTRClusterConstants.h>
5+
#import <stdint.h>
6+
7+
#pragma mark - Private Cluster IDs
8+
9+
typedef NS_ENUM(uint32_t, MTRPrivateClusterIDType) {
10+
{{#zcl_clusters}}
11+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
12+
{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}}
13+
{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
14+
MTRPrivateClusterIDType{{>cluster}}ID {{availability (asUpperCamelCase label preserveAcronyms=true) minimalRelease="267F4B03-3256-4056-A62D-5237640FDCFE" isForIds=true deprecationMessage=(concat "The " (asUpperCamelCase label preserveAcronyms=true) " cluster will be removed")}} = {{asMEI manufacturerCode code}},
15+
{{/if}}
16+
{{/if}}
17+
{{/zcl_clusters}}
18+
};
19+
20+
#pragma mark - Private Attribute IDs
21+
22+
typedef NS_ENUM(uint32_t, MTRPrivateAttributeIDType) {
23+
{{#zcl_clusters}}
24+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
25+
{{#*inline "attributeIDs"}}
26+
{{#zcl_attributes_server}}
27+
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}}
28+
{{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
29+
{{#if (and (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)
30+
(or clusterRef
31+
(isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)))}}
32+
MTRPrivateAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) minimalRelease="267F4B03-3256-4056-A62D-5237640FDCFE" isForIds=true deprecationMessage=(concat "The " (asUpperCamelCase label preserveAcronyms=true) " attribute will be removed")}} = {{#if clusterRef}}{{asMEI manufacturerCode code}}{{else}}MTRAttributeIDTypeGlobalAttribute{{asUpperCamelCase label}}ID{{/if}},
33+
{{/if}}
34+
{{/zcl_attributes_server}}
35+
{{/inline}}
36+
37+
{{> attributeIDs clusterName=label}}
38+
{{/if}}
39+
{{/zcl_clusters}}
40+
};
41+
42+
#pragma mark - Private Command IDs
43+
44+
typedef NS_ENUM(uint32_t, MTRPrivateCommandIDType) {
45+
{{#zcl_clusters}}
46+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
47+
{{#*inline "commandIDs"}}
48+
{{#zcl_commands}}
49+
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}}
50+
{{~#*inline "command"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}}
51+
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) isForIds=true)}}
52+
MTRPrivateCommandIDTypeCluster{{>cluster}}Command{{>command}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="267F4B03-3256-4056-A62D-5237640FDCFE" isForIds=true deprecationMessage=(concat "The " (asUpperCamelCase name preserveAcronyms=true) " command will be removed")}} = {{asMEI manufacturerCode code}},
53+
{{/if}}
54+
{{/zcl_commands}}
55+
{{/inline}}
56+
57+
{{> commandIDs clusterName=label}}
58+
{{/if}}
59+
{{/zcl_clusters}}
60+
};
61+
62+
#pragma mark - Private Event IDs
63+
64+
typedef NS_ENUM(uint32_t, MTRPrivateEventIDType) {
65+
{{#zcl_clusters}}
66+
{{#if (isInConfigList (asUpperCamelCase name preserveAcronyms=true) "DarwinPrivateClusters")}}
67+
{{#*inline "eventIDs"}}
68+
{{#zcl_events}}
69+
{{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}}
70+
{{~#*inline "event"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}}
71+
{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) isForIds=true)}}
72+
MTRPrivateEventIDTypeCluster{{>cluster}}Event{{>event}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="267F4B03-3256-4056-A62D-5237640FDCFE" isForIds=true}} = {{asMEI manufacturerCode code}},
73+
{{/if}}
74+
{{/zcl_events}}
75+
{{/inline}}
76+
77+
{{> eventIDs clusterName=label}}
78+
{{/if}}
79+
{{/zcl_clusters}}
80+
};

0 commit comments

Comments
 (0)