ObjFW  Diff

Differences From Artifact [e350530160]:

To Artifact [c563fc5512]:


336
337
338
339
340
341
342
343
344
345
346
347

348
349
350

351

352


353

354

355
356
357
358

359



360

361

362
363
364
365
366
367
368
369
370
	if (newImp == (IMP)0 || !class_respondsToSelector(self->isa, selector))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	return objc_replace_class_method(self, selector, newImp);
#elif defined(OF_OLD_GNU_RUNTIME)
	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(((Class)self->class_pointer)->dtable,

	    (sidx)method->method_name->sel_id))



		sarray_at_put_safe(((Class)self->class_pointer)->dtable,

		    (sidx)method->method_name->sel_id, method->method_imp);


	return oldImp;
#else
	Method method;

	if (newImp == (IMP)0 ||
	    (method = class_getClassMethod(self, selector)) == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];







|

<
|
|
>



>
|
>
|
>
>
|
>

>
|

|
|
>
|
>
>
>
|
>
|
>

|







336
337
338
339
340
341
342
343
344

345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
	if (newImp == (IMP)0 || !class_respondsToSelector(self->isa, selector))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	return objc_replace_class_method(self, selector, newImp);
#elif defined(OF_OLD_GNU_RUNTIME)
	Method_t method;
	MethodList_t iter;


	method = class_get_class_method(self->class_pointer, selector);

	if (newImp == (IMP)0 || method == METHOD_NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	for (iter = ((Class)self->class_pointer)->methods; iter != NULL;
	    iter = iter->method_next) {
		int i;

		for (i = 0; i < iter->method_count; i++)
			if (sel_eq(iter->method_list[i].method_name,
			    selector)) {
				IMP oldImp;

				oldImp = iter->method_list[i].method_imp;
				iter->method_list[i].method_imp = newImp;

				sarray_at_put_safe(
				    ((Class)self->class_pointer)->dtable,
				    (sidx)selector->sel_id, newImp);

				return oldImp;
			}
	}

	assert([self addClassMethod: selector
		   withTypeEncoding: method->method_types
		     implementation: newImp]);

	return (IMP)0;
#else
	Method method;

	if (newImp == (IMP)0 ||
	    (method = class_getClassMethod(self, selector)) == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];
399
400
401
402
403
404
405



406
407
408
409
410
411
412

413

414


415

416

417
418
419
420
421
422
423
424
425








426
427
428
429
430
431
432
#if defined(OF_OBJFW_RUNTIME)
	if (newImp == (IMP)0 || !class_respondsToSelector(self, selector))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	return objc_replace_instance_method(self, selector, newImp);
#elif defined(OF_OLD_GNU_RUNTIME)



	Method_t method = class_get_instance_method(self, selector);
	IMP oldImp;

	if (method == 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(((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;








#else
	Method method;

	if (newImp == (IMP)0 ||
	    (method = class_getInstanceMethod(self, selector)) == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];







>
>
>
|
<

|



>
|
>
|
>
>
|
>

>
|

<
<
<
|
|

|
>
>
>
>
>
>
>
>







411
412
413
414
415
416
417
418
419
420
421

422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
#if defined(OF_OBJFW_RUNTIME)
	if (newImp == (IMP)0 || !class_respondsToSelector(self, selector))
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	return objc_replace_instance_method(self, selector, newImp);
#elif defined(OF_OLD_GNU_RUNTIME)
	Method_t method;
	MethodList_t iter;

	method = class_get_instance_method(self, selector);


	if (newImp == (IMP)0 || method == METHOD_NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];

	for (iter = ((Class)self)->methods; iter != NULL;
	    iter = iter->method_next) {
		int i;

		for (i = 0; i < iter->method_count; i++)
			if (sel_eq(iter->method_list[i].method_name,
			    selector)) {
				IMP oldImp;

				oldImp = iter->method_list[i].method_imp;
				iter->method_list[i].method_imp = newImp;




				sarray_at_put_safe(((Class)self)->dtable,
				    (sidx)selector->sel_id, newImp);

				return oldImp;
			}
	}

	assert([self addInstanceMethod: selector
		      withTypeEncoding: method->method_types
			implementation: newImp]);

	return (IMP)0;
#else
	Method method;

	if (newImp == (IMP)0 ||
	    (method = class_getInstanceMethod(self, selector)) == NULL)
		@throw [OFInvalidArgumentException newWithClass: self
						       selector: _cmd];