objc2/ffi/
method.rs

1use core::ffi::c_char;
2#[cfg(any(doc, not(feature = "unstable-objfw")))]
3use core::ffi::c_uint;
4
5use crate::runtime::{Imp, Method, Sel};
6
7/// Describes an Objective-C method.
8#[repr(C)]
9#[derive(Debug, Copy, Clone)]
10pub struct objc_method_description {
11    /// The name of the method.
12    pub name: Option<Sel>,
13    /// The types of the method arguments.
14    pub types: *const c_char,
15}
16
17extern_c! {
18    #[cfg(any(doc, not(feature = "unstable-objfw")))]
19    /// The return value is deallocated with [`free`][crate::ffi::free].
20    pub fn method_copyArgumentType(method: *const Method, index: c_uint) -> *mut c_char;
21    #[cfg(any(doc, not(feature = "unstable-objfw")))]
22    /// The return value is deallocated with [`free`][crate::ffi::free].
23    pub fn method_copyReturnType(method: *const Method) -> *mut c_char;
24    #[cfg(any(doc, not(feature = "unstable-objfw")))]
25    pub fn method_exchangeImplementations(method1: *mut Method, method2: *mut Method);
26    #[cfg(any(doc, not(feature = "unstable-objfw")))]
27    pub fn method_getArgumentType(
28        method: *const Method,
29        index: c_uint,
30        dst: *mut c_char,
31        dst_len: usize,
32    );
33    #[cfg(any(doc, target_vendor = "apple"))]
34    pub fn method_getDescription(m: *const Method) -> *const objc_method_description;
35    #[cfg(any(doc, not(feature = "unstable-objfw")))]
36    pub fn method_getImplementation(method: *const Method) -> Option<Imp>;
37    #[cfg(any(doc, not(feature = "unstable-objfw")))]
38    pub fn method_getName(method: *const Method) -> Option<Sel>;
39    #[cfg(any(doc, not(feature = "unstable-objfw")))]
40    pub fn method_getNumberOfArguments(method: *const Method) -> c_uint;
41    #[cfg(any(doc, not(feature = "unstable-objfw")))]
42    pub fn method_getReturnType(method: *const Method, dst: *mut c_char, dst_len: usize);
43    #[cfg(any(doc, not(feature = "unstable-objfw")))]
44    pub fn method_getTypeEncoding(method: *const Method) -> *const c_char;
45    #[cfg(any(doc, not(feature = "unstable-objfw")))]
46    pub fn method_setImplementation(method: *const Method, imp: Imp) -> Option<Imp>;
47}