Skip to content

Commit

Permalink
Fix Darwin availability bits for command payloads: (#29468)
Browse files Browse the repository at this point in the history
1) Add missing isForCommandPayload=true to declarations of the old command
   payload names.  Otherwise we were ending up with SetUtcTime being marked
   provisional, which is not backwards-compatible.
2) We need to declare fields in the old-name command payloads with the right
   availability, since the availability in the super-class is "too new".  The
   implementation then needs to use @dynamic.  This is similar to how structs
   work.
3) SetUTCTime cannot be provisional (and hence unavailable) if SetUtcTime is
   supposed to be available and inherits from it.  This requires exposing
   SetUTCTime and its fields in the first release where we will update
   Matter.framework in the Xcode SDK to the setup where we started doing
   "provisionally available".

Items 1 and 2 are handled by using "completeDecl" for both the old and new name.
  • Loading branch information
bzbarsky-apple authored Sep 29, 2023
1 parent 38d6a48 commit 42957dc
Show file tree
Hide file tree
Showing 5 changed files with 1,583 additions and 191 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ NS_ASSUME_NONNULL_BEGIN
{{#*inline "oldNameImpl"}}

@implementation MTR{{cluster}}Cluster{{command}}Params
{{#zcl_command_arguments}}
{{#if (isSupported ../cluster command=../command commandField=(asStructPropertyName label))}}
@dynamic {{asStructPropertyName label}};
{{/if}}
{{/zcl_command_arguments}}

{{#if (isStrEqual source "client")}}
@dynamic timedInvokeTimeoutMs;
@dynamic serverSideProcessingTimeout;
{{else if (wasIntroducedBeforeRelease "First major API revamp" cluster command=command)}}
@dynamic timedInvokeTimeoutMs;
{{/if}}
@end
{{/inline}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
Expand Down
30 changes: 22 additions & 8 deletions src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ NS_ASSUME_NONNULL_BEGIN
{{#*inline "completeDecl"}}
{{#if (isSupported cluster command=command isForCommandPayload=true)}}

{{availability cluster command=command isForCommandPayload=true deprecationMessage="This command has been removed"}}
@interface MTR{{cluster}}Cluster{{command}}Params : NSObject <NSCopying>
{{availability cluster command=command isForCommandPayload=true deprecationMessage=deprecationMessage}}
@interface MTR{{cluster}}Cluster{{command}}Params : {{base}}
{{#zcl_command_arguments}}

{{#if (isSupported ../cluster command=../command commandField=(asStructPropertyName label))}}
{{> struct_field_decl cluster=parent.parent.name type=type label=label}} {{availability ../cluster command=../command commandField=(asStructPropertyName label) deprecationMessage=(concat "The " (asStructPropertyName label) " field will be removed")}};
{{/if}}
{{#*inline "oldNameFieldDecl"}}

{{#if (isSupported ../cluster command=../command commandField=commandField)}}
{{> struct_field_decl cluster=parent.parent.name type=type label=commandField}} {{availability ../cluster command=../command commandField=commandField deprecationMessage=(concat "Please use " (asStructPropertyName label))}};
{{/if}}
{{/inline}}
{{#if (and includeRenamedProperties
(hasOldName ../cluster command=../command commandField=(asStructPropertyName label)))}}
Expand Down Expand Up @@ -68,7 +72,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs {{availability "" api="Timed Invoke for server to client commands" deprecationMessage="Timed invoke does not make sense for server to client commands"}};
{{/if}}
{{#if (isStrEqual source "server")}}
{{#if (and (isStrEqual source "server")
includeInitWithResponseValue)}}

/**
* Initialize an MTR{{cluster}}Cluster{{command}}Params with a response-value dictionary
Expand All @@ -88,15 +93,21 @@ NS_ASSUME_NONNULL_BEGIN
{{/inline}}
{{#*inline "oldNameDecl"}}

{{availability cluster command=command deprecationMessage=(concat "Please use MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true) "Params")}}
@interface MTR{{cluster}}Cluster{{command}}Params : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name}}Params
@end
{{> completeDecl cluster=cluster
command=command
includeRenamedProperties=true
deprecationMessage=(concat "Please use MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true) "Params")
base=(concat "MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true) "Params")
includeInitWithResponseValue=false}}

{{/inline}}
{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}}
{{> completeDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true)
command=(asUpperCamelCase name preserveAcronyms=true)
includeRenamedProperties=false}}
includeRenamedProperties=false
deprecationMessage="This command has been removed"
base="NSObject <NSCopying>"
includeInitWithResponseValue=true}}
{{#if (or (not (isStrEqual (asUpperCamelCase parent.name preserveAcronyms=true) (compatClusterNameRemapping parent.name)))
(not (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatCommandNameRemapping parent.name name))))}}
{{> oldNameDecl cluster=(compatClusterNameRemapping parent.name)
Expand All @@ -123,7 +134,10 @@ NS_ASSUME_NONNULL_BEGIN
{{else}}
{{> completeDecl cluster=(compatClusterNameRemapping parent.name)
command=(compatCommandNameRemapping parent.name name)
includeRenamedProperties=true}}
includeRenamedProperties=true
deprecationMessage="This command has been removed"
base="NSObject <NSCopying>"
includeInitWithResponseValue=true}}
{{/if}}
{{/zcl_commands}}
{{/zcl_clusters}}
Expand Down
16 changes: 16 additions & 0 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6331,6 +6331,13 @@
commands:
BasicInformation:
- MfgSpecificPing
command fields:
# Cases where the cluster/command got renamed and the fields got
# renamed, so the old command name never had the new fields.
OtaSoftwareUpdateProvider:
QueryImage:
- vendorID
- productID
enums:
# DoorLockUserStatus (non-spec) and UserStatusEnum (from the spec) end
# up with the same enum name (MTRDoorLockUserStatus), so just remove
Expand Down Expand Up @@ -7577,6 +7584,15 @@
- release: "Future"
versions: "future"
introduced:
command payloads:
TimeSynchronization:
- SetUTCTime
command fields:
TimeSynchronization:
SetUTCTime:
- utcTime
- granularity
- timeSource
enum values:
OnOff:
DelayedAllOffEffectVariantEnum:
Expand Down
Loading

0 comments on commit 42957dc

Please sign in to comment.