tree-vect-loop-manip.c (vect_create_cond_for_alias_checks): Use new names for group...
[gcc.git] / libobjc / objc / objc-api.h
1 /* GNU Objective-C Runtime API - Traditional API
2 Copyright (C) 1993, 1995, 1996, 1997, 2001, 2002, 2003, 2004, 2005,
3 2007, 2009, 2010 Free Software Foundation, Inc.
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3, or (at your option) any
10 later version.
11
12 GCC is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 License for more details.
16
17 Under Section 7 of GPL version 3, you are granted additional
18 permissions described in the GCC Runtime Library Exception, version
19 3.1, as published by the Free Software Foundation.
20
21 You should have received a copy of the GNU General Public License and
22 a copy of the GCC Runtime Library Exception along with this program;
23 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
24 <http://www.gnu.org/licenses/>. */
25
26 #ifndef __objc_api_INCLUDE_GNU
27 #define __objc_api_INCLUDE_GNU
28
29 /* This file declares the "traditional" GNU Objective-C Runtime API.
30 It is the API supported by older versions of the GNU Objective-C
31 Runtime. Include this file to use it.
32
33 This API is being replaced by the "modern" GNU Objective-C Runtime
34 API, which is declared in objc/runtime.h. The "modern" API is very
35 similar to the API used by the modern Apple/NeXT runtime.
36
37 The last version of GCC supporting the traditional API is GCC 4.6.
38 This file will not exist in later versions of GCC.
39
40 Because the two APIs have some conflicting definitions (in
41 particular, Method and Category are defined differently) you should
42 include either objc/objc-api.h (to use the traditional GNU
43 Objective-C Runtime API) or objc/runtime.h (to use the modern GNU
44 Objective-C Runtime API), but not both. */
45 #ifdef __objc_runtime_INCLUDE_GNU
46 # error You can not include both objc/objc-api.h and objc/runtime.h. Include objc/objc-api.h for the traditional GNU Objective-C Runtime API and objc/runtime.h for the modern one.
47 #endif
48
49 /* TODO: A deprecation warning any time the file is included ? */
50
51 #include "objc.h"
52 #ifndef GNU_LIBOBJC_COMPILING_LIBOBJC_ITSELF
53 # include "deprecated/hash.h"
54 #endif
55 #include "thr.h"
56 #include "objc-decls.h"
57 #include <stdio.h>
58 #include <stdarg.h>
59
60 #ifdef __cplusplus
61 extern "C" {
62 #endif /* __cplusplus */
63
64 #include "deprecated/METHOD_NULL.h"
65
66 /* Method descriptor returned by introspective Object methods.
67 This is really just the first part of the more complete objc_method
68 structure defined below and used internally by the runtime. */
69 struct objc_method_description
70 {
71 SEL name; /* this is a selector, not a string */
72 char *types; /* type encoding */
73 };
74
75 /* The following are used in encode strings to describe the type of
76 Ivars and Methods. */
77 #define _C_ID '@'
78 #define _C_CLASS '#'
79 #define _C_SEL ':'
80 #define _C_CHR 'c'
81 #define _C_UCHR 'C'
82 #define _C_SHT 's'
83 #define _C_USHT 'S'
84 #define _C_INT 'i'
85 #define _C_UINT 'I'
86 #define _C_LNG 'l'
87 #define _C_ULNG 'L'
88 #define _C_LNG_LNG 'q'
89 #define _C_ULNG_LNG 'Q'
90 #define _C_FLT 'f'
91 #define _C_DBL 'd'
92 #define _C_LNG_DBL 'D'
93 #define _C_BFLD 'b'
94 #define _C_BOOL 'B'
95 #define _C_VOID 'v'
96 #define _C_UNDEF '?'
97 #define _C_PTR '^'
98 #define _C_CHARPTR '*'
99 #define _C_ARY_B '['
100 #define _C_ARY_E ']'
101 #define _C_UNION_B '('
102 #define _C_UNION_E ')'
103 #define _C_STRUCT_B '{'
104 #define _C_STRUCT_E '}'
105 #define _C_VECTOR '!'
106 #define _C_COMPLEX 'j'
107
108 /* _C_ATOM is never generated by the compiler. You can treat it as
109 equivalent to "*". */
110 #define _C_ATOM '%'
111
112 #include "deprecated/objc_error.h"
113
114 #include "deprecated/struct_objc_static_instances.h"
115 #include "deprecated/struct_objc_symtab.h"
116 #include "deprecated/struct_objc_module.h"
117 #include "deprecated/struct_objc_ivar.h"
118 #include "deprecated/struct_objc_ivar_list.h"
119 #include "deprecated/struct_objc_method.h"
120 typedef struct objc_method Method, *Method_t;
121
122 #include "deprecated/struct_objc_method_list.h"
123 #include "deprecated/struct_objc_protocol_list.h"
124
125 /*
126 ** This is used to assure consistent access to the info field of
127 ** classes
128 */
129 #ifndef HOST_BITS_PER_LONG
130 #define HOST_BITS_PER_LONG (sizeof(long)*8)
131 #endif
132
133 #define __CLS_INFO(cls) ((cls)->info)
134 #define __CLS_ISINFO(cls, mask) ((__CLS_INFO(cls)&mask)==mask)
135 #define __CLS_SETINFO(cls, mask) (__CLS_INFO(cls) |= mask)
136
137 /* The structure is of type MetaClass */
138 #define _CLS_META 0x2L
139 #define CLS_ISMETA(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_META))
140
141
142 /* The structure is of type Class */
143 #define _CLS_CLASS 0x1L
144 #define CLS_ISCLASS(cls) ((cls)&&__CLS_ISINFO(cls, _CLS_CLASS))
145
146 /*
147 ** The class is initialized within the runtime. This means that
148 ** it has had correct super and sublinks assigned
149 */
150 #define _CLS_RESOLV 0x8L
151 #define CLS_ISRESOLV(cls) __CLS_ISINFO(cls, _CLS_RESOLV)
152 #define CLS_SETRESOLV(cls) __CLS_SETINFO(cls, _CLS_RESOLV)
153
154 /*
155 ** The class has been send a +initialize message or a such is not
156 ** defined for this class
157 */
158 #define _CLS_INITIALIZED 0x04L
159 #define CLS_ISINITIALIZED(cls) __CLS_ISINFO(cls, _CLS_INITIALIZED)
160 #define CLS_SETINITIALIZED(cls) __CLS_SETINFO(cls, _CLS_INITIALIZED)
161
162 /*
163 ** The class number of this class. This must be the same for both the
164 ** class and its meta class object
165 */
166 #define CLS_GETNUMBER(cls) (__CLS_INFO(cls) >> (HOST_BITS_PER_LONG/2))
167 #define CLS_SETNUMBER(cls, num) \
168 ({ (cls)->info <<= (HOST_BITS_PER_LONG/2); \
169 (cls)->info >>= (HOST_BITS_PER_LONG/2); \
170 __CLS_SETINFO(cls, (((unsigned long)num) << (HOST_BITS_PER_LONG/2))); })
171
172 #include "deprecated/struct_objc_category.h"
173
174 typedef struct objc_category Category, *Category_t;
175
176 /* We include message.h for compatibility with the old objc-api.h
177 which included the declarations currently in message.h. The
178 Apple/NeXT runtime does not do this and only includes message.h in
179 objc-runtime.h. It does not matter that much since most of the
180 definitions in message.h are runtime-specific. */
181 #include "message.h"
182
183 /*
184 ** This is a hook which is called by objc_lookup_class and
185 ** objc_get_class if the runtime is not able to find the class.
186 ** This may e.g. try to load in the class using dynamic loading.
187 ** The function is guaranteed to be passed a non-NULL name string.
188 ** In the Modern API, this is replaced by
189 ** objc_setGetUnknownClassHandler ().
190 */
191 objc_EXPORT Class (*_objc_lookup_class)(const char *name);
192
193 /*
194 ** This is a hook which is called by __objc_exec_class every time a class
195 ** or a category is loaded into the runtime. This may e.g. help a
196 ** dynamic loader determine the classes that have been loaded when
197 ** an object file is dynamically linked in.
198 */
199 objc_EXPORT void (*_objc_load_callback)(Class _class, Category* category);
200
201 #include "deprecated/objc_object_alloc.h"
202
203 /*
204 Standard functions for memory allocation and disposal. Users should
205 use these functions in their ObjC programs so that they work so that
206 they work properly with garbage collectors.
207 */
208 objc_EXPORT void *
209 objc_malloc(size_t size);
210
211 /* FIXME: Shouldn't the following be called objc_malloc_atomic ? The
212 GC function is GC_malloc_atomic() which makes sense.
213 */
214 objc_EXPORT void *
215 objc_atomic_malloc(size_t size);
216
217 objc_EXPORT void *
218 objc_realloc(void *mem, size_t size);
219
220 objc_EXPORT void *
221 objc_calloc(size_t nelem, size_t size);
222
223 objc_EXPORT void
224 objc_free(void *mem);
225
226 #include "deprecated/objc_valloc.h"
227 #include "deprecated/objc_malloc.h"
228
229 #include "deprecated/objc_unexpected_exception.h"
230
231 objc_EXPORT Method_t class_get_class_method(MetaClass _class, SEL aSel);
232
233 objc_EXPORT Method_t class_get_instance_method(Class _class, SEL aSel);
234
235 objc_EXPORT Class class_pose_as(Class impostor, Class superclass);
236
237 objc_EXPORT Class objc_get_class(const char *name);
238
239 objc_EXPORT Class objc_lookup_class(const char *name);
240
241 objc_EXPORT Class objc_next_class(void **enum_state);
242
243 objc_EXPORT const char *sel_get_name(SEL selector);
244
245 objc_EXPORT const char *sel_get_type(SEL selector);
246
247 objc_EXPORT SEL sel_get_uid(const char *name);
248
249 objc_EXPORT SEL sel_get_any_uid(const char *name);
250
251 objc_EXPORT SEL sel_get_any_typed_uid(const char *name);
252
253 objc_EXPORT SEL sel_get_typed_uid(const char *name, const char*);
254
255 objc_EXPORT SEL sel_register_name(const char *name);
256
257 objc_EXPORT SEL sel_register_typed_name(const char *name, const char*type);
258
259
260 objc_EXPORT BOOL sel_is_mapped (SEL aSel);
261
262 extern id class_create_instance(Class _class);
263
264 static inline const char *
265 class_get_class_name(Class _class)
266 {
267 return CLS_ISCLASS(_class)?_class->name:((_class==Nil)?"Nil":0);
268 }
269
270 static inline long
271 class_get_instance_size(Class _class)
272 {
273 return CLS_ISCLASS(_class)?_class->instance_size:0;
274 }
275
276 static inline MetaClass
277 class_get_meta_class(Class _class)
278 {
279 return CLS_ISCLASS(_class)?_class->class_pointer:Nil;
280 }
281
282 static inline Class
283 class_get_super_class(Class _class)
284 {
285 return CLS_ISCLASS(_class)?_class->super_class:Nil;
286 }
287
288 static inline int
289 class_get_version(Class _class)
290 {
291 return CLS_ISCLASS(_class)?_class->version:-1;
292 }
293
294 static inline BOOL
295 class_is_class(Class _class)
296 {
297 return CLS_ISCLASS(_class);
298 }
299
300 static inline BOOL
301 class_is_meta_class(Class _class)
302 {
303 return CLS_ISMETA(_class);
304 }
305
306
307 static inline void
308 class_set_version(Class _class, long version)
309 {
310 if (CLS_ISCLASS(_class))
311 _class->version = version;
312 }
313
314 static inline void *
315 class_get_gc_object_type (Class _class)
316 {
317 return CLS_ISCLASS(_class) ? _class->gc_object_type : NULL;
318 }
319
320 /* Mark the instance variable as innaccessible to the garbage collector */
321 extern void class_ivar_set_gcinvisible (Class _class,
322 const char* ivarname,
323 BOOL gcInvisible);
324
325 objc_EXPORT IMP method_get_imp(Method_t method);
326
327 objc_EXPORT IMP get_imp (Class _class, SEL sel);
328
329 /* object_copy used to take a single argument in the traditional GNU
330 Objective-C Runtime API (the one declared here), but takes 2 in the
331 modern API (implemented in the actual runtime). Define the old
332 object_copy in terms of the new one. */
333 objc_EXPORT id object_copy (id object, size_t size);
334 #define object_copy(X) (object_copy ((X), 0))
335
336 objc_EXPORT id object_dispose(id object);
337
338 static inline Class
339 object_get_class(id object)
340 {
341 return ((object!=nil)
342 ? (CLS_ISCLASS(object->class_pointer)
343 ? object->class_pointer
344 : (CLS_ISMETA(object->class_pointer)
345 ? (Class)object
346 : Nil))
347 : Nil);
348 }
349
350 static inline const char *
351 object_get_class_name(id object)
352 {
353 return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
354 ?object->class_pointer->name
355 :((Class)object)->name)
356 :"Nil");
357 }
358
359 static inline MetaClass
360 object_get_meta_class(id object)
361 {
362 return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
363 ?object->class_pointer->class_pointer
364 :(CLS_ISMETA(object->class_pointer)
365 ?object->class_pointer
366 :Nil))
367 :Nil);
368 }
369
370 static inline Class
371 object_get_super_class
372 (id object)
373 {
374 return ((object!=nil)?(CLS_ISCLASS(object->class_pointer)
375 ?object->class_pointer->super_class
376 :(CLS_ISMETA(object->class_pointer)
377 ?((Class)object)->super_class
378 :Nil))
379 :Nil);
380 }
381
382 static inline BOOL
383 object_is_class (id object)
384 {
385 return ((object != nil) && CLS_ISMETA (object->class_pointer));
386 }
387
388 static inline BOOL
389 object_is_instance (id object)
390 {
391 return ((object != nil) && CLS_ISCLASS (object->class_pointer));
392 }
393
394 static inline BOOL
395 object_is_meta_class (id object)
396 {
397 return ((object != nil)
398 && !object_is_instance (object)
399 && !object_is_class (object));
400 }
401
402 #include "deprecated/objc_get_uninstalled_dtable.h"
403
404 #ifdef __cplusplus
405 }
406 #endif /* __cplusplus */
407
408 #endif /* not __objc_api_INCLUDE_GNU */
409
410
411