GNUstep CoreBase Library 0.2
CFBase.h
1/* CFBase.h
2
3 Copyright (C) 2010 Free Software Foundation, Inc.
4
5 Written by: Stefan Bidigaray
6 Date: January, 2010
7
8 This file is part of the GNUstep CoreBase Library.
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; see the file COPYING.LIB.
22 If not, see <http://www.gnu.org/licenses/> or write to the
23 Free Software Foundation, 51 Franklin Street, Fifth Floor,
24 Boston, MA 02110-1301, USA.
25*/
26
27
28#ifndef __COREFOUNDATION_CFBASE_H__
29#define __COREFOUNDATION_CFBASE_H__
30
31/* CoreFoundation defines __LITTLE_ENDIAN__ or __BIG_ENDIAN__ so we'll
32 * do the same here for compatibility.
33 */
34#if !defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__)
35#define __LITTLE_ENDIAN__ 1
36#endif
37
38#include <CoreFoundation/CFAvailability.h>
39#include <GNUstepBase/GSVersionMacros.h>
40
41/*
42 * CoreFoundation types
43 */
44typedef unsigned char Boolean;
45typedef unsigned char UInt8;
46typedef signed char SInt8;
47typedef unsigned short UInt16;
48typedef signed short SInt16;
49typedef unsigned int UInt32;
50typedef signed int SInt32;
51typedef unsigned long long UInt64;
52typedef signed long long SInt64;
53typedef SInt32 OSStatus;
54
55typedef float Float32;
56typedef double Float64;
57typedef UInt16 UniChar;
58typedef UInt8 *StringPtr;
59typedef const StringPtr *ConstStringPtr;
60typedef UInt8 Str255[256];
61typedef const Str255 *ConstStr255Param;
62typedef SInt16 OSErr;
63typedef SInt16 RegionCode;
64typedef SInt16 LangCode;
65typedef SInt16 ScriptCode;
66typedef UInt32 FourCharCode;
67#ifndef OSTYPE_DECLARED
68typedef FourCharCode OSType;
69#define OSTYPE_DECLARED
70#endif
71typedef UInt8 Byte;
72typedef SInt8 SignedByte;
73
74#ifndef UTF32Char /* UTF32Char is also defined in GSConfig.h */
75typedef UInt32 UTF32Char;
76#endif
77typedef UInt16 UTF16Char;
78typedef UInt8 UTF8Char;
79
80#if !defined(CF_EXTERN_C_BEGIN)
81#if defined(__cplusplus)
82#define CF_EXTERN_C_BEGIN extern "C" {
83#define CF_EXTERN_C_END }
84#else
85#define CF_EXTERN_C_BEGIN
86#define CF_EXTERN_C_END
87#endif
88#endif
89
90#if defined(_WIN32)
91#if defined(BUILDING_SELF)
92#if defined(__cplusplus)
93#define CF_EXPORT extern "C" __declspec(dllexport)
94#else
95#define CF_EXPORT extern __declspec(dllexport)
96#endif
97#else
98#if defined(__cplusplus)
99#define CF_EXPORT extern "C" __declspec(dllimport)
100#else
101#define CF_EXPORT extern __declspec(dllimport)
102#endif
103#endif
104#else
105#if defined(__cplusplus)
106#define CF_EXPORT extern "C"
107#else
108#define CF_EXPORT extern
109#endif
110#endif
111
112#if !defined(__bool_true_false_are_defined)
113#define true 1
114#define false 0
115#endif
116
117#ifndef TRUE
118#define TRUE 1
119#endif
120#ifndef FALSE
121#define FALSE 0
122#endif
123
124#if !defined(CF_INLINE)
125#if defined(__GNUC__) && (__GNUC__ >= 4)
126#define CF_INLINE static __inline__ __attribute__((always_inline))
127#elif defined(__GNUC__)
128#define CF_INLINE static __inline__
129#elif defined(__MWERKS__) || defined(__cplusplus)
130#define CF_INLINE static inline
131#elif defined(_MSC_VER)
132#define CF_INLINE static __inline
133#elif _WIN32
134#define CF_INLINE static __inline__
135#else
136#define CF_INLINE static inline
137#endif
138#endif
139
140#if defined(__GNUC__) || defined(__llvm__)
141#define GS_PURE_FUNCTION __attribute__((pure))
142#else
143#define GS_PURE_FUNCTION
144#endif
145
146CF_EXTERN_C_BEGIN
150typedef unsigned long CFTypeID;
151typedef const void *CFTypeRef;
159typedef unsigned long CFHashCode;
163typedef unsigned long CFOptionFlags;
165typedef signed long CFIndex;
166
170typedef struct CFRange CFRange;
178
184CF_INLINE CFRange
185CFRangeMake (CFIndex location, CFIndex length)
186{
187 CFRange range;
188
189 range.location = location;
190 range.length = length;
191 return range;
192}
193
194/* Returned by comparison functions */
195typedef enum
196{
197 kCFCompareLessThan = -1,
198 kCFCompareEqualTo = 0,
199 kCFCompareGreaterThan = 1
200} CFComparisonResult;
201
202/* Return when a value is not found */
203enum
204{
205 kCFNotFound = -1
206};
207
208/* Definition for standard comparison function callback. */
209typedef CFComparisonResult (*CFComparatorFunction) (const void *val1,
210 const void *val2,
211 void *context);
212
213/* CoreFoundation version numbers */
217CF_EXPORT const double kCFCoreFoundationVersionNumber;
218#define kCFCoreFoundationVersionNumber10_0 196.40
219#define kCFCoreFoundationVersionNumber10_0_3 196.50
220#define kCFCoreFoundationVersionNumber10_1 226.00
221#define kCFCoreFoundationVersionNumber10_1_1 226.00
222#define kCFCoreFoundationVersionNumber10_1_2 227.20
223#define kCFCoreFoundationVersionNumber10_1_3 227.20
224#define kCFCoreFoundationVersionNumber10_1_4 227.30
225#define kCFCoreFoundationVersionNumber10_2 263.00
226#define kCFCoreFoundationVersionNumber10_2_1 263.10
227#define kCFCoreFoundationVersionNumber10_2_2 263.10
228#define kCFCoreFoundationVersionNumber10_2_3 263.30
229#define kCFCoreFoundationVersionNumber10_2_4 263.30
230#define kCFCoreFoundationVersionNumber10_2_5 263.50
231#define kCFCoreFoundationVersionNumber10_2_6 263.50
232#define kCFCoreFoundationVersionNumber10_2_7 263.50
233#define kCFCoreFoundationVersionNumber10_2_8 263.50
234#define kCFCoreFoundationVersionNumber10_3 299.00
235#define kCFCoreFoundationVersionNumber10_3_1 299.00
236#define kCFCoreFoundationVersionNumber10_3_2 299.00
237#define kCFCoreFoundationVersionNumber10_3_3 299.30
238#define kCFCoreFoundationVersionNumber10_3_4 299.31
239#define kCFCoreFoundationVersionNumber10_3_5 299.31
240#define kCFCoreFoundationVersionNumber10_3_6 299.32
241#define kCFCoreFoundationVersionNumber10_3_7 299.33
242#define kCFCoreFoundationVersionNumber10_3_8 299.33
243#define kCFCoreFoundationVersionNumber10_3_9 299.35
244#define kCFCoreFoundationVersionNumber10_4 368.00
245#define kCFCoreFoundationVersionNumber10_4_1 368.10
246#define kCFCoreFoundationVersionNumber10_4_2 368.11
247#define kCFCoreFoundationVersionNumber10_4_3 368.18
248#define kCFCoreFoundationVersionNumber10_4_4_Intel 368.26
249#define kCFCoreFoundationVersionNumber10_4_4_PowerPC 368.25
250#define kCFCoreFoundationVersionNumber10_4_5_Intel 368.26
251#define kCFCoreFoundationVersionNumber10_4_5_PowerPC 368.25
252#define kCFCoreFoundationVersionNumber10_4_6_Intel 368.26
253#define kCFCoreFoundationVersionNumber10_4_6_PowerPC 368.25
254#define kCFCoreFoundationVersionNumber10_4_7 368.27
255#define kCFCoreFoundationVersionNumber10_4_8 368.27
256#define kCFCoreFoundationVersionNumber10_4_9 368.28
257#define kCFCoreFoundationVersionNumber10_4_10 368.28
258#define kCFCoreFoundationVersionNumber10_4_11 368.31
259#define kCFCoreFoundationVersionNumber10_5 476.00
260#define kCFCoreFoundationVersionNumber10_5_1 476.00
261#define kCFCoreFoundationVersionNumber10_5_2 476.10
262#define kCFCoreFoundationVersionNumber10_5_3 476.13
263#define kCFCoreFoundationVersionNumber10_5_4 476.14
264#define kCFCoreFoundationVersionNumber10_5_5 476.15
265#define kCFCoreFoundationVersionNumber10_5_6 476.17
269#if __has_feature(attribute_cf_returns_retained)
270#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
271#else
272#define CF_RETURNS_RETAINED
273#endif
274
275#if __has_feature(attribute_cf_returns_not_retained)
276#define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
277#else
278#define CF_RETURNS_NOT_RETAINED
279#endif
280
283typedef CFTypeRef CFPropertyListRef;
284
287typedef const struct __CFString *CFStringRef;
290typedef struct __CFString *CFMutableStringRef;
291
292
293
301typedef const struct __CFAllocator *CFAllocatorRef;
302
303typedef void *(*CFAllocatorAllocateCallBack) (CFIndex allocSize,
304 CFOptionFlags hint, void *info);
305typedef void (*CFAllocatorDeallocateCallBack) (void *ptr, void *info);
306typedef void *(*CFAllocatorReallocateCallBack) (void *ptr,
307 CFIndex newsize,
308 CFOptionFlags hint, void *info);
309typedef CFIndex (*CFAllocatorPreferredSizeCallBack) (CFIndex size,
310 CFOptionFlags hint,
311 void *info);
312typedef const void *(*CFAllocatorRetainCallBack) (const void *info);
313typedef void (*CFAllocatorReleaseCallBack) (const void *info);
314typedef CFStringRef (*CFAllocatorCopyDescriptionCallBack) (const void *info);
315
317{
318 CFIndex version;
319 void *info;
320 CFAllocatorRetainCallBack retain;
321 CFAllocatorReleaseCallBack release;
322 CFAllocatorCopyDescriptionCallBack copyDescription;
323 CFAllocatorAllocateCallBack allocate;
324 CFAllocatorReallocateCallBack reallocate;
325 CFAllocatorDeallocateCallBack deallocate;
326 CFAllocatorPreferredSizeCallBack preferredSize;
327};
328typedef struct _CFAllocatorContext CFAllocatorContext;
329
343#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
347#endif
356
364CF_EXPORT CFAllocatorRef
365CFAllocatorCreate (CFAllocatorRef allocator, CFAllocatorContext * context);
366
374CF_EXPORT void *CFAllocatorAllocate (CFAllocatorRef allocator, CFIndex size,
375 CFOptionFlags hint);
376
382CF_EXPORT void CFAllocatorDeallocate (CFAllocatorRef allocator, void *ptr);
383
384CF_EXPORT CFIndex
385CFAllocatorGetPreferredSizeForSize (CFAllocatorRef allocator, CFIndex size,
386 CFOptionFlags hint);
387
388CF_EXPORT void *CFAllocatorReallocate (CFAllocatorRef allocator, void *ptr,
389 CFIndex newsize, CFOptionFlags hint);
390
391CF_EXPORT CFAllocatorRef CFAllocatorGetDefault (void);
392
393CF_EXPORT void CFAllocatorSetDefault (CFAllocatorRef allocator);
394
395CF_EXPORT void
396CFAllocatorGetContext (CFAllocatorRef allocator, CFAllocatorContext * context);
397
398CF_EXPORT CFTypeID CFAllocatorGetTypeID (void);
406/* These function will be implemented in CFRuntime.c since they
407 require runtime support. */
408CF_EXPORT CFStringRef CFCopyDescription (CFTypeRef cf);
409
410CF_EXPORT CFStringRef CFCopyTypeIDDescription (CFTypeID typeID);
411
412CF_EXPORT Boolean CFEqual (CFTypeRef cf1, CFTypeRef cf2);
413
414CF_EXPORT CFAllocatorRef CFGetAllocator (CFTypeRef cf);
415
416CF_EXPORT CFIndex CFGetRetainCount (CFTypeRef cf);
417
418CF_EXPORT CFTypeID CFGetTypeID (CFTypeRef cf);
419
420CF_EXPORT CFHashCode CFHash (CFTypeRef cf);
421
422#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
423CF_EXPORT CFTypeRef CFMakeCollectable (CFTypeRef cf);
424#endif
425
426CF_EXPORT void CFRelease (CFTypeRef cf);
427
428CF_EXPORT CFTypeRef CFRetain (CFTypeRef cf);
429
430CF_EXPORT CFTypeRef CFAutorelease(CFTypeRef arg);
431
432#if OS_API_VERSION(MAC_OS_X_VERSION_10_7, GS_API_LATEST)
433CF_EXPORT void *_CFBridgingRelease (CFTypeRef cf);
434CF_EXPORT CFTypeRef _CFBridgingRetain (void *obj);
435
436#if __has_feature(objc_arc)
437#define CFBridgingRetain(x) (__bridge_retained CFTypeRef)(x)
438#define CFBridgingRelease(x) (__bridge_transfer id)(x)
439#elif __OBJC__
440#define CFBridgingRetain(x) _CFBridgingRetain((void *)(x))
441#define CFBridgingRelease(x) (id)_CFBridgingRelease((x))
442#else
443#define CFBridgingRetain(x) _CFBridgingRetain((void *)(x))
444#define CFBridgingRelease(x) _CFBridgingRelease((x))
445#endif
446#endif
454#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
455typedef struct __CFNull *CFNullRef;
456
457CF_EXPORT CFNullRef kCFNull;
458
459CFTypeID CFNullGetTypeID (void);
460#endif
463CF_EXTERN_C_END
464#endif /* __COREFOUNDATION_CFBASE_H__ */
CFIndex location
Definition CFBase.h:173
CFIndex length
Definition CFBase.h:175
unsigned long CFOptionFlags
Definition CFBase.h:163
signed long CFIndex
Definition CFBase.h:165
CFRange CFRangeMake(CFIndex location, CFIndex length)
Definition CFBase.h:185
unsigned long CFHashCode
Definition CFBase.h:159
Definition CFBase.h:172
CFAllocatorRef kCFAllocatorUseContext
Definition CFBase.h:355
void CFAllocatorDeallocate(CFAllocatorRef allocator, void *ptr)
CFAllocatorRef kCFAllocatorNull
Definition CFBase.h:351
CFAllocatorRef kCFAllocatorMallocZone
Definition CFBase.h:346
const struct __CFAllocator * CFAllocatorRef
A reference to a CFAllocator object.
Definition CFBase.h:301
CFAllocatorRef CFAllocatorCreate(CFAllocatorRef allocator, CFAllocatorContext *context)
CFAllocatorRef kCFAllocatorDefault
Definition CFBase.h:334
CFAllocatorRef kCFAllocatorMalloc
Definition CFBase.h:342
CFAllocatorRef kCFAllocatorSystemDefault
Definition CFBase.h:339
void * CFAllocatorAllocate(CFAllocatorRef allocator, CFIndex size, CFOptionFlags hint)
Definition CFBase.h:317