ObjFW  Check-in [252833ad30]

Overview
Comment:Only allow subclasses for +[replace*Method:with*MethodFromClass:].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 252833ad304a2a7a59359ac24ce4ad3b33a599d354fb291f1ba53e67e8acb74d
User & Date: js on 2010-05-04 12:25:05
Other Links: manifest | tags
Context
2010-05-05
17:21
Rename method replacement methods - the old names were too long. check-in: bce7bbddf4 user: js tags: trunk
2010-05-04
12:25
Only allow subclasses for +[replace*Method:with*MethodFromClass:]. check-in: 252833ad30 user: js tags: trunk
2010-05-02
16:16
Win32 compatibility for the new file operations. check-in: 66b3f09fc0 user: js tags: trunk
Changes

Modified src/OFObject.m from [7e95f15bf5] to [721d4fa462].

263
264
265
266
267
268
269




270
271
272
273
274
275
276
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280







+
+
+
+







}

+  (IMP)replaceClassMethod: (SEL)selector
  withClassMethodFromClass: (Class)class;
{
	IMP newimp;

	if (![class isSubclassOfClass: self])
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

#if defined(OF_OBJFW_RUNTIME)
	newimp = objc_get_class_method(class, selector);
#elif defined(OF_APPLE_RUNTIME)
	newimp = method_getImplementation(class_getClassMethod(class,
	    selector));
#else
	/* The class method is the instance method of the meta class */
314
315
316
317
318
319
320




321
322
323
324
325
326
327
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335







+
+
+
+







#endif
}

+  (IMP)replaceInstanceMethod: (SEL)selector
  withInstanceMethodFromClass: (Class)class;
{
	IMP newimp;

	if (![class isSubclassOfClass: self])
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

#if defined(OF_OBJFW_RUNTIME)
	newimp = objc_get_instance_method(class, selector);
#elif defined(OF_APPLE_RUNTIME)
	newimp = class_getMethodImplementation(class, selector);
#else
	newimp = method_get_imp(class_get_instance_method(class, selector));