ObjFW  Check-in [2dec88a9d5]

Overview
Comment:runtime: More consistency in the API.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 2dec88a9d57cee089ab4388018be5954271a9fd58c9e2c1824046ead31efad09
User & Date: js on 2013-12-20 00:14:15
Other Links: manifest | tags
Context
2013-12-20
00:20
Fix make recursion for bridge. check-in: 3f3151bd81 user: js tags: trunk
00:14
runtime: More consistency in the API. check-in: 2dec88a9d5 user: js tags: trunk
2013-12-19
22:21
runtime: Add objc_{get,copy}ClassList(). check-in: 035fa09270 user: js tags: trunk
Changes

Modified src/OFObject.m from [704b6761d2] to [9bd5d20560].

367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
{
	return class_getMethodImplementation(self, selector);
}

+ (const char*)typeEncodingForInstanceSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	return objc_get_type_encoding(self, selector);
#else
	Method m;

	if ((m = class_getInstanceMethod(self, selector)) == NULL)
		return NULL;

	return method_getTypeEncoding(m);







|







367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
{
	return class_getMethodImplementation(self, selector);
}

+ (const char*)typeEncodingForInstanceSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	return class_getMethodTypeEncoding(self, selector);
#else
	Method m;

	if ((m = class_getInstanceMethod(self, selector)) == NULL)
		return NULL;

	return method_getTypeEncoding(m);
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
	objc_autoreleasePoolPop(pool);
}
#endif

- (const char*)typeEncodingForSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	return objc_get_type_encoding(object_getClass(self), selector);
#else
	Method m;

	if ((m = class_getInstanceMethod(object_getClass(self),
	    selector)) == NULL)
		return NULL;








|







832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
	objc_autoreleasePoolPop(pool);
}
#endif

- (const char*)typeEncodingForSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	return class_getMethodTypeEncoding(object_getClass(self), selector);
#else
	Method m;

	if ((m = class_getInstanceMethod(object_getClass(self),
	    selector)) == NULL)
		return NULL;

Modified src/runtime/class.m from [0bf2860357] to [a168991e4e].

614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
IMP
class_getMethodImplementation(Class cls, SEL sel)
{
	return objc_sparsearray_get(cls->dtable, (uint32_t)sel->uid);
}

const char*
objc_get_type_encoding(Class cls, SEL sel)
{
	struct objc_method_list *ml;
	struct objc_category **cats;
	unsigned int i;

	objc_global_mutex_lock();








|







614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
IMP
class_getMethodImplementation(Class cls, SEL sel)
{
	return objc_sparsearray_get(cls->dtable, (uint32_t)sel->uid);
}

const char*
class_getMethodTypeEncoding(Class cls, SEL sel)
{
	struct objc_method_list *ml;
	struct objc_category **cats;
	unsigned int i;

	objc_global_mutex_lock();

651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
				}
			}
		}
	}

	objc_global_mutex_unlock();

	if (cls->superclass != NULL)
		return objc_get_type_encoding(cls->superclass, sel);

	return NULL;
}

IMP
class_replaceMethod(Class cls, SEL sel, IMP newimp, const char *types)
{







|
|







651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
				}
			}
		}
	}

	objc_global_mutex_unlock();

	if (cls->superclass != Nil)
		return class_getMethodTypeEncoding(cls->superclass, sel);

	return NULL;
}

IMP
class_replaceMethod(Class cls, SEL sel, IMP newimp, const char *types)
{

Modified src/runtime/runtime.h from [eb0edb48c5] to [bd61ad8aad].

35
36
37
38
39
40
41





42
43
44
45
46
47

48
49
50
51
52
53
54
#endif

#if __has_attribute(objc_root_class)
# define OBJC_ROOT_CLASS __attribute__((objc_root_class))
#else
# define OBJC_ROOT_CLASS
#endif






typedef struct objc_class* Class;
typedef struct objc_object* id;
typedef const struct objc_selector* SEL;
typedef signed char BOOL;
typedef id (*IMP)(id, SEL, ...);


struct objc_class {
	Class isa;
	Class superclass;
	const char *name;
	unsigned long version;
	unsigned long info;







>
>
>
>
>






>







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
#endif

#if __has_attribute(objc_root_class)
# define OBJC_ROOT_CLASS __attribute__((objc_root_class))
#else
# define OBJC_ROOT_CLASS
#endif

#define Nil (Class)0
#define nil (id)0
#define YES (BOOL)1
#define NO  (BOOL)0

typedef struct objc_class* Class;
typedef struct objc_object* id;
typedef const struct objc_selector* SEL;
typedef signed char BOOL;
typedef id (*IMP)(id, SEL, ...);
typedef void (*objc_uncaught_exception_handler)(id);

struct objc_class {
	Class isa;
	Class superclass;
	const char *name;
	unsigned long version;
	unsigned long info;
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
	struct objc_method_list *class_methods;
	struct objc_protocol_list *protocols;
};

struct objc_ivar {
	const char *name;
	const char *type;
	unsigned offset;
};

struct objc_ivar_list {
	unsigned count;
	struct objc_ivar ivars[1];
};


#define OBJC_PROPERTY_READONLY	0x01
#define OBJC_PROPERTY_GETTER	0x02
#define OBJC_PROPERTY_ASSIGN	0x04
#define OBJC_PROPERTY_READWRITE	0x08
#define OBJC_PROPERTY_RETAIN	0x10
#define OBJC_PROPERTY_COPY	0x20
#define OBJC_PROPERTY_NONATOMIC	0x40
#define OBJC_PROPERTY_SETTER	0x80


struct objc_property {
	const char *name;
	unsigned char attributes;
	BOOL synthesized;
	struct {
		const char *name;
		const char *type;
	} getter, setter;
};

struct objc_property_list {
	unsigned count;
	struct objc_property_list *next;
	struct objc_property properties[1];
};

#ifdef __OBJC__
OBJC_ROOT_CLASS
@interface Protocol







|



|



>
|
|
|
|
|
|
|
|
>












|







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
	struct objc_method_list *class_methods;
	struct objc_protocol_list *protocols;
};

struct objc_ivar {
	const char *name;
	const char *type;
	unsigned int offset;
};

struct objc_ivar_list {
	unsigned int count;
	struct objc_ivar ivars[1];
};

enum objc_property_attributes {
	OBJC_PROPERTY_READONLY	= 0x01,
	OBJC_PROPERTY_GETTER	= 0x02,
	OBJC_PROPERTY_ASSIGN	= 0x04,
	OBJC_PROPERTY_READWRITE	= 0x08,
	OBJC_PROPERTY_RETAIN	= 0x10,
	OBJC_PROPERTY_COPY	= 0x20,
	OBJC_PROPERTY_NONATOMIC	= 0x40,
	OBJC_PROPERTY_SETTER	= 0x80
};

struct objc_property {
	const char *name;
	unsigned char attributes;
	BOOL synthesized;
	struct {
		const char *name;
		const char *type;
	} getter, setter;
};

struct objc_property_list {
	unsigned int count;
	struct objc_property_list *next;
	struct objc_property properties[1];
};

#ifdef __OBJC__
OBJC_ROOT_CLASS
@interface Protocol
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

struct objc_protocol_list {
	struct objc_protocol_list *next;
	long count;
	OBJC_UNSAFE_UNRETAINED Protocol *list[1];
};

#define Nil (Class)0
#define nil (id)0
#define YES (BOOL)1
#define NO  (BOOL)0

typedef void (*objc_uncaught_exception_handler)(id);

#ifdef __cplusplus
extern "C" {
#endif
extern SEL sel_registerName(const char*);
extern const char* sel_getName(SEL);
extern bool sel_isEqual(SEL, SEL);
extern id objc_lookUpClass(const char*);
extern id objc_getClass(const char*);
extern id objc_getRequiredClass(const char*);
extern unsigned int objc_getClassList(Class*, unsigned int);
extern Class* objc_copyClassList(unsigned int*);
extern bool class_isMetaClass(Class);
extern const char* class_getName(Class);
extern Class class_getSuperclass(Class);
extern bool class_isKindOfClass(Class, Class);
extern unsigned long class_getInstanceSize(Class);
extern bool class_respondsToSelector(Class, SEL);
extern bool class_conformsToProtocol(Class, Protocol*);
extern IMP class_getMethodImplementation(Class, SEL);

extern IMP class_replaceMethod(Class, SEL, IMP, const char*);
extern const char* objc_get_type_encoding(Class, SEL);
extern Class object_getClass(id);
extern Class object_setClass(id, Class);
extern const char* object_getClassName(id);
extern IMP objc_msg_lookup(id, SEL);
extern IMP objc_msg_lookup_stret(id, SEL);
extern IMP objc_msg_lookup_super(struct objc_super*, SEL);
extern IMP objc_msg_lookup_super_stret(struct objc_super*, SEL);
extern const char* protocol_getName(Protocol*);
extern bool protocol_isEqual(Protocol*, Protocol*);
extern bool protocol_conformsToProtocol(Protocol*, Protocol*);
extern void objc_exit(void);
extern objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(
    objc_uncaught_exception_handler);
extern IMP (*objc_forward_handler)(id, SEL);
extern IMP (*objc_forward_handler_stret)(id, SEL);
extern id objc_autorelease(id);
extern void* objc_autoreleasePoolPush(void);
extern void objc_autoreleasePoolPop(void*);
extern id _objc_rootAutorelease(id);





#ifdef __cplusplus
}
#endif

#undef OBJC_UNSAFE_UNRETAINED
#undef OBJC_ROOT_CLASS

#endif







<
<
<
<
<
<
<



















>

<



<
<
<
<












>
>
>
>
>








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

struct objc_protocol_list {
	struct objc_protocol_list *next;
	long count;
	OBJC_UNSAFE_UNRETAINED Protocol *list[1];
};








#ifdef __cplusplus
extern "C" {
#endif
extern SEL sel_registerName(const char*);
extern const char* sel_getName(SEL);
extern bool sel_isEqual(SEL, SEL);
extern id objc_lookUpClass(const char*);
extern id objc_getClass(const char*);
extern id objc_getRequiredClass(const char*);
extern unsigned int objc_getClassList(Class*, unsigned int);
extern Class* objc_copyClassList(unsigned int*);
extern bool class_isMetaClass(Class);
extern const char* class_getName(Class);
extern Class class_getSuperclass(Class);
extern bool class_isKindOfClass(Class, Class);
extern unsigned long class_getInstanceSize(Class);
extern bool class_respondsToSelector(Class, SEL);
extern bool class_conformsToProtocol(Class, Protocol*);
extern IMP class_getMethodImplementation(Class, SEL);
extern const char* class_getMethodTypeEncoding(Class, SEL);
extern IMP class_replaceMethod(Class, SEL, IMP, const char*);

extern Class object_getClass(id);
extern Class object_setClass(id, Class);
extern const char* object_getClassName(id);




extern const char* protocol_getName(Protocol*);
extern bool protocol_isEqual(Protocol*, Protocol*);
extern bool protocol_conformsToProtocol(Protocol*, Protocol*);
extern void objc_exit(void);
extern objc_uncaught_exception_handler objc_setUncaughtExceptionHandler(
    objc_uncaught_exception_handler);
extern IMP (*objc_forward_handler)(id, SEL);
extern IMP (*objc_forward_handler_stret)(id, SEL);
extern id objc_autorelease(id);
extern void* objc_autoreleasePoolPush(void);
extern void objc_autoreleasePoolPop(void*);
extern id _objc_rootAutorelease(id);
/* Used by the compiler, but can be called manually. */
extern IMP objc_msg_lookup(id, SEL);
extern IMP objc_msg_lookup_stret(id, SEL);
extern IMP objc_msg_lookup_super(struct objc_super*, SEL);
extern IMP objc_msg_lookup_super_stret(struct objc_super*, SEL);
#ifdef __cplusplus
}
#endif

#undef OBJC_UNSAFE_UNRETAINED
#undef OBJC_ROOT_CLASS

#endif