use core::cell::UnsafeCell; use core::ffi::c_int; use core::ffi::c_void; use core::marker::{PhantomData, PhantomPinned};
/// Type for block class ISAs. /// /// This will likely become an extern type in the future. #[repr(C)] #[allow(missing_debug_implementations)] pubstruct Class { /// The size probably doesn't really matter here, as we only ever use the /// classes behind pointers, but let's import it with the correct size to /// be sure. /// /// This applies with the compiler-rt runtime and with Apple's runtime. #[cfg(not(any(feature = "gnustep-1-7", feature = "unstable-objfw")))]
_priv: [*mut c_void; 32],
/// The size of this is unknown, so let's use a ZST so the compiler /// doesn't assume anything about the size. #[cfg(any(feature = "gnustep-1-7", feature = "unstable-objfw"))]
_priv: [u8; 0],
/// Mark as `!Send + !Sync + !Unpin` and as mutable behind shared /// references (`!Freeze`). /// /// Same as `objc2::ffi::OpaqueData`.
_opaque: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
// Use `extern "C-unwind"`, runtime functions may call external routines. extern"C-unwind" { /// Class ISA used for global blocks. pubstatic _NSConcreteGlobalBlock: Class;
/// Class ISA used for stack blocks. pubstatic _NSConcreteStackBlock: Class;
/// Copy/retain a block. /// /// When called on a: /// - Global block: Does nothing. /// - Stack block: `memmove`s the block to a new heap allocation, calls /// the copy helper, and returns the new malloc block. /// - Malloc block: Increments the retain count. /// /// Returns `NULL` on allocation failure. #[doc(alias = "Block_copy")] pubfn _Block_copy(block: *const c_void) -> *mut c_void;
/// Release a block. /// /// When called on a: /// - Global block: Does nothing. /// - Stack block: Does nothing. /// - Malloc block: Decrements the retain count, and if it reaches zero, /// calls the dispose helper and frees the underlying storage. #[doc(alias = "Block_release")] pubfn _Block_release(block: *const c_void);
/// Copy a block field or `__block` variable from one location to another. /// /// Called by C compilers to clone fields inside copy helper routines, and /// to handle memory management of `__block` marked variables. pubfn _Block_object_assign(dest_addr: *mut c_void, object: *const c_void, flags: c_int);
/// Dispose an object previously copied using `_Block_object_assign`. /// /// Called by C compilers to drop fields inside dispose helper routines, /// and handle memory management of `__block` marked variables. pubfn _Block_object_dispose(object: *const c_void, flags: c_int);
}
// Whether the return value of the block is on the stack. // macOS 10.7 #[cfg(any(doc, target_vendor = "apple"))] pubfn _Block_use_stret(block: *mut c_void) -> bool;
// Returns a string describing the block's GC layout. // This uses the GC skip/scan encoding. // May return NULL. // macOS 10.7 #[cfg(any(doc, target_vendor = "apple"))] pubfn _Block_layout(block: *mut c_void) -> *const c_char;
// Returns a string describing the block's layout. // This uses the "extended layout" form described above. // May return NULL. // macOS 10.8 #[cfg(any(doc, target_vendor = "apple"))] pubfn _Block_extended_layout(block: *mut c_void) -> *const c_char;
// Callable only from the ARR weak subsystem while in exclusion zone // macOS 10.7 #[cfg(any(doc, target_vendor = "apple"))] pubfn _Block_tryRetain(block: *const c_void) -> bool;
// Callable only from the ARR weak subsystem while in exclusion zone // macOS 10.7 #[cfg(any(doc, target_vendor = "apple"))] pubfn _Block_isDeallocating(block: *const c_void) -> bool;
// indicates whether block was compiled with compiler that sets the ABI // related metadata bits // macOS 10.7 #[cfg(any(doc, target_vendor = "apple", feature = "gnustep-1-7"))] pubfn _Block_has_signature(block: *mut c_void) -> bool;
// Returns a string describing the block's parameter and return types. // The encoding scheme is the same as Objective-C @encode. // Returns NULL for blocks compiled with some compilers. // macOS 10.7 #[cfg(any(doc, target_vendor = "apple", feature = "gnustep-1-7"))] pubfn _Block_signature(block: *mut c_void) -> *const c_char;
}
}
#[cfg(test)] mod tests { usesuper::*; use core::ptr;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.