2 * Copyright (c) 1999-2007 Apple Inc. All Rights Reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
24 #ifndef _OBJC_RUNTIME_OLD_H
25 #define _OBJC_RUNTIME_OLD_H
27 #include "objc-private.h"
28 #include "objc-file-old.h"
32 struct old_class
*isa
;
33 struct old_class
*super_class
;
38 struct old_ivar_list
*ivars
;
39 struct old_method_list
**methodLists
;
41 struct old_protocol_list
*protocols
;
43 const uint8_t *ivar_layout
;
44 struct old_class_ext
*ext
;
47 struct old_class_ext
{
49 const uint8_t *weak_ivar_layout
;
50 struct old_property_list
**propertyLists
;
56 struct old_method_list
*instance_methods
;
57 struct old_method_list
*class_methods
;
58 struct old_protocol_list
*protocols
;
60 struct old_property_list
*instance_properties
;
72 struct old_ivar_list
{
77 /* variable length structure */
78 struct old_ivar ivar_list
[1];
88 struct old_method_list
{
89 struct old_method_list
*obsolete
;
95 /* variable length structure */
96 struct old_method method_list
[1];
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
;
107 struct old_protocol_list
{
108 struct old_protocol_list
*next
;
110 struct old_protocol
*list
[1];
113 struct old_protocol_ext
{
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
;
122 struct old_property
{
124 const char *attributes
;
127 struct old_property_list
{
130 struct old_property first
;
134 #define CLS_CLASS 0x1
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
149 #define CLS_FROM_BUNDLE 0x1000
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
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
177 // Terminator for array of method lists
178 #define END_OF_METHODS_LIST ((struct old_method_list*)-1)
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)
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)
194 extern void unload_class(struct old_class
*cls
);
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
);
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
);
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
);
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
;