objc2_foundation/generated/
NSPointerFunctions.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6
7use crate::*;
8
9/// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspointerfunctionsoptions?language=objc)
10// NS_OPTIONS
11#[repr(transparent)]
12#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct NSPointerFunctionsOptions(pub NSUInteger);
14bitflags::bitflags! {
15    impl NSPointerFunctionsOptions: NSUInteger {
16        #[doc(alias = "NSPointerFunctionsStrongMemory")]
17        const StrongMemory = 0<<0;
18        #[doc(alias = "NSPointerFunctionsZeroingWeakMemory")]
19#[deprecated = "GC no longer supported"]
20        const ZeroingWeakMemory = 1<<0;
21        #[doc(alias = "NSPointerFunctionsOpaqueMemory")]
22        const OpaqueMemory = 2<<0;
23        #[doc(alias = "NSPointerFunctionsMallocMemory")]
24        const MallocMemory = 3<<0;
25        #[doc(alias = "NSPointerFunctionsMachVirtualMemory")]
26        const MachVirtualMemory = 4<<0;
27        #[doc(alias = "NSPointerFunctionsWeakMemory")]
28        const WeakMemory = 5<<0;
29        #[doc(alias = "NSPointerFunctionsObjectPersonality")]
30        const ObjectPersonality = 0<<8;
31        #[doc(alias = "NSPointerFunctionsOpaquePersonality")]
32        const OpaquePersonality = 1<<8;
33        #[doc(alias = "NSPointerFunctionsObjectPointerPersonality")]
34        const ObjectPointerPersonality = 2<<8;
35        #[doc(alias = "NSPointerFunctionsCStringPersonality")]
36        const CStringPersonality = 3<<8;
37        #[doc(alias = "NSPointerFunctionsStructPersonality")]
38        const StructPersonality = 4<<8;
39        #[doc(alias = "NSPointerFunctionsIntegerPersonality")]
40        const IntegerPersonality = 5<<8;
41        #[doc(alias = "NSPointerFunctionsCopyIn")]
42        const CopyIn = 1<<16;
43    }
44}
45
46unsafe impl Encode for NSPointerFunctionsOptions {
47    const ENCODING: Encoding = NSUInteger::ENCODING;
48}
49
50unsafe impl RefEncode for NSPointerFunctionsOptions {
51    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
52}
53
54extern_class!(
55    /// [Apple's documentation](https://developer.apple.com/documentation/foundation/nspointerfunctions?language=objc)
56    #[unsafe(super(NSObject))]
57    #[derive(Debug, PartialEq, Eq, Hash)]
58    pub struct NSPointerFunctions;
59);
60
61#[cfg(feature = "NSObject")]
62extern_conformance!(
63    unsafe impl NSCopying for NSPointerFunctions {}
64);
65
66#[cfg(feature = "NSObject")]
67unsafe impl CopyingHelper for NSPointerFunctions {
68    type Result = Self;
69}
70
71extern_conformance!(
72    unsafe impl NSObjectProtocol for NSPointerFunctions {}
73);
74
75impl NSPointerFunctions {
76    extern_methods!(
77        #[unsafe(method(initWithOptions:))]
78        #[unsafe(method_family = init)]
79        pub fn initWithOptions(
80            this: Allocated<Self>,
81            options: NSPointerFunctionsOptions,
82        ) -> Retained<Self>;
83
84        #[unsafe(method(pointerFunctionsWithOptions:))]
85        #[unsafe(method_family = none)]
86        pub fn pointerFunctionsWithOptions(
87            options: NSPointerFunctionsOptions,
88        ) -> Retained<NSPointerFunctions>;
89
90        #[unsafe(method(hashFunction))]
91        #[unsafe(method_family = none)]
92        pub fn hashFunction(
93            &self,
94        ) -> Option<
95            unsafe extern "C-unwind" fn(
96                NonNull<c_void>,
97                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
98            ) -> NSUInteger,
99        >;
100
101        /// Setter for [`hashFunction`][Self::hashFunction].
102        ///
103        /// # Safety
104        ///
105        /// `hash_function` must be implemented correctly.
106        #[unsafe(method(setHashFunction:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setHashFunction(
109            &self,
110            hash_function: Option<
111                unsafe extern "C-unwind" fn(
112                    NonNull<c_void>,
113                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
114                ) -> NSUInteger,
115            >,
116        );
117
118        #[unsafe(method(isEqualFunction))]
119        #[unsafe(method_family = none)]
120        pub fn isEqualFunction(
121            &self,
122        ) -> Option<
123            unsafe extern "C-unwind" fn(
124                NonNull<c_void>,
125                NonNull<c_void>,
126                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
127            ) -> Bool,
128        >;
129
130        /// Setter for [`isEqualFunction`][Self::isEqualFunction].
131        ///
132        /// # Safety
133        ///
134        /// `is_equal_function` must be implemented correctly.
135        #[unsafe(method(setIsEqualFunction:))]
136        #[unsafe(method_family = none)]
137        pub unsafe fn setIsEqualFunction(
138            &self,
139            is_equal_function: Option<
140                unsafe extern "C-unwind" fn(
141                    NonNull<c_void>,
142                    NonNull<c_void>,
143                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
144                ) -> Bool,
145            >,
146        );
147
148        #[unsafe(method(sizeFunction))]
149        #[unsafe(method_family = none)]
150        pub fn sizeFunction(
151            &self,
152        ) -> Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>;
153
154        /// Setter for [`sizeFunction`][Self::sizeFunction].
155        ///
156        /// # Safety
157        ///
158        /// `size_function` must be implemented correctly.
159        #[unsafe(method(setSizeFunction:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn setSizeFunction(
162            &self,
163            size_function: Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
164        );
165
166        #[cfg(feature = "NSString")]
167        #[unsafe(method(descriptionFunction))]
168        #[unsafe(method_family = none)]
169        pub fn descriptionFunction(
170            &self,
171        ) -> Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> *mut NSString>;
172
173        #[cfg(feature = "NSString")]
174        /// Setter for [`descriptionFunction`][Self::descriptionFunction].
175        ///
176        /// # Safety
177        ///
178        /// `description_function` must be implemented correctly.
179        #[unsafe(method(setDescriptionFunction:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setDescriptionFunction(
182            &self,
183            description_function: Option<
184                unsafe extern "C-unwind" fn(NonNull<c_void>) -> *mut NSString,
185            >,
186        );
187
188        #[unsafe(method(relinquishFunction))]
189        #[unsafe(method_family = none)]
190        pub fn relinquishFunction(
191            &self,
192        ) -> Option<
193            unsafe extern "C-unwind" fn(
194                NonNull<c_void>,
195                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
196            ),
197        >;
198
199        /// Setter for [`relinquishFunction`][Self::relinquishFunction].
200        ///
201        /// # Safety
202        ///
203        /// `relinquish_function` must be implemented correctly.
204        #[unsafe(method(setRelinquishFunction:))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn setRelinquishFunction(
207            &self,
208            relinquish_function: Option<
209                unsafe extern "C-unwind" fn(
210                    NonNull<c_void>,
211                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
212                ),
213            >,
214        );
215
216        #[unsafe(method(acquireFunction))]
217        #[unsafe(method_family = none)]
218        pub fn acquireFunction(
219            &self,
220        ) -> Option<
221            unsafe extern "C-unwind" fn(
222                NonNull<c_void>,
223                Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
224                Bool,
225            ) -> NonNull<c_void>,
226        >;
227
228        /// Setter for [`acquireFunction`][Self::acquireFunction].
229        ///
230        /// # Safety
231        ///
232        /// `acquire_function` must be implemented correctly.
233        #[unsafe(method(setAcquireFunction:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setAcquireFunction(
236            &self,
237            acquire_function: Option<
238                unsafe extern "C-unwind" fn(
239                    NonNull<c_void>,
240                    Option<unsafe extern "C-unwind" fn(NonNull<c_void>) -> NSUInteger>,
241                    Bool,
242                ) -> NonNull<c_void>,
243            >,
244        );
245
246        #[deprecated = "Garbage collection no longer supported"]
247        #[unsafe(method(usesStrongWriteBarrier))]
248        #[unsafe(method_family = none)]
249        pub fn usesStrongWriteBarrier(&self) -> bool;
250
251        /// Setter for [`usesStrongWriteBarrier`][Self::usesStrongWriteBarrier].
252        #[deprecated = "Garbage collection no longer supported"]
253        #[unsafe(method(setUsesStrongWriteBarrier:))]
254        #[unsafe(method_family = none)]
255        pub fn setUsesStrongWriteBarrier(&self, uses_strong_write_barrier: bool);
256
257        #[deprecated = "Garbage collection no longer supported"]
258        #[unsafe(method(usesWeakReadAndWriteBarriers))]
259        #[unsafe(method_family = none)]
260        pub fn usesWeakReadAndWriteBarriers(&self) -> bool;
261
262        /// Setter for [`usesWeakReadAndWriteBarriers`][Self::usesWeakReadAndWriteBarriers].
263        #[deprecated = "Garbage collection no longer supported"]
264        #[unsafe(method(setUsesWeakReadAndWriteBarriers:))]
265        #[unsafe(method_family = none)]
266        pub fn setUsesWeakReadAndWriteBarriers(&self, uses_weak_read_and_write_barriers: bool);
267    );
268}
269
270/// Methods declared on superclass `NSObject`.
271impl NSPointerFunctions {
272    extern_methods!(
273        #[unsafe(method(init))]
274        #[unsafe(method_family = init)]
275        pub fn init(this: Allocated<Self>) -> Retained<Self>;
276
277        #[unsafe(method(new))]
278        #[unsafe(method_family = new)]
279        pub fn new() -> Retained<Self>;
280    );
281}
282
283impl DefaultRetained for NSPointerFunctions {
284    #[inline]
285    fn default_retained() -> Retained<Self> {
286        Self::new()
287    }
288}