Skip to content

Commit

Permalink
Add better APIs for initializing MTRCluster instances from Swift. (#2…
Browse files Browse the repository at this point in the history
  • Loading branch information
bzbarsky-apple authored Oct 24, 2023
1 parent 9ff8254 commit 954fff0
Show file tree
Hide file tree
Showing 8 changed files with 788 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/MTRDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
#if MTR_ENABLE_PROVISIONAL
#define MTR_PROVISIONALLY_AVAILABLE MTR_NEWLY_AVAILABLE
#else
#define MTR_PROVISIONALLY_AVAILABLE NS_UNAVAILABLE MTR_HIDDEN
#define MTR_PROVISIONALLY_AVAILABLE API_UNAVAILABLE(ios, macos, tvos, watchos) MTR_HIDDEN
#endif

#ifndef MTR_PER_CONTROLLER_STORAGE_ENABLED
Expand Down
15 changes: 15 additions & 0 deletions src/darwin/Framework/CHIP/templates/MTRClusters-swift.zapt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{> header excludeZapComment=true}}

private let clusterQueue = DispatchQueue(label: "MTRCluster completion dispatch")

{{#zcl_clusters}}
{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}}
{{swiftAvailability (asUpperCamelCase name preserveAcronyms=true) minimalRelease="Future"}}
extension MTRCluster{{asUpperCamelCase name preserveAcronyms=true}} {
public convenience init(device : MTRDevice, endpointID: UInt) {
self.init(device: device, endpointID: endpointID as NSNumber, queue: clusterQueue)!
}
}

{{/if}}
{{/zcl_clusters}}
56 changes: 28 additions & 28 deletions src/darwin/Framework/CHIP/templates/availability.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@

- release: "Initial release"
versions:
ios: "16.1"
macos: "13.0"
watchos: "9.1"
tvos: "16.1"
iOS: "16.1"
macOS: "13.0"
watchOS: "9.1"
tvOS: "16.1"
introduced:
clusters:
- Identify
Expand Down Expand Up @@ -4722,10 +4722,10 @@

- release: "First dot-release"
versions:
ios: "16.2"
macos: "13.1"
watchos: "9.2"
tvos: "16.2"
iOS: "16.2"
macOS: "13.1"
watchOS: "9.2"
tvOS: "16.2"
introduced:
attributes:
TestCluster:
Expand Down Expand Up @@ -4778,10 +4778,10 @@

- release: "First major API revamp"
versions:
ios: "16.4"
macos: "13.3"
watchos: "9.4"
tvos: "16.4"
iOS: "16.4"
macOS: "13.3"
watchOS: "9.4"
tvOS: "16.4"
introduced:
clusters:
- OTASoftwareUpdateProvider
Expand Down Expand Up @@ -6723,10 +6723,10 @@

- release: "First after major API revamp"
versions:
ios: "16.5"
macos: "13.4"
watchos: "9.5"
tvos: "16.5"
iOS: "16.5"
macOS: "13.4"
watchOS: "9.5"
tvOS: "16.5"
introduced:
ids:
attributes:
Expand Down Expand Up @@ -7031,10 +7031,10 @@

- release: "Fall 2023"
versions:
ios: "17.0"
macos: "14.0"
watchos: "10.0"
tvos: "17.0"
iOS: "17.0"
macOS: "14.0"
watchOS: "10.0"
tvOS: "17.0"
introduced:
attributes:
BasicInformation:
Expand Down Expand Up @@ -7515,10 +7515,10 @@

- release: "Fall 2023 #2"
versions:
ios: "17.1"
macos: "14.1"
watchos: "10.1"
tvos: "17.1"
iOS: "17.1"
macOS: "14.1"
watchOS: "10.1"
tvOS: "17.1"
introduced:
bitmaps:
TimeFormatLocalization:
Expand Down Expand Up @@ -7583,10 +7583,10 @@

- release: "Fall 2023 #3"
versions:
ios: "17.2"
macos: "14.2"
watchos: "10.2"
tvos: "17.2"
iOS: "17.2"
macOS: "14.2"
watchOS: "10.2"
tvOS: "17.2"
introduced:
command payloads:
TimeSynchronization:
Expand Down
5 changes: 5 additions & 0 deletions src/darwin/Framework/CHIP/templates/templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@
"name": "Objc ZCL synchronous API",
"output": "src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm"
},
{
"path": "MTRClusters-swift.zapt",
"name": "Swift ZCL synchronous API Header extensions",
"output": "src/darwin/Framework/CHIP/zap-generated/MTRClusters.swift"
},
{
"path": "MTRStructsObjc.zapt",
"name": "Objc reflections of MTR spec structs header",
Expand Down
Loading

0 comments on commit 954fff0

Please sign in to comment.