]>
Commit | Line | Data |
---|---|---|
88e17b57 | 1 | /* Basic data types for Objective C. |
3d0d8739 NP |
2 | Copyright (C) 1993, 1995, 1996, 2004, 2009, |
3 | 2010 Free Software Foundation, Inc. | |
88e17b57 | 4 | |
6c82ad25 | 5 | This file is part of GCC. |
88e17b57 | 6 | |
6c82ad25 | 7 | GCC is free software; you can redistribute it and/or modify |
88e17b57 | 8 | it under the terms of the GNU General Public License as published by |
748086b7 | 9 | the Free Software Foundation; either version 3, or (at your option) |
88e17b57 BE |
10 | any later version. |
11 | ||
6c82ad25 | 12 | GCC is distributed in the hope that it will be useful, |
88e17b57 BE |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
16 | ||
748086b7 JJ |
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/>. */ | |
88e17b57 | 25 | |
88e17b57 BE |
26 | #ifndef __objc_INCLUDE_GNU |
27 | #define __objc_INCLUDE_GNU | |
28 | ||
6dead247 NP |
29 | /* This file contains the definition of the basic types used by the |
30 | Objective-C language. It needs to be included to do almost | |
31 | anything with Objective-C. | |
32 | */ | |
33 | ||
88e17b57 BE |
34 | #ifdef __cplusplus |
35 | extern "C" { | |
36 | #endif | |
37 | ||
38 | #include <stddef.h> | |
39 | ||
6dead247 NP |
40 | /* The current version of the GNU Objective-C Runtime library in |
41 | compressed ISO date format. This should be updated any time a new | |
42 | version is released with changes to the public API (there is no | |
43 | need to update it if there were no API changes since the previous | |
44 | release). This macro is only defined starting with the GNU | |
45 | Objective-C Runtime shipped with GCC 4.6.0. If it is not defined, | |
46 | it is either an older version of the runtime, or another runtime. | |
47 | */ | |
48 | #define __GNU_LIBOBJC__ 20100911 | |
49 | ||
88e17b57 | 50 | /* |
3d0d8739 NP |
51 | Definition of the boolean type. |
52 | ||
53 | Compatibility note: the Apple/NeXT runtime defines a BOOL as a | |
54 | 'signed char'. The GNU runtime uses an 'unsigned char'. | |
55 | ||
56 | Important: this could change and we could switch to 'typedef bool | |
57 | BOOL' in the future. Do not depend on the type of BOOL. | |
88e17b57 | 58 | */ |
b15b7ef8 | 59 | #undef BOOL |
88e17b57 | 60 | typedef unsigned char BOOL; |
3d0d8739 | 61 | |
88e17b57 BE |
62 | #define YES (BOOL)1 |
63 | #define NO (BOOL)0 | |
64 | ||
3d0d8739 NP |
65 | /* The basic Objective-C types (SEL, Class, id) are defined as pointer |
66 | to opaque structures. The details of the structures are private to | |
67 | the runtime and may potentially change from one version to the | |
68 | other. | |
88e17b57 | 69 | */ |
88e17b57 | 70 | |
3d0d8739 NP |
71 | /* A SEL (selector) represents an abstract method (in the |
72 | object-oriented sense) and includes all the details of how to | |
73 | invoke the method (which means its name, arguments and return | |
74 | types) but provides no implementation of its own. You can check | |
75 | whether a class implements a selector or not, and if you have a | |
76 | selector and know that the class implements it, you can use it to | |
77 | call the method for an object in the class. | |
78 | */ | |
79 | typedef const struct objc_selector *SEL; | |
80 | #include "deprecated/struct_objc_selector.h" | |
81 | ||
82 | /* A Class is a class (in the object-oriented sense). In Objective-C | |
83 | there is the complication that each Class is an object itself, and | |
84 | so belongs to a class too. This class that a class belongs to is | |
85 | called its 'meta class'. | |
88e17b57 | 86 | */ |
3d0d8739 NP |
87 | typedef struct objc_class *Class; |
88 | #include "deprecated/MetaClass.h" | |
89 | #include "deprecated/struct_objc_class.h" | |
90 | ||
bc18535a NP |
91 | /* An 'id' is an object of an unknown class. The way the object data |
92 | is stored inside the object is private and what you see here is | |
93 | only the beginning of the actual struct. The first field is always | |
94 | a pointer to the Class that the object belongs to. If performance | |
95 | is paramount, you can use this knowledge to get the class of an | |
96 | object by doing '((id)object)->class_pointer'. | |
3d0d8739 NP |
97 | */ |
98 | typedef struct objc_object | |
99 | { | |
100 | /* 'class_pointer' is the Class that the object belongs to. In case | |
bc18535a NP |
101 | of a Class object, this pointer points to the meta class. |
102 | ||
103 | Compatibility Note: The Apple/NeXT runtime calls this field | |
104 | 'isa'. */ | |
3d0d8739 | 105 | Class class_pointer; |
88e17b57 BE |
106 | } *id; |
107 | ||
108 | /* | |
3d0d8739 NP |
109 | 'IMP' is a C function that implements a method. When retrieving the |
110 | implementation of a method from the runtime, this is the type of the | |
111 | pointer returned. The idea of the definition of IMP is to represent | |
112 | a 'pointer to a general function taking an id, a SEL, followed by | |
113 | other unspecified arguments'. You must always cast an IMP to a | |
114 | pointer to a function taking the appropriate, specific types for | |
115 | that function, before calling it - to make sure the appropriate | |
116 | arguments are passed to it. The code generated by the compiler to | |
117 | perform method calls automatically does this cast inside method | |
118 | calls. | |
88e17b57 BE |
119 | */ |
120 | typedef id (*IMP)(id, SEL, ...); | |
121 | ||
3d0d8739 NP |
122 | /* 'nil' is the null object. Messages to nil do nothing and always |
123 | return 0. */ | |
124 | #define nil (id)0 | |
88e17b57 | 125 | |
3d0d8739 NP |
126 | /* 'Nil' is the null class. Since classes are objects too, this is |
127 | actually the same object as 'nil' (and behaves in the same way), | |
128 | but it has a type of Class, so it is good to use it instead of | |
129 | 'nil' if you are comparing a Class object to nil as it enables the | |
130 | compiler to do some type-checking. */ | |
131 | #define Nil (Class)0 | |
132 | ||
133 | #include "deprecated/STR.h" | |
134 | ||
135 | /* TODO: Move the 'Protocol' declaration into objc/runtime.h. A | |
136 | Protocol is simply an object, not a basic Objective-C type. The | |
137 | Apple runtime defines Protocol in objc/runtime.h too, so it's good | |
138 | to move it there for API compatibility. | |
88e17b57 | 139 | */ |
88e17b57 | 140 | |
3d0d8739 NP |
141 | /* A 'Protocol' is a formally defined list of selectors (normally |
142 | created using the @protocol Objective-C syntax). It is mostly used | |
143 | at compile-time to check that classes implement all the methods | |
144 | that they are supposed to. Protocols are also available in the | |
145 | runtime system as Protocol objects. | |
146 | */ | |
88e17b57 | 147 | #ifndef __OBJC__ |
3d0d8739 NP |
148 | /* Once we stop including the deprecated struct_objc_protocol.h |
149 | there is no reason to even define a 'struct objc_protocol'. As | |
150 | all the structure details will be hidden, a Protocol basically is | |
151 | simply an object (as it should be). | |
152 | */ | |
153 | /* typedef struct objc_object Protocol; */ | |
154 | #include "deprecated/struct_objc_protocol.h" | |
88e17b57 | 155 | #else /* __OBJC__ */ |
3d0d8739 | 156 | @class Protocol; |
88e17b57 BE |
157 | #endif |
158 | ||
3d0d8739 NP |
159 | /* Deprecated include - here temporarily, for backwards-compatibility |
160 | as reval_t, apply_t, arglist_t and objc_msg_lookup() used to be | |
161 | defined here. */ | |
162 | #include "message.h" | |
88e17b57 | 163 | |
3d0d8739 NP |
164 | /* Compatibility note: the Apple/NeXT runtime defines sel_getName(), |
165 | sel_registerName(), object_getClassName(), object_getIndexedIvars() | |
166 | in this file while the GNU runtime defines them in runtime.h. | |
88e17b57 | 167 | |
3d0d8739 NP |
168 | The reason the GNU runtime does not define them here is that they |
169 | are not basic Objective-C types (defined in this file), but are | |
170 | part of the runtime API (defined in runtime.h). | |
171 | */ | |
88e17b57 BE |
172 | |
173 | #ifdef __cplusplus | |
174 | } | |
175 | #endif | |
176 | ||
177 | #endif /* not __objc_INCLUDE_GNU */ |