]>
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 * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
7 * Reserved. This file contains Original Code and/or Modifications of
8 * Original Code as defined in and that are subject to the Apple Public
9 * Source License Version 1.1 (the "License"). You may not use this file
10 * except in compliance with the License. Please obtain a copy of the
11 * License at http://www.apple.com/publicsource and read it before using
14 * The Original Code and all software distributed under the License are
15 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
19 * License for the specific language governing rights and limitations
22 * @APPLE_LICENSE_HEADER_END@
26 * Copyright 1988-1996, NeXT Software, Inc.
29 #ifndef _OBJC_CLASS_H_
30 #define _OBJC_CLASS_H_
37 struct objc_class
*isa
;
38 struct objc_class
*super_class
;
43 struct objc_ivar_list
*ivars
;
45 struct objc_method_list
**methodLists
;
47 struct objc_cache
*cache
;
48 struct objc_protocol_list
*protocols
;
50 #define CLS_GETINFO(cls,infomask) ((cls)->info & infomask)
51 #define CLS_SETINFO(cls,infomask) ((cls)->info |= infomask)
53 #define CLS_CLASS 0x1L
55 #define CLS_INITIALIZED 0x4L
56 #define CLS_POSING 0x8L
57 #define CLS_MAPPED 0x10L
58 #define CLS_FLUSH_CACHE 0x20L
59 #define CLS_GROW_CACHE 0x40L
60 #define CLS_NEED_BIND 0x80L
61 #define CLS_METHOD_ARRAY 0x100L
62 // the JavaBridge constructs classes with these markers
63 #define CLS_JAVA_HYBRID 0x200L
64 #define CLS_JAVA_CLASS 0x400L
68 typedef struct objc_category
*Category
;
70 struct objc_category
{
73 struct objc_method_list
*instance_methods
;
74 struct objc_method_list
*class_methods
;
75 struct objc_protocol_list
*protocols
;
78 * Instance Variable Template
80 typedef struct objc_ivar
*Ivar
;
82 struct objc_ivar_list
{
94 } ivar_list
[1]; /* variable length structure */
97 OBJC_EXPORT Ivar
object_setInstanceVariable(id
, const char *name
, void *);
98 OBJC_EXPORT Ivar
object_getInstanceVariable(id
, const char *name
, void **);
103 typedef struct objc_method
*Method
;
105 struct objc_method_list
{
106 struct objc_method_list
*obsolete
;
116 } method_list
[1]; /* variable length structure */
119 /* Protocol support */
123 struct objc_protocol_list
{
124 struct objc_protocol_list
*next
;
129 /* Definitions of filer types */
148 #define _C_CHARPTR '*'
151 #define _C_UNION_B '('
152 #define _C_UNION_E ')'
153 #define _C_STRUCT_B '{'
154 #define _C_STRUCT_E '}'
156 /* Structure for method cache - allocated/sized at runtime */
158 typedef struct objc_cache
* Cache
;
160 #define CACHE_BUCKET_NAME(B) ((B)->method_name)
161 #define CACHE_BUCKET_IMP(B) ((B)->method_imp)
162 #define CACHE_BUCKET_VALID(B) (B)
164 unsigned int mask
; /* total = mask + 1 */
165 unsigned int occupied
;
170 OBJC_EXPORT id
class_createInstance(Class
, unsigned idxIvars
);
171 OBJC_EXPORT id
class_createInstanceFromZone(Class
, unsigned idxIvars
, void *z
);
173 OBJC_EXPORT
void class_setVersion(Class
, int);
174 OBJC_EXPORT
int class_getVersion(Class
);
176 OBJC_EXPORT Ivar
class_getInstanceVariable(Class
, const char *);
177 OBJC_EXPORT Method
class_getInstanceMethod(Class
, SEL
);
178 OBJC_EXPORT Method
class_getClassMethod(Class
, SEL
);
180 OBJC_EXPORT
void class_addMethods(Class
, struct objc_method_list
*);
181 OBJC_EXPORT
void class_removeMethods(Class
, struct objc_method_list
*);
183 OBJC_EXPORT Class
class_poseAs(Class imposter
, Class original
);
185 OBJC_EXPORT
unsigned method_getNumberOfArguments(Method
);
186 OBJC_EXPORT
unsigned method_getSizeOfArguments(Method
);
187 OBJC_EXPORT
unsigned method_getArgumentInfo(Method m
, int arg
, const char **type
, int *offset
);
188 OBJC_EXPORT
const char * NSModulePathForClass (Class aClass
);
190 // usage for nextMethodList
192 // void *iterator = 0;
193 // struct objc_method_list *mlist;
194 // while ( mlist = class_nextMethodList( cls, &iterator ) )
196 #define OBJC_NEXT_METHOD_LIST 1
197 OBJC_EXPORT
struct objc_method_list
*class_nextMethodList(Class
, void **);
199 typedef void *marg_list
;
201 #if defined(__ppc__) || defined(ppc)
202 #define marg_prearg_size 128
204 #define marg_prearg_size 0
207 #define marg_malloc(margs, method) \
209 margs = (marg_list *)malloc (marg_prearg_size + ((7 + method_getSizeOfArguments(method)) & ~7)); \
213 #define marg_free(margs) \
218 #define marg_adjustedOffset(method, offset) \
219 (marg_prearg_size + offset)
224 #define marg_getRef(margs, offset, type) \
225 ( (type *)((char *)margs + marg_adjustedOffset(method,offset) ) )
227 #define marg_getValue(margs, offset, type) \
228 ( *marg_getRef(margs, offset, type) )
230 #define marg_setValue(margs, offset, type, value) \
231 ( marg_getValue(margs, offset, type) = (value) )
233 /* Load categories and non-referenced classes from libraries. */
235 #endif /* _OBJC_CLASS_H_ */