core_foundation_sys/
number.rs1use std::os::raw::c_void;
11
12use crate::base::{Boolean, CFAllocatorRef, CFComparisonResult, CFIndex, CFTypeID};
13
14#[repr(C)]
15pub struct __CFBoolean(c_void);
16
17pub type CFBooleanRef = *const __CFBoolean;
18
19pub type CFNumberType = u32;
20
21pub const kCFNumberSInt8Type: CFNumberType = 1;
23pub const kCFNumberSInt16Type: CFNumberType = 2;
24pub const kCFNumberSInt32Type: CFNumberType = 3;
25pub const kCFNumberSInt64Type: CFNumberType = 4;
26pub const kCFNumberFloat32Type: CFNumberType = 5;
27pub const kCFNumberFloat64Type: CFNumberType = 6;
28pub const kCFNumberCharType: CFNumberType = 7;
29pub const kCFNumberShortType: CFNumberType = 8;
30pub const kCFNumberIntType: CFNumberType = 9;
31pub const kCFNumberLongType: CFNumberType = 10;
32pub const kCFNumberLongLongType: CFNumberType = 11;
33pub const kCFNumberFloatType: CFNumberType = 12;
34pub const kCFNumberDoubleType: CFNumberType = 13;
35pub const kCFNumberCFIndexType: CFNumberType = 14;
36pub const kCFNumberNSIntegerType: CFNumberType = 15;
37pub const kCFNumberCGFloatType: CFNumberType = 16;
38pub const kCFNumberMaxType: CFNumberType = 16;
39
40pub enum __CFNumber {}
43
44pub type CFNumberRef = *const __CFNumber;
45
46extern "C" {
47 pub static kCFBooleanTrue: CFBooleanRef;
51 pub static kCFBooleanFalse: CFBooleanRef;
52 pub static kCFNumberPositiveInfinity: CFNumberRef;
53 pub static kCFNumberNegativeInfinity: CFNumberRef;
54 pub static kCFNumberNaN: CFNumberRef;
55
56 pub fn CFNumberCreate(
58 allocator: CFAllocatorRef,
59 theType: CFNumberType,
60 valuePtr: *const c_void,
61 ) -> CFNumberRef;
62
63 pub fn CFNumberGetByteSize(number: CFNumberRef) -> CFIndex;
65 pub fn CFNumberGetType(number: CFNumberRef) -> CFNumberType;
66 pub fn CFNumberGetValue(
67 number: CFNumberRef,
68 theType: CFNumberType,
69 valuePtr: *mut c_void,
70 ) -> bool;
71 pub fn CFNumberIsFloatType(number: CFNumberRef) -> Boolean;
72
73 pub fn CFNumberCompare(
75 date: CFNumberRef,
76 other: CFNumberRef,
77 context: *mut c_void,
78 ) -> CFComparisonResult;
79
80 pub fn CFNumberGetTypeID() -> CFTypeID;
82
83 pub fn CFBooleanGetValue(boolean: CFBooleanRef) -> bool;
84 pub fn CFBooleanGetTypeID() -> CFTypeID;
85}
86
87#[cfg(test)]
88mod test {
89 use super::*;
90
91 #[test]
92 fn match_for_type_id_should_be_backwards_compatible() {
93 let type_id = kCFNumberFloat32Type;
94 match type_id {
96 vf64 if vf64 == kCFNumberFloat32Type => assert!(true),
97 _ => panic!("should not happen"),
98 };
99
100 match type_id {
102 kCFNumberFloat32Type => assert!(true),
103 _ => panic!("should not happen"),
104 };
105 }
106}