From 9a633db7e14849ba1158166b8c7cccfdfefe00d1 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Sun, 18 Jun 2023 18:58:49 +0300 Subject: [PATCH] Rename Class, Object and Protocol to AnyClass, AnyObject and AnyProtocol To match Swift's naming, and to be able to call the `ClassType` trait for just `Class` in the future --- crates/header-translator/src/rust_type.rs | 18 +- crates/header-translator/src/stmt.rs | 2 +- .../header-translator/translation-config.toml | 2 +- crates/icrate/examples/browser.rs | 6 +- crates/icrate/examples/delegate.rs | 6 +- crates/icrate/examples/nspasteboard.rs | 10 +- crates/icrate/src/AppKit/fixes/mod.rs | 2 +- .../Foundation/__macro_helpers/ns_string.rs | 10 +- .../icrate/src/Foundation/additions/array.rs | 2 +- .../Foundation/additions/attributed_string.rs | 2 +- .../icrate/src/Foundation/additions/bundle.rs | 2 +- .../src/Foundation/additions/dictionary.rs | 9 +- .../src/Foundation/additions/exception.rs | 4 +- .../icrate/src/Foundation/additions/iter.rs | 4 +- .../icrate/src/Foundation/additions/thread.rs | 7 +- .../icrate/src/Foundation/fixes/enumerator.rs | 2 +- .../icrate/src/Foundation/fixes/generics.rs | 20 +- crates/icrate/src/Metal/private.rs | 4 +- crates/icrate/src/common.rs | 8 +- crates/icrate/src/generated | 2 +- crates/icrate/tests/attributed_string.rs | 6 +- crates/icrate/tests/auto_traits.rs | 8 +- crates/icrate/tests/mutable_data.rs | 10 +- crates/objc-sys/src/types.rs | 2 +- crates/objc2/CHANGELOG.md | 7 + crates/objc2/benches/autorelease.rs | 48 ++--- crates/objc2/examples/class_with_lifetime.rs | 6 +- crates/objc2/examples/encode_nsstring.rs | 8 +- crates/objc2/examples/introspection.rs | 6 +- crates/objc2/src/__macro_helpers/cache.rs | 12 +- crates/objc2/src/__macro_helpers/mod.rs | 48 ++--- crates/objc2/src/class_type.rs | 12 +- crates/objc2/src/declare/ivar.rs | 34 ++-- crates/objc2/src/declare/mod.rs | 82 ++++---- crates/objc2/src/exception.rs | 22 +- crates/objc2/src/macros/__rewrite_self_arg.rs | 4 +- crates/objc2/src/macros/declare_class.rs | 6 +- crates/objc2/src/macros/extern_class.rs | 8 +- crates/objc2/src/macros/mod.rs | 68 +++---- crates/objc2/src/message/apple/mod.rs | 10 +- crates/objc2/src/message/gnustep.rs | 10 +- crates/objc2/src/message/mod.rs | 74 +++---- crates/objc2/src/protocol_type.rs | 8 +- crates/objc2/src/rc/autorelease.rs | 6 +- crates/objc2/src/rc/id.rs | 26 +-- crates/objc2/src/runtime/mod.rs | 188 ++++++++++-------- crates/objc2/src/runtime/nsobject.rs | 33 +-- crates/objc2/src/runtime/nsproxy.rs | 12 +- crates/objc2/src/runtime/protocol_object.rs | 15 +- crates/objc2/src/test_utils.rs | 68 +++---- crates/objc2/src/verify.rs | 6 +- crates/objc2/tests/no_prelude.rs | 8 +- crates/objc2/tests/track_caller.rs | 24 +-- crates/objc2/tests/use_macros.rs | 6 +- .../expected/apple-aarch64.s | 24 +-- .../expected/apple-armv7.s | 24 +-- .../expected/apple-armv7s.s | 24 +-- .../expected/apple-old-x86.s | 20 +- .../test_extern_protocol/expected/apple-x86.s | 20 +- .../expected/apple-x86_64.s | 20 +- .../crates/test_extern_protocol/lib.rs | 4 +- .../expected/apple-aarch64.s | 16 +- .../expected/apple-armv7.s | 16 +- .../expected/apple-armv7s.s | 16 +- .../test_msg_send_error/expected/apple-x86.s | 16 +- .../expected/apple-x86_64.s | 16 +- .../expected/gnustep-x86.s | 28 +-- .../expected/gnustep-x86_64.s | 28 +-- .../crates/test_msg_send_error/lib.rs | 16 +- .../crates/test_msg_send_id/lib.rs | 38 ++-- .../expected/apple-aarch64.s | 94 ++++----- .../expected/apple-armv7.s | 98 ++++----- .../expected/apple-armv7s.s | 98 ++++----- .../expected/apple-old-x86.s | 84 ++++---- .../expected/apple-x86.s | 84 ++++---- .../expected/apple-x86_64.s | 84 ++++---- .../crates/test_msg_send_static_sel/lib.rs | 8 +- .../crates/test_msg_send_zero_cost/lib.rs | 6 +- .../crates/test_out_parameters/lib.rs | 32 +-- .../crates/test_retain_autoreleased/lib.rs | 6 +- .../expected/apple-aarch64.s | 80 ++++---- .../test_static_class/expected/apple-armv7.s | 80 ++++---- .../test_static_class/expected/apple-armv7s.s | 80 ++++---- .../expected/apple-old-x86.s | 160 +++++++-------- .../test_static_class/expected/apple-x86.s | 64 +++--- .../test_static_class/expected/apple-x86_64.s | 64 +++--- .../crates/test_static_class/lib.rs | 12 +- crates/test-fuzz/fuzz_targets/class.rs | 4 +- crates/test-ui/ui/add_method_no_bool.rs | 6 +- crates/test-ui/ui/add_method_no_bool.stderr | 4 +- .../test-ui/ui/declare_add_bad_method.stderr | 80 ++++---- .../ui/declare_class_invalid_receiver.stderr | 108 +++++----- .../ui/declare_class_invalid_syntax.stderr | 4 +- crates/test-ui/ui/extern_class_root.rs | 10 +- .../ui/extern_class_subclass_object.rs | 4 +- .../ui/extern_class_subclass_object.stderr | 8 +- crates/test-ui/ui/fn_ptr_reference_method.rs | 10 +- .../test-ui/ui/fn_ptr_reference_method.stderr | 22 +- crates/test-ui/ui/fn_ptr_reference_method2.rs | 8 +- .../ui/fn_ptr_reference_method2.stderr | 24 +-- crates/test-ui/ui/invalid_msg_send.rs | 6 +- crates/test-ui/ui/invalid_msg_send.stderr | 4 +- crates/test-ui/ui/invalid_msg_send_super.rs | 6 +- .../ui/msg_send_id_alloc_init_different.rs | 4 +- .../msg_send_id_alloc_init_different.stderr | 8 +- .../test-ui/ui/msg_send_id_invalid_method.rs | 4 +- .../ui/msg_send_id_invalid_receiver.rs | 28 +-- .../ui/msg_send_id_invalid_receiver.stderr | 92 ++++----- .../test-ui/ui/msg_send_id_invalid_return.rs | 36 ++-- .../ui/msg_send_id_invalid_return.stderr | 116 +++++------ .../test-ui/ui/msg_send_id_underspecified.rs | 6 +- .../ui/msg_send_id_underspecified.stderr | 4 +- crates/test-ui/ui/msg_send_id_unwrap.rs | 4 +- crates/test-ui/ui/msg_send_id_unwrap.stderr | 4 +- .../test-ui/ui/msg_send_invalid_error.stderr | 2 +- crates/test-ui/ui/msg_send_mutable.rs | 4 +- crates/test-ui/ui/msg_send_mutable.stderr | 4 +- .../test-ui/ui/msg_send_only_message.stderr | 4 +- .../ui/msg_send_super_not_classtype.rs | 4 +- .../ui/msg_send_super_not_classtype.stderr | 8 +- crates/test-ui/ui/not_encode.stderr | 8 +- crates/test-ui/ui/not_writeback.stderr | 20 +- .../ui/nsarray_bound_not_send_sync.stderr | 56 +++--- crates/test-ui/ui/object_not_send_sync.rs | 8 +- crates/test-ui/ui/object_not_send_sync.stderr | 48 ++--- crates/tests/src/exception.rs | 8 +- crates/tests/src/test_encode_utils.rs | 6 +- crates/tests/src/test_object.rs | 28 +-- 128 files changed, 1660 insertions(+), 1635 deletions(-) diff --git a/crates/header-translator/src/rust_type.rs b/crates/header-translator/src/rust_type.rs index 692be0ac8..7e1858eaa 100644 --- a/crates/header-translator/src/rust_type.rs +++ b/crates/header-translator/src/rust_type.rs @@ -358,10 +358,10 @@ impl fmt::Display for IdType { Ok(()) } Self::AnyObject { protocols } => match &**protocols { - [] => write!(f, "Object"), + [] => write!(f, "AnyObject"), [id] if id.is_nsobject() => write!(f, "NSObject"), [id] if id.name == "NSCopying" || id.name == "NSMutableCopying" => { - write!(f, "Object") + write!(f, "AnyObject") } [id] => write!(f, "ProtocolObject", id.path()), // TODO: Handle this better @@ -369,7 +369,7 @@ impl fmt::Display for IdType { }, Self::TypeDef { id, .. } => write!(f, "{}", id.path()), Self::GenericParam { name } => write!(f, "{name}"), - Self::AnyProtocol => write!(f, "Protocol"), + Self::AnyProtocol => write!(f, "AnyProtocol"), // TODO: Handle this better Self::AnyClass { .. } => write!(f, "TodoClass"), Self::Self_ { .. } => write!(f, "Self"), @@ -1052,9 +1052,9 @@ impl fmt::Display for Inner { } Class { nullability } => { if *nullability == Nullability::NonNull { - write!(f, "NonNull") + write!(f, "NonNull") } else { - write!(f, "*const Class") + write!(f, "*const AnyClass") } } Sel { nullability } => { @@ -1546,9 +1546,9 @@ impl fmt::Display for Ty { } Inner::Class { nullability } => { if *nullability == Nullability::NonNull { - write!(f, "&'static Class") + write!(f, "&'static AnyClass") } else { - write!(f, "Option<&'static Class>") + write!(f, "Option<&'static AnyClass>") } } Inner::C99Bool => { @@ -1648,9 +1648,9 @@ impl fmt::Display for Ty { } Inner::Class { nullability } => { if *nullability == Nullability::NonNull { - write!(f, "&Class") + write!(f, "&AnyClass") } else { - write!(f, "Option<&Class>") + write!(f, "Option<&AnyClass>") } } Inner::C99Bool if self.kind == TyKind::MethodArgument => { diff --git a/crates/header-translator/src/stmt.rs b/crates/header-translator/src/stmt.rs index 7e086593e..4a7597123 100644 --- a/crates/header-translator/src/stmt.rs +++ b/crates/header-translator/src/stmt.rs @@ -1280,7 +1280,7 @@ impl fmt::Display for Stmt { if !generics.is_empty() { write!(f, "<")?; for generic in generics { - write!(f, "{generic}: Message = Object, ")?; + write!(f, "{generic}: Message = AnyObject, ")?; } write!(f, ">")?; }; diff --git a/crates/header-translator/translation-config.toml b/crates/header-translator/translation-config.toml index f79202ad0..bdbd087a6 100644 --- a/crates/header-translator/translation-config.toml +++ b/crates/header-translator/translation-config.toml @@ -1235,7 +1235,7 @@ skipped = true menuHasKeyEquivalent_forEvent_target_action = { skipped = true } # These subclass a generic struct, and hence the type parameter defaults to -# `Object`, which is not PartialEq, Eq nor Hash. +# `AnyObject`, which is not PartialEq, Eq nor Hash. [class.NSLayoutXAxisAnchor] derives = "Debug" [class.NSLayoutYAxisAnchor] diff --git a/crates/icrate/examples/browser.rs b/crates/icrate/examples/browser.rs index a088cf429..3d932f527 100644 --- a/crates/icrate/examples/browser.rs +++ b/crates/icrate/examples/browser.rs @@ -19,7 +19,7 @@ use objc2::{ declare_class, extern_methods, msg_send, mutability::InteriorMutable, rc::{Allocated, Id}, - runtime::{Object, ProtocolObject, Sel}, + runtime::{AnyObject, ProtocolObject, Sel}, sel, ClassType, }; @@ -169,7 +169,7 @@ fn main() { let back_button = { // configure the button to navigate the webview backward let title = ns_string!("back"); - let target = Some::<&Object>(&web_view); + let target = Some::<&AnyObject>(&web_view); let action = Some(sel!(goBack)); let this = unsafe { NSButton::buttonWithTitle_target_action(title, target, action) }; unsafe { this.setBezelStyle(NSBezelStyleShadowlessSquare) }; @@ -180,7 +180,7 @@ fn main() { let forward_button = { // configure the button to navigate the web view forward let title = ns_string!("forward"); - let target = Some::<&Object>(&web_view); + let target = Some::<&AnyObject>(&web_view); let action = Some(sel!(goForward)); let this = unsafe { NSButton::buttonWithTitle_target_action(title, target, action) }; unsafe { this.setBezelStyle(NSBezelStyleShadowlessSquare) }; diff --git a/crates/icrate/examples/delegate.rs b/crates/icrate/examples/delegate.rs index 37a35716b..2204ab74d 100644 --- a/crates/icrate/examples/delegate.rs +++ b/crates/icrate/examples/delegate.rs @@ -6,7 +6,7 @@ use icrate::ns_string; use icrate::Foundation::{NSCopying, NSObject, NSString}; use objc2::declare::{Ivar, IvarBool, IvarDrop, IvarEncode}; use objc2::rc::Id; -use objc2::runtime::Object; +use objc2::runtime::AnyObject; use objc2::{declare_class, msg_send, msg_send_id, mutability, ClassType}; #[cfg(target_os = "macos")] @@ -71,7 +71,7 @@ declare_class!( unsafe impl CustomAppDelegate { /// This is `unsafe` because it expects `sender` to be valid #[method(applicationDidFinishLaunching:)] - unsafe fn did_finish_launching(&self, sender: *mut Object) { + unsafe fn did_finish_launching(&self, sender: *mut AnyObject) { println!("Did finish launching!"); // Do something with `sender` dbg!(sender); @@ -80,7 +80,7 @@ declare_class!( /// Some comment before `sel`. #[method(applicationWillTerminate:)] /// Some comment after `sel`. - fn will_terminate(&self, _: *mut Object) { + fn will_terminate(&self, _: *mut AnyObject) { println!("Will terminate!"); } } diff --git a/crates/icrate/examples/nspasteboard.rs b/crates/icrate/examples/nspasteboard.rs index a68061935..849b33940 100644 --- a/crates/icrate/examples/nspasteboard.rs +++ b/crates/icrate/examples/nspasteboard.rs @@ -6,7 +6,7 @@ use icrate::AppKit::{NSPasteboard, NSPasteboardTypeString}; use icrate::Foundation::{NSArray, NSCopying, NSString}; use objc2::rc::Id; -use objc2::runtime::{Class, Object, ProtocolObject}; +use objc2::runtime::{AnyClass, AnyObject, ProtocolObject}; use objc2::ClassType; /// Simplest implementation @@ -20,18 +20,18 @@ pub fn get_text_1(pasteboard: &NSPasteboard) -> Option> { pub fn get_text_2(pasteboard: &NSPasteboard) -> Option> { // The NSPasteboard API is a bit weird, it requires you to pass classes as // objects, which `icrate::Foundation::NSArray` was not really made for - - // so we convert the class to an `Object` type instead. + // so we convert the class to an `AnyObject` type instead. // // TODO: Investigate and find a better way to express this in `objc2`. let string_class = { - let cls: *const Class = NSString::class(); - let cls = cls as *mut Object; + let cls: *const AnyClass = NSString::class(); + let cls = cls as *mut AnyObject; unsafe { Id::new(cls).unwrap() } }; let class_array = NSArray::from_vec(vec![string_class]); let objects = unsafe { pasteboard.readObjectsForClasses_options(&class_array, None) }; - let obj: *const Object = objects?.first()?; + let obj: *const AnyObject = objects?.first()?; // And this part is weird as well, since we now have to convert the object // into an NSString, which we know it to be since that's what we told // `readObjectsForClasses:options:`. diff --git a/crates/icrate/src/AppKit/fixes/mod.rs b/crates/icrate/src/AppKit/fixes/mod.rs index 96eb04b3f..a4c965482 100644 --- a/crates/icrate/src/AppKit/fixes/mod.rs +++ b/crates/icrate/src/AppKit/fixes/mod.rs @@ -43,7 +43,7 @@ extern_class!( __inner_extern_class!( #[cfg(feature = "AppKit_NSLayoutAnchor")] #[derive(Debug, PartialEq, Eq, Hash)] - pub struct NSLayoutAnchor { + pub struct NSLayoutAnchor { __superclass: NSObject, _inner0: PhantomData<*mut AnchorType>, notunwindsafe: PhantomData<&'static mut ()>, diff --git a/crates/icrate/src/Foundation/__macro_helpers/ns_string.rs b/crates/icrate/src/Foundation/__macro_helpers/ns_string.rs index 121ee3d74..7458fb238 100644 --- a/crates/icrate/src/Foundation/__macro_helpers/ns_string.rs +++ b/crates/icrate/src/Foundation/__macro_helpers/ns_string.rs @@ -16,7 +16,7 @@ use core::ffi::c_void; use crate::Foundation::NSString; -use objc2::runtime::Class; +use objc2::runtime::AnyClass; // This is defined in CoreFoundation, but we don't emit a link attribute // here because it is already linked via Foundation. @@ -24,7 +24,7 @@ use objc2::runtime::Class; // Although this is a "private" (underscored) symbol, it is directly // referenced in Objective-C binaries. So it's safe for us to reference. extern "C" { - pub static __CFConstantStringClassReference: Class; + pub static __CFConstantStringClassReference: AnyClass; } /// Structure used to describe a constant `CFString`. @@ -38,7 +38,7 @@ extern "C" { /// [`CF_CONST_STRING`]: #[repr(C)] pub struct CFConstString { - isa: &'static Class, + isa: &'static AnyClass, // Important that we don't use `usize` here, since that would be wrong on // big-endian systems! cfinfo: u32, @@ -66,7 +66,7 @@ impl CFConstString { const FLAGS_ASCII: u32 = 0x07_C8; const FLAGS_UTF16: u32 = 0x07_D0; - pub const unsafe fn new_ascii(isa: &'static Class, data: &'static [u8]) -> Self { + pub const unsafe fn new_ascii(isa: &'static AnyClass, data: &'static [u8]) -> Self { Self { isa, cfinfo: Self::FLAGS_ASCII, @@ -78,7 +78,7 @@ impl CFConstString { } } - pub const unsafe fn new_utf16(isa: &'static Class, data: &'static [u16]) -> Self { + pub const unsafe fn new_utf16(isa: &'static AnyClass, data: &'static [u16]) -> Self { Self { isa, cfinfo: Self::FLAGS_UTF16, diff --git a/crates/icrate/src/Foundation/additions/array.rs b/crates/icrate/src/Foundation/additions/array.rs index 4e3a89c9a..6866222a6 100644 --- a/crates/icrate/src/Foundation/additions/array.rs +++ b/crates/icrate/src/Foundation/additions/array.rs @@ -26,7 +26,7 @@ impl NSArray { // now safely take ownership (even if `T` is mutable). unsafe { Self::initWithObjects_count(Self::alloc(), ptr, len) } // The drop of `Vec` here would invalidate our mutable pointer, - // except for the fact that we're using `UnsafeCell` in `Object`. + // except for the fact that we're using `UnsafeCell` in `AnyObject`. } pub fn from_id_slice(slice: &[Id]) -> Id diff --git a/crates/icrate/src/Foundation/additions/attributed_string.rs b/crates/icrate/src/Foundation/additions/attributed_string.rs index 100bcc787..3e97e7d18 100644 --- a/crates/icrate/src/Foundation/additions/attributed_string.rs +++ b/crates/icrate/src/Foundation/additions/attributed_string.rs @@ -29,7 +29,7 @@ impl NSAttributedString { #[cfg(feature = "Foundation_NSString")] pub unsafe fn new_with_attributes( string: &Foundation::NSString, - attributes: &Foundation::NSDictionary, + attributes: &Foundation::NSDictionary, ) -> Id { unsafe { Self::initWithString_attributes(Self::alloc(), string, Some(attributes)) } } diff --git a/crates/icrate/src/Foundation/additions/bundle.rs b/crates/icrate/src/Foundation/additions/bundle.rs index 4dd6bcc92..58d824cc1 100644 --- a/crates/icrate/src/Foundation/additions/bundle.rs +++ b/crates/icrate/src/Foundation/additions/bundle.rs @@ -20,7 +20,7 @@ impl NSBundle { let info = self.infoDictionary()?; // TODO: Use ns_string! let name = info.get(&NSString::from_str("CFBundleName"))?; - let ptr: *const Object = name; + let ptr: *const AnyObject = name; let ptr: *const NSString = ptr.cast(); // SAFETY: TODO let name = unsafe { ptr.as_ref().unwrap_unchecked() }; diff --git a/crates/icrate/src/Foundation/additions/dictionary.rs b/crates/icrate/src/Foundation/additions/dictionary.rs index 77764f696..2a6071679 100644 --- a/crates/icrate/src/Foundation/additions/dictionary.rs +++ b/crates/icrate/src/Foundation/additions/dictionary.rs @@ -9,7 +9,6 @@ use core::panic::{RefUnwindSafe, UnwindSafe}; use core::ptr::{self, NonNull}; use objc2::mutability::IsMutable; -use objc2::runtime::Object; use super::iter; use super::util; @@ -27,7 +26,7 @@ impl NSDictionary { let count = min(keys.len(), vals.len()); let keys: *mut NonNull = util::ref_ptr_cast_const(keys.as_ptr()); - let keys: *mut NonNull = keys.cast(); + let keys: *mut NonNull = keys.cast(); let vals = util::id_ptr_cast(vals.as_mut_ptr()); unsafe { Self::initWithObjects_forKeys_count(Self::alloc(), vals, keys, count) } @@ -44,7 +43,7 @@ impl NSMutableDictionary { let count = min(keys.len(), vals.len()); let keys: *mut NonNull = util::ref_ptr_cast_const(keys.as_ptr()); - let keys: *mut NonNull = keys.cast(); + let keys: *mut NonNull = keys.cast(); let vals = util::id_ptr_cast(vals.as_mut_ptr()); unsafe { Self::initWithObjects_forKeys_count(Self::alloc(), vals, keys, count) } @@ -215,8 +214,8 @@ impl NSMutableDictionary { .get(&key) .map(|old_obj| unsafe { util::mutable_collection_retain_removed_id(old_obj) }); - // SAFETY: It is always safe to transmute an `Id` to `Object`. - let key: Id = unsafe { Id::cast(key) }; + // SAFETY: It is always safe to transmute an `Id` to `AnyObject`. + let key: Id = unsafe { Id::cast(key) }; // SAFETY: We have ownership over both the key and the value. unsafe { self.setObject_forKey(&value, &key) }; old_obj diff --git a/crates/icrate/src/Foundation/additions/exception.rs b/crates/icrate/src/Foundation/additions/exception.rs index 1f3d3f7ed..3176c3ce6 100644 --- a/crates/icrate/src/Foundation/additions/exception.rs +++ b/crates/icrate/src/Foundation/additions/exception.rs @@ -27,7 +27,7 @@ impl NSException { pub fn new( name: &NSExceptionName, reason: Option<&Foundation::NSString>, - user_info: Option<&Foundation::NSDictionary>, + user_info: Option<&Foundation::NSDictionary>, ) -> Option> { unsafe { msg_send_id![ @@ -91,7 +91,7 @@ impl NSException { #[cfg(feature = "Foundation_NSString")] impl fmt::Debug for NSException { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - let obj: &Object = self.as_ref(); + let obj: &AnyObject = self.as_ref(); write!(f, "{obj:?} '{}'", self.name())?; if let Some(reason) = self.reason() { write!(f, " reason:{reason}")?; diff --git a/crates/icrate/src/Foundation/additions/iter.rs b/crates/icrate/src/Foundation/additions/iter.rs index 7d59a91b4..51fa429e1 100644 --- a/crates/icrate/src/Foundation/additions/iter.rs +++ b/crates/icrate/src/Foundation/additions/iter.rs @@ -23,7 +23,7 @@ const BUF_SIZE: usize = 16; #[derive(Debug, PartialEq)] struct FastEnumeratorHelper { state: NSFastEnumerationState, - buf: [*mut Object; BUF_SIZE], + buf: [*mut AnyObject; BUF_SIZE], // TODO: We could possibly optimize things a bit by doing // `itemsPtr.add(1); items_count -= 1;` on every loop, instead of storing // `current_item` - but it's not really defined whether we're allowed to @@ -136,7 +136,7 @@ impl FastEnumeratorHelper { unsafe fn next_from( &mut self, collection: &ProtocolObject, - ) -> Option> { + ) -> Option> { // If we've exhausted the current array of items. if self.current_item >= self.items_count { // Get the next array of items. diff --git a/crates/icrate/src/Foundation/additions/thread.rs b/crates/icrate/src/Foundation/additions/thread.rs index 68a3c62ab..317f397c5 100644 --- a/crates/icrate/src/Foundation/additions/thread.rs +++ b/crates/icrate/src/Foundation/additions/thread.rs @@ -56,14 +56,13 @@ fn make_multithreaded() { /// Use when designing APIs that are only safe to use on the main thread: /// /// ```no_run -/// use icrate::Foundation::MainThreadMarker; -/// use icrate::objc2::runtime::Object; +/// use icrate::Foundation::{MainThreadMarker, NSObject}; /// use icrate::objc2::msg_send; -/// # let obj = 0 as *const Object; +/// # let obj = 0 as *const NSObject; /// /// // This action requires the main thread, so we take a marker as parameter. /// // It signals clearly to users "this requires the main thread". -/// unsafe fn do_thing(obj: *const Object, _mtm: MainThreadMarker) { +/// unsafe fn do_thing(obj: *const NSObject, _mtm: MainThreadMarker) { /// msg_send![obj, someActionThatRequiresTheMainThread] /// } /// diff --git a/crates/icrate/src/Foundation/fixes/enumerator.rs b/crates/icrate/src/Foundation/fixes/enumerator.rs index b952f50ec..e337fbebe 100644 --- a/crates/icrate/src/Foundation/fixes/enumerator.rs +++ b/crates/icrate/src/Foundation/fixes/enumerator.rs @@ -6,7 +6,7 @@ use crate::common::*; #[derive(Clone, Copy, Debug, PartialEq)] pub struct NSFastEnumerationState { pub state: c_ulong, - pub itemsPtr: *mut *mut Object, + pub itemsPtr: *mut *mut AnyObject, pub mutationsPtr: *mut c_ulong, pub extra: [c_ulong; 5], } diff --git a/crates/icrate/src/Foundation/fixes/generics.rs b/crates/icrate/src/Foundation/fixes/generics.rs index 458c27300..725d7ad51 100644 --- a/crates/icrate/src/Foundation/fixes/generics.rs +++ b/crates/icrate/src/Foundation/fixes/generics.rs @@ -18,7 +18,7 @@ impl UnwindSafe for UnsafeIgnoreAutoTraits {} __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSArray")] - pub struct NSArray { + pub struct NSArray { // SAFETY: Auto traits specified below. __superclass: UnsafeIgnoreAutoTraits, /// `NSArray` and `NSMutableArray` have `Id`-like storage. @@ -101,7 +101,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSArray")] - pub struct NSMutableArray { + pub struct NSMutableArray { // Inherit auto traits from superclass. __superclass: NSArray, } @@ -125,7 +125,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSDictionary")] - pub struct NSDictionary { + pub struct NSDictionary { // SAFETY: Auto traits specified below. __superclass: UnsafeIgnoreAutoTraits, // Same as if the dictionary was implemented with: @@ -151,7 +151,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSDictionary")] - pub struct NSMutableDictionary { + pub struct NSMutableDictionary { // Inherit auto traits from superclass. __superclass: NSDictionary, } @@ -177,7 +177,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSSet")] - pub struct NSSet { + pub struct NSSet { // SAFETY: Auto traits specified below. __superclass: UnsafeIgnoreAutoTraits, // Same as if the set was implemented as `NSArray`. @@ -202,7 +202,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSSet")] - pub struct NSMutableSet { + pub struct NSMutableSet { // Inherit auto traits from superclass. __superclass: NSSet, } @@ -226,7 +226,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(Debug, PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSCountedSet")] - pub struct NSCountedSet { + pub struct NSCountedSet { // Inherit auto traits from superclass. __superclass: NSMutableSet, } @@ -250,7 +250,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSOrderedSet")] - pub struct NSOrderedSet { + pub struct NSOrderedSet { // SAFETY: Auto traits specified below. __superclass: UnsafeIgnoreAutoTraits, // Same as if the set was implemented with `NSArray`. @@ -275,7 +275,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSOrderedSet")] - pub struct NSMutableOrderedSet { + pub struct NSMutableOrderedSet { // Inherit auto traits from superclass. __superclass: NSOrderedSet, } @@ -299,7 +299,7 @@ __inner_extern_class!( __inner_extern_class!( #[derive(Debug, PartialEq, Eq, Hash)] #[cfg(feature = "Foundation_NSEnumerator")] - pub struct NSEnumerator { + pub struct NSEnumerator { // SAFETY: Auto traits specified below. __superclass: UnsafeIgnoreAutoTraits, // Enumerators are basically the same as if we were storing diff --git a/crates/icrate/src/Metal/private.rs b/crates/icrate/src/Metal/private.rs index a27590843..fed5db715 100644 --- a/crates/icrate/src/Metal/private.rs +++ b/crates/icrate/src/Metal/private.rs @@ -41,7 +41,7 @@ extern_methods!( pub unsafe fn newSerializedVertexDataWithFlags_error( &self, flags: u64, - ) -> Result, Id>; + ) -> Result, Id>; #[method(serializeFragmentData)] pub unsafe fn serializeFragmentData(&self) -> *mut c_void; @@ -60,6 +60,6 @@ extern_methods!( #[cfg(feature = "Metal_MTLVertexDescriptor")] unsafe impl Metal::MTLVertexDescriptor { #[method_id(newSerializedDescriptor)] - pub unsafe fn newSerializedDescriptor(&self) -> Option>; + pub unsafe fn newSerializedDescriptor(&self) -> Option>; } ); diff --git a/crates/icrate/src/common.rs b/crates/icrate/src/common.rs index fd81e1f99..fdc9fdaae 100644 --- a/crates/icrate/src/common.rs +++ b/crates/icrate/src/common.rs @@ -20,7 +20,7 @@ pub(crate) use objc2::mutability::{ #[cfg(feature = "objective-c")] pub(crate) use objc2::rc::{Allocated, DefaultId, Id}; #[cfg(feature = "objective-c")] -pub(crate) use objc2::runtime::{Bool, Class, Object, Sel}; +pub(crate) use objc2::runtime::{AnyClass, AnyObject, Bool, Sel}; #[cfg(feature = "objective-c")] pub(crate) use objc2::runtime::{NSObject, NSObjectProtocol, ProtocolObject}; #[cfg(feature = "objective-c")] @@ -34,12 +34,12 @@ pub(crate) use block2::Block; // TODO #[cfg(feature = "objective-c")] -pub(crate) type Protocol = Object; +pub(crate) type AnyProtocol = AnyObject; pub(crate) type TodoFunction = *const c_void; #[cfg(feature = "objective-c")] -pub(crate) type TodoClass = Object; +pub(crate) type TodoClass = AnyObject; #[cfg(feature = "objective-c")] -pub(crate) type TodoProtocols = Object; +pub(crate) type TodoProtocols = AnyObject; // MacTypes.h pub(crate) type Boolean = u8; // unsigned char diff --git a/crates/icrate/src/generated b/crates/icrate/src/generated index bc00d3906..89fcde3b8 160000 --- a/crates/icrate/src/generated +++ b/crates/icrate/src/generated @@ -1 +1 @@ -Subproject commit bc00d39068aa4089564979de43317703a406a603 +Subproject commit 89fcde3b8fef0f79b0370ac2a4b28340e89ef958 diff --git a/crates/icrate/tests/attributed_string.rs b/crates/icrate/tests/attributed_string.rs index 703068d3b..6cc0acb13 100644 --- a/crates/icrate/tests/attributed_string.rs +++ b/crates/icrate/tests/attributed_string.rs @@ -1,7 +1,7 @@ #![cfg(feature = "Foundation_NSAttributedString")] #![cfg(feature = "Foundation_NSString")] use objc2::rc::{autoreleasepool, Id}; -use objc2::runtime::Object; +use objc2::runtime::AnyObject; use icrate::Foundation::{self, NSAttributedString, NSObject, NSString}; @@ -55,8 +55,8 @@ fn test_debug() { }; assert_eq!(format!("{s:?}"), expected); - let obj: Id = unsafe { Id::cast(NSObject::new()) }; - let ptr: *const Object = &*obj; + let obj = Id::into_super(NSObject::new()); + let ptr: *const AnyObject = &*obj; let s = unsafe { NSAttributedString::new_with_attributes( &NSString::from_str("abc"), diff --git a/crates/icrate/tests/auto_traits.rs b/crates/icrate/tests/auto_traits.rs index 132539402..262c58aa6 100644 --- a/crates/icrate/tests/auto_traits.rs +++ b/crates/icrate/tests/auto_traits.rs @@ -6,7 +6,7 @@ use static_assertions::{assert_impl_all, assert_not_impl_any}; use icrate::Foundation::*; use objc2::mutability::{Immutable, Mutable}; use objc2::rc::Id; -use objc2::runtime::Object; +use objc2::runtime::AnyObject; use objc2::{declare_class, ClassType}; // We expect most Foundation types to be UnwindSafe and RefUnwindSafe, @@ -102,9 +102,9 @@ fn test_generic_auto_traits() { } // TODO - assert_not_impl_any!(NSArray: Unpin); - assert_not_impl_any!(NSMutableArray: Unpin); - assert_not_impl_any!(NSDictionary: Unpin); + assert_not_impl_any!(NSArray: Unpin); + assert_not_impl_any!(NSMutableArray: Unpin); + assert_not_impl_any!(NSDictionary: Unpin); assert_id_like!(NSArray); #[allow(dead_code)] diff --git a/crates/icrate/tests/mutable_data.rs b/crates/icrate/tests/mutable_data.rs index d4415ad5b..3c307df4d 100644 --- a/crates/icrate/tests/mutable_data.rs +++ b/crates/icrate/tests/mutable_data.rs @@ -1,7 +1,7 @@ #![cfg(feature = "Foundation_NSMutableData")] use objc2::rc::Id; -use objc2::runtime::Object; +use objc2::runtime::AnyObject; use icrate::Foundation::{NSData, NSMutableData, NSObject}; @@ -91,15 +91,15 @@ fn test_as_ref_borrow() { impls_borrow_mut::(&mut obj); impls_borrow::(&obj); impls_borrow_mut::(&mut obj); - impls_borrow::(&obj); - impls_borrow_mut::(&mut obj); + impls_borrow::(&obj); + impls_borrow_mut::(&mut obj); impls_borrow::(&obj); impls_borrow_mut::(&mut obj); impls_borrow::(&obj); impls_borrow_mut::(&mut obj); - impls_borrow::(&obj); - impls_borrow_mut::(&mut obj); + impls_borrow::(&obj); + impls_borrow_mut::(&mut obj); fn impls_as_ref + ?Sized, U: ?Sized>(_: &T) {} fn impls_as_mut + ?Sized, U: ?Sized>(_: &mut T) {} diff --git a/crates/objc-sys/src/types.rs b/crates/objc-sys/src/types.rs index b4206bc74..82a7ce164 100644 --- a/crates/objc-sys/src/types.rs +++ b/crates/objc-sys/src/types.rs @@ -210,5 +210,5 @@ pub type SEL = *const objc_selector; /// - `icrate::Foundation::NS[...]` for when you know the class of the object /// you're dealing with. /// - `objc2::rc::Id` for a proper way of doing memory management. -/// - `objc2::runtime::Object` for a bit safer representation of this. +/// - `objc2::runtime::AnyObject` for a bit safer representation of this. pub type id = *mut objc_object; diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index 0a59d5e72..9b4af615c 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -77,6 +77,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Relaxed a `fmt::Debug` bound on `WeakId`'s own `fmt::Debug` impl. * Changed `Debug` impl for `runtime::Class`, `runtime::Sel` and `runtime::Protocol` to give more information. +* Renamed: + - `Object` to `AnyObject`. + - `Class` to `AnyClass`. + - `Protocol` to `AnyProtocol`. + + To better fit with Swift's naming scheme. The types are still available + under the old names as deprecated aliases. ### Fixed * Fixed using autorelease pools on 32bit macOS and older macOS versions. diff --git a/crates/objc2/benches/autorelease.rs b/crates/objc2/benches/autorelease.rs index 8050be5b8..51d3adc88 100644 --- a/crates/objc2/benches/autorelease.rs +++ b/crates/objc2/benches/autorelease.rs @@ -2,7 +2,7 @@ use core::ffi::c_void; use std::mem::ManuallyDrop; use objc2::rc::{autoreleasepool, Id}; -use objc2::runtime::{Class, Object, Sel}; +use objc2::runtime::{AnyClass, NSObject, Sel}; use objc2::{class, msg_send, sel}; const BYTES: &[u8] = &[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; @@ -13,7 +13,7 @@ fn pool_cleanup() { autoreleasepool(|_| {}) } -fn class() -> &'static Class { +fn class() -> &'static AnyClass { class!(NSObject) } @@ -21,24 +21,24 @@ fn sel() -> Sel { sel!(alloc) } -fn send_message() -> &'static Class { +fn send_message() -> &'static AnyClass { unsafe { msg_send![class!(NSObject), class] } } -fn alloc_nsobject() -> *mut Object { +fn alloc_nsobject() -> *mut NSObject { unsafe { msg_send![class!(NSObject), alloc] } } -fn new_nsobject() -> Id { +fn new_nsobject() -> Id { let obj = alloc_nsobject(); - let obj: *mut Object = unsafe { msg_send![obj, init] }; + let obj: *mut NSObject = unsafe { msg_send![obj, init] }; unsafe { Id::new(obj).unwrap_unchecked() } } -fn new_nsdata() -> Id { +fn new_nsdata() -> Id { let bytes_ptr = BYTES.as_ptr() as *const c_void; - let obj: *mut Object = unsafe { msg_send![class!(NSData), alloc] }; - let obj: *mut Object = unsafe { + let obj: *mut NSObject = unsafe { msg_send![class!(NSData), alloc] }; + let obj: *mut NSObject = unsafe { msg_send![ obj, initWithBytes: bytes_ptr, @@ -48,11 +48,11 @@ fn new_nsdata() -> Id { unsafe { Id::new(obj).unwrap_unchecked() } } -fn new_leaked_nsdata() -> *const Object { +fn new_leaked_nsdata() -> *const NSObject { Id::as_ptr(&*ManuallyDrop::new(new_nsdata())) } -fn autoreleased_nsdata() -> *const Object { +fn autoreleased_nsdata() -> *const NSObject { // let bytes_ptr = BYTES.as_ptr() as *const c_void; // unsafe { // msg_send![ @@ -64,46 +64,46 @@ fn autoreleased_nsdata() -> *const Object { unsafe { msg_send![new_leaked_nsdata(), autorelease] } } -fn new_nsstring() -> Id { - let obj: *mut Object = unsafe { msg_send![class!(NSString), alloc] }; - let obj: *mut Object = unsafe { msg_send![obj, init] }; +fn new_nsstring() -> Id { + let obj: *mut NSObject = unsafe { msg_send![class!(NSString), alloc] }; + let obj: *mut NSObject = unsafe { msg_send![obj, init] }; unsafe { Id::new(obj).unwrap_unchecked() } } -fn new_leaked_nsstring() -> *const Object { +fn new_leaked_nsstring() -> *const NSObject { Id::as_ptr(&*ManuallyDrop::new(new_nsstring())) } -fn autoreleased_nsstring() -> *const Object { +fn autoreleased_nsstring() -> *const NSObject { // unsafe { msg_send![class!(NSString), string] } unsafe { msg_send![new_leaked_nsstring(), autorelease] } } -fn retain_autoreleased(obj: *const Object) -> Id { - unsafe { Id::retain_autoreleased((obj as *mut Object).cast()).unwrap_unchecked() } +fn retain_autoreleased(obj: *const NSObject) -> Id { + unsafe { Id::retain_autoreleased((obj as *mut NSObject).cast()).unwrap_unchecked() } } -fn autoreleased_nsdata_pool_cleanup() -> *const Object { +fn autoreleased_nsdata_pool_cleanup() -> *const NSObject { autoreleasepool(|_| autoreleased_nsdata()) } -fn autoreleased_nsdata_fast_caller_cleanup() -> Id { +fn autoreleased_nsdata_fast_caller_cleanup() -> Id { retain_autoreleased(autoreleased_nsdata()) } -fn autoreleased_nsdata_fast_caller_cleanup_pool_cleanup() -> Id { +fn autoreleased_nsdata_fast_caller_cleanup_pool_cleanup() -> Id { autoreleasepool(|_| retain_autoreleased(autoreleased_nsdata())) } -fn autoreleased_nsstring_pool_cleanup() -> *const Object { +fn autoreleased_nsstring_pool_cleanup() -> *const NSObject { autoreleasepool(|_| autoreleased_nsstring()) } -fn autoreleased_nsstring_fast_caller_cleanup() -> Id { +fn autoreleased_nsstring_fast_caller_cleanup() -> Id { retain_autoreleased(autoreleased_nsstring()) } -fn autoreleased_nsstring_fast_caller_cleanup_pool_cleanup() -> Id { +fn autoreleased_nsstring_fast_caller_cleanup_pool_cleanup() -> Id { autoreleasepool(|_| retain_autoreleased(autoreleased_nsstring())) } diff --git a/crates/objc2/examples/class_with_lifetime.rs b/crates/objc2/examples/class_with_lifetime.rs index bced9ea23..54410530d 100644 --- a/crates/objc2/examples/class_with_lifetime.rs +++ b/crates/objc2/examples/class_with_lifetime.rs @@ -7,7 +7,7 @@ use std::sync::Once; use objc2::declare::{ClassBuilder, Ivar, IvarEncode, IvarType}; use objc2::mutability::Mutable; use objc2::rc::Id; -use objc2::runtime::{Class, NSObject, Sel}; +use objc2::runtime::{AnyClass, NSObject, Sel}; use objc2::{msg_send, msg_send_id, sel}; use objc2::{ClassType, Encoding, Message, RefEncode}; @@ -76,7 +76,7 @@ unsafe impl<'a> ClassType for MyObject<'a> { type Mutability = Mutable; const NAME: &'static str = "MyObject"; - fn class() -> &'static Class { + fn class() -> &'static AnyClass { // TODO: Use std::lazy::LazyCell static REGISTER_CLASS: Once = Once::new(); @@ -96,7 +96,7 @@ unsafe impl<'a> ClassType for MyObject<'a> { let _cls = builder.register(); }); - Class::get("MyObject").unwrap() + AnyClass::get("MyObject").unwrap() } fn as_super(&self) -> &Self::Super { diff --git a/crates/objc2/examples/encode_nsstring.rs b/crates/objc2/examples/encode_nsstring.rs index 9f64e5d77..7b48cc757 100644 --- a/crates/objc2/examples/encode_nsstring.rs +++ b/crates/objc2/examples/encode_nsstring.rs @@ -1,15 +1,15 @@ use objc2::encode::{Encode, Encoding, RefEncode}; -use objc2::runtime::Object; +use objc2::runtime::AnyObject; #[repr(transparent)] struct NSString { - // `NSString` has the same layout / works the same as `Object`. - _priv: Object, + // `NSString` has the same layout / works the same as `AnyObject`. + _priv: AnyObject, } // We don't know the size of NSString, so we can only hold pointers to it. // -// SAFETY: The string is `repr(transparent)` over `Object`. +// SAFETY: The string is `repr(transparent)` over `AnyObject`. unsafe impl RefEncode for NSString { const ENCODING_REF: Encoding = Encoding::Object; } diff --git a/crates/objc2/examples/introspection.rs b/crates/objc2/examples/introspection.rs index 2b8059ffc..66f62c3f9 100644 --- a/crates/objc2/examples/introspection.rs +++ b/crates/objc2/examples/introspection.rs @@ -1,4 +1,4 @@ -use objc2::runtime::{Class, NSObject}; +use objc2::runtime::{AnyClass, NSObject}; use objc2::{sel, ClassType, Encode}; fn main() { @@ -29,7 +29,7 @@ fn main() { ivar.name(), ivar.type_encoding() ); - assert!(<*const Class>::ENCODING.equivalent_to_str(ivar.type_encoding())); + assert!(<*const AnyClass>::ENCODING.equivalent_to_str(ivar.type_encoding())); // Inspect a method of the class let method = cls.instance_method(sel!(hash)).unwrap(); @@ -52,6 +52,6 @@ fn main() { // Access an ivar of the object // // As before, you should not rely on the `isa` ivar being available! - let isa = unsafe { *obj.ivar::<*const Class>("isa") }; + let isa = unsafe { *obj.ivar::<*const AnyClass>("isa") }; println!("NSObject isa: {isa:?}"); } diff --git a/crates/objc2/src/__macro_helpers/cache.rs b/crates/objc2/src/__macro_helpers/cache.rs index 28b32c0b2..3b3c81d17 100644 --- a/crates/objc2/src/__macro_helpers/cache.rs +++ b/crates/objc2/src/__macro_helpers/cache.rs @@ -2,7 +2,7 @@ use core::ptr; use core::sync::atomic::{AtomicPtr, Ordering}; use crate::ffi; -use crate::runtime::{Class, Sel}; +use crate::runtime::{AnyClass, Sel}; /// Allows storing a [`Sel`] in a static and lazily loading it. #[doc(hidden)] @@ -40,10 +40,10 @@ impl CachedSel { } } -/// Allows storing a [`Class`] reference in a static and lazily loading it. +/// Allows storing a [`AnyClass`] reference in a static and lazily loading it. #[doc(hidden)] pub struct CachedClass { - ptr: AtomicPtr, + ptr: AtomicPtr, } impl CachedClass { @@ -58,14 +58,14 @@ impl CachedClass { /// the given name and stores it. #[inline] #[doc(hidden)] - pub unsafe fn get(&self, name: &str) -> Option<&'static Class> { + pub unsafe fn get(&self, name: &str) -> Option<&'static AnyClass> { // `Relaxed` should be fine since `objc_getClass` is thread-safe. let ptr = self.ptr.load(Ordering::Relaxed); if let Some(cls) = unsafe { ptr.as_ref() } { Some(cls) } else { - let ptr: *const Class = unsafe { ffi::objc_getClass(name.as_ptr().cast()) }.cast(); - self.ptr.store(ptr as *mut Class, Ordering::Relaxed); + let ptr: *const AnyClass = unsafe { ffi::objc_getClass(name.as_ptr().cast()) }.cast(); + self.ptr.store(ptr as *mut AnyClass, Ordering::Relaxed); unsafe { ptr.as_ref() } } } diff --git a/crates/objc2/src/__macro_helpers/mod.rs b/crates/objc2/src/__macro_helpers/mod.rs index 6ad4d7fff..48839f679 100644 --- a/crates/objc2/src/__macro_helpers/mod.rs +++ b/crates/objc2/src/__macro_helpers/mod.rs @@ -11,7 +11,7 @@ use crate::message::__TupleExtender; use crate::rc::{Allocated, Id}; #[cfg(all(debug_assertions, feature = "verify"))] use crate::runtime::MethodDescription; -use crate::runtime::{Class, Object, Protocol, Sel}; +use crate::runtime::{AnyClass, AnyObject, AnyProtocol, Sel}; use crate::{Message, MessageArguments, MessageReceiver}; use crate::{__sel_data, __sel_inner}; @@ -184,10 +184,10 @@ impl MsgSendId> for New { } } -impl MsgSendId<&'_ Class, Allocated> for Alloc { +impl MsgSendId<&'_ AnyClass, Allocated> for Alloc { #[inline] unsafe fn send_message_id>>( - cls: &Class, + cls: &AnyClass, sel: Sel, args: A, ) -> R { @@ -321,7 +321,7 @@ pub trait MsgSendIdFailed<'a> { } impl<'a> MsgSendIdFailed<'a> for New { - type Args = (Option<&'a Object>, Sel); + type Args = (Option<&'a AnyObject>, Sel); #[cold] fn failed((obj, sel): Self::Args) -> ! { @@ -343,7 +343,7 @@ impl<'a> MsgSendIdFailed<'a> for New { } impl<'a> MsgSendIdFailed<'a> for Alloc { - type Args = (&'a Class, Sel); + type Args = (&'a AnyClass, Sel); #[cold] fn failed((cls, sel): Self::Args) -> ! { @@ -356,7 +356,7 @@ impl<'a> MsgSendIdFailed<'a> for Alloc { } impl MsgSendIdFailed<'_> for Init { - type Args = (*const Object, Sel); + type Args = (*const AnyObject, Sel); #[cold] fn failed((ptr, sel): Self::Args) -> ! { @@ -384,7 +384,7 @@ impl MsgSendIdFailed<'_> for CopyOrMutCopy { } impl<'a> MsgSendIdFailed<'a> for Other { - type Args = (Option<&'a Object>, Sel); + type Args = (Option<&'a AnyObject>, Sel); #[cold] fn failed((obj, sel): Self::Args) -> ! { @@ -475,7 +475,7 @@ impl ClassBuilder { #[doc(hidden)] pub fn __add_protocol_methods<'a, 'b>( &'a mut self, - protocol: Option<&'b Protocol>, + protocol: Option<&'b AnyProtocol>, ) -> ClassProtocolMethodsBuilder<'a, 'b> { if let Some(protocol) = protocol { self.add_protocol(protocol); @@ -520,7 +520,7 @@ impl ClassBuilder { pub struct ClassProtocolMethodsBuilder<'a, 'b> { builder: &'a mut ClassBuilder, #[allow(unused)] - protocol: Option<&'b Protocol>, + protocol: Option<&'b AnyProtocol>, #[cfg(all(debug_assertions, feature = "verify"))] required_instance_methods: Vec, #[cfg(all(debug_assertions, feature = "verify"))] @@ -569,7 +569,7 @@ impl ClassProtocolMethodsBuilder<'_, '_> { #[inline] pub unsafe fn add_class_method(&mut self, sel: Sel, func: F) where - F: MethodImplementation, + F: MethodImplementation, { #[cfg(all(debug_assertions, feature = "verify"))] if let Some(protocol) = self.protocol { @@ -632,13 +632,13 @@ mod tests { #[cfg(feature = "objc2-proc-macros")] use crate::__hash_idents; use crate::rc::{__RcTestObject, __ThreadTestData}; - use crate::runtime::{NSObject, NSZone, Object}; + use crate::runtime::{AnyObject, NSObject, NSZone}; use crate::{class, msg_send_id, ClassType}; #[test] fn test_new() { - let _obj: Id = unsafe { msg_send_id![NSObject::class(), new] }; - let _obj: Option> = unsafe { msg_send_id![NSObject::class(), new] }; + let _obj: Id = unsafe { msg_send_id![NSObject::class(), new] }; + let _obj: Option> = unsafe { msg_send_id![NSObject::class(), new] }; } #[test] @@ -646,8 +646,8 @@ mod tests { let mut expected = __ThreadTestData::current(); let obj = __RcTestObject::new(); - let _obj: Id = unsafe { msg_send_id![&obj, newMethodOnInstance] }; - let _obj: Option> = unsafe { msg_send_id![&obj, newMethodOnInstance] }; + let _obj: Id = unsafe { msg_send_id![&obj, newMethodOnInstance] }; + let _obj: Option> = unsafe { msg_send_id![&obj, newMethodOnInstance] }; expected.alloc += 3; expected.init += 3; expected.assert_current(); @@ -660,11 +660,11 @@ mod tests { let mut expected = __ThreadTestData::current(); let object_class = __RcTestObject::class(); - let key: Id = unsafe { msg_send_id![class!(NSString), new] }; - let contents_value: *const Object = ptr::null(); - let properties: Id = unsafe { msg_send_id![class!(NSDictionary), new] }; + let key: Id = unsafe { msg_send_id![class!(NSString), new] }; + let contents_value: *const AnyObject = ptr::null(); + let properties: Id = unsafe { msg_send_id![class!(NSDictionary), new] }; - let _obj: Option> = unsafe { + let _obj: Option> = unsafe { msg_send_id![ NSObject::class(), newScriptingObjectOfClass: object_class, @@ -772,7 +772,7 @@ mod tests { // GNUStep instead returns an invalid instance that panics on accesses #[cfg_attr(feature = "gnustep-1-7", ignore)] fn new_nsvalue_fails() { - let _val: Id = unsafe { msg_send_id![class!(NSValue), new] }; + let _val: Id = unsafe { msg_send_id![class!(NSValue), new] }; } #[test] @@ -786,7 +786,7 @@ mod tests { #[should_panic = "unexpected NULL returned from -[__RcTestObject newMethodOnInstanceNull]"] fn test_new_any_with_null() { let obj = __RcTestObject::new(); - let _obj: Id = unsafe { msg_send_id![&obj, newMethodOnInstanceNull] }; + let _obj: Id = unsafe { msg_send_id![&obj, newMethodOnInstanceNull] }; } #[test] @@ -794,7 +794,7 @@ mod tests { #[cfg(not(debug_assertions))] // Does NULL receiver checks fn test_new_any_with_null_receiver() { let obj: *const NSObject = ptr::null(); - let _obj: Id = unsafe { msg_send_id![obj, newMethodOnInstance] }; + let _obj: Id = unsafe { msg_send_id![obj, newMethodOnInstance] }; } #[test] @@ -846,7 +846,7 @@ mod tests { #[cfg(not(debug_assertions))] // Does NULL receiver checks fn test_normal_with_null_receiver() { let obj: *const NSObject = ptr::null(); - let _obj: Id = unsafe { msg_send_id![obj, description] }; + let _obj: Id = unsafe { msg_send_id![obj, description] }; } #[test] @@ -960,7 +960,7 @@ mod tests { #[test] fn test_macro_still_works() { let cls = class!(NSObject); - let _obj: Id = unsafe { msg_send_id![cls, new] }; + let _obj: Id = unsafe { msg_send_id![cls, new] }; } } diff --git a/crates/objc2/src/class_type.rs b/crates/objc2/src/class_type.rs index aeb7b216d..53d8b352c 100644 --- a/crates/objc2/src/class_type.rs +++ b/crates/objc2/src/class_type.rs @@ -1,7 +1,7 @@ use crate::msg_send_id; use crate::mutability::{IsAllocableAnyThread, IsRetainable, Mutability}; use crate::rc::{Allocated, Id}; -use crate::runtime::Class; +use crate::runtime::AnyClass; use crate::Message; /// Marks types that represent specific classes. @@ -21,7 +21,7 @@ use crate::Message; /// /// 1. The type must represent a specific class. /// 2. [`Self::Super`] must be a superclass of the class (or something that -/// represents any object, like [`Object`][crate::runtime::Object]). +/// represents any object, like [`AnyObject`][crate::runtime::AnyObject]). /// 3. [`Self::Mutability`] must be specified correctly. /// /// Note that very little Objective-C code follows Rust's usual ownership @@ -40,7 +40,7 @@ use crate::Message; /// /// # Examples /// -/// Use the trait to access the [`Class`] of an object. +/// Use the trait to access the [`AnyClass`] of an object. /// /// ``` /// use objc2::{ClassType, msg_send_id}; @@ -112,11 +112,11 @@ pub unsafe trait ClassType: Message { /// If you have implemented [`Deref`] for your type, it is highly /// recommended that this is equal to [`Deref::Target`]. /// - /// This may be [`Object`] if the class is a root class. + /// This may be [`AnyObject`] if the class is a root class. /// /// [`Deref`]: std::ops::Deref /// [`Deref::Target`]: std::ops::Deref::Target - /// [`Object`]: crate::runtime::Object + /// [`AnyObject`]: crate::runtime::AnyObject type Super: Message; /// Whether the type is mutable or immutable. @@ -140,7 +140,7 @@ pub unsafe trait ClassType: Message { /// This may panic if something went wrong with getting or declaring the /// class, e.g. if the program is not properly linked to the framework /// that defines the class. - fn class() -> &'static Class; + fn class() -> &'static AnyClass; /// Get an immutable reference to the superclass. // Note: It'd be safe to provide a default impl using transmute here if diff --git a/crates/objc2/src/declare/ivar.rs b/crates/objc2/src/declare/ivar.rs index 65410d8e7..d9274a9f9 100644 --- a/crates/objc2/src/declare/ivar.rs +++ b/crates/objc2/src/declare/ivar.rs @@ -5,7 +5,7 @@ use core::ops::{Deref, DerefMut}; use core::ptr::{self, NonNull}; use crate::encode::Encode; -use crate::runtime::{ivar_offset, Object}; +use crate::runtime::{ivar_offset, AnyObject}; pub(crate) mod private { pub trait Sealed {} @@ -92,7 +92,7 @@ pub unsafe trait IvarType { const NAME: &'static str; #[doc(hidden)] - unsafe fn __offset(ptr: NonNull) -> isize { + unsafe fn __offset(ptr: NonNull) -> isize { let obj = unsafe { ptr.as_ref() }; ivar_offset(obj.class(), Self::NAME, &Self::Type::ENCODING) } @@ -107,9 +107,9 @@ pub unsafe trait IvarType { /// of the containing object. /// /// Note that this is not ([currently][zst-hack]) allowed by [stacked -/// borrows][sb], but due to [`Object`] being a zero-sized type such that we -/// don't have provenance over the ivars anyhow, this should be just as sound -/// as normal instance variable access. +/// borrows][sb], but due to objects being zero-sized types, we don't have +/// provenance over the ivars anyhow, this should be just as sound as normal +/// instance variable access. /// /// [sb]: https://github.com/rust-lang/unsafe-code-guidelines/blob/e21202c60c7be03dd2ab016ada92fb5305d40438/wip/stacked-borrows.md /// [zst-hack]: https://github.com/rust-lang/unsafe-code-guidelines/issues/305 @@ -141,7 +141,7 @@ pub unsafe trait IvarType { /// /// ``` /// use objc2::declare::{Ivar, IvarEncode, IvarType}; -/// use objc2::runtime::Object; +/// use objc2::runtime::NSObject; /// /// // Declare ivar with given type and name /// struct MyCustomIvar; @@ -153,15 +153,15 @@ pub unsafe trait IvarType { /// // Custom object /// #[repr(C)] /// pub struct MyObject { -/// inner: Object, +/// inner: NSObject, /// // SAFETY: The instance variable is used within an object, and it is /// // properly declared below. /// my_ivar: Ivar, /// } /// -/// # use objc2::class; +/// # use objc2::ClassType; /// # use objc2::declare::ClassBuilder; -/// # let mut builder = ClassBuilder::new("MyObject", class!(NSObject)).unwrap(); +/// # let mut builder = ClassBuilder::new("MyObject", NSObject::class()).unwrap(); /// // Declare the class and add the instance variable to it /// builder.add_static_ivar::(); /// # let _cls = builder.register(); @@ -202,10 +202,10 @@ impl Ivar { } fn as_inner_ptr(&self) -> NonNull { - let ptr: NonNull = NonNull::from(self).cast(); + let ptr: NonNull = NonNull::from(self).cast(); // SAFETY: The user ensures that this is placed in a struct that can - // be reinterpreted as an `Object`. Since `Ivar` can never be + // be reinterpreted as an `AnyObject`. Since `Ivar` can never be // constructed by itself (and is neither Copy nor Clone), we know that // it is guaranteed to _stay_ in said struct. // @@ -217,7 +217,7 @@ impl Ivar { // so that is fine. let offset = unsafe { T::__offset(ptr) }; // SAFETY: The offset is valid - unsafe { Object::ivar_at_offset::(ptr, offset) } + unsafe { AnyObject::ivar_at_offset::(ptr, offset) } } /// Get a mutable pointer to the instance variable. @@ -235,12 +235,12 @@ impl Ivar { } fn as_inner_mut_ptr(&mut self) -> NonNull { - let ptr: NonNull = NonNull::from(self).cast(); + let ptr: NonNull = NonNull::from(self).cast(); // SAFETY: Same as `as_inner_ptr` let offset = unsafe { T::__offset(ptr) }; // SAFETY: The offset is valid - unsafe { Object::ivar_at_offset::(ptr, offset) } + unsafe { AnyObject::ivar_at_offset::(ptr, offset) } } /// Sets the value of the instance variable. @@ -281,13 +281,13 @@ impl DerefMut for Ivar { // Safe as mutable because there is only one access to a // particular ivar at a time (since we have `&mut self`). - // Note: We're careful not to create `&mut Object` because the user + // Note: We're careful not to create `&mut AnyObject` because the user // might have two mutable references to different ivars, as such: // // ``` // #[repr(C)] // struct X { - // inner: Object, + // inner: AnyObject, // ivar1: Ivar, // ivar2: Ivar, // } @@ -332,7 +332,7 @@ mod tests { #[repr(C)] struct IvarTestObject { - inner: Object, + inner: NSObject, foo: Ivar, } diff --git a/crates/objc2/src/declare/mod.rs b/crates/objc2/src/declare/mod.rs index 5216c91c7..d7ee6bcd4 100644 --- a/crates/objc2/src/declare/mod.rs +++ b/crates/objc2/src/declare/mod.rs @@ -20,10 +20,10 @@ //! //! use objc2::declare::ClassBuilder; //! use objc2::rc::Id; -//! use objc2::runtime::{Class, Object, NSObject, Sel}; +//! use objc2::runtime::{AnyClass, AnyObject, NSObject, Sel}; //! use objc2::{sel, msg_send, msg_send_id, ClassType}; //! -//! fn register_class() -> &'static Class { +//! fn register_class() -> &'static AnyClass { //! // Inherit from NSObject //! let mut builder = ClassBuilder::new("MyNumber", NSObject::class()) //! .expect("a class with the name MyNumber likely already exists"); @@ -33,15 +33,15 @@ //! //! // Add an Objective-C method for initializing an instance with a number //! // -//! // We "cheat" a bit here, and use `Object` instead of `NSObject`, +//! // We "cheat" a bit here, and use `AnyObject` instead of `NSObject`, //! // since only the former is allowed to be a mutable receiver (which is //! // always safe in `init` methods, but not in others). //! unsafe extern "C" fn init_with_number( -//! this: &mut Object, +//! this: &mut AnyObject, //! _cmd: Sel, //! number: u32, -//! ) -> Option<&mut Object> { -//! let this: Option<&mut Object> = msg_send![super(this, NSObject::class()), init]; +//! ) -> Option<&mut AnyObject> { +//! let this: Option<&mut AnyObject> = msg_send![super(this, NSObject::class()), init]; //! this.map(|this| { //! // SAFETY: The ivar is added with the same type above //! this.set_ivar::>("_number", Cell::new(number)); @@ -57,7 +57,7 @@ //! //! // Add convenience method for getting a new instance with the number //! extern "C" fn with_number( -//! cls: &Class, +//! cls: &AnyClass, //! _cmd: Sel, //! number: u32, //! ) -> *mut NSObject { @@ -136,7 +136,7 @@ use crate::encode::{Encode, Encoding, RefEncode}; use crate::ffi; use crate::mutability::IsMutable; use crate::rc::Allocated; -use crate::runtime::{Bool, Class, Imp, Object, Protocol, Sel}; +use crate::runtime::{AnyClass, AnyObject, AnyProtocol, Bool, Imp, Sel}; use crate::sel; use crate::Message; @@ -249,12 +249,12 @@ macro_rules! method_decl_impl { method_decl_impl!(@<'a> T: Message, R, unsafe extern $abi fn(&'a T, Sel $(, $t)*) -> R, $($t),*); method_decl_impl!(@<'a> T: IsMutable, R, unsafe extern $abi fn(&'a mut T, Sel $(, $t)*) -> R, $($t),*); - method_decl_impl!(@<'a> Object, R, extern $abi fn(&'a mut Object, Sel $(, $t)*) -> R, $($t),*); - method_decl_impl!(@<'a> Object, R, unsafe extern $abi fn(&'a mut Object, Sel $(, $t)*) -> R, $($t),*); + method_decl_impl!(@<'a> AnyObject, R, extern $abi fn(&'a mut AnyObject, Sel $(, $t)*) -> R, $($t),*); + method_decl_impl!(@<'a> AnyObject, R, unsafe extern $abi fn(&'a mut AnyObject, Sel $(, $t)*) -> R, $($t),*); - method_decl_impl!(@<'a> Class, R, extern $abi fn(&'a Class, Sel $(, $t)*) -> R, $($t),*); - method_decl_impl!(@<> Class, R, unsafe extern $abi fn(*const Class, Sel $(, $t)*) -> R, $($t),*); - method_decl_impl!(@<'a> Class, R, unsafe extern $abi fn(&'a Class, Sel $(, $t)*) -> R, $($t),*); + method_decl_impl!(@<'a> AnyClass, R, extern $abi fn(&'a AnyClass, Sel $(, $t)*) -> R, $($t),*); + method_decl_impl!(@<> AnyClass, R, unsafe extern $abi fn(*const AnyClass, Sel $(, $t)*) -> R, $($t),*); + method_decl_impl!(@<'a> AnyClass, R, unsafe extern $abi fn(&'a AnyClass, Sel $(, $t)*) -> R, $($t),*); method_decl_impl!(@<> Allocated, extern $abi fn(Allocated, Sel $(, $t)*) -> __IdReturnValue, $($t),*); method_decl_impl!(@<> Allocated, unsafe extern $abi fn(Allocated, Sel $(, $t)*) -> __IdReturnValue, $($t),*); @@ -288,16 +288,16 @@ method_decl_impl!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P); /// `Allocated`, without exposing that implementation to users. #[doc(hidden)] #[repr(transparent)] -pub struct __IdReturnValue(pub(crate) *mut Object); +pub struct __IdReturnValue(pub(crate) *mut AnyObject); // SAFETY: `__IdReturnValue` is `#[repr(transparent)]` unsafe impl Encode for __IdReturnValue { - const ENCODING: Encoding = <*mut Object>::ENCODING; + const ENCODING: Encoding = <*mut AnyObject>::ENCODING; } fn method_type_encoding(ret: &Encoding, args: &[Encoding]) -> CString { // First two arguments are always self and the selector - let mut types = format!("{ret}{}{}", <*mut Object>::ENCODING, Sel::ENCODING); + let mut types = format!("{ret}{}{}", <*mut AnyObject>::ENCODING, Sel::ENCODING); for enc in args { use core::fmt::Write; write!(&mut types, "{enc}").unwrap(); @@ -318,7 +318,7 @@ fn log2_align_of() -> u8 { #[derive(Debug)] pub struct ClassBuilder { // Note: Don't ever construct a &mut objc_class, since it is possible to - // get this pointer using `Class::classes`! + // get this pointer using `AnyClass::classes`! cls: NonNull, } @@ -346,19 +346,19 @@ impl ClassBuilder { } #[allow(unused)] - fn superclass(&self) -> Option<&Class> { + fn superclass(&self) -> Option<&AnyClass> { // SAFETY: Though the class is not finalized, `class_getSuperclass` is // still safe to call. - unsafe { Class::superclass_raw(self.cls.as_ptr()) } + unsafe { AnyClass::superclass_raw(self.cls.as_ptr()) } } #[allow(unused)] fn name(&self) -> &str { // SAFETY: Same as `superclass` - unsafe { Class::name_raw(self.cls.as_ptr()) } + unsafe { AnyClass::name_raw(self.cls.as_ptr()) } } - fn with_superclass(name: &str, superclass: Option<&Class>) -> Option { + fn with_superclass(name: &str, superclass: Option<&AnyClass>) -> Option { let name = CString::new(name).unwrap(); let super_ptr = superclass.map_or(ptr::null(), |c| c).cast(); let cls = unsafe { ffi::objc_allocateClassPair(super_ptr, name.as_ptr(), 0) }; @@ -369,7 +369,7 @@ impl ClassBuilder { /// /// Returns [`None`] if the class couldn't be allocated, or a class with /// that name already exist. - pub fn new(name: &str, superclass: &Class) -> Option { + pub fn new(name: &str, superclass: &AnyClass) -> Option { Self::with_superclass(name, Some(superclass)) } @@ -389,7 +389,7 @@ impl ClassBuilder { /// `-release` used by ARC, will not be present otherwise. pub fn root(name: &str, intitialize_fn: F) -> Option where - F: MethodImplementation, + F: MethodImplementation, { Self::with_superclass(name, None).map(|mut this| { unsafe { this.add_class_method(sel!(initialize), intitialize_fn) }; @@ -474,7 +474,7 @@ impl ClassBuilder { /// when the method is invoked from Objective-C. pub unsafe fn add_class_method(&mut self, sel: Sel, func: F) where - F: MethodImplementation, + F: MethodImplementation, { let enc_args = F::Args::ENCODINGS; let enc_ret = F::Ret::ENCODING_RETURN; @@ -571,7 +571,7 @@ impl ClassBuilder { /// # Panics /// /// If the protocol wasn't successfully added. - pub fn add_protocol(&mut self, proto: &Protocol) { + pub fn add_protocol(&mut self, proto: &AnyProtocol) { let success = unsafe { ffi::class_addProtocol(self.as_mut_ptr(), proto.as_ptr()) }; let success = Bool::from_raw(success).as_bool(); assert!(success, "Failed to add protocol {proto}"); @@ -580,12 +580,12 @@ impl ClassBuilder { // fn add_property(&self, name: &str, attributes: &[ffi::objc_property_attribute_t]); /// Registers the [`ClassBuilder`], consuming it, and returns a reference - /// to the newly registered [`Class`]. - pub fn register(self) -> &'static Class { + /// to the newly registered [`AnyClass`]. + pub fn register(self) -> &'static AnyClass { // Forget self, otherwise the class will be disposed in drop let mut this = ManuallyDrop::new(self); unsafe { ffi::objc_registerClassPair(this.as_mut_ptr()) }; - unsafe { this.cls.cast::().as_ref() } + unsafe { this.cls.cast::().as_ref() } } } @@ -595,7 +595,7 @@ impl Drop for ClassBuilder { // so we register the class before disposing it. // // Doing it this way is _technically_ a race-condition, since other - // code could read e.g. `Class::classes()` and then pick the class + // code could read e.g. `AnyClass::classes()` and then pick the class // before it got disposed - but let's not worry about that for now. #[cfg(feature = "gnustep-1-7")] unsafe { @@ -610,7 +610,7 @@ impl Drop for ClassBuilder { /// before registering it. #[derive(Debug)] pub struct ProtocolBuilder { - proto: NonNull, + proto: NonNull, } #[doc(hidden)] @@ -685,15 +685,15 @@ impl ProtocolBuilder { } /// Adds a requirement on another protocol. - pub fn add_protocol(&mut self, proto: &Protocol) { + pub fn add_protocol(&mut self, proto: &AnyProtocol) { unsafe { ffi::protocol_addProtocol(self.as_mut_ptr(), proto.as_ptr()); } } /// Registers the [`ProtocolBuilder`], consuming it and returning a reference - /// to the newly registered [`Protocol`]. - pub fn register(mut self) -> &'static Protocol { + /// to the newly registered [`AnyProtocol`]. + pub fn register(mut self) -> &'static AnyProtocol { unsafe { ffi::objc_registerProtocol(self.as_mut_ptr()); self.proto.as_ref() @@ -736,7 +736,7 @@ mod tests { let cls = test_utils::custom_class(); let mut builder = ClassBuilder::new("TestClassBuilderDuplicateMethod", cls).unwrap(); - extern "C" fn xyz(_this: &Object, _cmd: Sel) {} + extern "C" fn xyz(_this: &NSObject, _cmd: Sel) {} unsafe { builder.add_method(sel!(xyz), xyz as extern "C" fn(_, _)); @@ -754,7 +754,7 @@ mod tests { let cls = test_utils::custom_class(); let mut builder = ClassBuilder::new("TestClassBuilderInvalidMethod", cls).unwrap(); - extern "C" fn foo(_this: &Object, _cmd: Sel) -> i32 { + extern "C" fn foo(_this: &NSObject, _cmd: Sel) -> i32 { 0 } @@ -772,7 +772,7 @@ mod tests { let cls = test_utils::custom_class(); let mut builder = ClassBuilder::new("TestClassBuilderInvalidClassMethod", cls).unwrap(); - extern "C" fn class_foo(_cls: &Class, _cmd: Sel) -> i32 { + extern "C" fn class_foo(_cls: &AnyClass, _cmd: Sel) -> i32 { 0 } @@ -787,7 +787,7 @@ mod tests { let cls = test_utils::custom_class(); let mut builder = ClassBuilder::new("TestClassBuilderDuplicateProtocol", cls).unwrap(); - let protocol = Protocol::get("NSObject").unwrap(); + let protocol = AnyProtocol::get("NSObject").unwrap(); builder.add_protocol(protocol); // Should panic: @@ -815,9 +815,9 @@ mod tests { #[test] #[cfg(feature = "malloc")] fn test_in_all_classes() { - fn is_present(cls: *const Class) -> bool { - // Check whether the class is present in Class::classes() - Class::classes().iter().any(|item| ptr::eq(cls, *item)) + fn is_present(cls: *const AnyClass) -> bool { + // Check whether the class is present in AnyClass::classes() + AnyClass::classes().iter().any(|item| ptr::eq(cls, *item)) } let superclass = test_utils::custom_class(); @@ -1023,7 +1023,7 @@ mod tests { unimplemented!() } - fn class() -> &'static Class { + fn class() -> &'static AnyClass { let superclass = NSObject::class(); let mut builder = ClassBuilder::new(Self::NAME, superclass).unwrap(); diff --git a/crates/objc2/src/exception.rs b/crates/objc2/src/exception.rs index 9d5673322..719784ed1 100644 --- a/crates/objc2/src/exception.rs +++ b/crates/objc2/src/exception.rs @@ -36,7 +36,7 @@ use crate::encode::{Encoding, RefEncode}; use crate::ffi; use crate::rc::{autoreleasepool_leaking, Id}; use crate::runtime::__nsstring::nsstring_to_str; -use crate::runtime::{Class, NSObject, NSObjectProtocol, Object}; +use crate::runtime::{AnyClass, AnyObject, NSObject, NSObjectProtocol}; use crate::{extern_methods, sel, Message}; /// An Objective-C exception. @@ -47,7 +47,7 @@ use crate::{extern_methods, sel, Message}; /// /// [`panic_any`]: std::panic::panic_any #[repr(transparent)] -pub struct Exception(Object); +pub struct Exception(AnyObject); unsafe impl RefEncode for Exception { const ENCODING_REF: Encoding = Encoding::Object; @@ -56,17 +56,17 @@ unsafe impl RefEncode for Exception { unsafe impl Message for Exception {} impl Deref for Exception { - type Target = Object; + type Target = AnyObject; #[inline] - fn deref(&self) -> &Object { + fn deref(&self) -> &AnyObject { &self.0 } } -impl AsRef for Exception { +impl AsRef for Exception { #[inline] - fn as_ref(&self) -> &Object { + fn as_ref(&self) -> &AnyObject { self } } @@ -78,7 +78,7 @@ impl Exception { let obj: *const Exception = self; let obj = unsafe { obj.cast::().as_ref().unwrap() }; // Get class dynamically instead of with `class!` macro - Some(obj.__isKindOfClass(Class::get("NSException")?)) + Some(obj.__isKindOfClass(AnyClass::get("NSException")?)) } else { Some(false) } @@ -121,7 +121,7 @@ impl fmt::Debug for Exception { .as_deref() .map(|reason| unsafe { nsstring_to_str(reason, pool) }); - let obj: &Object = self.as_ref(); + let obj: &AnyObject = self.as_ref(); write!(f, "{obj:?} '{}'", name.unwrap_or_default())?; if let Some(reason) = reason { write!(f, " reason:{reason}")?; @@ -131,7 +131,7 @@ impl fmt::Debug for Exception { Ok(()) }) } else { - // Fall back to `Object` Debug + // Fall back to `AnyObject` Debug write!(f, "{:?}", self.0) } } @@ -184,8 +184,8 @@ pub unsafe fn throw(exception: Id) -> ! { // We consume the exception object since we can't make any guarantees // about its mutability. let ptr = exception.0.as_ptr() as *mut ffi::objc_object; - // SAFETY: Object is valid and non-null (nil exceptions are not valid in - // the old runtime). + // SAFETY: The object is valid and non-null (nil exceptions are not valid + // in the old runtime). unsafe { ffi::objc_exception_throw(ptr) } } diff --git a/crates/objc2/src/macros/__rewrite_self_arg.rs b/crates/objc2/src/macros/__rewrite_self_arg.rs index 5df592962..084461edf 100644 --- a/crates/objc2/src/macros/__rewrite_self_arg.rs +++ b/crates/objc2/src/macros/__rewrite_self_arg.rs @@ -211,9 +211,9 @@ macro_rules! __rewrite_self_arg_inner { (add_class_method) (::class()) - (&$crate::runtime::Class) + (&$crate::runtime::AnyClass) ( - _: &$crate::runtime::Class, + _: &$crate::runtime::AnyClass, _: $crate::runtime::Sel, ) ($($args_rest)*) diff --git a/crates/objc2/src/macros/declare_class.rs b/crates/objc2/src/macros/declare_class.rs index 16edca8df..db70e08b7 100644 --- a/crates/objc2/src/macros/declare_class.rs +++ b/crates/objc2/src/macros/declare_class.rs @@ -523,7 +523,7 @@ macro_rules! __inner_declare_class { $crate::__extern_class_impl_traits! { // SAFETY: Upheld by caller unsafe impl () for $for { - INHERITS = [$superclass, $($($inheritance_rest,)+)? $crate::runtime::Object]; + INHERITS = [$superclass, $($($inheritance_rest,)+)? $crate::runtime::AnyObject]; fn as_super(&self) { &*self.__superclass @@ -541,7 +541,7 @@ macro_rules! __inner_declare_class { type Mutability = $mutability; const NAME: &'static $crate::__macro_helpers::str = $name_const; - fn class() -> &'static $crate::runtime::Class { + fn class() -> &'static $crate::runtime::AnyClass { $crate::__macro_helpers::assert_mutability_matches_superclass_mutability::(); // TODO: Use `core::cell::LazyCell` @@ -610,7 +610,7 @@ macro_rules! __inner_declare_class { }); // We just registered the class, so it should be available - $crate::runtime::Class::get(::NAME).unwrap() + $crate::runtime::AnyClass::get(::NAME).unwrap() } #[inline] diff --git a/crates/objc2/src/macros/extern_class.rs b/crates/objc2/src/macros/extern_class.rs index 44534d2fe..ffb0c5fda 100644 --- a/crates/objc2/src/macros/extern_class.rs +++ b/crates/objc2/src/macros/extern_class.rs @@ -350,7 +350,7 @@ macro_rules! __inner_extern_class { $crate::__extern_class_impl_traits! { $(#[$impl_m])* unsafe impl ($($t_for $(: $b_for)?),*) for $for { - INHERITS = [$superclass, $($($inheritance_rest,)+)? $crate::runtime::Object]; + INHERITS = [$superclass, $($($inheritance_rest,)+)? $crate::runtime::AnyObject]; fn as_super(&$as_super_self) $as_super fn as_super_mut(&mut $as_super_mut_self) $as_super_mut @@ -364,7 +364,7 @@ macro_rules! __inner_extern_class { const NAME: &'static $crate::__macro_helpers::str = $crate::__select_name!($name; $($name_const)?); #[inline] - fn class() -> &'static $crate::runtime::Class { + fn class() -> &'static $crate::runtime::AnyClass { $crate::__macro_helpers::assert_mutability_matches_superclass_mutability::(); $crate::__class_inner!( @@ -414,8 +414,8 @@ macro_rules! __extern_class_impl_traits { = <$superclass as $crate::RefEncode>::ENCODING_REF; } - // SAFETY: This is a newtype wrapper over `Object` (we even ensure - // that `Object` is always last in our inheritance tree), so it is + // SAFETY: This is a newtype wrapper over `AnyObject` (we even ensure + // that `AnyObject` is always last in our inheritance tree), so it is // always safe to reinterpret as that. // // That the object must work with standard memory management is diff --git a/crates/objc2/src/macros/mod.rs b/crates/objc2/src/macros/mod.rs index 626666851..cf980ae85 100644 --- a/crates/objc2/src/macros/mod.rs +++ b/crates/objc2/src/macros/mod.rs @@ -8,12 +8,12 @@ mod extern_class; mod extern_methods; mod extern_protocol; -/// Gets a reference to a [`Class`] from the given name. +/// Gets a reference to an [`AnyClass`] from the given name. /// /// If you have an object that implements [`ClassType`], consider using the /// [`ClassType::class`] method instead. /// -/// [`Class`]: crate::runtime::Class +/// [`AnyClass`]: crate::runtime::AnyClass /// [`ClassType`]: crate::ClassType /// [`ClassType::class`]: crate::ClassType::class /// @@ -22,9 +22,9 @@ mod extern_protocol; /// /// Panics if no class with the given name can be found. /// -/// To dynamically check for a class that may not exist, use [`Class::get`]. +/// To dynamically check for a class that may not exist, use [`AnyClass::get`]. /// -/// [`Class::get`]: crate::runtime::Class::get +/// [`AnyClass::get`]: crate::runtime::AnyClass::get /// /// /// # Features @@ -442,7 +442,7 @@ macro_rules! __inner_statics_apple_generic { $hash:expr; } => { use $crate::__macro_helpers::UnsafeCell; - use $crate::runtime::Class; + use $crate::runtime::AnyClass; extern "C" { /// Link to the Objective-C class static. @@ -458,7 +458,7 @@ macro_rules! __inner_statics_apple_generic { /// though _should_ be a static linker error. /// /// Ideally, we'd have some way of allowing this to be weakly - /// linked, and return `Option<&Class>` in that case, but Rust + /// linked, and return `Option<&AnyClass>` in that case, but Rust /// doesn't have the capability to do so yet! /// /// @@ -467,7 +467,7 @@ macro_rules! __inner_statics_apple_generic { "OBJC_CLASS_$_", $name, )] - static CLASS: Class; + static CLASS: AnyClass; } /// SAFETY: Same as `REF` above in `@sel`. @@ -476,7 +476,7 @@ macro_rules! __inner_statics_apple_generic { "\x01L_OBJC_CLASSLIST_REFERENCES_$_", $hash, )] - static mut REF: UnsafeCell<&Class> = unsafe { + static mut REF: UnsafeCell<&AnyClass> = unsafe { UnsafeCell::new(&CLASS) }; }; @@ -486,7 +486,7 @@ macro_rules! __inner_statics_apple_generic { $hash:expr; } => { use $crate::__macro_helpers::{u8, UnsafeCell}; - use $crate::runtime::Class; + use $crate::runtime::AnyClass; const X: &[u8] = $name.as_bytes(); @@ -507,8 +507,8 @@ macro_rules! __inner_statics_apple_generic { "\x01L_OBJC_CLASS_REFERENCES_", $hash, )] - static mut REF: UnsafeCell<&Class> = unsafe { - let ptr: *const Class = NAME_DATA.as_ptr().cast(); + static mut REF: UnsafeCell<&AnyClass> = unsafe { + let ptr: *const AnyClass = NAME_DATA.as_ptr().cast(); UnsafeCell::new(&*ptr) }; } @@ -659,7 +659,7 @@ macro_rules! __class_inner { $crate::__inner_statics!(@class $name, $hash); #[inline(never)] - fn objc_static_workaround() -> &'static Class { + fn objc_static_workaround() -> &'static AnyClass { // SAFETY: Same as __sel_inner unsafe { *REF.get() } } @@ -694,8 +694,8 @@ macro_rules! __class_inner { /// ``` /// # use std::os::raw::{c_int, c_char}; /// # use objc2::msg_send; -/// # use objc2::runtime::Object; -/// unsafe fn do_something(obj: &Object, arg: c_int) -> *const c_char { +/// # use objc2::runtime::NSObject; +/// unsafe fn do_something(obj: &NSObject, arg: c_int) -> *const c_char { /// msg_send![obj, doSomething: arg] /// } /// ``` @@ -880,11 +880,11 @@ macro_rules! __class_inner { /// /// ```no_run /// use objc2::msg_send; -/// use objc2::runtime::Object; +/// use objc2::runtime::NSObject; /// -/// let obj: *mut Object; -/// # obj = 0 as *mut Object; -/// let description: *const Object = unsafe { msg_send![obj, description] }; +/// let obj: *mut NSObject; +/// # obj = 0 as *mut NSObject; +/// let description: *const NSObject = unsafe { msg_send![obj, description] }; /// // Usually you'd use msg_send_id here ^ /// let _: () = unsafe { msg_send![obj, setArg1: 1i32, arg2: true] }; /// let arg1: i32 = unsafe { msg_send![obj, getArg1] }; @@ -919,13 +919,13 @@ macro_rules! __class_inner { /// ```no_run /// # use objc2::class; /// use objc2::msg_send; -/// use objc2::runtime::{Class, Object}; +/// use objc2::runtime::{AnyClass, NSObject}; /// /// // Since we specify the superclass ourselves, this doesn't need to /// // implement ClassType -/// let obj: *mut Object; -/// # obj = 0 as *mut Object; -/// let superclass: &Class; +/// let obj: *mut NSObject; +/// # obj = 0 as *mut NSObject; +/// let superclass: &AnyClass; /// # superclass = class!(NSObject); /// let arg3: u32 = unsafe { msg_send![super(obj, superclass), getArg3] }; /// ``` @@ -936,8 +936,8 @@ macro_rules! __class_inner { /// use objc2::msg_send; /// use objc2::rc::Id; /// -/// # type NSBundle = objc2::runtime::Object; -/// # type NSError = objc2::runtime::Object; +/// # type NSBundle = objc2::runtime::NSObject; +/// # type NSError = objc2::runtime::NSObject; /// let obj: &NSBundle; /// # obj = todo!(); /// // The `_` tells the macro that the return type should be `Result`. @@ -952,9 +952,9 @@ macro_rules! __class_inner { /// use objc2::msg_send; /// use objc2::rc::Id; /// -/// # type NSFileManager = objc2::runtime::Object; -/// # type NSURL = objc2::runtime::Object; -/// # type NSError = objc2::runtime::Object; +/// # type NSFileManager = objc2::runtime::NSObject; +/// # type NSURL = objc2::runtime::NSObject; +/// # type NSError = objc2::runtime::NSObject; /// let obj: &NSFileManager; /// # obj = todo!(); /// let url: &NSURL; @@ -1102,11 +1102,11 @@ macro_rules! msg_send_bool { /// families][sel-families] the selector belongs to: /// /// - The `new` family: The receiver may be anything that implements -/// [`MessageReceiver`] (though often you'll want to use `&Class`). The +/// [`MessageReceiver`] (though often you'll want to use `&AnyClass`). The /// return type is a generic `Id` or `Option>`. /// -/// - The `alloc` family: The receiver must be `&Class`, and the return type -/// is a generic `Allocated` or `Option>`. +/// - The `alloc` family: The receiver must be `&AnyClass`, and the return +/// type is a generic `Allocated` or `Option>`. /// /// - The `init` family: The receiver must be `Option>` as /// returned from `alloc`. The receiver is consumed, and a the @@ -1199,16 +1199,16 @@ macro_rules! msg_send_bool { /// use objc2::{class, msg_send_id}; /// use objc2::ffi::NSUInteger; /// use objc2::rc::Id; -/// use objc2::runtime::Object; +/// use objc2::runtime::NSObject; /// // Allocate new object /// let obj = unsafe { msg_send_id![class!(NSObject), alloc] }; /// // Consume the allocated object, return initialized object -/// let obj: Id = unsafe { msg_send_id![obj, init] }; +/// let obj: Id = unsafe { msg_send_id![obj, init] }; /// // Copy the object -/// let copy: Id = unsafe { msg_send_id![&obj, copy] }; +/// let copy: Id = unsafe { msg_send_id![&obj, copy] }; /// // Call ordinary selector that returns an object /// // This time, we handle failures ourselves -/// let s: Option> = unsafe { msg_send_id![&obj, description] }; +/// let s: Option> = unsafe { msg_send_id![&obj, description] }; /// let s = s.expect("description was NULL"); /// ``` #[macro_export] diff --git a/crates/objc2/src/message/apple/mod.rs b/crates/objc2/src/message/apple/mod.rs index 8fb13129c..f14b8db80 100644 --- a/crates/objc2/src/message/apple/mod.rs +++ b/crates/objc2/src/message/apple/mod.rs @@ -1,6 +1,6 @@ use crate::encode::__unstable::EncodeReturn; use crate::ffi; -use crate::runtime::{Class, Imp, Object, Sel}; +use crate::runtime::{AnyClass, AnyObject, Imp, Sel}; use crate::MessageArguments; #[cfg(target_arch = "x86")] @@ -26,7 +26,7 @@ unsafe trait MsgSendFn: EncodeReturn { #[inline] #[track_caller] -pub(crate) unsafe fn send_unverified(receiver: *mut Object, sel: Sel, args: A) -> R +pub(crate) unsafe fn send_unverified(receiver: *mut AnyObject, sel: Sel, args: A) -> R where A: MessageArguments, R: EncodeReturn, @@ -38,8 +38,8 @@ where #[inline] #[track_caller] pub(crate) unsafe fn send_super_unverified( - receiver: *mut Object, - superclass: &Class, + receiver: *mut AnyObject, + superclass: &AnyClass, sel: Sel, args: A, ) -> R @@ -47,7 +47,7 @@ where A: MessageArguments, R: EncodeReturn, { - let superclass: *const Class = superclass; + let superclass: *const AnyClass = superclass; let mut sup = ffi::objc_super { receiver: receiver.cast(), super_class: superclass.cast(), diff --git a/crates/objc2/src/message/gnustep.rs b/crates/objc2/src/message/gnustep.rs index 59611021b..5f9510d42 100644 --- a/crates/objc2/src/message/gnustep.rs +++ b/crates/objc2/src/message/gnustep.rs @@ -3,7 +3,7 @@ use core::mem; use crate::encode::__unstable::EncodeReturn; use crate::ffi; -use crate::runtime::{Class, Imp, Object, Sel}; +use crate::runtime::{AnyClass, AnyObject, Imp, Sel}; use crate::MessageArguments; #[inline] @@ -21,7 +21,7 @@ fn unwrap_msg_send_fn(msg_send_fn: Option) -> Imp { } #[track_caller] -pub(crate) unsafe fn send_unverified(receiver: *mut Object, sel: Sel, args: A) -> R +pub(crate) unsafe fn send_unverified(receiver: *mut AnyObject, sel: Sel, args: A) -> R where A: MessageArguments, R: EncodeReturn, @@ -43,8 +43,8 @@ where #[track_caller] pub(crate) unsafe fn send_super_unverified( - receiver: *mut Object, - superclass: &Class, + receiver: *mut AnyObject, + superclass: &AnyClass, sel: Sel, args: A, ) -> R @@ -57,7 +57,7 @@ where return unsafe { mem::zeroed() }; } - let superclass: *const Class = superclass; + let superclass: *const AnyClass = superclass; let sup = ffi::objc_super { receiver: receiver.cast(), super_class: superclass.cast(), diff --git a/crates/objc2/src/message/mod.rs b/crates/objc2/src/message/mod.rs index cfa690e13..aadcf3673 100644 --- a/crates/objc2/src/message/mod.rs +++ b/crates/objc2/src/message/mod.rs @@ -8,7 +8,7 @@ use crate::encode::__unstable::{ use crate::encode::{Encode, RefEncode}; use crate::mutability::IsMutable; use crate::rc::Id; -use crate::runtime::{Class, Imp, Object, Sel}; +use crate::runtime::{AnyClass, AnyObject, Imp, Sel}; use crate::ClassType; /// Wrap the given closure in `exception::catch` if the `catch-all` feature is @@ -45,7 +45,7 @@ macro_rules! conditional_try { #[cfg(debug_assertions)] #[track_caller] fn msg_send_check( - obj: Option<&Object>, + obj: Option<&AnyObject>, sel: Sel, args: &[crate::encode::Encoding], ret: &crate::encode::Encoding, @@ -79,7 +79,7 @@ fn panic_null(sel: Sel) -> ! { #[cfg(debug_assertions)] #[track_caller] -fn panic_verify(cls: &Class, sel: Sel, err: crate::runtime::VerificationError) -> ! { +fn panic_verify(cls: &AnyClass, sel: Sel, err: crate::runtime::VerificationError) -> ! { panic!( "invalid message send to {}[{cls} {sel}]: {err}", if cls.is_metaclass() { "+" } else { "-" }, @@ -131,7 +131,7 @@ use self::platform::{send_super_unverified, send_unverified}; /// # Safety /// /// The type must represent an Objective-C object, meaning it: -/// - Must be valid to reinterpret as [`runtime::Object`][`Object`]. +/// - Must be valid to reinterpret as [`runtime::AnyObject`][`AnyObject`]. /// - Must be able to be the receiver of an Objective-C message sent with /// [`objc_msgSend`] or similar. /// - Must respond to the standard memory management `retain`, `release` and @@ -146,13 +146,13 @@ use self::platform::{send_super_unverified, send_unverified}; /// # Example /// /// ``` -/// use objc2::runtime::Object; +/// use objc2::runtime::NSObject; /// use objc2::{Encoding, Message, RefEncode}; /// /// #[repr(C)] /// struct MyObject { -/// // This has the exact same layout as `Object` -/// inner: Object +/// // This has the exact same layout as `NSObject` +/// inner: NSObject /// } /// /// unsafe impl RefEncode for MyObject { @@ -194,7 +194,7 @@ pub unsafe trait MessageReceiver: private::Sealed + Sized { type __Inner: ?Sized; #[doc(hidden)] - fn __as_raw_receiver(self) -> *mut Object; + fn __as_raw_receiver(self) -> *mut AnyObject; /// Sends a message to the receiver with the given selector and arguments. /// @@ -257,7 +257,7 @@ pub unsafe trait MessageReceiver: private::Sealed + Sized { /// [`msg_send!(super(...), ...)`]: crate::msg_send #[inline] #[track_caller] - unsafe fn send_super_message(self, superclass: &Class, sel: Sel, args: A) -> R + unsafe fn send_super_message(self, superclass: &AnyClass, sel: Sel, args: A) -> R where A: MessageArguments, R: EncodeConvertReturn, @@ -321,7 +321,7 @@ pub unsafe trait MessageReceiver: private::Sealed + Sized { #[doc(hidden)] unsafe fn __send_super_message_error( self, - superclass: &Class, + superclass: &AnyClass, sel: Sel, args: A, ) -> Result<(), Id> @@ -379,7 +379,7 @@ unsafe impl MessageReceiver for *const T { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { (self as *mut T).cast() } } @@ -389,7 +389,7 @@ unsafe impl MessageReceiver for *mut T { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { self.cast() } } @@ -399,7 +399,7 @@ unsafe impl MessageReceiver for NonNull { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { self.as_ptr().cast() } } @@ -409,7 +409,7 @@ unsafe impl<'a, T: ?Sized + Message> MessageReceiver for &'a T { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { let ptr: *const T = self; (ptr as *mut T).cast() } @@ -422,7 +422,7 @@ unsafe impl<'a, T: ?Sized + Message> MessageReceiver for &'a mut T { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { let ptr: *mut T = self; ptr.cast() } @@ -433,7 +433,7 @@ unsafe impl<'a, T: ?Sized + Message> MessageReceiver for &'a Id { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { (Id::as_ptr(self) as *mut T).cast() } } @@ -443,7 +443,7 @@ unsafe impl<'a, T: ?Sized + IsMutable> MessageReceiver for &'a mut Id { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { Id::as_mut_ptr(self).cast() } } @@ -453,29 +453,29 @@ unsafe impl MessageReceiver for ManuallyDrop> { type __Inner = T; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { Id::consume_as_ptr(self).cast() } } -impl private::Sealed for *const Class {} -unsafe impl MessageReceiver for *const Class { - type __Inner = Class; +impl private::Sealed for *const AnyClass {} +unsafe impl MessageReceiver for *const AnyClass { + type __Inner = AnyClass; #[inline] - fn __as_raw_receiver(self) -> *mut Object { - (self as *mut Class).cast() + fn __as_raw_receiver(self) -> *mut AnyObject { + (self as *mut AnyClass).cast() } } -impl<'a> private::Sealed for &'a Class {} -unsafe impl<'a> MessageReceiver for &'a Class { - type __Inner = Class; +impl<'a> private::Sealed for &'a AnyClass {} +unsafe impl<'a> MessageReceiver for &'a AnyClass { + type __Inner = AnyClass; #[inline] - fn __as_raw_receiver(self) -> *mut Object { - let ptr: *const Class = self; - (ptr as *mut Class).cast() + fn __as_raw_receiver(self) -> *mut AnyObject { + let ptr: *const AnyClass = self; + (ptr as *mut AnyClass).cast() } } @@ -496,7 +496,7 @@ pub unsafe trait MessageArguments: EncodeArguments { /// be called directly; instead, use the `msg_send!` macro or, in cases /// with a dynamic selector, the [`MessageReceiver::send_message`] method. #[doc(hidden)] - unsafe fn __invoke(imp: Imp, obj: *mut Object, sel: Sel, args: Self) -> R; + unsafe fn __invoke(imp: Imp, obj: *mut AnyObject, sel: Sel, args: Self) -> R; } pub trait __TupleExtender { @@ -510,7 +510,7 @@ macro_rules! message_args_impl { ($($a:ident: $t:ident),*) => ( unsafe impl<$($t: EncodeConvertArgument),*> MessageArguments for ($($t,)*) { #[inline] - unsafe fn __invoke(imp: Imp, obj: *mut Object, sel: Sel, ($($a,)*): Self) -> R { + unsafe fn __invoke(imp: Imp, obj: *mut AnyObject, sel: Sel, ($($a,)*): Self) -> R { $(let $a = EncodeConvertArgument::__into_argument($a);)* // The imp must be cast to the appropriate function pointer @@ -518,11 +518,11 @@ macro_rules! message_args_impl { // parametric, but instead "trampolines" to the actual // method implementations. #[cfg(not(feature = "unstable-c-unwind"))] - let imp: unsafe extern "C" fn(*mut Object, Sel $(, $t::__Inner)*) -> R = unsafe { + let imp: unsafe extern "C" fn(*mut AnyObject, Sel $(, $t::__Inner)*) -> R = unsafe { mem::transmute(imp) }; #[cfg(feature = "unstable-c-unwind")] - let imp: unsafe extern "C-unwind" fn(*mut Object, Sel $(, $t::__Inner)*) -> R = unsafe { + let imp: unsafe extern "C-unwind" fn(*mut AnyObject, Sel $(, $t::__Inner)*) -> R = unsafe { mem::transmute(imp) }; // TODO: On x86_64 it would be more efficient to use a GOT @@ -722,10 +722,10 @@ mod tests { #[test] #[cfg_attr(debug_assertions, should_panic = "messsaging description to nil")] fn test_send_message_nil() { - let nil: *mut Object = ::core::ptr::null_mut(); + let nil: *mut NSObject = ::core::ptr::null_mut(); // This result should not be relied on - let result: Option> = unsafe { msg_send_id![nil, description] }; + let result: Option> = unsafe { msg_send_id![nil, description] }; assert!(result.is_none()); // This result should not be relied on @@ -742,12 +742,12 @@ mod tests { assert_eq!(result, 0.0); // This result should not be relied on - let result: Option> = + let result: Option> = unsafe { msg_send_id![nil, multiple: 1u32, arguments: 2i8] }; assert!(result.is_none()); // This result should not be relied on - let result: Option> = unsafe { msg_send_id![None, init] }; + let result: Option> = unsafe { msg_send_id![None, init] }; assert!(result.is_none()); } diff --git a/crates/objc2/src/protocol_type.rs b/crates/objc2/src/protocol_type.rs index c88f82240..11c8c8b42 100644 --- a/crates/objc2/src/protocol_type.rs +++ b/crates/objc2/src/protocol_type.rs @@ -1,4 +1,4 @@ -use crate::runtime::Protocol; +use crate::runtime::AnyProtocol; /// Marks types that represent specific protocols. /// @@ -19,7 +19,7 @@ use crate::runtime::Protocol; /// /// # Examples /// -/// Use the trait to access the [`Protocol`] of different objects. +/// Use the trait to access the [`AnyProtocol`] of different objects. /// /// ``` /// use objc2::ProtocolType; @@ -62,8 +62,8 @@ pub unsafe trait ProtocolType { /// This may panic if something went wrong with getting or declaring the /// protocol, e.g. if the program is not properly linked to the framework /// that defines the protocol. - fn protocol() -> Option<&'static Protocol> { - Protocol::get(Self::NAME) + fn protocol() -> Option<&'static AnyProtocol> { + AnyProtocol::get(Self::NAME) } #[doc(hidden)] diff --git a/crates/objc2/src/rc/autorelease.rs b/crates/objc2/src/rc/autorelease.rs index d38b9c325..6c41a36af 100644 --- a/crates/objc2/src/rc/autorelease.rs +++ b/crates/objc2/src/rc/autorelease.rs @@ -525,7 +525,7 @@ mod tests { use static_assertions::{assert_impl_all, assert_not_impl_any}; use super::{AutoreleasePool, AutoreleaseSafe}; - use crate::runtime::Object; + use crate::runtime::AnyObject; #[test] fn auto_traits() { @@ -533,8 +533,8 @@ mod tests { assert_not_impl_any!(AutoreleasePool<'static>: Send, Sync); assert_impl_all!(usize: AutoreleaseSafe); - assert_impl_all!(*mut Object: AutoreleaseSafe); - assert_impl_all!(&mut Object: AutoreleaseSafe); + assert_impl_all!(*mut AnyObject: AutoreleaseSafe); + assert_impl_all!(&mut AnyObject: AutoreleaseSafe); #[cfg(feature = "unstable-autoreleasesafe")] assert_not_impl_any!(AutoreleasePool<'static>: AutoreleaseSafe); } diff --git a/crates/objc2/src/rc/id.rs b/crates/objc2/src/rc/id.rs index d4c533554..563d5acc0 100644 --- a/crates/objc2/src/rc/id.rs +++ b/crates/objc2/src/rc/id.rs @@ -256,10 +256,10 @@ impl Id { /// a specific class (e.g. casting an instance of `NSString` to `NSObject` /// is safe because `NSString` is a subclass of `NSObject`). /// - /// All `'static` objects can safely be cast to [`Object`], since that + /// All `'static` objects can safely be cast to [`AnyObject`], since that /// assumes no specific class. /// - /// [`Object`]: crate::runtime::Object + /// [`AnyObject`]: crate::runtime::AnyObject /// [`ProtocolObject::from_id`]: crate::runtime::ProtocolObject::from_id /// /// @@ -558,12 +558,12 @@ impl Id { /// use objc2::{class, msg_send_id, sel}; /// use objc2::declare::ClassBuilder; /// use objc2::rc::Id; - /// use objc2::runtime::{Class, Object, Sel}; + /// use objc2::runtime::{AnyClass, AnyObject, Sel}; /// /// let mut builder = ClassBuilder::new("ExampleObject", class!(NSObject)).unwrap(); /// - /// extern "C" fn get(cls: &Class, _cmd: Sel) -> *mut Object { - /// let obj: Id = unsafe { msg_send_id![cls, new] }; + /// extern "C" fn get(cls: &AnyClass, _cmd: Sel) -> *mut AnyObject { + /// let obj: Id = unsafe { msg_send_id![cls, new] }; /// Id::autorelease_return(obj) /// } /// @@ -685,11 +685,11 @@ impl fmt::Pointer for Id { } mod private { - use crate::runtime::Object; + use crate::runtime::AnyObject; use crate::ClassType; use core::panic::{RefUnwindSafe, UnwindSafe}; - pub struct UnknownStorage(*const T, Object); + pub struct UnknownStorage(*const T, AnyObject); pub struct ArcLikeStorage(*const T); // SAFETY: Same as `Arc` @@ -812,7 +812,7 @@ mod tests { use super::*; use crate::mutability::{Immutable, Mutable}; use crate::rc::{__RcTestObject, __ThreadTestData, autoreleasepool}; - use crate::runtime::{NSObject, Object}; + use crate::runtime::{AnyObject, NSObject}; use crate::{declare_class, msg_send}; #[test] @@ -849,8 +849,8 @@ mod tests { unsafe impl Send for MutableSendSyncObject {} unsafe impl Sync for MutableSendSyncObject {} - assert_impl_all!(Id: Unpin); - assert_not_impl_any!(Id: Send, Sync, UnwindSafe, RefUnwindSafe); + assert_impl_all!(Id: Unpin); + assert_not_impl_any!(Id: Send, Sync, UnwindSafe, RefUnwindSafe); assert_not_impl_any!(Id: Send, Sync); assert_not_impl_any!(Id: Send, Sync); @@ -866,7 +866,7 @@ mod tests { } #[track_caller] - fn assert_retain_count(obj: &Object, expected: usize) { + fn assert_retain_count(obj: &AnyObject, expected: usize) { let retain_count: usize = unsafe { msg_send![obj, retainCount] }; assert_eq!(retain_count, expected); } @@ -954,8 +954,8 @@ mod tests { let obj: Id<__RcTestObject> = __RcTestObject::new(); let expected = __ThreadTestData::current(); - // SAFETY: Any object can be cast to `Object` - let obj: Id = unsafe { Id::cast(obj) }; + // SAFETY: Any object can be cast to `AnyObject` + let obj: Id = unsafe { Id::cast(obj) }; expected.assert_current(); // SAFETY: The object was originally `__RcTestObject` diff --git a/crates/objc2/src/runtime/mod.rs b/crates/objc2/src/runtime/mod.rs index 42e015d7c..ad39e7941 100644 --- a/crates/objc2/src/runtime/mod.rs +++ b/crates/objc2/src/runtime/mod.rs @@ -291,7 +291,7 @@ impl fmt::Pointer for Sel { #[doc(alias = "objc_ivar")] pub struct Ivar(ffi::objc_ivar); -// SAFETY: Ivar is immutable (and can be retrieved from Class anyhow). +// SAFETY: Ivar is immutable (and can be retrieved from AnyClass anyhow). unsafe impl Sync for Ivar {} unsafe impl Send for Ivar {} impl UnwindSafe for Ivar {} @@ -372,7 +372,7 @@ impl MethodDescription { #[doc(alias = "objc_method")] pub struct Method(ffi::objc_method); -// SAFETY: Method is immutable (and can be retrieved from Class anyhow). +// SAFETY: Method is immutable (and can be retrieved from AnyClass anyhow). unsafe impl Sync for Method {} unsafe impl Send for Method {} impl UnwindSafe for Method {} @@ -549,25 +549,29 @@ impl fmt::Debug for Method { /// A type that represents an Objective-C class. /// /// This is an opaque type meant to be used behind a shared reference -/// `&Class`, which is semantically equivalent to `Class _Nonnull`. +/// `&AnyClass`, which is semantically equivalent to `Class _Nonnull`. /// -/// A nullable class can be used as `Option<&Class>`. +/// A nullable class can be used as `Option<&AnyClass>`. /// /// See [Apple's documentation](https://developer.apple.com/documentation/objectivec/class?language=objc). #[repr(C)] -#[doc(alias = "AnyClass")] +#[doc(alias = "Class")] #[doc(alias = "objc_class")] -pub struct Class(ffi::objc_class); - -// SAFETY: Class is immutable (and can be retrieved from any thread using the -// `class!` macro). -unsafe impl Sync for Class {} -unsafe impl Send for Class {} -impl UnwindSafe for Class {} -impl RefUnwindSafe for Class {} +pub struct AnyClass(ffi::objc_class); + +/// Use [`AnyClass`] instead. +#[deprecated = "renamed to `runtime::AnyClass`"] +pub type Class = AnyClass; + +// SAFETY: AnyClass is immutable (and can be retrieved from any thread using +// the `class!` macro). +unsafe impl Sync for AnyClass {} +unsafe impl Send for AnyClass {} +impl UnwindSafe for AnyClass {} +impl RefUnwindSafe for AnyClass {} // Note that Unpin is not applicable. -impl Class { +impl AnyClass { pub(crate) fn as_ptr(&self) -> *const ffi::objc_class { let ptr: *const Self = self; ptr.cast() @@ -632,10 +636,10 @@ impl Class { /// 1. The class pointer must be valid. /// 2. The caller must bound the lifetime of the returned class. #[inline] - pub(crate) unsafe fn superclass_raw<'a>(ptr: *const ffi::objc_class) -> Option<&'a Class> { + pub(crate) unsafe fn superclass_raw<'a>(ptr: *const ffi::objc_class) -> Option<&'a AnyClass> { // SAFETY: Caller ensures that the pointer is valid let superclass = unsafe { ffi::class_getSuperclass(ptr) }; - let superclass: *const Class = superclass.cast(); + let superclass: *const AnyClass = superclass.cast(); // SAFETY: The result is properly bounded by the caller. unsafe { superclass.as_ref() } } @@ -643,7 +647,7 @@ impl Class { /// Returns the superclass of self, or [`None`] if self is a root class. #[inline] #[doc(alias = "class_getSuperclass")] - pub fn superclass(&self) -> Option<&Class> { + pub fn superclass(&self) -> Option<&AnyClass> { // SAFETY: The pointer is valid, and the return is properly bounded unsafe { Self::superclass_raw(self.as_ptr()) } } @@ -656,7 +660,7 @@ impl Class { unsafe { ptr.as_ref().unwrap_unchecked() } } - // objc_getMetaClass -> Same as `Class::get(name).metaclass()` + // objc_getMetaClass -> Same as `AnyClass::get(name).metaclass()` #[allow(unused)] pub(crate) fn is_metaclass(&self) -> bool { @@ -740,7 +744,7 @@ impl Class { /// Checks whether this class conforms to the specified protocol. #[doc(alias = "class_conformsToProtocol")] - pub fn conforms_to(&self, proto: &Protocol) -> bool { + pub fn conforms_to(&self, proto: &AnyProtocol) -> bool { unsafe { Bool::from_raw(ffi::class_conformsToProtocol(self.as_ptr(), proto.as_ptr())).as_bool() } @@ -749,10 +753,10 @@ impl Class { /// Get a list of the protocols to which this class conforms. #[cfg(feature = "malloc")] #[doc(alias = "class_copyProtocolList")] - pub fn adopted_protocols(&self) -> Malloc<[&Protocol]> { + pub fn adopted_protocols(&self) -> Malloc<[&AnyProtocol]> { unsafe { let mut count: c_uint = 0; - let protos: *mut &Protocol = + let protos: *mut &AnyProtocol = ffi::class_copyProtocolList(self.as_ptr(), &mut count).cast(); Malloc::from_array(protos, count as usize) } @@ -809,14 +813,14 @@ impl Class { /// /// ``` /// # use objc2::{class, sel}; - /// # use objc2::runtime::Class; + /// # use objc2::runtime::AnyClass; /// let cls = class!(NSObject); /// let sel = sel!(isKindOfClass:); /// // Verify that `isKindOfClass:`: /// // - Exists on the class /// // - Takes a class as a parameter /// // - Returns a BOOL - /// let result = cls.verify_sel::<(&Class,), bool>(sel); + /// let result = cls.verify_sel::<(&AnyClass,), bool>(sel); /// assert!(result.is_ok()); /// ``` pub fn verify_sel(&self, sel: Sel) -> Result<(), VerificationError> @@ -829,21 +833,21 @@ impl Class { } } -standard_pointer_impls!(Class); +standard_pointer_impls!(AnyClass); -unsafe impl RefEncode for Class { +unsafe impl RefEncode for AnyClass { const ENCODING_REF: Encoding = Encoding::Class; } -impl fmt::Debug for Class { +impl fmt::Debug for AnyClass { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Class") + f.debug_struct("AnyClass") .field("name", &self.name()) .finish_non_exhaustive() } } -impl fmt::Display for Class { +impl fmt::Display for AnyClass { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self.name(), f) } @@ -851,18 +855,21 @@ impl fmt::Display for Class { /// A type that represents an Objective-C protocol. #[repr(C)] -#[doc(alias = "AnyProtocol")] #[doc(alias = "objc_protocol")] -pub struct Protocol(ffi::objc_protocol); +pub struct AnyProtocol(ffi::objc_protocol); -// SAFETY: Protocol is immutable (and can be retrieved from Class anyhow). -unsafe impl Sync for Protocol {} -unsafe impl Send for Protocol {} -impl UnwindSafe for Protocol {} -impl RefUnwindSafe for Protocol {} +/// Use [`AnyProtocol`] instead. +#[deprecated = "renamed to `runtime::AnyProtocol`"] +pub type Protocol = AnyProtocol; + +// SAFETY: AnyProtocol is immutable (and can be retrieved from AnyClass anyhow). +unsafe impl Sync for AnyProtocol {} +unsafe impl Send for AnyProtocol {} +impl UnwindSafe for AnyProtocol {} +impl RefUnwindSafe for AnyProtocol {} // Note that Unpin is not applicable. -impl Protocol { +impl AnyProtocol { pub(crate) fn as_ptr(&self) -> *const ffi::objc_protocol { let ptr: *const Self = self; ptr.cast() @@ -871,7 +878,7 @@ impl Protocol { /// Returns the protocol definition of a specified protocol, or [`None`] /// if the protocol is not registered with the Objective-C runtime. #[doc(alias = "objc_getProtocol")] - pub fn get(name: &str) -> Option<&'static Protocol> { + pub fn get(name: &str) -> Option<&'static Self> { let name = CString::new(name).unwrap(); unsafe { let proto = ffi::objc_getProtocol(name.as_ptr()); @@ -882,10 +889,10 @@ impl Protocol { /// Obtains the list of registered protocol definitions. #[cfg(feature = "malloc")] #[doc(alias = "objc_copyProtocolList")] - pub fn protocols() -> Malloc<[&'static Protocol]> { + pub fn protocols() -> Malloc<[&'static Self]> { unsafe { let mut count: c_uint = 0; - let protocols: *mut &Protocol = ffi::objc_copyProtocolList(&mut count).cast(); + let protocols: *mut &Self = ffi::objc_copyProtocolList(&mut count).cast(); Malloc::from_array(protocols, count as usize) } } @@ -893,10 +900,10 @@ impl Protocol { /// Get a list of the protocols to which this protocol conforms. #[cfg(feature = "malloc")] #[doc(alias = "protocol_copyProtocolList")] - pub fn adopted_protocols(&self) -> Malloc<[&Protocol]> { + pub fn adopted_protocols(&self) -> Malloc<[&AnyProtocol]> { unsafe { let mut count: c_uint = 0; - let protocols: *mut &Protocol = + let protocols: *mut &Self = ffi::protocol_copyProtocolList(self.as_ptr(), &mut count).cast(); Malloc::from_array(protocols, count as usize) } @@ -904,7 +911,7 @@ impl Protocol { /// Checks whether this protocol conforms to the specified protocol. #[doc(alias = "protocol_conformsToProtocol")] - pub fn conforms_to(&self, proto: &Protocol) -> bool { + pub fn conforms_to(&self, proto: &AnyProtocol) -> bool { unsafe { Bool::from_raw(ffi::protocol_conformsToProtocol( self.as_ptr(), @@ -959,39 +966,39 @@ impl Protocol { } } -impl PartialEq for Protocol { +impl PartialEq for AnyProtocol { /// Check whether the protocols are equal, or conform to each other. #[inline] #[doc(alias = "protocol_isEqual")] - fn eq(&self, other: &Protocol) -> bool { + fn eq(&self, other: &Self) -> bool { unsafe { Bool::from_raw(ffi::protocol_isEqual(self.as_ptr(), other.as_ptr())).as_bool() } } } -impl Eq for Protocol {} +impl Eq for AnyProtocol {} // Don't implement `Hash` for protocol, it is unclear how that would work -unsafe impl RefEncode for Protocol { - // Protocol is an object internally +unsafe impl RefEncode for AnyProtocol { + // Protocols are objects internally. const ENCODING_REF: Encoding = Encoding::Object; } -impl fmt::Debug for Protocol { +impl fmt::Debug for AnyProtocol { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - f.debug_struct("Protocol") + f.debug_struct("AnyProtocol") .field("name", &self.name()) .finish_non_exhaustive() } } -impl fmt::Display for Protocol { +impl fmt::Display for AnyProtocol { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(self.name(), f) } } -pub(crate) fn ivar_offset(cls: &Class, name: &str, expected: &Encoding) -> isize { +pub(crate) fn ivar_offset(cls: &AnyClass, name: &str, expected: &Encoding) -> isize { match cls.instance_variable(name) { Some(ivar) => { let encoding = ivar.type_encoding(); @@ -1012,7 +1019,7 @@ pub(crate) fn ivar_offset(cls: &Class, name: &str, expected: &Encoding) -> isize /// a subclass of `NSObject`, so it can represent other root classes like /// `NSProxy`). /// -/// `Id` is equivalent to Objective-C's `id _Nonnull`. +/// `Id` is equivalent to Objective-C's `id _Nonnull`. /// /// This contains [`UnsafeCell`], and is similar to that in that one can /// safely access and perform interior mutability on this (both via. @@ -1031,18 +1038,22 @@ pub(crate) fn ivar_offset(cls: &Class, name: &str, expected: &Encoding) -> isize /// [`msg_send!`]: crate::msg_send #[doc(alias = "id")] #[repr(C)] -pub struct Object(ffi::objc_object); +pub struct AnyObject(ffi::objc_object); -unsafe impl RefEncode for Object { +/// Use [`AnyObject`] instead. +#[deprecated = "renamed to `runtime::AnyObject`. Consider using the correct type from `icrate` instead though"] +pub type Object = AnyObject; + +unsafe impl RefEncode for AnyObject { const ENCODING_REF: Encoding = Encoding::Object; } // SAFETY: This is technically slightly wrong, not all objects implement the // standard memory management methods. But not having this impl would be too // restrictive, so we'll live with it. -unsafe impl Message for Object {} +unsafe impl Message for AnyObject {} -impl Object { +impl AnyObject { pub(crate) fn as_ptr(&self) -> *const ffi::objc_object { let ptr: *const Self = self; ptr.cast() @@ -1050,8 +1061,8 @@ impl Object { /// Dynamically find the class of this object. #[doc(alias = "object_getClass")] - pub fn class(&self) -> &Class { - let ptr: *const Class = unsafe { ffi::object_getClass(self.as_ptr()) }.cast(); + pub fn class(&self) -> &AnyClass { + let ptr: *const AnyClass = unsafe { ffi::object_getClass(self.as_ptr()) }.cast(); // SAFETY: The class is not NULL because the object is not NULL. unsafe { ptr.as_ref().unwrap_unchecked() } } @@ -1083,10 +1094,10 @@ impl Object { /// panic. #[inline] #[doc(alias = "object_setClass")] - pub unsafe fn set_class<'s>(this: &Self, cls: &Class) -> &'s Class { + pub unsafe fn set_class<'s>(this: &Self, cls: &AnyClass) -> &'s AnyClass { let ptr = unsafe { ffi::object_setClass(this.as_ptr() as *mut ffi::objc_object, cls.as_ptr()) }; - let ptr: *const Class = ptr.cast(); + let ptr: *const AnyClass = ptr.cast(); // SAFETY: The class is not NULL because the object is not NULL. let old_cls = unsafe { ptr.as_ref().unwrap_unchecked() }; // TODO: Check the superclass requirement too? @@ -1170,8 +1181,8 @@ impl Object { /// Returns a reference to the instance variable with the given name. /// - /// See [`Object::ivar_ptr`] for more information, including on when this - /// panics. + /// See [`AnyObject::ivar_ptr`] for more information, including on when + /// this panics. /// /// /// # Safety @@ -1181,20 +1192,20 @@ impl Object { /// /// No thread syncronization is done, so you must ensure that no other /// thread is concurrently mutating the variable. This requirement can be - /// considered upheld if all mutation happens through [`Object::ivar_mut`] - /// (since that takes `&mut self`). + /// considered upheld if all mutation happens through + /// [`AnyObject::ivar_mut`] (since that takes `&mut self`). pub unsafe fn ivar(&self, name: &str) -> &T { // SAFETY: Upheld by caller. unsafe { self.ivar_ptr::(name).as_ref().unwrap_unchecked() } } - /// Use [`Object::ivar`] instead. + /// Use [`AnyObject::ivar`] instead. /// /// /// # Safety /// - /// See [`Object::ivar`]. - #[deprecated = "Use `Object::ivar` instead."] + /// See [`AnyObject::ivar`]. + #[deprecated = "Use `AnyObject::ivar` instead."] pub unsafe fn get_ivar(&self, name: &str) -> &T { // SAFETY: Upheld by caller unsafe { self.ivar::(name) } @@ -1202,8 +1213,8 @@ impl Object { /// Returns a mutable reference to the ivar with the given name. /// - /// See [`Object::ivar_ptr`] for more information, including on when this - /// panics. + /// See [`AnyObject::ivar_ptr`] for more information, including on when + /// this panics. /// /// /// # Safety @@ -1225,13 +1236,13 @@ impl Object { unsafe { ptr.as_mut() } } - /// Use [`Object::ivar_mut`] instead. + /// Use [`AnyObject::ivar_mut`] instead. /// /// /// # Safety /// - /// Same as [`Object::ivar_mut`]. - #[deprecated = "Use `Object::ivar_mut` instead."] + /// Same as [`AnyObject::ivar_mut`]. + #[deprecated = "Use `AnyObject::ivar_mut` instead."] pub unsafe fn get_mut_ivar(&mut self, name: &str) -> &mut T { // SAFETY: Upheld by caller unsafe { self.ivar_mut::(name) } @@ -1239,13 +1250,13 @@ impl Object { /// Sets the value of the ivar with the given name. /// - /// This is a shorthand for [`Object::ivar_mut`], see that for more + /// This is a shorthand for [`AnyObject::ivar_mut`], see that for more /// information. /// /// /// # Safety /// - /// Same as [`Object::ivar_mut`]. + /// Same as [`AnyObject::ivar_mut`]. pub unsafe fn set_ivar(&mut self, name: &str, value: T) { // SAFETY: Invariants upheld by caller unsafe { *self.ivar_mut::(name) = value }; @@ -1256,7 +1267,7 @@ impl Object { // objc_removeAssociatedObjects } -impl fmt::Debug for Object { +impl fmt::Debug for AnyObject { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "<{}: {:p}>", self.class().name(), self.as_ptr()) } @@ -1372,7 +1383,7 @@ mod tests { assert!(!cls.responds_to(sel!(abc))); assert!(!cls.responds_to(sel!(addNumber:toNumber:))); - assert_eq!(Class::get(cls.name()), Some(cls)); + assert_eq!(AnyClass::get(cls.name()), Some(cls)); let metaclass = cls.metaclass(); // The metaclass of a root class is a subclass of the root class @@ -1388,13 +1399,13 @@ mod tests { #[test] fn test_classes_count() { - assert!(Class::classes_count() > 0); + assert!(AnyClass::classes_count() > 0); } #[test] #[cfg(feature = "malloc")] fn test_classes() { - let classes = Class::classes(); + let classes = AnyClass::classes(); assert!(classes.len() > 0); } @@ -1453,7 +1464,7 @@ mod tests { let _ = test_utils::custom_protocol(); #[cfg(feature = "malloc")] - assert!(Protocol::protocols().len() > 0); + assert!(AnyProtocol::protocols().len() > 0); } #[test] @@ -1487,24 +1498,24 @@ mod tests { fn assert_enc(expected: &str) { assert_eq!(&T::ENCODING.to_string(), expected); } - assert_enc::<&Object>("@"); - assert_enc::<*mut Object>("@"); - assert_enc::<&Class>("#"); + assert_enc::<&AnyObject>("@"); + assert_enc::<*mut AnyObject>("@"); + assert_enc::<&AnyClass>("#"); assert_enc::(":"); assert_enc::>(":"); assert_enc::("^?"); assert_enc::>("^?"); - assert_enc::<&Protocol>("@"); + assert_enc::<&AnyProtocol>("@"); } #[test] fn test_send_sync() { fn assert_send_sync() {} assert_send_sync::(); - assert_send_sync::(); + assert_send_sync::(); assert_send_sync::(); assert_send_sync::(); - assert_send_sync::(); + assert_send_sync::(); assert_send_sync::(); } @@ -1515,12 +1526,15 @@ mod tests { assert_eq!(format!("{sel:?}"), "Sel(\"abc:\")"); let cls = test_utils::custom_class(); assert_eq!(format!("{cls}"), "CustomObject"); - assert_eq!(format!("{cls:?}"), "Class { name: \"CustomObject\", .. }"); + assert_eq!( + format!("{cls:?}"), + "AnyClass { name: \"CustomObject\", .. }" + ); let protocol = test_utils::custom_protocol(); assert_eq!(format!("{protocol}"), "CustomProtocol"); assert_eq!( format!("{protocol:?}"), - "Protocol { name: \"CustomProtocol\", .. }" + "AnyProtocol { name: \"CustomProtocol\", .. }" ); let object = test_utils::custom_object(); diff --git a/crates/objc2/src/runtime/nsobject.rs b/crates/objc2/src/runtime/nsobject.rs index 64117cee6..3f9848a06 100644 --- a/crates/objc2/src/runtime/nsobject.rs +++ b/crates/objc2/src/runtime/nsobject.rs @@ -3,7 +3,7 @@ use core::hash; use crate::mutability::Root; use crate::rc::{DefaultId, Id}; -use crate::runtime::{Class, ImplementedBy, Object, Protocol, ProtocolObject}; +use crate::runtime::{AnyClass, AnyObject, AnyProtocol, ImplementedBy, ProtocolObject}; use crate::{extern_methods, msg_send, msg_send_id, Message}; use crate::{ClassType, ProtocolType}; @@ -25,13 +25,13 @@ crate::__emit_struct! { (pub) (NSObject) ( - __inner: Object, + __inner: AnyObject, ) } crate::__extern_class_impl_traits! { unsafe impl () for NSObject { - INHERITS = [Object]; + INHERITS = [AnyObject]; fn as_super(&self) { &self.__inner @@ -44,12 +44,12 @@ crate::__extern_class_impl_traits! { } unsafe impl ClassType for NSObject { - type Super = Object; + type Super = AnyObject; type Mutability = Root; const NAME: &'static str = "NSObject"; #[inline] - fn class() -> &'static Class { + fn class() -> &'static AnyClass { #[cfg(feature = "apple")] { crate::class!(NSObject) @@ -60,7 +60,7 @@ unsafe impl ClassType for NSObject { // The linking changed in libobjc2 v2.0 #[cfg_attr(feature = "gnustep-2-0", link_name = "._OBJC_CLASS_NSObject")] #[cfg_attr(not(feature = "gnustep-2-0"), link_name = "_OBJC_CLASS_NSObject")] - static OBJC_CLASS_NSObject: Class; + static OBJC_CLASS_NSObject: AnyClass; // Others: // __objc_class_name_NSObject // _OBJC_CLASS_REF_NSObject @@ -127,7 +127,7 @@ pub unsafe trait NSObjectProtocol { } #[doc(hidden)] - fn __isKindOfClass(&self, cls: &Class) -> bool + fn __isKindOfClass(&self, cls: &AnyClass) -> bool where Self: Sized + Message, { @@ -169,8 +169,11 @@ unsafe impl NSObjectProtocol for NSObject {} unsafe impl ProtocolType for NSObject { const NAME: &'static str = "NSObject"; - fn protocol() -> Option<&'static Protocol> { - Some(Protocol::get(::NAME).expect("could not find NSObject protocol")) + fn protocol() -> Option<&'static AnyProtocol> { + Some( + AnyProtocol::get(::NAME) + .expect("could not find NSObject protocol"), + ) } const __INNER: () = (); @@ -269,7 +272,7 @@ mod tests { fn test_deref() { let obj: Id = NSObject::new(); let _: &NSObject = &obj; - let _: &Object = &obj; + let _: &AnyObject = &obj; } #[test] @@ -279,8 +282,8 @@ mod tests { let _: &mut NSObjectMutable = &mut obj; let _: &NSObject = &obj; let _: &mut NSObject = &mut obj; - let _: &Object = &obj; - let _: &mut Object = &mut obj; + let _: &AnyObject = &obj; + let _: &mut AnyObject = &mut obj; } #[test] @@ -297,13 +300,13 @@ mod tests { impls_as_mut::(&mut obj); impls_as_ref::(&obj); impls_as_mut::(&mut obj); - impls_as_ref::(&obj); - impls_as_mut::(&mut obj); + impls_as_ref::(&obj); + impls_as_mut::(&mut obj); let obj = NSObject::new(); impls_as_ref::, NSObject>(&obj); impls_as_ref::(&obj); - impls_as_ref::(&obj); + impls_as_ref::(&obj); } #[test] diff --git a/crates/objc2/src/runtime/nsproxy.rs b/crates/objc2/src/runtime/nsproxy.rs index 658d0d6a1..cc35ab290 100644 --- a/crates/objc2/src/runtime/nsproxy.rs +++ b/crates/objc2/src/runtime/nsproxy.rs @@ -2,7 +2,7 @@ use core::fmt; use core::hash; use crate::mutability::Root; -use crate::runtime::{Class, NSObject, NSObjectProtocol, Object, ProtocolObject}; +use crate::runtime::{AnyClass, AnyObject, NSObject, NSObjectProtocol, ProtocolObject}; use crate::ClassType; crate::__emit_struct! { @@ -17,13 +17,13 @@ crate::__emit_struct! { (pub) (NSProxy) ( - __inner: Object, + __inner: AnyObject, ) } crate::__extern_class_impl_traits! { unsafe impl () for NSProxy { - INHERITS = [Object]; + INHERITS = [AnyObject]; fn as_super(&self) { &self.__inner @@ -36,12 +36,12 @@ crate::__extern_class_impl_traits! { } unsafe impl ClassType for NSProxy { - type Super = Object; + type Super = AnyObject; type Mutability = Root; const NAME: &'static str = "NSProxy"; #[inline] - fn class() -> &'static Class { + fn class() -> &'static AnyClass { #[cfg(feature = "apple")] { crate::class!(NSProxy) @@ -52,7 +52,7 @@ unsafe impl ClassType for NSProxy { // The linking changed in libobjc2 v2.0 #[cfg_attr(feature = "gnustep-2-0", link_name = "._OBJC_CLASS_NSProxy")] #[cfg_attr(not(feature = "gnustep-2-0"), link_name = "_OBJC_CLASS_NSProxy")] - static OBJC_CLASS_NSProxy: Class; + static OBJC_CLASS_NSProxy: AnyClass; // Others: // __objc_class_name_NSProxy // _OBJC_CLASS_REF_NSProxy diff --git a/crates/objc2/src/runtime/protocol_object.rs b/crates/objc2/src/runtime/protocol_object.rs index e99497d46..7b4f6688e 100644 --- a/crates/objc2/src/runtime/protocol_object.rs +++ b/crates/objc2/src/runtime/protocol_object.rs @@ -6,7 +6,7 @@ use core::ptr::NonNull; use crate::encode::{Encoding, RefEncode}; use crate::rc::{autoreleasepool_leaking, Id}; use crate::runtime::__nsstring::nsstring_to_str; -use crate::runtime::{NSObjectProtocol, Object}; +use crate::runtime::{AnyObject, NSObjectProtocol}; use crate::{Message, ProtocolType}; /// An internal helper trait for [`ProtocolObject`]. @@ -58,17 +58,17 @@ pub unsafe trait ImplementedBy { #[doc(alias = "id")] #[repr(C)] pub struct ProtocolObject { - inner: Object, + inner: AnyObject, p: PhantomData

, } -// SAFETY: The type is `#[repr(C)]` and `Object` internally +// SAFETY: The type is `#[repr(C)]` and `AnyObject` internally unsafe impl RefEncode for ProtocolObject

{ const ENCODING_REF: Encoding = Encoding::Object; } -// SAFETY: The type is `Object` internally, and is mean to be messaged as-if -// it's an object. +// SAFETY: The type is `AnyObject` internally, and is mean to be messaged +// as-if it's an object. unsafe impl Message for ProtocolObject

{} impl ProtocolObject

{ @@ -154,9 +154,10 @@ impl fmt::Debug for ProtocolObject< fmt::Display::fmt(s, f) }) } - // If description was `NULL`, use `Object`'s `Debug` impl instead + // If description was `NULL`, use `AnyObject`'s `Debug` impl + // instead None => { - let obj: &Object = &self.inner; + let obj: &AnyObject = &self.inner; fmt::Debug::fmt(obj, f) } } diff --git a/crates/objc2/src/test_utils.rs b/crates/objc2/src/test_utils.rs index 82ff56fd8..5d24d8ad5 100644 --- a/crates/objc2/src/test_utils.rs +++ b/crates/objc2/src/test_utils.rs @@ -4,18 +4,18 @@ use std::os::raw::c_char; use std::sync::Once; use crate::declare::{ClassBuilder, ProtocolBuilder}; -use crate::runtime::{Class, Object, Protocol, Sel}; +use crate::runtime::{AnyClass, AnyObject, AnyProtocol, Sel}; use crate::{ffi, Encode, Encoding, MessageReceiver}; use crate::{msg_send, sel}; #[derive(Debug)] pub(crate) struct CustomObject { - obj: *mut Object, + obj: *mut AnyObject, } impl CustomObject { - fn new(class: &Class) -> Self { - let ptr: *const Class = class; + fn new(class: &AnyClass) -> Self { + let ptr: *const AnyClass = class; let obj = unsafe { ffi::class_createInstance(ptr.cast(), 0) }.cast(); CustomObject { obj } } @@ -27,42 +27,42 @@ impl crate::message::private::Sealed for &mut CustomObject {} impl crate::message::private::Sealed for ManuallyDrop {} unsafe impl MessageReceiver for &CustomObject { - type __Inner = Object; + type __Inner = AnyObject; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { self.obj } } unsafe impl MessageReceiver for &mut CustomObject { - type __Inner = Object; + type __Inner = AnyObject; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { self.obj } } unsafe impl MessageReceiver for ManuallyDrop { - type __Inner = Object; + type __Inner = AnyObject; #[inline] - fn __as_raw_receiver(self) -> *mut Object { + fn __as_raw_receiver(self) -> *mut AnyObject { self.obj } } impl Deref for CustomObject { - type Target = Object; + type Target = AnyObject; - fn deref(&self) -> &Object { + fn deref(&self) -> &AnyObject { unsafe { self.obj.as_ref().unwrap_unchecked() } } } impl DerefMut for CustomObject { - fn deref_mut(&mut self) -> &mut Object { + fn deref_mut(&mut self) -> &mut AnyObject { unsafe { self.obj.as_mut().unwrap_unchecked() } } } @@ -92,12 +92,12 @@ unsafe impl Encode for CustomStruct { ); } -pub(crate) fn custom_class() -> &'static Class { +pub(crate) fn custom_class() -> &'static AnyClass { static REGISTER_CUSTOM_CLASS: Once = Once::new(); REGISTER_CUSTOM_CLASS.call_once(|| { // The runtime will call this method, so it has to be implemented - extern "C" fn custom_obj_class_initialize(_this: &Class, _cmd: Sel) {} + extern "C" fn custom_obj_class_initialize(_this: &AnyClass, _cmd: Sel) {} let mut builder = ClassBuilder::root( "CustomObject", @@ -109,24 +109,24 @@ pub(crate) fn custom_class() -> &'static Class { builder.add_protocol(proto); builder.add_ivar::("_foo"); - unsafe extern "C" fn custom_obj_release(this: *mut Object, _cmd: Sel) { + unsafe extern "C" fn custom_obj_release(this: *mut AnyObject, _cmd: Sel) { // Drop the value let _ = CustomObject { obj: this }; } - extern "C" fn custom_obj_set_foo(this: &mut Object, _cmd: Sel, foo: u32) { + extern "C" fn custom_obj_set_foo(this: &mut AnyObject, _cmd: Sel, foo: u32) { unsafe { this.set_ivar::("_foo", foo) } } - extern "C" fn custom_obj_get_foo(this: &Object, _cmd: Sel) -> u32 { + extern "C" fn custom_obj_get_foo(this: &AnyObject, _cmd: Sel) -> u32 { unsafe { *this.ivar::("_foo") } } - extern "C" fn custom_obj_get_foo_reference(this: &Object, _cmd: Sel) -> &u32 { + extern "C" fn custom_obj_get_foo_reference(this: &AnyObject, _cmd: Sel) -> &u32 { unsafe { this.ivar::("_foo") } } - extern "C" fn custom_obj_get_struct(_this: &Object, _cmd: Sel) -> CustomStruct { + extern "C" fn custom_obj_get_struct(_this: &AnyObject, _cmd: Sel) -> CustomStruct { CustomStruct { a: 1, b: 2, @@ -135,18 +135,18 @@ pub(crate) fn custom_class() -> &'static Class { } } - extern "C" fn custom_obj_class_method(_this: &Class, _cmd: Sel) -> u32 { + extern "C" fn custom_obj_class_method(_this: &AnyClass, _cmd: Sel) -> u32 { 7 } - extern "C" fn custom_obj_set_bar(this: &mut Object, _cmd: Sel, bar: u32) { + extern "C" fn custom_obj_set_bar(this: &mut AnyObject, _cmd: Sel, bar: u32) { unsafe { this.set_ivar::("_foo", bar); } } extern "C" fn custom_obj_add_number_to_number( - _this: &Class, + _this: &AnyClass, _cmd: Sel, fst: i32, snd: i32, @@ -155,7 +155,7 @@ pub(crate) fn custom_class() -> &'static Class { } extern "C" fn custom_obj_multiple_colon( - _obj: &Object, + _obj: &AnyObject, _cmd: Sel, arg1: i32, arg2: i32, @@ -166,7 +166,7 @@ pub(crate) fn custom_class() -> &'static Class { } extern "C" fn custom_obj_multiple_colon_class( - _cls: &Class, + _cls: &AnyClass, _cmd: Sel, arg1: i32, arg2: i32, @@ -207,10 +207,10 @@ pub(crate) fn custom_class() -> &'static Class { }); // Can't use `class!` here since `CustomObject` is dynamically created. - Class::get("CustomObject").unwrap() + AnyClass::get("CustomObject").unwrap() } -pub(crate) fn custom_protocol() -> &'static Protocol { +pub(crate) fn custom_protocol() -> &'static AnyProtocol { static REGISTER_CUSTOM_PROTOCOL: Once = Once::new(); REGISTER_CUSTOM_PROTOCOL.call_once(|| { @@ -223,10 +223,10 @@ pub(crate) fn custom_protocol() -> &'static Protocol { builder.register(); }); - Protocol::get("CustomProtocol").unwrap() + AnyProtocol::get("CustomProtocol").unwrap() } -pub(crate) fn custom_subprotocol() -> &'static Protocol { +pub(crate) fn custom_subprotocol() -> &'static AnyProtocol { static REGISTER_CUSTOM_SUBPROTOCOL: Once = Once::new(); REGISTER_CUSTOM_SUBPROTOCOL.call_once(|| { @@ -239,26 +239,26 @@ pub(crate) fn custom_subprotocol() -> &'static Protocol { builder.register(); }); - Protocol::get("CustomSubProtocol").unwrap() + AnyProtocol::get("CustomSubProtocol").unwrap() } pub(crate) fn custom_object() -> CustomObject { CustomObject::new(custom_class()) } -pub(crate) fn custom_subclass() -> &'static Class { +pub(crate) fn custom_subclass() -> &'static AnyClass { static REGISTER_CUSTOM_SUBCLASS: Once = Once::new(); REGISTER_CUSTOM_SUBCLASS.call_once(|| { let superclass = custom_class(); let mut builder = ClassBuilder::new("CustomSubclassObject", superclass).unwrap(); - extern "C" fn custom_subclass_get_foo(this: &Object, _cmd: Sel) -> u32 { + extern "C" fn custom_subclass_get_foo(this: &AnyObject, _cmd: Sel) -> u32 { let foo: u32 = unsafe { msg_send![super(this, custom_class()), foo] }; foo + 2 } - extern "C" fn custom_subclass_class_method(_cls: &Class, _cmd: Sel) -> u32 { + extern "C" fn custom_subclass_class_method(_cls: &AnyClass, _cmd: Sel) -> u32 { 9 } @@ -272,7 +272,7 @@ pub(crate) fn custom_subclass() -> &'static Class { builder.register(); }); - Class::get("CustomSubclassObject").unwrap() + AnyClass::get("CustomSubclassObject").unwrap() } pub(crate) fn custom_subclass_object() -> CustomObject { diff --git a/crates/objc2/src/verify.rs b/crates/objc2/src/verify.rs index 966cb78a1..2c3963f61 100644 --- a/crates/objc2/src/verify.rs +++ b/crates/objc2/src/verify.rs @@ -40,13 +40,13 @@ impl fmt::Display for Inner { /// Failed verifying selector on a class. /// -/// This is returned in the error case of [`Class::verify_sel`], see that for -/// details. +/// This is returned in the error case of [`AnyClass::verify_sel`], see that +/// for details. /// /// This implements [`Error`], and a description of the error can be retrieved /// using [`fmt::Display`]. /// -/// [`Class::verify_sel`]: crate::runtime::Class::verify_sel +/// [`AnyClass::verify_sel`]: crate::runtime::AnyClass::verify_sel #[derive(Debug, PartialEq, Eq, Hash)] pub struct VerificationError(Inner); diff --git a/crates/objc2/tests/no_prelude.rs b/crates/objc2/tests/no_prelude.rs index 827468929..16aa6f777 100644 --- a/crates/objc2/tests/no_prelude.rs +++ b/crates/objc2/tests/no_prelude.rs @@ -162,11 +162,11 @@ pub fn test_msg_send(obj: &CustomObject) { let _: () = unsafe { new_objc2::msg_send![super(obj, superclass), a: obj, b: obj] }; } -pub fn test_msg_send_id(obj: &new_objc2::runtime::Object) { - let _: new_objc2::rc::Id = +pub fn test_msg_send_id(obj: &new_objc2::runtime::AnyObject) { + let _: new_objc2::rc::Id = unsafe { new_objc2::msg_send_id![obj, a] }; - let _: new_objc2::__macro_helpers::Option> = + let _: new_objc2::__macro_helpers::Option> = unsafe { new_objc2::msg_send_id![obj, a] }; - let _: new_objc2::rc::Id = + let _: new_objc2::rc::Id = unsafe { new_objc2::msg_send_id![obj, a: obj, b: obj] }; } diff --git a/crates/objc2/tests/track_caller.rs b/crates/objc2/tests/track_caller.rs index 8d1d2d1ba..0f2b0e060 100644 --- a/crates/objc2/tests/track_caller.rs +++ b/crates/objc2/tests/track_caller.rs @@ -8,7 +8,7 @@ use std::sync::Mutex; use objc2::encode::Encode; use objc2::rc::{Allocated, Id, __RcTestObject}; -use objc2::runtime::{NSObject, Object}; +use objc2::runtime::NSObject; use objc2::{class, declare_class, msg_send, msg_send_id, mutability, ClassType}; static EXPECTED_MESSAGE: Mutex = Mutex::new(String::new()); @@ -88,17 +88,17 @@ fn test_track_caller() { } pub fn test_nil(checker: &PanicChecker) { - let nil: *mut Object = ptr::null_mut(); + let nil: *mut NSObject = ptr::null_mut(); let msg = "messsaging description to nil"; checker.assert_panics(msg, line!() + 1, || { - let _: *mut Object = unsafe { msg_send![nil, description] }; + let _: *mut NSObject = unsafe { msg_send![nil, description] }; }); checker.assert_panics(msg, line!() + 1, || { - let _: *mut Object = unsafe { msg_send![super(nil, NSObject::class()), description] }; + let _: *mut NSObject = unsafe { msg_send![super(nil, NSObject::class()), description] }; }); checker.assert_panics(msg, line!() + 1, || { - let _: Option> = unsafe { msg_send_id![nil, description] }; + let _: Option> = unsafe { msg_send_id![nil, description] }; }); } @@ -112,12 +112,12 @@ pub fn test_verify(checker: &PanicChecker) { let msg = format!("invalid message send to -[NSObject hash]: expected return to have type code '{}', but found '@'", usize::ENCODING); checker.assert_panics(&msg, line!() + 1, || { - let _: Option> = unsafe { msg_send_id![&obj, hash] }; + let _: Option> = unsafe { msg_send_id![&obj, hash] }; }); } pub fn test_error_methods(checker: &PanicChecker) { - let nil: *mut Object = ptr::null_mut(); + let nil: *mut NSObject = ptr::null_mut(); let msg = "messsaging someSelectorWithError: to nil"; checker.assert_panics(msg, line!() + 1, || { @@ -128,7 +128,7 @@ pub fn test_error_methods(checker: &PanicChecker) { unsafe { msg_send![super(nil, NSObject::class()), someSelectorWithError: _] }; }); checker.assert_panics(msg, line!() + 2, || { - let _: Result, Id> = + let _: Result, Id> = unsafe { msg_send_id![nil, someSelectorWithError: _] }; }); @@ -176,12 +176,12 @@ pub fn test_catch_all(checker: &PanicChecker) { let msg = "NSRangeException"; checker.assert_panics(msg, line!() + 1, || { - let _: *mut Object = unsafe { msg_send![&obj, objectAtIndex: 0usize] }; + let _: *mut NSObject = unsafe { msg_send![&obj, objectAtIndex: 0usize] }; }); let msg = "NSRangeException"; checker.assert_panics(msg, line!() + 1, || { - let _: Id = unsafe { msg_send_id![&obj, objectAtIndex: 0usize] }; + let _: Id = unsafe { msg_send_id![&obj, objectAtIndex: 0usize] }; }); } @@ -206,9 +206,9 @@ pub fn test_unwind(checker: &PanicChecker) { let msg = "panic in PanickingClass"; let line = line!() - 7; checker.assert_panics(msg, line, || { - let _: *mut Object = unsafe { msg_send![PanickingClass::class(), panic] }; + let _: *mut NSObject = unsafe { msg_send![PanickingClass::class(), panic] }; }); checker.assert_panics(msg, line, || { - let _: Id = unsafe { msg_send_id![PanickingClass::class(), panic] }; + let _: Id = unsafe { msg_send_id![PanickingClass::class(), panic] }; }); } diff --git a/crates/objc2/tests/use_macros.rs b/crates/objc2/tests/use_macros.rs index 32d149ecf..b3edaceb8 100644 --- a/crates/objc2/tests/use_macros.rs +++ b/crates/objc2/tests/use_macros.rs @@ -1,5 +1,5 @@ use objc2::mutability::Immutable; -use objc2::runtime::{Class, NSObject, Object}; +use objc2::runtime::{AnyClass, NSObject}; use objc2::{class, declare_class, msg_send, sel, ClassType}; declare_class!( @@ -16,7 +16,7 @@ declare_class!( fn use_class_and_msg_send() { unsafe { let cls = class!(NSObject); - let obj: *mut Object = msg_send![cls, new]; + let obj: *mut NSObject = msg_send![cls, new]; let _hash: usize = msg_send![obj, hash]; let _: () = msg_send![obj, release]; } @@ -29,7 +29,7 @@ fn use_sel() { } #[allow(unused)] -fn test_msg_send_comma_handling(obj: &MyObject, superclass: &Class) { +fn test_msg_send_comma_handling(obj: &MyObject, superclass: &AnyClass) { unsafe { let _: () = msg_send![obj, a]; let _: () = msg_send![obj, a,]; diff --git a/crates/test-assembly/crates/test_extern_protocol/expected/apple-aarch64.s b/crates/test-assembly/crates/test_extern_protocol/expected/apple-aarch64.s index 1c8a4e268..031dc612c 100644 --- a/crates/test-assembly/crates/test_extern_protocol/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_extern_protocol/expected/apple-aarch64.s @@ -7,16 +7,16 @@ Lloh0: Lloh1: add x0, x0, l_anon.[ID].0@PAGEOFF mov w1, #10 - b SYM(objc2::runtime::Protocol::get::GENERATED_ID, 0) + b SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) .loh AdrpAdd Lloh0, Lloh1 .globl _dyn_call .p2align 2 _dyn_call: Lloh2: - adrp x8, L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f@PAGE Lloh3: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f@PAGEOFF] b _objc_msgSend .loh AdrpLdr Lloh2, Lloh3 @@ -28,9 +28,9 @@ _dyn_consume: add x29, sp, #16 mov x19, x0 Lloh4: - adrp x8, L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f@PAGE Lloh5: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f@PAGEOFF] bl _objc_msgSend mov x0, x19 ldp x29, x30, [sp, #16] @@ -43,20 +43,20 @@ l_anon.[ID].0: .ascii "MyProtocol" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_d7a070d5c55b8e69 + .globl L_OBJC_IMAGE_INFO_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_d7a070d5c55b8e69: +L_OBJC_IMAGE_INFO_17aa92881c42487f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 -L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69: + .globl L_OBJC_METH_VAR_NAME_17aa92881c42487f +L_OBJC_METH_VAR_NAME_17aa92881c42487f: .asciz "aMethod" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69 + .globl L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69: - .quad L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 +L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f: + .quad L_OBJC_METH_VAR_NAME_17aa92881c42487f .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7.s b/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7.s index 91ac95f02..26e74c448 100644 --- a/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7.s +++ b/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7.s @@ -9,14 +9,14 @@ _get_protocol: movt r0, :upper16:(l_anon.[ID].0-(LPC0_0+8)) LPC0_0: add r0, pc, r0 - b SYM(objc2::runtime::Protocol::get::GENERATED_ID, 0) + b SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) .globl _dyn_call .p2align 2 .code 32 _dyn_call: - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC1_0+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC1_0+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC1_0+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC1_0+8)) LPC1_0: ldr r1, [pc, r1] b _objc_msgSend @@ -27,9 +27,9 @@ LPC1_0: _dyn_consume: push {r4, r7, lr} add r7, sp, #4 - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC2_0+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC2_0+8)) mov r4, r0 - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC2_0+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC2_0+8)) LPC2_0: ldr r1, [pc, r1] bl _objc_msgSend @@ -42,20 +42,20 @@ l_anon.[ID].0: .ascii "MyProtocol" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_d7a070d5c55b8e69 + .globl L_OBJC_IMAGE_INFO_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_d7a070d5c55b8e69: +L_OBJC_IMAGE_INFO_17aa92881c42487f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 -L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69: + .globl L_OBJC_METH_VAR_NAME_17aa92881c42487f +L_OBJC_METH_VAR_NAME_17aa92881c42487f: .asciz "aMethod" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69 + .globl L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69: - .long L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 +L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f: + .long L_OBJC_METH_VAR_NAME_17aa92881c42487f .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7s.s b/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7s.s index 1c15631f3..7dbd2cd92 100644 --- a/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7s.s +++ b/crates/test-assembly/crates/test_extern_protocol/expected/apple-armv7s.s @@ -11,7 +11,7 @@ _get_protocol: movt r0, :upper16:(l_anon.[ID].0-(LPC0_0+8)) LPC0_0: add r0, pc, r0 - bl SYM(objc2::runtime::Protocol::get::GENERATED_ID, 0) + bl SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) pop {r7, pc} .globl _dyn_call @@ -20,8 +20,8 @@ LPC0_0: _dyn_call: push {r7, lr} mov r7, sp - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC1_0+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC1_0+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC1_0+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC1_0+8)) LPC1_0: ldr r1, [pc, r1] bl _objc_msgSend @@ -33,9 +33,9 @@ LPC1_0: _dyn_consume: push {r4, r7, lr} add r7, sp, #4 - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC2_0+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC2_0+8)) mov r4, r0 - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-(LPC2_0+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-(LPC2_0+8)) LPC2_0: ldr r1, [pc, r1] bl _objc_msgSend @@ -48,20 +48,20 @@ l_anon.[ID].0: .ascii "MyProtocol" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_d7a070d5c55b8e69 + .globl L_OBJC_IMAGE_INFO_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_d7a070d5c55b8e69: +L_OBJC_IMAGE_INFO_17aa92881c42487f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 -L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69: + .globl L_OBJC_METH_VAR_NAME_17aa92881c42487f +L_OBJC_METH_VAR_NAME_17aa92881c42487f: .asciz "aMethod" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69 + .globl L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69: - .long L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 +L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f: + .long L_OBJC_METH_VAR_NAME_17aa92881c42487f .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_extern_protocol/expected/apple-old-x86.s b/crates/test-assembly/crates/test_extern_protocol/expected/apple-old-x86.s index 38fac2cb5..ab40b8067 100644 --- a/crates/test-assembly/crates/test_extern_protocol/expected/apple-old-x86.s +++ b/crates/test-assembly/crates/test_extern_protocol/expected/apple-old-x86.s @@ -13,7 +13,7 @@ L0$pb: lea eax, [eax + l_anon.[ID].0-L0$pb] push 10 push eax - call SYM(objc2::runtime::Protocol::get::GENERATED_ID, 0) + call SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) add esp, 24 pop ebp ret @@ -28,7 +28,7 @@ _dyn_call: L1$pb: pop eax sub esp, 8 - push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-L1$pb] + push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-L1$pb] push dword ptr [ebp + 8] call _objc_msgSend add esp, 24 @@ -45,7 +45,7 @@ _dyn_consume: L2$pb: pop eax sub esp, 8 - push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-L2$pb] + push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-L2$pb] push dword ptr [ebp + 8] call _objc_msgSend add esp, 24 @@ -57,20 +57,20 @@ l_anon.[ID].0: .ascii "MyProtocol" .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_d7a070d5c55b8e69 + .globl L_OBJC_IMAGE_INFO_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_d7a070d5c55b8e69: +L_OBJC_IMAGE_INFO_17aa92881c42487f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 -L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69: + .globl L_OBJC_METH_VAR_NAME_17aa92881c42487f +L_OBJC_METH_VAR_NAME_17aa92881c42487f: .asciz "aMethod" .section __OBJC,__message_refs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69 + .globl L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69: - .long L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 +L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f: + .long L_OBJC_METH_VAR_NAME_17aa92881c42487f .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86.s b/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86.s index 6443ae695..bbdc2466a 100644 --- a/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86.s +++ b/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86.s @@ -13,7 +13,7 @@ L0$pb: lea eax, [eax + l_anon.[ID].0-L0$pb] push 10 push eax - call SYM(objc2::runtime::Protocol::get::GENERATED_ID, 0) + call SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) add esp, 24 pop ebp ret @@ -28,7 +28,7 @@ _dyn_call: L1$pb: pop eax sub esp, 8 - push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-L1$pb] + push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-L1$pb] push dword ptr [ebp + 8] call _objc_msgSend add esp, 24 @@ -45,7 +45,7 @@ _dyn_consume: L2$pb: pop eax sub esp, 8 - push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69-L2$pb] + push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f-L2$pb] push dword ptr [ebp + 8] call _objc_msgSend add esp, 24 @@ -57,20 +57,20 @@ l_anon.[ID].0: .ascii "MyProtocol" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_d7a070d5c55b8e69 + .globl L_OBJC_IMAGE_INFO_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_d7a070d5c55b8e69: +L_OBJC_IMAGE_INFO_17aa92881c42487f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 -L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69: + .globl L_OBJC_METH_VAR_NAME_17aa92881c42487f +L_OBJC_METH_VAR_NAME_17aa92881c42487f: .asciz "aMethod" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69 + .globl L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69: - .long L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 +L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f: + .long L_OBJC_METH_VAR_NAME_17aa92881c42487f .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86_64.s b/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86_64.s index b5119b5ca..6dd9b7a95 100644 --- a/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_extern_protocol/expected/apple-x86_64.s @@ -8,14 +8,14 @@ _get_protocol: lea rdi, [rip + l_anon.[ID].0] mov esi, 10 pop rbp - jmp SYM(objc2::runtime::Protocol::get::GENERATED_ID, 0) + jmp SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) .globl _dyn_call .p2align 4, 0x90 _dyn_call: push rbp mov rbp, rsp - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f] pop rbp jmp _objc_msgSend @@ -27,7 +27,7 @@ _dyn_consume: push rbx push rax mov rbx, rdi - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f] call _objc_msgSend mov rdi, rbx add rsp, 8 @@ -40,20 +40,20 @@ l_anon.[ID].0: .ascii "MyProtocol" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_d7a070d5c55b8e69 + .globl L_OBJC_IMAGE_INFO_17aa92881c42487f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_d7a070d5c55b8e69: +L_OBJC_IMAGE_INFO_17aa92881c42487f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 -L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69: + .globl L_OBJC_METH_VAR_NAME_17aa92881c42487f +L_OBJC_METH_VAR_NAME_17aa92881c42487f: .asciz "aMethod" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69 + .globl L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_d7a070d5c55b8e69: - .quad L_OBJC_METH_VAR_NAME_d7a070d5c55b8e69 +L_OBJC_SELECTOR_REFERENCES_17aa92881c42487f: + .quad L_OBJC_METH_VAR_NAME_17aa92881c42487f .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_extern_protocol/lib.rs b/crates/test-assembly/crates/test_extern_protocol/lib.rs index 77602db9f..272f5c7ac 100644 --- a/crates/test-assembly/crates/test_extern_protocol/lib.rs +++ b/crates/test-assembly/crates/test_extern_protocol/lib.rs @@ -3,7 +3,7 @@ use core::mem::ManuallyDrop; use objc2::rc::Id; -use objc2::runtime::{Protocol, ProtocolObject}; +use objc2::runtime::{AnyProtocol, ProtocolObject}; use objc2::{extern_protocol, ProtocolType}; extern_protocol!( @@ -18,7 +18,7 @@ extern_protocol!( ); #[no_mangle] -unsafe fn get_protocol() -> &'static Protocol { +unsafe fn get_protocol() -> &'static AnyProtocol { ::protocol().unwrap_unchecked() } diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s b/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s index 5b6aecd4f..4a47f9e16 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s @@ -1,6 +1,6 @@ .section __TEXT,__text,regular,pure_instructions .p2align 2 -SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): +SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): stp x20, x19, [sp, #-32]! stp x29, x30, [sp, #16] add x29, sp, #16 @@ -21,7 +21,7 @@ Lloh1: .loh AdrpAdd Lloh0, Lloh1 .p2align 2 -SYM(objc2[CRATE_ID]::message::encountered_error::, 0): +SYM(objc2[CRATE_ID]::message::encountered_error::, 0): stp x29, x30, [sp, #-16]! mov x29, sp bl _objc_retain @@ -59,7 +59,7 @@ _error_bool: ret LBB2_2: ldr x0, [sp, #8] - bl SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::message::encountered_error::, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 ret @@ -85,7 +85,7 @@ Lloh6: adrp x1, l_anon.[ID].4@PAGE Lloh7: add x1, x1, l_anon.[ID].4@PAGEOFF - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov x1, x0 mov w0, #1 ldp x29, x30, [sp, #16] @@ -114,7 +114,7 @@ Lloh8: adrp x1, l_anon.[ID].5@PAGE Lloh9: add x1, x1, l_anon.[ID].5@PAGEOFF - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov x1, x0 mov w0, #1 ldp x29, x30, [sp, #16] @@ -143,7 +143,7 @@ Lloh10: adrp x1, l_anon.[ID].6@PAGE Lloh11: add x1, x1, l_anon.[ID].6@PAGEOFF - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov x1, x0 mov w0, #1 ldp x29, x30, [sp, #16] @@ -172,7 +172,7 @@ Lloh12: adrp x1, l_anon.[ID].7@PAGE Lloh13: add x1, x1, l_anon.[ID].7@PAGEOFF - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov x1, x0 mov w0, #1 ldp x29, x30, [sp, #16] @@ -205,7 +205,7 @@ Lloh14: adrp x1, l_anon.[ID].8@PAGE Lloh15: add x1, x1, l_anon.[ID].8@PAGEOFF - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov x1, x0 mov w0, #1 ldp x29, x30, [sp, #16] diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7.s b/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7.s index ebebc37a6..85dc61d65 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7.s @@ -2,7 +2,7 @@ .syntax unified .p2align 2 .code 32 -SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): +SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): push {r4, r7, lr} add r7, sp, #4 mov r4, r1 @@ -21,7 +21,7 @@ LPC0_0: .p2align 2 .code 32 -SYM(objc2[CRATE_ID]::message::encountered_error::, 0): +SYM(objc2[CRATE_ID]::message::encountered_error::, 0): push {r7, lr} mov r7, sp bl _objc_retain @@ -58,7 +58,7 @@ _error_bool: pop {r4, r7, pc} LBB2_2: ldr r0, [sp] - bl SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::message::encountered_error::, 0) mov r4, r0 mov r0, r4 sub sp, r7, #4 @@ -87,7 +87,7 @@ LBB3_2: movt r1, :upper16:(l_anon.[ID].4-(LPC3_0+8)) LPC3_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -117,7 +117,7 @@ LBB4_2: movt r1, :upper16:(l_anon.[ID].5-(LPC4_0+8)) LPC4_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -147,7 +147,7 @@ LBB5_2: movt r1, :upper16:(l_anon.[ID].6-(LPC5_0+8)) LPC5_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -177,7 +177,7 @@ LBB6_2: movt r1, :upper16:(l_anon.[ID].7-(LPC6_0+8)) LPC6_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -211,7 +211,7 @@ LBB7_2: movt r1, :upper16:(l_anon.[ID].8-(LPC7_0+8)) LPC7_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7s.s b/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7s.s index 38527a8bd..07ab3cb9f 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7s.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/apple-armv7s.s @@ -2,7 +2,7 @@ .syntax unified .p2align 2 .code 32 -SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): +SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): push {r4, r7, lr} add r7, sp, #4 mov r4, r1 @@ -21,7 +21,7 @@ LPC0_0: .p2align 2 .code 32 -SYM(objc2[CRATE_ID]::message::encountered_error::, 0): +SYM(objc2[CRATE_ID]::message::encountered_error::, 0): push {r7, lr} mov r7, sp bl _objc_retain @@ -58,7 +58,7 @@ _error_bool: pop {r4, r7, pc} LBB2_2: ldr r0, [sp] - bl SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::message::encountered_error::, 0) mov r4, r0 mov r0, r4 sub sp, r7, #4 @@ -87,7 +87,7 @@ LBB3_2: ldr r0, [sp] LPC3_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -117,7 +117,7 @@ LBB4_2: ldr r0, [sp] LPC4_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -147,7 +147,7 @@ LBB5_2: ldr r0, [sp] LPC5_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -177,7 +177,7 @@ LBB6_2: ldr r0, [sp] LPC6_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 @@ -211,7 +211,7 @@ LBB7_2: ldr r0, [sp] LPC7_0: add r1, pc, r1 - bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + bl SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov r1, r0 mov r4, #1 mov r0, r4 diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86.s b/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86.s index 0004786c5..71641da83 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86.s @@ -1,7 +1,7 @@ .section __TEXT,__text,regular,pure_instructions .intel_syntax noprefix .p2align 4, 0x90 -SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): +SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): push ebp mov ebp, esp push edi @@ -29,7 +29,7 @@ LBB0_2: call SYM(core::option::expect_failed::GENERATED_ID, 0) .p2align 4, 0x90 -SYM(objc2[CRATE_ID]::message::encountered_error::, 0): +SYM(objc2[CRATE_ID]::message::encountered_error::, 0): push ebp mov ebp, esp push esi @@ -84,7 +84,7 @@ _error_bool: ret LBB2_1: mov ecx, dword ptr [ebp - 8] - call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) add esp, 4 pop esi pop ebp @@ -121,7 +121,7 @@ L3$pb: LBB3_2: mov ecx, dword ptr [ebp - 8] lea edx, [esi + l_anon.[ID].4-L3$pb] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 add esp, 4 @@ -160,7 +160,7 @@ L4$pb: LBB4_2: mov ecx, dword ptr [ebp - 8] lea edx, [esi + l_anon.[ID].5-L4$pb] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 add esp, 4 @@ -199,7 +199,7 @@ L5$pb: LBB5_2: mov ecx, dword ptr [ebp - 8] lea edx, [esi + l_anon.[ID].6-L5$pb] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 add esp, 4 @@ -238,7 +238,7 @@ L6$pb: LBB6_2: mov ecx, dword ptr [ebp - 8] lea edx, [esi + l_anon.[ID].7-L6$pb] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 add esp, 4 @@ -286,7 +286,7 @@ L7$pb: LBB7_2: mov ecx, dword ptr [ebp - 8] lea edx, [esi + l_anon.[ID].8-L7$pb] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 add esp, 4 diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86_64.s b/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86_64.s index a6e556836..70028f4c5 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/apple-x86_64.s @@ -1,7 +1,7 @@ .section __TEXT,__text,regular,pure_instructions .intel_syntax noprefix .p2align 4, 0x90 -SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): +SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): push rbp mov rbp, rsp push rbx @@ -21,7 +21,7 @@ LBB0_2: call SYM(core::option::expect_failed::GENERATED_ID, 0) .p2align 4, 0x90 -SYM(objc2[CRATE_ID]::message::encountered_error::, 0): +SYM(objc2[CRATE_ID]::message::encountered_error::, 0): push rbp mov rbp, rsp call _objc_retain @@ -52,7 +52,7 @@ _error_bool: ret LBB2_2: mov rdi, qword ptr [rbp - 8] - call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) add rsp, 16 pop rbp ret @@ -76,7 +76,7 @@ _error_new: LBB3_2: mov rdi, qword ptr [rbp - 8] lea rsi, [rip + l_anon.[ID].4] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 16 @@ -102,7 +102,7 @@ _error_alloc: LBB4_2: mov rdi, qword ptr [rbp - 8] lea rsi, [rip + l_anon.[ID].5] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 16 @@ -128,7 +128,7 @@ _error_init: LBB5_2: mov rdi, qword ptr [rbp - 8] lea rsi, [rip + l_anon.[ID].6] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 16 @@ -154,7 +154,7 @@ _error_copy: LBB6_2: mov rdi, qword ptr [rbp - 8] lea rsi, [rip + l_anon.[ID].7] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 16 @@ -187,7 +187,7 @@ _error_autoreleased: LBB7_2: mov rdi, qword ptr [rbp - 8] lea rsi, [rip + l_anon.[ID].8] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 16 diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86.s b/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86.s index bf510ef9c..0c09d6b77 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86.s @@ -1,9 +1,9 @@ .text .intel_syntax noprefix - .section .text.unlikely.SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),"ax",@progbits + .section .text.unlikely.SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),"ax",@progbits .p2align 4, 0x90 - .type SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),@function -SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): + .type SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),@function +SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): push ebx push esi push eax @@ -33,12 +33,12 @@ SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0), .Lfunc_end0-SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + .size SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0), .Lfunc_end0-SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) - .section .text.unlikely.SYM(objc2[CRATE_ID]::message::encountered_error::, 0),"ax",@progbits + .section .text.unlikely.SYM(objc2[CRATE_ID]::message::encountered_error::, 0),"ax",@progbits .p2align 4, 0x90 - .type SYM(objc2[CRATE_ID]::message::encountered_error::, 0),@function -SYM(objc2[CRATE_ID]::message::encountered_error::, 0): + .type SYM(objc2[CRATE_ID]::message::encountered_error::, 0),@function +SYM(objc2[CRATE_ID]::message::encountered_error::, 0): push ebx sub esp, 8 call .L1$pb @@ -66,7 +66,7 @@ SYM(objc2[CRATE_ID]::message::encountered_error::, 0), .Lfunc_end1-SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + .size SYM(objc2[CRATE_ID]::message::encountered_error::, 0), .Lfunc_end1-SYM(objc2[CRATE_ID]::message::encountered_error::, 0) .section .text.error_bool,"ax",@progbits .globl error_bool @@ -112,7 +112,7 @@ error_bool: ret .LBB2_1: mov ecx, dword ptr [esp + 8] - call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) jmp .LBB2_2 .Lfunc_end2: .size error_bool, .Lfunc_end2-error_bool @@ -158,7 +158,7 @@ error_new: .LBB3_2: mov ecx, dword ptr [esp + 12] lea edx, [ebx + .Lanon.[ID].4@GOTOFF] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 jmp .LBB3_3 @@ -206,7 +206,7 @@ error_alloc: .LBB4_2: mov ecx, dword ptr [esp + 12] lea edx, [ebx + .Lanon.[ID].5@GOTOFF] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 jmp .LBB4_3 @@ -260,7 +260,7 @@ error_init: mov ecx, dword ptr [esp + 12] .LBB5_5: lea edx, [ebx + .Lanon.[ID].6@GOTOFF] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 jmp .LBB5_6 @@ -308,7 +308,7 @@ error_copy: .LBB6_2: mov ecx, dword ptr [esp + 12] lea edx, [ebx + .Lanon.[ID].7@GOTOFF] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 jmp .LBB6_3 @@ -359,7 +359,7 @@ error_autoreleased: .LBB7_2: mov ecx, dword ptr [esp + 12] lea edx, [ebx + .Lanon.[ID].8@GOTOFF] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov edx, eax mov eax, 1 jmp .LBB7_3 diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86_64.s b/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86_64.s index daee7a24b..f3860ec58 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86_64.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/gnustep-x86_64.s @@ -1,9 +1,9 @@ .text .intel_syntax noprefix - .section .text.unlikely.SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),"ax",@progbits + .section .text.unlikely.SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),"ax",@progbits .p2align 4, 0x90 - .type SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),@function -SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): + .type SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0),@function +SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0): push rbx mov rbx, rsi call qword ptr [rip + objc_retain@GOTPCREL] @@ -18,12 +18,12 @@ SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0), .Lfunc_end0-SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + .size SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0), .Lfunc_end0-SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) - .section .text.unlikely.SYM(objc2[CRATE_ID]::message::encountered_error::, 0),"ax",@progbits + .section .text.unlikely.SYM(objc2[CRATE_ID]::message::encountered_error::, 0),"ax",@progbits .p2align 4, 0x90 - .type SYM(objc2[CRATE_ID]::message::encountered_error::, 0),@function -SYM(objc2[CRATE_ID]::message::encountered_error::, 0): + .type SYM(objc2[CRATE_ID]::message::encountered_error::, 0),@function +SYM(objc2[CRATE_ID]::message::encountered_error::, 0): push rax call qword ptr [rip + objc_retain@GOTPCREL] test rax, rax @@ -37,7 +37,7 @@ SYM(objc2[CRATE_ID]::message::encountered_error::, 0), .Lfunc_end1-SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + .size SYM(objc2[CRATE_ID]::message::encountered_error::, 0), .Lfunc_end1-SYM(objc2[CRATE_ID]::message::encountered_error::, 0) .section .text.error_bool,"ax",@progbits .globl error_bool @@ -69,7 +69,7 @@ error_bool: ret .LBB2_2: mov rdi, qword ptr [rsp + 8] - call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::message::encountered_error::, 0) jmp .LBB2_3 .Lfunc_end2: .size error_bool, .Lfunc_end2-error_bool @@ -101,7 +101,7 @@ error_new: .LBB3_2: mov rdi, qword ptr [rsp] lea rsi, [rip + .Lanon.[ID].4] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 8 @@ -138,7 +138,7 @@ error_alloc: .LBB4_2: mov rdi, qword ptr [rsp] lea rsi, [rip + .Lanon.[ID].5] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 8 @@ -181,7 +181,7 @@ error_init: mov rdi, qword ptr [rsp] .LBB5_5: lea rsi, [rip + .Lanon.[ID].6] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 8 @@ -218,7 +218,7 @@ error_copy: .LBB6_2: mov rdi, qword ptr [rsp] lea rsi, [rip + .Lanon.[ID].7] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 8 @@ -257,7 +257,7 @@ error_autoreleased: .LBB7_2: mov rdi, qword ptr [rsp] lea rsi, [rip + .Lanon.[ID].8] - call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) + call SYM(objc2[CRATE_ID]::__macro_helpers::encountered_error::, 0) mov rdx, rax mov eax, 1 add rsp, 8 diff --git a/crates/test-assembly/crates/test_msg_send_error/lib.rs b/crates/test-assembly/crates/test_msg_send_error/lib.rs index d43d3ee95..d78fcbca0 100644 --- a/crates/test-assembly/crates/test_msg_send_error/lib.rs +++ b/crates/test-assembly/crates/test_msg_send_error/lib.rs @@ -1,37 +1,37 @@ //! Test that error parameters are handled correctly. use objc2::rc::{Allocated, Id}; -use objc2::runtime::{Class, Object, Sel}; +use objc2::runtime::{AnyClass, AnyObject, Sel}; use objc2::MessageReceiver; use objc2::__macro_helpers::{Alloc, CopyOrMutCopy, Init, MsgSendId, New, Other}; -type Result = std::result::Result>; +type Result = std::result::Result>; #[no_mangle] -unsafe fn error_bool(obj: &Object, sel: Sel, param: u32) -> Result<()> { +unsafe fn error_bool(obj: &AnyObject, sel: Sel, param: u32) -> Result<()> { MessageReceiver::__send_message_error(obj, sel, (param,)) } #[no_mangle] -unsafe fn error_new(cls: &Class, sel: Sel) -> Result> { +unsafe fn error_new(cls: &AnyClass, sel: Sel) -> Result> { New::send_message_id_error(cls, sel, ()) } #[no_mangle] -unsafe fn error_alloc(cls: &Class, sel: Sel) -> Result> { +unsafe fn error_alloc(cls: &AnyClass, sel: Sel) -> Result> { Alloc::send_message_id_error(cls, sel, ()) } #[no_mangle] -unsafe fn error_init(obj: Option>, sel: Sel) -> Result> { +unsafe fn error_init(obj: Option>, sel: Sel) -> Result> { Init::send_message_id_error(obj, sel, ()) } #[no_mangle] -unsafe fn error_copy(obj: &Object, sel: Sel) -> Result> { +unsafe fn error_copy(obj: &AnyObject, sel: Sel) -> Result> { CopyOrMutCopy::send_message_id_error(obj, sel, ()) } #[no_mangle] -unsafe fn error_autoreleased(obj: &Object, sel: Sel) -> Result> { +unsafe fn error_autoreleased(obj: &AnyObject, sel: Sel) -> Result> { Other::send_message_id_error(obj, sel, ()) } diff --git a/crates/test-assembly/crates/test_msg_send_id/lib.rs b/crates/test-assembly/crates/test_msg_send_id/lib.rs index 56fa49e2e..1a4a3b6e1 100644 --- a/crates/test-assembly/crates/test_msg_send_id/lib.rs +++ b/crates/test-assembly/crates/test_msg_send_id/lib.rs @@ -1,83 +1,83 @@ //! Test assembly output of `msg_send_id!` internals. use objc2::__macro_helpers::{Alloc, CopyOrMutCopy, Init, MsgSendId, New, Other}; use objc2::rc::{Allocated, Id}; -use objc2::runtime::{Class, Object, Sel}; +use objc2::runtime::{AnyClass, AnyObject, Sel}; #[no_mangle] -unsafe fn handle_new(cls: &Class, sel: Sel) -> Option> { +unsafe fn handle_new(cls: &AnyClass, sel: Sel) -> Option> { New::send_message_id(cls, sel, ()) } #[no_mangle] -unsafe fn handle_new_fallible(cls: &Class, sel: Sel) -> Id { +unsafe fn handle_new_fallible(cls: &AnyClass, sel: Sel) -> Id { New::send_message_id(cls, sel, ()) } #[no_mangle] -unsafe fn handle_alloc(cls: &Class, sel: Sel) -> Option> { +unsafe fn handle_alloc(cls: &AnyClass, sel: Sel) -> Option> { Alloc::send_message_id(cls, sel, ()) } #[no_mangle] -unsafe fn handle_alloc_fallible(cls: &Class, sel: Sel) -> Allocated { +unsafe fn handle_alloc_fallible(cls: &AnyClass, sel: Sel) -> Allocated { Alloc::send_message_id(cls, sel, ()) } #[no_mangle] -unsafe fn handle_init(obj: Option>, sel: Sel) -> Option> { +unsafe fn handle_init(obj: Option>, sel: Sel) -> Option> { Init::send_message_id(obj, sel, ()) } #[no_mangle] -unsafe fn handle_init_fallible(obj: Option>, sel: Sel) -> Id { +unsafe fn handle_init_fallible(obj: Option>, sel: Sel) -> Id { Init::send_message_id(obj, sel, ()) } #[no_mangle] -unsafe fn handle_alloc_init(cls: &Class, sel1: Sel, sel2: Sel) -> Option> { +unsafe fn handle_alloc_init(cls: &AnyClass, sel1: Sel, sel2: Sel) -> Option> { let obj = Alloc::send_message_id(cls, sel1, ()); Init::send_message_id(obj, sel2, ()) } #[no_mangle] -unsafe fn handle_alloc_release(cls: &Class, sel: Sel) { - let obj: Option> = Alloc::send_message_id(cls, sel, ()); +unsafe fn handle_alloc_release(cls: &AnyClass, sel: Sel) { + let obj: Option> = Alloc::send_message_id(cls, sel, ()); let _obj = obj.unwrap_unchecked(); } #[no_mangle] -unsafe fn handle_alloc_init_release(cls: &Class, sel1: Sel, sel2: Sel) { +unsafe fn handle_alloc_init_release(cls: &AnyClass, sel1: Sel, sel2: Sel) { let obj = Alloc::send_message_id(cls, sel1, ()); - let obj: Option> = Init::send_message_id(obj, sel2, ()); + let obj: Option> = Init::send_message_id(obj, sel2, ()); let _obj = obj.unwrap_unchecked(); } #[no_mangle] -unsafe fn handle_copy(obj: &Object, sel: Sel) -> Option> { +unsafe fn handle_copy(obj: &AnyObject, sel: Sel) -> Option> { CopyOrMutCopy::send_message_id(obj, sel, ()) } #[no_mangle] -unsafe fn handle_copy_fallible(obj: &Object, sel: Sel) -> Id { +unsafe fn handle_copy_fallible(obj: &AnyObject, sel: Sel) -> Id { CopyOrMutCopy::send_message_id(obj, sel, ()) } #[no_mangle] -unsafe fn handle_autoreleased(obj: &Object, sel: Sel) -> Option> { +unsafe fn handle_autoreleased(obj: &AnyObject, sel: Sel) -> Option> { Other::send_message_id(obj, sel, ()) } #[no_mangle] -unsafe fn handle_autoreleased_fallible(obj: &Object, sel: Sel) -> Id { +unsafe fn handle_autoreleased_fallible(obj: &AnyObject, sel: Sel) -> Id { Other::send_message_id(obj, sel, ()) } // TODO: The optimization does not happen here, fix this! #[no_mangle] unsafe fn handle_with_out_param( - obj: &Object, + obj: &AnyObject, sel: Sel, - param: &mut Id, -) -> Option> { + param: &mut Id, +) -> Option> { Other::send_message_id(obj, sel, (param,)) } diff --git a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s index e55e623b4..4cb6d69af 100644 --- a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-aarch64.s @@ -3,9 +3,9 @@ .p2align 2 _handle_with_sel: Lloh0: - adrp x8, L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_ad1b815073641351@PAGE Lloh1: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_ad1b815073641351@PAGEOFF] b _objc_msgSend .loh AdrpLdr Lloh0, Lloh1 @@ -55,24 +55,24 @@ _use_generic: add x29, sp, #16 mov x19, x0 Lloh10: - adrp x8, L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138@PAGE Lloh11: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da@PAGEOFF] - adrp x20, L_OBJC_SELECTOR_REFERENCES_379095321e06c060@PAGE - ldr x2, [x20, L_OBJC_SELECTOR_REFERENCES_379095321e06c060@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138@PAGEOFF] + adrp x20, L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05@PAGE + ldr x2, [x20, L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05@PAGEOFF] bl _objc_msgSend Lloh12: - adrp x8, L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da@PAGE Lloh13: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1@PAGEOFF] - ldr x2, [x20, L_OBJC_SELECTOR_REFERENCES_379095321e06c060@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da@PAGEOFF] + ldr x2, [x20, L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05@PAGEOFF] mov x0, x19 bl _objc_msgSend Lloh14: - adrp x8, L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a@PAGE Lloh15: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d@PAGEOFF] - ldr x2, [x20, L_OBJC_SELECTOR_REFERENCES_379095321e06c060@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a@PAGEOFF] + ldr x2, [x20, L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05@PAGEOFF] mov x0, x19 ldp x29, x30, [sp, #16] ldp x20, x19, [sp], #32 @@ -92,88 +92,88 @@ l_anon.[ID].1: .asciz ";\000\000\000\000\000\000\000\016\000\000\000\005\000\000" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_77d2b75bddfbef7c + .globl L_OBJC_IMAGE_INFO_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_77d2b75bddfbef7c: +L_OBJC_IMAGE_INFO_ad1b815073641351: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c -L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c: + .globl L_OBJC_METH_VAR_NAME_ad1b815073641351 +L_OBJC_METH_VAR_NAME_ad1b815073641351: .asciz "someSelector" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c + .globl L_OBJC_SELECTOR_REFERENCES_ad1b815073641351 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c: - .quad L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c +L_OBJC_SELECTOR_REFERENCES_ad1b815073641351: + .quad L_OBJC_METH_VAR_NAME_ad1b815073641351 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_379095321e06c060 + .globl L_OBJC_IMAGE_INFO_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_379095321e06c060: +L_OBJC_IMAGE_INFO_5ace898e385eba05: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_379095321e06c060 -L_OBJC_METH_VAR_NAME_379095321e06c060: + .globl L_OBJC_METH_VAR_NAME_5ace898e385eba05 +L_OBJC_METH_VAR_NAME_5ace898e385eba05: .asciz "generic:selector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_379095321e06c060 + .globl L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_379095321e06c060: - .quad L_OBJC_METH_VAR_NAME_379095321e06c060 +L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05: + .quad L_OBJC_METH_VAR_NAME_5ace898e385eba05 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_038d21a6277de1da + .globl L_OBJC_IMAGE_INFO_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_038d21a6277de1da: +L_OBJC_IMAGE_INFO_1f1c7bd8029c3138: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_038d21a6277de1da -L_OBJC_METH_VAR_NAME_038d21a6277de1da: + .globl L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 +L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da + .globl L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da: - .quad L_OBJC_METH_VAR_NAME_038d21a6277de1da +L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138: + .quad L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1 + .globl L_OBJC_IMAGE_INFO_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1: +L_OBJC_IMAGE_INFO_eb5b4d2de37744da: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 -L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1: + .globl L_OBJC_METH_VAR_NAME_eb5b4d2de37744da +L_OBJC_METH_VAR_NAME_eb5b4d2de37744da: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1 + .globl L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1: - .quad L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 +L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da: + .quad L_OBJC_METH_VAR_NAME_eb5b4d2de37744da .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_9885c1be4d03110d + .globl L_OBJC_IMAGE_INFO_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_9885c1be4d03110d: +L_OBJC_IMAGE_INFO_c76827c00227cd8a: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_9885c1be4d03110d -L_OBJC_METH_VAR_NAME_9885c1be4d03110d: + .globl L_OBJC_METH_VAR_NAME_c76827c00227cd8a +L_OBJC_METH_VAR_NAME_c76827c00227cd8a: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d + .globl L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d: - .quad L_OBJC_METH_VAR_NAME_9885c1be4d03110d +L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a: + .quad L_OBJC_METH_VAR_NAME_c76827c00227cd8a .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s index c694c7201..f574ce27a 100644 --- a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s +++ b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7.s @@ -4,8 +4,8 @@ .p2align 2 .code 32 _handle_with_sel: - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c-(LPC0_0+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c-(LPC0_0+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_ad1b815073641351-(LPC0_0+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_ad1b815073641351-(LPC0_0+8)) LPC0_0: ldr r1, [pc, r1] b _objc_msgSend @@ -48,33 +48,33 @@ LPC1_2: _use_generic: push {r4, r7, lr} add r7, sp, #4 - movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_0+8)) + movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_0+8)) mov r4, r0 - movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_0+8)) + movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_0+8)) LPC2_0: ldr r2, [pc, r2] - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da-(LPC2_1+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da-(LPC2_1+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138-(LPC2_1+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138-(LPC2_1+8)) LPC2_1: ldr r1, [pc, r1] bl _objc_msgSend - movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_2+8)) + movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_2+8)) mov r0, r4 - movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_2+8)) + movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_2+8)) LPC2_2: ldr r2, [pc, r2] - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1-(LPC2_3+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1-(LPC2_3+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da-(LPC2_3+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da-(LPC2_3+8)) LPC2_3: ldr r1, [pc, r1] bl _objc_msgSend - movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_4+8)) + movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_4+8)) mov r0, r4 - movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_4+8)) + movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_4+8)) LPC2_4: ldr r2, [pc, r2] - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d-(LPC2_5+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d-(LPC2_5+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a-(LPC2_5+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a-(LPC2_5+8)) LPC2_5: ldr r1, [pc, r1] pop {r4, r7, lr} @@ -91,89 +91,89 @@ l_anon.[ID].1: .asciz ";\000\000\000\016\000\000\000\005\000\000" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_77d2b75bddfbef7c + .globl L_OBJC_IMAGE_INFO_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_77d2b75bddfbef7c: +L_OBJC_IMAGE_INFO_ad1b815073641351: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c -L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c: + .globl L_OBJC_METH_VAR_NAME_ad1b815073641351 +L_OBJC_METH_VAR_NAME_ad1b815073641351: .asciz "someSelector" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c + .globl L_OBJC_SELECTOR_REFERENCES_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c: - .long L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c +L_OBJC_SELECTOR_REFERENCES_ad1b815073641351: + .long L_OBJC_METH_VAR_NAME_ad1b815073641351 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_379095321e06c060 + .globl L_OBJC_IMAGE_INFO_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_379095321e06c060: +L_OBJC_IMAGE_INFO_5ace898e385eba05: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_379095321e06c060 -L_OBJC_METH_VAR_NAME_379095321e06c060: + .globl L_OBJC_METH_VAR_NAME_5ace898e385eba05 +L_OBJC_METH_VAR_NAME_5ace898e385eba05: .asciz "generic:selector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_379095321e06c060 + .globl L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_379095321e06c060: - .long L_OBJC_METH_VAR_NAME_379095321e06c060 +L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05: + .long L_OBJC_METH_VAR_NAME_5ace898e385eba05 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_038d21a6277de1da + .globl L_OBJC_IMAGE_INFO_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_038d21a6277de1da: +L_OBJC_IMAGE_INFO_1f1c7bd8029c3138: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_038d21a6277de1da -L_OBJC_METH_VAR_NAME_038d21a6277de1da: + .globl L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 +L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da + .globl L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da: - .long L_OBJC_METH_VAR_NAME_038d21a6277de1da +L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138: + .long L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1 + .globl L_OBJC_IMAGE_INFO_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1: +L_OBJC_IMAGE_INFO_eb5b4d2de37744da: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 -L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1: + .globl L_OBJC_METH_VAR_NAME_eb5b4d2de37744da +L_OBJC_METH_VAR_NAME_eb5b4d2de37744da: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1 + .globl L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1: - .long L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 +L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da: + .long L_OBJC_METH_VAR_NAME_eb5b4d2de37744da .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_9885c1be4d03110d + .globl L_OBJC_IMAGE_INFO_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_9885c1be4d03110d: +L_OBJC_IMAGE_INFO_c76827c00227cd8a: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_9885c1be4d03110d -L_OBJC_METH_VAR_NAME_9885c1be4d03110d: + .globl L_OBJC_METH_VAR_NAME_c76827c00227cd8a +L_OBJC_METH_VAR_NAME_c76827c00227cd8a: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d + .globl L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d: - .long L_OBJC_METH_VAR_NAME_9885c1be4d03110d +L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a: + .long L_OBJC_METH_VAR_NAME_c76827c00227cd8a .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers .p2align 2, 0x0 diff --git a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s index 3ba6c808f..f70e4daf4 100644 --- a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s +++ b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-armv7s.s @@ -6,8 +6,8 @@ _handle_with_sel: push {r7, lr} mov r7, sp - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c-(LPC0_0+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c-(LPC0_0+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_ad1b815073641351-(LPC0_0+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_ad1b815073641351-(LPC0_0+8)) LPC0_0: ldr r1, [pc, r1] bl _objc_msgSend @@ -51,33 +51,33 @@ LPC1_2: _use_generic: push {r4, r7, lr} add r7, sp, #4 - movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_0+8)) + movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_0+8)) mov r4, r0 - movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_0+8)) + movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_0+8)) LPC2_0: ldr r2, [pc, r2] - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da-(LPC2_1+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da-(LPC2_1+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138-(LPC2_1+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138-(LPC2_1+8)) LPC2_1: ldr r1, [pc, r1] bl _objc_msgSend - movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_2+8)) + movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_2+8)) mov r0, r4 - movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_2+8)) + movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_2+8)) LPC2_2: ldr r2, [pc, r2] - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1-(LPC2_3+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1-(LPC2_3+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da-(LPC2_3+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da-(LPC2_3+8)) LPC2_3: ldr r1, [pc, r1] bl _objc_msgSend - movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_4+8)) + movw r2, :lower16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_4+8)) mov r0, r4 - movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_379095321e06c060-(LPC2_4+8)) + movt r2, :upper16:(L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-(LPC2_4+8)) LPC2_4: ldr r2, [pc, r2] - movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d-(LPC2_5+8)) - movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d-(LPC2_5+8)) + movw r1, :lower16:(L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a-(LPC2_5+8)) + movt r1, :upper16:(L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a-(LPC2_5+8)) LPC2_5: ldr r1, [pc, r1] bl _objc_msgSend @@ -94,89 +94,89 @@ l_anon.[ID].1: .asciz ";\000\000\000\016\000\000\000\005\000\000" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_77d2b75bddfbef7c + .globl L_OBJC_IMAGE_INFO_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_77d2b75bddfbef7c: +L_OBJC_IMAGE_INFO_ad1b815073641351: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c -L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c: + .globl L_OBJC_METH_VAR_NAME_ad1b815073641351 +L_OBJC_METH_VAR_NAME_ad1b815073641351: .asciz "someSelector" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c + .globl L_OBJC_SELECTOR_REFERENCES_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c: - .long L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c +L_OBJC_SELECTOR_REFERENCES_ad1b815073641351: + .long L_OBJC_METH_VAR_NAME_ad1b815073641351 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_379095321e06c060 + .globl L_OBJC_IMAGE_INFO_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_379095321e06c060: +L_OBJC_IMAGE_INFO_5ace898e385eba05: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_379095321e06c060 -L_OBJC_METH_VAR_NAME_379095321e06c060: + .globl L_OBJC_METH_VAR_NAME_5ace898e385eba05 +L_OBJC_METH_VAR_NAME_5ace898e385eba05: .asciz "generic:selector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_379095321e06c060 + .globl L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_379095321e06c060: - .long L_OBJC_METH_VAR_NAME_379095321e06c060 +L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05: + .long L_OBJC_METH_VAR_NAME_5ace898e385eba05 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_038d21a6277de1da + .globl L_OBJC_IMAGE_INFO_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_038d21a6277de1da: +L_OBJC_IMAGE_INFO_1f1c7bd8029c3138: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_038d21a6277de1da -L_OBJC_METH_VAR_NAME_038d21a6277de1da: + .globl L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 +L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da + .globl L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da: - .long L_OBJC_METH_VAR_NAME_038d21a6277de1da +L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138: + .long L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1 + .globl L_OBJC_IMAGE_INFO_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1: +L_OBJC_IMAGE_INFO_eb5b4d2de37744da: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 -L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1: + .globl L_OBJC_METH_VAR_NAME_eb5b4d2de37744da +L_OBJC_METH_VAR_NAME_eb5b4d2de37744da: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1 + .globl L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1: - .long L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 +L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da: + .long L_OBJC_METH_VAR_NAME_eb5b4d2de37744da .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_9885c1be4d03110d + .globl L_OBJC_IMAGE_INFO_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_9885c1be4d03110d: +L_OBJC_IMAGE_INFO_c76827c00227cd8a: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_9885c1be4d03110d -L_OBJC_METH_VAR_NAME_9885c1be4d03110d: + .globl L_OBJC_METH_VAR_NAME_c76827c00227cd8a +L_OBJC_METH_VAR_NAME_c76827c00227cd8a: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d + .globl L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d: - .long L_OBJC_METH_VAR_NAME_9885c1be4d03110d +L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a: + .long L_OBJC_METH_VAR_NAME_c76827c00227cd8a .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers .p2align 2, 0x0 diff --git a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s index dce9a3632..c6da46205 100644 --- a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s +++ b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-old-x86.s @@ -10,7 +10,7 @@ _handle_with_sel: L0$pb: pop eax sub esp, 8 - push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c-L0$pb] + push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_ad1b815073641351-L0$pb] push dword ptr [ebp + 8] call _objc_msgSend add esp, 24 @@ -71,18 +71,18 @@ L2$pb: pop esi mov edi, dword ptr [ebp + 8] sub esp, 4 - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_379095321e06c060-L2$pb] - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138-L2$pb] push edi call _objc_msgSend add esp, 12 - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_379095321e06c060-L2$pb] - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da-L2$pb] push edi call _objc_msgSend add esp, 12 - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_379095321e06c060-L2$pb] - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a-L2$pb] push edi call _objc_msgSend add esp, 16 @@ -102,89 +102,89 @@ l_anon.[ID].1: .asciz ";\000\000\000\016\000\000\000\005\000\000" .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_77d2b75bddfbef7c + .globl L_OBJC_IMAGE_INFO_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_77d2b75bddfbef7c: +L_OBJC_IMAGE_INFO_ad1b815073641351: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c -L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c: + .globl L_OBJC_METH_VAR_NAME_ad1b815073641351 +L_OBJC_METH_VAR_NAME_ad1b815073641351: .asciz "someSelector" .section __OBJC,__message_refs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c + .globl L_OBJC_SELECTOR_REFERENCES_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c: - .long L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c +L_OBJC_SELECTOR_REFERENCES_ad1b815073641351: + .long L_OBJC_METH_VAR_NAME_ad1b815073641351 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_379095321e06c060 + .globl L_OBJC_IMAGE_INFO_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_379095321e06c060: +L_OBJC_IMAGE_INFO_5ace898e385eba05: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_METH_VAR_NAME_379095321e06c060 -L_OBJC_METH_VAR_NAME_379095321e06c060: + .globl L_OBJC_METH_VAR_NAME_5ace898e385eba05 +L_OBJC_METH_VAR_NAME_5ace898e385eba05: .asciz "generic:selector:" .section __OBJC,__message_refs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_379095321e06c060 + .globl L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_379095321e06c060: - .long L_OBJC_METH_VAR_NAME_379095321e06c060 +L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05: + .long L_OBJC_METH_VAR_NAME_5ace898e385eba05 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_038d21a6277de1da + .globl L_OBJC_IMAGE_INFO_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_038d21a6277de1da: +L_OBJC_IMAGE_INFO_1f1c7bd8029c3138: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_METH_VAR_NAME_038d21a6277de1da -L_OBJC_METH_VAR_NAME_038d21a6277de1da: + .globl L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 +L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138: .asciz "performSelector:" .section __OBJC,__message_refs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da + .globl L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da: - .long L_OBJC_METH_VAR_NAME_038d21a6277de1da +L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138: + .long L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1 + .globl L_OBJC_IMAGE_INFO_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1: +L_OBJC_IMAGE_INFO_eb5b4d2de37744da: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 -L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1: + .globl L_OBJC_METH_VAR_NAME_eb5b4d2de37744da +L_OBJC_METH_VAR_NAME_eb5b4d2de37744da: .asciz "performSelector:" .section __OBJC,__message_refs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1 + .globl L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1: - .long L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 +L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da: + .long L_OBJC_METH_VAR_NAME_eb5b4d2de37744da .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_9885c1be4d03110d + .globl L_OBJC_IMAGE_INFO_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_9885c1be4d03110d: +L_OBJC_IMAGE_INFO_c76827c00227cd8a: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_METH_VAR_NAME_9885c1be4d03110d -L_OBJC_METH_VAR_NAME_9885c1be4d03110d: + .globl L_OBJC_METH_VAR_NAME_c76827c00227cd8a +L_OBJC_METH_VAR_NAME_c76827c00227cd8a: .asciz "performSelector:" .section __OBJC,__message_refs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d + .globl L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d: - .long L_OBJC_METH_VAR_NAME_9885c1be4d03110d +L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a: + .long L_OBJC_METH_VAR_NAME_c76827c00227cd8a .section __IMPORT,__pointers,non_lazy_symbol_pointers LL_OBJC_SELECTOR_REFERENCES_alloc$non_lazy_ptr: diff --git a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s index 3a590c250..9797369b1 100644 --- a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s +++ b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86.s @@ -10,7 +10,7 @@ _handle_with_sel: L0$pb: pop eax sub esp, 8 - push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c-L0$pb] + push dword ptr [eax + L_OBJC_SELECTOR_REFERENCES_ad1b815073641351-L0$pb] push dword ptr [ebp + 8] call _objc_msgSend add esp, 24 @@ -71,18 +71,18 @@ L2$pb: pop esi mov edi, dword ptr [ebp + 8] sub esp, 4 - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_379095321e06c060-L2$pb] - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138-L2$pb] push edi call _objc_msgSend add esp, 12 - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_379095321e06c060-L2$pb] - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da-L2$pb] push edi call _objc_msgSend add esp, 12 - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_379095321e06c060-L2$pb] - push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05-L2$pb] + push dword ptr [esi + L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a-L2$pb] push edi call _objc_msgSend add esp, 16 @@ -102,89 +102,89 @@ l_anon.[ID].1: .asciz ";\000\000\000\016\000\000\000\005\000\000" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_77d2b75bddfbef7c + .globl L_OBJC_IMAGE_INFO_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_77d2b75bddfbef7c: +L_OBJC_IMAGE_INFO_ad1b815073641351: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c -L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c: + .globl L_OBJC_METH_VAR_NAME_ad1b815073641351 +L_OBJC_METH_VAR_NAME_ad1b815073641351: .asciz "someSelector" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c + .globl L_OBJC_SELECTOR_REFERENCES_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c: - .long L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c +L_OBJC_SELECTOR_REFERENCES_ad1b815073641351: + .long L_OBJC_METH_VAR_NAME_ad1b815073641351 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_379095321e06c060 + .globl L_OBJC_IMAGE_INFO_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_379095321e06c060: +L_OBJC_IMAGE_INFO_5ace898e385eba05: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_379095321e06c060 -L_OBJC_METH_VAR_NAME_379095321e06c060: + .globl L_OBJC_METH_VAR_NAME_5ace898e385eba05 +L_OBJC_METH_VAR_NAME_5ace898e385eba05: .asciz "generic:selector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_379095321e06c060 + .globl L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_379095321e06c060: - .long L_OBJC_METH_VAR_NAME_379095321e06c060 +L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05: + .long L_OBJC_METH_VAR_NAME_5ace898e385eba05 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_038d21a6277de1da + .globl L_OBJC_IMAGE_INFO_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_038d21a6277de1da: +L_OBJC_IMAGE_INFO_1f1c7bd8029c3138: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_038d21a6277de1da -L_OBJC_METH_VAR_NAME_038d21a6277de1da: + .globl L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 +L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da + .globl L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da: - .long L_OBJC_METH_VAR_NAME_038d21a6277de1da +L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138: + .long L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1 + .globl L_OBJC_IMAGE_INFO_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1: +L_OBJC_IMAGE_INFO_eb5b4d2de37744da: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 -L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1: + .globl L_OBJC_METH_VAR_NAME_eb5b4d2de37744da +L_OBJC_METH_VAR_NAME_eb5b4d2de37744da: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1 + .globl L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1: - .long L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 +L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da: + .long L_OBJC_METH_VAR_NAME_eb5b4d2de37744da .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_9885c1be4d03110d + .globl L_OBJC_IMAGE_INFO_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_9885c1be4d03110d: +L_OBJC_IMAGE_INFO_c76827c00227cd8a: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_9885c1be4d03110d -L_OBJC_METH_VAR_NAME_9885c1be4d03110d: + .globl L_OBJC_METH_VAR_NAME_c76827c00227cd8a +L_OBJC_METH_VAR_NAME_c76827c00227cd8a: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d + .globl L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d: - .long L_OBJC_METH_VAR_NAME_9885c1be4d03110d +L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a: + .long L_OBJC_METH_VAR_NAME_c76827c00227cd8a .section __IMPORT,__pointers,non_lazy_symbol_pointers LL_OBJC_SELECTOR_REFERENCES_alloc$non_lazy_ptr: diff --git a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s index fb4a675c3..2f76e0489 100644 --- a/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_msg_send_static_sel/expected/apple-x86_64.s @@ -5,7 +5,7 @@ _handle_with_sel: push rbp mov rbp, rsp - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_ad1b815073641351] pop rbp jmp _objc_msgSend @@ -45,15 +45,15 @@ _use_generic: push rbx push rax mov rbx, rdi - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da] - mov rdx, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_379095321e06c060] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138] + mov rdx, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05] call _objc_msgSend - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1] - mov rdx, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_379095321e06c060] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da] + mov rdx, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05] mov rdi, rbx call _objc_msgSend - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d] - mov rdx, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_379095321e06c060] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a] + mov rdx, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05] mov rdi, rbx add rsp, 8 pop rbx @@ -71,88 +71,88 @@ l_anon.[ID].1: .asciz ";\000\000\000\000\000\000\000\016\000\000\000\005\000\000" .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_77d2b75bddfbef7c + .globl L_OBJC_IMAGE_INFO_ad1b815073641351 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_77d2b75bddfbef7c: +L_OBJC_IMAGE_INFO_ad1b815073641351: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c -L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c: + .globl L_OBJC_METH_VAR_NAME_ad1b815073641351 +L_OBJC_METH_VAR_NAME_ad1b815073641351: .asciz "someSelector" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c + .globl L_OBJC_SELECTOR_REFERENCES_ad1b815073641351 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_77d2b75bddfbef7c: - .quad L_OBJC_METH_VAR_NAME_77d2b75bddfbef7c +L_OBJC_SELECTOR_REFERENCES_ad1b815073641351: + .quad L_OBJC_METH_VAR_NAME_ad1b815073641351 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_379095321e06c060 + .globl L_OBJC_IMAGE_INFO_5ace898e385eba05 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_379095321e06c060: +L_OBJC_IMAGE_INFO_5ace898e385eba05: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_379095321e06c060 -L_OBJC_METH_VAR_NAME_379095321e06c060: + .globl L_OBJC_METH_VAR_NAME_5ace898e385eba05 +L_OBJC_METH_VAR_NAME_5ace898e385eba05: .asciz "generic:selector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_379095321e06c060 + .globl L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_379095321e06c060: - .quad L_OBJC_METH_VAR_NAME_379095321e06c060 +L_OBJC_SELECTOR_REFERENCES_5ace898e385eba05: + .quad L_OBJC_METH_VAR_NAME_5ace898e385eba05 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_038d21a6277de1da + .globl L_OBJC_IMAGE_INFO_1f1c7bd8029c3138 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_038d21a6277de1da: +L_OBJC_IMAGE_INFO_1f1c7bd8029c3138: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_038d21a6277de1da -L_OBJC_METH_VAR_NAME_038d21a6277de1da: + .globl L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 +L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da + .globl L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_038d21a6277de1da: - .quad L_OBJC_METH_VAR_NAME_038d21a6277de1da +L_OBJC_SELECTOR_REFERENCES_1f1c7bd8029c3138: + .quad L_OBJC_METH_VAR_NAME_1f1c7bd8029c3138 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1 + .globl L_OBJC_IMAGE_INFO_eb5b4d2de37744da .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_573c1e9c42ae1ea1: +L_OBJC_IMAGE_INFO_eb5b4d2de37744da: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 -L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1: + .globl L_OBJC_METH_VAR_NAME_eb5b4d2de37744da +L_OBJC_METH_VAR_NAME_eb5b4d2de37744da: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1 + .globl L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_573c1e9c42ae1ea1: - .quad L_OBJC_METH_VAR_NAME_573c1e9c42ae1ea1 +L_OBJC_SELECTOR_REFERENCES_eb5b4d2de37744da: + .quad L_OBJC_METH_VAR_NAME_eb5b4d2de37744da .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_9885c1be4d03110d + .globl L_OBJC_IMAGE_INFO_c76827c00227cd8a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_9885c1be4d03110d: +L_OBJC_IMAGE_INFO_c76827c00227cd8a: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_9885c1be4d03110d -L_OBJC_METH_VAR_NAME_9885c1be4d03110d: + .globl L_OBJC_METH_VAR_NAME_c76827c00227cd8a +L_OBJC_METH_VAR_NAME_c76827c00227cd8a: .asciz "performSelector:" .section __DATA,__objc_selrefs,literal_pointers,no_dead_strip - .globl L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d + .globl L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_9885c1be4d03110d: - .quad L_OBJC_METH_VAR_NAME_9885c1be4d03110d +L_OBJC_SELECTOR_REFERENCES_c76827c00227cd8a: + .quad L_OBJC_METH_VAR_NAME_c76827c00227cd8a .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_msg_send_static_sel/lib.rs b/crates/test-assembly/crates/test_msg_send_static_sel/lib.rs index d72964d1f..632a08655 100644 --- a/crates/test-assembly/crates/test_msg_send_static_sel/lib.rs +++ b/crates/test-assembly/crates/test_msg_send_static_sel/lib.rs @@ -1,16 +1,16 @@ //! Test how static selectors work in relation to `msg_send!` and `msg_send_id!` #![cfg(feature = "apple")] use objc2::rc::Id; -use objc2::runtime::{Class, Object, Sel}; +use objc2::runtime::{AnyClass, AnyObject, Sel}; use objc2::{msg_send, msg_send_id, sel}; #[no_mangle] -unsafe fn handle_with_sel(obj: &Object) -> *mut Object { +unsafe fn handle_with_sel(obj: &AnyObject) -> *mut AnyObject { msg_send![obj, someSelector] } #[no_mangle] -unsafe fn handle_alloc_init(cls: &Class) -> Id { +unsafe fn handle_alloc_init(cls: &AnyClass) -> Id { msg_send_id![msg_send_id![cls, alloc], init] } @@ -19,7 +19,7 @@ fn generic() -> Sel { } #[no_mangle] -unsafe fn use_generic(obj: &Object) { +unsafe fn use_generic(obj: &AnyObject) { let _: () = msg_send![obj, performSelector: generic::()]; let _: () = msg_send![obj, performSelector: generic::()]; let _: () = msg_send![obj, performSelector: generic::()]; diff --git a/crates/test-assembly/crates/test_msg_send_zero_cost/lib.rs b/crates/test-assembly/crates/test_msg_send_zero_cost/lib.rs index 1dd8b1ed0..fdc99090d 100644 --- a/crates/test-assembly/crates/test_msg_send_zero_cost/lib.rs +++ b/crates/test-assembly/crates/test_msg_send_zero_cost/lib.rs @@ -2,11 +2,11 @@ use core::mem; use core::ptr; -use objc2::runtime::{Object, Sel}; +use objc2::runtime::{AnyObject, Sel}; use objc2::MessageReceiver; #[no_mangle] -unsafe fn handle(obj: &Object, sel: Sel) -> *mut Object { +unsafe fn handle(obj: &AnyObject, sel: Sel) -> *mut AnyObject { MessageReceiver::send_message(obj, sel, ()) } @@ -22,6 +22,6 @@ fn selector() -> Sel { } #[no_mangle] -unsafe fn handle_with_sel(obj: &Object) -> *mut Object { +unsafe fn handle_with_sel(obj: &AnyObject) -> *mut AnyObject { MessageReceiver::send_message(obj, selector(), ()) } diff --git a/crates/test-assembly/crates/test_out_parameters/lib.rs b/crates/test-assembly/crates/test_out_parameters/lib.rs index 088b39c70..9bbebcd51 100644 --- a/crates/test-assembly/crates/test_out_parameters/lib.rs +++ b/crates/test-assembly/crates/test_out_parameters/lib.rs @@ -1,34 +1,34 @@ //! Test that out parameters are handled correctly. use objc2::rc::Id; -use objc2::runtime::{Object, Sel}; +use objc2::runtime::{NSObject, Sel}; use objc2::MessageReceiver; #[no_mangle] -unsafe fn nonnull_nonnull(obj: &Object, sel: Sel, param: &mut Id) -> usize { +unsafe fn nonnull_nonnull(obj: &NSObject, sel: Sel, param: &mut Id) -> usize { MessageReceiver::send_message(obj, sel, (param,)) } #[no_mangle] -unsafe fn null_nonnull(obj: &Object, sel: Sel, param: Option<&mut Id>) -> usize { +unsafe fn null_nonnull(obj: &NSObject, sel: Sel, param: Option<&mut Id>) -> usize { MessageReceiver::send_message(obj, sel, (param,)) } #[no_mangle] -unsafe fn nonnull_null(obj: &Object, sel: Sel, param: &mut Option>) -> usize { +unsafe fn nonnull_null(obj: &NSObject, sel: Sel, param: &mut Option>) -> usize { MessageReceiver::send_message(obj, sel, (param,)) } #[no_mangle] -unsafe fn null_null(obj: &Object, sel: Sel, param: Option<&mut Option>>) -> usize { +unsafe fn null_null(obj: &NSObject, sel: Sel, param: Option<&mut Option>>) -> usize { MessageReceiver::send_message(obj, sel, (param,)) } #[no_mangle] unsafe fn two_nonnull_nonnull( - obj: &Object, + obj: &NSObject, sel: Sel, - param1: &mut Id, - param2: &mut Id, + param1: &mut Id, + param2: &mut Id, ) -> usize { MessageReceiver::send_message(obj, sel, (param1, param2)) } @@ -39,25 +39,25 @@ unsafe fn two_nonnull_nonnull( // These should fully avoid any extra `retain/release` #[no_mangle] -unsafe fn call_with_none1(obj: &Object, sel: Sel) -> usize { +unsafe fn call_with_none1(obj: &NSObject, sel: Sel) -> usize { null_nonnull(obj, sel, None) } #[no_mangle] -unsafe fn call_with_none2(obj: &Object, sel: Sel) -> usize { +unsafe fn call_with_none2(obj: &NSObject, sel: Sel) -> usize { null_null(obj, sel, None) } -type Res = (usize, Option>); +type Res = (usize, Option>); // These should only need a `retain` #[no_mangle] -unsafe fn call_with_none3(obj: &Object, sel: Sel) -> Res { +unsafe fn call_with_none3(obj: &NSObject, sel: Sel) -> Res { let mut param = None; let res = nonnull_null(obj, sel, &mut param); (res, param) } #[no_mangle] -unsafe fn call_with_none4(obj: &Object, sel: Sel) -> Res { +unsafe fn call_with_none4(obj: &NSObject, sel: Sel) -> Res { let mut param = None; let res = null_null(obj, sel, Some(&mut param)); (res, param) @@ -65,18 +65,18 @@ unsafe fn call_with_none4(obj: &Object, sel: Sel) -> Res { // These should need `retain/release`, but not have any branches #[no_mangle] -unsafe fn call_with_some1(obj: &Object, sel: Sel, mut param: Id) -> Res { +unsafe fn call_with_some1(obj: &NSObject, sel: Sel, mut param: Id) -> Res { let res = null_nonnull(obj, sel, Some(&mut param)); (res, Some(param)) } #[no_mangle] -unsafe fn call_with_some2(obj: &Object, sel: Sel, param: Id) -> Res { +unsafe fn call_with_some2(obj: &NSObject, sel: Sel, param: Id) -> Res { let mut param = Some(param); let res = nonnull_null(obj, sel, &mut param); (res, param) } #[no_mangle] -unsafe fn call_with_some3(obj: &Object, sel: Sel, param: Id) -> Res { +unsafe fn call_with_some3(obj: &NSObject, sel: Sel, param: Id) -> Res { let mut param = Some(param); let res = null_null(obj, sel, Some(&mut param)); (res, param) diff --git a/crates/test-assembly/crates/test_retain_autoreleased/lib.rs b/crates/test-assembly/crates/test_retain_autoreleased/lib.rs index 6d771f860..3dd160846 100644 --- a/crates/test-assembly/crates/test_retain_autoreleased/lib.rs +++ b/crates/test-assembly/crates/test_retain_autoreleased/lib.rs @@ -1,11 +1,11 @@ //! Test that `Id::retain_autoreleased` is inlined properly. use objc2::rc::Id; -use objc2::runtime::{Object, Sel}; +use objc2::runtime::{AnyObject, Sel}; use objc2::MessageReceiver; #[no_mangle] -unsafe fn handle(obj: &Object, sel: Sel) -> Option> { - let ptr: *mut Object = MessageReceiver::send_message(obj, sel, ()); +unsafe fn handle(obj: &AnyObject, sel: Sel) -> Option> { + let ptr: *mut AnyObject = MessageReceiver::send_message(obj, sel, ()); Id::retain_autoreleased(ptr) } diff --git a/crates/test-assembly/crates/test_static_class/expected/apple-aarch64.s b/crates/test-assembly/crates/test_static_class/expected/apple-aarch64.s index 7ffdf816c..02ad46f63 100644 --- a/crates/test-assembly/crates/test_static_class/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_static_class/expected/apple-aarch64.s @@ -3,9 +3,9 @@ .p2align 2 _get_class: Lloh0: - adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474@PAGE + adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777@PAGE Lloh1: - ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474@PAGEOFF] + ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777@PAGEOFF] ret .loh AdrpLdr Lloh0, Lloh1 @@ -13,9 +13,9 @@ Lloh1: .p2align 2 _get_same_class: Lloh2: - adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6@PAGE + adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07@PAGE Lloh3: - ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6@PAGEOFF] + ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07@PAGEOFF] ret .loh AdrpLdr Lloh2, Lloh3 @@ -23,9 +23,9 @@ Lloh3: .p2align 2 _get_different_class: Lloh4: - adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4@PAGE + adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b@PAGE Lloh5: - ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4@PAGEOFF] + ldr x0, [x8, L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b@PAGEOFF] ret .loh AdrpLdr Lloh4, Lloh5 @@ -38,21 +38,21 @@ _unused_sel: .p2align 2 _use_fns: Lloh6: - adrp x9, L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474@PAGE + adrp x9, L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777@PAGE Lloh7: - ldr x9, [x9, L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474@PAGEOFF] + ldr x9, [x9, L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777@PAGEOFF] Lloh8: - adrp x10, L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6@PAGE + adrp x10, L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07@PAGE Lloh9: - ldr x10, [x10, L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6@PAGEOFF] + ldr x10, [x10, L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07@PAGEOFF] Lloh10: - adrp x11, L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4@PAGE + adrp x11, L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b@PAGE Lloh11: - ldr x11, [x11, L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4@PAGEOFF] + ldr x11, [x11, L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b@PAGEOFF] Lloh12: - adrp x12, L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3@PAGE + adrp x12, L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb@PAGE Lloh13: - ldr x12, [x12, L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3@PAGEOFF] + ldr x12, [x12, L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb@PAGEOFF] stp x9, x10, [x8] stp x11, x12, [x8, #16] ret @@ -65,9 +65,9 @@ Lloh13: .p2align 2 _use_same_twice: Lloh14: - adrp x9, L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474@PAGE + adrp x9, L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777@PAGE Lloh15: - ldr x9, [x9, L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474@PAGEOFF] + ldr x9, [x9, L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777@PAGEOFF] stp x9, x9, [x8] ret .loh AdrpLdr Lloh14, Lloh15 @@ -78,75 +78,75 @@ _use_in_loop: ret .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_49a0cd2a35b9a474 + .globl L_OBJC_IMAGE_INFO_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_49a0cd2a35b9a474: +L_OBJC_IMAGE_INFO_928cf03fcc497777: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474 + .globl L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777 .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474: +L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777: .quad _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_60860b498061fbc6 + .globl L_OBJC_IMAGE_INFO_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_60860b498061fbc6: +L_OBJC_IMAGE_INFO_2fe1990982915f07: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6 + .globl L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07 .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6: +L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07: .quad _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_089cee9fe04089a4 + .globl L_OBJC_IMAGE_INFO_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_089cee9fe04089a4: +L_OBJC_IMAGE_INFO_dfff3a06c0bf722b: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4 + .globl L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4: +L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b: .quad _OBJC_CLASS_$_NSString .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_5331bb309754c706 + .globl L_OBJC_IMAGE_INFO_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_5331bb309754c706: +L_OBJC_IMAGE_INFO_f6e054106fdbe219: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706 + .globl L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219 .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706: +L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219: .quad _OBJC_CLASS_$_NSData .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3 + .globl L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3: +L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3 + .globl L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3: +L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb: .quad _OBJC_CLASS_$_NSException .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf + .globl L_OBJC_IMAGE_INFO_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf: +L_OBJC_IMAGE_INFO_54ecac6d305d112a: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf + .globl L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf: +L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a: .quad _OBJC_CLASS_$_NSLock .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_static_class/expected/apple-armv7.s b/crates/test-assembly/crates/test_static_class/expected/apple-armv7.s index 1e43bbc21..4e7dfaa83 100644 --- a/crates/test-assembly/crates/test_static_class/expected/apple-armv7.s +++ b/crates/test-assembly/crates/test_static_class/expected/apple-armv7.s @@ -4,8 +4,8 @@ .p2align 2 .code 32 _get_class: - movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC0_0+8)) - movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC0_0+8)) + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC0_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC0_0+8)) LPC0_0: ldr r0, [pc, r0] bx lr @@ -14,8 +14,8 @@ LPC0_0: .p2align 2 .code 32 _get_same_class: - movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC1_0+8)) - movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC1_0+8)) + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC1_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC1_0+8)) LPC1_0: ldr r0, [pc, r0] bx lr @@ -24,8 +24,8 @@ LPC1_0: .p2align 2 .code 32 _get_different_class: - movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC2_0+8)) - movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC2_0+8)) + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC2_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC2_0+8)) LPC2_0: ldr r0, [pc, r0] bx lr @@ -40,20 +40,20 @@ _unused_sel: .p2align 2 .code 32 _use_fns: - movw r9, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3-(LPC4_0+8)) - movt r9, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3-(LPC4_0+8)) + movw r9, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb-(LPC4_0+8)) + movt r9, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb-(LPC4_0+8)) LPC4_0: ldr r9, [pc, r9] - movw r2, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC4_1+8)) - movt r2, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC4_1+8)) + movw r2, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC4_1+8)) + movt r2, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC4_1+8)) LPC4_1: ldr r2, [pc, r2] - movw r3, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC4_2+8)) - movt r3, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC4_2+8)) + movw r3, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC4_2+8)) + movt r3, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC4_2+8)) LPC4_2: ldr r3, [pc, r3] - movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC4_3+8)) - movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC4_3+8)) + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC4_3+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC4_3+8)) str r2, [r0, #8] LPC4_3: ldr r1, [pc, r1] @@ -65,8 +65,8 @@ LPC4_3: .p2align 2 .code 32 _use_same_twice: - movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC5_0+8)) - movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC5_0+8)) + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC5_0+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC5_0+8)) LPC5_0: ldr r1, [pc, r1] str r1, [r0] @@ -80,75 +80,75 @@ _use_in_loop: bx lr .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_49a0cd2a35b9a474 + .globl L_OBJC_IMAGE_INFO_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_49a0cd2a35b9a474: +L_OBJC_IMAGE_INFO_928cf03fcc497777: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474 + .globl L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474: +L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777: .long _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_60860b498061fbc6 + .globl L_OBJC_IMAGE_INFO_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_60860b498061fbc6: +L_OBJC_IMAGE_INFO_2fe1990982915f07: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6 + .globl L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6: +L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07: .long _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_089cee9fe04089a4 + .globl L_OBJC_IMAGE_INFO_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_089cee9fe04089a4: +L_OBJC_IMAGE_INFO_dfff3a06c0bf722b: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4 + .globl L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4: +L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b: .long _OBJC_CLASS_$_NSString .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_5331bb309754c706 + .globl L_OBJC_IMAGE_INFO_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_5331bb309754c706: +L_OBJC_IMAGE_INFO_f6e054106fdbe219: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706 + .globl L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706: +L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219: .long _OBJC_CLASS_$_NSData .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3 + .globl L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3: +L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3 + .globl L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3: +L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb: .long _OBJC_CLASS_$_NSException .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf + .globl L_OBJC_IMAGE_INFO_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf: +L_OBJC_IMAGE_INFO_54ecac6d305d112a: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf + .globl L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf: +L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a: .long _OBJC_CLASS_$_NSLock .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_static_class/expected/apple-armv7s.s b/crates/test-assembly/crates/test_static_class/expected/apple-armv7s.s index 1e43bbc21..4e7dfaa83 100644 --- a/crates/test-assembly/crates/test_static_class/expected/apple-armv7s.s +++ b/crates/test-assembly/crates/test_static_class/expected/apple-armv7s.s @@ -4,8 +4,8 @@ .p2align 2 .code 32 _get_class: - movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC0_0+8)) - movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC0_0+8)) + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC0_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC0_0+8)) LPC0_0: ldr r0, [pc, r0] bx lr @@ -14,8 +14,8 @@ LPC0_0: .p2align 2 .code 32 _get_same_class: - movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC1_0+8)) - movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC1_0+8)) + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC1_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC1_0+8)) LPC1_0: ldr r0, [pc, r0] bx lr @@ -24,8 +24,8 @@ LPC1_0: .p2align 2 .code 32 _get_different_class: - movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC2_0+8)) - movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC2_0+8)) + movw r0, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC2_0+8)) + movt r0, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC2_0+8)) LPC2_0: ldr r0, [pc, r0] bx lr @@ -40,20 +40,20 @@ _unused_sel: .p2align 2 .code 32 _use_fns: - movw r9, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3-(LPC4_0+8)) - movt r9, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3-(LPC4_0+8)) + movw r9, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb-(LPC4_0+8)) + movt r9, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb-(LPC4_0+8)) LPC4_0: ldr r9, [pc, r9] - movw r2, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC4_1+8)) - movt r2, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-(LPC4_1+8)) + movw r2, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC4_1+8)) + movt r2, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-(LPC4_1+8)) LPC4_1: ldr r2, [pc, r2] - movw r3, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC4_2+8)) - movt r3, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-(LPC4_2+8)) + movw r3, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC4_2+8)) + movt r3, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-(LPC4_2+8)) LPC4_2: ldr r3, [pc, r3] - movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC4_3+8)) - movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC4_3+8)) + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC4_3+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC4_3+8)) str r2, [r0, #8] LPC4_3: ldr r1, [pc, r1] @@ -65,8 +65,8 @@ LPC4_3: .p2align 2 .code 32 _use_same_twice: - movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC5_0+8)) - movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-(LPC5_0+8)) + movw r1, :lower16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC5_0+8)) + movt r1, :upper16:(L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-(LPC5_0+8)) LPC5_0: ldr r1, [pc, r1] str r1, [r0] @@ -80,75 +80,75 @@ _use_in_loop: bx lr .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_49a0cd2a35b9a474 + .globl L_OBJC_IMAGE_INFO_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_49a0cd2a35b9a474: +L_OBJC_IMAGE_INFO_928cf03fcc497777: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474 + .globl L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474: +L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777: .long _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_60860b498061fbc6 + .globl L_OBJC_IMAGE_INFO_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_60860b498061fbc6: +L_OBJC_IMAGE_INFO_2fe1990982915f07: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6 + .globl L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6: +L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07: .long _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_089cee9fe04089a4 + .globl L_OBJC_IMAGE_INFO_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_089cee9fe04089a4: +L_OBJC_IMAGE_INFO_dfff3a06c0bf722b: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4 + .globl L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4: +L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b: .long _OBJC_CLASS_$_NSString .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_5331bb309754c706 + .globl L_OBJC_IMAGE_INFO_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_5331bb309754c706: +L_OBJC_IMAGE_INFO_f6e054106fdbe219: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706 + .globl L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706: +L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219: .long _OBJC_CLASS_$_NSData .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3 + .globl L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3: +L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3 + .globl L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3: +L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb: .long _OBJC_CLASS_$_NSException .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf + .globl L_OBJC_IMAGE_INFO_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf: +L_OBJC_IMAGE_INFO_54ecac6d305d112a: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf + .globl L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf: +L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a: .long _OBJC_CLASS_$_NSLock .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_static_class/expected/apple-old-x86.s b/crates/test-assembly/crates/test_static_class/expected/apple-old-x86.s index db10dc265..fc372098f 100644 --- a/crates/test-assembly/crates/test_static_class/expected/apple-old-x86.s +++ b/crates/test-assembly/crates/test_static_class/expected/apple-old-x86.s @@ -8,7 +8,7 @@ _get_class: call L0$pb L0$pb: pop eax - mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_49a0cd2a35b9a474-L0$pb] + mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_928cf03fcc497777-L0$pb] pop ebp ret @@ -20,7 +20,7 @@ _get_same_class: call L1$pb L1$pb: pop eax - mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_60860b498061fbc6-L1$pb] + mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_2fe1990982915f07-L1$pb] pop ebp ret @@ -32,7 +32,7 @@ _get_different_class: call L2$pb L2$pb: pop eax - mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_089cee9fe04089a4-L2$pb] + mov eax, dword ptr [eax + L_OBJC_CLASS_REFERENCES_dfff3a06c0bf722b-L2$pb] pop ebp ret @@ -55,10 +55,10 @@ _use_fns: L4$pb: pop ecx mov eax, dword ptr [ebp + 8] - mov edx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_49a0cd2a35b9a474-L4$pb] - mov esi, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_60860b498061fbc6-L4$pb] - mov edi, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_089cee9fe04089a4-L4$pb] - mov ecx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_15b3f8b356e4fdb3-L4$pb] + mov edx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_928cf03fcc497777-L4$pb] + mov esi, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_2fe1990982915f07-L4$pb] + mov edi, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_dfff3a06c0bf722b-L4$pb] + mov ecx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_5ab5a81fcf2763fb-L4$pb] mov dword ptr [eax], edx mov dword ptr [eax + 4], esi mov dword ptr [eax + 8], edi @@ -77,7 +77,7 @@ _use_same_twice: L5$pb: pop ecx mov eax, dword ptr [ebp + 8] - mov ecx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_49a0cd2a35b9a474-L5$pb] + mov ecx, dword ptr [ecx + L_OBJC_CLASS_REFERENCES_928cf03fcc497777-L5$pb] mov dword ptr [eax], ecx mov dword ptr [eax + 4], ecx pop ebp @@ -92,183 +92,183 @@ _use_in_loop: ret .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_49a0cd2a35b9a474 + .globl L_OBJC_IMAGE_INFO_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_49a0cd2a35b9a474: +L_OBJC_IMAGE_INFO_928cf03fcc497777: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_49a0cd2a35b9a474 -L_OBJC_CLASS_NAME_49a0cd2a35b9a474: + .globl L_OBJC_CLASS_NAME_928cf03fcc497777 +L_OBJC_CLASS_NAME_928cf03fcc497777: .ascii "NSObject" .section __OBJC,__cls_refs,literal_pointers,no_dead_strip - .globl L_OBJC_CLASS_REFERENCES_49a0cd2a35b9a474 + .globl L_OBJC_CLASS_REFERENCES_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_CLASS_REFERENCES_49a0cd2a35b9a474: - .long L_OBJC_CLASS_NAME_49a0cd2a35b9a474 +L_OBJC_CLASS_REFERENCES_928cf03fcc497777: + .long L_OBJC_CLASS_NAME_928cf03fcc497777 .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_49a0cd2a35b9a474_MODULE_INFO -L_OBJC_CLASS_NAME_49a0cd2a35b9a474_MODULE_INFO: + .globl L_OBJC_CLASS_NAME_928cf03fcc497777_MODULE_INFO +L_OBJC_CLASS_NAME_928cf03fcc497777_MODULE_INFO: .space 1 .section __OBJC,__module_info,regular,no_dead_strip - .globl L_OBJC_MODULES_49a0cd2a35b9a474 + .globl L_OBJC_MODULES_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_MODULES_49a0cd2a35b9a474: +L_OBJC_MODULES_928cf03fcc497777: .asciz "\007\000\000\000\020\000\000" - .long L_OBJC_CLASS_NAME_49a0cd2a35b9a474_MODULE_INFO + .long L_OBJC_CLASS_NAME_928cf03fcc497777_MODULE_INFO .space 4 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_60860b498061fbc6 + .globl L_OBJC_IMAGE_INFO_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_60860b498061fbc6: +L_OBJC_IMAGE_INFO_2fe1990982915f07: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_60860b498061fbc6 -L_OBJC_CLASS_NAME_60860b498061fbc6: + .globl L_OBJC_CLASS_NAME_2fe1990982915f07 +L_OBJC_CLASS_NAME_2fe1990982915f07: .ascii "NSObject" .section __OBJC,__cls_refs,literal_pointers,no_dead_strip - .globl L_OBJC_CLASS_REFERENCES_60860b498061fbc6 + .globl L_OBJC_CLASS_REFERENCES_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_CLASS_REFERENCES_60860b498061fbc6: - .long L_OBJC_CLASS_NAME_60860b498061fbc6 +L_OBJC_CLASS_REFERENCES_2fe1990982915f07: + .long L_OBJC_CLASS_NAME_2fe1990982915f07 .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_60860b498061fbc6_MODULE_INFO -L_OBJC_CLASS_NAME_60860b498061fbc6_MODULE_INFO: + .globl L_OBJC_CLASS_NAME_2fe1990982915f07_MODULE_INFO +L_OBJC_CLASS_NAME_2fe1990982915f07_MODULE_INFO: .space 1 .section __OBJC,__module_info,regular,no_dead_strip - .globl L_OBJC_MODULES_60860b498061fbc6 + .globl L_OBJC_MODULES_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_MODULES_60860b498061fbc6: +L_OBJC_MODULES_2fe1990982915f07: .asciz "\007\000\000\000\020\000\000" - .long L_OBJC_CLASS_NAME_60860b498061fbc6_MODULE_INFO + .long L_OBJC_CLASS_NAME_2fe1990982915f07_MODULE_INFO .space 4 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_089cee9fe04089a4 + .globl L_OBJC_IMAGE_INFO_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_089cee9fe04089a4: +L_OBJC_IMAGE_INFO_dfff3a06c0bf722b: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_089cee9fe04089a4 -L_OBJC_CLASS_NAME_089cee9fe04089a4: + .globl L_OBJC_CLASS_NAME_dfff3a06c0bf722b +L_OBJC_CLASS_NAME_dfff3a06c0bf722b: .ascii "NSString" .section __OBJC,__cls_refs,literal_pointers,no_dead_strip - .globl L_OBJC_CLASS_REFERENCES_089cee9fe04089a4 + .globl L_OBJC_CLASS_REFERENCES_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_CLASS_REFERENCES_089cee9fe04089a4: - .long L_OBJC_CLASS_NAME_089cee9fe04089a4 +L_OBJC_CLASS_REFERENCES_dfff3a06c0bf722b: + .long L_OBJC_CLASS_NAME_dfff3a06c0bf722b .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_089cee9fe04089a4_MODULE_INFO -L_OBJC_CLASS_NAME_089cee9fe04089a4_MODULE_INFO: + .globl L_OBJC_CLASS_NAME_dfff3a06c0bf722b_MODULE_INFO +L_OBJC_CLASS_NAME_dfff3a06c0bf722b_MODULE_INFO: .space 1 .section __OBJC,__module_info,regular,no_dead_strip - .globl L_OBJC_MODULES_089cee9fe04089a4 + .globl L_OBJC_MODULES_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_MODULES_089cee9fe04089a4: +L_OBJC_MODULES_dfff3a06c0bf722b: .asciz "\007\000\000\000\020\000\000" - .long L_OBJC_CLASS_NAME_089cee9fe04089a4_MODULE_INFO + .long L_OBJC_CLASS_NAME_dfff3a06c0bf722b_MODULE_INFO .space 4 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_5331bb309754c706 + .globl L_OBJC_IMAGE_INFO_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_5331bb309754c706: +L_OBJC_IMAGE_INFO_f6e054106fdbe219: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_5331bb309754c706 -L_OBJC_CLASS_NAME_5331bb309754c706: + .globl L_OBJC_CLASS_NAME_f6e054106fdbe219 +L_OBJC_CLASS_NAME_f6e054106fdbe219: .ascii "NSData" .section __OBJC,__cls_refs,literal_pointers,no_dead_strip - .globl L_OBJC_CLASS_REFERENCES_5331bb309754c706 + .globl L_OBJC_CLASS_REFERENCES_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_CLASS_REFERENCES_5331bb309754c706: - .long L_OBJC_CLASS_NAME_5331bb309754c706 +L_OBJC_CLASS_REFERENCES_f6e054106fdbe219: + .long L_OBJC_CLASS_NAME_f6e054106fdbe219 .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_5331bb309754c706_MODULE_INFO -L_OBJC_CLASS_NAME_5331bb309754c706_MODULE_INFO: + .globl L_OBJC_CLASS_NAME_f6e054106fdbe219_MODULE_INFO +L_OBJC_CLASS_NAME_f6e054106fdbe219_MODULE_INFO: .space 1 .section __OBJC,__module_info,regular,no_dead_strip - .globl L_OBJC_MODULES_5331bb309754c706 + .globl L_OBJC_MODULES_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_MODULES_5331bb309754c706: +L_OBJC_MODULES_f6e054106fdbe219: .asciz "\007\000\000\000\020\000\000" - .long L_OBJC_CLASS_NAME_5331bb309754c706_MODULE_INFO + .long L_OBJC_CLASS_NAME_f6e054106fdbe219_MODULE_INFO .space 4 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3 + .globl L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3: +L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_15b3f8b356e4fdb3 -L_OBJC_CLASS_NAME_15b3f8b356e4fdb3: + .globl L_OBJC_CLASS_NAME_5ab5a81fcf2763fb +L_OBJC_CLASS_NAME_5ab5a81fcf2763fb: .ascii "NSException" .section __OBJC,__cls_refs,literal_pointers,no_dead_strip - .globl L_OBJC_CLASS_REFERENCES_15b3f8b356e4fdb3 + .globl L_OBJC_CLASS_REFERENCES_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_CLASS_REFERENCES_15b3f8b356e4fdb3: - .long L_OBJC_CLASS_NAME_15b3f8b356e4fdb3 +L_OBJC_CLASS_REFERENCES_5ab5a81fcf2763fb: + .long L_OBJC_CLASS_NAME_5ab5a81fcf2763fb .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_15b3f8b356e4fdb3_MODULE_INFO -L_OBJC_CLASS_NAME_15b3f8b356e4fdb3_MODULE_INFO: + .globl L_OBJC_CLASS_NAME_5ab5a81fcf2763fb_MODULE_INFO +L_OBJC_CLASS_NAME_5ab5a81fcf2763fb_MODULE_INFO: .space 1 .section __OBJC,__module_info,regular,no_dead_strip - .globl L_OBJC_MODULES_15b3f8b356e4fdb3 + .globl L_OBJC_MODULES_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_MODULES_15b3f8b356e4fdb3: +L_OBJC_MODULES_5ab5a81fcf2763fb: .asciz "\007\000\000\000\020\000\000" - .long L_OBJC_CLASS_NAME_15b3f8b356e4fdb3_MODULE_INFO + .long L_OBJC_CLASS_NAME_5ab5a81fcf2763fb_MODULE_INFO .space 4 .section __OBJC,__image_info - .globl L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf + .globl L_OBJC_IMAGE_INFO_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf: +L_OBJC_IMAGE_INFO_54ecac6d305d112a: .asciz "\000\000\000\000@\000\000" .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_4fe8a7873c5b5bcf -L_OBJC_CLASS_NAME_4fe8a7873c5b5bcf: + .globl L_OBJC_CLASS_NAME_54ecac6d305d112a +L_OBJC_CLASS_NAME_54ecac6d305d112a: .ascii "NSLock" .section __OBJC,__cls_refs,literal_pointers,no_dead_strip - .globl L_OBJC_CLASS_REFERENCES_4fe8a7873c5b5bcf + .globl L_OBJC_CLASS_REFERENCES_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_CLASS_REFERENCES_4fe8a7873c5b5bcf: - .long L_OBJC_CLASS_NAME_4fe8a7873c5b5bcf +L_OBJC_CLASS_REFERENCES_54ecac6d305d112a: + .long L_OBJC_CLASS_NAME_54ecac6d305d112a .section __TEXT,__cstring,cstring_literals - .globl L_OBJC_CLASS_NAME_4fe8a7873c5b5bcf_MODULE_INFO -L_OBJC_CLASS_NAME_4fe8a7873c5b5bcf_MODULE_INFO: + .globl L_OBJC_CLASS_NAME_54ecac6d305d112a_MODULE_INFO +L_OBJC_CLASS_NAME_54ecac6d305d112a_MODULE_INFO: .space 1 .section __OBJC,__module_info,regular,no_dead_strip - .globl L_OBJC_MODULES_4fe8a7873c5b5bcf + .globl L_OBJC_MODULES_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_MODULES_4fe8a7873c5b5bcf: +L_OBJC_MODULES_54ecac6d305d112a: .asciz "\007\000\000\000\020\000\000" - .long L_OBJC_CLASS_NAME_4fe8a7873c5b5bcf_MODULE_INFO + .long L_OBJC_CLASS_NAME_54ecac6d305d112a_MODULE_INFO .space 4 .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_static_class/expected/apple-x86.s b/crates/test-assembly/crates/test_static_class/expected/apple-x86.s index 344b80358..52c1bb6ea 100644 --- a/crates/test-assembly/crates/test_static_class/expected/apple-x86.s +++ b/crates/test-assembly/crates/test_static_class/expected/apple-x86.s @@ -8,7 +8,7 @@ _get_class: call L0$pb L0$pb: pop eax - mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-L0$pb] + mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-L0$pb] pop ebp ret @@ -20,7 +20,7 @@ _get_same_class: call L1$pb L1$pb: pop eax - mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-L1$pb] + mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-L1$pb] pop ebp ret @@ -32,7 +32,7 @@ _get_different_class: call L2$pb L2$pb: pop eax - mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-L2$pb] + mov eax, dword ptr [eax + L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-L2$pb] pop ebp ret @@ -55,10 +55,10 @@ _use_fns: L4$pb: pop ecx mov eax, dword ptr [ebp + 8] - mov edx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-L4$pb] - mov esi, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6-L4$pb] - mov edi, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4-L4$pb] - mov ecx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3-L4$pb] + mov edx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-L4$pb] + mov esi, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07-L4$pb] + mov edi, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b-L4$pb] + mov ecx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb-L4$pb] mov dword ptr [eax], edx mov dword ptr [eax + 4], esi mov dword ptr [eax + 8], edi @@ -77,7 +77,7 @@ _use_same_twice: L5$pb: pop ecx mov eax, dword ptr [ebp + 8] - mov ecx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474-L5$pb] + mov ecx, dword ptr [ecx + L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777-L5$pb] mov dword ptr [eax], ecx mov dword ptr [eax + 4], ecx pop ebp @@ -92,75 +92,75 @@ _use_in_loop: ret .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_49a0cd2a35b9a474 + .globl L_OBJC_IMAGE_INFO_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_49a0cd2a35b9a474: +L_OBJC_IMAGE_INFO_928cf03fcc497777: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474 + .globl L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474: +L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777: .long _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_60860b498061fbc6 + .globl L_OBJC_IMAGE_INFO_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_60860b498061fbc6: +L_OBJC_IMAGE_INFO_2fe1990982915f07: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6 + .globl L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6: +L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07: .long _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_089cee9fe04089a4 + .globl L_OBJC_IMAGE_INFO_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_089cee9fe04089a4: +L_OBJC_IMAGE_INFO_dfff3a06c0bf722b: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4 + .globl L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4: +L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b: .long _OBJC_CLASS_$_NSString .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_5331bb309754c706 + .globl L_OBJC_IMAGE_INFO_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_5331bb309754c706: +L_OBJC_IMAGE_INFO_f6e054106fdbe219: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706 + .globl L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706: +L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219: .long _OBJC_CLASS_$_NSData .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3 + .globl L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3: +L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3 + .globl L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3: +L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb: .long _OBJC_CLASS_$_NSException .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf + .globl L_OBJC_IMAGE_INFO_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf: +L_OBJC_IMAGE_INFO_54ecac6d305d112a: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf + .globl L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf: +L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a: .long _OBJC_CLASS_$_NSLock .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_static_class/expected/apple-x86_64.s b/crates/test-assembly/crates/test_static_class/expected/apple-x86_64.s index 22a0b867b..09d7ffe07 100644 --- a/crates/test-assembly/crates/test_static_class/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_static_class/expected/apple-x86_64.s @@ -5,7 +5,7 @@ _get_class: push rbp mov rbp, rsp - mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474] + mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777] pop rbp ret @@ -14,7 +14,7 @@ _get_class: _get_same_class: push rbp mov rbp, rsp - mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6] + mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07] pop rbp ret @@ -23,7 +23,7 @@ _get_same_class: _get_different_class: push rbp mov rbp, rsp - mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4] + mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b] pop rbp ret @@ -41,10 +41,10 @@ _use_fns: push rbp mov rbp, rsp mov rax, rdi - mov rcx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474] - mov rdx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6] - mov rsi, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4] - mov rdi, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3] + mov rcx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777] + mov rdx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07] + mov rsi, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b] + mov rdi, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb] mov qword ptr [rax], rcx mov qword ptr [rax + 8], rdx mov qword ptr [rax + 16], rsi @@ -58,7 +58,7 @@ _use_same_twice: push rbp mov rbp, rsp mov rax, rdi - mov rcx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474] + mov rcx, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777] mov qword ptr [rdi], rcx mov qword ptr [rdi + 8], rcx pop rbp @@ -73,75 +73,75 @@ _use_in_loop: ret .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_49a0cd2a35b9a474 + .globl L_OBJC_IMAGE_INFO_928cf03fcc497777 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_49a0cd2a35b9a474: +L_OBJC_IMAGE_INFO_928cf03fcc497777: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474 + .globl L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777 .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_49a0cd2a35b9a474: +L_OBJC_CLASSLIST_REFERENCES_$_928cf03fcc497777: .quad _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_60860b498061fbc6 + .globl L_OBJC_IMAGE_INFO_2fe1990982915f07 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_60860b498061fbc6: +L_OBJC_IMAGE_INFO_2fe1990982915f07: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6 + .globl L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07 .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_60860b498061fbc6: +L_OBJC_CLASSLIST_REFERENCES_$_2fe1990982915f07: .quad _OBJC_CLASS_$_NSObject .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_089cee9fe04089a4 + .globl L_OBJC_IMAGE_INFO_dfff3a06c0bf722b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_089cee9fe04089a4: +L_OBJC_IMAGE_INFO_dfff3a06c0bf722b: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4 + .globl L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_089cee9fe04089a4: +L_OBJC_CLASSLIST_REFERENCES_$_dfff3a06c0bf722b: .quad _OBJC_CLASS_$_NSString .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_5331bb309754c706 + .globl L_OBJC_IMAGE_INFO_f6e054106fdbe219 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_5331bb309754c706: +L_OBJC_IMAGE_INFO_f6e054106fdbe219: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706 + .globl L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219 .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_5331bb309754c706: +L_OBJC_CLASSLIST_REFERENCES_$_f6e054106fdbe219: .quad _OBJC_CLASS_$_NSData .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3 + .globl L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_15b3f8b356e4fdb3: +L_OBJC_IMAGE_INFO_5ab5a81fcf2763fb: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3 + .globl L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_15b3f8b356e4fdb3: +L_OBJC_CLASSLIST_REFERENCES_$_5ab5a81fcf2763fb: .quad _OBJC_CLASS_$_NSException .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf + .globl L_OBJC_IMAGE_INFO_54ecac6d305d112a .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4fe8a7873c5b5bcf: +L_OBJC_IMAGE_INFO_54ecac6d305d112a: .asciz "\000\000\000\000@\000\000" .section __DATA,__objc_classrefs,regular,no_dead_strip - .globl L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf + .globl L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a .p2align 3, 0x0 -L_OBJC_CLASSLIST_REFERENCES_$_4fe8a7873c5b5bcf: +L_OBJC_CLASSLIST_REFERENCES_$_54ecac6d305d112a: .quad _OBJC_CLASS_$_NSLock .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_static_class/lib.rs b/crates/test-assembly/crates/test_static_class/lib.rs index 14146f44f..f31920d42 100644 --- a/crates/test-assembly/crates/test_static_class/lib.rs +++ b/crates/test-assembly/crates/test_static_class/lib.rs @@ -1,20 +1,20 @@ //! Test the output of the `class!` macro. #![cfg(feature = "apple")] use objc2::class; -use objc2::runtime::Class; +use objc2::runtime::AnyClass; #[no_mangle] -fn get_class() -> &'static Class { +fn get_class() -> &'static AnyClass { class!(NSObject) } #[no_mangle] -fn get_same_class() -> &'static Class { +fn get_same_class() -> &'static AnyClass { class!(NSObject) } #[no_mangle] -fn get_different_class() -> &'static Class { +fn get_different_class() -> &'static AnyClass { class!(NSString) } @@ -24,7 +24,7 @@ fn unused_sel() { } #[no_mangle] -fn use_fns() -> [&'static Class; 4] { +fn use_fns() -> [&'static AnyClass; 4] { let s1 = get_class(); let s2 = get_same_class(); let s3 = get_different_class(); @@ -33,7 +33,7 @@ fn use_fns() -> [&'static Class; 4] { } #[no_mangle] -fn use_same_twice() -> [&'static Class; 2] { +fn use_same_twice() -> [&'static AnyClass; 2] { // Should not need to load twice [get_class(), get_class()] } diff --git a/crates/test-fuzz/fuzz_targets/class.rs b/crates/test-fuzz/fuzz_targets/class.rs index 24f7511b2..c740223f9 100644 --- a/crates/test-fuzz/fuzz_targets/class.rs +++ b/crates/test-fuzz/fuzz_targets/class.rs @@ -1,6 +1,6 @@ #![no_main] use libfuzzer_sys::fuzz_target; -use objc2::runtime::Class; +use objc2::runtime::AnyClass; use std::ffi::CString; fuzz_target!(|s: &str| { @@ -9,7 +9,7 @@ fuzz_target!(|s: &str| { if CString::new(s).is_ok() { #[allow(clippy::eq_op)] - if let Some(cls) = Class::get(s) { + if let Some(cls) = AnyClass::get(s) { assert_eq!(s, cls.name()); assert_eq!(cls, cls); } diff --git a/crates/test-ui/ui/add_method_no_bool.rs b/crates/test-ui/ui/add_method_no_bool.rs index 4dad34f42..4e31676bd 100644 --- a/crates/test-ui/ui/add_method_no_bool.rs +++ b/crates/test-ui/ui/add_method_no_bool.rs @@ -2,12 +2,12 @@ //! //! This is not sound without a conversion step. use objc2::declare::ClassBuilder; -use objc2::runtime::{Object, Sel}; +use objc2::runtime::{NSObject, Sel}; use objc2::sel; -extern "C" fn my_bool_taking_method(obj: &Object, sel: Sel, arg: bool) {} +extern "C" fn my_bool_taking_method(obj: &NSObject, sel: Sel, arg: bool) {} -extern "C" fn my_bool_returning_method(obj: &Object, sel: Sel) -> bool { +extern "C" fn my_bool_returning_method(obj: &NSObject, sel: Sel) -> bool { true } diff --git a/crates/test-ui/ui/add_method_no_bool.stderr b/crates/test-ui/ui/add_method_no_bool.stderr index 646f734a1..0d9da37e5 100644 --- a/crates/test-ui/ui/add_method_no_bool.stderr +++ b/crates/test-ui/ui/add_method_no_bool.stderr @@ -16,7 +16,7 @@ error[E0277]: the trait bound `bool: Encode` is not satisfied AtomicI16 AtomicI32 and $N others - = note: required for `unsafe extern "C" fn(&objc2::runtime::Object, objc2::runtime::Sel, bool)` to implement `MethodImplementation` + = note: required for `unsafe extern "C" fn(&NSObject, objc2::runtime::Sel, bool)` to implement `MethodImplementation` note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs | @@ -45,7 +45,7 @@ error[E0277]: the trait bound `bool: Encode` is not satisfied AtomicI32 and $N others = note: required for `bool` to implement `EncodeReturn` - = note: required for `unsafe extern "C" fn(&objc2::runtime::Object, objc2::runtime::Sel) -> bool` to implement `MethodImplementation` + = note: required for `unsafe extern "C" fn(&NSObject, objc2::runtime::Sel) -> bool` to implement `MethodImplementation` note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs | diff --git a/crates/test-ui/ui/declare_add_bad_method.stderr b/crates/test-ui/ui/declare_add_bad_method.stderr index 3638a61d4..a76a500b8 100644 --- a/crates/test-ui/ui/declare_add_bad_method.stderr +++ b/crates/test-ui/ui/declare_add_bad_method.stderr @@ -7,14 +7,14 @@ error[E0277]: the trait bound `fn(_, _): MethodImplementation` is not satisfied | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -34,14 +34,14 @@ error[E0277]: the trait bound `fn(_, _): MethodImplementation` is not satisfied | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -61,14 +61,14 @@ error[E0277]: the trait bound `fn(_, _) -> _: MethodImplementation` is not satis | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -88,14 +88,14 @@ error[E0277]: the trait bound `fn(_, _) -> _: MethodImplementation` is not satis | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -115,14 +115,14 @@ error[E0277]: the trait bound `fn(_, _, _): MethodImplementation` is not satisfi | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs diff --git a/crates/test-ui/ui/declare_class_invalid_receiver.stderr b/crates/test-ui/ui/declare_class_invalid_receiver.stderr index b1beb7ae8..5c093441c 100644 --- a/crates/test-ui/ui/declare_class_invalid_receiver.stderr +++ b/crates/test-ui/ui/declare_class_invalid_receiver.stderr @@ -14,14 +14,14 @@ error[E0277]: the trait bound `extern "C" fn(Box, objc2::runtime:: | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -49,14 +49,14 @@ error[E0277]: the trait bound `extern "C" fn(Id, objc2::runtime::S | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -84,14 +84,14 @@ error[E0277]: the trait bound `extern "C" fn(CustomObject, objc2::runtime::Sel): | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -119,14 +119,14 @@ error[E0277]: the trait bound `extern "C" fn(Box, objc2::runtime:: | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -154,14 +154,14 @@ error[E0277]: the trait bound `extern "C" fn(Id, objc2::runtime::S | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -189,14 +189,14 @@ error[E0277]: the trait bound `extern "C" fn(CustomObject, objc2::runtime::Sel) | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs @@ -221,13 +221,13 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf | |_^ the trait `MessageReceiver` is not implemented for `Box` | = help: the following other types implement trait `MessageReceiver`: + &'a AnyClass &'a Id &'a T &'a mut Id &'a mut T - &'a objc2::runtime::Class + *const AnyClass *const T - *const objc2::runtime::Class *mut T and $N others = note: required for `RetainSemantics<5>` to implement `MessageRecieveId, Id>` @@ -264,13 +264,13 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied | |_^ the trait `MessageReceiver` is not implemented for `CustomObject` | = help: the following other types implement trait `MessageReceiver`: + &'a AnyClass &'a Id &'a T &'a mut Id &'a mut T - &'a objc2::runtime::Class + *const AnyClass *const T - *const objc2::runtime::Class *mut T and $N others = note: required for `RetainSemantics<5>` to implement `MessageRecieveId>` @@ -289,13 +289,13 @@ error[E0277]: the trait bound `Allocated: MessageReceiver` is not | |_^ the trait `MessageReceiver` is not implemented for `Allocated` | = help: the following other types implement trait `MessageReceiver`: + &'a AnyClass &'a Id &'a T &'a mut Id &'a mut T - &'a objc2::runtime::Class + *const AnyClass *const T - *const objc2::runtime::Class *mut T and $N others = note: required for `RetainSemantics<5>` to implement `MessageRecieveId, Id>` diff --git a/crates/test-ui/ui/declare_class_invalid_syntax.stderr b/crates/test-ui/ui/declare_class_invalid_syntax.stderr index f90383b25..748af0ab7 100644 --- a/crates/test-ui/ui/declare_class_invalid_syntax.stderr +++ b/crates/test-ui/ui/declare_class_invalid_syntax.stderr @@ -313,7 +313,7 @@ error[E0599]: no function or associated item named `test_self` found for struct | | ); | |_- function or associated item `test_self` not found for this struct -error[E0277]: the trait bound `RetainSemantics<2>: MessageRecieveId<&objc2::runtime::Class, Id>` is not satisfied +error[E0277]: the trait bound `RetainSemantics<2>: MessageRecieveId<&AnyClass, Id>` is not satisfied --> ui/declare_class_invalid_syntax.rs | | / declare_class!( @@ -323,7 +323,7 @@ error[E0277]: the trait bound `RetainSemantics<2>: MessageRecieveId<&objc2::runt ... | | | } | | ); - | |_^ the trait `MessageRecieveId<&objc2::runtime::Class, Id>` is not implemented for `RetainSemantics<2>` + | |_^ the trait `MessageRecieveId<&AnyClass, Id>` is not implemented for `RetainSemantics<2>` | = help: the following other types implement trait `MessageRecieveId`: as MessageRecieveId> diff --git a/crates/test-ui/ui/extern_class_root.rs b/crates/test-ui/ui/extern_class_root.rs index 4b329fedd..9b1d7e33c 100644 --- a/crates/test-ui/ui/extern_class_root.rs +++ b/crates/test-ui/ui/extern_class_root.rs @@ -1,11 +1,11 @@ use core::ops::{Deref, DerefMut}; use objc2::encode::{Encoding, RefEncode}; -use objc2::runtime::Object; +use objc2::runtime::AnyObject; use objc2::{extern_class, mutability, ClassType, Message}; #[repr(transparent)] -struct MyObject(Object); +struct MyObject(AnyObject); unsafe impl RefEncode for MyObject { const ENCODING_REF: Encoding = Encoding::Object; @@ -14,15 +14,15 @@ unsafe impl RefEncode for MyObject { unsafe impl Message for MyObject {} impl Deref for MyObject { - type Target = Object; + type Target = AnyObject; - fn deref(&self) -> &Object { + fn deref(&self) -> &AnyObject { &self.0 } } impl DerefMut for MyObject { - fn deref_mut(&mut self) -> &mut Object { + fn deref_mut(&mut self) -> &mut AnyObject { &mut self.0 } } diff --git a/crates/test-ui/ui/extern_class_subclass_object.rs b/crates/test-ui/ui/extern_class_subclass_object.rs index 74f3f8d3d..164e3e8cf 100644 --- a/crates/test-ui/ui/extern_class_subclass_object.rs +++ b/crates/test-ui/ui/extern_class_subclass_object.rs @@ -1,11 +1,11 @@ -use objc2::runtime::Object; +use objc2::runtime::AnyObject; use objc2::{extern_class, mutability, ClassType}; extern_class!( pub struct MyRootClass; unsafe impl ClassType for MyRootClass { - type Super = Object; + type Super = AnyObject; type Mutability = mutability::InteriorMutable; } ); diff --git a/crates/test-ui/ui/extern_class_subclass_object.stderr b/crates/test-ui/ui/extern_class_subclass_object.stderr index 80c06386c..bbed92cfc 100644 --- a/crates/test-ui/ui/extern_class_subclass_object.stderr +++ b/crates/test-ui/ui/extern_class_subclass_object.stderr @@ -1,4 +1,4 @@ -error[E0119]: conflicting implementations of trait `AsRef` for type `MyRootClass` +error[E0119]: conflicting implementations of trait `AsRef` for type `MyRootClass` --> ui/extern_class_subclass_object.rs | | / extern_class!( @@ -15,7 +15,7 @@ error[E0119]: conflicting implementations of trait `AsRef` for type `MyRootClass` +error[E0119]: conflicting implementations of trait `AsMut` for type `MyRootClass` --> ui/extern_class_subclass_object.rs | | / extern_class!( @@ -32,7 +32,7 @@ error[E0119]: conflicting implementations of trait `AsMut` for type `MyRootClass` +error[E0119]: conflicting implementations of trait `Borrow` for type `MyRootClass` --> ui/extern_class_subclass_object.rs | | / extern_class!( @@ -49,7 +49,7 @@ error[E0119]: conflicting implementations of trait `Borrow` for type `MyRootClass` +error[E0119]: conflicting implementations of trait `BorrowMut` for type `MyRootClass` --> ui/extern_class_subclass_object.rs | | / extern_class!( diff --git a/crates/test-ui/ui/fn_ptr_reference_method.rs b/crates/test-ui/ui/fn_ptr_reference_method.rs index 73a82b2e1..f1c594b32 100644 --- a/crates/test-ui/ui/fn_ptr_reference_method.rs +++ b/crates/test-ui/ui/fn_ptr_reference_method.rs @@ -6,10 +6,10 @@ //! (`_` can be used to work around this, by letting the compiler choose an //! appropriate lifetime '0 that the trait is implemented for). use objc2::declare::ClassBuilder; -use objc2::runtime::{Object, Sel}; +use objc2::runtime::{NSObject, Sel}; use objc2::{class, sel}; -extern "C" fn my_fn(_this: &Object, _cmd: Sel, _x: &Object) {} +extern "C" fn my_fn(_this: &NSObject, _cmd: Sel, _x: &NSObject) {} fn main() { let mut builder = ClassBuilder::new("SomeTestClass", class!(NSObject)).unwrap(); @@ -18,10 +18,10 @@ fn main() { builder.add_method(sel!(none:), my_fn as extern "C" fn(_, _, _)); // Fails - builder.add_method(sel!(third:), my_fn as extern "C" fn(_, _, &Object)); + builder.add_method(sel!(third:), my_fn as extern "C" fn(_, _, &NSObject)); // Also fails, properly tested in `fn_ptr_reference_method2` - builder.add_method(sel!(first:), my_fn as extern "C" fn(&Object, _, _)); - builder.add_method(sel!(both:), my_fn as extern "C" fn(&Object, _, &Object)); + builder.add_method(sel!(first:), my_fn as extern "C" fn(&NSObject, _, _)); + builder.add_method(sel!(both:), my_fn as extern "C" fn(&NSObject, _, &NSObject)); } } diff --git a/crates/test-ui/ui/fn_ptr_reference_method.stderr b/crates/test-ui/ui/fn_ptr_reference_method.stderr index 87005f902..4b794fd9a 100644 --- a/crates/test-ui/ui/fn_ptr_reference_method.stderr +++ b/crates/test-ui/ui/fn_ptr_reference_method.stderr @@ -1,20 +1,20 @@ -error[E0277]: the trait bound `for<'a> extern "C" fn(_, _, &'a objc2::runtime::Object): MethodImplementation` is not satisfied +error[E0277]: the trait bound `for<'a> extern "C" fn(_, _, &'a NSObject): MethodImplementation` is not satisfied --> ui/fn_ptr_reference_method.rs | - | builder.add_method(sel!(third:), my_fn as extern "C" fn(_, _, &Object)); - | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MethodImplementation` is not implemented for `for<'a> extern "C" fn(_, _, &'a objc2::runtime::Object)` + | builder.add_method(sel!(third:), my_fn as extern "C" fn(_, _, &NSObject)); + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MethodImplementation` is not implemented for `for<'a> extern "C" fn(_, _, &'a NSObject)` | | | required by a bound introduced by this call | = help: the following other types implement trait `MethodImplementation`: - extern "C" fn(&'a T, objc2::runtime::Sel) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F) -> R - extern "C" fn(&'a T, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F) -> R + extern "C" fn(&'a AnyClass, objc2::runtime::Sel, A, B, C, D, E, F, G) -> R and $N others note: required by a bound in `ClassBuilder::add_method` --> $WORKSPACE/crates/objc2/src/declare/mod.rs diff --git a/crates/test-ui/ui/fn_ptr_reference_method2.rs b/crates/test-ui/ui/fn_ptr_reference_method2.rs index bae53d029..d221cc571 100644 --- a/crates/test-ui/ui/fn_ptr_reference_method2.rs +++ b/crates/test-ui/ui/fn_ptr_reference_method2.rs @@ -1,15 +1,15 @@ //! Extra test for `fn_ptr_reference_method` //! (They fail at different compilation passes). use objc2::declare::ClassBuilder; -use objc2::runtime::{Object, Sel}; +use objc2::runtime::{NSObject, Sel}; use objc2::{class, sel}; -extern "C" fn my_fn(_this: &Object, _cmd: Sel, _x: &Object) {} +extern "C" fn my_fn(_this: &NSObject, _cmd: Sel, _x: &NSObject) {} fn main() { let mut builder = ClassBuilder::new("SomeTestClass", class!(NSObject)).unwrap(); unsafe { - builder.add_method(sel!(first:), my_fn as extern "C" fn(&Object, _, _)); - builder.add_method(sel!(both:), my_fn as extern "C" fn(&Object, Sel, &Object)); + builder.add_method(sel!(first:), my_fn as extern "C" fn(&NSObject, _, _)); + builder.add_method(sel!(both:), my_fn as extern "C" fn(&NSObject, Sel, &NSObject)); } } diff --git a/crates/test-ui/ui/fn_ptr_reference_method2.stderr b/crates/test-ui/ui/fn_ptr_reference_method2.stderr index b66684bbe..8e3313262 100644 --- a/crates/test-ui/ui/fn_ptr_reference_method2.stderr +++ b/crates/test-ui/ui/fn_ptr_reference_method2.stderr @@ -1,26 +1,26 @@ error: implementation of `MethodImplementation` is not general enough --> ui/fn_ptr_reference_method2.rs | - | builder.add_method(sel!(first:), my_fn as extern "C" fn(&Object, _, _)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MethodImplementation` is not general enough + | builder.add_method(sel!(first:), my_fn as extern "C" fn(&NSObject, _, _)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MethodImplementation` is not general enough | - = note: `MethodImplementation` would have to be implemented for the type `for<'a> extern "C" fn(&'a objc2::runtime::Object, objc2::runtime::Sel, &objc2::runtime::Object)` - = note: ...but `MethodImplementation` is actually implemented for the type `extern "C" fn(&'0 objc2::runtime::Object, objc2::runtime::Sel, &objc2::runtime::Object)`, for some specific lifetime `'0` + = note: `MethodImplementation` would have to be implemented for the type `for<'a> extern "C" fn(&'a NSObject, objc2::runtime::Sel, &NSObject)` + = note: ...but `MethodImplementation` is actually implemented for the type `extern "C" fn(&'0 NSObject, objc2::runtime::Sel, &NSObject)`, for some specific lifetime `'0` error: implementation of `MethodImplementation` is not general enough --> ui/fn_ptr_reference_method2.rs | - | builder.add_method(sel!(both:), my_fn as extern "C" fn(&Object, Sel, &Object)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MethodImplementation` is not general enough + | builder.add_method(sel!(both:), my_fn as extern "C" fn(&NSObject, Sel, &NSObject)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MethodImplementation` is not general enough | - = note: `MethodImplementation` would have to be implemented for the type `for<'a, 'b> extern "C" fn(&'a objc2::runtime::Object, objc2::runtime::Sel, &'b objc2::runtime::Object)` - = note: ...but `MethodImplementation` is actually implemented for the type `extern "C" fn(&'0 objc2::runtime::Object, objc2::runtime::Sel, &objc2::runtime::Object)`, for some specific lifetime `'0` + = note: `MethodImplementation` would have to be implemented for the type `for<'a, 'b> extern "C" fn(&'a NSObject, objc2::runtime::Sel, &'b NSObject)` + = note: ...but `MethodImplementation` is actually implemented for the type `extern "C" fn(&'0 NSObject, objc2::runtime::Sel, &NSObject)`, for some specific lifetime `'0` error: implementation of `MethodImplementation` is not general enough --> ui/fn_ptr_reference_method2.rs | - | builder.add_method(sel!(both:), my_fn as extern "C" fn(&Object, Sel, &Object)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MethodImplementation` is not general enough + | builder.add_method(sel!(both:), my_fn as extern "C" fn(&NSObject, Sel, &NSObject)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `MethodImplementation` is not general enough | - = note: `MethodImplementation` would have to be implemented for the type `for<'a, 'b> extern "C" fn(&'a objc2::runtime::Object, objc2::runtime::Sel, &'b objc2::runtime::Object)` - = note: ...but `MethodImplementation` is actually implemented for the type `extern "C" fn(&objc2::runtime::Object, objc2::runtime::Sel, &'0 objc2::runtime::Object)`, for some specific lifetime `'0` + = note: `MethodImplementation` would have to be implemented for the type `for<'a, 'b> extern "C" fn(&'a NSObject, objc2::runtime::Sel, &'b NSObject)` + = note: ...but `MethodImplementation` is actually implemented for the type `extern "C" fn(&NSObject, objc2::runtime::Sel, &'0 NSObject)`, for some specific lifetime `'0` diff --git a/crates/test-ui/ui/invalid_msg_send.rs b/crates/test-ui/ui/invalid_msg_send.rs index 6c7aa8616..7ea9246ab 100644 --- a/crates/test-ui/ui/invalid_msg_send.rs +++ b/crates/test-ui/ui/invalid_msg_send.rs @@ -1,10 +1,10 @@ //! Test invalid msg_send syntax use objc2::msg_send; use objc2::rc::Id; -use objc2::runtime::Object; +use objc2::runtime::NSObject; fn main() { - let obj: &Object; + let obj: &NSObject; let b = 32i32; let d = 32i32; let _: () = unsafe { msg_send![obj] }; @@ -16,5 +16,5 @@ fn main() { let _: () = unsafe { msg_send![obj, a: b: c] }; let _: () = unsafe { msg_send![obj, a: b c: d,] }; - let _: Result<(), Id> = unsafe { msg_send![obj, a: _, b: _] }; + let _: Result<(), Id> = unsafe { msg_send![obj, a: _, b: _] }; } diff --git a/crates/test-ui/ui/invalid_msg_send.stderr b/crates/test-ui/ui/invalid_msg_send.stderr index a4f1f096e..ebd87d780 100644 --- a/crates/test-ui/ui/invalid_msg_send.stderr +++ b/crates/test-ui/ui/invalid_msg_send.stderr @@ -97,8 +97,8 @@ note: while trying to match `)` error: no rules expected the token `b` --> ui/invalid_msg_send.rs | - | let _: Result<(), Id> = unsafe { msg_send![obj, a: _, b: _] }; - | ^ no rules expected this token in macro call + | let _: Result<(), Id> = unsafe { msg_send![obj, a: _, b: _] }; + | ^ no rules expected this token in macro call | note: while trying to match `)` --> $WORKSPACE/crates/objc2/src/macros/__msg_send_parse.rs diff --git a/crates/test-ui/ui/invalid_msg_send_super.rs b/crates/test-ui/ui/invalid_msg_send_super.rs index ac406419b..2c12685e5 100644 --- a/crates/test-ui/ui/invalid_msg_send_super.rs +++ b/crates/test-ui/ui/invalid_msg_send_super.rs @@ -1,10 +1,10 @@ //! Test invalid msg_send![super(...)] syntax use objc2::msg_send; -use objc2::runtime::{Class, Object}; +use objc2::runtime::{AnyClass, NSObject}; fn main() { - let obj: &Object; - let superclass: &Class; + let obj: &NSObject; + let superclass: &AnyClass; let _: () = unsafe { msg_send![super, init] }; let _: () = unsafe { msg_send![super(), init] }; diff --git a/crates/test-ui/ui/msg_send_id_alloc_init_different.rs b/crates/test-ui/ui/msg_send_id_alloc_init_different.rs index 0167514c0..d6c22e188 100644 --- a/crates/test-ui/ui/msg_send_id_alloc_init_different.rs +++ b/crates/test-ui/ui/msg_send_id_alloc_init_different.rs @@ -1,11 +1,11 @@ //! Ensure that `init` returns the same type as given from `alloc`. use objc2::rc::{Allocated, Id}; -use objc2::runtime::{NSObject, Object}; +use objc2::runtime::{NSObject, AnyObject}; use objc2::{class, msg_send_id}; fn main() { let cls = class!(NSObject); let obj: Option> = unsafe { msg_send_id![cls, alloc] }; - let _: Id = unsafe { msg_send_id![obj, init] }; + let _: Id = unsafe { msg_send_id![obj, init] }; } diff --git a/crates/test-ui/ui/msg_send_id_alloc_init_different.stderr b/crates/test-ui/ui/msg_send_id_alloc_init_different.stderr index f3c135b10..5de9e525e 100644 --- a/crates/test-ui/ui/msg_send_id_alloc_init_different.stderr +++ b/crates/test-ui/ui/msg_send_id_alloc_init_different.stderr @@ -1,11 +1,11 @@ -error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Id` +error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Id` --> ui/msg_send_id_alloc_init_different.rs | - | let _: Id = unsafe { msg_send_id![obj, init] }; - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Id`, found `Id` + | let _: Id = unsafe { msg_send_id![obj, init] }; + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Id`, found `Id` | = note: expected struct `Id` - found struct `Id` + found struct `Id` note: required by a bound in `send_message_id` --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | diff --git a/crates/test-ui/ui/msg_send_id_invalid_method.rs b/crates/test-ui/ui/msg_send_id_invalid_method.rs index 2b0e4187c..af9a26042 100644 --- a/crates/test-ui/ui/msg_send_id_invalid_method.rs +++ b/crates/test-ui/ui/msg_send_id_invalid_method.rs @@ -4,10 +4,10 @@ //! this is better than having it show up as part of the `msg_send_id!` macro //! itself! use objc2::msg_send_id; -use objc2::runtime::Object; +use objc2::runtime::NSObject; fn main() { - let object: &Object; + let object: &NSObject; unsafe { msg_send_id![object, retain] }; unsafe { msg_send_id![object, release] }; unsafe { msg_send_id![object, autorelease] }; diff --git a/crates/test-ui/ui/msg_send_id_invalid_receiver.rs b/crates/test-ui/ui/msg_send_id_invalid_receiver.rs index 27eaca44b..ebfba2999 100644 --- a/crates/test-ui/ui/msg_send_id_invalid_receiver.rs +++ b/crates/test-ui/ui/msg_send_id_invalid_receiver.rs @@ -1,22 +1,22 @@ //! Test compiler output with invalid msg_send_id receivers. use objc2::msg_send_id; use objc2::rc::{Allocated, Id}; -use objc2::runtime::{Class, Object}; +use objc2::runtime::{AnyClass, NSObject}; fn main() { - let obj: &Object; - let _: Allocated = unsafe { msg_send_id![obj, alloc] }; - let _: Id = unsafe { msg_send_id![obj, init] }; + let obj: &NSObject; + let _: Allocated = unsafe { msg_send_id![obj, alloc] }; + let _: Id = unsafe { msg_send_id![obj, init] }; - let cls: &Class; - let _: Id = unsafe { msg_send_id![cls, init] }; - let obj: Id; - let _: Id = unsafe { msg_send_id![obj, init] }; - let obj: Option>; - let _: Id = unsafe { msg_send_id![obj, init] }; + let cls: &AnyClass; + let _: Id = unsafe { msg_send_id![cls, init] }; + let obj: Id; + let _: Id = unsafe { msg_send_id![obj, init] }; + let obj: Option>; + let _: Id = unsafe { msg_send_id![obj, init] }; - let obj: Id; - let _: Id = unsafe { msg_send_id![obj, new] }; - let obj: Id; - let _: Id = unsafe { msg_send_id![obj, copy] }; + let obj: Id; + let _: Id = unsafe { msg_send_id![obj, new] }; + let obj: Id; + let _: Id = unsafe { msg_send_id![obj, copy] }; } diff --git a/crates/test-ui/ui/msg_send_id_invalid_receiver.stderr b/crates/test-ui/ui/msg_send_id_invalid_receiver.stderr index 20b1ab92b..e58158c6b 100644 --- a/crates/test-ui/ui/msg_send_id_invalid_receiver.stderr +++ b/crates/test-ui/ui/msg_send_id_invalid_receiver.stderr @@ -1,14 +1,14 @@ error[E0308]: mismatched types --> ui/msg_send_id_invalid_receiver.rs | - | let _: Allocated = unsafe { msg_send_id![obj, alloc] }; - | -------------^^^-------- - | | | - | | expected `&Class`, found `&Object` - | arguments to this function are incorrect - | - = note: expected reference `&objc2::runtime::Class` - found reference `&objc2::runtime::Object` + | let _: Allocated = unsafe { msg_send_id![obj, alloc] }; + | -------------^^^-------- + | | | + | | expected `&AnyClass`, found `&NSObject` + | arguments to this function are incorrect + | + = note: expected reference `&AnyClass` + found reference `&NSObject` note: associated function defined here --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | @@ -18,14 +18,14 @@ note: associated function defined here error[E0308]: mismatched types --> ui/msg_send_id_invalid_receiver.rs | - | let _: Id = unsafe { msg_send_id![obj, init] }; - | -------------^^^------- - | | | - | | expected `Option>`, found `&Object` - | arguments to this function are incorrect + | let _: Id = unsafe { msg_send_id![obj, init] }; + | -------------^^^------- + | | | + | | expected `Option>`, found `&NSObject` + | arguments to this function are incorrect | = note: expected enum `Option>` - found reference `&objc2::runtime::Object` + found reference `&NSObject` note: associated function defined here --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | @@ -35,14 +35,14 @@ note: associated function defined here error[E0308]: mismatched types --> ui/msg_send_id_invalid_receiver.rs | - | let _: Id = unsafe { msg_send_id![cls, init] }; - | -------------^^^------- - | | | - | | expected `Option>`, found `&Class` - | arguments to this function are incorrect + | let _: Id = unsafe { msg_send_id![cls, init] }; + | -------------^^^------- + | | | + | | expected `Option>`, found `&AnyClass` + | arguments to this function are incorrect | = note: expected enum `Option>` - found reference `&objc2::runtime::Class` + found reference `&AnyClass` note: associated function defined here --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | @@ -52,14 +52,14 @@ note: associated function defined here error[E0308]: mismatched types --> ui/msg_send_id_invalid_receiver.rs | - | let _: Id = unsafe { msg_send_id![obj, init] }; - | -------------^^^------- - | | | - | | expected `Option>`, found `Id` - | arguments to this function are incorrect + | let _: Id = unsafe { msg_send_id![obj, init] }; + | -------------^^^------- + | | | + | | expected `Option>`, found `Id` + | arguments to this function are incorrect | = note: expected enum `Option>` - found struct `Id` + found struct `Id` note: associated function defined here --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | @@ -69,44 +69,44 @@ note: associated function defined here error[E0308]: mismatched types --> ui/msg_send_id_invalid_receiver.rs | - | let _: Id = unsafe { msg_send_id![obj, init] }; - | -------------^^^------- - | | | - | | expected `Option>`, found `Option>` - | arguments to this function are incorrect + | let _: Id = unsafe { msg_send_id![obj, init] }; + | -------------^^^------- + | | | + | | expected `Option>`, found `Option>` + | arguments to this function are incorrect | = note: expected enum `Option>` - found enum `Option>` + found enum `Option>` note: associated function defined here --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | | unsafe fn send_message_id>( | ^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `Id: MessageReceiver` is not satisfied +error[E0277]: the trait bound `Id: MessageReceiver` is not satisfied --> ui/msg_send_id_invalid_receiver.rs | - | let _: Id = unsafe { msg_send_id![obj, new] }; - | -------------^^^------ - | | | - | | the trait `MessageReceiver` is not implemented for `Id` - | required by a bound introduced by this call + | let _: Id = unsafe { msg_send_id![obj, new] }; + | -------------^^^------ + | | | + | | the trait `MessageReceiver` is not implemented for `Id` + | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: &'a Id &'a mut Id - = note: required for `RetainSemantics<1>` to implement `MsgSendId, Id<_>>` + = note: required for `RetainSemantics<1>` to implement `MsgSendId, Id<_>>` -error[E0277]: the trait bound `Id: MessageReceiver` is not satisfied +error[E0277]: the trait bound `Id: MessageReceiver` is not satisfied --> ui/msg_send_id_invalid_receiver.rs | - | let _: Id = unsafe { msg_send_id![obj, copy] }; - | -------------^^^------- - | | | - | | the trait `MessageReceiver` is not implemented for `Id` - | required by a bound introduced by this call + | let _: Id = unsafe { msg_send_id![obj, copy] }; + | -------------^^^------- + | | | + | | the trait `MessageReceiver` is not implemented for `Id` + | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: &'a Id &'a mut Id - = note: required for `RetainSemantics<4>` to implement `MsgSendId, Id<_>>` + = note: required for `RetainSemantics<4>` to implement `MsgSendId, Id<_>>` diff --git a/crates/test-ui/ui/msg_send_id_invalid_return.rs b/crates/test-ui/ui/msg_send_id_invalid_return.rs index e39aa9dee..9009ac961 100644 --- a/crates/test-ui/ui/msg_send_id_invalid_return.rs +++ b/crates/test-ui/ui/msg_send_id_invalid_return.rs @@ -1,30 +1,30 @@ //! Test compiler output with invalid msg_send_id return values. use objc2::msg_send_id; use objc2::rc::{Allocated, Id}; -use objc2::runtime::{Class, NSObject, Object}; +use objc2::runtime::{AnyClass, NSObject, AnyObject}; fn main() { - let cls: &Class; - let _: &Object = unsafe { msg_send_id![cls, new] }; - let _: Id = unsafe { msg_send_id![cls, new] }; - let _: Option> = unsafe { msg_send_id![cls, new] }; + let cls: &AnyClass; + let _: &AnyObject = unsafe { msg_send_id![cls, new] }; + let _: Id = unsafe { msg_send_id![cls, new] }; + let _: Option> = unsafe { msg_send_id![cls, new] }; - let _: &Object = unsafe { msg_send_id![cls, alloc] }; - let _: Allocated = unsafe { msg_send_id![cls, alloc] }; - let _: Id = unsafe { msg_send_id![cls, alloc] }; + let _: &AnyObject = unsafe { msg_send_id![cls, alloc] }; + let _: Allocated = unsafe { msg_send_id![cls, alloc] }; + let _: Id = unsafe { msg_send_id![cls, alloc] }; // Earlier design worked like this - let _: Id> = unsafe { msg_send_id![cls, alloc] }; + let _: Id> = unsafe { msg_send_id![cls, alloc] }; - let obj: Option>; - let _: &Object = unsafe { msg_send_id![obj, init] }; - let obj: Option>; - let _: Id = unsafe { msg_send_id![obj, init] }; - let obj: Option>; + let obj: Option>; + let _: &AnyObject = unsafe { msg_send_id![obj, init] }; + let obj: Option>; + let _: Id = unsafe { msg_send_id![obj, init] }; + let obj: Option>; let _: Id = unsafe { msg_send_id![obj, init] }; - let obj: &Object; - let _: &Object = unsafe { msg_send_id![obj, copy] }; + let obj: &AnyObject; + let _: &AnyObject = unsafe { msg_send_id![obj, copy] }; - let _: &Object = unsafe { msg_send_id![obj, description] }; - let _: Option<&Object> = unsafe { msg_send_id![obj, description] }; + let _: &AnyObject = unsafe { msg_send_id![obj, description] }; + let _: Option<&AnyObject> = unsafe { msg_send_id![obj, description] }; } diff --git a/crates/test-ui/ui/msg_send_id_invalid_return.stderr b/crates/test-ui/ui/msg_send_id_invalid_return.stderr index 92b2d9c5b..bdea38a6d 100644 --- a/crates/test-ui/ui/msg_send_id_invalid_return.stderr +++ b/crates/test-ui/ui/msg_send_id_invalid_return.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `&objc2::runtime::Object: MaybeUnwrap` is not satisfied +error[E0277]: the trait bound `&AnyObject: MaybeUnwrap` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: &Object = unsafe { msg_send_id![cls, new] }; - | ^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&objc2::runtime::Object` + | let _: &AnyObject = unsafe { msg_send_id![cls, new] }; + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&AnyObject` | = help: the following other types implement trait `MaybeUnwrap`: Allocated @@ -16,47 +16,47 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `objc2::runtime::Class: Message` is not satisfied +error[E0277]: the trait bound `AnyClass: Message` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: Id = unsafe { msg_send_id![cls, new] }; - | -------------^^^------ - | | | - | | the trait `Message` is not implemented for `objc2::runtime::Class` - | required by a bound introduced by this call + | let _: Id = unsafe { msg_send_id![cls, new] }; + | -------------^^^------ + | | | + | | the trait `Message` is not implemented for `AnyClass` + | required by a bound introduced by this call | = help: the following other types implement trait `Message`: + AnyObject Exception NSObject ProtocolObject

__NSProxy __RcTestObject - objc2::runtime::Object - = note: required for `RetainSemantics<1>` to implement `MsgSendId<&objc2::runtime::Class, Id>` + = note: required for `RetainSemantics<1>` to implement `MsgSendId<&AnyClass, Id>` -error[E0277]: the trait bound `objc2::runtime::Class: Message` is not satisfied +error[E0277]: the trait bound `AnyClass: Message` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: Option> = unsafe { msg_send_id![cls, new] }; - | -------------^^^------ - | | | - | | the trait `Message` is not implemented for `objc2::runtime::Class` - | required by a bound introduced by this call + | let _: Option> = unsafe { msg_send_id![cls, new] }; + | -------------^^^------ + | | | + | | the trait `Message` is not implemented for `AnyClass` + | required by a bound introduced by this call | = help: the following other types implement trait `Message`: + AnyObject Exception NSObject ProtocolObject

__NSProxy __RcTestObject - objc2::runtime::Object - = note: required for `RetainSemantics<1>` to implement `MsgSendId<&objc2::runtime::Class, Id>` + = note: required for `RetainSemantics<1>` to implement `MsgSendId<&AnyClass, Id>` -error[E0277]: the trait bound `&objc2::runtime::Object: MaybeUnwrap` is not satisfied +error[E0277]: the trait bound `&AnyObject: MaybeUnwrap` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: &Object = unsafe { msg_send_id![cls, alloc] }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&objc2::runtime::Object` + | let _: &AnyObject = unsafe { msg_send_id![cls, alloc] }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&AnyObject` | = help: the following other types implement trait `MaybeUnwrap`: Allocated @@ -70,32 +70,32 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `objc2::runtime::Class: Message` is not satisfied +error[E0277]: the trait bound `AnyClass: Message` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: Allocated = unsafe { msg_send_id![cls, alloc] }; - | -------------^^^-------- - | | | - | | the trait `Message` is not implemented for `objc2::runtime::Class` - | required by a bound introduced by this call + | let _: Allocated = unsafe { msg_send_id![cls, alloc] }; + | -------------^^^-------- + | | | + | | the trait `Message` is not implemented for `AnyClass` + | required by a bound introduced by this call | = help: the following other types implement trait `Message`: + AnyObject Exception NSObject ProtocolObject

__NSProxy __RcTestObject - objc2::runtime::Object - = note: required for `RetainSemantics<2>` to implement `MsgSendId<&objc2::runtime::Class, Allocated>` + = note: required for `RetainSemantics<2>` to implement `MsgSendId<&AnyClass, Allocated>` -error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Allocated<_>` +error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Allocated<_>` --> ui/msg_send_id_invalid_return.rs | - | let _: Id = unsafe { msg_send_id![cls, alloc] }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `Allocated<_>`, found `Id` + | let _: Id = unsafe { msg_send_id![cls, alloc] }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `Allocated<_>`, found `Id` | = note: expected struct `Allocated<_>` - found struct `Id` + found struct `Id` note: required by a bound in `send_message_id` --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | @@ -103,14 +103,14 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0271]: type mismatch resolving `> as MaybeUnwrap>::Input == Allocated<_>` +error[E0271]: type mismatch resolving `> as MaybeUnwrap>::Input == Allocated<_>` --> ui/msg_send_id_invalid_return.rs | - | let _: Id> = unsafe { msg_send_id![cls, alloc] }; - | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `Allocated<_>`, found `Id>` + | let _: Id> = unsafe { msg_send_id![cls, alloc] }; + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `Allocated<_>`, found `Id>` | = note: expected struct `Allocated<_>` - found struct `Id>` + found struct `Id>` note: required by a bound in `send_message_id` --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | @@ -118,11 +118,11 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `&objc2::runtime::Object: MaybeUnwrap` is not satisfied +error[E0277]: the trait bound `&AnyObject: MaybeUnwrap` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: &Object = unsafe { msg_send_id![obj, init] }; - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&objc2::runtime::Object` + | let _: &AnyObject = unsafe { msg_send_id![obj, init] }; + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&AnyObject` | = help: the following other types implement trait `MaybeUnwrap`: Allocated @@ -136,14 +136,14 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Id` +error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Id` --> ui/msg_send_id_invalid_return.rs | - | let _: Id = unsafe { msg_send_id![obj, init] }; - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Id`, found `Id` + | let _: Id = unsafe { msg_send_id![obj, init] }; + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Id`, found `Id` | - = note: expected struct `Id` - found struct `Id` + = note: expected struct `Id` + found struct `Id` note: required by a bound in `send_message_id` --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs | @@ -151,13 +151,13 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Id` +error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Id` --> ui/msg_send_id_invalid_return.rs | | let _: Id = unsafe { msg_send_id![obj, init] }; - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Id`, found `Id` + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Id`, found `Id` | - = note: expected struct `Id` + = note: expected struct `Id` found struct `Id` note: required by a bound in `send_message_id` --> $WORKSPACE/crates/objc2/src/__macro_helpers/mod.rs @@ -166,11 +166,11 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `&objc2::runtime::Object: MaybeUnwrap` is not satisfied +error[E0277]: the trait bound `&AnyObject: MaybeUnwrap` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: &Object = unsafe { msg_send_id![obj, copy] }; - | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&objc2::runtime::Object` + | let _: &AnyObject = unsafe { msg_send_id![obj, copy] }; + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&AnyObject` | = help: the following other types implement trait `MaybeUnwrap`: Allocated @@ -184,11 +184,11 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `$crate::__msg_send_id_helper` which comes from the expansion of the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `&objc2::runtime::Object: MaybeUnwrap` is not satisfied +error[E0277]: the trait bound `&AnyObject: MaybeUnwrap` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: &Object = unsafe { msg_send_id![obj, description] }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&objc2::runtime::Object` + | let _: &AnyObject = unsafe { msg_send_id![obj, description] }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `&AnyObject` | = help: the following other types implement trait `MaybeUnwrap`: Allocated @@ -202,11 +202,11 @@ note: required by a bound in `send_message_id` | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `MsgSendId::send_message_id` = note: this error originates in the macro `$crate::__msg_send_id_helper` which comes from the expansion of the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Option<&objc2::runtime::Object>: MaybeUnwrap` is not satisfied +error[E0277]: the trait bound `Option<&AnyObject>: MaybeUnwrap` is not satisfied --> ui/msg_send_id_invalid_return.rs | - | let _: Option<&Object> = unsafe { msg_send_id![obj, description] }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `Option<&objc2::runtime::Object>` + | let _: Option<&AnyObject> = unsafe { msg_send_id![obj, description] }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MaybeUnwrap` is not implemented for `Option<&AnyObject>` | = help: the following other types implement trait `MaybeUnwrap`: Option> diff --git a/crates/test-ui/ui/msg_send_id_underspecified.rs b/crates/test-ui/ui/msg_send_id_underspecified.rs index 5837c0981..237188e80 100644 --- a/crates/test-ui/ui/msg_send_id_underspecified.rs +++ b/crates/test-ui/ui/msg_send_id_underspecified.rs @@ -1,8 +1,8 @@ //! Test compiler output of msg_send_id when ownership is not specified. use objc2::msg_send_id; -use objc2::runtime::Object; +use objc2::runtime::NSObject; fn main() { - let obj: &Object; - let _: &Object = &*unsafe { msg_send_id![obj, description] }; + let obj: &NSObject; + let _: &NSObject = &*unsafe { msg_send_id![obj, description] }; } diff --git a/crates/test-ui/ui/msg_send_id_underspecified.stderr b/crates/test-ui/ui/msg_send_id_underspecified.stderr index 0b876835d..10800fb6a 100644 --- a/crates/test-ui/ui/msg_send_id_underspecified.stderr +++ b/crates/test-ui/ui/msg_send_id_underspecified.stderr @@ -1,5 +1,5 @@ error[E0282]: type annotations needed --> ui/msg_send_id_underspecified.rs | - | let _: &Object = &*unsafe { msg_send_id![obj, description] }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + | let _: &NSObject = &*unsafe { msg_send_id![obj, description] }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type diff --git a/crates/test-ui/ui/msg_send_id_unwrap.rs b/crates/test-ui/ui/msg_send_id_unwrap.rs index 6f1a38eae..8a5f3960e 100644 --- a/crates/test-ui/ui/msg_send_id_unwrap.rs +++ b/crates/test-ui/ui/msg_send_id_unwrap.rs @@ -1,9 +1,9 @@ //! Test calling something on return from msg_send_id!. use objc2::rc::Id; -use objc2::runtime::Object; +use objc2::runtime::NSObject; use objc2::{class, msg_send_id}; fn main() { let cls = class!(NSObject); - let _: Id = unsafe { msg_send_id![cls, new].unwrap() }; + let _: Id = unsafe { msg_send_id![cls, new].unwrap() }; } diff --git a/crates/test-ui/ui/msg_send_id_unwrap.stderr b/crates/test-ui/ui/msg_send_id_unwrap.stderr index 873c648f9..8d6022048 100644 --- a/crates/test-ui/ui/msg_send_id_unwrap.stderr +++ b/crates/test-ui/ui/msg_send_id_unwrap.stderr @@ -1,7 +1,7 @@ error[E0282]: type annotations needed --> ui/msg_send_id_unwrap.rs | - | let _: Id = unsafe { msg_send_id![cls, new].unwrap() }; - | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + | let _: Id = unsafe { msg_send_id![cls, new].unwrap() }; + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type | = note: this error originates in the macro `msg_send_id` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/test-ui/ui/msg_send_invalid_error.stderr b/crates/test-ui/ui/msg_send_invalid_error.stderr index afbc7dafc..7d6473a53 100644 --- a/crates/test-ui/ui/msg_send_invalid_error.stderr +++ b/crates/test-ui/ui/msg_send_invalid_error.stderr @@ -40,6 +40,7 @@ error[E0277]: the trait bound `i32: Message` is not satisfied | ^^^^^^^^^^^^^^^^^^^^ the trait `Message` is not implemented for `i32` | = help: the following other types implement trait `Message`: + AnyObject Exception NSAppleEventDescriptor NSArray @@ -47,7 +48,6 @@ error[E0277]: the trait bound `i32: Message` is not satisfied NSEnumerator NSError NSHashTable - NSMapTable and $N others note: required by a bound in `__send_message_error` --> $WORKSPACE/crates/objc2/src/message/mod.rs diff --git a/crates/test-ui/ui/msg_send_mutable.rs b/crates/test-ui/ui/msg_send_mutable.rs index 17aa581b3..78659fa17 100644 --- a/crates/test-ui/ui/msg_send_mutable.rs +++ b/crates/test-ui/ui/msg_send_mutable.rs @@ -1,12 +1,12 @@ //! Test that `msg_send!` consumes their arguments, including the receiver. //! //! Ideally, it shouldn't be so, but that's how it works currently. -use objc2::runtime::Object; +use objc2::runtime::NSObject; use objc2::{class, msg_send}; fn main() { let cls = class!(NSObject); - let obj: &mut Object = unsafe { msg_send![cls, new] }; + let obj: &mut NSObject = unsafe { msg_send![cls, new] }; let _: () = unsafe { msg_send![obj, selector] }; // Could be solved with a reborrow diff --git a/crates/test-ui/ui/msg_send_mutable.stderr b/crates/test-ui/ui/msg_send_mutable.stderr index 21930eaf7..b813cf9f3 100644 --- a/crates/test-ui/ui/msg_send_mutable.stderr +++ b/crates/test-ui/ui/msg_send_mutable.stderr @@ -1,8 +1,8 @@ error[E0382]: use of moved value: `obj` --> ui/msg_send_mutable.rs | - | let obj: &mut Object = unsafe { msg_send![cls, new] }; - | --- move occurs because `obj` has type `&mut objc2::runtime::Object`, which does not implement the `Copy` trait + | let obj: &mut NSObject = unsafe { msg_send![cls, new] }; + | --- move occurs because `obj` has type `&mut NSObject`, which does not implement the `Copy` trait | | let _: () = unsafe { msg_send![obj, selector] }; | --- value moved here diff --git a/crates/test-ui/ui/msg_send_only_message.stderr b/crates/test-ui/ui/msg_send_only_message.stderr index b024fcd28..53055d13a 100644 --- a/crates/test-ui/ui/msg_send_only_message.stderr +++ b/crates/test-ui/ui/msg_send_only_message.stderr @@ -8,12 +8,12 @@ error[E0277]: the trait bound `{integer}: MessageReceiver` is not satisfied | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: + &'a AnyClass &'a Id &'a T &'a mut Id &'a mut T - &'a objc2::runtime::Class + *const AnyClass *const T - *const objc2::runtime::Class *mut T and $N others diff --git a/crates/test-ui/ui/msg_send_super_not_classtype.rs b/crates/test-ui/ui/msg_send_super_not_classtype.rs index 0940436ae..3bb5b4868 100644 --- a/crates/test-ui/ui/msg_send_super_not_classtype.rs +++ b/crates/test-ui/ui/msg_send_super_not_classtype.rs @@ -1,9 +1,9 @@ //! Invalid receiver to msg_send![super(obj), ...], missing ClassType impl. use objc2::msg_send; -use objc2::runtime::{NSObject, Object}; +use objc2::runtime::{NSObject, AnyObject}; fn main() { - let obj: &Object; + let obj: &AnyObject; let _: () = unsafe { msg_send![super(obj), method] }; let obj: &NSObject; // impls ClassType, but it's superclass does not diff --git a/crates/test-ui/ui/msg_send_super_not_classtype.stderr b/crates/test-ui/ui/msg_send_super_not_classtype.stderr index e9ad3842d..8242cf200 100644 --- a/crates/test-ui/ui/msg_send_super_not_classtype.stderr +++ b/crates/test-ui/ui/msg_send_super_not_classtype.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `objc2::runtime::Object: ClassType` is not satisfied +error[E0277]: the trait bound `AnyObject: ClassType` is not satisfied --> ui/msg_send_super_not_classtype.rs | | let _: () = unsafe { msg_send![super(obj), method] }; | ----------------^^^---------- | | | - | | the trait `ClassType` is not implemented for `objc2::runtime::Object` + | | the trait `ClassType` is not implemented for `AnyObject` | required by a bound introduced by this call | = help: the following other types implement trait `ClassType`: @@ -20,13 +20,13 @@ note: required by a bound in `__send_super_message_static` | Self::__Inner: ClassType, | ^^^^^^^^^ required by this bound in `MessageReceiver::__send_super_message_static` -error[E0277]: the trait bound `objc2::runtime::Object: ClassType` is not satisfied +error[E0277]: the trait bound `AnyObject: ClassType` is not satisfied --> ui/msg_send_super_not_classtype.rs | | let _: () = unsafe { msg_send![super(obj), method] }; | ----------------^^^---------- | | | - | | the trait `ClassType` is not implemented for `objc2::runtime::Object` + | | the trait `ClassType` is not implemented for `AnyObject` | required by a bound introduced by this call | = help: the following other types implement trait `ClassType`: diff --git a/crates/test-ui/ui/not_encode.stderr b/crates/test-ui/ui/not_encode.stderr index 11b3a193f..63b56e3dc 100644 --- a/crates/test-ui/ui/not_encode.stderr +++ b/crates/test-ui/ui/not_encode.stderr @@ -55,8 +55,8 @@ error[E0277]: the trait bound `(): RefEncode` is not satisfied *const c_void *mut T *mut c_void - AtomicI16 - AtomicI32 + AnyClass + AnyObject and $N others = note: required for `&()` to implement `Encode` note: required by a bound in `is_encode` @@ -78,8 +78,8 @@ error[E0277]: the trait bound `(): RefEncode` is not satisfied *const c_void *mut T *mut c_void - AtomicI16 - AtomicI32 + AnyClass + AnyObject and $N others = note: required for `*const ()` to implement `Encode` note: required by a bound in `is_encode` diff --git a/crates/test-ui/ui/not_writeback.stderr b/crates/test-ui/ui/not_writeback.stderr index b5bcf4130..a126a9d8c 100644 --- a/crates/test-ui/ui/not_writeback.stderr +++ b/crates/test-ui/ui/not_writeback.stderr @@ -11,8 +11,8 @@ error[E0277]: the trait bound `Id: RefEncode` is not satisfied *const c_void *mut T *mut c_void - AtomicI16 - AtomicI32 + AnyClass + AnyObject and $N others = note: required for `&mut Id` to implement `Encode` = note: required for `&mut Id` to implement `EncodeReturn` @@ -74,8 +74,8 @@ error[E0277]: the trait bound `Id: RefEncode` is not satisfied *const c_void *mut T *mut c_void - AtomicI16 - AtomicI32 + AnyClass + AnyObject and $N others = note: required for `&Id` to implement `Encode` = note: required for `&Id` to implement `EncodeConvertArgument` @@ -106,8 +106,8 @@ error[E0277]: the trait bound `Id: RefEncode` is not satisfied *const c_void *mut T *mut c_void - AtomicI16 - AtomicI32 + AnyClass + AnyObject and $N others = note: required for `&Id` to implement `Encode` = note: 1 redundant requirement hidden @@ -140,8 +140,8 @@ error[E0277]: the trait bound `Id: RefEncode` is not satisfied *const c_void *mut T *mut c_void - AtomicI16 - AtomicI32 + AnyClass + AnyObject and $N others = note: required for `*mut Id` to implement `Encode` = note: required for `*mut Id` to implement `EncodeConvertArgument` @@ -172,8 +172,8 @@ error[E0277]: the trait bound `Id: RefEncode` is not satisfied *const c_void *mut T *mut c_void - AtomicI16 - AtomicI32 + AnyClass + AnyObject and $N others = note: required for `&mut Id` to implement `RefEncode` = note: required for `&mut &mut Id` to implement `Encode` diff --git a/crates/test-ui/ui/nsarray_bound_not_send_sync.stderr b/crates/test-ui/ui/nsarray_bound_not_send_sync.stderr index 462521f40..6530de9e3 100644 --- a/crates/test-ui/ui/nsarray_bound_not_send_sync.stderr +++ b/crates/test-ui/ui/nsarray_bound_not_send_sync.stderr @@ -8,7 +8,7 @@ error[E0277]: `*const NSObject` cannot be shared between threads safely note: required because it appears within the type `UnknownStorage` --> $WORKSPACE/crates/objc2/src/rc/id.rs | - | pub struct UnknownStorage(*const T, Object); + | pub struct UnknownStorage(*const T, AnyObject); | ^^^^^^^^^^^^^^ note: required because it appears within the type `EquivalentType` --> $WORKSPACE/crates/objc2/src/rc/id.rs @@ -24,7 +24,7 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required by a bound in `needs_sync` --> ui/nsarray_bound_not_send_sync.rs @@ -44,11 +44,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | @@ -63,7 +63,7 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required by a bound in `needs_sync` --> ui/nsarray_bound_not_send_sync.rs @@ -81,7 +81,7 @@ error[E0277]: `*const NSObject` cannot be sent between threads safely note: required because it appears within the type `UnknownStorage` --> $WORKSPACE/crates/objc2/src/rc/id.rs | - | pub struct UnknownStorage(*const T, Object); + | pub struct UnknownStorage(*const T, AnyObject); | ^^^^^^^^^^^^^^ note: required because it appears within the type `EquivalentType` --> $WORKSPACE/crates/objc2/src/rc/id.rs @@ -97,7 +97,7 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required by a bound in `needs_send` --> ui/nsarray_bound_not_send_sync.rs @@ -128,11 +128,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | @@ -147,7 +147,7 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required by a bound in `needs_send` --> ui/nsarray_bound_not_send_sync.rs @@ -165,7 +165,7 @@ error[E0277]: `*const NSObject` cannot be shared between threads safely note: required because it appears within the type `UnknownStorage` --> $WORKSPACE/crates/objc2/src/rc/id.rs | - | pub struct UnknownStorage(*const T, Object); + | pub struct UnknownStorage(*const T, AnyObject); | ^^^^^^^^^^^^^^ note: required because it appears within the type `EquivalentType` --> $WORKSPACE/crates/objc2/src/rc/id.rs @@ -181,12 +181,12 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required because it appears within the type `NSMutableArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSMutableArray { + | pub struct NSMutableArray { | ^^^^^^^^^^^^^^ note: required by a bound in `needs_sync` --> ui/nsarray_bound_not_send_sync.rs @@ -206,11 +206,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | @@ -225,12 +225,12 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required because it appears within the type `NSMutableArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSMutableArray { + | pub struct NSMutableArray { | ^^^^^^^^^^^^^^ note: required by a bound in `needs_sync` --> ui/nsarray_bound_not_send_sync.rs @@ -248,7 +248,7 @@ error[E0277]: `*const NSObject` cannot be sent between threads safely note: required because it appears within the type `UnknownStorage` --> $WORKSPACE/crates/objc2/src/rc/id.rs | - | pub struct UnknownStorage(*const T, Object); + | pub struct UnknownStorage(*const T, AnyObject); | ^^^^^^^^^^^^^^ note: required because it appears within the type `EquivalentType` --> $WORKSPACE/crates/objc2/src/rc/id.rs @@ -264,12 +264,12 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required because it appears within the type `NSMutableArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSMutableArray { + | pub struct NSMutableArray { | ^^^^^^^^^^^^^^ note: required by a bound in `needs_send` --> ui/nsarray_bound_not_send_sync.rs @@ -300,11 +300,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | @@ -319,12 +319,12 @@ note: required because it appears within the type `PhantomData>` note: required because it appears within the type `NSArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSArray { + | pub struct NSArray { | ^^^^^^^ note: required because it appears within the type `NSMutableArray` --> $WORKSPACE/crates/icrate/src/Foundation/fixes/generics.rs | - | pub struct NSMutableArray { + | pub struct NSMutableArray { | ^^^^^^^^^^^^^^ note: required by a bound in `needs_send` --> ui/nsarray_bound_not_send_sync.rs diff --git a/crates/test-ui/ui/object_not_send_sync.rs b/crates/test-ui/ui/object_not_send_sync.rs index bf004c3d4..c1d2cdcaf 100644 --- a/crates/test-ui/ui/object_not_send_sync.rs +++ b/crates/test-ui/ui/object_not_send_sync.rs @@ -1,17 +1,17 @@ -//! Test that Object and NSObject are not Send and Sync, because their +//! Test that AnyObject and NSObject are not Send and Sync, because their //! subclasses might not be. //! //! Also test that `NSValue` is not Send nor Sync, because its contained value //! might not be. use icrate::Foundation::NSValue; -use objc2::runtime::{NSObject, Object}; +use objc2::runtime::{NSObject, AnyObject}; fn needs_sync() {} fn needs_send() {} fn main() { - needs_sync::(); - needs_send::(); + needs_sync::(); + needs_send::(); needs_sync::(); needs_send::(); needs_sync::(); diff --git a/crates/test-ui/ui/object_not_send_sync.stderr b/crates/test-ui/ui/object_not_send_sync.stderr index 4ec3059dd..05bf8849d 100644 --- a/crates/test-ui/ui/object_not_send_sync.stderr +++ b/crates/test-ui/ui/object_not_send_sync.stderr @@ -1,20 +1,20 @@ error[E0277]: `UnsafeCell, PhantomPinned)>>` cannot be shared between threads safely --> ui/object_not_send_sync.rs | - | needs_sync::(); - | ^^^^^^ `UnsafeCell, PhantomPinned)>>` cannot be shared between threads safely + | needs_sync::(); + | ^^^^^^^^^ `UnsafeCell, PhantomPinned)>>` cannot be shared between threads safely | - = help: within `objc2::runtime::Object`, the trait `Sync` is not implemented for `UnsafeCell, PhantomPinned)>>` + = help: within `AnyObject`, the trait `Sync` is not implemented for `UnsafeCell, PhantomPinned)>>` note: required because it appears within the type `objc_object` --> $WORKSPACE/crates/objc-sys/src/object.rs | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required by a bound in `needs_sync` --> ui/object_not_send_sync.rs | @@ -24,10 +24,10 @@ note: required by a bound in `needs_sync` error[E0277]: `*const UnsafeCell<()>` cannot be sent between threads safely --> ui/object_not_send_sync.rs | - | needs_send::(); - | ^^^^^^ `*const UnsafeCell<()>` cannot be sent between threads safely + | needs_send::(); + | ^^^^^^^^^ `*const UnsafeCell<()>` cannot be sent between threads safely | - = help: within `objc2::runtime::Object`, the trait `Send` is not implemented for `*const UnsafeCell<()>` + = help: within `AnyObject`, the trait `Send` is not implemented for `*const UnsafeCell<()>` = note: required because it appears within the type `(*const UnsafeCell<()>, PhantomPinned)` note: required because it appears within the type `PhantomData<(*const UnsafeCell<()>, PhantomPinned)>` --> $RUST/core/src/marker.rs @@ -44,11 +44,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required by a bound in `needs_send` --> ui/object_not_send_sync.rs | @@ -67,11 +67,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | @@ -106,11 +106,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | @@ -134,11 +134,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | @@ -178,11 +178,11 @@ note: required because it appears within the type `objc_object` | | pub struct objc_object { | ^^^^^^^^^^^ -note: required because it appears within the type `Object` +note: required because it appears within the type `AnyObject` --> $WORKSPACE/crates/objc2/src/runtime/mod.rs | - | pub struct Object(ffi::objc_object); - | ^^^^^^ + | pub struct AnyObject(ffi::objc_object); + | ^^^^^^^^^ note: required because it appears within the type `NSObject` --> $WORKSPACE/crates/objc2/src/runtime/nsobject.rs | diff --git a/crates/tests/src/exception.rs b/crates/tests/src/exception.rs index a3da4d782..98763eedc 100644 --- a/crates/tests/src/exception.rs +++ b/crates/tests/src/exception.rs @@ -4,10 +4,10 @@ use icrate::Foundation::{NSArray, NSException, NSString}; use objc2::exception::{catch, throw}; use objc2::msg_send; use objc2::rc::{autoreleasepool, Id}; -use objc2::runtime::Object; +use objc2::runtime::{AnyObject, NSObject}; #[track_caller] -fn assert_retain_count(obj: &Object, expected: usize) { +fn assert_retain_count(obj: &AnyObject, expected: usize) { let retain_count: usize = unsafe { msg_send![obj, retainCount] }; assert_eq!(retain_count, expected); } @@ -126,8 +126,8 @@ fn raise_catch() { fn catch_actual() { let res = unsafe { catch(|| { - let arr: Id> = NSArray::new(); - let _obj: *mut Object = msg_send![&arr, objectAtIndex: 0usize]; + let arr: Id> = NSArray::new(); + let _obj: *mut NSObject = msg_send![&arr, objectAtIndex: 0usize]; }) }; let exc = res.unwrap_err().unwrap(); diff --git a/crates/tests/src/test_encode_utils.rs b/crates/tests/src/test_encode_utils.rs index 5f7b15b84..1892ca559 100644 --- a/crates/tests/src/test_encode_utils.rs +++ b/crates/tests/src/test_encode_utils.rs @@ -2,7 +2,7 @@ use core::fmt::Display; use core::sync::atomic::{AtomicI32, AtomicPtr}; use objc2::ffi::{NSInteger, NSUInteger}; -use objc2::runtime::{Bool, Class, Object, Sel}; +use objc2::runtime::{AnyClass, AnyObject, Bool, Sel}; use objc2::{Encode, Encoding}; use paste::paste; use std::ffi::CStr; @@ -258,8 +258,8 @@ assert_types! { // Objective-C OBJC_BOOL => Bool, - ID => enc <*mut Object>::ENCODING, - CLASS => enc <&Class>::ENCODING, + ID => enc <*mut AnyObject>::ENCODING, + CLASS => enc <&AnyClass>::ENCODING, // Sel is (intentionally) not RefEncode SEL => enc ::ENCODING, NS_INTEGER => NSInteger, diff --git a/crates/tests/src/test_object.rs b/crates/tests/src/test_object.rs index f7fd95295..ec8850ab8 100644 --- a/crates/tests/src/test_object.rs +++ b/crates/tests/src/test_object.rs @@ -6,7 +6,9 @@ use std::os::raw::c_int; use icrate::Foundation::NSNumber; use objc2::encode::{Encoding, RefEncode}; use objc2::rc::{autoreleasepool, AutoreleasePool, Id}; -use objc2::runtime::{Bool, Class, NSObject, NSObjectProtocol, Object, Protocol, ProtocolObject}; +use objc2::runtime::{ + AnyClass, AnyObject, Bool, NSObject, NSObjectProtocol, AnyProtocol, ProtocolObject, +}; #[cfg(feature = "malloc")] use objc2::sel; use objc2::{ @@ -92,7 +94,7 @@ unsafe impl ClassType for MyTestObject { type Mutability = mutability::Mutable; const NAME: &'static str = "MyTestObject"; - fn class() -> &'static Class { + fn class() -> &'static AnyClass { class!(MyTestObject) } @@ -159,19 +161,19 @@ impl MyTestObject { unsafe { self.inner.ivar_mut("var2") } } - fn var3(&self) -> *mut Object { + fn var3(&self) -> *mut AnyObject { unsafe { msg_send![self, var3] } } - fn set_var3(&mut self, obj: *mut Object) { + fn set_var3(&mut self, obj: *mut AnyObject) { unsafe { msg_send![self, setVar3: obj] } } - fn var3_ivar(&self) -> &*mut Object { + fn var3_ivar(&self) -> &*mut AnyObject { unsafe { self.inner.ivar("var3") } } - fn var3_ivar_mut(&mut self) -> &mut *mut Object { + fn var3_ivar_mut(&mut self) -> &mut *mut AnyObject { unsafe { self.inner.ivar_mut("var3") } } } @@ -218,13 +220,13 @@ fn test_class() { #[cfg(feature = "malloc")] { - let classes = Class::classes(); - assert_eq!(classes.len(), Class::classes_count()); + let classes = AnyClass::classes(); + assert_eq!(classes.len(), AnyClass::classes_count()); assert_in!(cls, classes); } // Test objc2::runtime functionality - assert_eq!(Class::get("MyTestObject"), Some(cls)); + assert_eq!(AnyClass::get("MyTestObject"), Some(cls)); assert_ne!(cls, class!(NSObject)); assert_eq!(cls.name(), "MyTestObject"); assert_eq!(cls.superclass(), Some(class!(NSObject))); @@ -233,7 +235,7 @@ fn test_class() { assert_eq!(cls.instance_size(), { #[repr(C)] struct MyTestObjectLayout { - isa: *const Class, + isa: *const AnyClass, var1: c_int, var2: Bool, var3: *mut NSObject, @@ -241,14 +243,14 @@ fn test_class() { size_of::() }); - let protocol = Protocol::get("NSObject").unwrap(); + let protocol = AnyProtocol::get("NSObject").unwrap(); assert!(cls.conforms_to(protocol)); - assert!(!cls.conforms_to(Protocol::get("NSCopying").unwrap())); + assert!(!cls.conforms_to(AnyProtocol::get("NSCopying").unwrap())); #[cfg(feature = "malloc")] { assert_not_in!(protocol, cls.adopted_protocols()); assert_in!( - Protocol::get("MyTestProtocol").unwrap(), + AnyProtocol::get("MyTestProtocol").unwrap(), cls.adopted_protocols() ); }