Home | History | Annotate | Download | only in ARCMT
      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 
      7 #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
      8 #define CF_CONSUMED __attribute__((cf_consumed))
      9 #define CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
     10 
     11 #define NS_INLINE static __inline__ __attribute__((always_inline))
     12 #define nil ((void*) 0)
     13 
     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 
     21 typedef struct _NSZone NSZone;
     22 
     23 typedef const void * CFTypeRef;
     24 CFTypeRef CFRetain(CFTypeRef cf);
     25 CFTypeRef CFMakeCollectable(CFTypeRef cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
     26 
     27 NS_INLINE NS_RETURNS_RETAINED id NSMakeCollectable(CFTypeRef CF_CONSUMED cf) NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
     28 
     29 @protocol NSObject
     30 - (BOOL)isEqual:(id)object;
     31 - (NSZone *)zone NS_AUTOMATED_REFCOUNT_UNAVAILABLE;
     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;
     36 @end
     37 
     38 @interface NSObject <NSObject> {}
     39 - (id)init;
     40 
     41 + (id)new;
     42 + (id)alloc;
     43 - (void)dealloc;
     44 
     45 - (void)finalize;
     46 
     47 - (id)copy;
     48 - (id)mutableCopy;
     49 @end
     50 
     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);
     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);
     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
    105