blob: b388ecab741097ab5881ef4a51e85ebe85b0cef7 [file] [log] [blame]
John McCalld70fb982011-06-15 23:25:17 +00001#if __has_feature(objc_arr)
2#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE __attribute__((unavailable("not available in automatic reference counting mode")))
3#else
4#define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
5#endif
6
Argyrios Kyrtzidisd208ef92011-11-04 15:58:08 +00007#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
Argyrios Kyrtzidis41899f32011-09-14 18:17:09 +00008#define CF_CONSUMED __attribute__((cf_consumed))
Argyrios Kyrtzidis273c7c42012-06-01 00:10:47 +00009#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
Argyrios Kyrtzidis41899f32011-09-14 18:17:09 +000010
Argyrios Kyrtzidisd208ef92011-11-04 15:58:08 +000011#define NS_INLINE static __inline__ __attribute__((always_inline))
Argyrios Kyrtzidis93907472011-07-27 05:28:18 +000012#define nil ((void*) 0)
Argyrios Kyrtzidis6ba7afb2013-01-03 03:17:17 +000013#define NULL ((void*)0)
Argyrios Kyrtzidis93907472011-07-27 05:28:18 +000014
John McCalld70fb982011-06-15 23:25:17 +000015typedef int BOOL;
16typedef unsigned NSUInteger;
17typedef int int32_t;
18typedef unsigned char uint8_t;
19typedef int32_t UChar32;
20typedef unsigned char UChar;
21
Argyrios Kyrtzidis93907472011-07-27 05:28:18 +000022typedef struct _NSZone NSZone;
23
24typedef const void * CFTypeRef;
25CFTypeRef CFRetain(CFTypeRef cf);
Argyrios Kyrtzidis273c7c42012-06-01 00:10:47 +000026CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
Argyrios Kyrtzidisd208ef92011-11-04 15:58:08 +000027
28NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
Argyrios Kyrtzidis93907472011-07-27 05:28:18 +000029
John McCalld70fb982011-06-15 23:25:17 +000030@protocol NSObject
31- (BOOL)isEqual:(id)object;
Argyrios Kyrtzidis93907472011-07-27 05:28:18 +000032- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
John McCalld70fb982011-06-15 23:25:17 +000033- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
34- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
35- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
36- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
John McCalld70fb982011-06-15 23:25:17 +000037@end
38
39@interface NSObject <NSObject> {}
40- (id)init;
41
42+ (id)new;
John McCalld70fb982011-06-15 23:25:17 +000043+ (id)alloc;
44- (void)dealloc;
45
46- (void)finalize;
47
48- (id)copy;
49- (id)mutableCopy;
John McCalld70fb982011-06-15 23:25:17 +000050@end
51
John McCalld70fb982011-06-15 23:25:17 +000052NS_AUTOMATED_REFCOUNT_UNAVAILABLE
53@interface NSAutoreleasePool : NSObject {
54@private
55 void *_token;
56 void *_reserved3;
57 void *_reserved2;
58 void *_reserved;
59}
60
61+ (void)addObject:(id)anObject;
62
63- (void)addObject:(id)anObject;
64
65- (void)drain;
66
67@end
68
69typedef const void* objc_objectptr_t;
70extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer);
71extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer);
72extern objc_objectptr_t objc_unretainedPointer(id object);
Argyrios Kyrtzidis0b21d822012-05-23 21:50:04 +000073
74#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; })
75#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; })
76#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; })
77#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; })
78
79typedef id dispatch_object_t;
80typedef id xpc_object_t;
81
82void _dispatch_object_validate(dispatch_object_t object);
83void _xpc_object_validate(xpc_object_t object);
Argyrios Kyrtzidis273c7c42012-06-01 00:10:47 +000084
85#if __has_feature(objc_arc)
86
87NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
88 return (__bridge_retained CFTypeRef)X;
89}
90
91NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
92 return (__bridge_transfer id)X;
93}
94
95#else
96
97NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
98 return X ? CFRetain((CFTypeRef)X) : NULL;
99}
100
101NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
102 return [(id)CFMakeCollectable(X) autorelease];
103}
104
105#endif
Argyrios Kyrtzidis6ba7afb2013-01-03 03:17:17 +0000106
107void *_Block_copy(const void *aBlock);
108void _Block_release(const void *aBlock);
109#define Block_copy(...) ((__typeof(__VA_ARGS__))_Block_copy((const void *)(__VA_ARGS__)))
110#define Block_release(...) _Block_release((const void *)(__VA_ARGS__))