2 * This file contains declarations used by the run-time system.
4 * Most of these declarations are defined by virtue of data
5 * structures produced by the compiler.
14 #ifndef _objc_INCLUDE_GNU
15 #define _objc_INCLUDE_GNU
17 /* If someone is using a c++
18 compiler then adjust the
19 types in the file back
25 #include <sys/types.h>
29 #define nil ( id )0 /* id of Nil instance */
30 #define Nil ( Class_t )0 /* id of Nil class */
31 typedef char* STR
; /* String alias */
33 /* Boolean typedefs */
39 selector. Selectors are
40 really of type char*. The
41 run-time uses strcmp() to
45 /* ObjC uses this typedef
46 for untyped instances. */
47 typedef struct objc_object
{
48 struct objc_class
* isa
;
51 /* Prototype for method
59 /* Filer types used to
79 #define _C_CHARPTR '*'
82 #define _C_UNION_B '('
83 #define _C_UNION_E ')'
84 #define _C_STRUCT_B '{'
85 #define _C_STRUCT_E '}'
88 * These definitions are masks used with
89 * the "info" member variable in the class and
90 * meta class structures.
92 #define CLS_CLASS 0x1L /* The structure is of type
94 #define CLS_META 0x2L /* The structure is of type
95 meta class (MetaClass_t). */
96 #define CLS_INITIALIZED 0x4L /* Class is initialized. A
97 +initialize method is the
98 first message sent to a
99 class. It isn't guaranteed
100 to be sent only once. */
101 #define CLS_POSING 0x8L /* Class is posing as another.
104 #define CLS_MAPPED 0x10L /* Unknown. */
107 /* Set this variable to !0 to
108 have the messager print
109 messaging operations. */
110 extern BOOL objc_trace
;
114 * Whereas a Module (defined further down) is the
115 * root (typically) of a file, a Symtab is the root of the
116 * class and category definitions within the module.
118 * A Symtab contains a variable length array of pointers
119 * to classes and categories defined in the module.
121 typedef struct objc_symtab
{
122 u_long sel_ref_cnt
; /* Unknown. */
123 SEL
*refs
; /* Unknown. */
124 u_short cls_def_cnt
; /* Number of classes compiled
125 (defined) in the module. */
126 u_short cat_def_cnt
; /* Number of categories
127 compiled (defined) in the
129 void *defs
[1]; /* Variable array of pointers.
130 cls_def_cnt of type Class_t
131 followed by cat_def_cnt of
137 * The compiler generates one of these structures for each
138 * module that composes the executable (eg main.m).
140 * This data structure is the root of the definition tree
143 * A collect program runs between ld stages and creates
144 * a ObjC ctor array. That array holds a pointer to each
145 * module structure of the executable.
147 typedef struct objc_module
{
148 u_long version
; /* Unknown. */
149 u_long size
; /* Suspect this is
150 sizeof(Module). It is always
152 char* name
; /* Name of the file where the
153 module was generated. The
154 name includes the path. */
155 Symtab_t symtab
; /* Pointer to the Symtab of
156 the module. The Symtab
157 holds an array of pointers to
158 the classes and categories
159 defined in the module. */
164 * The compiler generates one of these structures for a
165 * class that has instance variables defined in its
168 typedef struct objc_ivar
* Ivar_t
;
169 typedef struct objc_ivar_list
{
170 int ivar_count
; /* Number of structures (Ivar)
171 contained in the list. One
172 structure per instance
173 variable defined in the
176 char* ivar_name
; /* Name of the instance
177 variable as entered in the
179 char* ivar_type
; /* Description of the Ivar's
182 int ivar_offset
; /* Byte offset from the base
183 address of the instance
184 structure to the variable. */
186 } ivar_list
[1]; /* Variable length
188 } IvarList
, *IvarList_t
;
192 * The compiler generates one (or more) of these structures
193 * for a class that has methods defined in its specification.
195 * The implementation of a class can be broken into separate
196 * pieces in a file and categories can break them across modules.
197 * To handle this problem is a singly linked list of methods.
199 typedef struct objc_method Method
;
200 typedef Method
* Method_t
;
201 typedef struct objc_method_list
{
202 struct objc_method_list
* method_next
; /* This variable is used to link
203 a method list to another. It
204 is a singly linked list. */
205 int method_count
; /* Number of methods defined in
208 SEL method_name
; /* This variable is the method's
210 The unique integer passed to
211 objc_msgSend() is a char* too.
212 It is compared against
213 method_name using strcmp(). */
214 char* method_types
; /* Description of the method's
215 parameter list. Useful for
217 IMP method_imp
; /* Address of the method in the
219 } method_list
[1]; /* Variable length
221 } MethodList
, *MethodList_t
;
225 * The compiler generates one of these structures for
228 * This structure is the definition for meta classes.
229 * By definition a meta class is the class's class. Its
230 * most relevant contribution is that its method list
231 * contain the class's factory methods.
233 * This structure is generated by the compiler in the
234 * executable and used by the run-time during normal
235 * messaging operations. Therefore some definitions
236 * don't make sense in some contexts.
238 typedef struct objc_metaClass
{
239 char* isa
; /* Always a pointer to the
241 char* super_class
; /* Name of the class's super
243 char* name
; /* Name of the meta class. */
244 long version
; /* Unknown. */
245 long info
; /* Bit mask. See class masks
247 long instance_size
; /* Always 0 except for Object.
248 Should be ignored. */
249 IvarList_t ivars
; /* Always NULL except for
250 Object. Should be ignored. */
251 MethodList_t methods
; /* Linked List of factory methods
253 Cache_t cache
; /* Used to cache factory methods
254 defined for the class and its
255 super classes. Entries are
256 made to the cache as the
257 messager receives them. */
258 } MetaClass
, *MetaClass_t
;
262 * The compiler generates one of these structures for
265 * This structure is the definition for classes.
267 * This structure is generated by the compiler in the
268 * executable and used by the run-time during normal
269 * messaging operations. Therefore some definitions
270 * don't make sense in some contexts.
272 typedef struct objc_class
{
273 MetaClass_t isa
; /* Pointer to the class's
275 char* super_class
; /* Name of the class's super
277 char* name
; /* Name of the class. */
278 long version
; /* Unknown. */
279 long info
; /* Bit mask. See class masks
281 long instance_size
; /* Size in bytes of the class.
282 The sum of the class definition
285 IvarList_t ivars
; /* Pointer to a structure that
286 describes the instance
287 variables in the class
288 definition. NULL indicates
289 no instance variables. Does
290 not include super class
292 MethodList_t methods
; /* Linked list of instance
293 methods defined for the
295 Cache_t cache
; /* Used to cache instance methods
296 defined for the class and its
297 super classes. Entries are
298 made to the cache as the
299 messager receives them. */
304 * The compiler generates one of these structures
305 * for each category. A class may have many
306 * categories and contain both instance and
309 typedef struct objc_category
{
310 char* category_name
; /* Name of the category. Name
311 contained in the () of the
312 category definition. */
313 char* class_name
; /* Name of the class to which
314 the category belongs. */
315 MethodList_t instance_methods
; /* Linked list of instance
316 methods defined in the
317 category. NULL indicates no
318 instance methods defined. */
319 MethodList_t class_methods
; /* Linked list of factory
320 methods defined in the
321 category. NULL indicates no
322 class methods defined. */
323 } Category
, *Category_t
;
327 * Structure used when a message is send to a class's
328 * super class. The compiler generates one of these
329 * structures and passes it to objc_msgSuper().
331 typedef struct objc_super
{
332 id receiver
; /* Id of the object sending
334 char* class; /* Name of the object's super
335 class. Passed to remove a
336 level of indirection? */