objc_sys/
method.rs

1use std::os::raw::c_char;
2#[cfg(any(doc, not(feature = "unstable-objfw")))]
3use std::os::raw::c_uint;
4
5#[cfg(any(doc, not(feature = "unstable-objfw")))]
6use crate::IMP;
7use crate::{objc_selector, OpaqueData};
8
9/// A type that represents a method in a class definition.
10#[repr(C)]
11pub struct objc_method {
12    _priv: [u8; 0],
13    _p: OpaqueData,
14}
15
16/// Describes an Objective-C method.
17#[repr(C)]
18#[derive(Debug, Copy, Clone)]
19pub struct objc_method_description {
20    /// The name of the method.
21    pub name: *const objc_selector,
22    /// The types of the method arguments.
23    pub types: *const c_char,
24}
25
26extern_c! {
27    #[cfg(any(doc, not(feature = "unstable-objfw")))]
28    /// The return value is deallocated with [`free`][crate::free].
29    pub fn method_copyArgumentType(method: *const objc_method, index: c_uint) -> *mut c_char;
30    #[cfg(any(doc, not(feature = "unstable-objfw")))]
31    /// The return value is deallocated with [`free`][crate::free].
32    pub fn method_copyReturnType(method: *const objc_method) -> *mut c_char;
33    #[cfg(any(doc, not(feature = "unstable-objfw")))]
34    pub fn method_exchangeImplementations(method1: *mut objc_method, method2: *mut objc_method);
35    #[cfg(any(doc, not(feature = "unstable-objfw")))]
36    pub fn method_getArgumentType(
37        method: *const objc_method,
38        index: c_uint,
39        dst: *mut c_char,
40        dst_len: usize,
41    );
42    #[cfg(any(doc, target_vendor = "apple"))]
43    pub fn method_getDescription(m: *const objc_method) -> *const objc_method_description;
44    #[cfg(any(doc, not(feature = "unstable-objfw")))]
45    pub fn method_getImplementation(method: *const objc_method) -> IMP;
46    #[cfg(any(doc, not(feature = "unstable-objfw")))]
47    pub fn method_getName(method: *const objc_method) -> *const objc_selector;
48    #[cfg(any(doc, not(feature = "unstable-objfw")))]
49    pub fn method_getNumberOfArguments(method: *const objc_method) -> c_uint;
50    #[cfg(any(doc, not(feature = "unstable-objfw")))]
51    pub fn method_getReturnType(method: *const objc_method, dst: *mut c_char, dst_len: usize);
52    #[cfg(any(doc, not(feature = "unstable-objfw")))]
53    pub fn method_getTypeEncoding(method: *const objc_method) -> *const c_char;
54    #[cfg(any(doc, not(feature = "unstable-objfw")))]
55    pub fn method_setImplementation(method: *const objc_method, imp: IMP) -> IMP;
56}