1 module eventcore.internal.corefoundation;
2 
3 version (darwin):
4 
5 nothrow extern(C):
6 
7 static if (!is(CFTypeRef)) {
8 	alias CFTypeRef = const(void)*;
9 	alias CFTypeRef CFAllocatorRef;
10 	extern const CFAllocatorRef kCFAllocatorDefault;
11 
12 	CFTypeRef CFRetain(CFTypeRef cf) @nogc;
13 	void CFRelease(CFTypeRef cf) @nogc;
14 
15 	struct __CFString;
16 	alias CFStringRef = const(__CFString)*;
17 
18 	alias Boolean = ubyte;
19 	alias UniChar = ushort;
20 	alias CFTypeID = size_t;
21 	alias CFIndex = sizediff_t;
22 
23 	alias CFAllocatorRetainCallBack = const(void)* function(const void *info);
24 	alias CFAllocatorReleaseCallBack = void function(const void *info);
25 	alias CFAllocatorCopyDescriptionCallBack = CFStringRef function(const void *info);
26 }
27 
28 static if (!is(CFArrayRef)) {
29 	struct __CFArray;
30 	alias CFArrayRef = const(__CFArray)*;
31 
32 	alias CFArrayRetainCallBack = const(void)* function(CFAllocatorRef allocator, const(void)* value);
33 	alias CFArrayReleaseCallBack = void function(CFAllocatorRef allocator, const(void)* value);
34 	alias CFArrayCopyDescriptionCallBack = CFStringRef function(const(void)* value);
35 	alias CFArrayEqualCallBack = Boolean function(const(void)* value1, const(void)* value2);
36 
37 	struct CFArrayCallBacks {
38 		CFIndex version_;
39 		CFArrayRetainCallBack retain;
40 		CFArrayReleaseCallBack release;
41 		CFArrayCopyDescriptionCallBack copyDescription;
42 		CFArrayEqualCallBack equal;
43 	}
44 
45 	CFArrayRef CFArrayCreate(CFAllocatorRef allocator, const(void)** values, CFIndex numValues, const(CFArrayCallBacks)* callBacks);
46 }
47 
48 static if (!is(CFStringEncoding)) {
49 	alias CFStringEncoding = uint;
50 
51 	enum kCFStringEncodingInvalidId = 0xffffffffU;
52 	enum {
53 	    kCFStringEncodingMacRoman = 0,
54 	    kCFStringEncodingWindowsLatin1 = 0x0500,
55 	    kCFStringEncodingISOLatin1 = 0x0201,
56 	    kCFStringEncodingNextStepLatin = 0x0B01,
57 	    kCFStringEncodingASCII = 0x0600,
58 	    kCFStringEncodingUnicode = 0x0100,
59 	    kCFStringEncodingUTF8 = 0x08000100,
60 	    kCFStringEncodingNonLossyASCII = 0x0BFF,
61 
62 	    kCFStringEncodingUTF16 = 0x0100,
63 	    kCFStringEncodingUTF16BE = 0x10000100,
64 	    kCFStringEncodingUTF16LE = 0x14000100,
65 
66 	    kCFStringEncodingUTF32 = 0x0c000100,
67 	    kCFStringEncodingUTF32BE = 0x18000100,
68 	    kCFStringEncodingUTF32LE = 0x1c000100
69 	}
70 
71 	CFStringRef CFStringCreateWithCString(CFAllocatorRef alloc, const(char)* cStr, CFStringEncoding encoding);
72 	CFStringRef CFStringCreateWithBytes(CFAllocatorRef alloc, const(ubyte)* bytes, CFIndex numBytes, CFStringEncoding encoding, Boolean isExternalRepresentation);
73 	CFStringRef CFStringCreateWithCharacters(CFAllocatorRef alloc, const(UniChar)* chars, CFIndex numChars);
74 }
75 
76 static if (!is(CFRunLoopRef)) {
77 	alias CFRunLoopMode = CFStringRef;
78 	struct __CFRunLoop;
79 	alias CFRunLoopRef = __CFRunLoop*;
80 	struct __CFRunLoopSource;
81 	alias CFRunLoopSourceRef = __CFRunLoopSource*;
82 
83 	alias CFTimeInterval = double;
84 
85 	enum CFRunLoopRunResult : int {
86 	    kCFRunLoopRunFinished = 1,
87 	    kCFRunLoopRunStopped = 2,
88 	    kCFRunLoopRunTimedOut = 3,
89 	    kCFRunLoopRunHandledSource = 4
90 	}
91 
92 	extern const CFStringRef kCFRunLoopDefaultMode;
93 	extern const CFStringRef kCFRunLoopCommonModes;
94 
95 	CFRunLoopRef CFRunLoopGetMain() @nogc;
96 	CFRunLoopRef CFRunLoopGetCurrent() @nogc;
97 	void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFRunLoopMode mode) @nogc;
98 	CFRunLoopRunResult CFRunLoopRunInMode(CFRunLoopMode mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
99 }
100 
101 static if (!is(CFFileDescriptorRef)) {
102 	alias CFFileDescriptorNativeDescriptor = int;
103 
104 	struct __CFFileDescriptor;
105 	alias CFFileDescriptorRef = __CFFileDescriptor*;
106 
107 	/* Callback Reason Types */
108 	enum CFOptionFlags {
109 	    kCFFileDescriptorReadCallBack = 1UL << 0,
110 	    kCFFileDescriptorWriteCallBack = 1UL << 1
111 	}
112 
113 	alias CFFileDescriptorCallBack = void function(CFFileDescriptorRef f, CFOptionFlags callBackTypes, void* info);
114 
115 	struct CFFileDescriptorContext {
116 	    CFIndex version_;
117 	    void* info;
118 	    void* function(void *info) retain;
119 	    void function(void *info) release;
120 	    CFStringRef function(void *info) copyDescription;
121 	}
122 
123 	CFTypeID CFFileDescriptorGetTypeID() @nogc;
124 	CFFileDescriptorRef	CFFileDescriptorCreate(CFAllocatorRef allocator, CFFileDescriptorNativeDescriptor fd, Boolean closeOnInvalidate, CFFileDescriptorCallBack callout, const(CFFileDescriptorContext)* context) @nogc;
125 	CFFileDescriptorNativeDescriptor CFFileDescriptorGetNativeDescriptor(CFFileDescriptorRef f) @nogc;
126 	void CFFileDescriptorGetContext(CFFileDescriptorRef f, CFFileDescriptorContext* context) @nogc;
127 	void CFFileDescriptorEnableCallBacks(CFFileDescriptorRef f, CFOptionFlags callBackTypes) @nogc;
128 	void CFFileDescriptorDisableCallBacks(CFFileDescriptorRef f, CFOptionFlags callBackTypes) @nogc;
129 	void CFFileDescriptorInvalidate(CFFileDescriptorRef f) @nogc;
130 	Boolean CFFileDescriptorIsValid(CFFileDescriptorRef f) @nogc;
131 	CFRunLoopSourceRef CFFileDescriptorCreateRunLoopSource(CFAllocatorRef allocator, CFFileDescriptorRef f, CFIndex order) @nogc;
132 }