ObjFW  Diff

Differences From Artifact [c072b00a16]:

To Artifact [958e60e586]:


27
28
29
30
31
32
33
34
35
36

37
38
39
40
41
42
43
#ifdef OF_APPLE_RUNTIME
# include <dlfcn.h>
#endif

#import "OFObject.h"
#import "OFArray.h"
#import "OFLocalization.h"
#import "OFTimer.h"
#import "OFRunLoop.h"
#import "OFThread.h"


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







|


>







27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifdef OF_APPLE_RUNTIME
# include <dlfcn.h>
#endif

#import "OFObject.h"
#import "OFArray.h"
#import "OFLocalization.h"
#import "OFMethodSignature.h"
#import "OFRunLoop.h"
#import "OFThread.h"
#import "OFTimer.h"

#import "OFAllocFailedException.h"
#import "OFEnumerationMutationException.h"
#import "OFInitializationFailedException.h"
#import "OFInvalidArgumentException.h"
#import "OFMemoryNotPartOfObjectException.h"
#import "OFNotImplementedException.h"
93
94
95
96
97
98
99















100
101
102
103
104
105
106
#define PRE_MEM(mem) ((struct pre_mem *)(void *)((char *)mem - PRE_MEM_ALIGN))

static struct {
	Class isa;
} allocFailedException;

uint32_t of_hash_seed;
















#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
static void
uncaughtExceptionHandler(id exception)
{
	OFString *description = [exception description];
	OFArray *backtrace = nil;







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







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#define PRE_MEM(mem) ((struct pre_mem *)(void *)((char *)mem - PRE_MEM_ALIGN))

static struct {
	Class isa;
} allocFailedException;

uint32_t of_hash_seed;

static const char *
typeEncodingForSelector(Class class, SEL selector)
{
#if defined(OF_OBJFW_RUNTIME)
	return class_getMethodTypeEncoding(class, selector);
#else
	Method m;

	if ((m = class_getInstanceMethod(class, selector)) == NULL)
		return NULL;

	return method_getTypeEncoding(m);
#endif
}

#if !defined(OF_APPLE_RUNTIME) || defined(__OBJC2__)
static void
uncaughtExceptionHandler(id exception)
{
	OFString *description = [exception description];
	OFArray *backtrace = nil;
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
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
383
384
385
386
387
388
389
390
}

+ (IMP)instanceMethodForSelector: (SEL)selector
{
	return class_getMethodImplementation(self, selector);
}

+ (const char *)typeEncodingForInstanceSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	return class_getMethodTypeEncoding(self, selector);
#else
	Method m;

	if ((m = class_getInstanceMethod(self, selector)) == NULL)
		return NULL;

	return method_getTypeEncoding(m);
#endif
}

+ (OFString *)description
{
	return [self className];
}

+ (IMP)replaceClassMethod: (SEL)selector
      withMethodFromClass: (Class)class
{
	IMP newImp;
	const char *typeEncoding;

	newImp = [class methodForSelector: selector];
	typeEncoding = [class typeEncodingForSelector: selector];

	return [self replaceClassMethod: selector
		     withImplementation: newImp
			   typeEncoding: typeEncoding];
}

+ (IMP)replaceInstanceMethod: (SEL)selector
	 withMethodFromClass: (Class)class
{
	IMP newImp;
	const char *typeEncoding;

	newImp = [class instanceMethodForSelector: selector];
	typeEncoding = [class typeEncodingForInstanceSelector: selector];

	return [self replaceInstanceMethod: selector
			withImplementation: newImp
			      typeEncoding: typeEncoding];
}

+ (IMP)replaceInstanceMethod: (SEL)selector
	  withImplementation: (IMP)implementation
		typeEncoding: (const char *)typeEncoding
{
	return class_replaceMethod(self, selector, implementation,
	    typeEncoding);
}

+ (IMP)replaceClassMethod: (SEL)selector
       withImplementation: (IMP)implementation
	     typeEncoding: (const char *)typeEncoding
{
	return class_replaceMethod(object_getClass(self), selector,
	    implementation, typeEncoding);
}

+ (void)inheritMethodsFromClass: (Class)class
{
	Class superclass = [self superclass];

	if ([self isSubclassOfClass: class])







|

<
|
<
<

|
|

|
<










<
<
|
|
|
|
<
<
<
|
<



<
<
|
|
<
<
<
<
<
<
<
<
<
<
<
<
|
<
<
<
<
<
<
<
<







332
333
334
335
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
}

+ (IMP)instanceMethodForSelector: (SEL)selector
{
	return class_getMethodImplementation(self, selector);
}

+ (OFMethodSignature *)instanceMethodSignatureForSelector: (SEL)selector
{

	const char *typeEncoding = typeEncodingForSelector(self, selector);



	if (typeEncoding == NULL)
		return nil;

	return [OFMethodSignature signatureWithObjCTypes: typeEncoding];

}

+ (OFString *)description
{
	return [self className];
}

+ (IMP)replaceClassMethod: (SEL)selector
      withMethodFromClass: (Class)class
{


	return class_replaceMethod(object_getClass(self), selector,
	    [class methodForSelector: selector],
	    typeEncodingForSelector(object_getClass(class), selector));
}





+ (IMP)replaceInstanceMethod: (SEL)selector
	 withMethodFromClass: (Class)class
{


	return class_replaceMethod(self, selector,
	    [class instanceMethodForSelector: selector],












	    typeEncodingForSelector(class, selector));








}

+ (void)inheritMethodsFromClass: (Class)class
{
	Class superclass = [self superclass];

	if ([self isSubclassOfClass: class])
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
							    object: object2
							   repeats: false]];

	objc_autoreleasePoolPop(pool);
}
#endif

- (const char *)typeEncodingForSelector: (SEL)selector
{
#if defined(OF_OBJFW_RUNTIME)
	return class_getMethodTypeEncoding(object_getClass(self), selector);
#else
	Method m;

	if ((m = class_getInstanceMethod(object_getClass(self),
	    selector)) == NULL)
		return NULL;

	return method_getTypeEncoding(m);
#endif
}

- (bool)isEqual: (id)object
{
	return (self == object);
}








|

|
|
<
<

<
|
|

|
<







760
761
762
763
764
765
766
767
768
769
770


771

772
773
774
775

776
777
778
779
780
781
782
							    object: object2
							   repeats: false]];

	objc_autoreleasePoolPop(pool);
}
#endif

- (OFMethodSignature *)methodSignatureForSelector: (SEL)selector
{
	const char *typeEncoding =
	    typeEncodingForSelector(object_getClass(self), selector);




	if (typeEncoding == NULL)
		return nil;

	return [OFMethodSignature signatureWithObjCTypes: typeEncoding];

}

- (bool)isEqual: (id)object
{
	return (self == object);
}