ObjFW  Check-in [012c6b5786]

Overview
Comment:Make +[resolve{Class,Instance}Method:] return BOOL

Other runtimes expect it to be BOOL, not bool.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 012c6b57864a78e68459d211e6fb3005d7f903176007f3128b211976b0107aab
User & Date: js on 2017-05-28 11:24:35
Other Links: manifest | tags
Context
2017-05-28
12:54
Only use AmigaDOS directly when not using ixemul check-in: 4258b6f227 user: js tags: trunk
11:24
Make +[resolve{Class,Instance}Method:] return BOOL check-in: 012c6b5786 user: js tags: trunk
10:29
ofzip: Fix typo in help check-in: f9c3b3d45f user: js tags: trunk
Changes

Modified src/OFObject.h from [6e202ea9b1] to [9973173cd1].

585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
 * @brief Try to resolve the specified class method.
 *
 * This method is called if a class method was not found, so that an
 * implementation can be provided at runtime.
 *
 * @return Whether the method has been added to the class
 */
+ (bool)resolveClassMethod: (SEL)selector;

/*!
 * @brief Try to resolve the specified instance method.
 *
 * This method is called if an instance method was not found, so that an
 * implementation can be provided at runtime.
 *
 * @return Whether the method has been added to the class
 */
+ (bool)resolveInstanceMethod: (SEL)selector;

/*!
 * @brief Returns the class.
 *
 * This method exists so that classes can be used in collections requiring
 * conformance to the OFCopying protocol.
 *







|









|







585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
 * @brief Try to resolve the specified class method.
 *
 * This method is called if a class method was not found, so that an
 * implementation can be provided at runtime.
 *
 * @return Whether the method has been added to the class
 */
+ (BOOL)resolveClassMethod: (SEL)selector;

/*!
 * @brief Try to resolve the specified instance method.
 *
 * This method is called if an instance method was not found, so that an
 * implementation can be provided at runtime.
 *
 * @return Whether the method has been added to the class
 */
+ (BOOL)resolveInstanceMethod: (SEL)selector;

/*!
 * @brief Returns the class.
 *
 * This method exists so that classes can be used in collections requiring
 * conformance to the OFCopying protocol.
 *

Modified src/OFObject.m from [a28a9b391e] to [a3ec40e380].

471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
		free(methodList);
	}
#endif

	[self inheritMethodsFromClass: [class superclass]];
}

+ (bool)resolveClassMethod: (SEL)selector
{
	return false;
}

+ (bool)resolveInstanceMethod: (SEL)selector
{
	return false;
}

- init
{
	return self;
}








|

|


|

|







471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
		free(methodList);
	}
#endif

	[self inheritMethodsFromClass: [class superclass]];
}

+ (BOOL)resolveClassMethod: (SEL)selector
{
	return NO;
}

+ (BOOL)resolveInstanceMethod: (SEL)selector
{
	return NO;
}

- init
{
	return self;
}

Modified tests/ForwardingTests.m from [cf2379237f] to [505a6ff075].

64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
static void
test(id self, SEL _cmd)
{
	success = true;
}

@implementation ForwardingTest
+ (bool)resolveClassMethod: (SEL)selector
{
	forwardings++;

	if (sel_isEqual(selector, @selector(test))) {
		[self replaceClassMethod: @selector(test)
		      withImplementation: (IMP)test
			    typeEncoding: "v#:"];
		return true;
	}

	return false;
}

+ (bool)resolveInstanceMethod: (SEL)selector
{
	forwardings++;

	if (sel_isEqual(selector, @selector(test))) {
		[self replaceInstanceMethod: @selector(test)
			 withImplementation: (IMP)test
			       typeEncoding: "v@:"];
		return true;
	}

	return false;
}

- (id)forwardingTargetForSelector: (SEL)selector
{
	/*
	 * Do some useless calculations in as many registers as possible to
	 * check if the arguments are properly saved and restored.







|







|


|


|







|


|







64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
static void
test(id self, SEL _cmd)
{
	success = true;
}

@implementation ForwardingTest
+ (BOOL)resolveClassMethod: (SEL)selector
{
	forwardings++;

	if (sel_isEqual(selector, @selector(test))) {
		[self replaceClassMethod: @selector(test)
		      withImplementation: (IMP)test
			    typeEncoding: "v#:"];
		return YES;
	}

	return NO;
}

+ (BOOL)resolveInstanceMethod: (SEL)selector
{
	forwardings++;

	if (sel_isEqual(selector, @selector(test))) {
		[self replaceInstanceMethod: @selector(test)
			 withImplementation: (IMP)test
			       typeEncoding: "v@:"];
		return YES;
	}

	return NO;
}

- (id)forwardingTargetForSelector: (SEL)selector
{
	/*
	 * Do some useless calculations in as many registers as possible to
	 * check if the arguments are properly saved and restored.