John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 1 | #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 Kyrtzidis | e0ac745 | 2011-11-04 15:58:08 +0000 | [diff] [blame] | 7 | #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained)) |
Argyrios Kyrtzidis | 4532b55 | 2011-09-14 18:17:09 +0000 | [diff] [blame] | 8 | #define CF_CONSUMED __attribute__((cf_consumed)) |
Argyrios Kyrtzidis | 684190b | 2012-06-01 00:10:47 +0000 | [diff] [blame] | 9 | #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained)) |
Argyrios Kyrtzidis | 4532b55 | 2011-09-14 18:17:09 +0000 | [diff] [blame] | 10 | |
Argyrios Kyrtzidis | e0ac745 | 2011-11-04 15:58:08 +0000 | [diff] [blame] | 11 | #define NS_INLINE static __inline__ __attribute__((always_inline)) |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 12 | #define nil ((void*) 0) |
| 13 | |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 14 | typedef int BOOL; |
| 15 | typedef unsigned NSUInteger; |
| 16 | typedef int int32_t; |
| 17 | typedef unsigned char uint8_t; |
| 18 | typedef int32_t UChar32; |
| 19 | typedef unsigned char UChar; |
| 20 | |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 21 | typedef struct _NSZone NSZone; |
| 22 | |
| 23 | typedef const void * CFTypeRef; |
| 24 | CFTypeRef CFRetain(CFTypeRef cf); |
Argyrios Kyrtzidis | 684190b | 2012-06-01 00:10:47 +0000 | [diff] [blame] | 25 | CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; |
Argyrios Kyrtzidis | e0ac745 | 2011-11-04 15:58:08 +0000 | [diff] [blame] | 26 | |
| 27 | NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE; |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 28 | |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 29 | @protocol NSObject |
| 30 | - (BOOL)isEqual:(id)object; |
Argyrios Kyrtzidis | 18fd0c6 | 2011-07-27 05:28:18 +0000 | [diff] [blame] | 31 | - (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE; |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 32 | - (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 McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 36 | @end |
| 37 | |
| 38 | @interface NSObject <NSObject> {} |
| 39 | - (id)init; |
| 40 | |
| 41 | + (id)new; |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 42 | + (id)alloc; |
| 43 | - (void)dealloc; |
| 44 | |
| 45 | - (void)finalize; |
| 46 | |
| 47 | - (id)copy; |
| 48 | - (id)mutableCopy; |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 49 | @end |
| 50 | |
John McCall | 8f0e8d2 | 2011-06-15 23:25:17 +0000 | [diff] [blame] | 51 | NS_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 | |
| 68 | typedef const void* objc_objectptr_t; |
| 69 | extern __attribute__((ns_returns_retained)) id objc_retainedObject(objc_objectptr_t __attribute__((cf_consumed)) pointer); |
| 70 | extern __attribute__((ns_returns_not_retained)) id objc_unretainedObject(objc_objectptr_t pointer); |
| 71 | extern objc_objectptr_t objc_unretainedPointer(id object); |
Argyrios Kyrtzidis | 1b8fbd3 | 2012-05-23 21:50:04 +0000 | [diff] [blame] | 72 | |
| 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 | |
| 78 | typedef id dispatch_object_t; |
| 79 | typedef id xpc_object_t; |
| 80 | |
| 81 | void _dispatch_object_validate(dispatch_object_t object); |
| 82 | void _xpc_object_validate(xpc_object_t object); |
Argyrios Kyrtzidis | 684190b | 2012-06-01 00:10:47 +0000 | [diff] [blame] | 83 | |
| 84 | #if __has_feature(objc_arc) |
| 85 | |
| 86 | NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { |
| 87 | return (__bridge_retained CFTypeRef)X; |
| 88 | } |
| 89 | |
| 90 | NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { |
| 91 | return (__bridge_transfer id)X; |
| 92 | } |
| 93 | |
| 94 | #else |
| 95 | |
| 96 | NS_INLINE CF_RETURNS_RETAINED CFTypeRef CFBridgingRetain(id X) { |
| 97 | return X ? CFRetain((CFTypeRef)X) : NULL; |
| 98 | } |
| 99 | |
| 100 | NS_INLINE id CFBridgingRelease(CFTypeRef CF_CONSUMED X) { |
| 101 | return [(id)CFMakeCollectable(X) autorelease]; |
| 102 | } |
| 103 | |
| 104 | #endif |