]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-runtime-new.h
objc4-437.tar.gz
[apple/objc4.git] / runtime / objc-runtime-new.h
1 /*
2 * Copyright (c) 2005-2007 Apple Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24 // Values for class_ro_t->flags
25 // These are emitted by the compiler and are part of the ABI.
26 // class is a metaclass
27 #define RO_META (1<<0)
28 // class is a root class
29 #define RO_ROOT (1<<1)
30 // class has .cxx_construct/destruct implementations
31 #define RO_HAS_CXX_STRUCTORS (1<<2)
32 // class has +load implementation
33 // #define RO_HAS_LOAD_METHOD (1<<3)
34 // class has visibility=hidden set
35 #define RO_HIDDEN (1<<4)
36 // class has attribute(objc_exception): OBJC_EHTYPE_$_ThisClass is non-weak
37 #define RO_EXCEPTION (1<<5)
38 // class is in an unloadable bundle - must never be set by compiler
39 #define RO_FROM_BUNDLE (1<<29)
40 // class is unrealized future class - must never be set by compiler
41 #define RO_FUTURE (1<<30)
42 // class is realized - must never be set by compiler
43 #define RO_REALIZED (1<<31)
44
45 // Values for class_rw_t->flags
46 // These are not emitted by the compiler and are never used in class_ro_t.
47 // Their presence should be considered in future ABI versions.
48 // class_t->data is class_rw_t, not class_ro_t
49 #define RW_REALIZED (1<<31)
50 // class is unresolved future class
51 #define RW_FUTURE (1<<30)
52 // class is initialized
53 #define RW_INITIALIZED (1<<29)
54 // class is initializing
55 #define RW_INITIALIZING (1<<28)
56 // class_rw_t->ro is heap copy of class_ro_t
57 #define RW_COPIED_RO (1<<27)
58 // class allocated but not yet registered
59 #define RW_CONSTRUCTING (1<<26)
60 // class allocated and registered
61 #define RW_CONSTRUCTED (1<<25)
62 // GC: class has unsafe finalize method
63 #define RW_FINALIZE_ON_MAIN_THREAD (1<<24)
64 // class +load has been called
65 #define RW_LOADED (1<<23)
66 // class does not share super's vtable
67 #define RW_SPECIALIZED_VTABLE (1<<22)
68 // class instances may have associative references
69 #define RW_INSTANCES_HAVE_ASSOCIATED_OBJECTS (1<<21)
70
71 typedef struct method_t {
72 SEL name;
73 const char *types;
74 IMP imp;
75 } method_t;
76
77 typedef struct method_list_t {
78 uint32_t entsize_NEVER_USE; // low 2 bits used for fixup markers
79 uint32_t count;
80 struct method_t first;
81 } method_list_t;
82
83 typedef struct ivar_t {
84 // *offset is 64-bit by accident even though other
85 // fields restrict total instance size to 32-bit.
86 uintptr_t *offset;
87 const char *name;
88 const char *type;
89 // alignment is sometimes -1; use ivar_alignment() instead
90 uint32_t alignment __attribute__((deprecated));
91 uint32_t size;
92 } ivar_t;
93
94 typedef struct ivar_list_t {
95 uint32_t entsize;
96 uint32_t count;
97 struct ivar_t first;
98 } ivar_list_t;
99
100 typedef uintptr_t protocol_ref_t; // protocol_t *, but unremapped
101
102 typedef struct protocol_t {
103 id isa;
104 const char *name;
105 struct protocol_list_t *protocols;
106 method_list_t *instanceMethods;
107 method_list_t *classMethods;
108 method_list_t *optionalInstanceMethods;
109 method_list_t *optionalClassMethods;
110 struct objc_property_list *instanceProperties;
111 } protocol_t;
112
113 typedef struct protocol_list_t {
114 // count is 64-bit by accident.
115 uintptr_t count;
116 protocol_ref_t list[0]; // variable-size
117 } protocol_list_t;
118
119 typedef struct class_ro_t {
120 uint32_t flags;
121 uint32_t instanceStart;
122 uint32_t instanceSize;
123 #ifdef __LP64__
124 uint32_t reserved;
125 #endif
126
127 const uint8_t * ivarLayout;
128
129 const char * name;
130 const method_list_t * baseMethods;
131 const protocol_list_t * baseProtocols;
132 const ivar_list_t * ivars;
133
134 const uint8_t * weakIvarLayout;
135 const struct objc_property_list *baseProperties;
136 } class_ro_t;
137
138 typedef struct class_rw_t {
139 uint32_t flags;
140 uint32_t version;
141
142 const class_ro_t *ro;
143
144 struct method_list_t **methods;
145 struct chained_property_list *properties;
146 struct protocol_list_t ** protocols;
147
148 struct class_t *firstSubclass;
149 struct class_t *nextSiblingClass;
150 } class_rw_t;
151
152 typedef struct class_t {
153 struct class_t *isa;
154 struct class_t *superclass;
155 Cache cache;
156 IMP *vtable;
157 class_rw_t *data;
158 } class_t;
159
160 typedef struct category_t {
161 const char *name;
162 struct class_t *cls;
163 struct method_list_t *instanceMethods;
164 struct method_list_t *classMethods;
165 struct protocol_list_t *protocols;
166 struct objc_property_list *instanceProperties;
167 } category_t;
168
169 struct objc_super2 {
170 id receiver;
171 Class current_class;
172 };