From 104848604c8ff22a8e70399ba7aa507981b1b708 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 5 May 2023 22:45:49 -0400 Subject: [PATCH] Don't try to use nonexistent global attribute id constants on Darwin. (#26398) We have some global attributes that are marked provisional. New clusters being added would try to generate a constant for the global attribute inside the cluster, until we had a chance to set it provisional, but set its value to the nonexistent global constant, which would fail to compile. This just skips generating the relevant cluster constants. --- .../Framework/CHIP/templates/MTRClusterConstants.zapt | 8 +++++--- src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt | 9 ++++++--- src/darwin/Framework/CHIP/templates/MTRClusters.zapt | 4 +++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt index bece573dd988e0..04111e11cfbf2c 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt @@ -38,8 +38,8 @@ MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID {{#zcl_attributes_server}} {{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} {{#unless clusterRef}} -{{#if (isSupported "" globalAttribute=(asUpperCamelCase label) isForIds=true)}} -MTRAttributeIDTypeGlobalAttribute{{>attribute}}ID {{availability "" globalAttribute=(asUpperCamelCase label) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}}, +{{#if (isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +MTRAttributeIDTypeGlobalAttribute{{>attribute}}ID {{availability "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}}, {{/if}} {{/unless}} {{/zcl_attributes_server}} @@ -86,7 +86,9 @@ MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID, // Cluster {{> cluster}} attributes {{/if}} {{/first}} -{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +{{#if (and (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true) + (or clusterRef + (isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)))}} MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{#if clusterRef}} {{asMEI manufacturerCode code}}, diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt index 75bb323bd542df..11ba013f232f8b 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt @@ -189,9 +189,12 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{#zcl_attributes_server}} {{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }} -{{#if (or (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)) - (and (isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) - (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}} +{{#if (and + (or clusterRef + (isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true))) + (or (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)) + (and (isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) + (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)))))}} {{#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} - (NSDictionary *)read{{>attribute}}WithParams:(MTRReadParams * _Nullable)params { diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt index d603d791ce190b..ef09d89f9e165f 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt @@ -40,7 +40,9 @@ NS_ASSUME_NONNULL_BEGIN {{/zcl_commands}} {{#zcl_attributes_server}} -{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (and (or clusterRef + (isSupported "" globalAttribute=(asUpperCamelCase label preserveAcronyms=true))) + (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)))}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} {{#*inline "availability"}} {{availability (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)}}