Skip to content

Commit 245a7f4

Browse files
Auto-generate availability annotations for Darwin. (#24071)
* Auto-generate availability annotations for Darwin. The changes to the generated code are as follows: * MTRBaseClusters.h: * Some newlines after MTR_NEWLY_AVAILABLE were removed. This led to a smaller diff than adding blank lines in all the places that do not use MTR_NEWLY_AVAILABLE. The newlines will return once we add availability annotations to everything we shipped in the initial Matter release, in a followup. * MTRLevelControlOptions gained the availability annotation it was missing. * Enum and bitmap values now have availability annotations. * MTRClusterConstants.h: * ClientMonitoring bits that should not have been generated (because it was added after we made the API changes that those bits are backwards compat shims for) were removed. * The availability annotations on MTRClusterDescriptorAttributeDeviceTypeListID got reordered (because the new autogenerated things put API_AVAILABLE before the deprecation annotation). * MTRClusters.h: * Some newlines after MTR_NEWLY_AVAILABLE were removed, similar to MTRBaseClusters.h. * Various selectors on clusters that have been newly added (e.g. due to renames) now have the right availability annotations. Most of the diff here is from the UnitTesting cluster. * Some typos in deprecation messages ("writeAtribute" instead of "writeAttribute" were fixed). * MTRCommandPayloadsObjc.h * Commands fields now have availability annotations. * MTRClientMonitoringClusterRegisterClientMonitoringParams and MTRClientMonitoringClusterStayAwakeRequestParams gained the availability annotation they were missing. * MTRStructsObjc.h * Struct fields now have availability annotations. * Deprecation annotation added to MTRDescriptorClusterDeviceType. * MTRClientMonitoringClusterMonitoringRegistration gained the availability annotation it was missing. * Fixes #23880 * Fixes #23680 * Address review comments: * Put the availability data filename in templates.json. * Deprecation of a container should deprecate all its contents. * Add renames as well. * Update to containers with newer ZAP.
1 parent 23f0824 commit 245a7f4

14 files changed

+5887
-775
lines changed

.github/workflows/zap_regeneration.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
runs-on: ubuntu-20.04
3030
container:
31-
image: connectedhomeip/chip-build:0.6.18
31+
image: connectedhomeip/chip-build:0.6.21
3232
defaults:
3333
run:
3434
shell: sh

.github/workflows/zap_templates.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929

3030
runs-on: ubuntu-20.04
3131
container:
32-
image: connectedhomeip/chip-build:0.6.18
32+
image: connectedhomeip/chip-build:0.6.21
3333
defaults:
3434
run:
3535
shell: sh

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

+32-52
Large diffs are not rendered by default.

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

+37-22
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77

88
typedef NS_ENUM(uint32_t, MTRClusterIDType) {
99
{{#zcl_clusters}}
10-
MTRCluster{{compatClusterNameRemapping label}}ID MTR_NEWLY_DEPRECATED("Please use MTRClusterIDType{{asUpperCamelCase label}}ID")= {{asMEI manufacturerCode code}},
10+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name) isForIds=true)}}
11+
MTRCluster{{compatClusterNameRemapping label}}ID {{availability (compatClusterNameRemapping name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRClusterIDType" (asUpperCamelCase label preserveAcronyms=false) "ID") isForIds=true}} = {{asMEI manufacturerCode code}},
12+
{{/if}}
1113
{{/zcl_clusters}}
1214
{{#zcl_clusters}}
1315
{{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
14-
MTRClusterIDType{{>cluster}}ID MTR_NEWLY_AVAILABLE = {{asMEI manufacturerCode code}},
16+
MTRClusterIDType{{>cluster}}ID {{availability (asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}},
1517
{{/zcl_clusters}}
1618
};
1719

@@ -21,44 +23,48 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) {
2123
// Deprecated global attribute names
2224
{{#zcl_attributes_server}}
2325
{{#unless clusterRef}}
26+
{{#if (wasIntroducedBeforeRelease "First major API revamp" "" globalAttribute=(asUpperCamelCase label) isForIds=true)}}
2427
MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID
25-
MTR_NEWLY_DEPRECATED("Please use MTRAttributeIDTypeGlobalAttribute{{asUpperCamelCase label}}ID")
28+
{{availability "" api="Deprecated global attribute names" deprecationMessage=(concat "Please use MTRAttributeIDTypeGlobalAttribute" (asUpperCamelCase label) "ID") isForIds=true}}
2629
= {{asMEI manufacturerCode code}},
30+
{{/if}}
2731
{{/unless}}
2832
{{/zcl_attributes_server}}
2933

3034
// Global attributes
3135
{{#zcl_attributes_server}}
3236
{{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}}
3337
{{#unless clusterRef}}
34-
MTRAttributeIDTypeGlobalAttribute{{>attribute}}ID MTR_NEWLY_AVAILABLE = {{asMEI manufacturerCode code}},
38+
MTRAttributeIDTypeGlobalAttribute{{>attribute}}ID {{availability "" globalAttribute=(asUpperCamelCase label) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}},
3539
{{/unless}}
3640
{{/zcl_attributes_server}}
3741

3842
{{#zcl_clusters}}
3943
{{#*inline "attributeIDs"}}
4044
{{#zcl_attributes_server}}
4145
{{#first}}
46+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) isForIds=true)}}
4247
// Cluster {{compatClusterNameRemapping ../clusterName}} deprecated attribute names
48+
{{/if}}
4349
{{/first}}
44-
{{#if clusterRef}}
45-
{{! TODO: We need a better setup for the API_AVAILABLE annotations here; this does not scale at all sanely. }}
46-
MTRCluster{{compatClusterNameRemapping ../clusterName}}Attribute{{asUpperCamelCase label}}ID
47-
MTR_NEWLY_DEPRECATED("Please use MTRAttributeIDTypeCluster{{asUpperCamelCase ../clusterName}}Attribute{{asUpperCamelCase label}}ID")
50+
{{! DeviceTypeList is special: we did not call it by that name
51+
anywhere else in the API at the point when we shipped an id for it
52+
here in the old id format but using the new name alongside the old name. }}
4853
{{#if (isStrEqual (asUpperCamelCase ../clusterName) "Descriptor")}}
4954
{{#if (isStrEqual (asUpperCamelCase label) "DeviceTypeList")}}
50-
API_AVAILABLE(ios(16.2), macos(13.1), watchos(9.2), tvos(16.2))
51-
{{/if}}
52-
{{/if}}
55+
MTRClusterDescriptorAttributeDeviceTypeListID
56+
{{availability "Descriptor" attribute="DeviceTypeList" deprecatedRelease="First major API revamp" deprecationMessage="Please use MTRAttributeIDTypeClusterDescriptorAttributeDeviceTypeListID" isForIds=true}}
5357
= {{asMEI manufacturerCode code}},
54-
{{!Backwards compat for now: DeviceList as an alias for DeviceTypeList}}
55-
{{#if (isStrEqual (asUpperCamelCase ../clusterName) "Descriptor")}}
56-
{{#if (isStrEqual (asUpperCamelCase label) "DeviceTypeList")}}
57-
MTRClusterDescriptorAttributeDeviceListID MTR_NEWLY_DEPRECATED("Please use MTRAttributeIDTypeCluster{{asUpperCamelCase ../clusterName}}Attribute{{asUpperCamelCase label}}ID") = {{asMEI manufacturerCode code}},
5858
{{/if}}
5959
{{/if}}
60+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) isForIds=true)}}
61+
MTRCluster{{compatClusterNameRemapping ../clusterName}}Attribute{{compatAttributeNameRemapping ../clusterName label}}ID
62+
{{availability (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRAttributeIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=false) "Attribute" (asUpperCamelCase label preserveAcronyms=false) "ID") isForIds=true}} =
63+
{{#if clusterRef}}
64+
{{asMEI manufacturerCode code}},
6065
{{else}}
61-
MTRCluster{{compatClusterNameRemapping ../clusterName}}Attribute{{asUpperCamelCase label}}ID MTR_NEWLY_DEPRECATED("Please use MTRAttributeIDTypeCluster{{asUpperCamelCase parent.label}}Attribute{{asUpperCamelCase label}}ID") = MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID,
66+
MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID,
67+
{{/if}}
6268
{{/if}}
6369
{{#last}}
6470

@@ -70,10 +76,11 @@ MTRCluster{{compatClusterNameRemapping ../clusterName}}Attribute{{asUpperCamelCa
7076
{{#first}}
7177
// Cluster {{> cluster}} attributes
7278
{{/first}}
79+
MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} =
7380
{{#if clusterRef}}
74-
MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID MTR_NEWLY_AVAILABLE = {{asMEI manufacturerCode code}},
81+
{{asMEI manufacturerCode code}},
7582
{{else}}
76-
MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID MTR_NEWLY_AVAILABLE= MTRAttributeIDTypeGlobalAttribute{{asUpperCamelCase label}}ID,
83+
MTRAttributeIDTypeGlobalAttribute{{asUpperCamelCase label}}ID,
7784
{{/if}}
7885
{{#last}}
7986

@@ -92,11 +99,15 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) {
9299
{{#*inline "commandIDs"}}
93100
{{#zcl_commands}}
94101
{{#first}}
102+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) isForIds=true)}}
95103
// Cluster {{compatClusterNameRemapping ../clusterName}} deprecated command id names
104+
{{/if}}
96105
{{/first}}
106+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) command=(asUpperCamelCase label) isForIds=true)}}
97107
MTRCluster{{compatClusterNameRemapping ../clusterName}}Command{{asUpperCamelCase label}}ID
98-
MTR_NEWLY_DEPRECATED("Please use MTRCommandIDTypeCluster{{asUpperCamelCase ../clusterName}}Command{{asUpperCamelCase label}}ID")
108+
{{availability (compatClusterNameRemapping ../clusterName) command=(asUpperCamelCase label) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRCommandIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=false) "Command" (asUpperCamelCase label preserveAcronyms=true) "ID") isForIds=true}}
99109
= {{asMEI manufacturerCode code}},
110+
{{/if}}
100111
{{#last}}
101112

102113
{{/last}}
@@ -107,7 +118,7 @@ MTR_NEWLY_DEPRECATED("Please use MTRCommandIDTypeCluster{{asUpperCamelCase ../cl
107118
{{#first}}
108119
// Cluster {{>cluster}} commands
109120
{{/first}}
110-
MTRCommandIDTypeCluster{{>cluster}}Command{{>command}}ID MTR_NEWLY_AVAILABLE = {{asMEI manufacturerCode code}},
121+
MTRCommandIDTypeCluster{{>cluster}}Command{{>command}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}},
111122
{{#last}}
112123

113124
{{/last}}
@@ -125,11 +136,15 @@ typedef NS_ENUM(uint32_t, MTREventIDType) {
125136
{{#*inline "eventIDs"}}
126137
{{#zcl_events}}
127138
{{#first}}
139+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) isForIds=true)}}
128140
// Cluster {{compatClusterNameRemapping ../clusterName}} deprecated event names
141+
{{/if}}
129142
{{/first}}
143+
{{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) event=(asUpperCamelCase name) isForIds=true)}}
130144
MTRCluster{{compatClusterNameRemapping ../clusterName}}Event{{asUpperCamelCase name}}ID
131-
MTR_NEWLY_DEPRECATED("Please use MTREventIDTypeCluster{{asUpperCamelCase ../clusterName}}Event{{asUpperCamelCase name}}ID")
145+
{{availability (compatClusterNameRemapping ../clusterName) event=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTREventIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=false) "Event" (asUpperCamelCase name preserveAcronyms=true) "ID") isForIds=true}}
132146
= {{asMEI manufacturerCode code}},
147+
{{/if}}
133148
{{#last}}
134149

135150
{{/last}}
@@ -140,7 +155,7 @@ MTR_NEWLY_DEPRECATED("Please use MTREventIDTypeCluster{{asUpperCamelCase ../clus
140155
{{#first}}
141156
// Cluster {{>cluster}} events
142157
{{/first}}
143-
MTREventIDTypeCluster{{>cluster}}Event{{>event}}ID MTR_NEWLY_AVAILABLE = {{asMEI manufacturerCode code}},
158+
MTREventIDTypeCluster{{>cluster}}Event{{>event}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}},
144159
{{#last}}
145160

146161
{{/last}}

0 commit comments

Comments
 (0)