blob: ed48949702472c189717339ce7360831a830a78c [file] [log] [blame]
John McCall8f0e8d22011-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 Kyrtzidise0ac7452011-11-04 15:58:08 +00007#define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
Argyrios Kyrtzidis4532b552011-09-14 18:17:09 +00008#define CF_CONSUMED __attribute__((cf_consumed))
Argyrios Kyrtzidis684190b2012-06-01 00:10:47 +00009#define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
Argyrios Kyrtzidis4532b552011-09-14 18:17:09 +000010
Argyrios Kyrtzidise0ac7452011-11-04 15:58:08 +000011#define NS_INLINE static __inline__ __attribute__((always_inline))
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000012#define nil ((void*) 0)
13
John McCall8f0e8d22011-06-15 23:25:17 +000014typedef int BOOL;
15typedef unsigned NSUInteger;
16typedef int int32_t;
17typedef unsigned char uint8_t;
18typedef int32_t UChar32;
19typedef unsigned char UChar;
20
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000021typedef struct _NSZone NSZone;
22
23typedef const void * CFTypeRef;
24CFTypeRef CFRetain(CFTypeRef cf);
Argyrios Kyrtzidis684190b2012-06-01 00:10:47 +000025CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
Argyrios Kyrtzidise0ac7452011-11-04 15:58:08 +000026
27NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000028
John McCall8f0e8d22011-06-15 23:25:17 +000029@protocol NSObject
30- (BOOL)isEqual:(id)object;
Argyrios Kyrtzidis18fd0c62011-07-27 05:28:18 +000031- (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
John McCall8f0e8d22011-06-15 23:25:17 +000032- (id)retain NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
33- (NSUInteger)retainCount NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
34- (oneway void)release NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
35- (id)autorelease NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
John McCall8f0e8d22011-06-15 23:25:17 +000036@end
37
38@interface NSObject <NSObject> {}
39- (id)init;
40
41+ (id)new;
John McCall8f0e8d22011-06-15 23:25:17 +000042+ (id)alloc;
43- (void)dealloc;
44
45- (void)finalize;
46
47- (id)copy;
48- (id)mutableCopy;
John McCall8f0e8d22011-06-15 23:25:17 +000049@end
50
John McCall8f0e8d22011-06-15 23:25:17 +000051NS_AUTOMATED_REFCOUNT_UNAVAILABLE
52@interface NSAutoreleasePool : NSObject {
53@private
54 void *_token;
55 void *_reserved3;
56 void *_reserved2;
57 void *_reserved;
58}
59
60+ (void)addObject:(id)anObject;
61
62- (void)addObject:(id)anObject;
63
64- (void)drain;
65
66@end
67
68typedef const void* objc_objectptr_t;
69extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer);
70extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer);
71extern objc_objectptr_t objc_unretainedPointer(id object);
Argyrios Kyrtzidis1b8fbd32012-05-23 21:50:04 +000072
73#define dispatch_retain(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); (void)[_o retain]; })
74#define dispatch_release(object) ({ dispatch_object_t _o = (object); _dispatch_object_validate(_o); [_o release]; })
75#define xpc_retain(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o retain]; })
76#define xpc_release(object) ({ xpc_object_t _o = (object); _xpc_object_validate(_o); [_o release]; })
77
78typedef id dispatch_object_t;
79typedef id xpc_object_t;
80
81void _dispatch_object_validate(dispatch_object_t object);
82void _xpc_object_validate(xpc_object_t object);
Argyrios Kyrtzidis684190b2012-06-01 00:10:47 +000083
84#if __has_feature(objc_arc)
85
86NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
87 return (__bridge_retained CFTypeRef)X;
88}
89
90NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
91 return (__bridge_transfer id)X;
92}
93
94#else
95
96NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) {
97 return X ? CFRetain((CFTypeRef)X) : NULL;
98}
99
100NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) {
101 return [(id)CFMakeCollectable(X) autorelease];
102}
103
104#endif