]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc.h
objc4-493.11.tar.gz
[apple/objc4.git] / runtime / objc.h
1 /*
2 * Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23 /*
24 * objc.h
25 * Copyright 1988-1996, NeXT Software, Inc.
26 */
27
28 #ifndef _OBJC_OBJC_H_
29 #define _OBJC_OBJC_H_
30
31 #include <sys/types.h> // for __DARWIN_NULL
32 #include <Availability.h>
33 #include <objc/objc-api.h>
34
35
36 typedef struct objc_class *Class;
37 typedef struct objc_object {
38 Class isa;
39 } *id;
40
41
42 typedef struct objc_selector *SEL;
43 typedef id (*IMP)(id, SEL, ...);
44 typedef signed char BOOL;
45 // BOOL is explicitly signed so @encode(BOOL) == "c" rather than "C"
46 // even if -funsigned-char is used.
47 #define OBJC_BOOL_DEFINED
48
49
50 #define YES (BOOL)1
51 #define NO (BOOL)0
52
53 #ifndef Nil
54 #define Nil __DARWIN_NULL /* id of Nil class */
55 #endif
56
57 #ifndef nil
58 #define nil __DARWIN_NULL /* id of Nil instance */
59 #endif
60
61 #if ! (defined(__OBJC_GC__) || __has_feature(objc_arr))
62 #define __strong /* empty */
63 #endif
64
65 #if !__has_feature(objc_arr)
66 #define __unsafe_unretained /* empty */
67 #define __autoreleasing /* empty */
68 #endif
69
70 OBJC_EXPORT const char *sel_getName(SEL sel)
71 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
72 OBJC_EXPORT SEL sel_registerName(const char *str)
73 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
74 OBJC_EXPORT const char *object_getClassName(id obj)
75 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
76 OBJC_EXPORT void *object_getIndexedIvars(id obj)
77 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
78 OBJC_EXPORT BOOL sel_isMapped(SEL sel)
79 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
80 OBJC_EXPORT SEL sel_getUid(const char *str)
81 __OSX_AVAILABLE_STARTING(__MAC_10_0, __IPHONE_2_0);
82
83
84 #ifndef CF_CONSUMED
85 #if __has_feature(attribute_cf_consumed)
86 #define CF_CONSUMED __attribute__((cf_consumed))
87 #else
88 #define CF_CONSUMED
89 #endif
90 #endif
91
92 #ifndef CF_RETURNS_NOT_RETAINED
93 #if __has_feature(attribute_cf_not_retained)
94 #define CF_RETURNS_NOT_RETAINED __attribute__((cf_returns_not_retained))
95 #else
96 #define CF_RETURNS_NOT_RETAINED
97 #endif
98 #endif
99
100 #ifndef NS_RETURNS_RETAINED
101 #if __has_feature(attribute_ns_returns_retained)
102 #define NS_RETURNS_RETAINED __attribute__((ns_returns_retained))
103 #else
104 #define NS_RETURNS_RETAINED
105 #endif
106 #endif
107
108 #ifndef NS_RETURNS_NOT_RETAINED
109 #if __has_feature(attribute_ns_returns_not_retained)
110 #define NS_RETURNS_NOT_RETAINED __attribute__((ns_returns_not_retained))
111 #else
112 #define NS_RETURNS_NOT_RETAINED
113 #endif
114 #endif
115
116 typedef const void* objc_objectptr_t;
117
118 OBJC_EXPORT NS_RETURNS_RETAINED id objc_retainedObject(objc_objectptr_t CF_CONSUMED pointer)
119 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
120 OBJC_EXPORT NS_RETURNS_NOT_RETAINED id objc_unretainedObject(objc_objectptr_t pointer)
121 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
122 OBJC_EXPORT CF_RETURNS_NOT_RETAINED objc_objectptr_t objc_unretainedPointer(id object)
123 __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_5_0);
124
125
126 #if !__OBJC2__
127
128 // The following declarations are provided here for source compatibility.
129
130 #if defined(__LP64__)
131 typedef long arith_t;
132 typedef unsigned long uarith_t;
133 # define ARITH_SHIFT 32
134 #else
135 typedef int arith_t;
136 typedef unsigned uarith_t;
137 # define ARITH_SHIFT 16
138 #endif
139
140 typedef char *STR;
141
142 #define ISSELECTOR(sel) sel_isMapped(sel)
143 #define SELNAME(sel) sel_getName(sel)
144 #define SELUID(str) sel_getUid(str)
145 #define NAMEOF(obj) object_getClassName(obj)
146 #define IV(obj) object_getIndexedIvars(obj)
147
148 #endif
149
150 #endif /* _OBJC_OBJC_H_ */