Skip to content

Commit 797b146

Browse files
authored
Merge pull request #426 from silvanshade/more-frameworks
Add HealthKit, MediaPlayer, MetricKit, PhotoKit frameworks
2 parents abf973e + 9596ab9 commit 797b146

File tree

20 files changed

+933
-50
lines changed

20 files changed

+933
-50
lines changed

crates/header-translator/framework-includes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@
6363

6464
#import <GameKit/GameKit.h>
6565

66+
#import <HealthKit/HealthKit.h>
67+
6668
#import <IdentityLookup/IdentityLookup.h>
6769

6870
#import <InputMethodKit/InputMethodKit.h>
@@ -75,12 +77,18 @@
7577

7678
#import <MapKit/MapKit.h>
7779

80+
#import <MediaPlayer/MediaPlayer.h>
81+
7882
#import <Metal/Metal.h>
7983

8084
#import <MetalFX/MetalFX.h>
8185

8286
#import <MetalKit/MetalKit.h>
8387

88+
#import <MetricKit/MetricKit.h>
89+
90+
#import <Photos/Photos.h>
91+
8492
#import <QuartzCore/CoreAnimation.h>
8593

8694
#import <SoundAnalysis/SoundAnalysis.h>

crates/header-translator/src/availability.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ use crate::context::Context;
88
#[derive(Debug, Clone, PartialEq, Default)]
99
struct Unavailable {
1010
ios: bool,
11+
ios_app_extension: bool,
1112
macos: bool,
13+
macos_app_extension: bool,
1214
maccatalyst: bool,
1315
watchos: bool,
1416
tvos: bool,
@@ -17,7 +19,9 @@ struct Unavailable {
1719
#[derive(Debug, Clone, PartialEq, Default)]
1820
struct Versions {
1921
ios: Option<Version>,
22+
ios_app_extension: Option<Version>,
2023
macos: Option<Version>,
24+
macos_app_extension: Option<Version>,
2125
maccatalyst: Option<Version>,
2226
watchos: Option<Version>,
2327
tvos: Option<Version>,
@@ -76,12 +80,24 @@ impl Availability {
7680
&mut introduced.ios,
7781
&mut deprecated.ios,
7882
),
83+
"ios_app_extension" => set(
84+
availability,
85+
&mut unavailable.ios_app_extension,
86+
&mut introduced.ios_app_extension,
87+
&mut deprecated.ios_app_extension,
88+
),
7989
"macos" => set(
8090
availability,
8191
&mut unavailable.macos,
8292
&mut introduced.macos,
8393
&mut deprecated.macos,
8494
),
95+
"macos_app_extension" => set(
96+
availability,
97+
&mut unavailable.macos_app_extension,
98+
&mut introduced.macos_app_extension,
99+
&mut deprecated.macos_app_extension,
100+
),
85101
"maccatalyst" => set(
86102
availability,
87103
&mut unavailable.maccatalyst,
@@ -122,7 +138,9 @@ impl fmt::Display for Availability {
122138
match &self.deprecated {
123139
Versions {
124140
ios: None,
141+
ios_app_extension: None,
125142
macos: None,
143+
macos_app_extension: None,
126144
maccatalyst: None,
127145
watchos: None,
128146
tvos: None,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data! {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data! {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data! {}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data! {}

crates/header-translator/src/data/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,21 @@ data! {
3232
mod Foundation;
3333
mod GameController;
3434
mod GameKit;
35+
mod HealthKit;
3536
mod IdentityLookup;
3637
mod InputMethodKit;
3738
mod LocalAuthentication;
3839
mod LocalAuthenticationEmbeddedUI;
3940
mod LinkPresentation;
4041
mod MailKit;
4142
mod MapKit;
43+
mod MediaPlayer;
4244
mod Metal;
4345
mod MetalFX;
4446
mod MetalKit;
47+
mod MetricKit;
4548
mod OSAKit;
49+
mod PhotoKit;
4650
mod SoundAnalysis;
4751
mod Speech;
4852
mod StoreKit;

crates/header-translator/src/method.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ impl MethodModifiers {
108108
EntityKind::ObjCInstanceMethodDecl => {
109109
warn!("method inside property/method");
110110
}
111+
EntityKind::VisibilityAttr => {
112+
// TODO: Handle these visibility attributes
113+
}
111114
_ => error!("unknown"),
112115
});
113116

crates/header-translator/src/unexposed_attr.rs

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -74,84 +74,92 @@ impl UnexposedAttr {
7474
// Weak specifiers - would be interesting if Rust supported weak statics
7575
"GK_EXTERN_WEAK" => None,
7676
// Availability attributes - their data is already exposed.
77-
"API_AVAILABLE"
78-
| "API_UNAVAILABLE"
79-
| "API_DEPRECATED"
77+
"__IOS_AVAILABLE"
78+
| "__OSX_AVAILABLE_STARTING"
79+
| "__TVOS_AVAILABLE"
80+
| "__WATCHOS_AVAILABLE"
81+
| "API_AVAILABLE_BEGIN"
82+
| "API_AVAILABLE"
8083
| "API_DEPRECATED_WITH_REPLACEMENT"
84+
| "API_DEPRECATED"
8185
| "API_UNAVAILABLE_BEGIN"
82-
| "NS_CLASS_AVAILABLE_MAC"
86+
| "API_UNAVAILABLE"
87+
| "CF_SWIFT_UNAVAILABLE"
88+
| "CG_AVAILABLE_BUT_DEPRECATED"
89+
| "CG_AVAILABLE_STARTING"
90+
| "FPUI_AVAILABLE"
91+
| "MP_API"
92+
| "MP_DEPRECATED_WITH_REPLACEMENT"
93+
| "MP_DEPRECATED"
94+
| "MP_UNAVAILABLE_BEGIN"
95+
| "MP_UNAVAILABLE"
96+
| "NS_AVAILABLE_MAC"
8397
| "NS_AVAILABLE"
84-
| "NS_OPENGL_DEPRECATED"
98+
| "NS_CLASS_AVAILABLE_MAC"
99+
| "NS_CLASS_AVAILABLE"
100+
| "NS_CLASS_DEPRECATED_IOS"
101+
| "NS_CLASS_DEPRECATED"
102+
| "NS_DEPRECATED_IOS"
103+
| "NS_DEPRECATED_MAC"
104+
| "NS_DEPRECATED"
105+
| "NS_ENUM_AVAILABLE"
106+
| "NS_ENUM_DEPRECATED_IOS"
107+
| "NS_ENUM_DEPRECATED"
108+
| "NS_EXTENSION_UNAVAILABLE"
85109
| "NS_OPENGL_CLASS_DEPRECATED"
110+
| "NS_OPENGL_DEPRECATED"
86111
| "NS_OPENGL_ENUM_DEPRECATED"
112+
| "NS_SWIFT_UNAVAILABLE"
87113
| "OBJC_AVAILABLE"
88114
| "OBJC_DEPRECATED"
89-
| "NS_DEPRECATED"
90-
| "NS_DEPRECATED_IOS"
91-
| "NS_DEPRECATED_MAC"
92-
| "CG_AVAILABLE_STARTING"
93-
| "CG_AVAILABLE_BUT_DEPRECATED"
94-
| "NS_SWIFT_UNAVAILABLE"
95-
| "CF_SWIFT_UNAVAILABLE"
96115
| "OBJC_SWIFT_UNAVAILABLE"
97-
| "FPUI_AVAILABLE"
98116
| "WEBKIT_AVAILABLE_MAC"
99-
| "WEBKIT_DEPRECATED_MAC"
100117
| "WEBKIT_CLASS_DEPRECATED_MAC"
101-
| "WEBKIT_ENUM_DEPRECATED_MAC"
102-
| "NS_AVAILABLE_MAC"
103-
| "NS_CLASS_AVAILABLE"
104-
| "NS_CLASS_DEPRECATED"
105-
| "NS_CLASS_DEPRECATED_IOS"
106-
| "NS_ENUM_AVAILABLE"
107-
| "NS_ENUM_DEPRECATED"
108-
| "NS_ENUM_DEPRECATED_IOS"
109-
| "__OSX_AVAILABLE_STARTING"
110-
| "__TVOS_AVAILABLE"
111-
| "__WATCHOS_AVAILABLE"
112-
| "__IOS_AVAILABLE" => {
118+
| "WEBKIT_DEPRECATED_MAC"
119+
| "WEBKIT_ENUM_DEPRECATED_MAC" => {
113120
let _ = get_arguments();
114121
None
115122
}
116-
"NS_UNAVAILABLE"
117-
| "UNAVAILABLE_ATTRIBUTE"
118-
| "NS_AUTOMATED_REFCOUNT_UNAVAILABLE"
119-
| "NS_AUTOMATED_REFCOUNT_WEAK_UNAVAILABLE"
120-
| "APPKIT_API_UNAVAILABLE_BEGIN_MACCATALYST"
121-
| "__OSX_UNAVAILABLE"
123+
"__IOS_PROHIBITED"
124+
| "__IOS_UNAVAILABLE"
122125
| "__OSX_AVAILABLE_BUT_DEPRECATED"
123-
| "__TVOS_UNAVAILABLE"
126+
| "__OSX_UNAVAILABLE"
124127
| "__TVOS_PROHIBITED"
125-
| "__WATCHOS_UNAVAILABLE"
128+
| "__TVOS_UNAVAILABLE"
126129
| "__WATCHOS_PROHIBITED"
127-
| "__IOS_UNAVAILABLE"
128-
| "UT_AVAILABLE_BEGIN"
129-
| "__IOS_PROHIBITED" => None,
130+
| "__WATCHOS_UNAVAILABLE"
131+
| "APPKIT_API_UNAVAILABLE_BEGIN_MACCATALYST"
132+
| "MP_INIT_UNAVAILABLE"
133+
| "NS_AUTOMATED_REFCOUNT_UNAVAILABLE"
134+
| "NS_AUTOMATED_REFCOUNT_WEAK_UNAVAILABLE"
135+
| "NS_UNAVAILABLE"
136+
| "UNAVAILABLE_ATTRIBUTE"
137+
| "UT_AVAILABLE_BEGIN" => None,
130138
s if s.starts_with("AVAILABLE_MAC_OS_X_VERSION_") => None,
131139
s if s.starts_with("DEPRECATED_IN_MAC_OS_X_VERSION_") => None,
132140
s if s.starts_with("FILEPROVIDER_API_AVAILABILITY_") => None,
133141
// Might be interesting in the future
134-
"NS_SWIFT_NAME"
135-
| "CF_SWIFT_NAME"
136-
| "NS_SWIFT_ASYNC_NAME"
137-
| "WK_SWIFT_ASYNC_NAME"
138-
| "NS_SWIFT_ASYNC_THROWS_ON_FALSE"
139-
| "NS_SWIFT_UNAVAILABLE_FROM_ASYNC"
142+
"CF_SWIFT_NAME"
140143
| "NS_HEADER_AUDIT_BEGIN"
141144
| "NS_REFINED_FOR_SWIFT_ASYNC"
145+
| "NS_SWIFT_ASYNC_NAME"
146+
| "NS_SWIFT_ASYNC_THROWS_ON_FALSE"
142147
| "NS_SWIFT_ASYNC"
148+
| "NS_SWIFT_NAME"
149+
| "NS_SWIFT_UNAVAILABLE_FROM_ASYNC"
150+
| "WK_SWIFT_ASYNC_NAME"
143151
| "WK_SWIFT_ASYNC" => {
144152
let _ = get_arguments();
145153
None
146154
}
147-
"NS_SWIFT_NOTHROW"
155+
"CF_REFINED_FOR_SWIFT"
148156
| "NS_REFINED_FOR_SWIFT"
149-
| "CF_REFINED_FOR_SWIFT"
150157
| "NS_SWIFT_DISABLE_ASYNC"
151-
| "NS_SWIFT_UI_ACTOR"
152-
| "NS_SWIFT_SENDABLE"
158+
| "NS_SWIFT_NONISOLATED"
153159
| "NS_SWIFT_NONSENDABLE"
154-
| "NS_SWIFT_NONISOLATED" => None,
160+
| "NS_SWIFT_NOTHROW"
161+
| "NS_SWIFT_SENDABLE"
162+
| "NS_SWIFT_UI_ACTOR" => None,
155163
_ => return Err(()),
156164
})
157165
}

crates/header-translator/translation-config.toml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ ios = "3.0"
247247
tvos = "9.0"
248248
watchos = "3.0"
249249

250+
[library.HealthKit]
251+
imports = ["CoreLocation", "Foundation", "UniformTypeIdentifiers"]
252+
macos = "13.0"
253+
maccatalyst = "13.0"
254+
ios = "8.0"
255+
watchos = "2.0"
256+
250257
[library.IdentityLookup]
251258
imports = ["Foundation"]
252259
macos = "10.15"
@@ -299,6 +306,14 @@ ios = "3.0"
299306
tvos = "9.2"
300307
watchos = "2.0"
301308

309+
[library.MediaPlayer]
310+
imports = ["AppKit", "Foundation"]
311+
macos = "10.12.1"
312+
maccatalyst = "13.0"
313+
ios = "2.0"
314+
tvos = "9.0"
315+
watchos = "5.0"
316+
302317
[library.Metal]
303318
imports = ["Foundation"]
304319
macos = "10.11"
@@ -324,6 +339,21 @@ maccatalyst = "13.0"
324339
ios = "9.0"
325340
tvos = "9.0"
326341

342+
[library.MetricKit]
343+
imports = ["Foundation"]
344+
macos = "12.0"
345+
maccatalyst = "13.0"
346+
ios = "13.0"
347+
348+
[library.Photos]
349+
name = "PhotoKit"
350+
imports = ["AppKit", "CoreLocation", "Foundation"]
351+
macos = "10.11"
352+
maccatalyst = "13.0"
353+
ios = "8.0"
354+
tvos = "10.0"
355+
watchos = "9.0"
356+
327357
[library.OSAKit]
328358
imports = ["AppKit", "Foundation"]
329359
macos = "10.4"
@@ -1162,6 +1192,41 @@ skipped = true
11621192
skipped = true
11631193
[class.LAPublicKey.methods.verifyData_signature_secKeyAlgorithm_completion]
11641194
skipped = true
1195+
# Needs `CGImagePropertyOrientation` from `ImageIO`
1196+
[class.PHLivePhotoEditingContext.methods.orientation]
1197+
skipped = true
1198+
[class.PHImageManager.methods.requestImageDataAndOrientationForAsset_options_resultHandler]
1199+
skipped = true
1200+
# Needs `UIImageOrientation` from `UIKit`
1201+
[class.PHImageManager.methods.requestImageDataForAsset_options_resultHandler]
1202+
skipped = true
1203+
# Needs `CMTime` from `CoreMedia`
1204+
[class.PHLivePhotoEditingContext.methods.duration]
1205+
skipped = true
1206+
[class.PHLivePhotoEditingContext.methods.photoTime]
1207+
skipped = true
1208+
[protocol.PHLivePhotoFrame.methods.time]
1209+
skipped = true
1210+
# Needs `PHLivePhotoFrameProcessingBlock` (skipped because needs `CIImage`)
1211+
[class.PHLivePhotoEditingContext.methods.frameProcessor]
1212+
skipped = true
1213+
[class.PHLivePhotoEditingContext.methods.setFrameProcessor]
1214+
skipped = true
1215+
# Needs `CIImage` from `CoreImage`
1216+
[typedef.PHLivePhotoFrameProcessingBlock]
1217+
skipped = true
1218+
# Needs `dispatch_block_t`
1219+
[class.PHPhotoLibrary.methods.performChanges_completionHandler]
1220+
skipped = true
1221+
[class.PHPhotoLibrary.methods.performChangesAndWait_error]
1222+
skipped = true
1223+
# Needs `CMTimeRange` from `CoreMedia`
1224+
[class.MPAdTimeRange.methods.initWithTimeRange]
1225+
skipped = true
1226+
[class.MPAdTimeRange.methods.timeRange]
1227+
skipped = true
1228+
[class.MPAdTimeRange.methods.setTimeRange]
1229+
skipped = true
11651230

11661231
# Uses a pointer to SEL, which doesn't implement Encode yet
11671232
[protocol.NSMenuDelegate.methods]
@@ -1467,3 +1532,15 @@ skipped = true
14671532
# produces wrong values for most cases; manually define for now
14681533
[enum.LAError]
14691534
skipped = true
1535+
1536+
# fails to strip const from `typedef const NSString *const MXLaunchTaskID;`
1537+
[typedef.MXLaunchTaskID]
1538+
skipped = true
1539+
# fails to parse method argument with `MXLaunchTaskID`
1540+
[class.MXMetricManager.methods.extendLaunchMeasurementForTaskID_error]
1541+
skipped = true
1542+
[class.MXMetricManager.methods.finishExtendedLaunchMeasurementForTaskID_error]
1543+
skipped = true
1544+
# `os_log_t` not defined; skip for now
1545+
[class.MXMetricManager.methods.makeLogHandleWithCategory]
1546+
skipped = true

0 commit comments

Comments
 (0)