ObjFW
OFIntrospection.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
3  * Jonathan Schleifer <js@heap.zone>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 
19 OF_ASSUME_NONNULL_BEGIN
20 
21 @class OFArray OF_GENERIC(ObjectType);
22 @class OFMutableArray OF_GENERIC(ObjectType);
23 @class OFString;
24 
25 enum {
26  OF_PROPERTY_READONLY = 0x01,
27  OF_PROPERTY_ASSIGN = 0x04,
28  OF_PROPERTY_READWRITE = 0x08,
29  OF_PROPERTY_RETAIN = 0x10,
30  OF_PROPERTY_COPY = 0x20,
31  OF_PROPERTY_NONATOMIC = 0x40,
32  OF_PROPERTY_SYNTHESIZED = 0x100,
33  OF_PROPERTY_DYNAMIC = 0x200,
34  OF_PROPERTY_ATOMIC = 0x400,
35  OF_PROPERTY_WEAK = 0x800
36 };
37 
43 @interface OFMethod: OFObject
44 {
45  SEL _selector;
46  OFString *_name;
47  const char *_typeEncoding;
48 }
49 
53 @property (readonly, nonatomic) SEL selector;
54 
58 @property (readonly, nonatomic) OFString *name;
59 
63 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) const char *typeEncoding;
64 
65 - init OF_UNAVAILABLE;
66 @end
67 
73 @interface OFProperty: OFObject
74 {
75  OFString *_name;
76  unsigned _attributes;
77  OFString *_Nullable _getter, *_Nullable _setter;
78 }
79 
83 @property (readonly, nonatomic) OFString *name;
84 
102 @property (readonly, nonatomic) unsigned attributes;
103 
107 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *getter;
108 
112 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *setter;
113 
114 - init OF_UNAVAILABLE;
115 @end
116 
123 {
124  OFString *_name;
125  const char *_typeEncoding;
126  ptrdiff_t _offset;
127 }
128 
132 @property (readonly, nonatomic) OFString *name;
133 
137 @property (readonly, nonatomic) ptrdiff_t offset;
138 
142 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) const char *typeEncoding;
143 
144 - init OF_UNAVAILABLE;
145 @end
146 
153 {
154  OFMutableArray OF_GENERIC(OFMethod *) *_classMethods;
155  OFMutableArray OF_GENERIC(OFMethod *) *_instanceMethods;
156  OFMutableArray OF_GENERIC(OFProperty *) *_properties;
157  OFMutableArray OF_GENERIC(OFInstanceVariable *) *_instanceVariables;
158 }
159 
163 @property (readonly, nonatomic) OFArray OF_GENERIC(OFMethod *) *classMethods;
164 
168 @property (readonly, nonatomic) OFArray OF_GENERIC(OFMethod *) *instanceMethods;
169 
190 @property (readonly, nonatomic) OFArray OF_GENERIC(OFProperty *) *properties;
191 
195 @property (readonly, nonatomic)
197 
198 /* TODO: protocols */
199 
205 + (instancetype)introspectionWithClass: (Class)class_;
206 
207 - init OF_UNAVAILABLE;
208 
215 - initWithClass: (Class)class_ OF_DESIGNATED_INITIALIZER;
216 @end
217 
218 OF_ASSUME_NONNULL_END
A class for describing an instance variable.
Definition: OFIntrospection.h:122
OFArray * instanceMethods
Definition: OFIntrospection.h:168
OFArray * properties
Definition: OFIntrospection.h:190
SEL selector
Definition: OFIntrospection.h:53
A class for handling strings.
Definition: OFString.h:114
A class for describing a method.
Definition: OFIntrospection.h:43
id init()
Initializes an already allocated object.
Definition: OFObject.m:488
A class for introspecting classes.
Definition: OFIntrospection.h:152
OFArray * classMethods
Definition: OFIntrospection.h:163
readonly
Definition: OFIntrospection.h:63
OFArray * instanceVariables
Definition: OFIntrospection.h:196
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
An abstract class for storing objects in an array.
Definition: OFArray.h:89
OFString * name
Definition: OFIntrospection.h:58
An abstract class for storing, adding and removing objects in an array.
Definition: OFMutableArray.h:40
A class for describing a property.
Definition: OFIntrospection.h:73