]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-runtime-old.h
fe319e6e29a90a07898e458100c29b12a12f8e17
[apple/objc4.git] / runtime / objc-runtime-old.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 #ifndef _OBJC_RUNTIME_OLD_H
25 #define _OBJC_RUNTIME_OLD_H
26
27 #include "objc-private.h"
28 #include "objc-file-old.h"
29
30
31 struct old_class {
32 struct old_class *isa;
33 struct old_class *super_class;
34 const char *name;
35 long version;
36 long info;
37 long instance_size;
38 struct old_ivar_list *ivars;
39 struct old_method_list **methodLists;
40 Cache cache;
41 struct old_protocol_list *protocols;
42 // CLS_EXT only
43 const uint8_t *ivar_layout;
44 struct old_class_ext *ext;
45 };
46
47 struct old_class_ext {
48 uint32_t size;
49 const uint8_t *weak_ivar_layout;
50 struct old_property_list **propertyLists;
51 };
52
53 struct old_category {
54 char *category_name;
55 char *class_name;
56 struct old_method_list *instance_methods;
57 struct old_method_list *class_methods;
58 struct old_protocol_list *protocols;
59 uint32_t size;
60 struct old_property_list *instance_properties;
61 };
62
63 struct old_ivar {
64 char *ivar_name;
65 char *ivar_type;
66 int ivar_offset;
67 #ifdef __LP64__
68 int space;
69 #endif
70 };
71
72 struct old_ivar_list {
73 int ivar_count;
74 #ifdef __LP64__
75 int space;
76 #endif
77 /* variable length structure */
78 struct old_ivar ivar_list[1];
79 };
80
81
82 struct old_method {
83 SEL method_name;
84 char *method_types;
85 IMP method_imp;
86 };
87
88 struct old_method_list {
89 struct old_method_list *obsolete;
90
91 int method_count;
92 #ifdef __LP64__
93 int space;
94 #endif
95 /* variable length structure */
96 struct old_method method_list[1];
97 };
98
99 struct old_protocol {
100 Class isa;
101 const char *protocol_name;
102 struct old_protocol_list *protocol_list;
103 struct objc_method_description_list *instance_methods;
104 struct objc_method_description_list *class_methods;
105 };
106
107 struct old_protocol_list {
108 struct old_protocol_list *next;
109 long count;
110 struct old_protocol *list[1];
111 };
112
113 struct old_protocol_ext {
114 uint32_t size;
115 struct objc_method_description_list *optional_instance_methods;
116 struct objc_method_description_list *optional_class_methods;
117 struct old_property_list *instance_properties;
118 const char **extendedMethodTypes;
119 };
120
121
122 struct old_property {
123 const char *name;
124 const char *attributes;
125 };
126
127 struct old_property_list {
128 uint32_t entsize;
129 uint32_t count;
130 struct old_property first;
131 };
132
133
134 #define CLS_CLASS 0x1
135 #define CLS_META 0x2
136 #define CLS_INITIALIZED 0x4
137 #define CLS_POSING 0x8
138 #define CLS_MAPPED 0x10
139 #define CLS_FLUSH_CACHE 0x20
140 #define CLS_GROW_CACHE 0x40
141 #define CLS_NEED_BIND 0x80
142 #define CLS_METHOD_ARRAY 0x100
143 // the JavaBridge constructs classes with these markers
144 #define CLS_JAVA_HYBRID 0x200
145 #define CLS_JAVA_CLASS 0x400
146 // thread-safe +initialize
147 #define CLS_INITIALIZING 0x800
148 // bundle unloading
149 #define CLS_FROM_BUNDLE 0x1000
150 // C++ ivar support
151 #define CLS_HAS_CXX_STRUCTORS 0x2000
152 // Lazy method list arrays
153 #define CLS_NO_METHOD_ARRAY 0x4000
154 // +load implementation
155 #define CLS_HAS_LOAD_METHOD 0x8000
156 // objc_allocateClassPair API
157 #define CLS_CONSTRUCTING 0x10000
158 // visibility=hidden
159 #define CLS_HIDDEN 0x20000
160 // GC: class has unsafe finalize method
161 #define CLS_FINALIZE_ON_MAIN_THREAD 0x40000
162 // Lazy property list arrays
163 #define CLS_NO_PROPERTY_ARRAY 0x80000
164 // +load implementation
165 #define CLS_CONNECTED 0x100000
166 #define CLS_LOADED 0x200000
167 // objc_allocateClassPair API
168 #define CLS_CONSTRUCTED 0x400000
169 // class is leaf for cache flushing
170 #define CLS_LEAF 0x800000
171 // class instances may have associative references
172 #define CLS_INSTANCES_HAVE_ASSOCIATED_OBJECTS 0x1000000
173 // class has instance-specific GC layout
174 #define CLS_HAS_INSTANCE_SPECIFIC_LAYOUT 0x2000000
175
176
177 // Terminator for array of method lists
178 #define END_OF_METHODS_LIST ((struct old_method_list*)-1)
179
180 #define ISCLASS(cls) (((cls)->info & CLS_CLASS) != 0)
181 #define ISMETA(cls) (((cls)->info & CLS_META) != 0)
182 #define GETMETA(cls) (ISMETA(cls) ? (cls) : (cls)->isa)
183
184
185 __BEGIN_DECLS
186
187 #define oldcls(cls) ((struct old_class *)cls)
188 #define oldprotocol(proto) ((struct old_protocol *)proto)
189 #define oldmethod(meth) ((struct old_method *)meth)
190 #define oldcategory(cat) ((struct old_category *)cat)
191 #define oldivar(ivar) ((struct old_ivar *)ivar)
192 #define oldproperty(prop) ((struct old_property *)prop)
193
194 extern void unload_class(struct old_class *cls);
195
196 extern Class objc_getOrigClass (const char *name);
197 extern IMP lookupNamedMethodInMethodList(struct old_method_list *mlist, const char *meth_name);
198 extern void _objc_insertMethods(struct old_class *cls, struct old_method_list *mlist, struct old_category *cat);
199 extern void _objc_removeMethods(struct old_class *cls, struct old_method_list *mlist);
200 extern void _objc_flush_caches (Class cls);
201 extern BOOL _class_addProperties(struct old_class *cls, struct old_property_list *additions);
202 extern void change_class_references(struct old_class *imposter, struct old_class *original, struct old_class *copy, BOOL changeSuperRefs);
203 extern void flush_marked_caches(void);
204 extern void set_superclass(struct old_class *cls, struct old_class *supercls, BOOL cls_is_new);
205 extern void try_free(const void *p);
206
207 extern struct old_property *property_list_nth(const struct old_property_list *plist, uint32_t i);
208 extern struct old_property **copyPropertyList(struct old_property_list *plist, unsigned int *outCount);
209
210 extern void _class_setInfo(Class cls, long set);
211 extern void _class_clearInfo(Class cls, long clear);
212 extern void _class_changeInfo(Class cls, long set, long clear);
213
214
215 // used by flush_caches outside objc-cache.m
216 extern void _cache_flush(Class cls);
217 #ifdef OBJC_INSTRUMENTED
218 extern unsigned int LinearFlushCachesCount;
219 extern unsigned int LinearFlushCachesVisitedCount;
220 extern unsigned int MaxLinearFlushCachesVisitedCount;
221 extern unsigned int NonlinearFlushCachesCount;
222 extern unsigned int NonlinearFlushCachesClassCount;
223 extern unsigned int NonlinearFlushCachesVisitedCount;
224 extern unsigned int MaxNonlinearFlushCachesVisitedCount;
225 extern unsigned int IdealFlushCachesCount;
226 extern unsigned int MaxIdealFlushCachesCount;
227 #endif
228
229 __END_DECLS
230
231 #endif