]>
git.saurik.com Git - apple/objc4.git/blob - runtime/objc-class.h
2 * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * Copyright 1988-1996, NeXT Software, Inc.
30 #ifndef _OBJC_CLASS_H_
31 #define _OBJC_CLASS_H_
38 struct objc_class
*isa
;
39 struct objc_class
*super_class
;
44 struct objc_ivar_list
*ivars
;
46 struct objc_method_list
**methodLists
;
48 struct objc_cache
*cache
;
49 struct objc_protocol_list
*protocols
;
51 #define CLS_GETINFO(cls,infomask) ((cls)->info & (infomask))
52 #define CLS_SETINFO(cls,infomask) ((cls)->info |= (infomask))
54 #define CLS_CLASS 0x1L
56 #define CLS_INITIALIZED 0x4L
57 #define CLS_POSING 0x8L
58 #define CLS_MAPPED 0x10L
59 #define CLS_FLUSH_CACHE 0x20L
60 #define CLS_GROW_CACHE 0x40L
61 #define CLS_NEED_BIND 0x80L
62 #define CLS_METHOD_ARRAY 0x100L
63 // the JavaBridge constructs classes with these markers
64 #define CLS_JAVA_HYBRID 0x200L
65 #define CLS_JAVA_CLASS 0x400L
66 // thread-safe +initialize
67 #define CLS_INITIALIZING 0x800
69 #define CLS_FROM_BUNDLE 0x1000L
71 #define CLS_HAS_CXX_STRUCTORS 0x2000L
72 // Lazy method list arrays
73 #define CLS_NO_METHOD_ARRAY 0x4000L
74 // +load implementation
75 // #define CLS_HAS_LOAD_METHOD 0x8000L
81 typedef struct objc_category
*Category
;
83 struct objc_category
{
86 struct objc_method_list
*instance_methods
;
87 struct objc_method_list
*class_methods
;
88 struct objc_protocol_list
*protocols
;
92 * Instance Variable Template
94 typedef struct objc_ivar
*Ivar
;
105 struct objc_ivar_list
{
110 struct objc_ivar ivar_list
[1]; /* variable length structure */
113 OBJC_EXPORT Ivar
object_setInstanceVariable(id
, const char *name
, void *);
114 OBJC_EXPORT Ivar
object_getInstanceVariable(id
, const char *name
, void **);
119 typedef struct objc_method
*Method
;
127 struct objc_method_list
{
128 struct objc_method_list
*obsolete
;
134 struct objc_method method_list
[1]; /* variable length structure */
137 /* Protocol support */
142 typedef struct objc_object Protocol
;
145 struct objc_protocol_list
{
146 struct objc_protocol_list
*next
;
151 /* Definitions of filer types */
170 #define _C_CHARPTR '*'
173 #define _C_UNION_B '('
174 #define _C_UNION_E ')'
175 #define _C_STRUCT_B '{'
176 #define _C_STRUCT_E '}'
178 /* Structure for method cache - allocated/sized at runtime */
180 typedef struct objc_cache
* Cache
;
182 #define CACHE_BUCKET_NAME(B) ((B)->method_name)
183 #define CACHE_BUCKET_IMP(B) ((B)->method_imp)
184 #define CACHE_BUCKET_VALID(B) (B)
185 #define CACHE_HASH(sel, mask) (((uarith_t)(sel)>>2) & (mask))
187 unsigned int mask
; /* total = mask + 1 */
188 unsigned int occupied
;
193 OBJC_EXPORT id
class_createInstance(Class
, unsigned idxIvars
);
194 OBJC_EXPORT id
class_createInstanceFromZone(Class
, unsigned idxIvars
, void *z
);
196 OBJC_EXPORT
void class_setVersion(Class
, int);
197 OBJC_EXPORT
int class_getVersion(Class
);
199 OBJC_EXPORT Ivar
class_getInstanceVariable(Class
, const char *);
200 OBJC_EXPORT Method
class_getInstanceMethod(Class
, SEL
);
201 OBJC_EXPORT Method
class_getClassMethod(Class
, SEL
);
203 OBJC_EXPORT
void class_addMethods(Class
, struct objc_method_list
*);
204 OBJC_EXPORT
void class_removeMethods(Class
, struct objc_method_list
*);
206 OBJC_EXPORT Class
class_poseAs(Class imposter
, Class original
);
208 OBJC_EXPORT
unsigned method_getNumberOfArguments(Method
);
209 OBJC_EXPORT
unsigned method_getSizeOfArguments(Method
);
210 OBJC_EXPORT
unsigned method_getArgumentInfo(Method m
, int arg
, const char **type
, int *offset
);
212 // usage for nextMethodList
214 // void *iterator = 0;
215 // struct objc_method_list *mlist;
216 // while ( mlist = class_nextMethodList( cls, &iterator ) )
218 #define OBJC_NEXT_METHOD_LIST 1
219 OBJC_EXPORT
struct objc_method_list
*class_nextMethodList(Class
, void **);
221 typedef void *marg_list
;
223 #if defined(__ppc__) || defined(ppc)
224 #define marg_prearg_size 128
226 #define marg_prearg_size 0
229 #define marg_malloc(margs, method) \
231 margs = (marg_list *)malloc (marg_prearg_size + ((7 + method_getSizeOfArguments(method)) & ~7)); \
235 #define marg_free(margs) \
240 #define marg_adjustedOffset(method, offset) \
241 (marg_prearg_size + offset)
246 #define marg_getRef(margs, offset, type) \
247 ( (type *)((char *)margs + marg_adjustedOffset(method,offset) ) )
249 #define marg_getValue(margs, offset, type) \
250 ( *marg_getRef(margs, offset, type) )
252 #define marg_setValue(margs, offset, type, value) \
253 ( marg_getValue(margs, offset, type) = (value) )
255 /* Load categories and non-referenced classes from libraries. */
257 #endif /* _OBJC_CLASS_H_ */