diff --git a/Cargo.lock b/Cargo.lock index 55924b187..e751753f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1407,7 +1407,7 @@ dependencies = [ ] [[package]] -name = "test_declare_class" +name = "test_define_class" version = "0.1.0" dependencies = [ "objc2", diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index c1abb805e..884ba63fd 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -29,14 +29,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Implement `Message` for `AnyClass` and `AnyProtocol`. * Allow `AnyClass` and `AnyProtocol` to be converted to `AnyObject` (both of these can act as objects). -* Classes created using `declare_class!` now implement `Send` and `Sync` when +* Classes created using `define_class!` now implement `Send` and `Sync` when subclassing `NSObject`. ### Changed -* **BREAKING**: Changed the syntax of `declare_class!` to be more succinct: +* **BREAKING**: Renamed `declare_class!` to `define_class!`, and changed the + syntax to be more succinct: ```rust // Before + use objc2::mutability::InteriorMutable; + use objc2::runtime::NSObject; + use objc2::{declare_class, ClassType, DeclaredClass}; + + struct MyIvars; + declare_class!( struct MyObject; @@ -54,7 +61,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ); // After - declare_class!( + use objc2::runtime::NSObject; + use objc2::define_class; + + struct MyIvars; + + define_class!( #[unsafe(super(NSObject))] #[name = "MyObject"] #[ivars = MyIvars] @@ -69,6 +81,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * **BREAKING**: Changed the syntax of `extern_class!` to be more succinct: ```rust // Before + use objc2::mutability::MainThreadOnly; + use objc2::runtime::NSObject; + use objc2::{extern_class, ClassType}; + extern_class!( #[derive(PartialEq, Eq, Hash, Debug)] struct MyClass; @@ -81,6 +97,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ); // After + use objc2::runtime::NSObject; + use objc2::{extern_class, MainThreadOnly}; + extern_class!( #[unsafe(super(NSObject))] #[thread_kind = MainThreadOnly] @@ -126,6 +145,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * Deprecated `NSObjectProtocol::is_kind_of`, use `isKindOfClass` or the new `AnyObject::downcast_ref` method instead. * Deprecated `Retained::cast`, this has been renamed to `Retained::cast_unchecked`. +* Renamed `DeclaredClass` to `DefinedClass`. ### Removed * **BREAKING**: Removed the `ffi::SEL` and `ffi::objc_selector` types. Use diff --git a/crates/objc2/examples/class_with_lifetime.rs b/crates/objc2/examples/class_with_lifetime.rs index dfc83d90b..a93a3d215 100644 --- a/crates/objc2/examples/class_with_lifetime.rs +++ b/crates/objc2/examples/class_with_lifetime.rs @@ -1,5 +1,5 @@ -//! Note: We can't use the `declare_class!` macro for this, it doesn't support -//! such use-cases (yet). Instead, we'll declare the class manually. +//! Note: We can't use the `define_class!` macro for this, it doesn't support +//! such use-cases (yet). Instead, we'll create it manually. #![deny(unsafe_op_in_unsafe_fn)] use std::cell::Cell; use std::marker::PhantomData; diff --git a/crates/objc2/src/__macro_helpers/common_selectors.rs b/crates/objc2/src/__macro_helpers/common_selectors.rs index 978c88018..c1766e771 100644 --- a/crates/objc2/src/__macro_helpers/common_selectors.rs +++ b/crates/objc2/src/__macro_helpers/common_selectors.rs @@ -44,10 +44,10 @@ fn cxx_construct_sel() -> Sel { /// undocumented in clang - but since the selector is emitted into the final /// binary, it is fine to rely on it being used. /// -/// Unfortunately though, this only works if the class has been declared +/// Unfortunately though, this only works if the class has been defined /// statically, since in that case a flag is set to inform the runtime that it /// needs to run destructors. So unfortunately we can't use this on -/// dynamically declared classes. +/// dynamically defined classes. /// /// /// # ABI diff --git a/crates/objc2/src/__macro_helpers/convert.rs b/crates/objc2/src/__macro_helpers/convert.rs index 29b63e3cd..945910737 100644 --- a/crates/objc2/src/__macro_helpers/convert.rs +++ b/crates/objc2/src/__macro_helpers/convert.rs @@ -25,7 +25,7 @@ pub trait ConvertArgument: argument_private::Sealed { type __StoredBeforeMessage: Sized; #[doc(hidden)] - fn __from_declared_param(inner: Self::__Inner) -> Self; + fn __from_defined_param(inner: Self::__Inner) -> Self; #[doc(hidden)] fn __into_argument(self) -> (Self::__Inner, Self::__StoredBeforeMessage); @@ -48,7 +48,7 @@ impl ConvertArgument for T { type __StoredBeforeMessage = (); #[inline] - fn __from_declared_param(inner: Self::__Inner) -> Self { + fn __from_defined_param(inner: Self::__Inner) -> Self { inner } @@ -65,7 +65,7 @@ impl ConvertArgument for bool { type __StoredBeforeMessage = (); #[inline] - fn __from_declared_param(inner: Self::__Inner) -> Self { + fn __from_defined_param(inner: Self::__Inner) -> Self { inner.as_bool() } @@ -86,7 +86,7 @@ pub trait ConvertReturn: return_private::Sealed { type __Inner: EncodeReturn; #[doc(hidden)] - fn __into_declared_return(self) -> Self::__Inner; + fn __into_defined_return(self) -> Self::__Inner; #[doc(hidden)] fn __from_return(inner: Self::__Inner) -> Self; @@ -97,7 +97,7 @@ impl ConvertReturn for T { type __Inner = Self; #[inline] - fn __into_declared_return(self) -> Self::__Inner { + fn __into_defined_return(self) -> Self::__Inner { self } @@ -112,7 +112,7 @@ impl ConvertReturn for bool { type __Inner = Bool; #[inline] - fn __into_declared_return(self) -> Self::__Inner { + fn __into_defined_return(self) -> Self::__Inner { Bool::new(self) } @@ -295,7 +295,7 @@ mod tests { TypeId::of::<::__Inner>(), TypeId::of::() ); - assert_eq!(::__from_declared_param(42), 42); + assert_eq!(::__from_defined_param(42), 42); assert_eq!(ConvertArgument::__into_argument(42i32).0, 42); } @@ -305,21 +305,21 @@ mod tests { TypeId::of::<::__Inner>(), TypeId::of::() ); - assert_eq!(::__from_declared_param(-3), -3); + assert_eq!(::__from_defined_param(-3), -3); assert_eq!(ConvertArgument::__into_argument(-3i32).0, -3); } #[test] fn convert_bool() { - assert!(!::__from_declared_param(Bool::NO)); - assert!(::__from_declared_param(Bool::YES)); + assert!(!::__from_defined_param(Bool::NO)); + assert!(::__from_defined_param(Bool::YES)); assert!(!::__from_return(Bool::NO)); assert!(::__from_return(Bool::YES)); assert!(!ConvertArgument::__into_argument(false).0.as_bool()); assert!(ConvertArgument::__into_argument(true).0.as_bool()); - assert!(!ConvertReturn::__into_declared_return(false).as_bool()); - assert!(ConvertReturn::__into_declared_return(true).as_bool()); + assert!(!ConvertReturn::__into_defined_return(false).as_bool()); + assert!(ConvertReturn::__into_defined_return(true).as_bool()); #[cfg(all(target_vendor = "apple", target_os = "macos", target_arch = "x86_64"))] assert_eq!( diff --git a/crates/objc2/src/__macro_helpers/declare_class.rs b/crates/objc2/src/__macro_helpers/define_class.rs similarity index 96% rename from crates/objc2/src/__macro_helpers/declare_class.rs rename to crates/objc2/src/__macro_helpers/define_class.rs index 8de7e28ba..d417d1e1d 100644 --- a/crates/objc2/src/__macro_helpers/declare_class.rs +++ b/crates/objc2/src/__macro_helpers/define_class.rs @@ -13,12 +13,12 @@ use crate::runtime::{ }; #[cfg(debug_assertions)] use crate::runtime::{AnyProtocol, MethodDescription}; -use crate::{AllocAnyThread, ClassType, DeclaredClass, Message, ProtocolType}; +use crate::{AllocAnyThread, ClassType, DefinedClass, Message, ProtocolType}; -use super::declared_ivars::{register_with_ivars, setup_dealloc}; +use super::defined_ivars::{register_with_ivars, setup_dealloc}; use super::{Copy, Init, MaybeUnwrap, MutableCopy, New, Other}; -/// Helper for determining auto traits of declared classes. +/// Helper for determining auto traits of defined classes. /// /// This will contain either `dyn AllocAnyThread` or `dyn MainThreadOnly`, so /// it will have no auto traits by default. @@ -64,7 +64,7 @@ unsafe impl Encode for RetainedReturnValue { } // One could imagine a different design where we had a method like -// `fn convert_receiver()`, but that won't work in `declare_class!` since we +// `fn convert_receiver()`, but that won't work in `define_class!` since we // can't actually modify the `self` argument (e.g. `let self = foo(self)` is // not allowed). // @@ -143,7 +143,7 @@ where /// Helper trait for specifying an `Retained` or an `Option>`. /// -/// (Both of those are valid return types from declare_class! `#[method_id]`). +/// (Both of those are valid return types from define_class! `#[method_id]`). pub trait MaybeOptionRetained: MaybeUnwrap { fn consumed_return(self) -> RetainedReturnValue; fn autorelease_return(self) -> RetainedReturnValue; @@ -195,7 +195,7 @@ fn create_builder(name: &str, superclass: &AnyClass) -> ClassBuilder { } } -impl ClassBuilderHelper { +impl ClassBuilderHelper { #[inline] #[track_caller] #[allow(clippy::new_without_default)] @@ -302,7 +302,7 @@ pub struct ClassProtocolMethodsBuilder<'a, T: ?Sized> { registered_class_methods: HashSet, } -impl ClassProtocolMethodsBuilder<'_, T> { +impl ClassProtocolMethodsBuilder<'_, T> { // Addition: This restricts to callee `T` #[inline] pub unsafe fn add_method(&mut self, sel: Sel, func: F) diff --git a/crates/objc2/src/__macro_helpers/declared_ivars.rs b/crates/objc2/src/__macro_helpers/defined_ivars.rs similarity index 94% rename from crates/objc2/src/__macro_helpers/declared_ivars.rs rename to crates/objc2/src/__macro_helpers/defined_ivars.rs index 5cd7126ef..c20c21fd2 100644 --- a/crates/objc2/src/__macro_helpers/declared_ivars.rs +++ b/crates/objc2/src/__macro_helpers/defined_ivars.rs @@ -1,4 +1,4 @@ -//! # Supporting code for instance variables on declared classes. +//! # Supporting code for instance variables on defined classes. //! //! Adding instance variables to Objective-C classes is fairly simple, it can //! be done using `ClassBuilder::add_ivar`. @@ -14,7 +14,7 @@ //! following tagged enum: //! ``` //! #[repr(u8)] -//! enum ActualIvar { +//! enum ActualIvar { //! Allocated = 0, //! PartialInit(T::Ivars), //! Finalized(T::Ivars), @@ -54,7 +54,7 @@ use core::ptr::{self, NonNull}; use crate::encode::{Encode, Encoding}; use crate::runtime::{AnyClass, AnyObject, ClassBuilder, MessageReceiver, Sel}; -use crate::{sel, ClassType, DeclaredClass}; +use crate::{sel, ClassType, DefinedClass}; /// A type representing the drop flags that may be set for a type. #[repr(u8)] @@ -82,12 +82,12 @@ unsafe impl Encode for DropFlag { const ENCODING: Encoding = u8::ENCODING; } -pub trait DeclaredIvarsHelper { +pub trait DefinedIvarsHelper { const HAS_IVARS: bool; const HAS_DROP_FLAG: bool; } -impl DeclaredIvarsHelper for T { +impl DefinedIvarsHelper for T { /// Only add ivar if we need the runtime to allocate memory for it. /// /// We can avoid doing so if the type is a zero-sized type (ZST), and the @@ -112,7 +112,7 @@ impl DeclaredIvarsHelper for T { /// The pointer must be valid, and the instance variable offset (if it has /// any) must have been initialized. #[inline] -unsafe fn ptr_to_ivar(ptr: NonNull) -> NonNull { +unsafe fn ptr_to_ivar(ptr: NonNull) -> NonNull { // This is called even when there is no ivars, but that's fine, since in // that case the ivar is zero-sized, and the offset will be zero, so we // can still compute a valid pointer to the ivar. @@ -120,7 +120,7 @@ unsafe fn ptr_to_ivar(ptr: NonNull) -> NonNull(ptr.cast(), T::__ivars_offset()) } } @@ -130,14 +130,14 @@ unsafe fn ptr_to_ivar(ptr: NonNull) -> NonNull(ptr: NonNull) -> *mut DropFlag { +unsafe fn ptr_to_drop_flag(ptr: NonNull) -> *mut DropFlag { debug_assert!(T::HAS_DROP_FLAG, "type did not have drop flag"); // SAFETY: That a drop flag exists at the specified offset is ensured // by caller. unsafe { AnyObject::ivar_at_offset::(ptr.cast(), T::__drop_flag_offset()).as_ptr() } } -pub(crate) fn setup_dealloc(builder: &mut ClassBuilder) +pub(crate) fn setup_dealloc(builder: &mut ClassBuilder) where T::Super: ClassType, { @@ -158,7 +158,7 @@ where /// - /// - /// - -unsafe extern "C-unwind" fn dealloc(this: NonNull, cmd: Sel) +unsafe extern "C-unwind" fn dealloc(this: NonNull, cmd: Sel) where T::Super: ClassType, { @@ -236,7 +236,7 @@ where /// Register the class, and get the ivar offsets. #[inline] -pub(crate) fn register_with_ivars( +pub(crate) fn register_with_ivars( mut builder: ClassBuilder, ) -> (&'static AnyClass, isize, isize) { let (ivar_name, drop_flag_name): (Cow<'static, CStr>, Cow<'static, CStr>) = { @@ -281,7 +281,7 @@ pub(crate) fn register_with_ivars( if T::HAS_DROP_FLAG { // TODO: Maybe we can reuse the drop flag when subclassing an already - // declared class? + // defined class? builder.add_ivar::(&drop_flag_name); } @@ -291,7 +291,7 @@ pub(crate) fn register_with_ivars( // Monomorphized error handling // Intentionally not #[track_caller], we expect this error to never occur fn get_ivar_failed() -> ! { - unreachable!("failed retrieving instance variable on newly declared class") + unreachable!("failed retrieving instance variable on newly defined class") } cls.instance_variable(&ivar_name) @@ -309,7 +309,7 @@ pub(crate) fn register_with_ivars( // Monomorphized error handling // Intentionally not #[track_caller], we expect this error to never occur fn get_drop_flag_failed() -> ! { - unreachable!("failed retrieving drop flag instance variable on newly declared class") + unreachable!("failed retrieving drop flag instance variable on newly defined class") } cls.instance_variable(&drop_flag_name) @@ -331,7 +331,7 @@ pub(crate) fn register_with_ivars( /// The pointer must be a valid, newly allocated instance. #[inline] #[track_caller] -pub(crate) unsafe fn initialize_ivars(ptr: NonNull, val: T::Ivars) { +pub(crate) unsafe fn initialize_ivars(ptr: NonNull, val: T::Ivars) { // Debug assert the state of the drop flag if T::HAS_DROP_FLAG && cfg!(debug_assertions) { // SAFETY: Just checked that the drop flag is available. @@ -371,7 +371,7 @@ pub(crate) unsafe fn initialize_ivars(ptr: NonNull, val: T: /// have been run). #[inline] #[track_caller] -pub(crate) unsafe fn set_finalized(ptr: NonNull) { +pub(crate) unsafe fn set_finalized(ptr: NonNull) { // Debug assert the state of the drop flag if T::HAS_DROP_FLAG && cfg!(debug_assertions) { // SAFETY: Just checked that the drop flag is available. @@ -400,7 +400,7 @@ pub(crate) unsafe fn set_finalized(ptr: NonNull) { /// The pointer must be valid and the instance variables must be initialized. #[inline] #[track_caller] -pub(crate) unsafe fn get_initialized_ivar_ptr( +pub(crate) unsafe fn get_initialized_ivar_ptr( ptr: NonNull, ) -> NonNull { // Debug assert the state of the drop flag @@ -435,10 +435,10 @@ mod tests { use super::*; use crate::rc::{Allocated, PartialInit, RcTestObject, Retained, ThreadTestData}; use crate::runtime::NSObject; - use crate::{declare_class, msg_send, msg_send_id, AllocAnyThread, Message}; + use crate::{define_class, msg_send, msg_send_id, AllocAnyThread, Message}; /// Initialize superclasses, but not own class. - unsafe fn init_only_superclasses(obj: Allocated) -> Retained + unsafe fn init_only_superclasses(obj: Allocated) -> Retained where T::Super: ClassType, { @@ -446,7 +446,7 @@ mod tests { } /// Initialize, but fail to finalize (which is only done by `msg_send_id!`). - unsafe fn init_no_finalize(obj: Allocated) -> Retained + unsafe fn init_no_finalize(obj: Allocated) -> Retained where T::Super: ClassType, T::Ivars: Default, @@ -456,7 +456,7 @@ mod tests { } /// Initialize properly. - unsafe fn init(obj: Allocated) -> Retained { + unsafe fn init(obj: Allocated) -> Retained { unsafe { msg_send_id![obj, init] } } @@ -496,7 +496,7 @@ mod tests { // First class - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "ImplsDrop"] #[ivars = ()] @@ -530,7 +530,7 @@ mod tests { // Subclass - declare_class!( + define_class!( #[unsafe(super(ImplsDrop))] #[name = "IvarsImplDrop"] #[ivars = IvarThatImplsDrop] @@ -558,7 +558,7 @@ mod tests { // Further subclass - declare_class!( + define_class!( #[unsafe(super(IvarsImplDrop))] #[name = "BothIvarsAndTypeImplsDrop"] #[ivars = IvarThatImplsDrop] @@ -608,7 +608,7 @@ mod tests { field2: bool, } - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "IvarsNoDrop"] #[ivars = Ivar] @@ -628,7 +628,7 @@ mod tests { #[derive(Default, Debug, Clone, Copy)] struct Ivar; - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "IvarZst"] #[ivars = Cell] @@ -666,7 +666,7 @@ mod tests { #[repr(align(16))] struct HighAlignment; - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "HasIvarWithHighAlignment"] #[ivars = HighAlignment] @@ -691,7 +691,7 @@ mod tests { #[test] fn test_ivar_access() { - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "RcIvar"] #[ivars = Cell>>] @@ -751,7 +751,7 @@ mod tests { obj: Cell>, } - declare_class!( + define_class!( #[unsafe(super(RcIvar))] #[name = "RcIvarSubclass"] #[ivars = RcIvarSubclassIvars] @@ -816,7 +816,7 @@ mod tests { #[cfg_attr(not(debug_assertions), ignore = "only panics with debug assertions")] #[should_panic = "tried to access uninitialized instance variable"] fn access_invalid() { - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "InvalidAccess"] // Type has to have a drop flag to detect invalid access @@ -833,7 +833,7 @@ mod tests { #[should_panic = "panic in drop"] #[ignore = "panicking in Drop requires that we actually implement `dealloc` as `C-unwind`"] fn test_panic_in_drop() { - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "DropPanics"] struct DropPanics; @@ -862,7 +862,7 @@ mod tests { } } - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "IvarDropPanics"] #[ivars = DropPanics] @@ -882,7 +882,7 @@ mod tests { // performance. #[test] fn test_retain_leak_in_drop() { - declare_class!( + define_class!( // SAFETY: Intentionally broken! #[unsafe(super(NSObject))] #[name = "DropRetainsAndLeaksSelf"] diff --git a/crates/objc2/src/__macro_helpers/mod.rs b/crates/objc2/src/__macro_helpers/mod.rs index 4e70c879d..4e048b24d 100644 --- a/crates/objc2/src/__macro_helpers/mod.rs +++ b/crates/objc2/src/__macro_helpers/mod.rs @@ -18,8 +18,8 @@ mod cache; mod class; mod common_selectors; mod convert; -mod declare_class; -pub(crate) mod declared_ivars; +mod define_class; +pub(crate) mod defined_ivars; mod image_info; mod method_family; mod module_info; @@ -33,11 +33,11 @@ pub use self::cache::{CachedClass, CachedSel}; pub use self::class::{DoesNotImplDrop, MainThreadOnlyDoesNotImplSendSync, ValidThreadKind}; pub use self::common_selectors::{alloc_sel, dealloc_sel, init_sel, new_sel}; pub use self::convert::{ConvertArgument, ConvertArguments, ConvertReturn, TupleExtender}; -pub use self::declare_class::{ +pub use self::define_class::{ ClassBuilderHelper, ClassProtocolMethodsBuilder, MaybeOptionRetained, MessageReceiveRetained, RetainedReturnValue, ThreadKindAutoTraits, }; -pub use self::declared_ivars::DeclaredIvarsHelper; +pub use self::defined_ivars::DefinedIvarsHelper; pub use self::image_info::ImageInfo; pub use self::method_family::{ retain_semantics, Alloc, Copy, Init, MutableCopy, New, Other, RetainSemantics, diff --git a/crates/objc2/src/__macro_helpers/msg_send.rs b/crates/objc2/src/__macro_helpers/msg_send.rs index 188745ba1..1cad77fcd 100644 --- a/crates/objc2/src/__macro_helpers/msg_send.rs +++ b/crates/objc2/src/__macro_helpers/msg_send.rs @@ -184,7 +184,7 @@ impl MsgSend for ManuallyDrop> { mod tests { use crate::rc::{autoreleasepool, RcTestObject, ThreadTestData}; use crate::runtime::NSObject; - use crate::{declare_class, msg_send, msg_send_id, test_utils}; + use crate::{define_class, msg_send, msg_send_id, test_utils}; use super::*; @@ -229,7 +229,7 @@ mod tests { } } - declare_class!( + define_class!( #[unsafe(super(RcTestObject, NSObject))] #[name = "RcTestObjectSubclass"] #[derive(Debug, PartialEq, Eq)] diff --git a/crates/objc2/src/__macro_helpers/msg_send_retained.rs b/crates/objc2/src/__macro_helpers/msg_send_retained.rs index c5913f569..8f801128a 100644 --- a/crates/objc2/src/__macro_helpers/msg_send_retained.rs +++ b/crates/objc2/src/__macro_helpers/msg_send_retained.rs @@ -3,9 +3,9 @@ use core::ptr::{self, NonNull}; use crate::encode::{Encode, RefEncode}; use crate::rc::{Allocated, PartialInit, Retained}; use crate::runtime::{AnyClass, AnyObject, Sel}; -use crate::{sel, ClassType, DeclaredClass, Message}; +use crate::{sel, ClassType, DefinedClass, Message}; -use super::declared_ivars::set_finalized; +use super::defined_ivars::set_finalized; use super::{Alloc, ConvertArguments, Copy, Init, MsgSend, MutableCopy, New, Other, TupleExtender}; pub trait MsgSendRetained { @@ -300,7 +300,7 @@ impl MsgSendRetained, Option>> for } } -impl MsgSendSuperRetained, Option>> for Init { +impl MsgSendSuperRetained, Option>> for Init { type Inner = T; #[inline] @@ -1008,7 +1008,7 @@ mod tests { 1 } else if cfg!(target_arch = "x86") { // x86 autorelease_return is not currently tail-called, so the - // optimization doesn't work on declare_class! functions. + // optimization doesn't work on define_class! functions. 2 } else if cfg!(target_arch = "aarch64") { // Currently doesn't work diff --git a/crates/objc2/src/__macro_helpers/writeback.rs b/crates/objc2/src/__macro_helpers/writeback.rs index f16ceaa06..ef6ff334d 100644 --- a/crates/objc2/src/__macro_helpers/writeback.rs +++ b/crates/objc2/src/__macro_helpers/writeback.rs @@ -34,8 +34,8 @@ impl ConvertArgument for &mut Retained { ); #[inline] - fn __from_declared_param(_inner: Self::__Inner) -> Self { - todo!("`&mut Retained<_>` is not supported in `declare_class!` yet") + fn __from_defined_param(_inner: Self::__Inner) -> Self { + todo!("`&mut Retained<_>` is not supported in `define_class!` yet") } #[inline] @@ -115,8 +115,8 @@ impl ConvertArgument for &mut Option> { type __StoredBeforeMessage = (Self::__Inner, *mut T); #[inline] - fn __from_declared_param(_inner: Self::__Inner) -> Self { - todo!("`&mut Option>` is not supported in `declare_class!` yet") + fn __from_defined_param(_inner: Self::__Inner) -> Self { + todo!("`&mut Option>` is not supported in `define_class!` yet") } #[inline] @@ -162,8 +162,8 @@ impl ConvertArgument for Option<&mut Retained> { type __StoredBeforeMessage = Option<(NonNull<*mut T>, NonNull)>; #[inline] - fn __from_declared_param(_inner: Self::__Inner) -> Self { - todo!("`Option<&mut Retained<_>>` is not supported in `declare_class!` yet") + fn __from_defined_param(_inner: Self::__Inner) -> Self { + todo!("`Option<&mut Retained<_>>` is not supported in `define_class!` yet") } #[inline] @@ -191,8 +191,8 @@ impl ConvertArgument for Option<&mut Option>> type __StoredBeforeMessage = Option<(NonNull<*mut T>, *mut T)>; #[inline] - fn __from_declared_param(_inner: Self::__Inner) -> Self { - todo!("`Option<&mut Option>>` is not supported in `declare_class!` yet") + fn __from_defined_param(_inner: Self::__Inner) -> Self { + todo!("`Option<&mut Option>>` is not supported in `define_class!` yet") } #[inline] diff --git a/crates/objc2/src/downcast.rs b/crates/objc2/src/downcast.rs index 6efbff7d5..537e4c208 100644 --- a/crates/objc2/src/downcast.rs +++ b/crates/objc2/src/downcast.rs @@ -12,10 +12,10 @@ use crate::ClassType; /// is unknown. /// /// This trait is implemented automatically by the [`extern_class!`] and -/// [`declare_class!`] macros. +/// [`define_class!`] macros. /// /// [`extern_class!`]: crate::extern_class -/// [`declare_class!`]: crate::declare_class +/// [`define_class!`]: crate::define_class /// /// /// # Safety diff --git a/crates/objc2/src/encode.rs b/crates/objc2/src/encode.rs index 81a2a49e0..f7861f70f 100644 --- a/crates/objc2/src/encode.rs +++ b/crates/objc2/src/encode.rs @@ -350,7 +350,7 @@ mod argument_private { // // You might be tempted to think that `bool` could work in this, but that // would be a mistake (even ignoring that its size is different on certain -// targets) because it cannot be safely used in declared methods. +// targets) because it cannot be safely used in custom defined methods. pub unsafe trait EncodeArgument: argument_private::Sealed { /// The Objective-C type-encoding for this type. const ENCODING_ARGUMENT: Encoding; diff --git a/crates/objc2/src/lib.rs b/crates/objc2/src/lib.rs index 4ff7ab12e..35cecd686 100644 --- a/crates/objc2/src/lib.rs +++ b/crates/objc2/src/lib.rs @@ -138,13 +138,11 @@ //! //! ## Other functionality //! -//! That was a quick introduction, this library also has [support for handling -//! exceptions][exc], [the ability to declare Objective-C -//! classes][declare_class!], [advanced reference-counting utilities][rc], and more - -//! peruse the documentation at will! -//! -//! [exc]: crate::exception -//! [rc]: crate::rc +//! That was a quick introduction, this library also has +//! [support for handling exceptions][crate::exception], +//! [the ability to create Objective-C classes][crate::define_class], +//! [advanced reference-counting utilities][crate::rc], +//! and more - peruse the documentation at will! #![no_std] #![cfg_attr( @@ -179,7 +177,7 @@ pub use self::downcast::DowncastTarget; pub use self::encode::{Encode, Encoding, RefEncode}; pub use self::main_thread_marker::MainThreadMarker; pub use self::top_level_traits::{ - AllocAnyThread, ClassType, DeclaredClass, MainThreadOnly, Message, ProtocolType, ThreadKind, + AllocAnyThread, ClassType, DefinedClass, MainThreadOnly, Message, ProtocolType, ThreadKind, }; #[cfg(feature = "objc2-proc-macros")] @@ -221,8 +219,8 @@ mod verify; /// module. #[deprecated = "Moved to the `runtime` module"] pub mod declare { + use super::runtime; pub use super::runtime::{ClassBuilder, ProtocolBuilder}; - use super::*; /// Use [`runtime::ClassBuilder`] instead. #[deprecated = "Use `runtime::ClassBuilder` instead."] @@ -233,6 +231,10 @@ pub mod declare { pub type ProtocolDecl = runtime::ProtocolBuilder; } +/// Deprecated alias of [`DefinedClass`]. +#[deprecated = "renamed to DefinedClass"] +pub use DefinedClass as DeclaredClass; + #[cfg(not(feature = "std"))] compile_error!("The `std` feature currently must be enabled."); diff --git a/crates/objc2/src/macros/__attribute_helpers.rs b/crates/objc2/src/macros/__attribute_helpers.rs index 40e9c2342..46e2bd054 100644 --- a/crates/objc2/src/macros/__attribute_helpers.rs +++ b/crates/objc2/src/macros/__attribute_helpers.rs @@ -335,7 +335,7 @@ macro_rules! __extract_custom_attributes_inner { /// Extract struct attributes, and send them to another macro. /// -/// Used by `declare_class!` and `extern_class!`. +/// Used by `define_class!` and `extern_class!`. /// /// This will ensure that there is only one of our custom attributes present. /// diff --git a/crates/objc2/src/macros/declare_class.rs b/crates/objc2/src/macros/define_class.rs similarity index 89% rename from crates/objc2/src/macros/declare_class.rs rename to crates/objc2/src/macros/define_class.rs index db2c67c0a..992d99117 100644 --- a/crates/objc2/src/macros/declare_class.rs +++ b/crates/objc2/src/macros/define_class.rs @@ -1,4 +1,4 @@ -/// Declare a new class. +/// Create a new class. /// /// This is useful in many cases since Objective-C frameworks tend to favour a /// design pattern using "delegates", where to hook into a piece of @@ -6,23 +6,27 @@ /// a custom class. /// /// This macro is the declarative way of creating classes, in contrast with -/// the [`declare`] module which mostly contain ways of declaring classes in -/// an imperative fashion. It is highly recommended that you use this macro -/// though, since it contains a lot of extra debug assertions and niceties -/// that help ensure the soundness of your code. +/// [`ClassBuilder`], which allows creating classes in an imperative fashion. +/// It is highly recommended that you use this macro though, since it contains +/// a lot of extra debug assertions and niceties that help ensure the +/// soundness of your code. /// /// The class is guaranteed to have been created and registered with the /// Objective-C runtime after the [`ClassType::class`] function has been /// called. /// -/// [`declare`]: crate::declare +/// See [Apple's documentation] on defining classes for a more in-depth +/// introduction. +/// +/// [Apple's documentation]: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/ProgrammingWithObjectiveC/DefiningClasses/DefiningClasses.html +/// [`ClassBuilder`]: crate::runtime::ClassBuilder /// [`ClassType::class`]: crate::ClassType::class /// /// /// # Specification /// /// This macro consists of the following parts: -/// - The type declaration with special attributes. +/// - The type definition, along with special attributes. /// - Any number of inherent implementations. /// - Any number of protocol implementations. /// @@ -31,7 +35,7 @@ /// /// This macro creates an opaque struct with implementations in [a similar /// manner as the `extern_class!` macro][ec_spec]. Additionally, it implements -/// the [`DeclaredClass`] trait, as well as any protocols specified in the +/// the [`DefinedClass`] trait, as well as any protocols specified in the /// protocol implementations. /// /// If the type implements [`Drop`], the macro will generate a `dealloc` @@ -42,7 +46,7 @@ /// [`extern_class!`]: crate::extern_class /// [`extern_methods!`]: crate::extern_methods /// [ec_spec]: crate::extern_class#specification -/// [`DeclaredClass`]: crate::DeclaredClass +/// [`DefinedClass`]: crate::DefinedClass /// /// /// ## Attributes @@ -86,7 +90,7 @@ /// `init`), you must override the subclass' designated initializers, and /// initialize your ivars properly in there. /// -/// [the instance variables]: crate::DeclaredClass::Ivars +/// [the instance variables]: crate::DefinedClass::Ivars /// [`Cell`]: core::cell::Cell /// [`RefCell`]: core::cell::RefCell /// [interior_mutability]: crate::topics::interior_mutability @@ -252,7 +256,7 @@ /// /// # Examples /// -/// Declare a class `MyCustomObject` that inherits `NSObject`, has a few +/// Define a class `MyCustomObject` that inherits `NSObject`, has a few /// instance variables and methods, and implements the `NSCopying` protocol. /// /// ``` @@ -263,8 +267,8 @@ /// use objc2_foundation::{NSCopying, NSObject, NSObjectProtocol, NSZone}; /// use objc2::rc::{Allocated, Retained}; /// use objc2::{ -/// declare_class, extern_protocol, msg_send, msg_send_id, AllocAnyThread, -/// ClassType, DeclaredClass, ProtocolType, +/// define_class, extern_protocol, msg_send, msg_send_id, AllocAnyThread, +/// ClassType, DefinedClass, ProtocolType, /// }; /// /// #[derive(Clone)] @@ -274,7 +278,7 @@ /// object: Retained, /// } /// -/// declare_class!( +/// define_class!( /// // SAFETY: /// // - The superclass NSObject does not have any subclassing requirements. /// // - `MyCustomObject` does not implement `Drop`. @@ -430,7 +434,7 @@ #[doc(alias = "@interface")] #[doc(alias = "@implementation")] #[macro_export] -macro_rules! declare_class { +macro_rules! define_class { { // The following special attributes are supported: // - #[unsafe(super($($superclasses:path),*))] @@ -449,14 +453,14 @@ macro_rules! declare_class { $crate::__extract_struct_attributes! { ($(#[$($attrs)*])*) - ($crate::__declare_class_inner) + ($crate::__define_class_inner) ($v) ($class) ($($impls)*) } // Methods. - $crate::__declare_class_output_impls! { + $crate::__define_class_output_impls! { $($impls)* } }; @@ -464,7 +468,37 @@ macro_rules! declare_class { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_inner { +macro_rules! declare_class { + { + $(#[$m:meta])* + $v:vis struct $name:ident; + + unsafe impl ClassType for $for_class:ty { + $(#[inherits($($inheritance_rest:ty),+)])? + type Super = $superclass:ty; + + type Mutability = $mutability:ty; + + const NAME: &'static str = $name_const:expr; + } + + impl DefinedClass for $for_defined:ty { + $(type Ivars = $ivars:ty;)? + } + + $($impls:tt)* + } => { + // For slightly better diagnostics + $(#[$m])* + $v struct $name; + + $crate::__macro_helpers::compile_error!("declare_class! has been renamed to define_class!, and the syntax has changed") + } +} + +#[doc(hidden)] +#[macro_export] +macro_rules! __define_class_inner { ( ($v:vis) ($class:ident) @@ -494,7 +528,7 @@ macro_rules! __declare_class_inner { }>, __phantom: $crate::__macro_helpers::PhantomData<( // Include ivars for auto traits. - ::Ivars, + ::Ivars, // Translate thread kind to appropriate auto traits. $crate::__macro_helpers::ThreadKindAutoTraits<::ThreadKind>, )>, @@ -507,7 +541,7 @@ macro_rules! __declare_class_inner { ($($superclass, $($superclasses,)*)? $crate::runtime::AnyObject) } - $crate::__declare_class_derives! { + $crate::__define_class_derives! { ($($attr_impl)*) ($class) ($($derives)*) @@ -556,7 +590,7 @@ macro_rules! __declare_class_inner { let mut __objc2_builder = $crate::__macro_helpers::ClassBuilderHelper::::new(); // Implement protocols and methods - $crate::__declare_class_register_impls! { + $crate::__define_class_register_impls! { (__objc2_builder) $($impls)* } @@ -567,10 +601,10 @@ macro_rules! __declare_class_inner { // before any access to the variables. unsafe { __OBJC2_CLASS.get().write($crate::__macro_helpers::MaybeUninit::new(__objc2_cls)); - if ::HAS_IVARS { + if ::HAS_IVARS { __OBJC2_IVAR_OFFSET.get().write($crate::__macro_helpers::MaybeUninit::new(__objc2_ivar_offset)); } - if ::HAS_DROP_FLAG { + if ::HAS_DROP_FLAG { __OBJC2_DROP_FLAG_OFFSET.get().write($crate::__macro_helpers::MaybeUninit::new(__objc2_drop_flag_offset)); } } @@ -590,7 +624,7 @@ macro_rules! __declare_class_inner { type __SubclassingType = Self; } - impl $crate::DeclaredClass for $class { + impl $crate::DefinedClass for $class { type Ivars = $crate::__select_ivars!($($ivars)?); #[inline] @@ -599,7 +633,7 @@ macro_rules! __declare_class_inner { // // This makes the offset not be included in the final // executable if it's not needed. - if ::HAS_IVARS { + if ::HAS_IVARS { // SAFETY: Accessing the offset is guaranteed to only be // done after the class has been initialized. unsafe { __OBJC2_IVAR_OFFSET.get().read().assume_init() } @@ -614,7 +648,7 @@ macro_rules! __declare_class_inner { #[inline] fn __drop_flag_offset() -> $crate::__macro_helpers::isize { - if ::HAS_DROP_FLAG { + if ::HAS_DROP_FLAG { // SAFETY: Same as above. unsafe { __OBJC2_DROP_FLAG_OFFSET.get().read().assume_init() } } else { @@ -644,7 +678,7 @@ macro_rules! __declare_class_inner { /// Mirror of [`crate::__extern_class_derives`]. #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_derives { +macro_rules! __define_class_derives { // Base case ( ($($attr_impl:tt)*) @@ -668,12 +702,12 @@ macro_rules! __declare_class_derives { fn fmt(&self, f: &mut $crate::__macro_helpers::fmt::Formatter<'_>) -> $crate::__macro_helpers::fmt::Result { f.debug_struct($crate::__macro_helpers::stringify!($for)) .field("super", &**self.__superclass) - .field("ivars", ::ivars(self)) + .field("ivars", ::ivars(self)) .finish() } } - $crate::__declare_class_derives! { + $crate::__define_class_derives! { ($($attr_impl)*) ($for) ($($rest)*) @@ -700,7 +734,7 @@ macro_rules! __declare_class_derives { } } - $crate::__declare_class_derives! { + $crate::__define_class_derives! { ($($attr_impl)*) ($for) ($($rest)*) @@ -721,7 +755,7 @@ macro_rules! __declare_class_derives { #[automatically_derived] impl $crate::__macro_helpers::Eq for $for {} - $crate::__declare_class_derives! { + $crate::__define_class_derives! { ($($attr_impl)*) ($for) ($($rest)*) @@ -748,7 +782,7 @@ macro_rules! __declare_class_derives { } } - $crate::__declare_class_derives! { + $crate::__define_class_derives! { ($($attr_impl)*) ($for) ($($rest)*) @@ -771,10 +805,10 @@ macro_rules! __declare_class_derives { struct Derive; }; $crate::__macro_helpers::compile_error!($crate::__macro_helpers::stringify!( - #[derive($derive)] is not supported in declare_class! + #[derive($derive)] is not supported in define_class! )); - $crate::__declare_class_derives! { + $crate::__define_class_derives! { ($($attr_impl)*) ($for) ($($($rest)*)?) @@ -796,7 +830,7 @@ macro_rules! __select_ivars { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_output_impls { +macro_rules! __define_class_output_impls { // Base-case () => {}; @@ -815,12 +849,12 @@ macro_rules! __declare_class_output_impls { $(#[$m])* impl $for { - $crate::__declare_class_output_methods! { + $crate::__define_class_output_methods! { $($methods)* } } - $crate::__declare_class_output_impls!{ + $crate::__define_class_output_impls!{ $($rest)* } }; @@ -836,12 +870,12 @@ macro_rules! __declare_class_output_impls { ) => { $(#[$m])* impl $for { - $crate::__declare_class_output_methods! { + $crate::__define_class_output_methods! { $($methods)* } } - $crate::__declare_class_output_impls! { + $crate::__define_class_output_impls! { $($rest)* } }; @@ -849,7 +883,7 @@ macro_rules! __declare_class_output_impls { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_output_methods { +macro_rules! __define_class_output_methods { // Base case {} => {}; @@ -866,14 +900,14 @@ macro_rules! __declare_class_output_methods { ($crate::__extract_custom_attributes) ($(#[$($m)*])*) - ($crate::__declare_class_method_out) + ($crate::__define_class_method_out) (unsafe) ($name) ($($ret)?) ($body) } - $crate::__declare_class_output_methods! { + $crate::__define_class_output_methods! { $($rest)* } }; @@ -891,14 +925,14 @@ macro_rules! __declare_class_output_methods { ($crate::__extract_custom_attributes) ($(#[$($m)*])*) - ($crate::__declare_class_method_out) + ($crate::__define_class_method_out) () ($name) ($($ret)?) ($body) } - $crate::__declare_class_output_methods! { + $crate::__define_class_output_methods! { $($rest)* } }; @@ -906,7 +940,7 @@ macro_rules! __declare_class_output_methods { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_register_impls { +macro_rules! __define_class_register_impls { // Base-case ( ($builder:ident) @@ -936,18 +970,18 @@ macro_rules! __declare_class_register_impls { #[allow(unused_unsafe)] // SAFETY: Upheld by caller unsafe { - $crate::__declare_class_register_methods! { + $crate::__define_class_register_methods! { (__objc2_protocol_builder) $($methods)* } } - // Finished declaring protocol; get error message if any + // Finished creating protocol; get error message if any __objc2_protocol_builder.finish(); } - $crate::__declare_class_register_impls! { + $crate::__define_class_register_impls! { ($builder) $($rest)* } @@ -973,7 +1007,7 @@ macro_rules! __declare_class_register_impls { #[allow(unused_unsafe)] // SAFETY: Upheld by caller unsafe { - $crate::__declare_class_register_methods! { + $crate::__define_class_register_methods! { ($builder) $($methods)* @@ -981,7 +1015,7 @@ macro_rules! __declare_class_register_impls { } } - $crate::__declare_class_register_impls! { + $crate::__define_class_register_impls! { ($builder) $($rest)* } @@ -990,7 +1024,7 @@ macro_rules! __declare_class_register_impls { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_register_methods { +macro_rules! __define_class_register_methods { // Base case { ($builder:ident) @@ -1011,7 +1045,7 @@ macro_rules! __declare_class_register_methods { ($crate::__extract_custom_attributes) ($(#[$($m)*])*) - ($crate::__declare_class_register_out) + ($crate::__define_class_register_out) ($builder) (unsafe) ($name) @@ -1019,7 +1053,7 @@ macro_rules! __declare_class_register_methods { ($body) } - $crate::__declare_class_register_methods! { + $crate::__define_class_register_methods! { ($builder) $($rest)* @@ -1041,7 +1075,7 @@ macro_rules! __declare_class_register_methods { ($crate::__extract_custom_attributes) ($(#[$($m)*])*) - ($crate::__declare_class_register_out) + ($crate::__define_class_register_out) ($builder) () ($name) @@ -1049,7 +1083,7 @@ macro_rules! __declare_class_register_methods { ($body) } - $crate::__declare_class_register_methods! { + $crate::__define_class_register_methods! { ($builder) $($rest)* @@ -1058,7 +1092,7 @@ macro_rules! __declare_class_register_methods { // Consume associated items for better UI. // - // This will still fail inside __declare_class_output_methods! + // This will still fail inside __define_class_output_methods! { ($builder:ident) @@ -1066,7 +1100,7 @@ macro_rules! __declare_class_register_methods { $($rest:tt)* } => { - $crate::__declare_class_output_methods! { + $crate::__define_class_output_methods! { ($builder) $($rest)* @@ -1076,7 +1110,7 @@ macro_rules! __declare_class_register_methods { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_method_out { +macro_rules! __define_class_method_out { { ($($qualifiers:tt)*) ($name:ident) @@ -1094,12 +1128,12 @@ macro_rules! __declare_class_method_out { ($($m_optional:tt)*) ($($m_checked:tt)*) } => { - $crate::__declare_class_rewrite_params! { + $crate::__define_class_rewrite_params! { ($($params_rest)*) () () - ($crate::__declare_class_method_out_inner) + ($crate::__define_class_method_out_inner) ($($qualifiers)*) ($name) @@ -1121,7 +1155,7 @@ macro_rules! __declare_class_method_out { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_rewrite_params { +macro_rules! __define_class_rewrite_params { // Convert _ { (_ : $param_ty:ty $(, $($params_rest:tt)*)?) @@ -1131,7 +1165,7 @@ macro_rules! __declare_class_rewrite_params { ($out_macro:path) $($macro_args:tt)* } => { - $crate::__declare_class_rewrite_params! { + $crate::__define_class_rewrite_params! { ($($($params_rest)*)?) ($($params_converted)* _ : <$param_ty as $crate::__macro_helpers::ConvertArgument>::__Inner,) ($($body_prefix)*) @@ -1149,12 +1183,12 @@ macro_rules! __declare_class_rewrite_params { ($out_macro:path) $($macro_args:tt)* } => { - $crate::__declare_class_rewrite_params! { + $crate::__define_class_rewrite_params! { ($($($params_rest)*)?) ($($params_converted)* $param : <$param_ty as $crate::__macro_helpers::ConvertArgument>::__Inner,) ( $($body_prefix)* - let mut $param = <$param_ty as $crate::__macro_helpers::ConvertArgument>::__from_declared_param($param); + let mut $param = <$param_ty as $crate::__macro_helpers::ConvertArgument>::__from_defined_param($param); ) ($out_macro) @@ -1170,12 +1204,12 @@ macro_rules! __declare_class_rewrite_params { ($out_macro:path) $($macro_args:tt)* } => { - $crate::__declare_class_rewrite_params! { + $crate::__define_class_rewrite_params! { ($($($params_rest)*)?) ($($params_converted)* $param : <$param_ty as $crate::__macro_helpers::ConvertArgument>::__Inner,) ( $($body_prefix)* - let $param = <$param_ty as $crate::__macro_helpers::ConvertArgument>::__from_declared_param($param); + let $param = <$param_ty as $crate::__macro_helpers::ConvertArgument>::__from_defined_param($param); ) ($out_macro) @@ -1202,7 +1236,7 @@ macro_rules! __declare_class_rewrite_params { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_method_out_inner { +macro_rules! __define_class_method_out_inner { // #[method(...)] { ($($qualifiers:tt)*) @@ -1249,7 +1283,7 @@ macro_rules! __declare_class_method_out_inner { ($($params_prefix:tt)*) (#[method_id($($sel:tt)*)]) - () // Specifying retain semantics is unsupported in declare_class! for now + () // Specifying retain semantics is unsupported in define_class! for now ($($__m_optional:tt)*) ($($m_checked:tt)*) @@ -1318,13 +1352,13 @@ macro_rules! __convert_result { ($body:block; $ret:ty) => { let __objc2_result = $body; #[allow(unreachable_code)] - <$ret as $crate::__macro_helpers::ConvertReturn>::__into_declared_return(__objc2_result) + <$ret as $crate::__macro_helpers::ConvertReturn>::__into_defined_return(__objc2_result) }; } #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_register_out { +macro_rules! __define_class_register_out { { ($builder:ident) ($($qualifiers:tt)*) @@ -1346,7 +1380,7 @@ macro_rules! __declare_class_register_out { $crate::__extract_and_apply_cfg_attributes! { ($($m_checked)*) - $crate::__declare_class_invalid_selectors!(#[$method_or_method_id($($sel)*)]); + $crate::__define_class_invalid_selectors!(#[$method_or_method_id($($sel)*)]); $crate::__extern_methods_no_optional!($($m_optional)*); $builder.$builder_method( @@ -1363,7 +1397,7 @@ macro_rules! __declare_class_register_out { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_invalid_selectors { +macro_rules! __define_class_invalid_selectors { (#[method(dealloc)]) => { $crate::__macro_helpers::compile_error!( "`#[method(dealloc)]` is not supported. Implement `Drop` for the type instead" @@ -1403,7 +1437,7 @@ macro_rules! __declare_class_invalid_selectors { #[doc(hidden)] #[macro_export] -macro_rules! __declare_class_no_optional { +macro_rules! __define_class_no_optional { () => {}; (#[optional]) => { $crate::__macro_helpers::compile_error!( diff --git a/crates/objc2/src/macros/extern_methods.rs b/crates/objc2/src/macros/extern_methods.rs index f0bb14f4d..353b08703 100644 --- a/crates/objc2/src/macros/extern_methods.rs +++ b/crates/objc2/src/macros/extern_methods.rs @@ -69,12 +69,12 @@ /// use objc2::ffi::NSUInteger; /// use objc2::rc::{Allocated, Retained}; /// use objc2::runtime::NSObject; -/// use objc2::{declare_class, extern_methods}; +/// use objc2::{define_class, extern_methods}; /// /// // Shim /// type NSError = NSObject; /// -/// declare_class!( +/// define_class!( /// // SAFETY: /// // - The superclass NSObject does not have any subclassing requirements. /// // - `MyObject` does not implement `Drop`. @@ -122,12 +122,12 @@ /// # use objc2::ffi::NSUInteger; /// # use objc2::rc::{Allocated, Retained}; /// # use objc2::runtime::NSObject; -/// # use objc2::{declare_class, extern_methods, ClassType}; +/// # use objc2::{define_class, extern_methods, ClassType}; /// # /// # // Shim /// # type NSError = NSObject; /// # -/// # declare_class!( +/// # define_class!( /// # #[unsafe(super(NSObject))] /// # #[name = "MyObject2"] /// # pub struct MyObject; diff --git a/crates/objc2/src/macros/extern_protocol.rs b/crates/objc2/src/macros/extern_protocol.rs index 3f27a53c6..a180204de 100644 --- a/crates/objc2/src/macros/extern_protocol.rs +++ b/crates/objc2/src/macros/extern_protocol.rs @@ -12,7 +12,7 @@ /// to the functionality exposed by the protocol. /// /// Note that that conforming to a protocol in a custom object requires -/// putting the implementation inside the [`declare_class!`] invocation. +/// putting the implementation inside the [`define_class!`] invocation. /// /// Objective-C has a smart feature where you can write `id`, and /// then work with the protocol as-if it was an object; this is very similar @@ -43,14 +43,14 @@ /// /// Finally, you can use the `#[optional]` attribute to mark optional methods. /// This currently doesn't have any effect, but probably will have one in the -/// future when implementing protocols in [`declare_class!`]. +/// future when implementing protocols in [`define_class!`]. /// /// This macro otherwise shares similarities with [`extern_class!`] and /// [`extern_methods!`]. /// /// [`ProtocolObject`]: crate::runtime::ProtocolObject /// [`ProtocolType`]: crate::ProtocolType -/// [`declare_class!`]: crate::declare_class +/// [`define_class!`]: crate::define_class /// [`extern_class!`]: crate::extern_class /// [`extern_methods!`]: crate::extern_methods /// @@ -107,7 +107,7 @@ /// -> Retained>; /// /// // The rest of these are optional, which means that a user of -/// // `declare_class!` would not need to implement them. +/// // `define_class!` would not need to implement them. /// /// #[optional] /// #[method_id(writableTypeIdentifiersForItemProvider)] diff --git a/crates/objc2/src/macros/mod.rs b/crates/objc2/src/macros/mod.rs index 1e9ae1b9b..5c464fbc3 100644 --- a/crates/objc2/src/macros/mod.rs +++ b/crates/objc2/src/macros/mod.rs @@ -4,7 +4,7 @@ mod __method_msg_send; mod __msg_send_parse; mod __rewrite_self_param; mod available; -mod declare_class; +mod define_class; mod extern_category; mod extern_class; mod extern_methods; @@ -38,7 +38,7 @@ mod extern_protocol; /// Errors that were previously runtime panics may now turn into linker errors /// if you try to use a class which is not available. Additionally, you may /// have to call `msg_send![cls, class]` on the result if you want to use it -/// in a dynamic context (e.g. dynamically declaring classes). +/// in a dynamic context (e.g. when dynamically creating classes). /// /// See the [corresponding section][sel#features] in the [`sel!`] macro for /// more details on the limitations of this. The @@ -907,7 +907,7 @@ macro_rules! __class_inner { /// ```no_run /// use objc2::msg_send; /// # -/// # objc2::declare_class!( +/// # objc2::define_class!( /// # #[unsafe(super(objc2::runtime::NSObject))] /// # #[name = "MyObject"] /// # struct MyObject; diff --git a/crates/objc2/src/rc/allocated_partial_init.rs b/crates/objc2/src/rc/allocated_partial_init.rs index 4b819d25e..e65662e4f 100644 --- a/crates/objc2/src/rc/allocated_partial_init.rs +++ b/crates/objc2/src/rc/allocated_partial_init.rs @@ -3,9 +3,9 @@ use core::mem::ManuallyDrop; use core::ptr::NonNull; use core::{fmt, ptr}; -use crate::__macro_helpers::declared_ivars::initialize_ivars; +use crate::__macro_helpers::defined_ivars::initialize_ivars; use crate::runtime::{objc_release_fast, AnyObject}; -use crate::{DeclaredClass, Message}; +use crate::{DefinedClass, Message}; /// An Objective-C object that has been allocated, but not initialized. /// @@ -161,7 +161,7 @@ impl Allocated { #[track_caller] pub fn set_ivars(self, ivars: T::Ivars) -> PartialInit where - T: DeclaredClass + Sized, + T: DefinedClass + Sized, { if let Some(ptr) = NonNull::new(ManuallyDrop::new(self).ptr as *mut T) { // SAFETY: The pointer came from `self`, so it is valid. diff --git a/crates/objc2/src/rc/retained.rs b/crates/objc2/src/rc/retained.rs index 38b0f2728..15f135f75 100644 --- a/crates/objc2/src/rc/retained.rs +++ b/crates/objc2/src/rc/retained.rs @@ -637,9 +637,9 @@ impl Retained { /// The object is not immediately released, but will be when the innermost /// autorelease pool is drained. /// - /// This is useful when [declaring your own methods][declare] where you - /// will often find yourself in need of returning autoreleased objects to - /// properly follow [Cocoa's Memory Management Policy][mmRules]. + /// This is useful when [defining your own methods][classbuilder] where + /// you will often find yourself in need of returning autoreleased objects + /// to properly follow [Cocoa's Memory Management Policy][mmRules]. /// /// To that end, you could also use [`Retained::autorelease_ptr`], but /// this is more efficient than a normal `autorelease`, since it makes a @@ -650,20 +650,19 @@ impl Retained { /// This optimization relies heavily on this function being tail called, /// so make sure you only call this function at the end of your method. /// - /// [declare]: crate::declare + /// [classbuilder]: crate::runtime::ClassBuilder /// [mmRules]: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html /// /// /// # Example /// - /// Returning an `Retained` from a declared method (note: the [`declare_class!`] - /// macro supports doing this for you automatically). + /// Returning an `Retained` from a custom method (note: the + /// [`define_class!`] macro supports doing this for you automatically). /// /// ``` /// use objc2::{class, msg_send_id, sel}; - /// use objc2::declare::ClassBuilder; /// use objc2::rc::Retained; - /// use objc2::runtime::{AnyClass, AnyObject, Sel}; + /// use objc2::runtime::{AnyClass, AnyObject, ClassBuilder, Sel}; /// /// let mut builder = ClassBuilder::new(c"ExampleObject", class!(NSObject)).unwrap(); /// @@ -682,7 +681,7 @@ impl Retained { /// let cls = builder.register(); /// ``` /// - /// [`declare_class!`]: crate::declare_class + /// [`define_class!`]: crate::define_class #[doc(alias = "objc_autoreleaseReturnValue")] #[must_use = "if you don't intend to use the object any more, drop it as usual"] #[inline] @@ -736,7 +735,7 @@ impl Drop for Retained { /// /// The contained object's destructor (`Drop` impl, if it has one) is /// never run - override the `dealloc` method instead (which - /// `declare_class!` does for you). + /// `define_class!` does for you). #[doc(alias = "objc_release")] #[doc(alias = "release")] #[inline] @@ -846,13 +845,13 @@ mod tests { use super::*; use crate::rc::{autoreleasepool, RcTestObject, ThreadTestData}; use crate::runtime::{AnyObject, NSObject, NSObjectProtocol}; - use crate::{declare_class, msg_send}; + use crate::{define_class, msg_send}; #[test] fn auto_traits() { macro_rules! helper { ($name:ident) => { - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = concat!(stringify!($name), "Test")] // Make the type not thread safe by default. diff --git a/crates/objc2/src/rc/retained_traits.rs b/crates/objc2/src/rc/retained_traits.rs index a9b32c780..a60f6ff1d 100644 --- a/crates/objc2/src/rc/retained_traits.rs +++ b/crates/objc2/src/rc/retained_traits.rs @@ -118,9 +118,9 @@ impl> FromIterator for Retained { mod tests { use super::*; use crate::runtime::NSObject; - use crate::{declare_class, msg_send_id, ClassType}; + use crate::{define_class, msg_send_id, ClassType}; - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "MyCustomCollection"] #[derive(PartialEq, Eq, Hash, Debug)] diff --git a/crates/objc2/src/rc/test_object.rs b/crates/objc2/src/rc/test_object.rs index b3282d64b..988343b50 100644 --- a/crates/objc2/src/rc/test_object.rs +++ b/crates/objc2/src/rc/test_object.rs @@ -4,7 +4,7 @@ use core::ptr; use crate::rc::{Allocated, DefaultRetained, Retained}; use crate::runtime::{NSObject, NSZone}; -use crate::{declare_class, msg_send, msg_send_id, ClassType}; +use crate::{define_class, msg_send, msg_send_id, ClassType}; // TODO: Put tests that use this in another crate #[derive(Debug, Clone, Default, PartialEq, Eq)] @@ -60,7 +60,7 @@ std::thread_local! { static TEST_DATA: RefCell = RefCell::default(); } -declare_class!( +define_class!( /// A helper object that counts how many times various reference-counting /// primitives are called. #[derive(Debug, PartialEq, Eq, Hash)] diff --git a/crates/objc2/src/runtime/declare.rs b/crates/objc2/src/runtime/define.rs similarity index 94% rename from crates/objc2/src/runtime/declare.rs rename to crates/objc2/src/runtime/define.rs index 9c6743044..20f7c7284 100644 --- a/crates/objc2/src/runtime/declare.rs +++ b/crates/objc2/src/runtime/define.rs @@ -40,25 +40,24 @@ impl Log2Alignment for T { }; } -/// A type for declaring a new class and adding new methods and ivars to it +/// A type for creating a new class and adding new methods and ivars to it /// before registering it. /// /// **Note**: You likely don't need the dynamicism that this provides! -/// Consider using the [`declare_class!`][crate::declare_class] macro instead. +/// Consider using the [`define_class!`][crate::define_class] macro instead. /// /// /// # Example /// -/// Declare a class named `MyNumber` that has one ivar, a `u32` named `_number` +/// Create a class named `MyNumber` that has one ivar, a `u32` named `_number` /// and a few constructor methods and methods for interfacing with the number /// (using interior mutability, as is common for Objective-C objects). /// /// ``` /// use core::cell::Cell; /// -/// use objc2::declare::ClassBuilder; /// use objc2::rc::Retained; -/// use objc2::runtime::{AnyClass, AnyObject, NSObject, Sel}; +/// use objc2::runtime::{AnyClass, AnyObject, ClassBuilder, NSObject, Sel}; /// use objc2::{sel, msg_send, msg_send_id, ClassType}; /// /// fn register_class() -> &'static AnyClass { @@ -210,8 +209,8 @@ impl ClassBuilder { Self::with_superclass(name, Some(superclass)) } - /// Constructs a [`ClassBuilder`] declaring a new root class with the - /// given name. + /// Constructs a [`ClassBuilder`] that will construct a new root class + /// with the given name. /// /// Returns [`None`] if the class couldn't be allocated. /// @@ -289,7 +288,7 @@ impl ClassBuilder { if let Err(err) = crate::verify::verify_method_signature(method, enc_args, enc_ret) { panic!( - "declared invalid method -[{} {sel}]: {err}", + "defined invalid method -[{} {sel}]: {err}", self.name().to_string_lossy() ) } @@ -354,7 +353,7 @@ impl ClassBuilder { if let Err(err) = crate::verify::verify_method_signature(method, enc_args, enc_ret) { panic!( - "declared invalid method +[{} {sel}]: {err}", + "defined invalid method +[{} {sel}]: {err}", self.name().to_string_lossy() ) } @@ -459,7 +458,7 @@ impl Drop for ClassBuilder { } } -/// A type for declaring a new protocol and adding new methods to it +/// A type for creating a new protocol and adding new methods to it /// before registering it. #[derive(Debug)] pub struct ProtocolBuilder { @@ -516,7 +515,7 @@ impl ProtocolBuilder { } } - /// Adds an instance method declaration with a given description. + /// Add an instance method with a given description. pub fn add_method_description(&mut self, sel: Sel, required: bool) where Args: EncodeArguments, @@ -531,7 +530,7 @@ impl ProtocolBuilder { ); } - /// Adds a class method declaration with a given description. + /// Add a class method with a given description. pub fn add_class_method_description(&mut self, sel: Sel, required: bool) where Args: EncodeArguments, @@ -583,7 +582,7 @@ mod tests { use crate::rc::Retained; use crate::runtime::{NSObject, NSObjectProtocol}; use crate::{ - declare_class, extern_methods, msg_send, msg_send_id, test_utils, ClassType, ProtocolType, + define_class, extern_methods, msg_send, msg_send_id, test_utils, ClassType, ProtocolType, }; // TODO: Remove once c"" strings are in MSRV @@ -685,7 +684,7 @@ mod tests { #[test] #[cfg_attr( debug_assertions, - should_panic = "declared invalid method -[TestClassBuilderInvalidMethod foo]: expected return to have type code 'I', but found 's'" + should_panic = "defined invalid method -[TestClassBuilderInvalidMethod foo]: expected return to have type code 'I', but found 's'" )] fn invalid_method() { let cls = test_utils::custom_class(); @@ -703,7 +702,7 @@ mod tests { #[test] #[cfg_attr( all(debug_assertions, not(feature = "relax-sign-encoding")), - should_panic = "declared invalid method +[TestClassBuilderInvalidClassMethod classFoo]: expected return to have type code 'I', but found 'i'" + should_panic = "defined invalid method +[TestClassBuilderInvalidClassMethod classFoo]: expected return to have type code 'I', but found 'i'" )] fn invalid_class_method() { let cls = test_utils::custom_class(); @@ -844,21 +843,21 @@ mod tests { assert_eq!(result, 7); } - // Proof-of-concept how we could make declare_class! accept generic types. + // Proof-of-concept how we could make define_class! accept generic types. #[test] fn test_generic() { - struct GenericDeclareClass(T); + struct GenericDefineClass(T); - unsafe impl RefEncode for GenericDeclareClass { + unsafe impl RefEncode for GenericDefineClass { const ENCODING_REF: Encoding = Encoding::Object; } - unsafe impl Message for GenericDeclareClass {} + unsafe impl Message for GenericDefineClass {} - unsafe impl ClassType for GenericDeclareClass { + unsafe impl ClassType for GenericDefineClass { type Super = NSObject; type ThreadKind = ::ThreadKind; - const NAME: &'static str = "GenericDeclareClass"; + const NAME: &'static str = "GenericDefineClass"; #[inline] fn as_super(&self) -> &Self::Super { @@ -872,7 +871,7 @@ mod tests { unsafe { builder.add_method( sel!(generic), - >::generic as unsafe extern "C" fn(_, _), + >::generic as unsafe extern "C" fn(_, _), ); } @@ -884,16 +883,16 @@ mod tests { type __SubclassingType = Self; } - impl GenericDeclareClass { + impl GenericDefineClass { extern "C" fn generic(&self, _cmd: Sel) {} } - let _ = GenericDeclareClass::<()>::class(); + let _ = GenericDefineClass::<()>::class(); } #[test] fn test_inherited_nsobject_methods_work() { - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "TestInheritedNSObjectMethodsWork"] #[derive(Debug, PartialEq, Eq, Hash)] @@ -954,8 +953,7 @@ mod tests { } let mut superclass = - ClassBuilder::new(&c("DeclareClassDuplicateIvarSuperclass"), NSObject::class()) - .unwrap(); + ClassBuilder::new(&c("DefineClassDuplicateIvarSuperclass"), NSObject::class()).unwrap(); superclass.add_ivar::(&c("ivar1")); superclass.add_ivar::(&c("ivar2")); superclass.add_ivar::(&c("ivar3")); @@ -963,7 +961,7 @@ mod tests { let superclass = superclass.register(); let mut subclass = - ClassBuilder::new(&c("DeclareClassDuplicateIvarSubclass"), superclass).unwrap(); + ClassBuilder::new(&c("DefineClassDuplicateIvarSubclass"), superclass).unwrap(); // Try to overwrite instance variables subclass.add_ivar::(&c("ivar1")); subclass.add_ivar::(&c("ivar2")); diff --git a/crates/objc2/src/runtime/mod.rs b/crates/objc2/src/runtime/mod.rs index bf210797c..ffde9e1c5 100644 --- a/crates/objc2/src/runtime/mod.rs +++ b/crates/objc2/src/runtime/mod.rs @@ -29,7 +29,7 @@ use core::ptr::{self, NonNull}; #[doc(hidden)] pub mod __nsstring; mod bool; -mod declare; +mod define; mod malloc; mod message_receiver; mod method_encoding_iter; @@ -53,7 +53,7 @@ use crate::{ffi, DowncastTarget, Message}; pub use self::nsproxy::NSProxy as __NSProxy; pub use self::bool::Bool; -pub use self::declare::{ClassBuilder, ProtocolBuilder}; +pub use self::define::{ClassBuilder, ProtocolBuilder}; pub use self::message_receiver::MessageReceiver; pub use self::method_implementation::MethodImplementation; pub use self::nsobject::{NSObject, NSObjectProtocol}; @@ -363,7 +363,7 @@ impl Ivar { /// interface to the ivar. /// /// [`UnsafeCell::get`]: core::cell::UnsafeCell::get - /// [`ClassBuilder::add_ivar`]: crate::declare::ClassBuilder::add_ivar + /// [`ClassBuilder::add_ivar`]: crate::runtime::ClassBuilder::add_ivar /// /// /// # Panics @@ -908,7 +908,7 @@ impl AnyClass { } } - /// Describes the instance variables declared by self. + /// Get a list of instance variables on the class. #[doc(alias = "class_copyIvarList")] pub fn instance_variables(&self) -> MallocSlice!(&Ivar) { unsafe { @@ -1350,7 +1350,7 @@ impl AnyObject { } pub(crate) fn is_kind_of_class(&self, cls: &AnyClass) -> Bool { - // SAFETY: The signature is declared correctly. + // SAFETY: The signature is correct. // // Note that `isKindOfClass:` is not available on every object, but it // is still safe to _use_, since the runtime will simply crash if the diff --git a/crates/objc2/src/runtime/protocol_object.rs b/crates/objc2/src/runtime/protocol_object.rs index 87f90e840..5c7b8757b 100644 --- a/crates/objc2/src/runtime/protocol_object.rs +++ b/crates/objc2/src/runtime/protocol_object.rs @@ -200,7 +200,7 @@ mod tests { use super::*; use crate::runtime::{ClassBuilder, NSObject}; use crate::{ - declare_class, extern_methods, extern_protocol, msg_send_id, ClassType, ProtocolType, + define_class, extern_methods, extern_protocol, msg_send_id, ClassType, ProtocolType, }; extern_protocol!( @@ -251,7 +251,7 @@ mod tests { unsafe impl ProtocolType for dyn FooFooBar {} ); - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "ProtocolTestsDummyClass"] #[derive(Debug, PartialEq, Eq, Hash)] diff --git a/crates/objc2/src/top_level_traits.rs b/crates/objc2/src/top_level_traits.rs index 1c2c9f843..f5dde1850 100644 --- a/crates/objc2/src/top_level_traits.rs +++ b/crates/objc2/src/top_level_traits.rs @@ -1,7 +1,7 @@ use alloc::ffi::CString; use core::ptr::NonNull; -use crate::__macro_helpers::declared_ivars::get_initialized_ivar_ptr; +use crate::__macro_helpers::defined_ivars::get_initialized_ivar_ptr; use crate::encode::RefEncode; use crate::rc::{Allocated, Retained}; use crate::runtime::{AnyClass, AnyProtocol, ProtocolObject}; @@ -34,10 +34,10 @@ use crate::{msg_send_id, MainThreadMarker}; /// runtime will do so. If you need to run some code when the object is /// destroyed, implement the `dealloc` method instead. /// -/// The [`declare_class!`] macro does this for you, but the [`extern_class!`] +/// The [`define_class!`] macro does this for you, but the [`extern_class!`] /// macro fundamentally cannot. /// -/// [`declare_class!`]: crate::declare_class +/// [`define_class!`]: crate::define_class /// [`extern_class!`]: crate::extern_class /// /// @@ -128,7 +128,7 @@ pub unsafe trait Message: RefEncode { /// a few properties of the class to the rest of the type-system. /// /// This is implemented for your type by the -/// [`declare_class!`][crate::declare_class] and +/// [`define_class!`][crate::define_class] and /// [`extern_class!`][crate::extern_class] macros. /// /// @@ -249,7 +249,7 @@ pub unsafe trait ClassType: Message { /// /// # Panics /// - /// This may panic if something went wrong with getting or declaring the + /// This may panic if something went wrong with getting or creating the /// class, e.g. if the program is not properly linked to the framework /// that defines the class. fn class() -> &'static AnyClass; @@ -262,7 +262,7 @@ pub unsafe trait ClassType: Message { #[doc(hidden)] const __INNER: (); - /// Inner type to use when subclassing with `declare_class!`. + /// Inner type to use when subclassing with `define_class!`. /// /// This is used by NSObject to control which auto traits are set for /// defined subclasses. Set to `= Self` in all other cases. @@ -270,18 +270,18 @@ pub unsafe trait ClassType: Message { type __SubclassingType: ?Sized; } -/// Marks types whose implementation is defined in Rust. +/// Marks class types whose implementation is defined in Rust. /// -/// This is used in [`declare_class!`], and allows access to the instance +/// This is used in [`define_class!`], and allows access to the instance /// variables that a given type declares, see that macro for details. /// -/// [`declare_class!`]: crate::declare_class +/// [`define_class!`]: crate::define_class // // Note: We mark this trait as not `unsafe` for better documentation, since -// implementing it inside `declare_class!` is not `unsafe`. +// implementing it inside `define_class!` is not `unsafe`. // // Safety is ensured by `__UNSAFE_OFFSETS_CORRECT`. -pub trait DeclaredClass: ClassType { +pub trait DefinedClass: ClassType { /// A type representing the instance variables that this class carries. type Ivars: Sized; @@ -380,7 +380,7 @@ pub unsafe trait ProtocolType { /// /// # Panics /// - /// This may panic if something went wrong with getting or declaring the + /// This may panic if something went wrong with getting or creating the /// protocol, e.g. if the program is not properly linked to the framework /// that defines the protocol. fn protocol() -> Option<&'static AnyProtocol> { diff --git a/crates/objc2/src/topics/interior_mutability.md b/crates/objc2/src/topics/interior_mutability.md index f9830787e..2411d4f7e 100644 --- a/crates/objc2/src/topics/interior_mutability.md +++ b/crates/objc2/src/topics/interior_mutability.md @@ -24,7 +24,7 @@ Let's take an example: We define a class that contains an [`i32`] and a [`Vec`]. ```rust use std::cell::{Cell, RefCell}; -use objc2::{declare_class, DeclaredClass}; +use objc2::{define_class, DefinedClass}; use objc2::runtime::NSObject; // Usually, you would just do: @@ -50,7 +50,7 @@ struct Ivars { my_vec: RefCell>, } -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "MyClass"] #[ivars = Ivars] diff --git a/crates/objc2/src/topics/kvo.md b/crates/objc2/src/topics/kvo.md index 8819df63b..30adc9d8e 100644 --- a/crates/objc2/src/topics/kvo.md +++ b/crates/objc2/src/topics/kvo.md @@ -21,7 +21,7 @@ use core::ptr; use objc2::rc::Retained; use objc2::runtime::AnyObject; -use objc2::{declare_class, msg_send_id, AllocAnyThread, ClassType, DeclaredClass}; +use objc2::{define_class, msg_send_id, AllocAnyThread, ClassType, DefinedClass}; use objc2_foundation::{ ns_string, NSCopying, NSDictionary, NSKeyValueChangeKey, NSKeyValueObservingOptions, NSObject, NSObjectNSKeyValueObserverRegistration, NSObjectProtocol, NSString, @@ -33,7 +33,7 @@ struct Ivars { handler: Box) + 'static>, } -declare_class!( +define_class!( // SAFETY: // - The superclass NSObject does not have any subclassing requirements. // - MyObserver implements `Drop` and ensures that: diff --git a/crates/objc2/src/topics/mvc.md b/crates/objc2/src/topics/mvc.md index d07d0400f..c4e97dfeb 100644 --- a/crates/objc2/src/topics/mvc.md +++ b/crates/objc2/src/topics/mvc.md @@ -6,11 +6,11 @@ The [Model-View-Controller (MVC) design pattern][mvc-doc] is quite prominent in **View**: Use the built-in views (`NSView` or `UIView`). If you need to register a delegate on these, use the controller as the delegate. -**Controller**: Use the [`declare_class!`] macro to create a new object. Use [`MainThreadOnly`] as the [`ClassType::ThreadKind`], so that you can implement view delegate protocols. +**Controller**: Use the [`define_class!`] macro to create a new object. Use [`MainThreadOnly`] as the [`ClassType::ThreadKind`], so that you can implement view delegate protocols. [mvc-doc]: https://developer.apple.com/library/archive/documentation/General/Conceptual/CocoaEncyclopedia/Model-View-Controller/Model-View-Controller.html [`Cell`]: core::cell::Cell [`RefCell`]: core::cell::RefCell -[`declare_class!`]: crate::declare_class +[`define_class!`]: crate::define_class [`MainThreadOnly`]: crate::MainThreadOnly [`ClassType::ThreadKind`]: crate::ClassType::ThreadKind diff --git a/crates/objc2/src/topics/run_loop.md b/crates/objc2/src/topics/run_loop.md index 460b7de5d..7ae6b2797 100644 --- a/crates/objc2/src/topics/run_loop.md +++ b/crates/objc2/src/topics/run_loop.md @@ -37,7 +37,7 @@ In graphical applications, the main run loop needs to be managed by the applicat ```rust, no_run use objc2::rc::{Allocated, Retained}; -use objc2::{declare_class, msg_send_id, ClassType, DeclaredClass, MainThreadOnly}; +use objc2::{define_class, msg_send_id, ClassType, DefinedClass, MainThreadOnly}; use objc2_foundation::{NSNotification, NSObject, NSObjectProtocol}; // Application delegate protocols happens to share a few methods, @@ -52,7 +52,7 @@ struct AppState { // Whatever state you want to store in your delegate. } -declare_class!( +define_class!( // SAFETY: // - NSObject does not have any subclassing requirements. // - `AppDelegate` does not implement `Drop`. @@ -109,7 +109,7 @@ fn main() { fn main() { // Initialize the class so that the storyboard can see it. // - // The name specified in `declare_class!`, i.e. "AppDelegate", must + // The name specified in `define_class!`, i.e. "AppDelegate", must // match what's specified in the storyboard. let _cls = AppDelegate::class(); unsafe { diff --git a/crates/objc2/tests/declare_class.rs b/crates/objc2/tests/define_class.rs similarity index 88% rename from crates/objc2/tests/declare_class.rs rename to crates/objc2/tests/define_class.rs index d49296410..1bf6a111c 100644 --- a/crates/objc2/tests/declare_class.rs +++ b/crates/objc2/tests/define_class.rs @@ -6,7 +6,7 @@ use std::panic::{RefUnwindSafe, UnwindSafe}; use objc2::rc::Retained; use objc2::runtime::NSObject; -use objc2::{declare_class, extern_methods, sel, ClassType, MainThreadOnly}; +use objc2::{define_class, extern_methods, sel, ClassType, MainThreadOnly}; use static_assertions::{assert_impl_all, assert_not_impl_any}; // Test that adding the `deprecated` attribute does not mean that warnings @@ -16,7 +16,7 @@ fn allow_deprecated() { #![deny(deprecated)] // Test allow propagates to impls - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "AllowDeprecated"] #[deprecated] @@ -34,18 +34,18 @@ fn allow_deprecated() { let _ = AllowDeprecated::class(); } -declare_class!( +define_class!( #[unsafe(super(NSObject))] - #[name = "DeclareClassDeprecatedMethod"] - struct DeclareClassDeprecatedMethod; + #[name = "DefineClassDeprecatedMethod"] + struct DefineClassDeprecatedMethod; #[deprecated] - unsafe impl DeclareClassDeprecatedMethod { + unsafe impl DefineClassDeprecatedMethod { #[method(deprecatedOnImpl)] fn deprecated_on_impl() {} } - unsafe impl DeclareClassDeprecatedMethod { + unsafe impl DefineClassDeprecatedMethod { #[deprecated] #[method(deprecatedOnMethod)] fn deprecated_on_method() {} @@ -54,7 +54,7 @@ declare_class!( #[test] fn test_deprecated() { - let _cls = DeclareClassDeprecatedMethod::class(); + let _cls = DefineClassDeprecatedMethod::class(); } #[test] @@ -62,7 +62,7 @@ fn cfg() { // Test `cfg`. We use `debug_assertions` here because it's something that we // know our CI already tests. - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "OnlyOnDebugAssertions"] #[cfg(debug_assertions)] @@ -72,7 +72,7 @@ fn cfg() { #[cfg(debug_assertions)] let _ = OnlyOnDebugAssertions::class(); - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "NeverOnDebugAssertions"] #[cfg(not(debug_assertions))] @@ -84,12 +84,12 @@ fn cfg() { } // Test that `cfg` in methods. -declare_class!( +define_class!( #[unsafe(super(NSObject))] - #[name = "DeclareClassCfg"] - struct DeclareClassCfg; + #[name = "DefineClassCfg"] + struct DefineClassCfg; - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[cfg(debug_assertions)] #[method(changesOnCfg1)] fn _changes_on_cfg1() -> i32 { @@ -112,7 +112,7 @@ declare_class!( } #[cfg(debug_assertions)] - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[method(changesOnCfg2)] fn _changes_on_cfg2(&self) -> i32 { 1 @@ -123,7 +123,7 @@ declare_class!( } #[cfg(not(debug_assertions))] - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[method(changesOnCfg2)] fn _changes_on_cfg2(&self) -> i32 { 2 @@ -134,7 +134,7 @@ declare_class!( } #[cfg(debug_assertions)] - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[cfg(not(debug_assertions))] #[method(never)] fn _never(&self) {} @@ -146,12 +146,12 @@ declare_class!( ); extern_methods!( - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[method_id(new)] fn new() -> Retained; } - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[method(changesOnCfg1)] fn changes_on_cfg1() -> i32; @@ -168,13 +168,13 @@ extern_methods!( } #[cfg(debug_assertions)] - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[method(onlyWhenEnabled2)] fn only_when_enabled2(); } #[cfg(not(debug_assertions))] - unsafe impl DeclareClassCfg { + unsafe impl DefineClassCfg { #[method(onlyWhenDisabled2)] fn only_when_disabled2(); } @@ -183,18 +183,18 @@ extern_methods!( #[test] fn test_method_that_changes_based_on_cfg() { let expected = if cfg!(debug_assertions) { 1 } else { 2 }; - let actual = DeclareClassCfg::changes_on_cfg1(); + let actual = DefineClassCfg::changes_on_cfg1(); assert_eq!(expected, actual, "changes_on_cfg1"); - let actual = DeclareClassCfg::new().changes_on_cfg2(); + let actual = DefineClassCfg::new().changes_on_cfg2(); assert_eq!(expected, actual, "changes_on_cfg2"); } #[test] fn test_method_that_is_only_available_based_on_cfg() { - let cls = DeclareClassCfg::class(); + let cls = DefineClassCfg::class(); let metacls = cls.metaclass(); - let obj = DeclareClassCfg::new(); + let obj = DefineClassCfg::new(); #[cfg(debug_assertions)] { @@ -202,7 +202,7 @@ fn test_method_that_is_only_available_based_on_cfg() { assert!(!metacls.responds_to(sel!(onlyWhenDisabled2))); obj.only_when_enabled1(); - DeclareClassCfg::only_when_enabled2(); + DefineClassCfg::only_when_enabled2(); } #[cfg(not(debug_assertions))] { @@ -210,19 +210,19 @@ fn test_method_that_is_only_available_based_on_cfg() { assert!(!metacls.responds_to(sel!(onlyWhenEnabled2))); obj.only_when_disabled1(); - DeclareClassCfg::only_when_disabled2(); + DefineClassCfg::only_when_disabled2(); } } #[test] fn test_method_that_is_never_available() { - let cls = DeclareClassCfg::class(); + let cls = DefineClassCfg::class(); let metacls = cls.metaclass(); assert!(!cls.responds_to(sel!(never))); assert!(!metacls.responds_to(sel!(never))); } -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "TestMultipleColonSelector"] struct TestMultipleColonSelector; @@ -291,12 +291,12 @@ fn test_multiple_colon_selector() { assert!(obj.test_object(1, 2, 3, ptr::null()).is_none()); } -declare_class!( +define_class!( #[unsafe(super(NSObject))] - #[name = "DeclareClassAllTheBool"] - struct DeclareClassAllTheBool; + #[name = "DefineClassAllTheBool"] + struct DefineClassAllTheBool; - unsafe impl DeclareClassAllTheBool { + unsafe impl DefineClassAllTheBool { #[method(returnsBool)] fn returns_bool() -> bool { true @@ -347,16 +347,16 @@ declare_class!( #[test] fn test_all_the_bool() { - let _ = DeclareClassAllTheBool::class(); + let _ = DefineClassAllTheBool::class(); } -declare_class!( +define_class!( #[unsafe(super(NSObject))] - #[name = "DeclareClassUnreachable"] - struct DeclareClassUnreachable; + #[name = "DefineClassUnreachable"] + struct DefineClassUnreachable; // Ensure none of these warn - unsafe impl DeclareClassUnreachable { + unsafe impl DefineClassUnreachable { #[method(unreachable)] fn unreachable(&self) -> bool { unreachable!() @@ -391,10 +391,10 @@ declare_class!( #[test] fn test_unreachable() { - let _ = DeclareClassUnreachable::class(); + let _ = DefineClassUnreachable::class(); } -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "OutParam"] #[derive(Debug)] @@ -435,7 +435,7 @@ extern_methods!( ); #[test] -#[should_panic = "`&mut Retained<_>` is not supported in `declare_class!` yet"] +#[should_panic = "`&mut Retained<_>` is not supported in `define_class!` yet"] #[cfg_attr( feature = "gnustep-1-7", ignore = "unwinding seems to not work properly here" @@ -446,7 +446,7 @@ fn out_param1() { } #[test] -#[should_panic = "`Option<&mut Retained<_>>` is not supported in `declare_class!` yet"] +#[should_panic = "`Option<&mut Retained<_>>` is not supported in `define_class!` yet"] #[cfg_attr( feature = "gnustep-1-7", ignore = "unwinding seems to not work properly here" @@ -456,7 +456,7 @@ fn out_param2() { } #[test] -#[should_panic = "`&mut Option>` is not supported in `declare_class!` yet"] +#[should_panic = "`&mut Option>` is not supported in `define_class!` yet"] #[cfg_attr( feature = "gnustep-1-7", ignore = "unwinding seems to not work properly here" @@ -467,7 +467,7 @@ fn out_param3() { } #[test] -#[should_panic = "`Option<&mut Option>>` is not supported in `declare_class!` yet"] +#[should_panic = "`Option<&mut Option>>` is not supported in `define_class!` yet"] #[cfg_attr( feature = "gnustep-1-7", ignore = "unwinding seems to not work properly here" @@ -478,7 +478,7 @@ fn out_param4() { #[test] fn test_pointer_receiver_allowed() { - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "PointerReceiver"] #[derive(Debug)] @@ -519,13 +519,13 @@ fn test_auto_traits() { // Superclass propagates. - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "NonThreadSafeHelper"] #[ivars = (NotSend, NotSync, NotUnwindSafe)] struct NonThreadSafeHelper; ); - declare_class!( + define_class!( #[unsafe(super(NonThreadSafeHelper))] #[name = "InheritsCustomWithNonSendIvar"] #[ivars = ()] @@ -536,7 +536,7 @@ fn test_auto_traits() { // Main thread only. Not Send + Sync. - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[thread_kind = MainThreadOnly] #[name = "InheritsNSObjectMainThreadOnly"] @@ -549,7 +549,7 @@ fn test_auto_traits() { // NSObject is special. - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "InheritsNSObject"] #[ivars = ()] @@ -559,7 +559,7 @@ fn test_auto_traits() { assert_impl_all!(InheritsNSObject: Send, Sync, UnwindSafe, RefUnwindSafe); assert_not_impl_any!(InheritsNSObject: Unpin); - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "InheritsNSObjectWithNonSendIvar"] #[ivars = NotSend] @@ -569,7 +569,7 @@ fn test_auto_traits() { assert_impl_all!(InheritsNSObjectWithNonSendIvar: Sync, UnwindSafe, RefUnwindSafe); assert_not_impl_any!(InheritsNSObjectWithNonSendIvar: Unpin, Send); - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "InheritsNSObjectWithNonSyncIvar"] #[ivars = NotSync] @@ -579,7 +579,7 @@ fn test_auto_traits() { assert_impl_all!(InheritsNSObjectWithNonSyncIvar: Send, UnwindSafe, RefUnwindSafe); assert_not_impl_any!(InheritsNSObjectWithNonSyncIvar: Unpin, Sync); - declare_class!( + define_class!( #[unsafe(super(NSObject))] #[name = "InheritsNSObjectWithNonUnwindSafeIvar"] #[ivars = NotUnwindSafe] diff --git a/crates/objc2/tests/declare_class_self.rs b/crates/objc2/tests/define_class_self.rs similarity index 95% rename from crates/objc2/tests/declare_class_self.rs rename to crates/objc2/tests/define_class_self.rs index bf98eda9b..5916f1e50 100644 --- a/crates/objc2/tests/declare_class_self.rs +++ b/crates/objc2/tests/define_class_self.rs @@ -1,9 +1,9 @@ -//! To remind myself that `Self` needs to work in methods in `declare_class!`, +//! To remind myself that `Self` needs to work in methods in `define_class!`, //! and hence whenever we name any of the types involved in this, we need to //! do it in a context where `Self` works. use objc2::rc::{Allocated, Retained}; use objc2::runtime::NSObject; -use objc2::{declare_class, ClassType}; +use objc2::{define_class, ClassType}; trait GetSameType { type SameType: ?Sized; @@ -27,7 +27,7 @@ macro_rules! get_self { }; } -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "MyTestObject"] struct MyTestObject; diff --git a/crates/objc2/tests/macros_mainthreadmarker.rs b/crates/objc2/tests/macros_mainthreadmarker.rs index 3a4c2612c..cb7915ef3 100644 --- a/crates/objc2/tests/macros_mainthreadmarker.rs +++ b/crates/objc2/tests/macros_mainthreadmarker.rs @@ -1,6 +1,6 @@ use objc2::rc::Retained; use objc2::runtime::{NSObject, NSObjectProtocol}; -use objc2::{declare_class, extern_methods, extern_protocol, ProtocolType}; +use objc2::{define_class, extern_methods, extern_protocol, ProtocolType}; extern_protocol!( #[allow(clippy::missing_safety_doc)] @@ -17,7 +17,7 @@ extern_protocol!( } ); -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "MainThreadMarkerTest"] #[derive(PartialEq, Eq, Hash, Debug)] diff --git a/crates/objc2/tests/no_prelude.rs b/crates/objc2/tests/no_prelude.rs index faff4c605..d1303afd4 100644 --- a/crates/objc2/tests/no_prelude.rs +++ b/crates/objc2/tests/no_prelude.rs @@ -90,7 +90,7 @@ struct MyCustomIvars { ivars: i32, } -new_objc2::declare_class!( +new_objc2::define_class!( #[unsafe(super(new_objc2::runtime::NSObject))] #[name = "CustomObject"] #[ivars = MyCustomIvars] diff --git a/crates/objc2/tests/track_caller.rs b/crates/objc2/tests/track_caller.rs index 3b3380993..28ac67b8a 100644 --- a/crates/objc2/tests/track_caller.rs +++ b/crates/objc2/tests/track_caller.rs @@ -10,7 +10,7 @@ use std::sync::Mutex; use objc2::encode::Encode; use objc2::rc::{self, Allocated, Retained}; use objc2::runtime::{self, NSObject}; -use objc2::{class, declare_class, msg_send, msg_send_id, AllocAnyThread, ClassType}; +use objc2::{class, define_class, msg_send, msg_send_id, AllocAnyThread, ClassType}; #[path = "../src/rc/test_object.rs"] #[allow(dead_code)] @@ -199,7 +199,7 @@ fn test_catch_all(checker: &PanicChecker) { }); } -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "PanickingClass"] struct PanickingClass; diff --git a/crates/objc2/tests/use_macros.rs b/crates/objc2/tests/use_macros.rs index 5565ee304..0be76ef32 100644 --- a/crates/objc2/tests/use_macros.rs +++ b/crates/objc2/tests/use_macros.rs @@ -1,7 +1,7 @@ use objc2::runtime::{AnyClass, NSObject}; -use objc2::{class, declare_class, msg_send, sel}; +use objc2::{class, define_class, msg_send, sel}; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "MyObject"] pub struct MyObject; diff --git a/crates/test-assembly/crates/test_declare_class/Cargo.toml b/crates/test-assembly/crates/test_define_class/Cargo.toml similarity index 97% rename from crates/test-assembly/crates/test_declare_class/Cargo.toml rename to crates/test-assembly/crates/test_define_class/Cargo.toml index f6e4a67a7..965560087 100644 --- a/crates/test-assembly/crates/test_declare_class/Cargo.toml +++ b/crates/test-assembly/crates/test_define_class/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "test_declare_class" +name = "test_define_class" version = "0.1.0" edition.workspace = true publish = false diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s b/crates/test-assembly/crates/test_define_class/expected/apple-aarch64.s similarity index 74% rename from crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s rename to crates/test-assembly/crates/test_define_class/expected/apple-aarch64.s index 5733cc7ab..fe4d32e9e 100644 --- a/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_define_class/expected/apple-aarch64.s @@ -1,6 +1,6 @@ .section __TEXT,__text,regular,pure_instructions .p2align 2 -SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::, 0): +SYM(objc2[CRATE_ID]::__macro_helpers::defined_ivars::dealloc::, 0): Lfunc_begin0: sub sp, sp, #64 stp x22, x21, [sp, #16] @@ -10,19 +10,19 @@ Lfunc_begin0: mov x19, x1 mov x20, x0 Lloh0: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE Lloh1: - ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] + ldr x8, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] ldrb w8, [x0, x8] cbz w8, LBB0_6 cmp w8, #255 b.ne LBB0_3 - bl SYM(::drop, 0) + bl SYM(::drop, 0) LBB0_3: Lloh2: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE Lloh3: - ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] + ldr x8, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x20, x8 ldp x0, x21, [x8] Ltmp0: @@ -106,7 +106,7 @@ Lttbase0: .section __TEXT,__text,regular,pure_instructions .p2align 2 -SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): Lfunc_begin1: sub sp, sp, #48 stp x20, x19, [sp, #16] @@ -131,12 +131,12 @@ Lloh12: Lloh13: add x3, x3, l_anon.[ID].15@PAGEOFF mov w1, #7 - bl SYM(objc2::__macro_helpers::declare_class::create_builder::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::define_class::create_builder::GENERATED_ID, 0) str x0, [sp, #8] Lloh14: - adrp x8, L_OBJC_SELECTOR_REFERENCES_4534bbe5e50290a1@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_4ee60abb2719f036@PAGE Lloh15: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_4534bbe5e50290a1@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_4ee60abb2719f036@PAGEOFF] Ltmp6: Lloh16: adrp x4, l_anon.[ID].16@PAGE @@ -149,12 +149,12 @@ Lloh19: add x0, sp, #8 mov w2, #8 mov x3, #0 - bl SYM(objc2::runtime::declare::ClassBuilder::add_class_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_class_method_inner::GENERATED_ID, 0) Ltmp7: Lloh20: - adrp x8, L_OBJC_SELECTOR_REFERENCES_885f02de2bcfda61@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_94f56691766f024b@PAGE Lloh21: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_885f02de2bcfda61@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_94f56691766f024b@PAGEOFF] Ltmp8: Lloh22: adrp x4, l_anon.[ID].3@PAGE @@ -167,12 +167,12 @@ Lloh25: add x0, sp, #8 mov w2, #8 mov x3, #0 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp9: Lloh26: - adrp x8, L_OBJC_SELECTOR_REFERENCES_22190004c3782bc8@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_d6661a0373fc878f@PAGE Lloh27: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_22190004c3782bc8@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_d6661a0373fc878f@PAGEOFF] Ltmp10: Lloh28: adrp x2, l_anon.[ID].17@PAGE @@ -185,12 +185,12 @@ Lloh31: add x0, sp, #8 mov w3, #1 mov x4, x2 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp11: Lloh32: - adrp x8, L_OBJC_SELECTOR_REFERENCES_384873ae30ec6d43@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_8677be6883ccd195@PAGE Lloh33: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_384873ae30ec6d43@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_8677be6883ccd195@PAGEOFF] Ltmp12: Lloh34: adrp x4, l_anon.[ID].18@PAGE @@ -203,12 +203,12 @@ Lloh37: add x0, sp, #8 mov w2, #8 mov x3, #0 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp13: Lloh38: - adrp x8, L_OBJC_SELECTOR_REFERENCES_56240dc6bf8dcec3@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_3f5c953c5f98b853@PAGE Lloh39: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_56240dc6bf8dcec3@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_3f5c953c5f98b853@PAGEOFF] Ltmp14: Lloh40: adrp x2, l_anon.[ID].17@PAGE @@ -224,7 +224,7 @@ Lloh45: add x5, x5, _method_retained_with_param@PAGEOFF add x0, sp, #8 mov w3, #1 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp15: Ltmp16: Lloh46: @@ -253,9 +253,9 @@ Ltmp19: bl _class_addProtocol LBB1_12: Lloh50: - adrp x8, L_OBJC_SELECTOR_REFERENCES_8e8381168048230b@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_76a1da9e60049d4f@PAGE Lloh51: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_8e8381168048230b@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_76a1da9e60049d4f@PAGEOFF] Ltmp20: Lloh52: adrp x2, l_anon.[ID].23@PAGE @@ -271,7 +271,7 @@ Lloh57: add x5, x5, _copyWithZone@PAGEOFF add x0, sp, #8 mov w3, #1 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp21: ldr x19, [sp, #8] mov x0, x19 @@ -348,7 +348,7 @@ Lcst_end1: .section __TEXT,__text,regular,pure_instructions .p2align 2 -SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): Lfunc_begin2: sub sp, sp, #96 stp x20, x19, [sp, #64] @@ -373,7 +373,7 @@ Lloh65: Lloh66: add x3, x3, l_anon.[ID].25@PAGEOFF mov w1, #9 - bl SYM(objc2::__macro_helpers::declare_class::create_builder::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::define_class::create_builder::GENERATED_ID, 0) str x0, [sp, #24] Lloh67: adrp x8, L_OBJC_SELECTOR_REFERENCES_dealloc@GOTPAGE @@ -387,13 +387,13 @@ Lloh70: Lloh71: add x4, x4, l_anon.[ID].3@PAGEOFF Lloh72: - adrp x5, SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::, 0)@PAGE + adrp x5, SYM(objc2[CRATE_ID]::__macro_helpers::defined_ivars::dealloc::, 0)@PAGE Lloh73: - add x5, x5, SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::, 0)@PAGEOFF + add x5, x5, SYM(objc2[CRATE_ID]::__macro_helpers::defined_ivars::dealloc::, 0)@PAGEOFF add x0, sp, #24 mov w2, #8 mov x3, #0 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp24: ldr x8, [sp, #24] str x8, [sp, #8] @@ -415,7 +415,7 @@ Lloh80: add x0, sp, #8 mov w2, #8 mov x3, #0 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp27: ldr x8, [sp, #8] str x8, [sp, #16] @@ -437,7 +437,7 @@ Lloh84: mov w2, #6 mov w3, #16 mov w4, #3 - bl SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) Ltmp30: Ltmp31: Lloh85: @@ -452,7 +452,7 @@ Lloh88: mov w2, #10 mov w3, #1 mov w4, #0 - bl SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) Ltmp32: ldr x19, [sp, #16] mov x0, x19 @@ -478,11 +478,11 @@ Lloh93: adrp x8, __MergedGlobals@PAGE+32 str x19, [x8, __MergedGlobals@PAGEOFF+32] Lloh94: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE - str x20, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE + str x20, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] Lloh95: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE - str x0, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE + str x0, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] ldp x29, x30, [sp, #80] ldp x20, x19, [sp, #64] add sp, sp, #96 @@ -494,9 +494,9 @@ Lloh97: add x0, x0, l_anon.[ID].12@PAGEOFF bl SYM(core::option::unwrap_failed::GENERATED_ID, 0) LBB2_9: - bl SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::defined_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) LBB2_10: - bl SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_drop_flag_failed::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::defined_ivars::register_with_ivars::get_drop_flag_failed::GENERATED_ID, 0) LBB2_11: Ltmp28: mov x19, x0 @@ -574,7 +574,7 @@ Lcst_end2: .section __TEXT,__text,regular,pure_instructions .p2align 2 -SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): Lfunc_begin3: sub sp, sp, #96 stp x20, x19, [sp, #64] @@ -599,7 +599,7 @@ Lloh103: Lloh104: add x3, x3, l_anon.[ID].24@PAGEOFF mov w1, #15 - bl SYM(objc2::__macro_helpers::declare_class::create_builder::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::define_class::create_builder::GENERATED_ID, 0) str x0, [sp, #8] Lloh105: adrp x8, L_OBJC_SELECTOR_REFERENCES_init@GOTPAGE @@ -619,7 +619,7 @@ Lloh111: add x0, sp, #8 mov w2, #8 mov x3, #0 - bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp35: ldr x8, [sp, #8] str x8, [sp, #16] @@ -641,7 +641,7 @@ Lloh115: mov w2, #6 mov w3, #8 mov w4, #2 - bl SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) + bl SYM(objc2::runtime::define::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) Ltmp38: ldr x19, [sp, #16] mov x0, x19 @@ -658,8 +658,8 @@ Lloh118: adrp x8, __MergedGlobals@PAGE+16 str x19, [x8, __MergedGlobals@PAGEOFF+16] Lloh119: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE - str x0, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE + str x0, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] ldp x29, x30, [sp, #80] ldp x20, x19, [sp, #64] add sp, sp, #96 @@ -671,7 +671,7 @@ Lloh121: add x0, x0, l_anon.[ID].12@PAGEOFF bl SYM(core::option::unwrap_failed::GENERATED_ID, 0) LBB3_6: - bl SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) + bl SYM(objc2::__macro_helpers::defined_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) LBB3_7: Ltmp39: mov x19, x0 @@ -730,40 +730,40 @@ Lcst_end3: .section __TEXT,__text,regular,pure_instructions .p2align 2 -SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): +SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 ldr x8, [x0] str x8, [sp, #8] add x0, sp, #8 - bl SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + bl SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 ret .p2align 2 -SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): +SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 ldr x8, [x0] str x8, [sp, #8] add x0, sp, #8 - bl SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + bl SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 ret .p2align 2 -SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): +SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 ldr x8, [x0] str x8, [sp, #8] add x0, sp, #8 - bl SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + bl SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 ret @@ -824,18 +824,18 @@ Lloh133: .p2align 2 _access_forgetable_ivars: Lloh134: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE Lloh135: - ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] + ldr x8, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] add x8, x0, x8 ldr w1, [x8] ldrb w0, [x8, #4] ret .loh AdrpLdr Lloh134, Lloh135 - .globl SYM(::drop, 0) + .globl SYM(::drop, 0) .p2align 2 -SYM(::drop, 0): +SYM(::drop, 0): ; InlineAsm Start ; InlineAsm End ret @@ -896,17 +896,17 @@ Lloh147: .p2align 2 _access_drop_ivars: Lloh148: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE Lloh149: - ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] + ldr x8, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x0, x8 ldp x0, x1, [x8] ret .loh AdrpLdr Lloh148, Lloh149 - .globl SYM(::class, 0) + .globl SYM(::class, 0) .p2align 2 -SYM(::class, 0): +SYM(::class, 0): Lloh150: adrp x8, __MergedGlobals@PAGE+8 Lloh151: @@ -1210,9 +1210,9 @@ Lloh199: .loh AdrpAdd Lloh196, Lloh197 .loh AdrpAdd Lloh194, Lloh195 - .globl SYM(::class, 0) + .globl SYM(::class, 0) .p2align 2 -SYM(::class, 0): +SYM(::class, 0): Lloh200: adrp x8, __MergedGlobals@PAGE+24 Lloh201: @@ -1267,9 +1267,9 @@ Lloh211: _init_forgetable_ivars: cbz x0, LBB20_2 Lloh212: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE Lloh213: - ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] + ldr x8, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] add x8, x0, x8 mov w9, #43 str w9, [x8] @@ -1280,9 +1280,9 @@ LBB20_2: stp x29, x30, [sp, #16] add x29, sp, #16 Lloh214: - adrp x8, L_OBJC_SELECTOR_REFERENCES_affdf4249c01fc9d@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_8ae30338ec8fe87d@PAGE Lloh215: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_affdf4249c01fc9d@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_8ae30338ec8fe87d@PAGEOFF] Lloh216: adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGE Lloh217: @@ -1300,9 +1300,9 @@ Lloh218: .loh AdrpAdrp Lloh214, Lloh216 .loh AdrpLdr Lloh214, Lloh215 - .globl SYM(::class, 0) + .globl SYM(::class, 0) .p2align 2 -SYM(::class, 0): +SYM(::class, 0): Lloh219: adrp x8, __MergedGlobals@PAGE+40 Lloh220: @@ -1370,15 +1370,15 @@ Ltmp49: bl SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) Ltmp50: mov x21, x0 - adrp x22, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE + adrp x22, SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE cbz x19, LBB22_4 Lloh231: - adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE + adrp x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE Lloh232: - ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] + ldr x8, [x8, SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x19, x8 stp x20, x21, [x8] - ldr x8, [x22, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] + ldr x8, [x22, SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] mov w9, #15 strb w9, [x19, x8] b LBB22_6 @@ -1391,9 +1391,9 @@ Ltmp58: bl _objc_release LBB22_6: Lloh233: - adrp x8, L_OBJC_SELECTOR_REFERENCES_8a88921dfbe0b09d@PAGE + adrp x8, L_OBJC_SELECTOR_REFERENCES_c3d3047551604c9f@PAGE Lloh234: - ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_8a88921dfbe0b09d@PAGEOFF] + ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_c3d3047551604c9f@PAGEOFF] Lloh235: adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGE Lloh236: @@ -1404,7 +1404,7 @@ Lloh237: mov x0, sp bl _objc_msgSendSuper cbz x0, LBB22_8 - ldr x8, [x22, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] + ldr x8, [x22, SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] mov w9, #255 strb w9, [x0, x8] LBB22_8: @@ -1503,20 +1503,20 @@ Lttbase2: .p2align 3, 0x0 l_anon.[ID].0: .asciz "\000\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000" - .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) - .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) + .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) .p2align 3, 0x0 l_anon.[ID].1: .asciz "\000\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000" - .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) - .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) + .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) .p2align 3, 0x0 l_anon.[ID].2: .asciz "\000\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000" - .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) - .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) + .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) .section __TEXT,__const .p2align 3, 0x0 @@ -1564,10 +1564,10 @@ l_anon.[ID].12: l_anon.[ID].13: .ascii "NoIvars" - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2),8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1),8,3 l_anon.[ID].14: .ascii "crates/$DIR/lib.rs" @@ -1575,7 +1575,7 @@ l_anon.[ID].14: .p2align 3, 0x0 l_anon.[ID].15: .quad l_anon.[ID].14 - .asciz "5\000\000\000\000\000\000\000\016\000\000\000\001\000\000" + .asciz "4\000\000\000\000\000\000\000\016\000\000\000\001\000\000" .section __TEXT,__const .p2align 3, 0x0 @@ -1622,159 +1622,159 @@ l_anon.[ID].23: .space 24 .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_4534bbe5e50290a1 -L_OBJC_METH_VAR_NAME_4534bbe5e50290a1: + .globl L_OBJC_METH_VAR_NAME_4ee60abb2719f036 +L_OBJC_METH_VAR_NAME_4ee60abb2719f036: .asciz "classMethod" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_4534bbe5e50290a1 + .globl L_OBJC_SELECTOR_REFERENCES_4ee60abb2719f036 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_4534bbe5e50290a1: - .quad L_OBJC_METH_VAR_NAME_4534bbe5e50290a1 +L_OBJC_SELECTOR_REFERENCES_4ee60abb2719f036: + .quad L_OBJC_METH_VAR_NAME_4ee60abb2719f036 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_4534bbe5e50290a1 + .globl L_OBJC_IMAGE_INFO_4ee60abb2719f036 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4534bbe5e50290a1: +L_OBJC_IMAGE_INFO_4ee60abb2719f036: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_885f02de2bcfda61 -L_OBJC_METH_VAR_NAME_885f02de2bcfda61: + .globl L_OBJC_METH_VAR_NAME_94f56691766f024b +L_OBJC_METH_VAR_NAME_94f56691766f024b: .asciz "method" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_885f02de2bcfda61 + .globl L_OBJC_SELECTOR_REFERENCES_94f56691766f024b .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_885f02de2bcfda61: - .quad L_OBJC_METH_VAR_NAME_885f02de2bcfda61 +L_OBJC_SELECTOR_REFERENCES_94f56691766f024b: + .quad L_OBJC_METH_VAR_NAME_94f56691766f024b .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_885f02de2bcfda61 + .globl L_OBJC_IMAGE_INFO_94f56691766f024b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_885f02de2bcfda61: +L_OBJC_IMAGE_INFO_94f56691766f024b: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_22190004c3782bc8 -L_OBJC_METH_VAR_NAME_22190004c3782bc8: + .globl L_OBJC_METH_VAR_NAME_d6661a0373fc878f +L_OBJC_METH_VAR_NAME_d6661a0373fc878f: .asciz "methodBool:" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_22190004c3782bc8 + .globl L_OBJC_SELECTOR_REFERENCES_d6661a0373fc878f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_22190004c3782bc8: - .quad L_OBJC_METH_VAR_NAME_22190004c3782bc8 +L_OBJC_SELECTOR_REFERENCES_d6661a0373fc878f: + .quad L_OBJC_METH_VAR_NAME_d6661a0373fc878f .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_22190004c3782bc8 + .globl L_OBJC_IMAGE_INFO_d6661a0373fc878f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_22190004c3782bc8: +L_OBJC_IMAGE_INFO_d6661a0373fc878f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_384873ae30ec6d43 -L_OBJC_METH_VAR_NAME_384873ae30ec6d43: + .globl L_OBJC_METH_VAR_NAME_8677be6883ccd195 +L_OBJC_METH_VAR_NAME_8677be6883ccd195: .asciz "methodRetained" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_384873ae30ec6d43 + .globl L_OBJC_SELECTOR_REFERENCES_8677be6883ccd195 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_384873ae30ec6d43: - .quad L_OBJC_METH_VAR_NAME_384873ae30ec6d43 +L_OBJC_SELECTOR_REFERENCES_8677be6883ccd195: + .quad L_OBJC_METH_VAR_NAME_8677be6883ccd195 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_384873ae30ec6d43 + .globl L_OBJC_IMAGE_INFO_8677be6883ccd195 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_384873ae30ec6d43: +L_OBJC_IMAGE_INFO_8677be6883ccd195: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_56240dc6bf8dcec3 -L_OBJC_METH_VAR_NAME_56240dc6bf8dcec3: + .globl L_OBJC_METH_VAR_NAME_3f5c953c5f98b853 +L_OBJC_METH_VAR_NAME_3f5c953c5f98b853: .asciz "methodRetainedWithParam:" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_56240dc6bf8dcec3 + .globl L_OBJC_SELECTOR_REFERENCES_3f5c953c5f98b853 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_56240dc6bf8dcec3: - .quad L_OBJC_METH_VAR_NAME_56240dc6bf8dcec3 +L_OBJC_SELECTOR_REFERENCES_3f5c953c5f98b853: + .quad L_OBJC_METH_VAR_NAME_3f5c953c5f98b853 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_56240dc6bf8dcec3 + .globl L_OBJC_IMAGE_INFO_3f5c953c5f98b853 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_56240dc6bf8dcec3: +L_OBJC_IMAGE_INFO_3f5c953c5f98b853: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_8e8381168048230b -L_OBJC_METH_VAR_NAME_8e8381168048230b: + .globl L_OBJC_METH_VAR_NAME_76a1da9e60049d4f +L_OBJC_METH_VAR_NAME_76a1da9e60049d4f: .asciz "copyWithZone:" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_8e8381168048230b + .globl L_OBJC_SELECTOR_REFERENCES_76a1da9e60049d4f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_8e8381168048230b: - .quad L_OBJC_METH_VAR_NAME_8e8381168048230b +L_OBJC_SELECTOR_REFERENCES_76a1da9e60049d4f: + .quad L_OBJC_METH_VAR_NAME_76a1da9e60049d4f .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_8e8381168048230b + .globl L_OBJC_IMAGE_INFO_76a1da9e60049d4f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_8e8381168048230b: +L_OBJC_IMAGE_INFO_76a1da9e60049d4f: .asciz "\000\000\000\000@\000\000" - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1),8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2),8,3 .section __DATA,__const .p2align 3, 0x0 l_anon.[ID].24: .quad l_anon.[ID].14 - .asciz "5\000\000\000\000\000\000\000M\000\000\000\001\000\000" + .asciz "4\000\000\000\000\000\000\000M\000\000\000\001\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_affdf4249c01fc9d -L_OBJC_METH_VAR_NAME_affdf4249c01fc9d: + .globl L_OBJC_METH_VAR_NAME_8ae30338ec8fe87d +L_OBJC_METH_VAR_NAME_8ae30338ec8fe87d: .asciz "init" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_affdf4249c01fc9d + .globl L_OBJC_SELECTOR_REFERENCES_8ae30338ec8fe87d .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_affdf4249c01fc9d: - .quad L_OBJC_METH_VAR_NAME_affdf4249c01fc9d +L_OBJC_SELECTOR_REFERENCES_8ae30338ec8fe87d: + .quad L_OBJC_METH_VAR_NAME_8ae30338ec8fe87d .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_affdf4249c01fc9d + .globl L_OBJC_IMAGE_INFO_8ae30338ec8fe87d .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_affdf4249c01fc9d: +L_OBJC_IMAGE_INFO_8ae30338ec8fe87d: .asciz "\000\000\000\000@\000\000" - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0),8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0),8,3 .section __DATA,__const .p2align 3, 0x0 l_anon.[ID].25: .quad l_anon.[ID].14 - .asciz "5\000\000\000\000\000\000\000o\000\000\000\001\000\000" + .asciz "4\000\000\000\000\000\000\000o\000\000\000\001\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_8a88921dfbe0b09d -L_OBJC_METH_VAR_NAME_8a88921dfbe0b09d: + .globl L_OBJC_METH_VAR_NAME_c3d3047551604c9f +L_OBJC_METH_VAR_NAME_c3d3047551604c9f: .asciz "init" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_8a88921dfbe0b09d + .globl L_OBJC_SELECTOR_REFERENCES_c3d3047551604c9f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_8a88921dfbe0b09d: - .quad L_OBJC_METH_VAR_NAME_8a88921dfbe0b09d +L_OBJC_SELECTOR_REFERENCES_c3d3047551604c9f: + .quad L_OBJC_METH_VAR_NAME_c3d3047551604c9f .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_8a88921dfbe0b09d + .globl L_OBJC_IMAGE_INFO_c3d3047551604c9f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_8a88921dfbe0b09d: +L_OBJC_IMAGE_INFO_c3d3047551604c9f: .asciz "\000\000\000\000@\000\000" .zerofill __DATA,__bss,__MergedGlobals,48,3 diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-armv7s.s b/crates/test-assembly/crates/test_define_class/expected/apple-armv7s.s similarity index 100% rename from crates/test-assembly/crates/test_declare_class/expected/apple-armv7s.s rename to crates/test-assembly/crates/test_define_class/expected/apple-armv7s.s diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-old-x86.s b/crates/test-assembly/crates/test_define_class/expected/apple-old-x86.s similarity index 100% rename from crates/test-assembly/crates/test_declare_class/expected/apple-old-x86.s rename to crates/test-assembly/crates/test_define_class/expected/apple-old-x86.s diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-x86.s b/crates/test-assembly/crates/test_define_class/expected/apple-x86.s similarity index 100% rename from crates/test-assembly/crates/test_declare_class/expected/apple-x86.s rename to crates/test-assembly/crates/test_define_class/expected/apple-x86.s diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s b/crates/test-assembly/crates/test_define_class/expected/apple-x86_64.s similarity index 61% rename from crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s rename to crates/test-assembly/crates/test_define_class/expected/apple-x86_64.s index f19208c3f..501681377 100644 --- a/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_define_class/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::declared_ivars::dealloc::, 0): +SYM(objc2[CRATE_ID]::__macro_helpers::defined_ivars::dealloc::, 0): Lfunc_begin0: push rbp mov rbp, rsp @@ -11,15 +11,15 @@ Lfunc_begin0: sub rsp, 24 mov rbx, rsi mov r14, rdi - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] movzx eax, byte ptr [rdi + rax] test eax, eax je LBB0_6 cmp eax, 255 jne LBB0_3 - call SYM(::drop, 0) + call SYM(::drop, 0) LBB0_3: - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] mov rdi, qword ptr [r14 + rax] mov r15, qword ptr [r14 + rax + 8] Ltmp0: @@ -100,7 +100,7 @@ Lttbase0: .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 -SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): Lfunc_begin1: push rbp mov rbp, rsp @@ -115,52 +115,52 @@ Lfunc_begin1: lea rdi, [rip + l_anon.[ID].13] lea rcx, [rip + l_anon.[ID].15] mov esi, 7 - call SYM(objc2::__macro_helpers::declare_class::create_builder::GENERATED_ID, 0) + call SYM(objc2::__macro_helpers::define_class::create_builder::GENERATED_ID, 0) mov qword ptr [rbp - 16], rax - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_4534bbe5e50290a1] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_4ee60abb2719f036] Ltmp6: lea r8, [rip + l_anon.[ID].16] lea r9, [rip + _get_class] lea rdi, [rbp - 16] mov edx, 8 xor ecx, ecx - call SYM(objc2::runtime::declare::ClassBuilder::add_class_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_class_method_inner::GENERATED_ID, 0) Ltmp7: - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_885f02de2bcfda61] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_94f56691766f024b] Ltmp8: lea r8, [rip + l_anon.[ID].3] lea r9, [rip + _method_simple] lea rdi, [rbp - 16] mov edx, 8 xor ecx, ecx - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp9: - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_22190004c3782bc8] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_d6661a0373fc878f] Ltmp10: lea rdx, [rip + l_anon.[ID].17] lea r9, [rip + _method_bool] lea rdi, [rbp - 16] mov ecx, 1 mov r8, rdx - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp11: - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_384873ae30ec6d43] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_8677be6883ccd195] Ltmp12: lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _method_retained] lea rdi, [rbp - 16] mov edx, 8 xor ecx, ecx - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp13: - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_56240dc6bf8dcec3] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_3f5c953c5f98b853] Ltmp14: lea rdx, [rip + l_anon.[ID].17] lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _method_retained_with_param] lea rdi, [rbp - 16] mov ecx, 1 - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp15: Ltmp16: lea rdi, [rip + L_anon.[ID].19] @@ -184,19 +184,19 @@ Ltmp19: mov rsi, rax call _class_addProtocol LBB1_12: - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_8e8381168048230b] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_76a1da9e60049d4f] Ltmp20: lea rdx, [rip + l_anon.[ID].23] lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _copyWithZone] lea rdi, [rbp - 16] mov ecx, 1 - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp21: mov rbx, qword ptr [rbp - 16] mov rdi, rbx call _objc_registerClassPair - mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0], rbx + mov qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0], rbx add rsp, 8 pop rbx pop rbp @@ -238,7 +238,7 @@ Lcst_end1: .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 -SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): Lfunc_begin2: push rbp mov rbp, rsp @@ -254,18 +254,18 @@ Lfunc_begin2: lea rdi, [rip + l_anon.[ID].10] lea rcx, [rip + l_anon.[ID].25] mov esi, 9 - call SYM(objc2::__macro_helpers::declare_class::create_builder::GENERATED_ID, 0) + call SYM(objc2::__macro_helpers::define_class::create_builder::GENERATED_ID, 0) mov qword ptr [rbp - 72], rax mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_dealloc@GOTPCREL] mov rsi, qword ptr [rax] Ltmp23: lea r8, [rip + l_anon.[ID].3] - lea r9, [rip + SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::, 0)] + lea r9, [rip + SYM(objc2[CRATE_ID]::__macro_helpers::defined_ivars::dealloc::, 0)] lea rbx, [rbp - 72] mov edx, 8 mov rdi, rbx xor ecx, ecx - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp24: mov rax, qword ptr [rbp - 72] mov qword ptr [rbp - 32], rax @@ -278,7 +278,7 @@ Ltmp26: mov edx, 8 mov rdi, rbx xor ecx, ecx - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp27: mov rax, qword ptr [rbp - 32] mov qword ptr [rbp - 24], rax @@ -294,7 +294,7 @@ Ltmp29: mov ecx, 16 mov rdi, rbx mov r8d, 3 - call SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) Ltmp30: Ltmp31: lea rsi, [rip + l_anon.[ID].5] @@ -303,7 +303,7 @@ Ltmp31: mov edx, 10 mov ecx, 1 xor r8d, r8d - call SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) Ltmp32: mov rbx, qword ptr [rbp - 24] mov rdi, rbx @@ -323,9 +323,9 @@ Ltmp32: je LBB2_10 mov rdi, rax call _ivar_getOffset - mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0], rbx - mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)], r14 - mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)], rax + mov qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0], rbx + mov qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)], r14 + mov qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)], rax add rsp, 64 pop rbx pop r14 @@ -335,9 +335,9 @@ LBB2_14: lea rdi, [rip + l_anon.[ID].12] call SYM(core::option::unwrap_failed::GENERATED_ID, 0) LBB2_6: - call SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) + call SYM(objc2::__macro_helpers::defined_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) LBB2_10: - call SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_drop_flag_failed::GENERATED_ID, 0) + call SYM(objc2::__macro_helpers::defined_ivars::register_with_ivars::get_drop_flag_failed::GENERATED_ID, 0) LBB2_12: Ltmp28: jmp LBB2_8 @@ -387,7 +387,7 @@ Lcst_end2: .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 -SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): Lfunc_begin3: push rbp mov rbp, rsp @@ -403,7 +403,7 @@ Lfunc_begin3: lea rdi, [rip + l_anon.[ID].9] lea rcx, [rip + l_anon.[ID].24] mov esi, 15 - call SYM(objc2::__macro_helpers::declare_class::create_builder::GENERATED_ID, 0) + call SYM(objc2::__macro_helpers::define_class::create_builder::GENERATED_ID, 0) mov qword ptr [rbp - 24], rax mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_init@GOTPCREL] mov rsi, qword ptr [rax] @@ -414,7 +414,7 @@ Ltmp34: mov edx, 8 mov rdi, rbx xor ecx, ecx - call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_method_inner::GENERATED_ID, 0) Ltmp35: mov rax, qword ptr [rbp - 24] mov qword ptr [rbp - 32], rax @@ -430,7 +430,7 @@ Ltmp37: mov ecx, 8 mov rdi, rbx mov r8d, 2 - call SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) + call SYM(objc2::runtime::define::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) Ltmp38: mov rbx, qword ptr [rbp - 32] mov rdi, rbx @@ -442,8 +442,8 @@ Ltmp38: je LBB3_4 mov rdi, rax call _ivar_getOffset - mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0], rbx - mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)], rax + mov qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0], rbx + mov qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)], rax add rsp, 64 pop rbx pop r14 @@ -453,7 +453,7 @@ LBB3_9: lea rdi, [rip + l_anon.[ID].12] call SYM(core::option::unwrap_failed::GENERATED_ID, 0) LBB3_4: - call SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) + call SYM(objc2::__macro_helpers::defined_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) LBB3_5: Ltmp39: jmp LBB3_6 @@ -496,40 +496,40 @@ Lcst_end3: .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 -SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): +SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): push rbp mov rbp, rsp sub rsp, 16 mov rax, qword ptr [rdi] mov qword ptr [rbp - 8], rax lea rdi, [rbp - 8] - call SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + call SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) add rsp, 16 pop rbp ret .p2align 4, 0x90 -SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): +SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): push rbp mov rbp, rsp sub rsp, 16 mov rax, qword ptr [rdi] mov qword ptr [rbp - 8], rax lea rdi, [rbp - 8] - call SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + call SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) add rsp, 16 pop rbp ret .p2align 4, 0x90 -SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): +SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): push rbp mov rbp, rsp sub rsp, 16 mov rax, qword ptr [rdi] mov qword ptr [rbp - 8], rax lea rdi, [rbp - 8] - call SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + call SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) add rsp, 16 pop rbp ret @@ -537,10 +537,10 @@ SYM(<::call_once<::class::REGISTER_CLASS, 0)] + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB7_1 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] ret LBB7_1: push rbp @@ -549,7 +549,7 @@ LBB7_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].2] lea r8, [rip + l_anon.[ID].24] lea rdx, [rbp - 16] @@ -557,7 +557,7 @@ LBB7_1: call SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) add rsp, 16 pop rbp - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] ret .globl _access_forgetable_ivars @@ -565,15 +565,15 @@ LBB7_1: _access_forgetable_ivars: push rbp mov rbp, rsp - mov rcx, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)] + mov rcx, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)] movzx eax, byte ptr [rdi + rcx + 4] mov edx, dword ptr [rdi + rcx] pop rbp ret - .globl SYM(::drop, 0) + .globl SYM(::drop, 0) .p2align 4, 0x90 -SYM(::drop, 0): +SYM(::drop, 0): push rbp mov rbp, rsp ## InlineAsm Start @@ -584,10 +584,10 @@ SYM( .globl _access_drop_ivars_class .p2align 4, 0x90 _access_drop_ivars_class: - mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB10_1 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] ret LBB10_1: push rbp @@ -596,7 +596,7 @@ LBB10_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].1] lea r8, [rip + l_anon.[ID].25] lea rdx, [rbp - 16] @@ -604,7 +604,7 @@ LBB10_1: call SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) add rsp, 16 pop rbp - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] ret .globl _access_drop_ivars @@ -612,19 +612,19 @@ LBB10_1: _access_drop_ivars: push rbp mov rbp, rsp - mov rcx, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] + mov rcx, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] mov rax, qword ptr [rdi + rcx] mov rdx, qword ptr [rdi + rcx + 8] pop rbp ret - .globl SYM(::class, 0) + .globl SYM(::class, 0) .p2align 4, 0x90 -SYM(::class, 0): - mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] +SYM(::class, 0): + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB12_1 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] ret LBB12_1: push rbp @@ -633,7 +633,7 @@ LBB12_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] lea r8, [rip + l_anon.[ID].15] lea rdx, [rbp - 16] @@ -641,16 +641,16 @@ LBB12_1: call SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) add rsp, 16 pop rbp - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] ret .globl _get_class .p2align 4, 0x90 _get_class: - mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB13_1 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] ret LBB13_1: push rbp @@ -659,7 +659,7 @@ LBB13_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] lea r8, [rip + l_anon.[ID].15] lea rdx, [rbp - 16] @@ -667,7 +667,7 @@ LBB13_1: call SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) add rsp, 16 pop rbp - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] ret .globl _method_simple @@ -695,11 +695,11 @@ _method_retained: push rbp mov rbp, rsp sub rsp, 16 - mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB16_1 LBB16_2: - mov rdi, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] + mov rdi, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_new@GOTPCREL] mov rsi, qword ptr [rax] call _objc_msgSend @@ -712,7 +712,7 @@ LBB16_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] lea r8, [rip + l_anon.[ID].15] lea rdx, [rbp - 16] @@ -805,11 +805,11 @@ _copyWithZone: push rbp mov rbp, rsp sub rsp, 16 - mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB18_1 LBB18_2: - mov rdi, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] + mov rdi, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0] mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_new@GOTPCREL] mov rsi, qword ptr [rax] call _objc_msgSend @@ -820,7 +820,7 @@ LBB18_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].0] lea r8, [rip + l_anon.[ID].15] lea rdx, [rbp - 16] @@ -828,13 +828,13 @@ LBB18_1: call SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) jmp LBB18_2 - .globl SYM(::class, 0) + .globl SYM(::class, 0) .p2align 4, 0x90 -SYM(::class, 0): - mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] +SYM(::class, 0): + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB19_1 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] ret LBB19_1: push rbp @@ -843,7 +843,7 @@ LBB19_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].2] lea r8, [rip + l_anon.[ID].24] lea rdx, [rbp - 16] @@ -851,7 +851,7 @@ LBB19_1: call SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) add rsp, 16 pop rbp - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0] ret .globl _init_forgetable_ivars @@ -859,14 +859,14 @@ LBB19_1: _init_forgetable_ivars: test rdi, rdi je LBB20_2 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)] mov dword ptr [rdi + rax], 43 mov byte ptr [rdi + rax + 4], 42 LBB20_2: push rbp mov rbp, rsp sub rsp, 16 - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_affdf4249c01fc9d] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_8ae30338ec8fe87d] mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPCREL] mov rax, qword ptr [rax] mov qword ptr [rbp - 16], rdi @@ -877,13 +877,13 @@ LBB20_2: pop rbp ret - .globl SYM(::class, 0) + .globl SYM(::class, 0) .p2align 4, 0x90 -SYM(::class, 0): - mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] +SYM(::class, 0): + mov rax, qword ptr [rip + SYM(::class::REGISTER_CLASS, 0)] cmp rax, 3 jne LBB21_1 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] ret LBB21_1: push rbp @@ -892,7 +892,7 @@ LBB21_1: mov byte ptr [rbp - 1], 1 lea rax, [rbp - 1] mov qword ptr [rbp - 16], rax - lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] + lea rdi, [rip + SYM(::class::REGISTER_CLASS, 0)] lea rcx, [rip + l_anon.[ID].1] lea r8, [rip + l_anon.[ID].25] lea rdx, [rbp - 16] @@ -900,7 +900,7 @@ LBB21_1: call SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) add rsp, 16 pop rbp - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0] ret .globl _init_drop_ivars @@ -925,10 +925,10 @@ Ltmp50: mov r12, rax test rbx, rbx je LBB22_3 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] mov qword ptr [rbx + rax], r15 mov qword ptr [rbx + rax + 8], r12 - mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] + mov rax, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] mov byte ptr [rbx + rax], 15 jmp LBB22_9 LBB22_3: @@ -939,7 +939,7 @@ Ltmp58: mov rdi, r12 call _objc_release LBB22_9: - mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_8a88921dfbe0b09d] + mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_c3d3047551604c9f] mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPCREL] mov rax, qword ptr [rax] mov qword ptr [rbp - 48], rbx @@ -948,7 +948,7 @@ LBB22_9: call _objc_msgSendSuper test rax, rax je LBB22_11 - mov rcx, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] + mov rcx, qword ptr [rip + SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] mov byte ptr [rax + rcx], -1 LBB22_11: add rsp, 16 @@ -1043,20 +1043,20 @@ Lttbase2: .p2align 3, 0x0 l_anon.[ID].0: .asciz "\000\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000" - .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) - .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) + .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) .p2align 3, 0x0 l_anon.[ID].1: .asciz "\000\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000" - .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) - .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) + .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) .p2align 3, 0x0 l_anon.[ID].2: .asciz "\000\000\000\000\000\000\000\000\b\000\000\000\000\000\000\000\b\000\000\000\000\000\000" - .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) - .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) + .quad SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0) + .quad SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0) .section __TEXT,__const .p2align 3, 0x0 @@ -1104,11 +1104,11 @@ l_anon.[ID].12: l_anon.[ID].13: .ascii "NoIvars" -.zerofill __DATA,__bss,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0,8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2),8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1),8,3 +.zerofill __DATA,__bss,SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0,8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 2),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 1),8,3 l_anon.[ID].14: .ascii "crates/$DIR/lib.rs" @@ -1116,9 +1116,9 @@ l_anon.[ID].14: .p2align 3, 0x0 l_anon.[ID].15: .quad l_anon.[ID].14 - .asciz "5\000\000\000\000\000\000\000\016\000\000\000\001\000\000" + .asciz "4\000\000\000\000\000\000\000\016\000\000\000\001\000\000" -.zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 +.zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 .section __TEXT,__const .p2align 3, 0x0 l_anon.[ID].16: @@ -1164,163 +1164,163 @@ l_anon.[ID].23: .space 24 .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_4534bbe5e50290a1 -L_OBJC_METH_VAR_NAME_4534bbe5e50290a1: + .globl L_OBJC_METH_VAR_NAME_4ee60abb2719f036 +L_OBJC_METH_VAR_NAME_4ee60abb2719f036: .asciz "classMethod" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_4534bbe5e50290a1 + .globl L_OBJC_SELECTOR_REFERENCES_4ee60abb2719f036 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_4534bbe5e50290a1: - .quad L_OBJC_METH_VAR_NAME_4534bbe5e50290a1 +L_OBJC_SELECTOR_REFERENCES_4ee60abb2719f036: + .quad L_OBJC_METH_VAR_NAME_4ee60abb2719f036 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_4534bbe5e50290a1 + .globl L_OBJC_IMAGE_INFO_4ee60abb2719f036 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_4534bbe5e50290a1: +L_OBJC_IMAGE_INFO_4ee60abb2719f036: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_885f02de2bcfda61 -L_OBJC_METH_VAR_NAME_885f02de2bcfda61: + .globl L_OBJC_METH_VAR_NAME_94f56691766f024b +L_OBJC_METH_VAR_NAME_94f56691766f024b: .asciz "method" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_885f02de2bcfda61 + .globl L_OBJC_SELECTOR_REFERENCES_94f56691766f024b .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_885f02de2bcfda61: - .quad L_OBJC_METH_VAR_NAME_885f02de2bcfda61 +L_OBJC_SELECTOR_REFERENCES_94f56691766f024b: + .quad L_OBJC_METH_VAR_NAME_94f56691766f024b .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_885f02de2bcfda61 + .globl L_OBJC_IMAGE_INFO_94f56691766f024b .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_885f02de2bcfda61: +L_OBJC_IMAGE_INFO_94f56691766f024b: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_22190004c3782bc8 -L_OBJC_METH_VAR_NAME_22190004c3782bc8: + .globl L_OBJC_METH_VAR_NAME_d6661a0373fc878f +L_OBJC_METH_VAR_NAME_d6661a0373fc878f: .asciz "methodBool:" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_22190004c3782bc8 + .globl L_OBJC_SELECTOR_REFERENCES_d6661a0373fc878f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_22190004c3782bc8: - .quad L_OBJC_METH_VAR_NAME_22190004c3782bc8 +L_OBJC_SELECTOR_REFERENCES_d6661a0373fc878f: + .quad L_OBJC_METH_VAR_NAME_d6661a0373fc878f .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_22190004c3782bc8 + .globl L_OBJC_IMAGE_INFO_d6661a0373fc878f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_22190004c3782bc8: +L_OBJC_IMAGE_INFO_d6661a0373fc878f: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_384873ae30ec6d43 -L_OBJC_METH_VAR_NAME_384873ae30ec6d43: + .globl L_OBJC_METH_VAR_NAME_8677be6883ccd195 +L_OBJC_METH_VAR_NAME_8677be6883ccd195: .asciz "methodRetained" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_384873ae30ec6d43 + .globl L_OBJC_SELECTOR_REFERENCES_8677be6883ccd195 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_384873ae30ec6d43: - .quad L_OBJC_METH_VAR_NAME_384873ae30ec6d43 +L_OBJC_SELECTOR_REFERENCES_8677be6883ccd195: + .quad L_OBJC_METH_VAR_NAME_8677be6883ccd195 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_384873ae30ec6d43 + .globl L_OBJC_IMAGE_INFO_8677be6883ccd195 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_384873ae30ec6d43: +L_OBJC_IMAGE_INFO_8677be6883ccd195: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_56240dc6bf8dcec3 -L_OBJC_METH_VAR_NAME_56240dc6bf8dcec3: + .globl L_OBJC_METH_VAR_NAME_3f5c953c5f98b853 +L_OBJC_METH_VAR_NAME_3f5c953c5f98b853: .asciz "methodRetainedWithParam:" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_56240dc6bf8dcec3 + .globl L_OBJC_SELECTOR_REFERENCES_3f5c953c5f98b853 .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_56240dc6bf8dcec3: - .quad L_OBJC_METH_VAR_NAME_56240dc6bf8dcec3 +L_OBJC_SELECTOR_REFERENCES_3f5c953c5f98b853: + .quad L_OBJC_METH_VAR_NAME_3f5c953c5f98b853 .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_56240dc6bf8dcec3 + .globl L_OBJC_IMAGE_INFO_3f5c953c5f98b853 .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_56240dc6bf8dcec3: +L_OBJC_IMAGE_INFO_3f5c953c5f98b853: .asciz "\000\000\000\000@\000\000" .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_8e8381168048230b -L_OBJC_METH_VAR_NAME_8e8381168048230b: + .globl L_OBJC_METH_VAR_NAME_76a1da9e60049d4f +L_OBJC_METH_VAR_NAME_76a1da9e60049d4f: .asciz "copyWithZone:" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_8e8381168048230b + .globl L_OBJC_SELECTOR_REFERENCES_76a1da9e60049d4f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_8e8381168048230b: - .quad L_OBJC_METH_VAR_NAME_8e8381168048230b +L_OBJC_SELECTOR_REFERENCES_76a1da9e60049d4f: + .quad L_OBJC_METH_VAR_NAME_76a1da9e60049d4f .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_8e8381168048230b + .globl L_OBJC_IMAGE_INFO_76a1da9e60049d4f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_8e8381168048230b: +L_OBJC_IMAGE_INFO_76a1da9e60049d4f: .asciz "\000\000\000\000@\000\000" -.zerofill __DATA,__bss,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0,8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1),8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2),8,3 +.zerofill __DATA,__bss,SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0,8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 2),8,3 .section __DATA,__const .p2align 3, 0x0 l_anon.[ID].24: .quad l_anon.[ID].14 - .asciz "5\000\000\000\000\000\000\000M\000\000\000\001\000\000" + .asciz "4\000\000\000\000\000\000\000M\000\000\000\001\000\000" -.zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 +.zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_affdf4249c01fc9d -L_OBJC_METH_VAR_NAME_affdf4249c01fc9d: + .globl L_OBJC_METH_VAR_NAME_8ae30338ec8fe87d +L_OBJC_METH_VAR_NAME_8ae30338ec8fe87d: .asciz "init" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_affdf4249c01fc9d + .globl L_OBJC_SELECTOR_REFERENCES_8ae30338ec8fe87d .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_affdf4249c01fc9d: - .quad L_OBJC_METH_VAR_NAME_affdf4249c01fc9d +L_OBJC_SELECTOR_REFERENCES_8ae30338ec8fe87d: + .quad L_OBJC_METH_VAR_NAME_8ae30338ec8fe87d .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_affdf4249c01fc9d + .globl L_OBJC_IMAGE_INFO_8ae30338ec8fe87d .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_affdf4249c01fc9d: +L_OBJC_IMAGE_INFO_8ae30338ec8fe87d: .asciz "\000\000\000\000@\000\000" -.zerofill __DATA,__bss,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0,8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0),8,3 - .globl SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0) -.zerofill __DATA,__common,SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0),8,3 +.zerofill __DATA,__bss,SYM(test_define_class[CRATE_ID]::_::__OBJC2_CLASS, 1).0,8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0),8,3 + .globl SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0) +.zerofill __DATA,__common,SYM(test_define_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0),8,3 .section __DATA,__const .p2align 3, 0x0 l_anon.[ID].25: .quad l_anon.[ID].14 - .asciz "5\000\000\000\000\000\000\000o\000\000\000\001\000\000" + .asciz "4\000\000\000\000\000\000\000o\000\000\000\001\000\000" -.zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 +.zerofill __DATA,__bss,SYM(::class::REGISTER_CLASS, 0),8,3 .section __TEXT,__objc_methname,cstring_literals - .globl L_OBJC_METH_VAR_NAME_8a88921dfbe0b09d -L_OBJC_METH_VAR_NAME_8a88921dfbe0b09d: + .globl L_OBJC_METH_VAR_NAME_c3d3047551604c9f +L_OBJC_METH_VAR_NAME_c3d3047551604c9f: .asciz "init" .section __DATA,__objc_selrefs,literal_pointers - .globl L_OBJC_SELECTOR_REFERENCES_8a88921dfbe0b09d + .globl L_OBJC_SELECTOR_REFERENCES_c3d3047551604c9f .p2align 3, 0x0 -L_OBJC_SELECTOR_REFERENCES_8a88921dfbe0b09d: - .quad L_OBJC_METH_VAR_NAME_8a88921dfbe0b09d +L_OBJC_SELECTOR_REFERENCES_c3d3047551604c9f: + .quad L_OBJC_METH_VAR_NAME_c3d3047551604c9f .section __DATA,__objc_imageinfo,regular,no_dead_strip - .globl L_OBJC_IMAGE_INFO_8a88921dfbe0b09d + .globl L_OBJC_IMAGE_INFO_c3d3047551604c9f .p2align 2, 0x0 -L_OBJC_IMAGE_INFO_8a88921dfbe0b09d: +L_OBJC_IMAGE_INFO_c3d3047551604c9f: .asciz "\000\000\000\000@\000\000" .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_declare_class/expected/gnustep-x86.s b/crates/test-assembly/crates/test_define_class/expected/gnustep-x86.s similarity index 100% rename from crates/test-assembly/crates/test_declare_class/expected/gnustep-x86.s rename to crates/test-assembly/crates/test_define_class/expected/gnustep-x86.s diff --git a/crates/test-assembly/crates/test_declare_class/expected/gnustep-x86_64.s b/crates/test-assembly/crates/test_define_class/expected/gnustep-x86_64.s similarity index 100% rename from crates/test-assembly/crates/test_declare_class/expected/gnustep-x86_64.s rename to crates/test-assembly/crates/test_define_class/expected/gnustep-x86_64.s diff --git a/crates/test-assembly/crates/test_declare_class/lib.rs b/crates/test-assembly/crates/test_define_class/lib.rs similarity index 96% rename from crates/test-assembly/crates/test_declare_class/lib.rs rename to crates/test-assembly/crates/test_define_class/lib.rs index cf32b0b26..5a12e1d9a 100644 --- a/crates/test-assembly/crates/test_declare_class/lib.rs +++ b/crates/test-assembly/crates/test_define_class/lib.rs @@ -1,4 +1,4 @@ -//! Test assembly output of `declare_class!`. +//! Test assembly output of `define_class!`. #![deny(unsafe_op_in_unsafe_fn)] // Limit to Apple targets only, since we don't particularly care about GNUStep code-size for now. #![cfg(target_vendor = "apple")] @@ -8,10 +8,10 @@ use core::ptr; use objc2::rc::{Allocated, Retained}; use objc2::runtime::AnyClass; -use objc2::{declare_class, msg_send_id, ClassType, DeclaredClass}; +use objc2::{define_class, msg_send_id, ClassType, DefinedClass}; use objc2_foundation::{CopyingHelper, NSCopying, NSObject, NSObjectProtocol, NSZone}; -declare_class!( +define_class!( #[no_mangle] #[unsafe(super(NSObject))] #[name = "NoIvars"] @@ -74,7 +74,7 @@ pub struct ForgetableIvarsIvars { bar: u32, } -declare_class!( +define_class!( #[no_mangle] #[unsafe(super(NSObject))] #[name = "ForgetableIvars"] @@ -108,7 +108,7 @@ pub struct DropIvarsIvars { obj_option: Option>, } -declare_class!( +define_class!( #[no_mangle] #[unsafe(super(NSObject))] #[name = "DropIvars"] diff --git a/crates/test-fuzz/fuzz_targets/collection_interior_mut.rs b/crates/test-fuzz/fuzz_targets/collection_interior_mut.rs index 23ce4a6c3..bdc242a6b 100644 --- a/crates/test-fuzz/fuzz_targets/collection_interior_mut.rs +++ b/crates/test-fuzz/fuzz_targets/collection_interior_mut.rs @@ -12,7 +12,7 @@ use std::hint::black_box; use arbitrary::Arbitrary; use objc2::rc::{autoreleasepool, Retained}; use objc2::runtime::AnyObject; -use objc2::{declare_class, msg_send_id, AllocAnyThread, ClassType, DeclaredClass, Message}; +use objc2::{define_class, msg_send_id, AllocAnyThread, ClassType, DefinedClass, Message}; use objc2_foundation::{ CopyingHelper, NSCopying, NSMutableDictionary, NSMutableSet, NSObject, NSObjectProtocol, NSUInteger, NSZone, @@ -47,7 +47,7 @@ struct KeyIvars { equal_to_mask: Cell, } -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "Key"] #[ivars = KeyIvars] diff --git a/crates/test-ui/ui/add_method_no_bool.rs b/crates/test-ui/ui/add_method_no_bool.rs index d4d75ba08..093c189bc 100644 --- a/crates/test-ui/ui/add_method_no_bool.rs +++ b/crates/test-ui/ui/add_method_no_bool.rs @@ -1,8 +1,7 @@ //! Ensure that methods taking/returning `bool` are not allowed. //! //! This is not sound without a conversion step. -use objc2::declare::ClassBuilder; -use objc2::runtime::{NSObject, Sel}; +use objc2::runtime::{ClassBuilder, NSObject, Sel}; use objc2::sel; extern "C" fn my_bool_taking_method(_obj: &NSObject, _sel: Sel, _arg: bool) {} diff --git a/crates/test-ui/ui/add_method_no_bool.stderr b/crates/test-ui/ui/add_method_no_bool.stderr index f17b7d84b..7a5ae533b 100644 --- a/crates/test-ui/ui/add_method_no_bool.stderr +++ b/crates/test-ui/ui/add_method_no_bool.stderr @@ -19,7 +19,7 @@ error[E0277]: the trait bound `bool: Encode` is not satisfied = note: required for `bool` to implement `EncodeArgument` = 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/runtime/declare.rs + --> $WORKSPACE/crates/objc2/src/runtime/define.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function @@ -48,7 +48,7 @@ error[E0277]: the trait bound `bool: Encode` is not satisfied = note: required for `bool` to implement `EncodeReturn` = 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/runtime/declare.rs + --> $WORKSPACE/crates/objc2/src/runtime/define.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function diff --git a/crates/test-ui/ui/declare_add_bad_method.rs b/crates/test-ui/ui/define_add_bad_method.rs similarity index 85% rename from crates/test-ui/ui/declare_add_bad_method.rs rename to crates/test-ui/ui/define_add_bad_method.rs index e9d7350c0..0241ead98 100644 --- a/crates/test-ui/ui/declare_add_bad_method.rs +++ b/crates/test-ui/ui/define_add_bad_method.rs @@ -1,10 +1,9 @@ -use objc2::declare::ClassBuilder; use objc2::rc::{Allocated, Retained}; -use objc2::runtime::{NSObject, Sel}; +use objc2::runtime::{ClassBuilder, NSObject, Sel}; use objc2::{sel, ClassType}; fn main() { - let builder = ClassBuilder::new(c"DeclareClassTest", NSObject::class()).unwrap(); + let builder = ClassBuilder::new(c"DefineClassTest", NSObject::class()).unwrap(); // Test receiver unsafe { diff --git a/crates/test-ui/ui/declare_add_bad_method.stderr b/crates/test-ui/ui/define_add_bad_method.stderr similarity index 94% rename from crates/test-ui/ui/declare_add_bad_method.stderr rename to crates/test-ui/ui/define_add_bad_method.stderr index 7c1830b24..6df84ce1b 100644 --- a/crates/test-ui/ui/declare_add_bad_method.stderr +++ b/crates/test-ui/ui/define_add_bad_method.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `fn(_, _): MethodImplementation` is not satisfied - --> ui/declare_add_bad_method.rs + --> ui/define_add_bad_method.rs | | builder.add_method(sel!(foo), foo as fn(_, _)); | ---------- ^^^^^^^^^^^^^^^ the trait `MethodImplementation` is not implemented for `fn(_, _)` @@ -17,7 +17,7 @@ error[E0277]: the trait bound `fn(_, _): MethodImplementation` is not satisfied extern "C" fn(Allocated, objc2::runtime::Sel, A, B, C, D, E, F, G) -> RetainedReturnValue and $N others note: required by a bound in `ClassBuilder::add_method` - --> $WORKSPACE/crates/objc2/src/runtime/declare.rs + --> $WORKSPACE/crates/objc2/src/runtime/define.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function @@ -26,7 +26,7 @@ note: required by a bound in `ClassBuilder::add_method` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilder::add_method` error[E0277]: the trait bound `fn(_, _): MethodImplementation` is not satisfied - --> ui/declare_add_bad_method.rs + --> ui/define_add_bad_method.rs | | builder.add_method(sel!(foo), foo as fn(_, _)); | ---------- ^^^^^^^^^^^^^^^ the trait `MethodImplementation` is not implemented for `fn(_, _)` @@ -44,7 +44,7 @@ error[E0277]: the trait bound `fn(_, _): MethodImplementation` is not satisfied extern "C" fn(Allocated, objc2::runtime::Sel, A, B, C, D, E, F, G) -> RetainedReturnValue and $N others note: required by a bound in `ClassBuilder::add_method` - --> $WORKSPACE/crates/objc2/src/runtime/declare.rs + --> $WORKSPACE/crates/objc2/src/runtime/define.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function @@ -53,7 +53,7 @@ note: required by a bound in `ClassBuilder::add_method` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilder::add_method` error[E0277]: the trait bound `fn(_, _) -> _: MethodImplementation` is not satisfied - --> ui/declare_add_bad_method.rs + --> ui/define_add_bad_method.rs | | builder.add_method(sel!(foo), foo as fn(_, _) -> _); | ---------- ^^^^^^^^^^^^^^^^^^^^ the trait `MethodImplementation` is not implemented for `fn(_, _) -> _` @@ -71,7 +71,7 @@ error[E0277]: the trait bound `fn(_, _) -> _: MethodImplementation` is not satis extern "C" fn(Allocated, objc2::runtime::Sel, A, B, C, D, E, F, G) -> RetainedReturnValue and $N others note: required by a bound in `ClassBuilder::add_method` - --> $WORKSPACE/crates/objc2/src/runtime/declare.rs + --> $WORKSPACE/crates/objc2/src/runtime/define.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function @@ -80,7 +80,7 @@ note: required by a bound in `ClassBuilder::add_method` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilder::add_method` error[E0277]: the trait bound `fn(_, _) -> _: MethodImplementation` is not satisfied - --> ui/declare_add_bad_method.rs + --> ui/define_add_bad_method.rs | | builder.add_method(sel!(foo), foo as fn(_, _) -> _); | ---------- ^^^^^^^^^^^^^^^^^^^^ the trait `MethodImplementation` is not implemented for `fn(_, _) -> _` @@ -98,7 +98,7 @@ error[E0277]: the trait bound `fn(_, _) -> _: MethodImplementation` is not satis extern "C" fn(Allocated, objc2::runtime::Sel, A, B, C, D, E, F, G) -> RetainedReturnValue and $N others note: required by a bound in `ClassBuilder::add_method` - --> $WORKSPACE/crates/objc2/src/runtime/declare.rs + --> $WORKSPACE/crates/objc2/src/runtime/define.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function @@ -107,7 +107,7 @@ note: required by a bound in `ClassBuilder::add_method` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilder::add_method` error[E0277]: the trait bound `fn(_, _, _): MethodImplementation` is not satisfied - --> ui/declare_add_bad_method.rs + --> ui/define_add_bad_method.rs | | builder.add_method(sel!(foo:), foo as fn(_, _, _)); | ---------- ^^^^^^^^^^^^^^^^^^ the trait `MethodImplementation` is not implemented for `fn(_, _, _)` @@ -125,7 +125,7 @@ error[E0277]: the trait bound `fn(_, _, _): MethodImplementation` is not satisfi extern "C" fn(Allocated, objc2::runtime::Sel, A, B, C, D, E, F, G) -> RetainedReturnValue and $N others note: required by a bound in `ClassBuilder::add_method` - --> $WORKSPACE/crates/objc2/src/runtime/declare.rs + --> $WORKSPACE/crates/objc2/src/runtime/define.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function diff --git a/crates/test-ui/ui/declare_class_delegate_not_mainthreadonly.rs b/crates/test-ui/ui/define_class_delegate_not_mainthreadonly.rs similarity index 92% rename from crates/test-ui/ui/declare_class_delegate_not_mainthreadonly.rs rename to crates/test-ui/ui/define_class_delegate_not_mainthreadonly.rs index 6332d80e1..0a8e3d18d 100644 --- a/crates/test-ui/ui/declare_class_delegate_not_mainthreadonly.rs +++ b/crates/test-ui/ui/define_class_delegate_not_mainthreadonly.rs @@ -2,7 +2,7 @@ //! a `MainThreadOnly` class. use objc2::rc::Retained; use objc2::{ - declare_class, extern_methods, extern_protocol, AllocAnyThread, MainThreadOnly, ProtocolType, + define_class, extern_methods, extern_protocol, AllocAnyThread, MainThreadOnly, ProtocolType, }; use objc2_foundation::{MainThreadMarker, NSNotification, NSObject, NSObjectProtocol}; @@ -19,7 +19,7 @@ extern_protocol!( unsafe impl ProtocolType for dyn NSApplicationDelegate {} ); -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[thread_kind = AllocAnyThread] // Not `MainThreadOnly` #[name = "CustomObject"] diff --git a/crates/test-ui/ui/declare_class_delegate_not_mainthreadonly.stderr b/crates/test-ui/ui/define_class_delegate_not_mainthreadonly.stderr similarity index 92% rename from crates/test-ui/ui/declare_class_delegate_not_mainthreadonly.stderr rename to crates/test-ui/ui/define_class_delegate_not_mainthreadonly.stderr index c413bdfd3..271513914 100644 --- a/crates/test-ui/ui/declare_class_delegate_not_mainthreadonly.stderr +++ b/crates/test-ui/ui/define_class_delegate_not_mainthreadonly.stderr @@ -1,5 +1,5 @@ error[E0271]: type mismatch resolving `::ThreadKind == dyn MainThreadOnly` - --> ui/declare_class_delegate_not_mainthreadonly.rs + --> ui/define_class_delegate_not_mainthreadonly.rs | | unsafe impl NSApplicationDelegate for CustomObject { | ^^^^^^^^^^^^ expected trait `MainThreadOnly`, found trait `AllocAnyThread` @@ -9,7 +9,7 @@ error[E0271]: type mismatch resolving `::ThreadKind = = help: `(dyn AllocAnyThread + 'static)` implements `MainThreadOnly` so you could box the found value and coerce it to the trait object `Box`, you will have to change the expected type as well = note: required for `CustomObject` to implement `MainThreadOnly` note: required by a bound in `NSApplicationDelegate` - --> ui/declare_class_delegate_not_mainthreadonly.rs + --> ui/define_class_delegate_not_mainthreadonly.rs | | / extern_protocol!( | | pub unsafe trait NSApplicationDelegate: NSObjectProtocol + MainThreadOnly { diff --git a/crates/test-ui/ui/declare_class_invalid_receiver.rs b/crates/test-ui/ui/define_class_invalid_receiver.rs similarity index 97% rename from crates/test-ui/ui/declare_class_invalid_receiver.rs rename to crates/test-ui/ui/define_class_invalid_receiver.rs index 81736c654..06c95a6af 100644 --- a/crates/test-ui/ui/declare_class_invalid_receiver.rs +++ b/crates/test-ui/ui/define_class_invalid_receiver.rs @@ -1,9 +1,9 @@ #![allow(unused_variables)] -use objc2::declare_class; +use objc2::define_class; use objc2::rc::{Allocated, Retained}; use objc2::runtime::{AnyClass, NSObject}; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "CustomObject"] struct CustomObject; diff --git a/crates/test-ui/ui/declare_class_invalid_receiver.stderr b/crates/test-ui/ui/define_class_invalid_receiver.stderr similarity index 73% rename from crates/test-ui/ui/declare_class_invalid_receiver.stderr rename to crates/test-ui/ui/define_class_invalid_receiver.stderr index 91b7079f8..6e7129535 100644 --- a/crates/test-ui/ui/declare_class_invalid_receiver.stderr +++ b/crates/test-ui/ui/define_class_invalid_receiver.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -21,19 +21,19 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf NonNull = note: required for `extern "C-unwind" fn(Box, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Retained: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -53,19 +53,19 @@ error[E0277]: the trait bound `Retained: MessageReceiver` is not s NonNull = note: required for `extern "C-unwind" fn(Retained, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -85,19 +85,19 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied NonNull = note: required for `extern "C-unwind" fn(CustomObject, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0271]: type mismatch resolving `::Callee == CustomObject` - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -110,19 +110,19 @@ error[E0271]: type mismatch resolving `::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0271]: type mismatch resolving `::Callee == CustomObject` - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -135,19 +135,19 @@ error[E0271]: type mismatch resolving `::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Box: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -167,19 +167,19 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf NonNull = note: required for `extern "C-unwind" fn(Box, objc2::runtime::Sel) -> RetainedReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Retained: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -199,19 +199,19 @@ error[E0277]: the trait bound `Retained: MessageReceiver` is not s NonNull = note: required for `extern "C-unwind" fn(Retained, objc2::runtime::Sel) -> RetainedReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -231,19 +231,19 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied NonNull = note: required for `extern "C-unwind" fn(CustomObject, objc2::runtime::Sel) -> RetainedReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Box: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -259,12 +259,12 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf *mut T NonNull = note: required for `RetainSemantics<6>` to implement `MessageReceiveRetained, Retained>` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Retained: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -280,12 +280,12 @@ error[E0277]: the trait bound `Retained: MessageReceiver` is not s *mut T NonNull = note: required for `RetainSemantics<6>` to implement `MessageReceiveRetained, Retained>` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -301,12 +301,12 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied *mut T NonNull = note: required for `RetainSemantics<6>` to implement `MessageReceiveRetained>` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Allocated: MessageReceiver` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -322,12 +322,12 @@ error[E0277]: the trait bound `Allocated: MessageReceiver` is not *mut T NonNull = note: required for `RetainSemantics<6>` to implement `MessageReceiveRetained, Retained>` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `RetainSemantics<3>: MessageReceiveRetained<&CustomObject, Retained>` is not satisfied - --> ui/declare_class_invalid_receiver.rs + --> ui/define_class_invalid_receiver.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -339,4 +339,4 @@ error[E0277]: the trait bound `RetainSemantics<3>: MessageReceiveRetained<&Custo = help: the trait `MessageReceiveRetained<&CustomObject, Retained>` is not implemented for `RetainSemantics<3>` but trait `MessageReceiveRetained, Retained>` is implemented for it = help: for that trait implementation, expected `Allocated`, found `&CustomObject` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/test-ui/ui/declare_class_invalid_syntax.rs b/crates/test-ui/ui/define_class_invalid_syntax.rs similarity index 96% rename from crates/test-ui/ui/declare_class_invalid_syntax.rs rename to crates/test-ui/ui/define_class_invalid_syntax.rs index e9a038d63..7423546a1 100644 --- a/crates/test-ui/ui/declare_class_invalid_syntax.rs +++ b/crates/test-ui/ui/define_class_invalid_syntax.rs @@ -1,8 +1,8 @@ -use objc2::declare_class; +use objc2::define_class; use objc2::rc::Retained; use objc2::runtime::NSObject; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "InvalidMethodDeclarations"] struct InvalidMethodDeclarations; @@ -126,27 +126,27 @@ declare_class!( } ); -declare_class!( +define_class!( #[unsafe(super(NSObject))] struct MissingName; ); -declare_class!( +define_class!( #[name = "MissingSuper"] struct MissingSuper; ); -declare_class!( +define_class!( #[super(NSObject)] #[name = "SafeSuper"] struct SafeSuper; ); -declare_class!( +define_class!( struct MissingBoth; ); -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "HasRepr"] #[repr(transparent)] diff --git a/crates/test-ui/ui/declare_class_invalid_syntax.stderr b/crates/test-ui/ui/define_class_invalid_syntax.stderr similarity index 67% rename from crates/test-ui/ui/declare_class_invalid_syntax.stderr rename to crates/test-ui/ui/define_class_invalid_syntax.stderr index 5d123eb19..3a94d8903 100644 --- a/crates/test-ui/ui/declare_class_invalid_syntax.stderr +++ b/crates/test-ui/ui/define_class_invalid_syntax.stderr @@ -1,7 +1,7 @@ error: must specify the desired selector using `#[method(...)]` or `#[method_id(...)]` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -10,12 +10,12 @@ error: must specify the desired selector using `#[method(...)]` or `#[method_id( | | ); | |_^ | - = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot specify the `method`/`method_id` attribute twice - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -24,12 +24,12 @@ error: cannot specify the `method`/`method_id` attribute twice | | ); | |_^ | - = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot specify the `method`/`method_id` attribute twice - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -38,16 +38,16 @@ error: cannot specify the `method`/`method_id` attribute twice | | ); | |_^ | - = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected expression, found `}` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | } | ^ expected expression error: no rules expected `(` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn test_pattern((a, b): (u32, i32)) { | ^ no rules expected this token in macro call @@ -55,21 +55,21 @@ error: no rules expected `(` = note: while trying to match sequence start error: unexpected end of macro invocation - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn test_self(self) { | ^ missing tokens in macro arguments | note: while trying to match `:` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | $param:ident : $param_ty:ty $(, $($rest:tt)*)? | ^ error: no rules expected `(` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -79,12 +79,12 @@ error: no rules expected `(` | |_^ no rules expected this token in macro call | = note: while trying to match end of macro - = note: this error originates in the macro `$crate::__declare_class_register_methods` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_methods` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `(` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -94,16 +94,16 @@ error: no rules expected `(` | |_^ no rules expected this token in macro call | = note: while trying to match end of macro - = note: this error originates in the macro `$crate::__declare_class_register_methods` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_methods` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected identifier, found keyword `fn` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn fn test_fn_fn() {} | ^^ expected identifier, found keyword error: missing parameters for function definition - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn fn test_fn_fn() {} | ^ @@ -114,31 +114,31 @@ help: add a parameter list | ++ error: expected one of `->`, `<`, `where`, or `{`, found `test_fn_fn` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn fn test_fn_fn() {} | ^^^^^^^^^^ expected one of `->`, `<`, `where`, or `{` | - ::: $WORKSPACE/crates/objc2/src/macros/declare_class.rs + ::: $WORKSPACE/crates/objc2/src/macros/define_class.rs | | $_associated_item:item | ---------------------- while parsing argument for this `item` macro fragment error: expected one of `->`, `where`, or `{`, found `` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn test_unfinished() | ^ expected one of `->`, `where`, or `{` | - ::: $WORKSPACE/crates/objc2/src/macros/declare_class.rs + ::: $WORKSPACE/crates/objc2/src/macros/define_class.rs | | $_associated_item:item | ---------------------- while parsing argument for this `item` macro fragment error: `#[method_id(alloc)]` is not supported. Use `#[method(alloc)]` and do the memory management yourself - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -147,12 +147,12 @@ error: `#[method_id(alloc)]` is not supported. Use `#[method(alloc)]` and do the | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_invalid_selectors` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_invalid_selectors` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[method_id(retain)]` is not supported. Use `#[method(retain)]` and do the memory management yourself - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -161,12 +161,12 @@ error: `#[method_id(retain)]` is not supported. Use `#[method(retain)]` and do t | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_invalid_selectors` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_invalid_selectors` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[method_id(release)]` is not supported. Use `#[method(release)]` and do the memory management yourself - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -175,12 +175,12 @@ error: `#[method_id(release)]` is not supported. Use `#[method(release)]` and do | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_invalid_selectors` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_invalid_selectors` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[method_id(autorelease)]` is not supported. Use `#[method(autorelease)]` and do the memory management yourself - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -189,12 +189,12 @@ error: `#[method_id(autorelease)]` is not supported. Use `#[method(autorelease)] | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_invalid_selectors` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_invalid_selectors` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[method_id(dealloc)]` is not supported. Implement `Drop` for the type instead - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -203,12 +203,12 @@ error: `#[method_id(dealloc)]` is not supported. Implement `Drop` for the type i | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_invalid_selectors` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_invalid_selectors` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[method(dealloc)]` is not supported. Implement `Drop` for the type instead - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -217,10 +217,10 @@ error: `#[method(dealloc)]` is not supported. Implement `Drop` for the type inst | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_invalid_selectors` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_invalid_selectors` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: an inner attribute is not permitted in this context - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | #![doc = "inner_attribute"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -229,20 +229,20 @@ error: an inner attribute is not permitted in this context = note: outer attributes, like `#[test]`, annotate the item following them error: expected an item keyword - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | #![doc = "inner_attribute"] | ^ | - ::: $WORKSPACE/crates/objc2/src/macros/declare_class.rs + ::: $WORKSPACE/crates/objc2/src/macros/define_class.rs | | $_associated_item:item | ---------------------- while parsing argument for this `item` macro fragment error: must specify the desired selector using `#[method(...)]` or `#[method_id(...)]` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -251,12 +251,12 @@ error: must specify the desired selector using `#[method(...)]` or `#[method_id( | | ); | |_^ | - = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot specify the `method`/`method_id` attribute twice - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -265,12 +265,12 @@ error: cannot specify the `method`/`method_id` attribute twice | | ); | |_^ | - = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: cannot specify the `method`/`method_id` attribute twice - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -279,12 +279,12 @@ error: cannot specify the `method`/`method_id` attribute twice | | ); | |_^ | - = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extract_custom_attributes_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[method_id(...)]` must have a return type - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -293,24 +293,24 @@ error: `#[method_id(...)]` must have a return type | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected `(` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn test_pattern((a, b): (u32, i32)) { | ^ no rules expected this token in macro call | note: while trying to match reserved identifier `_` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | (_ : $param_ty:ty $(, $($params_rest:tt)*)?) | ^ error: no rules expected `)` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -320,122 +320,122 @@ error: no rules expected `)` | |_^ no rules expected this token in macro call | note: while trying to match `:` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | ($param:ident : $param_ty:ty $(, $($params_rest:tt)*)?) | ^ - = note: this error originates in the macro `$crate::__declare_class_method_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: no rules expected keyword `pub` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | pub fn test_pub() {} | ^^^ no rules expected this token in macro call | note: while trying to match keyword `unsafe` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | unsafe fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^^^^^^ error: no rules expected keyword `const` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | const fn test_const() {} | ^^^^^ no rules expected this token in macro call | note: while trying to match keyword `unsafe` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | unsafe fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^^^^^^ error: no rules expected keyword `async` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | async fn test_async() {} | ^^^^^ no rules expected this token in macro call | note: while trying to match keyword `unsafe` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | unsafe fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^^^^^^ error: no rules expected keyword `extern` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | extern "C" fn test_extern() {} | ^^^^^^ no rules expected this token in macro call | note: while trying to match keyword `unsafe` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | unsafe fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^^^^^^ error: no rules expected `test_fn_fn` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn fn test_fn_fn() {} | ^^^^^^^^^^ no rules expected this token in macro call | note: while trying to match `(` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^ error: no rules expected `<` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn test_generic() {} | ^ no rules expected this token in macro call | note: while trying to match `(` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^ error: no rules expected `;` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn test_no_body(&self); | ^ no rules expected this token in macro call | note: while trying to match meta-variable `$body:block` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^^^^^^^^^^^ error: unexpected end of macro invocation - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | fn test_unfinished() | ^ missing tokens in macro arguments | note: while trying to match meta-variable `$body:block` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | fn $name:ident($($params:tt)*) $(-> $ret:ty)? $body:block | ^^^^^^^^^^^ error: no rules expected `!` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | #![doc = "inner_attribute"] | ^ no rules expected this token in macro call | note: while trying to match `[` - --> $WORKSPACE/crates/objc2/src/macros/declare_class.rs + --> $WORKSPACE/crates/objc2/src/macros/define_class.rs | | $(#[$($m:tt)*])* | ^ error: no rules expected keyword `type` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | type TypeAlias = Self; | ^^^^ no rules expected this token in macro call @@ -443,7 +443,7 @@ error: no rules expected keyword `type` = note: while trying to match end of macro error: no rules expected keyword `const` - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | | const CONSTANT: () = (); | ^^^^^ no rules expected this token in macro call @@ -451,63 +451,63 @@ error: no rules expected keyword `const` = note: while trying to match end of macro error: must set name of class with #[name = ...] - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | struct MissingName; | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: must specify the superclass with #[unsafe(super(...))] - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[name = "MissingSuper"] | | struct MissingSuper; | | ); | |_^ | - = note: this error originates in the macro `$crate::__extern_class_check_super_unsafe` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extern_class_check_super_unsafe` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: #[super(...)] must be wrapped in `unsafe`, as in #[unsafe(super(...))] - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[super(NSObject)] | | #[name = "SafeSuper"] | | struct SafeSuper; | | ); | |_^ | - = note: this error originates in the macro `$crate::__extern_class_check_super_unsafe` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extern_class_check_super_unsafe` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: must set name of class with #[name = ...] - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | struct MissingBoth; | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: must specify the superclass with #[unsafe(super(...))] - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | struct MissingBoth; | | ); | |_^ | - = note: this error originates in the macro `$crate::__extern_class_check_super_unsafe` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extern_class_check_super_unsafe` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0692]: transparent struct cannot have other repr hints - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "HasRepr"] | | #[repr(transparent)] @@ -516,12 +516,12 @@ error[E0692]: transparent struct cannot have other repr hints | | ); | |_^ | - = note: this error originates in the macro `$crate::__declare_class_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0599]: no function or associated item named `test_pattern` found for struct `InvalidMethodDeclarations` in the current scope - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -534,9 +534,9 @@ error[E0599]: no function or associated item named `test_pattern` found for stru | |_- function or associated item `test_pattern` not found for this struct error[E0599]: no function or associated item named `test_self` found for struct `InvalidMethodDeclarations` in the current scope - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -549,9 +549,9 @@ 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>: MessageReceiveRetained<&AnyClass, Retained>` is not satisfied - --> ui/declare_class_invalid_syntax.rs + --> ui/define_class_invalid_syntax.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "InvalidMethodDeclarations"] | | struct InvalidMethodDeclarations; @@ -566,4 +566,4 @@ error[E0277]: the trait bound `RetainSemantics<2>: MessageReceiveRetained<&AnyCl `RetainSemantics<4>` implements `MessageReceiveRetained` `RetainSemantics<5>` implements `MessageReceiveRetained` `RetainSemantics<6>` implements `MessageReceiveRetained` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/test-ui/ui/declare_class_invalid_type.rs b/crates/test-ui/ui/define_class_invalid_type.rs similarity index 93% rename from crates/test-ui/ui/declare_class_invalid_type.rs rename to crates/test-ui/ui/define_class_invalid_type.rs index e386c16ce..bdb0c6a6a 100644 --- a/crates/test-ui/ui/declare_class_invalid_type.rs +++ b/crates/test-ui/ui/define_class_invalid_type.rs @@ -1,8 +1,8 @@ -use objc2::declare_class; +use objc2::define_class; use objc2::rc::Retained; use objc2::runtime::NSObject; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "CustomObject"] struct CustomObject; diff --git a/crates/test-ui/ui/declare_class_invalid_type.stderr b/crates/test-ui/ui/define_class_invalid_type.stderr similarity index 78% rename from crates/test-ui/ui/declare_class_invalid_type.stderr rename to crates/test-ui/ui/define_class_invalid_type.stderr index 5510cdb05..b2e0eb304 100644 --- a/crates/test-ui/ui/declare_class_invalid_type.stderr +++ b/crates/test-ui/ui/define_class_invalid_type.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `Retained: EncodeReturn` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -31,12 +31,12 @@ note: required by a bound in `ConvertReturn` = help: the following types implement the trait: bool T - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Vec<()>: EncodeReturn` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -66,12 +66,12 @@ note: required by a bound in `ConvertReturn` = help: the following types implement the trait: bool T - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Box: EncodeArgument` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -105,12 +105,12 @@ note: required by a bound in `ConvertArgument` std::option::Option<&mut std::option::Option>> bool T - = note: this error originates in the macro `$crate::__declare_class_rewrite_params` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_rewrite_params` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `CustomObject: EncodeArgument` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -144,12 +144,12 @@ note: required by a bound in `ConvertArgument` std::option::Option<&mut std::option::Option>> bool T - = note: this error originates in the macro `$crate::__declare_class_rewrite_params` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_rewrite_params` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Retained: EncodeReturn` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -170,12 +170,12 @@ error[E0277]: the trait bound `Retained: EncodeReturn` is not sati and $N others = note: required for `Retained` to implement `EncodeReturn` = note: required for `Retained` to implement `ConvertReturn` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Retained: Encode` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -200,19 +200,19 @@ error[E0277]: the trait bound `Retained: Encode` is not satisfied = note: required for `Retained` to implement `EncodeReturn` = note: required for `extern "C-unwind" fn(&AnyClass, objc2::runtime::Sel) -> Retained` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_class_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_class_method(&mut self, sel: Sel, func: F) | ---------------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_class_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Vec<()>: EncodeReturn` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -233,12 +233,12 @@ error[E0277]: the trait bound `Vec<()>: EncodeReturn` is not satisfied and $N others = note: required for `Vec<()>` to implement `EncodeReturn` = note: required for `Vec<()>` to implement `ConvertReturn` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Vec<()>: Encode` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -263,19 +263,19 @@ error[E0277]: the trait bound `Vec<()>: Encode` is not satisfied = note: required for `Vec<()>` to implement `EncodeReturn` = note: required for `extern "C-unwind" fn(&AnyClass, objc2::runtime::Sel) -> Vec<()>` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_class_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_class_method(&mut self, sel: Sel, func: F) | ---------------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_class_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Box: EncodeArgument` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -296,12 +296,12 @@ error[E0277]: the trait bound `Box: EncodeArgument` is not satisfied and $N others = note: required for `Box` to implement `EncodeArgument` = note: required for `Box` to implement `ConvertArgument` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Box: Encode` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -326,19 +326,19 @@ error[E0277]: the trait bound `Box: Encode` is not satisfied = note: required for `Box` to implement `EncodeArgument` = note: required for `extern "C-unwind" fn(&CustomObject, objc2::runtime::Sel, Box)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `CustomObject: EncodeArgument` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -359,12 +359,12 @@ error[E0277]: the trait bound `CustomObject: EncodeArgument` is not satisfied and $N others = note: required for `CustomObject` to implement `EncodeArgument` = note: required for `CustomObject` to implement `ConvertArgument` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `CustomObject: Encode` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -389,19 +389,19 @@ error[E0277]: the trait bound `CustomObject: Encode` is not satisfied = note: required for `CustomObject` to implement `EncodeArgument` = note: required for `extern "C-unwind" fn(&CustomObject, objc2::runtime::Sel, CustomObject)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Retained: EncodeReturn` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -422,12 +422,12 @@ error[E0277]: the trait bound `Retained: EncodeReturn` is not sati and $N others = note: required for `Retained` to implement `EncodeReturn` = note: required for `Retained` to implement `ConvertReturn` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Vec<()>: EncodeReturn` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -448,12 +448,12 @@ error[E0277]: the trait bound `Vec<()>: EncodeReturn` is not satisfied and $N others = note: required for `Vec<()>` to implement `EncodeReturn` = note: required for `Vec<()>` to implement `ConvertReturn` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `Box: EncodeArgument` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -474,12 +474,12 @@ error[E0277]: the trait bound `Box: EncodeArgument` is not satisfied and $N others = note: required for `Box` to implement `EncodeArgument` = note: required for `Box` to implement `ConvertArgument` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `CustomObject: EncodeArgument` is not satisfied - --> ui/declare_class_invalid_type.rs + --> ui/define_class_invalid_type.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -500,4 +500,4 @@ error[E0277]: the trait bound `CustomObject: EncodeArgument` is not satisfied and $N others = note: required for `CustomObject` to implement `EncodeArgument` = note: required for `CustomObject` to implement `ConvertArgument` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/test-ui/ui/declare_class_invalid_type2.rs b/crates/test-ui/ui/define_class_invalid_type2.rs similarity index 92% rename from crates/test-ui/ui/declare_class_invalid_type2.rs rename to crates/test-ui/ui/define_class_invalid_type2.rs index ef12c1f7b..771a379f5 100644 --- a/crates/test-ui/ui/declare_class_invalid_type2.rs +++ b/crates/test-ui/ui/define_class_invalid_type2.rs @@ -1,8 +1,8 @@ -use objc2::declare_class; +use objc2::define_class; use objc2::rc::{Allocated, Retained}; use objc2::runtime::NSObject; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "CustomObject"] struct CustomObject; diff --git a/crates/test-ui/ui/declare_class_invalid_type2.stderr b/crates/test-ui/ui/define_class_invalid_type2.stderr similarity index 66% rename from crates/test-ui/ui/declare_class_invalid_type2.stderr rename to crates/test-ui/ui/define_class_invalid_type2.stderr index c6a41e48e..63d488581 100644 --- a/crates/test-ui/ui/declare_class_invalid_type2.stderr +++ b/crates/test-ui/ui/define_class_invalid_type2.stderr @@ -1,7 +1,7 @@ error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Input == Option>` - --> ui/declare_class_invalid_type2.rs + --> ui/define_class_invalid_type2.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -13,12 +13,12 @@ error[E0271]: type mismatch resolving ` as MaybeUnwrap>::Inpu = note: expected enum `Option>` found enum `Option>` = note: required for `RetainSemantics<3>` to implement `MessageReceiveRetained, Retained>` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `i32: MaybeOptionRetained` is not satisfied - --> ui/declare_class_invalid_type2.rs + --> ui/define_class_invalid_type2.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -31,4 +31,4 @@ error[E0277]: the trait bound `i32: MaybeOptionRetained` is not satisfied Option> Retained = note: required for `RetainSemantics<6>` to implement `MessageReceiveRetained<&CustomObject, i32>` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/test-ui/ui/declare_class_mut_self_not_mutable.rs b/crates/test-ui/ui/define_class_mut_self_not_mutable.rs similarity index 92% rename from crates/test-ui/ui/declare_class_mut_self_not_mutable.rs rename to crates/test-ui/ui/define_class_mut_self_not_mutable.rs index dbd04b5f5..c1a00c973 100644 --- a/crates/test-ui/ui/declare_class_mut_self_not_mutable.rs +++ b/crates/test-ui/ui/define_class_mut_self_not_mutable.rs @@ -1,8 +1,8 @@ -use objc2::declare_class; +use objc2::define_class; use objc2::rc::Retained; use objc2::runtime::NSObject; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "CustomObject"] struct CustomObject; diff --git a/crates/test-ui/ui/declare_class_mut_self_not_mutable.stderr b/crates/test-ui/ui/define_class_mut_self_not_mutable.stderr similarity index 76% rename from crates/test-ui/ui/declare_class_mut_self_not_mutable.stderr rename to crates/test-ui/ui/define_class_mut_self_not_mutable.stderr index e1a282040..6b13145bd 100644 --- a/crates/test-ui/ui/declare_class_mut_self_not_mutable.stderr +++ b/crates/test-ui/ui/define_class_mut_self_not_mutable.stderr @@ -1,7 +1,7 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisfied - --> ui/declare_class_mut_self_not_mutable.rs + --> ui/define_class_mut_self_not_mutable.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -22,19 +22,19 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf = note: `MessageReceiver` is implemented for `&CustomObject`, but not for `&mut CustomObject` = note: required for `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel) -> &mut CustomObject` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisfied - --> ui/declare_class_mut_self_not_mutable.rs + --> ui/define_class_mut_self_not_mutable.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -55,19 +55,19 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf = note: `MessageReceiver` is implemented for `&CustomObject`, but not for `&mut CustomObject` = note: required for `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisfied - --> ui/declare_class_mut_self_not_mutable.rs + --> ui/define_class_mut_self_not_mutable.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -88,19 +88,19 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf = note: `MessageReceiver` is implemented for `&CustomObject`, but not for `&mut CustomObject` = note: required for `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel) -> RetainedReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` - --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs + --> $WORKSPACE/crates/objc2/src/__macro_helpers/define_class.rs | | pub unsafe fn add_method(&mut self, sel: Sel, func: F) | ---------- required by a bound in this associated function | where | F: MethodImplementation, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` - = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_register_out` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisfied - --> ui/declare_class_mut_self_not_mutable.rs + --> ui/define_class_mut_self_not_mutable.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject"] | | struct CustomObject; @@ -117,4 +117,4 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf NonNull = note: `MessageReceiver` is implemented for `&CustomObject`, but not for `&mut CustomObject` = note: required for `RetainSemantics<6>` to implement `MessageReceiveRetained<&mut CustomObject, Retained>` - = note: this error originates in the macro `$crate::__declare_class_method_out_inner` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__define_class_method_out_inner` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/test-ui/ui/fn_ptr_reference_method.rs b/crates/test-ui/ui/fn_ptr_reference_method.rs index 793f87935..b3df76ee4 100644 --- a/crates/test-ui/ui/fn_ptr_reference_method.rs +++ b/crates/test-ui/ui/fn_ptr_reference_method.rs @@ -5,8 +5,7 @@ //! //! (`_` 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::{NSObject, Sel}; +use objc2::runtime::{ClassBuilder, NSObject, Sel}; use objc2::{class, sel}; extern "C" fn my_fn(_this: &NSObject, _cmd: Sel, _x: &NSObject) {} diff --git a/crates/test-ui/ui/implement_protocol_missing_super.rs b/crates/test-ui/ui/implement_protocol_missing_super.rs index bae31da39..cc3336894 100644 --- a/crates/test-ui/ui/implement_protocol_missing_super.rs +++ b/crates/test-ui/ui/implement_protocol_missing_super.rs @@ -1,9 +1,9 @@ //! Test that implementing certain traits like `NSURLSessionDelegate` requires //! super protocols like `NSObjectProtocol` to also be implemented. -use objc2::{declare_class, MainThreadOnly}; +use objc2::{define_class, MainThreadOnly}; use objc2_foundation::{NSObject, NSURLSessionDelegate}; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[thread_kind = MainThreadOnly] #[name = "CustomObject"] diff --git a/crates/test-ui/ui/main_thread_only_not_allocable.rs b/crates/test-ui/ui/main_thread_only_not_allocable.rs index 614a1ceba..773306402 100644 --- a/crates/test-ui/ui/main_thread_only_not_allocable.rs +++ b/crates/test-ui/ui/main_thread_only_not_allocable.rs @@ -1,9 +1,9 @@ use objc2::runtime::NSObject; #[expect(unused_imports)] use objc2::AllocAnyThread; -use objc2::{declare_class, MainThreadOnly}; +use objc2::{define_class, MainThreadOnly}; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[thread_kind = MainThreadOnly] #[name = "MyMainThreadOnlyClass"] diff --git a/crates/test-ui/ui/thread_kind_traits_unimplementable.rs b/crates/test-ui/ui/thread_kind_traits_unimplementable.rs index 7a3696b29..6cca6f4ef 100644 --- a/crates/test-ui/ui/thread_kind_traits_unimplementable.rs +++ b/crates/test-ui/ui/thread_kind_traits_unimplementable.rs @@ -1,8 +1,8 @@ //! Check that `MainThreadOnly`/`AllocAnyThread` traits are not implementable manually. use objc2::runtime::NSObject; -use objc2::{declare_class, AllocAnyThread, MainThreadOnly}; +use objc2::{define_class, AllocAnyThread, MainThreadOnly}; -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[thread_kind = AllocAnyThread] #[name = "Normal"] @@ -12,7 +12,7 @@ declare_class!( unsafe impl MainThreadOnly for Normal {} -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[thread_kind = MainThreadOnly] #[name = "OnlyMain"] diff --git a/crates/test-ui/ui/wrong_optional.rs b/crates/test-ui/ui/wrong_optional.rs index 0cfed317b..61e705652 100644 --- a/crates/test-ui/ui/wrong_optional.rs +++ b/crates/test-ui/ui/wrong_optional.rs @@ -1,6 +1,6 @@ use objc2::rc::Retained; use objc2::runtime::NSObject; -use objc2::{declare_class, extern_class, extern_methods}; +use objc2::{define_class, extern_class, extern_methods}; extern_class!( #[unsafe(super(NSObject))] @@ -25,7 +25,7 @@ extern_methods!( } ); -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "CustomObject1"] struct CustomObject1; @@ -38,7 +38,7 @@ declare_class!( } ); -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "CustomObject2"] struct CustomObject2; diff --git a/crates/test-ui/ui/wrong_optional.stderr b/crates/test-ui/ui/wrong_optional.stderr index ea7e87d17..2b01b7d32 100644 --- a/crates/test-ui/ui/wrong_optional.stderr +++ b/crates/test-ui/ui/wrong_optional.stderr @@ -29,7 +29,7 @@ error: `#[optional]` is only supported in `extern_protocol!` error: `#[optional]` is only supported in `extern_protocol!` --> ui/wrong_optional.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject1"] | | struct CustomObject1; @@ -38,12 +38,12 @@ error: `#[optional]` is only supported in `extern_protocol!` | | ); | |_^ | - = note: this error originates in the macro `$crate::__extern_methods_no_optional` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extern_methods_no_optional` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) error: `#[optional]` is only supported in `extern_protocol!` --> ui/wrong_optional.rs | - | / declare_class!( + | / define_class!( | | #[unsafe(super(NSObject))] | | #[name = "CustomObject2"] | | struct CustomObject2; @@ -52,4 +52,4 @@ error: `#[optional]` is only supported in `extern_protocol!` | | ); | |_^ | - = note: this error originates in the macro `$crate::__extern_methods_no_optional` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::__extern_methods_no_optional` which comes from the expansion of the macro `define_class` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/crates/tests/src/lib.rs b/crates/tests/src/lib.rs index 793ab75b9..e18e1ca43 100644 --- a/crates/tests/src/lib.rs +++ b/crates/tests/src/lib.rs @@ -19,7 +19,7 @@ mod block; mod exception; mod rc_test_object; #[cfg(test)] -mod test_declare_class_protocol; +mod test_define_class_protocol; #[cfg(test)] mod test_encode_utils; #[cfg(test)] diff --git a/crates/tests/src/test_declare_class_protocol.rs b/crates/tests/src/test_define_class_protocol.rs similarity index 68% rename from crates/tests/src/test_declare_class_protocol.rs rename to crates/tests/src/test_define_class_protocol.rs index 907a1b9be..7322b73e4 100644 --- a/crates/tests/src/test_declare_class_protocol.rs +++ b/crates/tests/src/test_define_class_protocol.rs @@ -1,21 +1,21 @@ #![cfg(feature = "all")] use objc2::rc::Retained; use objc2::runtime::{NSObject, NSZone}; -use objc2::{declare_class, ClassType, ProtocolType}; +use objc2::{define_class, ClassType, ProtocolType}; use objc2_foundation::NSCopying; #[test] -#[should_panic = "could not create new class TestDeclareClassDuplicate. Perhaps a class with that name already exists?"] -fn test_declare_class_duplicate() { - declare_class!( +#[should_panic = "could not create new class TestDefineClassDuplicate. Perhaps a class with that name already exists?"] +fn test_define_class_duplicate() { + define_class!( #[unsafe(super(NSObject))] - #[name = "TestDeclareClassDuplicate"] + #[name = "TestDefineClassDuplicate"] struct Custom1; ); - declare_class!( + define_class!( #[unsafe(super(NSObject))] - #[name = "TestDeclareClassDuplicate"] + #[name = "TestDefineClassDuplicate"] struct Custom2; ); @@ -25,10 +25,10 @@ fn test_declare_class_duplicate() { } #[test] -fn test_declare_class_protocol() { - declare_class!( +fn test_define_class_protocol() { + define_class!( #[unsafe(super(NSObject))] - #[name = "TestDeclareClassProtocolNotFound"] + #[name = "TestDefineClassProtocolNotFound"] struct Custom; unsafe impl NSCopying for Custom { @@ -46,12 +46,12 @@ fn test_declare_class_protocol() { #[test] #[cfg_attr( debug_assertions, - should_panic = "declared invalid method -[TestDeclareClassInvalidMethod description]: expected return to have type code '@', but found 'v'" + should_panic = "defined invalid method -[TestDefineClassInvalidMethod description]: expected return to have type code '@', but found 'v'" )] -fn test_declare_class_invalid_method() { - declare_class!( +fn test_define_class_invalid_method() { + define_class!( #[unsafe(super(NSObject))] - #[name = "TestDeclareClassInvalidMethod"] + #[name = "TestDefineClassInvalidMethod"] struct Custom; unsafe impl Custom { @@ -69,10 +69,10 @@ fn test_declare_class_invalid_method() { debug_assertions, should_panic = "must implement required protocol method -[NSCopying copyWithZone:]" )] -fn test_declare_class_missing_protocol_method() { - declare_class!( +fn test_define_class_missing_protocol_method() { + define_class!( #[unsafe(super(NSObject))] - #[name = "TestDeclareClassMissingProtocolMethod"] + #[name = "TestDefineClassMissingProtocolMethod"] struct Custom; unsafe impl NSCopying for Custom { @@ -85,10 +85,10 @@ fn test_declare_class_missing_protocol_method() { #[test] // #[cfg_attr(debug_assertions, should_panic = "...")] -fn test_declare_class_invalid_protocol_method() { - declare_class!( +fn test_define_class_invalid_protocol_method() { + define_class!( #[unsafe(super(NSObject))] - #[name = "TestDeclareClassInvalidProtocolMethod"] + #[name = "TestDefineClassInvalidProtocolMethod"] struct Custom; unsafe impl NSCopying for Custom { @@ -108,10 +108,10 @@ fn test_declare_class_invalid_protocol_method() { debug_assertions, should_panic = "failed overriding protocol method -[NSCopying someOtherMethod]: method not found" )] -fn test_declare_class_extra_protocol_method() { - declare_class!( +fn test_define_class_extra_protocol_method() { + define_class!( #[unsafe(super(NSObject))] - #[name = "TestDeclareClassExtraProtocolMethod"] + #[name = "TestDefineClassExtraProtocolMethod"] struct Custom; unsafe impl NSCopying for Custom { diff --git a/crates/tests/src/test_foundation_retain_semantics.rs b/crates/tests/src/test_foundation_retain_semantics.rs index b7f98822c..e6af1f7a5 100644 --- a/crates/tests/src/test_foundation_retain_semantics.rs +++ b/crates/tests/src/test_foundation_retain_semantics.rs @@ -2,7 +2,7 @@ use std::ptr; use objc2::rc::Retained; -use objc2::{declare_class, extern_methods}; +use objc2::{define_class, extern_methods}; use objc2_foundation::{ CopyingHelper, NSArray, NSCopying, NSMutableArray, NSMutableCopying, NSMutableDictionary, NSMutableSet, NSNumber, NSSet, NSValue, @@ -351,7 +351,7 @@ fn value_does_not_retain() { expected.assert_current(); } -declare_class!( +define_class!( #[unsafe(super(RcTestObject))] #[name = "NSCopyingRcTestObject"] #[derive(Debug, PartialEq, Eq, Hash)] diff --git a/framework-crates/objc2-app-kit/examples/delegate.rs b/framework-crates/objc2-app-kit/examples/delegate.rs index 0dea656d2..1df9b33c9 100644 --- a/framework-crates/objc2-app-kit/examples/delegate.rs +++ b/framework-crates/objc2-app-kit/examples/delegate.rs @@ -1,7 +1,7 @@ #![deny(unsafe_op_in_unsafe_fn)] use objc2::rc::Retained; use objc2::runtime::ProtocolObject; -use objc2::{declare_class, msg_send_id, DeclaredClass, MainThreadMarker, MainThreadOnly}; +use objc2::{define_class, msg_send_id, DefinedClass, MainThreadMarker, MainThreadOnly}; use objc2_app_kit::{NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate}; use objc2_foundation::{ ns_string, NSCopying, NSNotification, NSObject, NSObjectProtocol, NSString, @@ -18,7 +18,7 @@ struct Ivars { maybe_id_ivar: Option>, } -declare_class!( +define_class!( // SAFETY: // - The superclass NSObject does not have any subclassing requirements. // - `AppDelegate` does not implement `Drop`. diff --git a/framework-crates/objc2-foundation/src/copying.rs b/framework-crates/objc2-foundation/src/copying.rs index a840c8fdd..a874172d5 100644 --- a/framework-crates/objc2-foundation/src/copying.rs +++ b/framework-crates/objc2-foundation/src/copying.rs @@ -116,12 +116,12 @@ extern_protocol!( /// Implement `NSCopying` for a custom class. /// /// ``` - /// use objc2::{declare_class, msg_send_id, AllocAnyThread, DeclaredClass}; + /// use objc2::{define_class, msg_send_id, AllocAnyThread, DefinedClass}; /// use objc2::rc::Retained; /// use objc2::runtime::NSZone; /// use objc2_foundation::{CopyingHelper, NSCopying, NSObject}; /// - /// declare_class!( + /// define_class!( /// #[unsafe(super(NSObject))] /// #[name = "CustomClass"] /// struct CustomClass; diff --git a/framework-crates/objc2-foundation/src/tests/auto_traits.rs b/framework-crates/objc2-foundation/src/tests/auto_traits.rs index 4f2c5c028..d470826af 100644 --- a/framework-crates/objc2-foundation/src/tests/auto_traits.rs +++ b/framework-crates/objc2-foundation/src/tests/auto_traits.rs @@ -4,7 +4,7 @@ use core::panic::{RefUnwindSafe, UnwindSafe}; use static_assertions::assert_not_impl_any; use crate::*; -use objc2::declare_class; +use objc2::define_class; use objc2::rc::Retained; use objc2::runtime::AnyObject; @@ -29,7 +29,7 @@ fn assert_auto_traits() { assert_unwindsafe::(); } -declare_class!( +define_class!( #[unsafe(super(NSObject))] #[name = "SendSyncObject"] struct SendSyncObject; diff --git a/framework-crates/objc2-metal/examples/triangle.rs b/framework-crates/objc2-metal/examples/triangle.rs index 3b2c4d769..4e1e1fd40 100644 --- a/framework-crates/objc2-metal/examples/triangle.rs +++ b/framework-crates/objc2-metal/examples/triangle.rs @@ -6,7 +6,7 @@ use core::{cell::OnceCell, ptr::NonNull}; use objc2::rc::Retained; use objc2::runtime::ProtocolObject; -use objc2::{declare_class, msg_send_id, DeclaredClass, MainThreadMarker, MainThreadOnly}; +use objc2::{define_class, msg_send_id, DefinedClass, MainThreadMarker, MainThreadOnly}; #[cfg(target_os = "macos")] use objc2_app_kit::{ NSApplication, NSApplicationActivationPolicy, NSApplicationDelegate, NSBackingStoreType, @@ -54,7 +54,7 @@ macro_rules! idcell { }; } -// declare the desired instance variables +// The state of our application. struct Ivars { start_date: Retained, command_queue: OnceCell>>, @@ -63,8 +63,7 @@ struct Ivars { window: OnceCell>, } -// declare the Objective-C class machinery -declare_class!( +define_class!( // SAFETY: // - The superclass NSObject does not have any subclassing requirements. // - `MainThreadOnly` is correct, since this is an application delegate. diff --git a/framework-crates/objc2-web-kit/examples/browser.rs b/framework-crates/objc2-web-kit/examples/browser.rs index 552e1552a..83637c657 100644 --- a/framework-crates/objc2-web-kit/examples/browser.rs +++ b/framework-crates/objc2-web-kit/examples/browser.rs @@ -4,10 +4,10 @@ use core::cell::OnceCell; use objc2::{ - declare_class, msg_send_id, + define_class, msg_send_id, rc::Retained, runtime::{AnyObject, ProtocolObject, Sel}, - sel, DeclaredClass, MainThreadMarker, MainThreadOnly, + sel, DefinedClass, MainThreadMarker, MainThreadOnly, }; #[allow(deprecated)] #[cfg(target_os = "macos")] @@ -52,7 +52,7 @@ struct Ivars { window: OnceCell>, } -declare_class!( +define_class!( // SAFETY: // - The superclass NSObject does not have any subclassing requirements. // - `MainThreadOnly` is correct, since this is an application delegate.