ObjFW  Check-in [54e971a3a6]

Overview
Comment:Improve method replacing when using the Apple runtime.

This prevents replacing the method of a superclass when the method is
not implemented in the class and creates a new method instead.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 54e971a3a65d27573520d4b72a30fec56cae18ef36190b5d03b603252669057c
User & Date: js on 2010-04-01 20:57:30
Other Links: manifest | tags
Context
2010-04-01
22:15
Use __asm__ instead of asm to prevent conflicts. check-in: 3588e29b9c user: js tags: trunk
20:57
Improve method replacing when using the Apple runtime. check-in: 54e971a3a6 user: js tags: trunk
2010-03-19
22:05
Better values for OFMutableDictionary resizing. check-in: 6c93ca551a user: js tags: trunk
Changes

Modified src/OFObject.m from [4bc8df336e] to [95a9dc34dd].

224
225
226
227
228
229
230
231
232
233


234
235
236
237
238
239
240
241
242
243
244
224
225
226
227
228
229
230



231
232




233
234
235
236
237
238
239







-
-
-
+
+
-
-
-
-







#endif
}

+ (IMP)setImplementation: (IMP)newimp
	  forClassMethod: (SEL)selector
{
#ifdef OF_APPLE_RUNTIME
	Method method;

	if ((method = class_getClassMethod(self, selector)) == NULL)
	return class_replaceMethod(self->isa, selector, newimp,
	    method_getTypeEncoding(class_getClassMethod(self, selector)));
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	return method_setImplementation(method, newimp);
#else
	Method_t method;
	IMP oldimp;

	/* The class method is the instance method of the meta class */
	if ((method = class_get_instance_method(self->class_pointer,
	    selector)) == NULL)
279
280
281
282
283
284
285
286
287
288


289
290
291
292
293
294
295
296
297
298
299
274
275
276
277
278
279
280



281
282




283
284
285
286
287
288
289







-
-
-
+
+
-
-
-
-







			forClassMethod: selector];
}

+ (IMP)setImplementation: (IMP)newimp
       forInstanceMethod: (SEL)selector
{
#ifdef OF_APPLE_RUNTIME
	Method method;

	if ((method = class_getInstanceMethod(self, selector)) == NULL)
	return class_replaceMethod(self, selector, newimp,
	    method_getTypeEncoding(class_getInstanceMethod(self, selector)));
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	return method_setImplementation(method, newimp);
#else
	Method_t method = class_get_instance_method(self, selector);
	IMP oldimp;

	if (method == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];