In libobjc/: 2010-10-12 Nicola Pero <nicola.pero@meta-innovation.com>
[gcc.git] / libobjc / objc-private / module-abi-8.h
1 /* Definitions of Module Structures used by ABI version 8
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 under the
8 terms of the GNU General Public License as published by the Free Software
9 Foundation; either version 3, or (at your option) any later version.
10
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14 details.
15
16 Under Section 7 of GPL version 3, you are granted additional
17 permissions described in the GCC Runtime Library Exception, version
18 3.1, as published by the Free Software Foundation.
19
20 You should have received a copy of the GNU General Public License and
21 a copy of the GCC Runtime Library Exception along with this program;
22 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 <http://www.gnu.org/licenses/>. */
24
25 #ifndef __objc_private_module_abi_8_INCLUDE_GNU
26 #define __objc_private_module_abi_8_INCLUDE_GNU
27
28 /* For every class which happens to have statically allocated instances in
29 this module, one OBJC_STATIC_INSTANCES is allocated by the compiler.
30 INSTANCES is NULL terminated and points to all statically allocated
31 instances of this class. */
32 struct objc_static_instances
33 {
34 char *class_name;
35 #ifdef __cplusplus
36 id instances[1];
37 #else
38 id instances[0];
39 #endif
40 };
41
42 /* Whereas a Module (defined further down) is the root (typically) of a file,
43 a Symtab is the root of the class and category definitions within the
44 module.
45
46 A Symtab contains a variable length array of pointers to classes and
47 categories defined in the module. */
48 struct objc_symtab
49 {
50 unsigned long sel_ref_cnt; /* Unknown. */
51 SEL refs; /* Unknown. */
52 unsigned short cls_def_cnt; /* Number of classes compiled (defined)
53 in the module. */
54 unsigned short cat_def_cnt; /* Number of categories compiled
55 (defined) in the module. */
56 void *defs[1]; /* Variable array of pointers.
57 cls_def_cnt of type Class followed by
58 cat_def_cnt of type Category_t,
59 followed by a NULL terminated array
60 of objc_static_instances. */
61 };
62
63 /* The compiler generates one of these structures for each module that
64 composes the executable (eg main.m).
65
66 This data structure is the root of the definition tree for the
67 module.
68
69 A collect program runs between ld stages and creates a ObjC ctor
70 array. That array holds a pointer to each module structure of the
71 executable. */
72 struct objc_module
73 {
74 unsigned long version; /* Version of the Module data
75 structure. */
76 unsigned long size; /* sizeof(Module) according to the
77 compiler - only used to sanity check
78 that it matches sizeof(Module)
79 according to the runtime. */
80 const char* name; /* Name of the file used to compile the
81 module - not set by modern compilers
82 for security reasons. */
83 struct objc_symtab *symtab; /* Pointer to the Symtab of the module.
84 The Symtab holds an array of pointers
85 to the classes and categories defined
86 in the module. */
87 };
88
89 /* The compiler generates one of these structures for a class that has
90 instance variables defined in its specification. */
91 struct objc_ivar
92 {
93 const char* ivar_name; /* Name of the instance variable as entered
94 in the class definition. */
95 const char* ivar_type; /* Description of the Ivar's type. Useful
96 for debuggers. */
97 int ivar_offset; /* Byte offset from the base address of the
98 instance structure to the variable. */
99 };
100
101 struct objc_ivar_list
102 {
103 int ivar_count; /* Number of structures (Ivar)
104 contained in the list. One
105 structure per instance variable
106 defined in the class. */
107 struct objc_ivar ivar_list[1]; /* Variable length structure. */
108 };
109
110 /* The compiler generates one (or more) of these structures for a
111 class that has methods defined in its specification.
112
113 The implementation of a class can be broken into separate pieces in
114 a file and categories can break them across modules. To handle this
115 problem is a singly linked list of methods. */
116 struct objc_method
117 {
118 SEL method_name; /* This variable is the method's name. It
119 is a char*. The unique integer passed
120 to objc_msg_send is a char* too. It is
121 compared against method_name using
122 strcmp. */
123 const char* method_types; /* Description of the method's parameter
124 list. Useful for debuggers. */
125 IMP method_imp; /* Address of the method in the
126 executable. */
127 };
128
129 struct objc_method_list
130 {
131 struct objc_method_list* method_next; /* This variable is used to
132 link a method list to
133 another. It is a singly
134 linked list. */
135 int method_count; /* Number of methods defined
136 in this structure. */
137 struct objc_method method_list[1]; /* Variable length
138 structure. */
139 };
140
141 /* Currently defined in Protocol.m (that definition should go away
142 once we include this file). */
143 struct objc_method_description_list
144 {
145 int count;
146 struct objc_method_description list[1];
147 };
148
149 /* Currently defined by objc/objc.h. */
150 /*
151 struct objc_protocol {
152 struct objc_class* class_pointer;
153 char *protocol_name;
154 struct objc_protocol_list *protocol_list;
155 struct objc_method_description_list *instance_methods, *class_methods;
156 };
157 */
158
159 struct objc_protocol_list
160 {
161 struct objc_protocol_list *next;
162 size_t count;
163 Protocol *list[1];
164 };
165
166 /*
167 The compiler generates one of these structures for each class.
168
169 This structure is the definition for classes.
170
171 This structure is generated by the compiler in the executable and
172 used by the run-time during normal messaging operations. Therefore
173 some members change type. The compiler generates "char* const" and
174 places a string in the following member variables: super_class.
175 */
176 #ifndef __objc_STRUCT_OBJC_CLASS_defined
177 struct objc_class {
178 struct objc_class* class_pointer; /* Pointer to the class's meta
179 class. */
180 struct objc_class* super_class; /* Pointer to the super
181 class. NULL for class
182 Object. */
183 const char* name; /* Name of the class. */
184 long version; /* Unknown. */
185 unsigned long info; /* Bit mask. See class masks
186 defined above. */
187 long instance_size; /* Size in bytes of the class.
188 The sum of the class
189 definition and all super
190 class definitions. */
191 #ifdef _WIN64
192 /* We pad the structure manually to prevent warning when -Wpadded is
193 used. The compiler automatically pads the structures that it
194 generates, so this manually padded structure still matches the
195 one generated by the compiler, but if we don't pad manually,
196 -Wpadded detects that padding is being added and generates
197 annoying warnings. This hack is necessary as on LLP64 targets
198 sizeof (long) isn't equal to sizeof (void *). */
199 long pad;
200 #endif
201 struct objc_ivar_list* ivars; /* Pointer to a structure that
202 describes the instance
203 variables in the class
204 definition. NULL indicates
205 no instance variables.
206 Does not include super
207 class variables. */
208 struct objc_method_list* methods; /* Linked list of instance
209 methods defined for the
210 class. */
211 struct sarray * dtable; /* Pointer to instance method
212 dispatch table. */
213 struct objc_class* subclass_list; /* Subclasses */
214 struct objc_class* sibling_class;
215
216 struct objc_protocol_list *protocols; /* Protocols conformed to */
217 void* gc_object_type;
218 };
219 #endif /* __objc_STRUCT_OBJC_CLASS_defined */
220
221 /* The compiler generates one of these structures for each category.
222 A class may have many categories and contain both instance and
223 factory methods. */
224 struct objc_category
225 {
226 const char* category_name; /* Name of the category.
227 Name contained in the
228 () of the category
229 definition. */
230 const char* class_name; /* Name of the class to
231 which the category
232 belongs. */
233 struct objc_method_list *instance_methods; /* Linked list of
234 instance methods
235 defined in the
236 category. NULL
237 indicates no instance
238 methods defined. */
239 struct objc_method_list *class_methods; /* Linked list of
240 factory methods
241 defined in the
242 category. NULL
243 indicates no class
244 methods defined. */
245 struct objc_protocol_list *protocols; /* List of Protocols
246 conformed to. */
247 };
248
249 #endif /* __objc_private_module_abi_8_INCLUDE_GNU */