-
Notifications
You must be signed in to change notification settings - Fork 119
/
properties.h
239 lines (230 loc) · 5.43 KB
/
properties.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#include "visibility.h"
#include <assert.h>
enum PropertyAttributeKind
{
/**
* Property has no attributes.
*/
OBJC_PR_noattr = 0x00,
/**
* The property is declared read-only.
*/
OBJC_PR_readonly = (1<<0),
/**
* The property has a getter.
*/
OBJC_PR_getter = (1<<1),
/**
* The property has assign semantics.
*/
OBJC_PR_assign = (1<<2),
/**
* The property is declared read-write.
*/
OBJC_PR_readwrite = (1<<3),
/**
* Property has retain semantics.
*/
OBJC_PR_retain = (1<<4),
/**
* Property has copy semantics.
*/
OBJC_PR_copy = (1<<5),
/**
* Property is marked as non-atomic.
*/
OBJC_PR_nonatomic = (1<<6),
/**
* Property has setter.
*/
OBJC_PR_setter = (1<<7)
};
/**
* Flags in the second attributes field in declared properties.
* Note: This field replaces the old 'is synthesized' field and so these values
* are shifted left one from their values in clang.
*/
enum PropertyAttributeKind2
{
/**
* No extended attributes.
*/
OBJC_PR_noextattr = 0,
/**
* The property is synthesized. This has no meaning in properties on
* protocols.
*/
OBJC_PR_synthesized = (1<<0),
/**
* The property is dynamic (i.e. the implementation is inherited or
* provided at run time).
*/
OBJC_PR_dynamic = (1<<1),
/**
* This property belongs to a protocol.
*/
OBJC_PR_protocol = OBJC_PR_synthesized | OBJC_PR_dynamic,
/**
* The property is atomic.
*/
OBJC_PR_atomic = (1<<2),
/**
* The property value is a zeroing weak reference.
*/
OBJC_PR_weak = (1<<3),
/**
* The property value is strong (retained). Currently, this is equivalent
* to the strong attribute.
*/
OBJC_PR_strong = (1<<4),
/**
* The property value is just copied.
*/
OBJC_PR_unsafe_unretained = (1<<5),
};
/**
* Structure used for property enumeration. Note that property enumeration is
* currently quite broken on OS X, so achieving full compatibility there is
* impossible. Instead, we strive to achieve compatibility with the
* documentation.
*/
// begin: objc_property
struct objc_property
{
/**
* Name of this property.
*/
const char *name;
/**
* The type encoding of the property.
*/
const char *attributes;
/**
* The type encoding of the property.
*/
const char *type;
/**
* The selector for the getter for this property.
*/
SEL getter;
/**
* The selector for the setter for this property.
*/
SEL setter;
};
// end: objc_property
/**
* GNUstep v1 ABI version of `struct objc_property`
*/
struct objc_property_gsv1
{
/**
* Name of this property.
*/
const char *name;
/**
* Attributes for this property. Made by ORing together
* PropertyAttributeKinds.
*/
char attributes;
/**
* Flag set if the property is synthesized.
*/
char attributes2;
/**
* Padding field. These were implicit in the structure field alignment
* (four more on 64-bit platforms), but we'll make them explicit now for
* future use.
*/
char unused1;
/**
* More padding.
*/
char unused2;
/**
* Name of the getter for this property.
*/
const char *getter_name;
/**
* Type encoding for the get method for this property.
*/
const char *getter_types;
/**
* Name of the set method for this property.
*/
const char *setter_name;
/**
* Type encoding of the setter for this property.
*/
const char *setter_types;
};
/**
* List of property introspection data.
*/
struct objc_property_list_gsv1
{
/**
* Number of properties in this array.
*/
int count;
/*
* The next property in a linked list.
*/
struct objc_property_list *next;
/**
* List of properties.
*/
struct objc_property_gsv1 properties[];
};
/**
* List of property introspection data.
*/
// begin: objc_property_list
struct objc_property_list
{
/**
* Number of properties in this array.
*/
int count;
/**
* Size of `struct objc_property`. This allows the runtime to
* transparently support newer ABIs with more fields in the property
* metadata.
*/
int size;
/*
* The next property in a linked list.
*/
struct objc_property_list *next;
/**
* List of properties.
*/
struct objc_property properties[];
};
// end: objc_property_list
/**
* Returns a pointer to the property inside the `objc_property` structure.
* This structure is designed to allow the compiler to add other fields without
* breaking the ABI, so although the `properties` field appears to be an array
* of `objc_property` structures, it may be an array of some future version of
* `objc_property` structs, which have fields appended that this version of the
* runtime does not know about.
*/
static inline struct objc_property *property_at_index(struct objc_property_list *l, int i)
{
assert(l->size >= sizeof(struct objc_property));
return (struct objc_property*)(((char*)l->properties) + (i * l->size));
}
/**
* Constructs a property description from a list of attributes, returning the
* instance variable name via the third parameter.
*/
PRIVATE struct objc_property propertyFromAttrs(const objc_property_attribute_t *attributes,
unsigned int attributeCount,
const char *name);
/**
* Constructs and installs a property attribute string from the property
* attributes and, optionally, an ivar string.
*/
PRIVATE const char *constructPropertyAttributes(objc_property_t property,
const char *iVarName);