Skip to content

Commit

Permalink
Add support for renaming enums and bitmaps as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple committed Dec 22, 2022
1 parent d406f01 commit bc836e0
Showing 1 changed file with 38 additions and 12 deletions.
50 changes: 38 additions & 12 deletions src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -82,32 +82,58 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio
{{#zcl_clusters}}
{{#zcl_enums}}
{{#*inline "enumDef"}}
typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName label}}) {
typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumName}}) {
{{#zcl_enum_items}}
{{objCEnumName ../clusterName ../label}}{{objCEnumItemLabel label}} {{availability ../clusterName enum=(asUpperCamelCase ../label preserveAcronyms=true) enumValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}},
{{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel label}} {{availability ../clusterName enum=../enumName enumValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex value 2}},
{{/zcl_enum_items}}
}
{{/inline}}
{{> enumDef name=name clusterName=(asUpperCamelCase ../name preserveAcronyms=true) label=label}} {{availability (asUpperCamelCase ../name preserveAcronyms=true) enum=(asUpperCamelCase label preserveAcronyms=true)}};
{{#unless (isStrEqual (asUpperCamelCase ../name preserveAcronyms=true) (compatClusterNameRemapping ../name))}}
{{> enumDef name=name clusterName=(asUpperCamelCase ../name preserveAcronyms=true) enumName=(asUpperCamelCase label preserveAcronyms=true)}} {{availability (asUpperCamelCase ../name preserveAcronyms=true) enum=(asUpperCamelCase label preserveAcronyms=true)}};
{{! Takes the name of the enum to use as enumName. }}
{{#*inline "oldNameDecl"}}

{{> enumDef name=name clusterName=(compatClusterNameRemapping ../name) label=label}} {{availability (compatClusterNameRemapping ../name) enum=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../name preserveAcronyms=true) label))}};
{{/unless}}
{{> enumDef name=name clusterName=(compatClusterNameRemapping ../name) enumName=enumName}} {{availability (compatClusterNameRemapping ../name) enum=enumName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../name preserveAcronyms=true) label))}};
{{/inline}}
{{! Takes the old name of the enum, if any, as oldEnumName. }}
{{#*inline "oldNameCheck"}}
{{#if (or oldEnumName
(hasOldName (asUpperCamelCase ../name preserveAcronyms=true)))}}
{{#if oldEnumName}}
{{> oldNameDecl enumName=oldEnumName}}
{{else}}
{{> oldNameDecl enumName=(asUpperCamelCase label preserveAcronyms=true)}}
{{/if}}
{{/if}}
{{/inline}}
{{> oldNameCheck oldEnumName=(oldName (asUpperCamelCase ../name preserveAcronyms=true) enum=(asUpperCamelCase label preserveAcronyms=true))}}

{{/zcl_enums}}
{{#zcl_bitmaps}}
{{#*inline "bitmapDef"}}
typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName label}}) {
typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitmapName}}) {
{{#zcl_bitmap_items}}
{{objCEnumName ../clusterName ../label}}{{objCEnumItemLabel label}} {{availability ../clusterName bitmap=(asUpperCamelCase ../label preserveAcronyms=true) bitmapValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex mask}},
{{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel label}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=(objCEnumItemLabel label) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (objCEnumItemLabel label))}} = {{asHex mask}},
{{/zcl_bitmap_items}}
}
{{/inline}}
{{> bitmapDef name=name clusterName=(asUpperCamelCase ../name preserveAcronyms=true) label=label}} {{availability (asUpperCamelCase ../name preserveAcronyms=true) bitmap=(asUpperCamelCase label preserveAcronyms=true)}};
{{#unless (isStrEqual (asUpperCamelCase ../name preserveAcronyms=true) (compatClusterNameRemapping ../name))}}
{{> bitmapDef name=name clusterName=(asUpperCamelCase ../name preserveAcronyms=true) bitmapName=(asUpperCamelCase label preserveAcronyms=true)}} {{availability (asUpperCamelCase ../name preserveAcronyms=true) bitmap=(asUpperCamelCase label preserveAcronyms=true)}};
{{! Takes the name of the bitmap to use as bitmapName. }}
{{#*inline "oldNameDecl"}}

{{> bitmapDef name=name clusterName=(compatClusterNameRemapping ../name) label=label}} {{availability (compatClusterNameRemapping ../name) bitmap=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../name preserveAcronyms=true) label))}};
{{/unless}}
{{> bitmapDef name=name clusterName=(compatClusterNameRemapping ../name) bitmapName=bitmapName}} {{availability (compatClusterNameRemapping ../name) bitmap=bitmapName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../name preserveAcronyms=true) label))}};
{{/inline}}
{{! Takes the old name of the bitmap, if any, as oldBitmapName. }}
{{#*inline "oldNameCheck"}}
{{#if (or oldBitmapName
(hasOldName (asUpperCamelCase ../name preserveAcronyms=true)))}}
{{#if oldBitmapName}}
{{> oldNameDecl bitmapName=oldBitmapName}}
{{else}}
{{> oldNameDecl bitmapName=(asUpperCamelCase label preserveAcronyms=true)}}
{{/if}}
{{/if}}
{{/inline}}
{{> oldNameCheck oldBitmapName=(oldName (asUpperCamelCase ../name preserveAcronyms=true) bitmap=(asUpperCamelCase label preserveAcronyms=true))}}


{{/zcl_bitmaps}}
Expand Down

0 comments on commit bc836e0

Please sign in to comment.