ObjFW  Diff

Differences From Artifact [6537d810e0]:

To Artifact [3cd936beff]:


472
473
474
475
476
477
478
479
480
481
482
483
484
485
486








487







488
489
490
491
492
493
494























495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517


518
519
520
521
522
523
524
	    typeEncoding);
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
#endif
}

+ (void)inheritInstanceMethodsFromClass: (Class)class
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];
	OFMutableSet *set = [OFMutableSet set];
	OFIntrospection *introspection;
	OFMethod **cArray;
	size_t i, count;









	introspection = [OFIntrospection introspectionWithClass: self];







	cArray = [[introspection instanceMethods] cArray];
	count = [[introspection instanceMethods] count];

	for (i = 0; i < count; i++)
		[set addObject: [cArray[i] name]];

	introspection = [OFIntrospection introspectionWithClass: class];























	cArray = [[introspection instanceMethods] cArray];
	count = [[introspection instanceMethods] count];

	for (i = 0; i < count; i++) {
		SEL selector;
		IMP implementation;

		if ([set containsObject: [cArray[i] name]])
			continue;

		selector = [cArray[i] selector];
		implementation = [class instanceMethodForSelector: selector];

		if ([self respondsToSelector: selector])
			[self setImplementation: implementation
			      forInstanceMethod: selector];
		else
			[self addInstanceMethod: selector
			       withTypeEncoding: [cArray[i] typeEncoding]
				 implementation: implementation];
	}

	[pool release];


}

- init
{
	return self;
}








|

|
|




>
>
>
>
>
>
>
>

>
>
>
>
>
>
>




|


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







|





|









>
>







472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
	    typeEncoding);
#else
	@throw [OFNotImplementedException newWithClass: self
					      selector: _cmd];
#endif
}

+ (void)inheritMethodsFromClass: (Class)class
{
	OFAutoreleasePool *pool;
	OFMutableSet *classMethods, *instanceMethods;
	OFIntrospection *introspection;
	OFMethod **cArray;
	size_t i, count;

	if ([self isSubclassOfClass: class])
		return;

	pool = [[OFAutoreleasePool alloc] init];

	classMethods = [OFMutableSet set];
	instanceMethods = [OFMutableSet set];

	introspection = [OFIntrospection introspectionWithClass: self];

	cArray = [[introspection classMethods] cArray];
	count = [[introspection classMethods] count];

	for (i = 0; i < count; i++)
		[classMethods addObject: [cArray[i] name]];

	cArray = [[introspection instanceMethods] cArray];
	count = [[introspection instanceMethods] count];

	for (i = 0; i < count; i++)
		[instanceMethods addObject: [cArray[i] name]];

	introspection = [OFIntrospection introspectionWithClass: class];

	cArray = [[introspection classMethods] cArray];
	count = [[introspection classMethods] count];

	for (i = 0; i < count; i++) {
		SEL selector;
		IMP implementation;

		if ([classMethods containsObject: [cArray[i] name]])
			continue;

		selector = [cArray[i] selector];
		implementation = [class methodForSelector: selector];

		if ([self respondsToSelector: selector])
			[self setImplementation: implementation
				 forClassMethod: selector];
		else
			[self addClassMethod: selector
			    withTypeEncoding: [cArray[i] typeEncoding]
			      implementation: implementation];
	}

	cArray = [[introspection instanceMethods] cArray];
	count = [[introspection instanceMethods] count];

	for (i = 0; i < count; i++) {
		SEL selector;
		IMP implementation;

		if ([instanceMethods containsObject: [cArray[i] name]])
			continue;

		selector = [cArray[i] selector];
		implementation = [class instanceMethodForSelector: selector];

		if ([self instancesRespondToSelector: selector])
			[self setImplementation: implementation
			      forInstanceMethod: selector];
		else
			[self addInstanceMethod: selector
			       withTypeEncoding: [cArray[i] typeEncoding]
				 implementation: implementation];
	}

	[pool release];

	[self inheritMethodsFromClass: [class superclass]];
}

- init
{
	return self;
}