objc2_core_foundation/generated/
CFNumber.rs1use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9
10use crate::*;
11
12#[doc(alias = "CFBooleanRef")]
16#[repr(C)]
17pub struct CFBoolean {
18 inner: [u8; 0],
19 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
20}
21
22cf_type!(
23 unsafe impl CFBoolean {}
24);
25#[cfg(feature = "objc2")]
26cf_objc2_type!(
27 unsafe impl RefEncode<"__CFBoolean"> for CFBoolean {}
28);
29
30extern "C" {
31 pub static kCFBooleanTrue: Option<&'static CFBoolean>;
33}
34
35extern "C" {
36 pub static kCFBooleanFalse: Option<&'static CFBoolean>;
38}
39
40unsafe impl ConcreteType for CFBoolean {
41 #[doc(alias = "CFBooleanGetTypeID")]
42 #[inline]
43 fn type_id() -> CFTypeID {
44 extern "C-unwind" {
45 fn CFBooleanGetTypeID() -> CFTypeID;
46 }
47 unsafe { CFBooleanGetTypeID() }
48 }
49}
50
51impl CFBoolean {
52 #[doc(alias = "CFBooleanGetValue")]
53 #[inline]
54 pub fn value(&self) -> bool {
55 extern "C-unwind" {
56 fn CFBooleanGetValue(boolean: &CFBoolean) -> Boolean;
57 }
58 let ret = unsafe { CFBooleanGetValue(self) };
59 ret != 0
60 }
61}
62
63#[repr(transparent)]
66#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
67pub struct CFNumberType(pub CFIndex);
68impl CFNumberType {
69 #[doc(alias = "kCFNumberSInt8Type")]
70 pub const SInt8Type: Self = Self(1);
71 #[doc(alias = "kCFNumberSInt16Type")]
72 pub const SInt16Type: Self = Self(2);
73 #[doc(alias = "kCFNumberSInt32Type")]
74 pub const SInt32Type: Self = Self(3);
75 #[doc(alias = "kCFNumberSInt64Type")]
76 pub const SInt64Type: Self = Self(4);
77 #[doc(alias = "kCFNumberFloat32Type")]
78 pub const Float32Type: Self = Self(5);
79 #[doc(alias = "kCFNumberFloat64Type")]
80 pub const Float64Type: Self = Self(6);
81 #[doc(alias = "kCFNumberCharType")]
82 pub const CharType: Self = Self(7);
83 #[doc(alias = "kCFNumberShortType")]
84 pub const ShortType: Self = Self(8);
85 #[doc(alias = "kCFNumberIntType")]
86 pub const IntType: Self = Self(9);
87 #[doc(alias = "kCFNumberLongType")]
88 pub const LongType: Self = Self(10);
89 #[doc(alias = "kCFNumberLongLongType")]
90 pub const LongLongType: Self = Self(11);
91 #[doc(alias = "kCFNumberFloatType")]
92 pub const FloatType: Self = Self(12);
93 #[doc(alias = "kCFNumberDoubleType")]
94 pub const DoubleType: Self = Self(13);
95 #[doc(alias = "kCFNumberCFIndexType")]
96 pub const CFIndexType: Self = Self(14);
97 #[doc(alias = "kCFNumberNSIntegerType")]
98 pub const NSIntegerType: Self = Self(15);
99 #[doc(alias = "kCFNumberCGFloatType")]
100 pub const CGFloatType: Self = Self(16);
101 #[doc(alias = "kCFNumberMaxType")]
102 pub const MaxType: Self = Self(16);
103}
104
105#[cfg(feature = "objc2")]
106unsafe impl Encode for CFNumberType {
107 const ENCODING: Encoding = CFIndex::ENCODING;
108}
109
110#[cfg(feature = "objc2")]
111unsafe impl RefEncode for CFNumberType {
112 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
113}
114
115#[doc(alias = "CFNumberRef")]
119#[repr(C)]
120pub struct CFNumber {
121 inner: [u8; 0],
122 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
123}
124
125cf_type!(
126 unsafe impl CFNumber {}
127);
128#[cfg(feature = "objc2")]
129cf_objc2_type!(
130 unsafe impl RefEncode<"__CFNumber"> for CFNumber {}
131);
132
133extern "C" {
134 pub static kCFNumberPositiveInfinity: Option<&'static CFNumber>;
136}
137
138extern "C" {
139 pub static kCFNumberNegativeInfinity: Option<&'static CFNumber>;
141}
142
143extern "C" {
144 pub static kCFNumberNaN: Option<&'static CFNumber>;
146}
147
148unsafe impl ConcreteType for CFNumber {
149 #[doc(alias = "CFNumberGetTypeID")]
150 #[inline]
151 fn type_id() -> CFTypeID {
152 extern "C-unwind" {
153 fn CFNumberGetTypeID() -> CFTypeID;
154 }
155 unsafe { CFNumberGetTypeID() }
156 }
157}
158
159impl CFNumber {
160 #[doc(alias = "CFNumberCreate")]
165 #[inline]
166 pub unsafe fn new(
167 allocator: Option<&CFAllocator>,
168 the_type: CFNumberType,
169 value_ptr: *const c_void,
170 ) -> Option<CFRetained<CFNumber>> {
171 extern "C-unwind" {
172 fn CFNumberCreate(
173 allocator: Option<&CFAllocator>,
174 the_type: CFNumberType,
175 value_ptr: *const c_void,
176 ) -> Option<NonNull<CFNumber>>;
177 }
178 let ret = unsafe { CFNumberCreate(allocator, the_type, value_ptr) };
179 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
180 }
181
182 #[doc(alias = "CFNumberGetType")]
183 #[inline]
184 pub fn r#type(&self) -> CFNumberType {
185 extern "C-unwind" {
186 fn CFNumberGetType(number: &CFNumber) -> CFNumberType;
187 }
188 unsafe { CFNumberGetType(self) }
189 }
190
191 #[doc(alias = "CFNumberGetByteSize")]
192 #[inline]
193 pub fn byte_size(&self) -> CFIndex {
194 extern "C-unwind" {
195 fn CFNumberGetByteSize(number: &CFNumber) -> CFIndex;
196 }
197 unsafe { CFNumberGetByteSize(self) }
198 }
199
200 #[doc(alias = "CFNumberIsFloatType")]
201 #[inline]
202 pub fn is_float_type(&self) -> bool {
203 extern "C-unwind" {
204 fn CFNumberIsFloatType(number: &CFNumber) -> Boolean;
205 }
206 let ret = unsafe { CFNumberIsFloatType(self) };
207 ret != 0
208 }
209
210 #[doc(alias = "CFNumberGetValue")]
214 #[inline]
215 pub unsafe fn value(&self, the_type: CFNumberType, value_ptr: *mut c_void) -> bool {
216 extern "C-unwind" {
217 fn CFNumberGetValue(
218 number: &CFNumber,
219 the_type: CFNumberType,
220 value_ptr: *mut c_void,
221 ) -> Boolean;
222 }
223 let ret = unsafe { CFNumberGetValue(self, the_type, value_ptr) };
224 ret != 0
225 }
226
227 #[doc(alias = "CFNumberCompare")]
232 #[inline]
233 pub unsafe fn compare(
234 &self,
235 other_number: Option<&CFNumber>,
236 context: *mut c_void,
237 ) -> CFComparisonResult {
238 extern "C-unwind" {
239 fn CFNumberCompare(
240 number: &CFNumber,
241 other_number: Option<&CFNumber>,
242 context: *mut c_void,
243 ) -> CFComparisonResult;
244 }
245 unsafe { CFNumberCompare(self, other_number, context) }
246 }
247}
248
249#[deprecated = "renamed to `CFBoolean::value`"]
250#[inline]
251pub extern "C-unwind" fn CFBooleanGetValue(boolean: &CFBoolean) -> bool {
252 extern "C-unwind" {
253 fn CFBooleanGetValue(boolean: &CFBoolean) -> Boolean;
254 }
255 let ret = unsafe { CFBooleanGetValue(boolean) };
256 ret != 0
257}
258
259#[deprecated = "renamed to `CFNumber::new`"]
260#[inline]
261pub unsafe extern "C-unwind" fn CFNumberCreate(
262 allocator: Option<&CFAllocator>,
263 the_type: CFNumberType,
264 value_ptr: *const c_void,
265) -> Option<CFRetained<CFNumber>> {
266 extern "C-unwind" {
267 fn CFNumberCreate(
268 allocator: Option<&CFAllocator>,
269 the_type: CFNumberType,
270 value_ptr: *const c_void,
271 ) -> Option<NonNull<CFNumber>>;
272 }
273 let ret = unsafe { CFNumberCreate(allocator, the_type, value_ptr) };
274 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
275}
276
277#[deprecated = "renamed to `CFNumber::type`"]
278#[inline]
279pub extern "C-unwind" fn CFNumberGetType(number: &CFNumber) -> CFNumberType {
280 extern "C-unwind" {
281 fn CFNumberGetType(number: &CFNumber) -> CFNumberType;
282 }
283 unsafe { CFNumberGetType(number) }
284}
285
286#[deprecated = "renamed to `CFNumber::byte_size`"]
287#[inline]
288pub extern "C-unwind" fn CFNumberGetByteSize(number: &CFNumber) -> CFIndex {
289 extern "C-unwind" {
290 fn CFNumberGetByteSize(number: &CFNumber) -> CFIndex;
291 }
292 unsafe { CFNumberGetByteSize(number) }
293}
294
295#[deprecated = "renamed to `CFNumber::is_float_type`"]
296#[inline]
297pub extern "C-unwind" fn CFNumberIsFloatType(number: &CFNumber) -> bool {
298 extern "C-unwind" {
299 fn CFNumberIsFloatType(number: &CFNumber) -> Boolean;
300 }
301 let ret = unsafe { CFNumberIsFloatType(number) };
302 ret != 0
303}
304
305#[deprecated = "renamed to `CFNumber::value`"]
306#[inline]
307pub unsafe extern "C-unwind" fn CFNumberGetValue(
308 number: &CFNumber,
309 the_type: CFNumberType,
310 value_ptr: *mut c_void,
311) -> bool {
312 extern "C-unwind" {
313 fn CFNumberGetValue(
314 number: &CFNumber,
315 the_type: CFNumberType,
316 value_ptr: *mut c_void,
317 ) -> Boolean;
318 }
319 let ret = unsafe { CFNumberGetValue(number, the_type, value_ptr) };
320 ret != 0
321}
322
323extern "C-unwind" {
324 #[deprecated = "renamed to `CFNumber::compare`"]
325 pub fn CFNumberCompare(
326 number: &CFNumber,
327 other_number: Option<&CFNumber>,
328 context: *mut c_void,
329 ) -> CFComparisonResult;
330}