|
|
1.1 root 1: /*
2: * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
3: *
4: * @APPLE_LICENSE_HEADER_START@
5: *
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.0 (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
12: * this file.
13: *
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
20: * under the License."
21: *
22: * @APPLE_LICENSE_HEADER_END@
23: */
24: /*
25: * objc-class.h
26: * Copyright 1988, NeXT, Inc.
27: */
28:
29: #ifndef _OBJC_CLASS_H_
30: #define _OBJC_CLASS_H_
31:
32: #import "objc.h"
33: #import <objc/zone.h>
34: /*
35: * Class Template
36: */
37: struct objc_class {
38: struct objc_class *isa;
39: struct objc_class *super_class;
40: const char *name;
41: long version;
42: long info;
43: long instance_size;
44: struct objc_ivar_list *ivars;
45: struct objc_method_list *methods;
46: struct objc_cache *cache;
47: struct objc_protocol_list *protocols;
48: };
49: #define CLS_GETINFO(cls,infomask) ((cls)->info & infomask)
50: #define CLS_SETINFO(cls,infomask) ((cls)->info |= infomask)
51:
52: #define CLS_CLASS 0x1L
53: #define CLS_META 0x2L
54: #define CLS_INITIALIZED 0x4L
55: #define CLS_POSING 0x8L
56: #define CLS_MAPPED 0x10L
57: #define CLS_FLUSH_CACHE 0x20L
58: #define CLS_GROW_CACHE 0x40L
59: /*
60: * Category Template
61: */
62: typedef struct objc_category *Category;
63:
64: struct objc_category {
65: char *category_name;
66: char *class_name;
67: struct objc_method_list *instance_methods;
68: struct objc_method_list *class_methods;
69: struct objc_protocol_list *protocols;
70: };
71: /*
72: * Instance Variable Template
73: */
74: typedef struct objc_ivar *Ivar;
75:
76: struct objc_ivar_list {
77: int ivar_count;
78: struct objc_ivar {
79: char *ivar_name;
80: char *ivar_type;
81: int ivar_offset;
82: } ivar_list[1]; /* variable length structure */
83: };
84: /*
85: * Method Template
86: */
87: typedef struct objc_method *Method;
88:
89: struct objc_method_list {
90: struct objc_method_list *method_next;
91: int method_count;
92: struct objc_method {
93: SEL method_name;
94: char *method_types;
95: IMP method_imp;
96: } method_list[1]; /* variable length structure */
97: };
98:
99: /* Protocol support */
100:
101: @class Protocol;
102:
103: struct objc_protocol_list {
104: struct objc_protocol_list *next;
105: int count;
106: Protocol *list[1];
107: };
108:
109: /* Definitions of filer types */
110:
111: #define _C_ID '@'
112: #define _C_CLASS '#'
113: #define _C_SEL ':'
114: #define _C_CHR 'c'
115: #define _C_UCHR 'C'
116: #define _C_SHT 's'
117: #define _C_USHT 'S'
118: #define _C_INT 'i'
119: #define _C_UINT 'I'
120: #define _C_LNG 'l'
121: #define _C_ULNG 'L'
122: #define _C_FLT 'f'
123: #define _C_DBL 'd'
124: #define _C_BFLD 'b'
125: #define _C_VOID 'v'
126: #define _C_UNDEF '?'
127: #define _C_PTR '^'
128: #define _C_CHARPTR '*'
129: #define _C_ARY_B '['
130: #define _C_ARY_E ']'
131: #define _C_UNION_B '('
132: #define _C_UNION_E ')'
133: #define _C_STRUCT_B '{'
134: #define _C_STRUCT_E '}'
135:
136: /* Structure for method cache - allocated/sized at runtime */
137:
138: typedef struct objc_cache *Cache;
139:
140: #ifdef OBJC_COPY_CACHE
141:
142: #define CACHE_BUCKET_NAME(B) ((B).method_name)
143: #define CACHE_BUCKET_IMP(B) ((B).method_imp)
144: #define CACHE_BUCKET_VALID(B) ((B).method_name)
145: struct objc_cache_bucket {
146: SEL method_name;
147: IMP method_imp;
148: };
149:
150: struct objc_cache {
151: unsigned int mask; /* total = mask + 1 */
152: unsigned int occupied;
153: struct objc_cache_bucket buckets[1];
154: };
155:
156: #else
157:
158: #define CACHE_BUCKET_NAME(B) ((B)->method_name)
159: #define CACHE_BUCKET_IMP(B) ((B)->method_imp)
160: #define CACHE_BUCKET_VALID(B) (B)
161: struct objc_cache {
162: unsigned int mask; /* total = mask + 1 */
163: unsigned int occupied;
164: Method buckets[1];
165: };
166: #endif
167:
168: /* operations */
169:
170: extern id class_createInstance(Class, unsigned idxIvars);
171: extern id class_createInstanceFromZone(Class, unsigned idxIvars, NXZone *zone);
172:
173: extern void class_setVersion(Class, int);
174: extern int class_getVersion(Class);
175:
176: extern Ivar class_getInstanceVariable(Class, const char *);
177: extern Method class_getInstanceMethod(Class, SEL);
178: extern Method class_getClassMethod(Class, SEL);
179:
180: extern void class_addMethods(Class, struct objc_method_list *);
181: extern void class_removeMethods(Class, struct objc_method_list *);
182:
183: extern Class class_poseAs(Class imposter, Class original);
184:
185: extern unsigned method_getNumberOfArguments(Method);
186: extern unsigned method_getSizeOfArguments(Method);
187: extern unsigned method_getArgumentInfo(Method m, int arg, const char **type, int *offset);
188:
189: typedef void *marg_list;
190:
191: #define marg_getRef(margs, offset, type) \
192: ( (type *)((char *)margs + offset) )
193:
194: #define marg_getValue(margs, offset, type) \
195: ( *marg_getRef(margs, offset, type) )
196:
197: #define marg_setValue(margs, offset, type, value) \
198: ( marg_getValue(margs, offset, type) = (value) )
199:
200: #endif /* _OBJC_CLASS_H_ */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.