CoreFoundation_sys/
base.rs

1// Exports from <CoreFoundation/CFBase.h>
2
3use libc::{c_void,c_uchar,c_long,c_ulong};
4
5pub type Boolean = c_uchar;
6
7pub type UInt8 = u8;
8pub type SInt8 = i8;
9pub type UInt16 = u16;
10pub type SInt16 = i16;
11pub type UInt32 = u32;
12pub type SInt32 = i32;
13
14pub type UnicodeScalarValue = UInt32;
15pub type UTF32Char          = UInt32;
16pub type UniChar            = UInt16;
17pub type UTF16Char          = UInt16;
18pub type UTF8Char           = UInt8;
19pub type UniCharPtr         = *mut UniChar;
20pub type UniCharCount       = c_ulong;
21pub type UniCharCountPtr    = *mut UniCharCount;
22pub type Str255             = [c_uchar; 256];
23pub type Str63              = [c_uchar; 64];
24pub type Str32              = [c_uchar; 33];
25pub type Str31              = [c_uchar; 32];
26pub type Str27              = [c_uchar; 28];
27pub type Str15              = [c_uchar; 16];
28
29pub type CFTypeID = c_ulong;
30pub type CFOptionFlags = c_ulong;
31pub type CFHashCode = c_ulong;
32pub type CFIndex = c_long;
33
34pub type CFTypeRef = *const c_void;
35
36#[doc(hidden)]
37#[repr(C)]
38pub struct __CFString {
39    __private: c_void,
40}
41
42pub type CFStringRef = *const __CFString;
43pub type CFMutableStringRef = *mut __CFString;
44
45pub type CFComparisonResult = CFIndex;
46pub const kCFCompareLessThan:    CFComparisonResult = -1;
47pub const kCFCompareEqualTo:     CFComparisonResult = 0;
48pub const kCFCompareGreaterThan: CFComparisonResult = 1;
49
50pub type CFComparatorFunction = extern "C" fn(val1: *const c_void, val2: *const c_void) -> CFComparisonResult;
51
52pub const kCFNotFound: CFIndex = -1;
53
54#[repr(C)]
55pub struct CFRange {
56    pub location: CFIndex,
57    pub length: CFIndex
58}
59
60#[doc(hidden)]
61#[repr(C)]
62pub struct __CFAllocator {
63    __private: c_void,
64}
65
66pub type CFAllocatorRef = *const __CFAllocator;
67
68pub type CFAllocatorRetainCallBack = extern "C" fn(info: *const c_void) -> *const c_void;
69pub type CFAllocatorReleaseCallBack = extern "C" fn(info: *const c_void);
70pub type CFAllocatorCopyDescriptionCallBack = extern "C" fn(info: *const c_void) -> CFTypeRef;
71pub type CFAllocatorAllocateCallBack = extern "C" fn(allocSize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void;
72pub type CFAllocatorReallocateCallBack = extern "C" fn(ptr: *mut c_void, newSize: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> *mut c_void;
73pub type CFAllocatorDeallocateCallBack = extern "C" fn(ptr: *mut c_void, info: *mut c_void);
74pub type CFAllocatorPreferredSizeCallBack = extern "C" fn(size: CFIndex, hint: CFOptionFlags, info: *mut c_void) -> CFIndex;
75
76#[repr(C)]
77pub struct CFAllocatorContext {
78    pub version: CFIndex,
79    pub info: *mut c_void,
80    pub retain: CFAllocatorRetainCallBack,
81    pub release: CFAllocatorReleaseCallBack,
82    pub copyDescription: CFAllocatorCopyDescriptionCallBack,
83    pub allocate: CFAllocatorAllocateCallBack,
84    pub reallocate: CFAllocatorReallocateCallBack,
85    pub deallocate: CFAllocatorDeallocateCallBack,
86    pub preferredSize: CFAllocatorPreferredSizeCallBack
87}
88
89extern "C" {
90    pub static kCFAllocatorDefault: CFAllocatorRef;
91    pub static kCFAllocatorSystemDefault: CFAllocatorRef;
92    pub static kCFAllocatorMalloc: CFAllocatorRef;
93    pub static kCFAllocatorMallocZone: CFAllocatorRef;
94    pub static kCFAllocatorNull: CFAllocatorRef;
95    pub static kCFAllocatorUseContext: CFAllocatorRef;
96
97    pub fn CFAllocatorGetTypeID() -> CFTypeID;
98
99    pub fn CFAllocatorSetDefault(allocator: CFAllocatorRef);
100    pub fn CFAllocatorGetDefault() -> CFAllocatorRef;
101
102    pub fn CFAllocatorCreate(allocator: CFAllocatorRef, context: *mut CFAllocatorContext) -> CFAllocatorRef;
103    pub fn CFAllocatorAllocate(allocator: CFAllocatorRef, size: CFIndex, hint: CFOptionFlags) -> *mut c_void;
104    pub fn CFAllocatorReallocate(allocator: CFAllocatorRef, ptr: *mut c_void, newSize: CFIndex, hint: CFOptionFlags) -> *mut c_void;
105    pub fn CFAllocatorDeallocate(allocator: CFAllocatorRef, ptr: *mut c_void);
106    pub fn CFAllocatorGetPreferredSizeForSize(allocator: CFAllocatorRef, size: CFIndex, hint: CFOptionFlags) -> CFIndex;
107    pub fn CFAllocatorGetContext(allocator: CFAllocatorRef, context: *mut CFAllocatorContext);
108
109    pub fn CFGetTypeID(cf: CFTypeRef) -> CFTypeID;
110    pub fn CFCopyTypeIDDescription(cf: CFTypeID) -> CFStringRef;
111
112    pub fn CFRetain(cf: CFTypeRef) -> CFTypeRef;
113    pub fn CFRelease(cf: CFTypeRef);
114    pub fn CFAutorelease(arg: CFTypeRef) -> CFTypeRef;
115    pub fn CFGetRetainCount(cf: CFTypeRef) -> CFIndex;
116
117    pub fn CFEqual(cf1: CFTypeRef, cf2: CFTypeRef) -> Boolean;
118    pub fn CFHash(cf: CFTypeRef) -> CFHashCode;
119
120    pub fn CFCopyDescription(cf: CFTypeRef) -> CFStringRef;
121
122    pub fn CFGetAllocator(cf: CFTypeRef) -> CFAllocatorRef;
123    pub fn CFMakeCollectable(cf: CFTypeRef) -> CFTypeRef;
124}