From e71b8843e22837de2d45f285bef4fc9ea03a8a56 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 15 Dec 2024 23:14:16 +0100 Subject: [PATCH] Fix various definitions on 32-bit - AVAudioInteger - AVAudioUInteger - CFBundleRefNum Also avoid NSPoint/NSSize/NSRect being generated there. --- crates/header-translator/src/main.rs | 2 +- framework-crates/objc2-core-audio-types/src/lib.rs | 5 +++++ framework-crates/objc2-core-audio-types/src/session.rs | 9 +++++++++ .../objc2-core-audio-types/translation-config.toml | 4 ++++ framework-crates/objc2-core-foundation/src/bundle.rs | 7 +++++++ framework-crates/objc2-core-foundation/src/lib.rs | 4 ++++ .../objc2-core-foundation/translation-config.toml | 3 +++ .../objc2-foundation/translation-config.toml | 6 +++--- generated | 2 +- 9 files changed, 37 insertions(+), 5 deletions(-) create mode 100644 framework-crates/objc2-core-audio-types/src/session.rs create mode 100644 framework-crates/objc2-core-foundation/src/bundle.rs diff --git a/crates/header-translator/src/main.rs b/crates/header-translator/src/main.rs index bec78e7aa..c850a24f8 100644 --- a/crates/header-translator/src/main.rs +++ b/crates/header-translator/src/main.rs @@ -216,7 +216,7 @@ fn parse_framework( &[ "arm64-apple-macosx10.12.0", // "arm64-apple-macosx11.0.0", - // "i686-apple-macosx10.12.0", + // "i386-apple-macosx10.12.0", ] } else { &["arm64-apple-ios13.1.0-macabi"] diff --git a/framework-crates/objc2-core-audio-types/src/lib.rs b/framework-crates/objc2-core-audio-types/src/lib.rs index 472817681..33eeb3519 100644 --- a/framework-crates/objc2-core-audio-types/src/lib.rs +++ b/framework-crates/objc2-core-audio-types/src/lib.rs @@ -17,8 +17,13 @@ extern crate std; #[allow(clippy::eq_op)] mod generated; +#[cfg(feature = "AudioSessionTypes")] +mod session; + #[allow(unused_imports, unreachable_pub)] pub use self::generated::*; +#[cfg(feature = "AudioSessionTypes")] +pub use self::session::{AVAudioInteger, AVAudioUInteger}; // MacTypes.h #[allow(dead_code)] diff --git a/framework-crates/objc2-core-audio-types/src/session.rs b/framework-crates/objc2-core-audio-types/src/session.rs new file mode 100644 index 000000000..32b7072c1 --- /dev/null +++ b/framework-crates/objc2-core-audio-types/src/session.rs @@ -0,0 +1,9 @@ +// #if __LP64__ || NS_BUILD_32_LIKE_64 +// This is the same as NSInteger/NSUInteger, so let's use the same definition +// as those (namely isize/usize). + +/// [Apple's documentation](https://developer.apple.com/documentation/coreaudiotypes/avaudiointeger?language=objc) +pub type AVAudioInteger = isize; + +/// [Apple's documentation](https://developer.apple.com/documentation/coreaudiotypes/avaudiouinteger?language=objc) +pub type AVAudioUInteger = usize; diff --git a/framework-crates/objc2-core-audio-types/translation-config.toml b/framework-crates/objc2-core-audio-types/translation-config.toml index 8f8b2f0a6..dab655147 100644 --- a/framework-crates/objc2-core-audio-types/translation-config.toml +++ b/framework-crates/objc2-core-audio-types/translation-config.toml @@ -12,3 +12,7 @@ link = false # This framework only contains types # Requires a cast enum.anonymous.constants.AVAudioSessionErrorInsufficientPriority.skipped = true + +# Differs based on architecture +typedef.AVAudioInteger.skipped = true +typedef.AVAudioUInteger.skipped = true diff --git a/framework-crates/objc2-core-foundation/src/bundle.rs b/framework-crates/objc2-core-foundation/src/bundle.rs new file mode 100644 index 000000000..d8369e5ab --- /dev/null +++ b/framework-crates/objc2-core-foundation/src/bundle.rs @@ -0,0 +1,7 @@ +#[cfg(target_pointer_width = "64")] // #if TARGET_RT_64_BIT +type Inner = core::ffi::c_int; +#[cfg(not(target_pointer_width = "64"))] +type Inner = i16; // SInt16 + +/// [Apple's documentation](https://developer.apple.com/documentation/corefoundation/cfbundlerefnum?language=objc) +pub type CFBundleRefNum = Inner; diff --git a/framework-crates/objc2-core-foundation/src/lib.rs b/framework-crates/objc2-core-foundation/src/lib.rs index f9e457adc..381bbf738 100644 --- a/framework-crates/objc2-core-foundation/src/lib.rs +++ b/framework-crates/objc2-core-foundation/src/lib.rs @@ -15,10 +15,14 @@ extern crate alloc; #[cfg(feature = "std")] extern crate std; +#[cfg(feature = "CFBundle")] +mod bundle; mod generated; #[cfg(feature = "CFCGTypes")] mod geometry; +#[cfg(feature = "CFBundle")] +pub use self::bundle::CFBundleRefNum; #[allow(unused_imports, unreachable_pub)] pub use self::generated::*; #[cfg(feature = "CFCGTypes")] diff --git a/framework-crates/objc2-core-foundation/translation-config.toml b/framework-crates/objc2-core-foundation/translation-config.toml index 01171776c..a78e0a140 100644 --- a/framework-crates/objc2-core-foundation/translation-config.toml +++ b/framework-crates/objc2-core-foundation/translation-config.toml @@ -47,3 +47,6 @@ fn.CFAutorelease.skipped = true # Implementation details fn.__CFRangeMake.skipped = true fn.__CFStringMakeConstantString.skipped = true + +# Differs based on architecture +typedef.CFBundleRefNum.skipped = true diff --git a/framework-crates/objc2-foundation/translation-config.toml b/framework-crates/objc2-foundation/translation-config.toml index cb1f7fb8d..5dbc4908e 100644 --- a/framework-crates/objc2-foundation/translation-config.toml +++ b/framework-crates/objc2-foundation/translation-config.toml @@ -95,11 +95,11 @@ enum.NSComparisonResult.skipped = true # Different definitions on 32-bit typedef.NSPoint.skipped = true -struct.NSPoint.skipped = true +struct._NSPoint.skipped = true typedef.NSSize.skipped = true -struct.NSSize.skipped = true +struct._NSSize.skipped = true typedef.NSRect.skipped = true -struct.NSRect.skipped = true +struct._NSRect.skipped = true # References CGRectEdge enum.NSRectEdge.skipped = true diff --git a/generated b/generated index f52a897d9..6773cef35 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit f52a897d9b73a1bb6681998f838b1303788acf2e +Subproject commit 6773cef351f172a8812e869735534c68c3a0ac86