ObjFW  Diff

Differences From Artifact [3fb2c436d1]:

To Artifact [69ac875773]:


203
204
205
206
207
208
209























































210
211
212
213
214
215
216
{
#ifdef OF_APPLE_RUNTIME
	return class_getMethodImplementation(self, selector);
#else
	return method_get_imp(class_get_instance_method(self, selector));
#endif
}
























































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








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
{
#ifdef OF_APPLE_RUNTIME
	return class_getMethodImplementation(self, selector);
#else
	return method_get_imp(class_get_instance_method(self, selector));
#endif
}

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

	if ((method = class_getClassMethod(self, selector)) == NULL)
		@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)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	if ((oldimp = method_get_imp(method)) == (IMP)0 || newimp == (IMP)0)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	method->method_imp = newimp;

	/* Update the dtable if necessary */
	if (sarray_get_safe(self->class_pointer->dtable,
	    (sidx)method->method_name->sel_id))
		sarray_at_put_safe(self->class_pointer->dtable,
		    (sidx)method->method_name->sel_id, method->method_imp);

	return oldimp;
#endif
}

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

#ifdef OF_APPLE_RUNTIME
	newimp = method_getImplementation(class_getClassMethod(class,
	    selector));
#else
	/* The class method is the instance method of the meta class */
	newimp = method_get_imp(class_get_instance_method(class->class_pointer,
	    selector));
#endif

	return [self setImplementation: newimp
			forClassMethod: selector];
}

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

230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
	if ((oldimp = method_get_imp(method)) == (IMP)0 || newimp == (IMP)0)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	method->method_imp = newimp;

	/* Update the dtable if necessary */
	if (sarray_get_safe(((Class)self)->dtable,
	    (sidx)method->method_name->sel_id))
		sarray_at_put_safe(((Class)self)->dtable,
		    (sidx)method->method_name->sel_id, method->method_imp);

	return oldimp;
#endif
}

+  (IMP)replaceInstanceMethod: (SEL)selector







<
|
|







285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
300
	if ((oldimp = method_get_imp(method)) == (IMP)0 || newimp == (IMP)0)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	method->method_imp = newimp;

	/* Update the dtable if necessary */

	if (sarray_get_safe(self->dtable, (sidx)method->method_name->sel_id))
		sarray_at_put_safe(self->dtable,
		    (sidx)method->method_name->sel_id, method->method_imp);

	return oldimp;
#endif
}

+  (IMP)replaceInstanceMethod: (SEL)selector