Skip to content

Commit d48dc10

Browse files
authored
Merge pull request #31 from madsmtm/gnustep-fixes
`GNUStep` encoding fixes
2 parents 9480a6f + 6a3a119 commit d48dc10

File tree

9 files changed

+24
-18
lines changed

9 files changed

+24
-18
lines changed

objc/src/message/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ macro_rules! objc_try {
2929

3030
mod verify;
3131

32-
#[cfg(any(target_os = "macos", target_os = "ios"))]
32+
#[cfg(target_vendor = "apple")]
3333
#[path = "apple/mod.rs"]
3434
mod platform;
35-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
35+
#[cfg(not(target_vendor = "apple"))]
3636
#[path = "gnustep.rs"]
3737
mod platform;
3838

objc/src/rc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ pub use self::strong::StrongPtr;
4747
pub use self::weak::WeakPtr;
4848

4949
// These tests use NSObject, which isn't present for GNUstep
50-
#[cfg(all(test, any(target_os = "macos", target_os = "ios")))]
50+
#[cfg(all(test, target_vendor = "apple"))]
5151
mod tests {
5252
use super::autoreleasepool;
5353
use super::StrongPtr;

objc/src/runtime.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ use crate::Encode;
1616
/// The Objective-C `BOOL` type.
1717
///
1818
/// To convert an Objective-C `BOOL` into a Rust [`bool`], compare it with [`NO`].
19-
#[cfg(not(target_arch = "aarch64"))]
19+
#[cfg(all(target_vendor = "apple", not(target_arch = "aarch64")))]
2020
pub type BOOL = ::std::os::raw::c_schar;
21+
#[cfg(all(not(target_vendor = "apple"), not(target_arch = "aarch64")))]
22+
pub type BOOL = u8;
23+
2124
/// The equivalent of true for Objective-C's [`BOOL`] type.
2225
#[cfg(not(target_arch = "aarch64"))]
2326
pub const YES: BOOL = 1;

objc/tests/use_macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg(any(target_os = "macos", target_os = "ios"))]
1+
#![cfg(target_vendor = "apple")]
22

33
use objc::runtime::Object;
44
use objc::{class, msg_send, sel};

objc_block/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,11 @@ struct ClassInternal {
7070
}
7171

7272
#[cfg_attr(
73-
any(target_os = "macos", target_os = "ios"),
73+
target_vendor = "apple",
7474
link(name = "System", kind = "dylib")
7575
)]
7676
#[cfg_attr(
77-
not(any(target_os = "macos", target_os = "ios")),
77+
not(target_vendor = "apple"),
7878
link(name = "BlocksRuntime", kind = "dylib")
7979
)]
8080
extern "C" {

objc_foundation/src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,25 @@ pub use self::object::{INSObject, NSObject};
2121
pub use self::string::{INSCopying, INSMutableCopying, INSString, NSString};
2222
pub use self::value::{INSValue, NSValue};
2323

24-
#[cfg(any(target_os = "macos", target_os = "ios"))]
24+
#[cfg(target_vendor = "apple")]
2525
#[link(name = "Foundation", kind = "framework")]
2626
extern "C" {}
2727

28-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
28+
#[cfg(not(target_vendor = "apple"))]
2929
use objc::runtime::Class;
3030

31-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
31+
#[cfg(not(target_vendor = "apple"))]
3232
#[link(name = "gnustep-base", kind = "dylib")]
3333
extern "C" {}
3434

3535
// Split up to illustrate that the linking doesn't have to be annotated on the
3636
// correct `extern` block.
37-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
37+
#[cfg(not(target_vendor = "apple"))]
3838
extern "C" {
3939
static _OBJC_CLASS_NSObject: Class;
4040
}
4141

42-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
42+
#[cfg(not(target_vendor = "apple"))]
4343
#[allow(dead_code)]
4444
unsafe fn get_class_to_force_linkage() -> &'static Class {
4545
&_OBJC_CLASS_NSObject

objc_foundation/src/string.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ pub trait INSMutableCopying: INSObject {
3131
}
3232
}
3333

34+
#[cfg(target_vendor = "apple")]
3435
const UTF8_ENCODING: usize = 4;
36+
#[cfg(not(target_vendor = "apple"))]
37+
const UTF8_ENCODING: i32 = 4;
3538

3639
pub trait INSString: INSObject {
3740
fn len(&self) -> usize {
@@ -85,7 +88,7 @@ impl fmt::Display for NSString {
8588
mod tests {
8689
use super::{INSCopying, INSString, NSString};
8790

88-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
91+
#[cfg(not(target_vendor = "apple"))]
8992
#[test]
9093
fn ensure_linkage() {
9194
unsafe { crate::get_class_to_force_linkage() };

objc_id/src/id.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ mod tests {
238238
use objc::runtime::Object;
239239
use objc::{class, msg_send};
240240

241-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
241+
#[cfg(not(target_vendor = "apple"))]
242242
#[test]
243243
fn ensure_linkage() {
244244
unsafe { crate::get_class_to_force_linkage() };

objc_id/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@ mod id;
4747

4848
// TODO: Remove the need for this hack
4949

50-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
50+
#[cfg(not(target_vendor = "apple"))]
5151
use objc::runtime::Class;
5252

53-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
53+
#[cfg(not(target_vendor = "apple"))]
5454
#[link(name = "gnustep-base", kind = "dylib")]
5555
extern "C" {}
5656

57-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
57+
#[cfg(not(target_vendor = "apple"))]
5858
extern "C" {
5959
static _OBJC_CLASS_NSObject: Class;
6060
}
6161

62-
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
62+
#[cfg(not(target_vendor = "apple"))]
6363
#[allow(dead_code)]
6464
unsafe fn get_class_to_force_linkage() -> &'static Class {
6565
&_OBJC_CLASS_NSObject

0 commit comments

Comments
 (0)