ObjFW  Diff

Differences From Artifact [51e0fb0c89]:

To Artifact [c64aa46779]:


23
24
25
26
27
28
29


30
31
32
33
34
35
36
#include <string.h>

#include <unistd.h>

#include <assert.h>

#import "OFObject.h"


#import "OFAutoreleasePool.h"

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







>
>







23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <string.h>

#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"
#import "OFMemoryNotPartOfObjectException.h"
443
444
445
446
447
448
449






































450
451
452
453
454
455
456
						       selector: _cmd];

	newImp = [class instanceMethodForSelector: selector];

	return [self setImplementation: newImp
		     forInstanceMethod: selector];
}







































- init
{
	return self;
}

- (Class)class







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







445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
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
493
494
495
496
						       selector: _cmd];

	newImp = [class instanceMethodForSelector: selector];

	return [self setImplementation: newImp
		     forInstanceMethod: selector];
}

+ (BOOL)addInstanceMethod: (SEL)selector
	 withTypeEncoding: (const char*)typeEncoding
	   implementation: (IMP)implementation
{
#if defined(OF_APPLE_RUNTIME) || defined(OF_GNU_RUNTIME)
	return class_addMethod(self, selector, implementation, typeEncoding);
#elif defined(OF_OLD_GNU_RUNTIME)
	@throw [OFNotImplementedException newWithClass: isa
					      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
{
	return self;
}

- (Class)class