objc_sys/
message.rs

1//! The `objc_msgSend` familiy of functions.
2//!
3//! Most of these are `cfg`-gated, these configs are semver-stable.
4//!
5//! TODO: Some of these are only supported on _some_ GNUStep targets!
6use crate::{objc_class, objc_object};
7#[cfg(any(doc, feature = "gnustep-1-7", feature = "unstable-objfw"))]
8use crate::{objc_selector, IMP};
9
10/// Specifies data used when sending messages to superclasses.
11#[repr(C)]
12#[derive(Debug, Copy, Clone)]
13// TODO: Does this belong in this file or in types.rs?
14pub struct objc_super {
15    /// The object / instance to send a message to.
16    pub receiver: *mut objc_object,
17    /// The particular superclass of the instance to message.
18    ///
19    /// Named `class` in older Objective-C versions.
20    pub super_class: *const objc_class,
21}
22
23// All message sending functions should use "C-unwind"!
24//
25// Note that lookup functions won't throw exceptions themselves, but they can
26// call hooks, `resolveClassMethod:` and `resolveInstanceMethod:`, so we have
27// to make those "C-unwind" as well!
28extern_c_unwind! {
29    #[cfg(any(doc, feature = "gnustep-1-7", feature = "unstable-objfw"))]
30    pub fn objc_msg_lookup(receiver: *mut objc_object, sel: *const objc_selector) -> IMP;
31    #[cfg(any(doc, feature = "unstable-objfw"))]
32    pub fn objc_msg_lookup_stret(receiver: *mut objc_object, sel: *const objc_selector) -> IMP;
33    #[cfg(any(doc, feature = "gnustep-1-7", feature = "unstable-objfw"))]
34    pub fn objc_msg_lookup_super(sup: *const objc_super, sel: *const objc_selector) -> IMP;
35    #[cfg(any(doc, feature = "unstable-objfw"))]
36    pub fn objc_msg_lookup_super_stret(sup: *const objc_super, sel: *const objc_selector) -> IMP;
37    // #[cfg(any(doc, feature = "gnustep-1-7"))]
38    // objc_msg_lookup_sender
39    // objc_msgLookup family available in macOS >= 10.12
40
41    // objc_msgSend_noarg
42
43    #[cfg(any(doc, not(feature = "unstable-objfw")))]
44    pub fn objc_msgSend();
45    // objc_msgSend_debug
46
47    #[cfg(any(doc, target_vendor = "apple"))]
48    pub fn objc_msgSendSuper();
49    // objc_msgSendSuper2
50    // objc_msgSendSuper2_debug
51
52    #[cfg(any(doc, target_vendor = "apple"))]
53    pub fn method_invoke();
54    #[cfg(any(doc, target_vendor = "apple"))]
55    pub fn _objc_msgForward();
56    pub fn class_getMethodImplementation();
57
58    // Struct return. Not available on __arm64__:
59
60    #[cfg(any(doc, all(not(feature = "unstable-objfw"), not(target_arch = "aarch64"))))]
61    pub fn objc_msgSend_stret();
62    // objc_msgSend_stret_debug
63
64    #[cfg(any(doc, all(target_vendor = "apple", not(target_arch = "aarch64"))))]
65    pub fn objc_msgSendSuper_stret();
66    // objc_msgSendSuper2_stret
67    // objc_msgSendSuper2_stret_debug
68
69    #[cfg(any(doc, all(target_vendor = "apple", not(target_arch = "aarch64"))))]
70    pub fn method_invoke_stret();
71    #[cfg(any(doc, all(target_vendor = "apple", not(target_arch = "aarch64"))))]
72    pub fn _objc_msgForward_stret();
73    #[cfg(any(doc, feature = "unstable-objfw", not(target_arch = "aarch64")))]
74    pub fn class_getMethodImplementation_stret();
75
76    // __x86_64__ and __i386__
77
78    #[cfg(any(doc, all(not(feature = "unstable-objfw"), any(target_arch = "x86_64", target_arch = "x86"))))]
79    pub fn objc_msgSend_fpret();
80    // objc_msgSend_fpret_debug
81
82    // __x86_64__
83
84    #[cfg(any(doc, all(target_vendor = "apple", target_arch = "x86_64")))]
85    pub fn objc_msgSend_fp2ret();
86    // objc_msgSend_fp2ret_debug
87}