ObjFW  Diff

Differences From Artifact [6014bfe449]:

To Artifact [f90e9b8b92]:


15
16
17
18
19
20
21













22
23
24
25
26
27
28
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







+
+
+
+
+
+
+
+
+
+
+
+
+







 */

#import "OFObject.h"

@class OFString;
@class OFArray;
@class OFMutableArray;

enum {
	OF_PROPERTY_READONLY	=   0x01,
	OF_PROPERTY_ASSIGN	=   0x04,
	OF_PROPERTY_READWRITE	=   0x08,
	OF_PROPERTY_RETAIN	=   0x10,
	OF_PROPERTY_COPY	=   0x20,
	OF_PROPERTY_NONATOMIC	=   0x40,
	OF_PROPERTY_SYNTHESIZED	=  0x100,
	OF_PROPERTY_DYNAMIC	=  0x200,
	OF_PROPERTY_ATOMIC	=  0x400,
	OF_PROPERTY_WEAK	=  0x800
};

/*!
 * @brief A class for describing a method.
 */
@interface OFMethod: OFObject
{
	SEL _selector;
54
55
56
57
58
59
60



























































61
62
63
64
65
66
67
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







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







 * @brief Returns the type encoding for the method.
 *
 * @return The type encoding for the method
 */
- (const char*)typeEncoding;
@end

/*!
 * @brief A class for describing a property.
 */
@interface OFProperty: OFObject
{
	OFString *_name;
	unsigned _attributes;
	OFString *_getter, *_setter;
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy) OFString *name;
@property (readonly) unsigned attributes;
@property (readonly, copy) OFString *getter, *setter;
#endif

/*!
 * @brief Returns the name of the property.
 *
 * @return The name of the property
 */
- (OFString*)name;

/*!
 * @brief Returns the attributes of the property.
 *
 * The attributes are a bitmask with the following possible flags:@n
 * Flag                          | Description
 * ------------------------------|-------------------------------------
 * OF_PROPERTY_READONLY          | The property is declared `readonly`
 * OF_PROPERTY_READWRITE         | The property is declared `readwrite`
 * OF_PROPERTY_ASSIGN            | The property is declared `assign`
 * OF_PROPERTY_RETAIN            | The property is declared `retain`
 * OF_PROPERTY_COPY              | The property is declared `copy`
 * OF_PROPERTY_NONATOMIC         | The property is declared `nonatomic`
 * OF_PROPERTY_ATOMIC            | The property is declared `atomic`
 * OF_PROPERTY_WEAK              | The property is declared `weak`
 * OF_PROPERTY_SYNTHESIZED       | The property is synthesized
 * OF_PROPERTY_DYNAMIC           | The property is dynamic
 *
 * @return The attributes of the property
 */
- (unsigned)attributes;

/*!
 * @brief Returns the name of the getter.
 *
 * @return The name of the getter
 */
- (OFString*)getter;

/*!
 * @brief Returns the name of the setter.
 *
 * @return The name of the setter
 */
- (OFString*)setter;
@end

/*!
 * @brief A class for describing an instance variable.
 */
@interface OFInstanceVariable: OFObject
{
	OFString *_name;
	const char *_typeEncoding;
99
100
101
102
103
104
105
106

107
108

109
110
111
112
113
114

115
116
117
118
119
120
121
171
172
173
174
175
176
177

178


179

180
181
182
183
184
185
186
187
188
189
190
191
192







-
+
-
-
+
-





+







/*!
 * @brief A class for introspecting classes.
 */
@interface OFIntrospection: OFObject
{
	OFMutableArray *_classMethods;
	OFMutableArray *_instanceMethods;
	OFMutableArray *_instanceVariables;
	OFMutableArray *_properties;
#ifdef OF_HAVE_PROPERTIES
	OFMutableArray *_properties;
	OFMutableArray *_instanceVariables;
#endif
}

#ifdef OF_HAVE_PROPERTIES
@property (readonly, copy) OFArray *classMethods;
@property (readonly, copy) OFArray *instanceMethods;
@property (readonly, copy) OFArray *properties;
@property (readonly, copy) OFArray *instanceVariables;
#endif

/*!
 * @brief Creates a new introspection for the specified class.
 *
 * @return A new, autoreleased introspection for the specified class
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
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
240
241
242
243
244

245
246
247
248
249
250







-
+






-
+




+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+


-
+





 * @return An initialized OFIntrospection
 */
- initWithClass: (Class)class_;

/*!
 * @brief Returns the class methods of the class.
 *
 * @return An array of OFMethods
 * @return An array of objects of class @ref OFMethod
 */
- (OFArray*)classMethods;

/*!
 * @brief Returns the instance methods of the class.
 *
 * @return An array of OFMethods
 * @return An array of objects of class @ref OFMethod
 */
- (OFArray*)instanceMethods;

/*!
 * @brief Returns the properties of the class.
 *
 * @warning **Do not rely on this, as this behaves differently depending on the
 *	    compiler and ABI used!**
 *
 * @warning For the ObjFW ABI, Clang only emits data for property introspection
 *	    if `@``synthesize` or `@``dynamic` has been used on the property,
 *	    not if the property has only been implemented by methods. Using
 *	    `@``synthesize` and manually implementing the methods works,
 *	    though.
 *
 * @warning For the Apple ABI, Clang and GCC both emit data for property
 *	    introspection for every property that has been declared using
 *	    `@``property`, even if no `@``synchronize` or `@``dynamic` has been
 *	    used.
 *
 * @warning GCC does not emit any data for property introspection for the GNU
 *	    ABI.
 *
 * @return An array of objects of class @ref OFProperty
 */
- (OFArray*)properties;

/*!
 * @brief Returns the instance variables of the class.
 *
 * @return An array of OFInstanceVariables
 * @return An array of objects of class @ref OFInstanceVariable
 */
- (OFArray*)instanceVariables;

/* TODO: protocols */
@end