From 515acb062766e9fa3bebfe60ee1a2266f3ae658b Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Mon, 9 Dec 2024 22:03:05 +0100 Subject: [PATCH] Use CoreFoundation types where previously not possible --- Cargo.lock | 2 ++ .../objc2-core-bluetooth/Cargo.toml | 11 +++++++--- .../translation-config.toml | 6 ------ framework-crates/objc2-core-wlan/Cargo.toml | 18 +++++++++++++---- framework-crates/objc2-core-wlan/src/lib.rs | 3 +++ .../objc2-core-wlan/translation-config.toml | 20 ++++--------------- framework-crates/objc2-foundation/Cargo.toml | 2 +- .../objc2-foundation/translation-config.toml | 5 +---- .../objc2-game-controller/src/lib.rs | 5 ----- .../translation-config.toml | 3 --- .../objc2-quartz-core/translation-config.toml | 4 +--- framework-crates/objc2-ui-kit/Cargo.toml | 1 + .../objc2-ui-kit/translation-config.toml | 3 --- framework-crates/objc2-vision/Cargo.toml | 1 + .../objc2-vision/translation-config.toml | 4 ---- generated | 2 +- 16 files changed, 37 insertions(+), 53 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 84ba7cf6c..e392c2c3a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -564,6 +564,7 @@ version = "0.2.2" dependencies = [ "bitflags", "objc2", + "objc2-core-foundation", "objc2-foundation", ] @@ -636,6 +637,7 @@ version = "0.2.2" dependencies = [ "bitflags", "objc2", + "objc2-core-foundation", "objc2-foundation", ] diff --git a/framework-crates/objc2-core-bluetooth/Cargo.toml b/framework-crates/objc2-core-bluetooth/Cargo.toml index 769b1c8fc..8b467a9ac 100644 --- a/framework-crates/objc2-core-bluetooth/Cargo.toml +++ b/framework-crates/objc2-core-bluetooth/Cargo.toml @@ -18,6 +18,7 @@ workspace = true [dependencies] bitflags = { version = "2.5.0", default-features = false, optional = true } objc2 = { path = "../../crates/objc2", version = "0.5.2", default-features = false } +objc2-core-foundation = { path = "../objc2-core-foundation", version = "0.2.2", default-features = false, optional = true } objc2-foundation = { path = "../objc2-foundation", version = "0.2.2", default-features = false } [package.metadata.docs.rs] @@ -36,9 +37,10 @@ targets = [ default = ["std"] # Currently not possible to turn off, put here for forwards compatibility. -std = ["alloc", "bitflags?/std", "objc2/std", "objc2-foundation/std"] -alloc = ["objc2/alloc", "objc2-foundation/alloc"] -bitflags = ["dep:bitflags", "objc2-foundation/bitflags"] +std = ["alloc", "bitflags?/std", "objc2/std", "objc2-core-foundation?/std", "objc2-foundation/std"] +alloc = ["objc2/alloc", "objc2-core-foundation?/alloc", "objc2-foundation/alloc"] +bitflags = ["dep:bitflags", "objc2-core-foundation?/bitflags", "objc2-foundation/bitflags"] +objc2-core-foundation = ["dep:objc2-core-foundation", "objc2-foundation/objc2-core-foundation"] CBATTRequest = ["objc2-foundation/NSData"] CBAdvertisementData = ["objc2-foundation/NSString"] @@ -46,6 +48,7 @@ CBAttribute = [] CBCentral = ["objc2-foundation/NSObject"] CBCentralManager = [ "bitflags", + "objc2-core-foundation?/CFDate", "objc2-foundation/NSArray", "objc2-foundation/NSDictionary", "objc2-foundation/NSError", @@ -86,6 +89,7 @@ CBPeripheralManager = [ CBPeripheralManagerConstants = ["objc2-foundation/NSString"] CBService = ["objc2-foundation/NSArray"] CBUUID = [ + "objc2-core-foundation?/CFUUID", "objc2-foundation/NSData", "objc2-foundation/NSObject", "objc2-foundation/NSString", @@ -111,4 +115,5 @@ all = [ "CBService", "CBUUID", "bitflags", + "objc2-core-foundation", ] diff --git a/framework-crates/objc2-core-bluetooth/translation-config.toml b/framework-crates/objc2-core-bluetooth/translation-config.toml index d7facd8a9..eae940369 100644 --- a/framework-crates/objc2-core-bluetooth/translation-config.toml +++ b/framework-crates/objc2-core-bluetooth/translation-config.toml @@ -13,9 +13,3 @@ class.CBCentralManager.methods."initWithDelegate:queue:".skipped = true class.CBCentralManager.methods."initWithDelegate:queue:options:".skipped = true class.CBPeripheralManager.methods."initWithDelegate:queue:".skipped = true class.CBPeripheralManager.methods."initWithDelegate:queue:options:".skipped = true - -# Needs `CFAbsoluteTime` -protocol.CBCentralManagerDelegate.methods."centralManager:didDisconnectPeripheral:timestamp:isReconnecting:error:".skipped = true - -# Needs `CFUUIDRef` -class.CBUUID.methods."UUIDWithCFUUID:".skipped = true diff --git a/framework-crates/objc2-core-wlan/Cargo.toml b/framework-crates/objc2-core-wlan/Cargo.toml index 3a1f102eb..cd6fbaeb4 100644 --- a/framework-crates/objc2-core-wlan/Cargo.toml +++ b/framework-crates/objc2-core-wlan/Cargo.toml @@ -18,6 +18,7 @@ workspace = true [dependencies] bitflags = { version = "2.5.0", default-features = false, optional = true } objc2 = { path = "../../crates/objc2", version = "0.5.2", default-features = false } +objc2-core-foundation = { path = "../objc2-core-foundation", version = "0.2.2", default-features = false, optional = true } objc2-foundation = { path = "../objc2-foundation", version = "0.2.2", default-features = false } [package.metadata.docs.rs] @@ -33,9 +34,10 @@ targets = [ default = ["std"] # Currently not possible to turn off, put here for forwards compatibility. -std = ["alloc", "bitflags?/std", "objc2/std", "objc2-foundation/std"] -alloc = ["objc2/alloc", "objc2-foundation/alloc"] -bitflags = ["dep:bitflags", "objc2-foundation/bitflags"] +std = ["alloc", "bitflags?/std", "objc2/std", "objc2-core-foundation?/std", "objc2-foundation/std"] +alloc = ["objc2/alloc", "objc2-core-foundation?/alloc", "objc2-foundation/alloc"] +bitflags = ["dep:bitflags", "objc2-core-foundation?/bitflags", "objc2-foundation/bitflags"] +objc2-core-foundation = ["dep:objc2-core-foundation", "objc2-foundation/objc2-core-foundation"] CWChannel = ["objc2-foundation/NSObject"] CWConfiguration = [ @@ -65,7 +67,14 @@ CWWiFiClient = [ ] CoreWLANConstants = ["objc2-foundation/NSString"] CoreWLANTypes = ["bitflags"] -CoreWLANUtil = ["objc2-foundation/NSSet"] +CoreWLANUtil = [ + "objc2-core-foundation?/CFArray", + "objc2-core-foundation?/CFBase", + "objc2-core-foundation?/CFData", + "objc2-foundation/NSData", + "objc2-foundation/NSSet", + "objc2-foundation/NSString", +] all = [ "CWChannel", "CWConfiguration", @@ -77,4 +86,5 @@ all = [ "CoreWLANTypes", "CoreWLANUtil", "bitflags", + "objc2-core-foundation", ] diff --git a/framework-crates/objc2-core-wlan/src/lib.rs b/framework-crates/objc2-core-wlan/src/lib.rs index 07c1cd2ac..5e1157ae1 100644 --- a/framework-crates/objc2-core-wlan/src/lib.rs +++ b/framework-crates/objc2-core-wlan/src/lib.rs @@ -18,3 +18,6 @@ extern crate std; mod generated; #[allow(unused_imports, unreachable_pub)] pub use self::generated::*; + +#[allow(dead_code)] +pub(crate) type OSStatus = i32; diff --git a/framework-crates/objc2-core-wlan/translation-config.toml b/framework-crates/objc2-core-wlan/translation-config.toml index 4b3c73ace..9f14e2dc5 100644 --- a/framework-crates/objc2-core-wlan/translation-config.toml +++ b/framework-crates/objc2-core-wlan/translation-config.toml @@ -1,6 +1,7 @@ framework = "CoreWLAN" crate = "objc2-core-wlan" required-dependencies = ["objc2-foundation"] +custom-lib-rs = true macos = "10.6" maccatalyst = "13.0" @@ -10,24 +11,11 @@ class.CWMutableConfiguration.counterpart = "ImmutableSuperclass(CoreWLAN::CWConf class.CWNetworkProfile.counterpart = "MutableSubclass(CoreWLAN::CWNetworkProfile::CWMutableNetworkProfile)" class.CWMutableNetworkProfile.counterpart = "ImmutableSuperclass(CoreWLAN::CWNetworkProfile::CWNetworkProfile)" -# Uses types from CoreFoundation -fn.CWKeychainCopyEAPUsernameAndPassword.skipped = true -fn.CWKeychainCopyEAPIdentityList.skipped = true -fn.CWKeychainSetEAPUsernameAndPassword.skipped = true -fn.CWKeychainDeleteEAPUsernameAndPassword.skipped = true -fn.CWKeychainSetPassword.skipped = true -fn.CWKeychainDeletePassword.skipped = true -fn.CWKeychainCopyEAPIdentity.skipped = true -fn.CWKeychainSetEAPIdentity.skipped = true -fn.CWKeychainCopyPassword.skipped = true -fn.CWKeychainFindWiFiPassword.skipped = true -fn.CWKeychainSetWiFiPassword.skipped = true -fn.CWKeychainDeleteWiFiPassword.skipped = true -fn.CWKeychainFindWiFiEAPUsernameAndPassword.skipped = true -fn.CWKeychainSetWiFiEAPUsernameAndPassword.skipped = true -fn.CWKeychainDeleteWiFiEAPUsernameAndPassword.skipped = true +# Needs SecIdentityRef from Security fn.CWKeychainCopyWiFiEAPIdentity.skipped = true fn.CWKeychainSetWiFiEAPIdentity.skipped = true +fn.CWKeychainCopyEAPIdentity.skipped = true +fn.CWKeychainSetEAPIdentity.skipped = true class.CWInterface.methods."associateToEnterpriseNetwork:identity:username:password:error:".skipped = true # Needs `SFAuthorization` from the `SecurityFoundation` framework diff --git a/framework-crates/objc2-foundation/Cargo.toml b/framework-crates/objc2-foundation/Cargo.toml index aec7f7554..390308355 100644 --- a/framework-crates/objc2-foundation/Cargo.toml +++ b/framework-crates/objc2-foundation/Cargo.toml @@ -173,7 +173,7 @@ NSProxy = [] NSRange = [] NSRegularExpression = ["bitflags"] NSRelativeDateTimeFormatter = [] -NSRunLoop = [] +NSRunLoop = ["objc2-core-foundation?/CFRunLoop"] NSScanner = [] NSScriptClassDescription = [] NSScriptCoercionHandler = [] diff --git a/framework-crates/objc2-foundation/translation-config.toml b/framework-crates/objc2-foundation/translation-config.toml index de4ebc5d4..8dd83da51 100644 --- a/framework-crates/objc2-foundation/translation-config.toml +++ b/framework-crates/objc2-foundation/translation-config.toml @@ -12,6 +12,7 @@ gnustep = true # ns_consumed / NS_RELEASES_ARGUMENT / cf_consumed / CF_CONSUMED fn.CFBridgingRelease.skipped = true +fn.CFBridgingRetain.skipped = true fn.NSMakeCollectable.skipped = true fn.NSFreeMapTable.skipped = true protocol.NSKeyedUnarchiverDelegate.methods."unarchiver:didDecodeObject:".skipped = true @@ -174,10 +175,6 @@ class.NSDictionary.methods."dictionaryWithContentsOfURL:error:".skipped = true # enough to make it safe anyhow, we need to do manual work here anyhow. class.NSDictionary.categories.NSGenericFastEnumeration.skipped = true -# Needs CoreFoundation -fn.CFBridgingRetain.skipped = true -class.NSRunLoop.methods.getCFRunLoop.skipped = true - # Uses constants from CoreFoundation or similar frameworks enum.NSAppleEventSendOptions.use-value = true enum.NSCalendarUnit.use-value = true diff --git a/framework-crates/objc2-game-controller/src/lib.rs b/framework-crates/objc2-game-controller/src/lib.rs index ea959d17d..07ee1caeb 100644 --- a/framework-crates/objc2-game-controller/src/lib.rs +++ b/framework-crates/objc2-game-controller/src/lib.rs @@ -28,8 +28,3 @@ pub use self::extended_gamepad_snapshot::GCExtendedGamepadSnapshotData; pub use self::generated::*; #[cfg(feature = "GCInputNames")] pub use self::input_names::*; - -// TODO: GCKeyCode = CFIndex -// NOTE: CFIndex is c_long_long on __LLP64__ / Windows 64-bit (doesn't matter for us) -#[cfg(feature = "GCKeyCodes")] -pub type GCKeyCode = core::ffi::c_long; diff --git a/framework-crates/objc2-game-controller/translation-config.toml b/framework-crates/objc2-game-controller/translation-config.toml index 152f9024f..7494357d2 100644 --- a/framework-crates/objc2-game-controller/translation-config.toml +++ b/framework-crates/objc2-game-controller/translation-config.toml @@ -62,8 +62,5 @@ protocol.GCDevice.methods."setHandlerQueue:".skipped = true protocol.GCDevicePhysicalInput.methods.queue.skipped = true protocol.GCDevicePhysicalInput.methods."setQueue:".skipped = true -# Needs `CFIndex` (fixed locally for now) -typedef.GCKeyCode.skipped = true - # Needs `IOHIDDeviceRef` from IOKit class.GCController.methods."supportsHIDDevice:".skipped = true diff --git a/framework-crates/objc2-quartz-core/translation-config.toml b/framework-crates/objc2-quartz-core/translation-config.toml index 0cd7b5a77..fa4e35260 100644 --- a/framework-crates/objc2-quartz-core/translation-config.toml +++ b/framework-crates/objc2-quartz-core/translation-config.toml @@ -9,7 +9,7 @@ ios = "2.0" tvos = "9.0" visionos = "1.0" -# Uses stuff from CoreFoundation and CoreGraphics +# Uses stuff from CoreGraphics class.CAKeyframeAnimation.methods.path.skipped = true class.CAKeyframeAnimation.methods."setPath:".skipped = true class.CAShapeLayer.methods.path.skipped = true @@ -20,8 +20,6 @@ class.CAShapeLayer.methods.strokeColor.skipped = true class.CAShapeLayer.methods."setStrokeColor:".skipped = true class.CAEmitterCell.methods.color.skipped = true class.CAEmitterCell.methods."setColor:".skipped = true -class.CALayer.methods.affineTransform.skipped = true -class.CALayer.methods."setAffineTransform:".skipped = true class.CALayer.methods."drawInContext:".skipped = true class.CALayer.methods."renderInContext:".skipped = true class.CALayer.methods.backgroundColor.skipped = true diff --git a/framework-crates/objc2-ui-kit/Cargo.toml b/framework-crates/objc2-ui-kit/Cargo.toml index f472ac8f9..37690ce77 100644 --- a/framework-crates/objc2-ui-kit/Cargo.toml +++ b/framework-crates/objc2-ui-kit/Cargo.toml @@ -1457,6 +1457,7 @@ UISceneWindowingBehaviors = [] UIScene_AVAudioSession = [] UIScreen = [ "objc2-core-foundation?/CFCGTypes", + "objc2-core-foundation?/CFDate", "objc2-foundation/NSArray", "objc2-foundation/NSNotification", "objc2-foundation/NSString", diff --git a/framework-crates/objc2-ui-kit/translation-config.toml b/framework-crates/objc2-ui-kit/translation-config.toml index 11c16dd08..ccb66cc82 100644 --- a/framework-crates/objc2-ui-kit/translation-config.toml +++ b/framework-crates/objc2-ui-kit/translation-config.toml @@ -132,9 +132,6 @@ class.UIImage.methods."drawInRect:blendMode:alpha:".skipped = true fn.UIRectFillUsingBlendMode.skipped = true fn.UIRectFrameUsingBlendMode.skipped = true -# Needs `CFTimeInterval` -class.UIScreen.methods.calibratedLatency.skipped = true - # Needs `CGGlyph` class.NSLayoutManager.methods."CGGlyphAtIndex:isValidIndex:".skipped = true class.NSLayoutManager.methods."CGGlyphAtIndex:".skipped = true diff --git a/framework-crates/objc2-vision/Cargo.toml b/framework-crates/objc2-vision/Cargo.toml index 55384fa94..25c130e34 100644 --- a/framework-crates/objc2-vision/Cargo.toml +++ b/framework-crates/objc2-vision/Cargo.toml @@ -322,6 +322,7 @@ VNTrackingRequest = [ VNTypes = ["objc2-foundation/NSString"] VNUtils = ["objc2-core-foundation?/CFCGTypes"] VNVideoProcessor = [ + "objc2-core-foundation?/CFDate", "objc2-foundation/NSDictionary", "objc2-foundation/NSError", "objc2-foundation/NSObject", diff --git a/framework-crates/objc2-vision/translation-config.toml b/framework-crates/objc2-vision/translation-config.toml index 1a55260a4..b35ebc773 100644 --- a/framework-crates/objc2-vision/translation-config.toml +++ b/framework-crates/objc2-vision/translation-config.toml @@ -40,10 +40,6 @@ class.VNTargetedImageRequest.methods."initWithTargetedCMSampleBuffer:options:com class.VNVideoProcessor.methods."analyzeTimeRange:error:".skipped = true class.VNVideoProcessor.methods."analyzeWithTimeRange:error:".skipped = true -# Needs `CFTimeInterval` from CoreFoundation -class.VNVideoProcessorTimeIntervalCadence.methods."initWithTimeInterval:".skipped = true -class.VNVideoProcessorTimeIntervalCadence.methods.timeInterval.skipped = true - # Needs CoreVideo class.VNTargetedImageRequest.methods."initWithTargetedCVPixelBuffer:options:".skipped = true class.VNTargetedImageRequest.methods."initWithTargetedCVPixelBuffer:options:completionHandler:".skipped = true diff --git a/generated b/generated index f93c52800..28f85cd32 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit f93c528001a714a8e68a3be7712fda5a5b5c068b +Subproject commit 28f85cd32a3b761867768f311cb9dfd3db6764e2