1 /*
2 The MIT License (MIT)
3 
4 Copyright (c) 2015 Stephan Dilly
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 /*
25 * Copyright (c) 2015 Guillaume Piolat
26 * All rights reserved.
27 *
28 * Redistribution and use in source and binary forms, with or without
29 * modification, are permitted provided that the following conditions are
30 * met:
31 *
32 * * Redistributions of source code must retain the above copyright
33 *   notice, this list of conditions and the following disclaimer.
34 *
35 * * Redistributions in binary form must reproduce the above copyright
36 *   notice, this list of conditions and the following disclaimer in the
37 *   documentation and/or other materials provided with the distribution.
38 *
39 * * Neither the names 'Derelict', 'DerelictSDL', nor the names of its contributors
40 *   may be used to endorse or promote products derived from this software
41 *   without specific prior written permission.
42 *
43 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
45 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
47 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
48 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
49 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
50 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
51 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
52 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
53 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */
55 module derelict.carbon.corefoundation;
56 
57 import core.stdc.config;
58 
59 import dplug.core.sharedlib;
60 import dplug.core.nogc;
61 
62 version(OSX)
63     enum libNames = "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation";
64 else
65     enum libNames = "";
66 
67 
68 class DerelictCoreFoundationLoader : SharedLibLoader
69 {
70     public
71     {
72         nothrow @nogc:
73         this()
74         {
75             super(libNames);
76         }
77 
78         override void loadSymbols()
79         {
80             bindFunc(cast(void**)&CFRetain, "CFRetain");
81             bindFunc(cast(void**)&CFRelease, "CFRelease");
82             bindFunc(cast(void**)&CFEqual, "CFEqual");
83             bindFunc(cast(void**)&CFHash, "CFHash");
84             bindFunc(cast(void**)&CFCopyDescription, "CFCopyDescription");
85 
86             bindFunc(cast(void**)&CFArrayCreateMutable, "CFArrayCreateMutable");
87             bindFunc(cast(void**)&CFArrayAppendValue, "CFArrayAppendValue");
88 
89             bindFunc(cast(void**)&CFAllocatorAllocate, "CFAllocatorAllocate");
90             bindFunc(cast(void**)&CFAllocatorDeallocate, "CFAllocatorDeallocate");
91 
92             bindFunc(cast(void**)&CFBundleGetMainBundle, "CFBundleGetMainBundle");
93             bindFunc(cast(void**)&CFBundleGetBundleWithIdentifier, "CFBundleGetBundleWithIdentifier");
94             bindFunc(cast(void**)&CFBundleCopyBundleURL, "CFBundleCopyBundleURL");
95             bindFunc(cast(void**)&CFBundleCopyResourcesDirectoryURL, "CFBundleCopyResourcesDirectoryURL");
96 
97             bindFunc(cast(void**)&CFURLGetFileSystemRepresentation, "CFURLGetFileSystemRepresentation");
98 
99             bindFunc(cast(void**)&CFStringCreateWithCString, "CFStringCreateWithCString");
100             bindFunc(cast(void**)&CFStringGetLength, "CFStringGetLength");
101             bindFunc(cast(void**)&CFStringGetCString, "CFStringGetCString");
102             bindFunc(cast(void**)&CFStringCreateCopy, "CFStringCreateCopy");
103             bindFunc(cast(void**)&CFStringCompare, "CFStringCompare");
104             bindFunc(cast(void**)&CFStringCreateWithFormat, "CFStringCreateWithFormat");
105 
106             bindFunc(cast(void**)&CFDataCreate, "CFDataCreate");
107             bindFunc(cast(void**)&CFDataGetLength, "CFDataGetLength");
108             bindFunc(cast(void**)&CFDataGetBytePtr, "CFDataGetBytePtr");
109 
110             bindFunc(cast(void**)&CFDictionaryCreateMutable, "CFDictionaryCreateMutable");
111             bindFunc(cast(void**)&CFDictionaryGetValue, "CFDictionaryGetValue");
112             bindFunc(cast(void**)&CFDictionarySetValue, "CFDictionarySetValue");
113 
114             bindFunc(cast(void**)&CFNumberCreate, "CFNumberCreate");
115             bindFunc(cast(void**)&CFNumberGetValue, "CFNumberGetValue");
116 
117             with (kCFTypeArrayCallBacks)
118             {
119                 version_ = 0;
120                 retain = &myRetainCallBack;
121                 release = &myReleaseCallBack;
122                 copyDescription = CFCopyDescription;
123                 equal = CFEqual;
124             }
125 
126             with (kCFTypeDictionaryKeyCallBacks)
127             {
128                 version_ = 0;
129                 retain = &myRetainCallBack;
130                 release = &myReleaseCallBack;
131                 copyDescription = CFCopyDescription;
132                 equal = CFEqual;
133                 hash = CFHash;
134             }
135 
136             with (kCFTypeDictionaryValueCallBacks)
137             {
138                 version_ = 0;
139                 retain = &myRetainCallBack;
140                 release = &myReleaseCallBack;
141                 copyDescription = CFCopyDescription;
142                 equal = CFEqual;
143             }
144         }
145     }
146 }
147 
148 private __gshared DerelictCoreFoundationLoader DerelictCoreFoundation;
149 
150 private __gshared loaderCounterCF = 0;
151 
152 // Call this each time a novel owner uses these functions
153 // TODO: hold a mutex, because this isn't thread-safe
154 void acquireCoreFoundationFunctions() nothrow @nogc
155 {
156     if (DerelictCoreFoundation is null)  // You only live once
157     {
158         DerelictCoreFoundation = mallocEmplace!DerelictCoreFoundationLoader();
159         DerelictCoreFoundation.load();
160     }
161 }
162 
163 // Call this each time a novel owner releases a Cocoa functions
164 // TODO: hold a mutex, because this isn't thread-safe
165 void releaseCoreFoundationFunctions() nothrow @nogc
166 {
167     /*if (--loaderCounterCF == 0)
168     {
169         DerelictCoreFoundation.unload();
170         DerelictCoreFoundation.destroyFree();
171     }*/
172 }
173 
174 unittest
175 {
176     version(OSX)
177     {
178         acquireCoreFoundationFunctions();
179         releaseCoreFoundationFunctions();
180     }
181 }
182 
183 // To support character constants
184 package int CCONST(int a, int b, int c, int d) pure nothrow
185 {
186     return (a << 24) | (b << 16) | (c << 8) | (d << 0);
187 }
188 
189 
190 // <MacTypes.h>
191 
192 alias UInt8 = ubyte;
193 alias SInt8 = byte;
194 alias UInt16 = ushort;
195 alias SInt16 = short;
196 alias UInt32 = uint;
197 alias SInt32 = int;
198 alias UInt64 = ulong;
199 alias SInt64 = long;
200 
201 
202   // binary layout should be what is expected on this platform
203 version (LittleEndian)
204 {
205     struct wide
206     {
207         UInt32              lo;
208         SInt32              hi;
209     }
210 
211     struct UnsignedWide
212     {
213         UInt32              lo;
214         UInt32              hi;
215     }
216 }
217 else
218 {
219     struct wide
220     {
221         SInt32              hi;
222         UInt32              lo;
223     }
224 
225     struct UnsignedWide
226     {
227         UInt32              hi;
228         UInt32              lo;
229     }
230 }
231 
232 
233 alias Fixed = SInt32;
234 alias FixedPtr = Fixed*;
235 alias Fract = SInt32;
236 alias FractPtr = Fract*;
237 alias UnsignedFixed = UInt32;
238 alias UnsignedFixedPtr = UnsignedFixed*;
239 alias ShortFixed = short;
240 alias ShortFixedPtr = ShortFixed*;
241 
242 alias Float32 = float;
243 alias Float64 = double;
244 
245 struct Float32Point
246 {
247     Float32 x;
248     Float32 y;
249 }
250 
251 alias Ptr = char*;
252 alias Handle = Ptr*;
253 alias Size = long;
254 
255 
256 alias OSErr = SInt16;
257 alias OSStatus = SInt32;
258 alias LogicalAddress = void*;
259 alias ConstLogicalAddress = const(void)*;
260 alias PhysicalAddress = void*;
261 alias BytePtr = UInt8*;
262 alias ByteCount = c_ulong;
263 alias ByteOffset = c_ulong;
264 alias Duration = SInt32;
265 alias AbsoluteTime = UnsignedWide;
266 alias OptionBits = UInt32;
267 alias ItemCount = c_ulong;
268 alias PBVersion = UInt32;
269 alias ScriptCode = SInt16;
270 alias LangCode = SInt16;
271 alias RegionCode = SInt16;
272 alias FourCharCode = UInt32;
273 alias OSType = FourCharCode;
274 alias ResType = FourCharCode;
275 alias OSTypePtr = OSType*;
276 alias ResTypePtr = ResType*;
277 
278 enum
279 {
280     noErr                         = 0,
281     kNilOptions                   = 0,
282     kInvalidID                    = 0,
283     kVariableLengthArray          = 1,
284     kUnknownType                  = 0x3F3F3F3F
285 }
286 
287 alias UnicodeScalarValue = UInt32;
288 alias UTF32Char = UInt32;
289 alias UniChar = UInt16;
290 alias UTF16Char = UInt16;
291 alias UTF8Char = UInt8;
292 alias UniCharPtr = UniChar*;
293 alias UniCharCount = c_ulong;
294 alias UniCharCountPtr = UniCharCount*;
295 alias Str255 = char[256];
296 alias Str63 = char[64];
297 alias Str32 = char[33];
298 alias Str31 = char[32];
299 alias Str27 = char[28];
300 alias Str15 = char[16];
301 
302 
303 // <CoreFoundation/CFBase.h>
304 
305 
306 alias Boolean = ubyte;
307 
308 alias StringPtr = char*;
309 alias ConstStringPtr = const(char)*;
310 alias ConstStr255Param = const(char)*;
311 alias Byte = UInt8;
312 alias SignedByte = SInt8;
313 
314 
315 alias CFTypeID = c_ulong;
316 alias CFOptionFlags = c_ulong;
317 alias CFHashCode = c_ulong;
318 alias CFIndex = c_long;
319 
320 alias CFTypeRef = const(void)*;
321 
322 alias CFStringRef = void*;
323 alias CFMutableStringRef = void*;
324 alias CFAllocatorRef = void*;
325 
326 enum CFAllocatorRef kCFAllocatorDefault = null;
327 
328 alias CFPropertyListRef = CFTypeRef;
329 
330 
331 struct CFRange
332 {
333     CFIndex location;
334     CFIndex length;
335 }
336 
337 CFRange CFRangeMake(CFIndex loc, CFIndex len)
338 {
339     return CFRange(loc, len);
340 }
341 
342 alias CFComparisonResult = CFIndex;
343 enum : CFComparisonResult
344 {
345     kCFCompareLessThan = -1,
346     kCFCompareEqualTo = 0,
347     kCFCompareGreaterThan = 1
348 }
349 
350 alias CFNullRef = const(void)*;
351 
352 struct Point
353 {
354     short               v;
355     short               h;
356 }
357 alias PointPtr = Point*;
358 
359 struct Rect
360 {
361   short               top;
362   short               left;
363   short               bottom;
364   short               right;
365 }
366 alias RectPtr = Rect*;
367 
368 extern(C) nothrow @nogc
369 {
370     alias da_CFRetain = CFTypeRef function(CFTypeRef cf);
371     alias da_CFRelease = void function(CFTypeRef cf);
372     alias da_CFEqual = Boolean function(CFTypeRef cf1, CFTypeRef cf2);
373     alias da_CFHash = CFHashCode function(CFTypeRef cf);
374     alias da_CFCopyDescription = CFStringRef function(CFTypeRef cf);
375 }
376 
377 __gshared
378 {
379     da_CFRetain CFRetain;
380     da_CFRelease CFRelease;
381     da_CFEqual CFEqual;
382     da_CFHash CFHash;
383     da_CFCopyDescription CFCopyDescription;
384 }
385 
386 
387 extern(C) nothrow @nogc
388 {
389     alias da_CFAllocatorAllocate = void* function(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint);
390     alias da_CFAllocatorDeallocate = void function(CFAllocatorRef allocator, void *ptr);
391 }
392 
393 __gshared
394 {
395     da_CFAllocatorAllocate CFAllocatorAllocate;
396     da_CFAllocatorDeallocate CFAllocatorDeallocate;
397 }
398 
399 // <CoreFoundation/CFBundle.h>
400 
401 alias CFBundleRef = void*;
402 
403 extern(C) nothrow @nogc
404 {
405     alias da_CFBundleGetBundleWithIdentifier = CFBundleRef function(CFStringRef bundleID);
406     alias da_CFBundleCopyBundleURL = CFURLRef function(CFBundleRef bundle);
407     alias da_CFBundleGetMainBundle = CFBundleRef function();
408     alias da_CFBundleCopyResourcesDirectoryURL = CFURLRef function(CFBundleRef bundle);
409 
410     alias da_CFURLGetFileSystemRepresentation = Boolean function(CFURLRef url, Boolean resolveAgainstBase, UInt8* buffer, CFIndex maxBufLen);
411 }
412 
413 __gshared
414 {
415     da_CFBundleGetBundleWithIdentifier CFBundleGetBundleWithIdentifier;
416     da_CFBundleCopyBundleURL CFBundleCopyBundleURL;
417     da_CFBundleGetMainBundle CFBundleGetMainBundle;
418     da_CFBundleCopyResourcesDirectoryURL CFBundleCopyResourcesDirectoryURL;
419 
420     da_CFURLGetFileSystemRepresentation CFURLGetFileSystemRepresentation;
421 }
422 
423 
424 // <CoreFoundation/CFArray.h>
425 
426 alias CFArrayRef = void*;
427 alias CFMutableArrayRef = void*;
428 
429 extern(C) nothrow @nogc
430 {
431     alias CFArrayRetainCallBack = const(void)* function(CFAllocatorRef allocator, const(void)* value);
432     alias CFArrayReleaseCallBack = void function(CFAllocatorRef allocator, const(void)* value);
433     alias CFArrayEqualCallBack = Boolean function(const(void)* value1, const(void)* value2);
434 }
435 
436 // This one isn't forced to be @nogc (this is arbitrary, only nothrow is needed)
437 extern(C) nothrow
438 {
439     alias CFArrayCopyDescriptionCallBack = CFStringRef function(const(void)* value);
440 }
441 
442 struct CFArrayCallBacks
443 {
444     CFIndex             version_;
445     CFArrayRetainCallBack       retain;
446     CFArrayReleaseCallBack      release;
447     CFArrayCopyDescriptionCallBack  copyDescription;
448     CFArrayEqualCallBack        equal;
449 }
450 
451 __gshared CFArrayCallBacks kCFTypeArrayCallBacks;
452 
453 extern(C) nothrow @nogc
454 {
455     alias da_CFArrayCreateMutable = CFMutableArrayRef function(CFAllocatorRef allocator, CFIndex capacity, const(CFArrayCallBacks)* callBacks);
456     alias da_CFArrayAppendValue = void function(CFMutableArrayRef theArray, const(void)* value);
457 }
458 
459 __gshared
460 {
461     da_CFArrayCreateMutable CFArrayCreateMutable;
462     da_CFArrayAppendValue CFArrayAppendValue;
463 }
464 
465 
466 // <CoreFoundation/CFData.h>
467 
468 alias CFDataRef = void*;
469 alias CFMutableDataRef = void*;
470 
471 extern(C) nothrow @nogc
472 {
473     alias da_CFDataCreate = CFDataRef function(CFAllocatorRef allocator, const(UInt8)* bytes, CFIndex length);
474 
475     alias da_CFDataGetLength = CFIndex function(CFDataRef theData);
476     alias da_CFDataGetBytePtr = const(UInt8)* function(CFDataRef theData);
477 }
478 
479 __gshared
480 {
481     da_CFDataCreate CFDataCreate;
482     da_CFDataGetLength CFDataGetLength;
483     da_CFDataGetBytePtr CFDataGetBytePtr;
484 }
485 
486 // <CoreFoundation/CFDictionary.h>
487 
488 extern(C) nothrow @nogc
489 {
490     alias CFDictionaryRetainCallBack = const(void)* function(CFAllocatorRef allocator, const(void)* value);
491     alias CFDictionaryReleaseCallBack = void function(CFAllocatorRef allocator, const(void)* value);
492     alias CFDictionaryCopyDescriptionCallBack = CFStringRef function(const(void)* value);
493     alias CFDictionaryEqualCallBack = Boolean function(const(void)* value1, const(void)* value2);
494     alias CFDictionaryHashCallBack = CFHashCode function(const(void)* value);
495 }
496 
497 
498 // Dictionnaries callback
499 private extern(C) nothrow @nogc
500 {
501     const(void)* myRetainCallBack(CFAllocatorRef allocator, const(void)* value)
502     {
503         // MAYDO: not sure what to do with the allocator
504         return CFRetain(value);
505     }
506 
507     void myReleaseCallBack(CFAllocatorRef allocator, const(void)* value)
508     {
509         // MAYDO: not sure what to do with the allocator
510         return CFRelease(value);
511     }
512 }
513 
514 struct CFDictionaryKeyCallBacks
515 {
516     CFIndex             version_;
517     CFDictionaryRetainCallBack      retain;
518     CFDictionaryReleaseCallBack     release;
519     CFDictionaryCopyDescriptionCallBack copyDescription;
520     CFDictionaryEqualCallBack       equal;
521     CFDictionaryHashCallBack        hash;
522 }
523 
524 __gshared CFDictionaryKeyCallBacks kCFTypeDictionaryKeyCallBacks;
525 
526 struct CFDictionaryValueCallBacks
527 {
528     CFIndex             version_;
529     CFDictionaryRetainCallBack      retain;
530     CFDictionaryReleaseCallBack     release;
531     CFDictionaryCopyDescriptionCallBack copyDescription;
532     CFDictionaryEqualCallBack       equal;
533 }
534 
535 __gshared CFDictionaryValueCallBacks kCFTypeDictionaryValueCallBacks;
536 
537 alias CFDictionaryRef = void*;
538 alias CFMutableDictionaryRef = void*;
539 
540 extern(C) nothrow @nogc
541 {
542     alias da_CFDictionaryCreateMutable = CFMutableDictionaryRef function(CFAllocatorRef, CFIndex, const(CFDictionaryKeyCallBacks)*, const(CFDictionaryValueCallBacks)*);
543     alias da_CFDictionaryGetValue = const(void)* function(CFDictionaryRef theDict, const(void) *key);
544     alias da_CFDictionarySetValue = void function(CFMutableDictionaryRef theDict, const(void)* key, const(void)* value);
545 }
546 
547 __gshared
548 {
549     da_CFDictionaryCreateMutable CFDictionaryCreateMutable;
550     da_CFDictionaryGetValue CFDictionaryGetValue;
551     da_CFDictionarySetValue CFDictionarySetValue;
552 }
553 
554 // <CoreFoundation/CFNumber.h>
555 
556 alias CFNumberRef = void*;
557 
558 alias CFNumberType = CFIndex;
559 enum : CFNumberType
560 {
561     kCFNumberSInt8Type = 1,
562     kCFNumberSInt16Type = 2,
563     kCFNumberSInt32Type = 3,
564     kCFNumberSInt64Type = 4,
565     kCFNumberFloat32Type = 5,
566     kCFNumberFloat64Type = 6,
567     kCFNumberCharType = 7,
568     kCFNumberShortType = 8,
569     kCFNumberIntType = 9,
570     kCFNumberLongType = 10,
571     kCFNumberLongLongType = 11,
572     kCFNumberFloatType = 12,
573     kCFNumberDoubleType = 13,
574     kCFNumberCFIndexType = 14,
575     kCFNumberNSIntegerType = 15,
576     kCFNumberCGFloatType = 16,
577     kCFNumberMaxType = 16
578 }
579 
580 extern(C) nothrow @nogc
581 {
582     alias da_CFNumberCreate = CFNumberRef function(CFAllocatorRef allocator, CFNumberType theType, const(void) *valuePtr);
583     alias da_CFNumberGetValue = Boolean function(CFNumberRef number, CFNumberType theType, void *valuePtr);
584 }
585 
586 __gshared
587 {
588     da_CFNumberCreate CFNumberCreate;
589     da_CFNumberGetValue CFNumberGetValue;
590 }
591 
592 // <CoreFoundation/CFString.h>
593 
594 alias CFStringEncoding = UInt32;
595 alias CFStringBuiltInEncodings = CFStringEncoding;
596 enum : CFStringBuiltInEncodings
597 {
598     kCFStringEncodingMacRoman = 0,
599     kCFStringEncodingWindowsLatin1 = 0x0500,
600     kCFStringEncodingISOLatin1 = 0x0201,
601     kCFStringEncodingNextStepLatin = 0x0B01,
602     kCFStringEncodingASCII = 0x0600,
603     kCFStringEncodingUnicode = 0x0100,
604     kCFStringEncodingUTF8 = 0x08000100,
605     kCFStringEncodingNonLossyASCII = 0x0BFF,
606 
607     kCFStringEncodingUTF16 = 0x0100,
608     kCFStringEncodingUTF16BE = 0x10000100,
609     kCFStringEncodingUTF16LE = 0x14000100,
610 
611     kCFStringEncodingUTF32 = 0x0c000100,
612     kCFStringEncodingUTF32BE = 0x18000100,
613     kCFStringEncodingUTF32LE = 0x1c000100
614 }
615 
616 alias CFStringCompareFlags = CFOptionFlags;
617 enum : CFStringCompareFlags
618 {
619     kCFCompareCaseInsensitive = 1,
620     kCFCompareBackwards = 4,
621     kCFCompareAnchored = 8,
622     kCFCompareNonliteral = 16,
623     kCFCompareLocalized = 32,
624     kCFCompareNumerically = 64,
625     kCFCompareDiacriticInsensitive = 128,
626     kCFCompareWidthInsensitive = 256,
627     kCFCompareForcedOrdering = 512
628 }
629 
630 extern(C) nothrow @nogc
631 {
632     alias da_CFStringCreateWithCString = CFStringRef function(CFAllocatorRef, const(char)*, CFStringEncoding);
633     alias da_CFStringGetLength = CFIndex function(CFStringRef);
634     alias da_CFStringGetCString = Boolean function(CFStringRef, char*, CFIndex, CFStringEncoding);
635     alias da_CFStringCreateCopy = CFStringRef function(CFAllocatorRef alloc, CFStringRef theString);
636     alias da_CFStringCompare = CFComparisonResult function(CFStringRef theString1, CFStringRef theString2, CFStringCompareFlags compareOptions);
637     alias da_CFStringCreateWithFormat = CFStringRef function(CFAllocatorRef alloc, CFDictionaryRef formatOptions, CFStringRef format, ...);
638 }
639 
640 __gshared
641 {
642     da_CFStringCreateWithCString CFStringCreateWithCString;
643     da_CFStringGetLength CFStringGetLength;
644     da_CFStringGetCString CFStringGetCString;
645     da_CFStringCreateCopy CFStringCreateCopy;
646     da_CFStringCompare CFStringCompare;
647     da_CFStringCreateWithFormat CFStringCreateWithFormat;
648 }
649 
650 // <CoreFoundation/CFURL.h>
651 
652 alias CFURLRef = void*;