]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-runtime-old.h
objc4-493.9.tar.gz
[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 };
119
120
121 struct old_property {
122 const char *name;
123 const char *attributes;
124 };
125
126 struct old_property_list {
127 uint32_t entsize;
128 uint32_t count;
129 struct old_property first;
130 };
131
132
133 #define CLS_CLASS 0x1
134 #define CLS_META 0x2
135 #define CLS_INITIALIZED 0x4
136 #define CLS_POSING 0x8
137 #define CLS_MAPPED 0x10
138 #define CLS_FLUSH_CACHE 0x20
139 #define CLS_GROW_CACHE 0x40
140 #define CLS_NEED_BIND 0x80
141 #define CLS_METHOD_ARRAY 0x100
142 // the JavaBridge constructs classes with these markers
143 #define CLS_JAVA_HYBRID 0x200
144 #define CLS_JAVA_CLASS 0x400
145 // thread-safe +initialize
146 #define CLS_INITIALIZING 0x800
147 // bundle unloading
148 #define CLS_FROM_BUNDLE 0x1000
149 // C++ ivar support
150 #define CLS_HAS_CXX_STRUCTORS 0x2000
151 // Lazy method list arrays
152 #define CLS_NO_METHOD_ARRAY 0x4000
153 // +load implementation
154 #define CLS_HAS_LOAD_METHOD 0x8000
155 // objc_allocateClassPair API
156 #define CLS_CONSTRUCTING 0x10000
157 // visibility=hidden
158 #define CLS_HIDDEN 0x20000
159 // GC: class has unsafe finalize method
160 #define CLS_FINALIZE_ON_MAIN_THREAD 0x40000
161 // Lazy property list arrays
162 #define CLS_NO_PROPERTY_ARRAY 0x80000
163 // +load implementation
164 #define CLS_CONNECTED 0x100000
165 #define CLS_LOADED 0x200000
166 // objc_allocateClassPair API
167 #define CLS_CONSTRUCTED 0x400000
168 // class is leaf for cache flushing
169 #define CLS_LEAF 0x800000
170 // class instances may have associative references
171 #define CLS_INSTANCES_HAVE_ASSOCIATED_OBJECTS 0x1000000
172 // class has instance-specific GC layout
173 #define CLS_HAS_INSTANCE_SPECIFIC_LAYOUT 0x2000000
174
175
176 // Terminator for array of method lists
177 #define END_OF_METHODS_LIST ((struct old_method_list*)-1)
178
179 #define ISCLASS(cls) (((cls)->info & CLS_CLASS) != 0)
180 #define ISMETA(cls) (((cls)->info & CLS_META) != 0)
181 #define GETMETA(cls) (ISMETA(cls) ? (cls) : (cls)->isa)
182
183
184 __BEGIN_DECLS
185
186 #define oldcls(cls) ((struct old_class *)cls)
187 #define oldprotocol(proto) ((struct old_protocol *)proto)
188 #define oldmethod(meth) ((struct old_method *)meth)
189 #define oldcategory(cat) ((struct old_category *)cat)
190 #define oldivar(ivar) ((struct old_ivar *)ivar)
191 #define oldproperty(prop) ((struct old_property *)prop)
192
193 extern void unload_class(struct old_class *cls);
194
195 extern Class objc_getOrigClass (const char *name);
196 extern IMP lookupNamedMethodInMethodList(struct old_method_list *mlist, const char *meth_name);
197 extern void _objc_insertMethods(struct old_class *cls, struct old_method_list *mlist, struct old_category *cat);
198 extern void _objc_removeMethods(struct old_class *cls, struct old_method_list *mlist);
199 extern void _objc_flush_caches (Class cls);
200 extern BOOL _class_addProperties(struct old_class *cls, struct old_property_list *additions);
201 extern void change_class_references(struct old_class *imposter, struct old_class *original, struct old_class *copy, BOOL changeSuperRefs);
202 extern void flush_marked_caches(void);
203 extern void set_superclass(struct old_class *cls, struct old_class *supercls, BOOL cls_is_new);
204 extern void try_free(const void *p);
205
206 extern struct old_property *property_list_nth(const struct old_property_list *plist, uint32_t i);
207 extern struct old_property **copyPropertyList(struct old_property_list *plist, unsigned int *outCount);
208
209 extern void _class_setInfo(Class cls, long set);
210 extern void _class_clearInfo(Class cls, long clear);
211 extern void _class_changeInfo(Class cls, long set, long clear);
212
213
214 // used by flush_caches outside objc-cache.m
215 extern void _cache_flush(Class cls);
216 #ifdef OBJC_INSTRUMENTED
217 extern unsigned int LinearFlushCachesCount;
218 extern unsigned int LinearFlushCachesVisitedCount;
219 extern unsigned int MaxLinearFlushCachesVisitedCount;
220 extern unsigned int NonlinearFlushCachesCount;
221 extern unsigned int NonlinearFlushCachesClassCount;
222 extern unsigned int NonlinearFlushCachesVisitedCount;
223 extern unsigned int MaxNonlinearFlushCachesVisitedCount;
224 extern unsigned int IdealFlushCachesCount;
225 extern unsigned int MaxIdealFlushCachesCount;
226 #endif
227
228 __END_DECLS
229
230 #endif