]> git.saurik.com Git - apple/objc4.git/blob - runtime/objc-runtime-new.h
objc4-371.1.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 realized - must never be set by compiler
39 #define RO_REALIZED (1<<31)
40
41 // Values for class_rw_t->flags
42 // These are not emitted by the compiler and are never used in class_ro_t.
43 // Their presence should be considered in future ABI versions.
44 // class_t->data is class_rw_t, not class_ro_t
45 #define RW_REALIZED (1<<31)
46 // class's method lists are fixed up
47 #define RW_METHODIZED (1<<30)
48 // class is initialized
49 #define RW_INITIALIZED (1<<29)
50 // class is initializing
51 #define RW_INITIALIZING (1<<28)
52 // class_rw_t->ro is heap copy of class_ro_t
53 #define RW_COPIED_RO (1<<27)
54 // class allocated but not yet registered
55 #define RW_CONSTRUCTING (1<<26)
56 // class allocated and registered
57 #define RW_CONSTRUCTED (1<<25)
58 // GC: class has unsafe finalize method
59 #define RW_FINALIZE_ON_MAIN_THREAD (1<<24)
60 // class +load has been called
61 #define RW_LOADED (1<<23)
62
63 typedef struct method_t {
64 SEL name;
65 const char *types;
66 IMP imp;
67 } method_t;
68
69 typedef struct method_list_t {
70 uint32_t entsize;
71 uint32_t count;
72 struct method_t first;
73 } method_list_t;
74
75 typedef struct ivar_t {
76 // *offset is 64-bit by accident even though other
77 // fields restrict total instance size to 32-bit.
78 uintptr_t *offset;
79 const char *name;
80 const char *type;
81 uint32_t alignment;
82 uint32_t size;
83 } ivar_t;
84
85 typedef struct ivar_list_t {
86 uint32_t entsize;
87 uint32_t count;
88 struct ivar_t first;
89 } ivar_list_t;
90
91 typedef struct protocol_t {
92 id isa;
93 const char *name;
94 struct protocol_list_t *protocols;
95 method_list_t *instanceMethods;
96 method_list_t *classMethods;
97 method_list_t *optionalInstanceMethods;
98 method_list_t *optionalClassMethods;
99 struct objc_property_list *instanceProperties;
100 } protocol_t;
101
102 typedef struct protocol_list_t {
103 // count is 64-bit by accident.
104 uintptr_t count;
105 protocol_t *list[0]; // variable-size
106 } protocol_list_t;
107
108 typedef struct class_ro_t {
109 uint32_t flags;
110 uint32_t instanceStart;
111 uint32_t instanceSize;
112 uint32_t reserved;
113
114 const uint8_t * ivarLayout;
115
116 const char * name;
117 const method_list_t * baseMethods;
118 const protocol_list_t * baseProtocols;
119 const ivar_list_t * ivars;
120
121 const uint8_t * weakIvarLayout;
122 const struct objc_property_list *baseProperties;
123 } class_ro_t;
124
125 typedef struct class_rw_t {
126 uint32_t flags;
127 uint32_t version;
128
129 const class_ro_t *ro;
130
131 struct chained_method_list *methods;
132 struct chained_property_list *properties;
133 struct protocol_list_t ** protocols; // these are UNREMAPPED protocols!
134
135 struct class_t *firstSubclass;
136 struct class_t *nextSiblingClass;
137 } class_rw_t;
138
139 typedef struct class_t {
140 struct class_t *isa;
141 struct class_t *superclass;
142 Cache cache;
143 IMP *vtable;
144 class_rw_t *data;
145 } class_t;
146
147 typedef struct category_t {
148 const char *name;
149 struct class_t *cls;
150 struct method_list_t *instanceMethods;
151 struct method_list_t *classMethods;
152 struct protocol_list_t *protocols;
153 struct objc_property_list *instanceProperties;
154 } category_t;
155
156 struct objc_super2 {
157 id receiver;
158 Class current_class;
159 };