ObjFW  Diff

Differences From Artifact [c64aa46779]:

To Artifact [e21e0eaee6]:


24
25
26
27
28
29
30

31
32
33
34
35
36
37

#include <unistd.h>

#include <assert.h>

#import "OFObject.h"
#import "OFArray.h"

#import "OFIntrospection.h"
#import "OFAutoreleasePool.h"

#import "OFAllocFailedException.h"
#import "OFEnumerationMutationException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"







>







24
25
26
27
28
29
30
31
32
33
34
35
36
37
38

#include <unistd.h>

#include <assert.h>

#import "OFObject.h"
#import "OFArray.h"
#import "OFSet.h"
#import "OFIntrospection.h"
#import "OFAutoreleasePool.h"

#import "OFAllocFailedException.h"
#import "OFEnumerationMutationException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
461
462
463
464
465
466
467

468
469
470







471
472
473
474
475
476
477
478



479
480
481
482




483
484
485
486
487
488
489
490
491
492
					      selector: _cmd];
#endif
}

+ (void)inheritInstanceMethodsFromClass: (Class)class
{
	OFAutoreleasePool *pool = [[OFAutoreleasePool alloc] init];

	OFIntrospection *introspection;
	OFMethod **cArray;
	size_t i, count;








	introspection = [OFIntrospection introspectionWithClass: class];
	cArray = [[introspection instanceMethods] cArray];
	count = [[introspection instanceMethods] count];

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




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





		[self addInstanceMethod: selector
		       withTypeEncoding: [cArray[i] typeEncoding]
			 implementation: implementation];
	}

	[pool release];
}

- init
{







>



>
>
>
>
>
>
>








>
>
>




>
>
>
>
|
|
|







462
463
464
465
466
467
468
469
470
471
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
					      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
{