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
;
121 struct old_property
{
123 const char *attributes
;
126 struct old_property_list
{
129 struct old_property first
;
133 #define CLS_CLASS 0x1
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
148 #define CLS_FROM_BUNDLE 0x1000
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
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
176 // Terminator for array of method lists
177 #define END_OF_METHODS_LIST ((struct old_method_list*)-1)
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)
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)
193 extern void unload_class(struct old_class
*cls
);
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
);
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
);
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
);
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
;