objc_sys/
protocol.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::{objc_method_description, objc_property, objc_property_attribute_t, objc_selector};
7use crate::{OpaqueData, BOOL};
8
9/// Opaque type for Objective-C protocols.
10///
11/// Note that, although protocols are objects, sending messages to them is
12/// deprecated and may not work in the future.
13///
14/// The naming of this follows GNUStep; this struct does not exist in Apple's
15/// runtime, there `Protocol` is a type alias of `objc_object`.
16#[repr(C)]
17pub struct objc_protocol {
18    _priv: [u8; 0],
19    _p: OpaqueData,
20}
21
22extern_c! {
23    #[cfg(any(doc, not(feature = "unstable-objfw")))]
24    pub fn objc_getProtocol(name: *const c_char) -> *const objc_protocol;
25    #[cfg(any(doc, not(feature = "unstable-objfw")))]
26    /// The returned array is deallocated with [`free`][crate::free].
27    pub fn objc_copyProtocolList(out_len: *mut c_uint) -> *mut *const objc_protocol;
28
29    #[cfg(any(doc, not(feature = "unstable-objfw")))]
30    pub fn objc_allocateProtocol(name: *const c_char) -> *mut objc_protocol;
31    #[cfg(any(doc, not(feature = "unstable-objfw")))]
32    pub fn objc_registerProtocol(proto: *mut objc_protocol);
33
34    pub fn protocol_conformsToProtocol(
35        proto: *const objc_protocol,
36        other: *const objc_protocol,
37    ) -> BOOL;
38    pub fn protocol_isEqual(proto: *const objc_protocol, other: *const objc_protocol) -> BOOL;
39    pub fn protocol_getName(proto: *const objc_protocol) -> *const c_char;
40
41    #[cfg(any(doc, not(feature = "unstable-objfw")))]
42    pub fn protocol_addMethodDescription(
43        proto: *mut objc_protocol,
44        name: *const objc_selector,
45        types: *const c_char,
46        is_required_method: BOOL,
47        is_instance_method: BOOL,
48    );
49    #[cfg(any(doc, not(feature = "unstable-objfw")))]
50    pub fn protocol_addProperty(
51        proto: *mut objc_protocol,
52        name: *const c_char,
53        attributes: *const objc_property_attribute_t,
54        attributes_len: c_uint,
55        is_required_property: BOOL,
56        is_instance_property: BOOL,
57    );
58    #[cfg(any(doc, not(feature = "unstable-objfw")))]
59    pub fn protocol_addProtocol(proto: *mut objc_protocol, addition: *const objc_protocol);
60    #[cfg(any(doc, not(feature = "unstable-objfw")))]
61    /// The returned array is deallocated with [`free`][crate::free].
62    pub fn protocol_copyMethodDescriptionList(
63        proto: *const objc_protocol,
64        is_required_method: BOOL,
65        is_instance_method: BOOL,
66        out_len: *mut c_uint,
67    ) -> *mut objc_method_description;
68    #[cfg(any(doc, not(feature = "unstable-objfw")))]
69    /// The returned array is deallocated with [`free`][crate::free].
70    pub fn protocol_copyPropertyList(
71        proto: *const objc_protocol,
72        out_len: *mut c_uint,
73    ) -> *mut *const objc_property;
74    #[cfg(any(doc, not(feature = "unstable-objfw")))]
75    /// The returned array is deallocated with [`free`][crate::free].
76    pub fn protocol_copyProtocolList(
77        proto: *const objc_protocol,
78        out_len: *mut c_uint,
79    ) -> *mut *const objc_protocol;
80    #[cfg(any(doc, not(feature = "unstable-objfw")))]
81    pub fn protocol_getMethodDescription(
82        proto: *const objc_protocol,
83        sel: *const objc_selector,
84        is_required_method: BOOL,
85        is_instance_method: BOOL,
86    ) -> objc_method_description;
87    #[cfg(any(doc, not(feature = "unstable-objfw")))]
88    pub fn protocol_getProperty(
89        proto: *const objc_protocol,
90        name: *const c_char,
91        is_required_property: BOOL,
92        is_instance_property: BOOL,
93    ) -> *const objc_property;
94
95    // #[cfg(any(doc, macos >= 10.12))]
96    // protocol_copyPropertyList2
97
98    // #[cfg(any(doc, feature = "gnustep-1-7"))]
99    // _protocol_getMethodTypeEncoding
100}