Skip to content
This repository has been archived by the owner on Feb 2, 2021. It is now read-only.

Commit

Permalink
Fix objc_msgSend invocations.
Browse files Browse the repository at this point in the history
  • Loading branch information
ExtremeMan committed Jun 30, 2017
1 parent f3de5e9 commit 65def83
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Common/DuplicateTestNameFix.m
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ static void ProcessTestSuite(id testSuite)

static id TestProbe_specifiedTestSuite(Class cls, SEL cmd)
{
id testSuite = objc_msgSend(cls,
id testSuite = ((id (*)(id, SEL))objc_msgSend)(cls,
sel_registerName([[NSString stringWithFormat:@"__%s_specifiedTestSuite",
class_getName(cls)] UTF8String]));
ProcessTestSuite(testSuite);
Expand All @@ -115,7 +115,7 @@ static id TestProbe_specifiedTestSuite(Class cls, SEL cmd)

static id TestSuite_allTests(Class cls, SEL cmd)
{
id testSuite = objc_msgSend(cls,
id testSuite = ((id (*)(id, SEL))objc_msgSend)(cls,
sel_registerName([[NSString stringWithFormat:@"__%s_allTests",
class_getName(cls)] UTF8String]));
ProcessTestSuite(testSuite);
Expand Down
21 changes: 13 additions & 8 deletions otest-shim/otest-shim/otest-shim.m
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static void XCTestLog_testSuiteDidStart(id self, SEL sel, XCTestSuiteRun *run)

static void XCTestLog_testSuiteWillStart(id self, SEL sel, XCTestSuite *suite)
{
XCTestLog_testSuiteDidStart(self, sel, objc_msgSend(suite, @selector(testRun)));
XCTestLog_testSuiteDidStart(self, sel, ((XCTestSuiteRun *(*)(id, SEL))objc_msgSend)(suite, @selector(testRun)));
}

static void SenTestLog_testSuiteDidStart(id self, SEL sel, NSNotification *notification)
Expand Down Expand Up @@ -153,7 +153,7 @@ static void XCTestLog_testSuiteDidStop(id self, SEL sel, XCTestSuiteRun *run)

static void XCTestLog_testSuiteDidFinish(id self, SEL sel, XCTestSuite *suite)
{
XCTestLog_testSuiteDidStop(self, sel, objc_msgSend(suite, @selector(testRun)));
XCTestLog_testSuiteDidStop(self, sel, ((XCTestSuiteRun *(*)(id, SEL))objc_msgSend)(suite, @selector(testRun)));
}

static void SenTestLog_testSuiteDidStop(id self, SEL sel, NSNotification *notification)
Expand Down Expand Up @@ -191,7 +191,7 @@ static void XCTestLog_testCaseDidStart(id self, SEL sel, XCTestCaseRun *run)

static void XCTestLog_testCaseWillStart(id self, SEL sel, XCTestCase *testCase)
{
XCTestLog_testCaseDidStart(self, sel, objc_msgSend(testCase, @selector(testRun)));
XCTestLog_testCaseDidStart(self, sel, ((XCTestCaseRun *(*)(id, SEL))objc_msgSend)(testCase, @selector(testRun)));
}

static void SenTestLog_testCaseDidStart(id self, SEL sel, NSNotification *notification)
Expand Down Expand Up @@ -230,7 +230,7 @@ static void XCTestLog_testCaseDidStop(id self, SEL sel, XCTestCaseRun *run)

static void XCTestLog_testCaseDidFinish(id self, SEL sel, XCTestCase *testCase)
{
XCTestLog_testCaseDidStop(self, sel, objc_msgSend(testCase, @selector(testRun)));
XCTestLog_testCaseDidStop(self, sel, ((XCTestCaseRun *(*)(id, SEL))objc_msgSend)(testCase, @selector(testRun)));
}

static void SenTestLog_testCaseDidStop(id self, SEL sel, NSNotification *notification)
Expand Down Expand Up @@ -291,7 +291,12 @@ static void XCTestLog_testCaseDidFail(id self, SEL sel, XCTestCaseRun *run, NSSt

static void XCTestLog_testCaseDidFailWithDescription(id self, SEL sel, XCTestCase *testCase, NSString *description, NSString *file, NSUInteger line)
{
XCTestLog_testCaseDidFail(self, sel, objc_msgSend(testCase, @selector(testRun)), description, file, line);
XCTestLog_testCaseDidFail(self,
sel,
((XCTestCaseRun *(*)(id, SEL))objc_msgSend)(testCase, @selector(testRun)),
description,
file,
line);
}

static void SenTestLog_testCaseDidFail(id self, SEL sel, NSNotification *notification)
Expand Down Expand Up @@ -359,14 +364,14 @@ static void XCPerformTestWithSuppressedExpectedAssertionFailures(id self, SEL or
dispatch_resume(source);

// Call through original implementation
objc_msgSend(self, origSel, arg1);
((void (*)(id, SEL, id))objc_msgSend)(self, origSel, arg1);

dispatch_source_cancel(source);
dispatch_release(source);
dispatch_release(queue);
} else {
// Call through original implementation
objc_msgSend(self, origSel, arg1);
((void (*)(id, SEL, id))objc_msgSend)(self, origSel, arg1);
}

// The assertion handler hasn't been touched for our test, so we can safely remove it.
Expand Down Expand Up @@ -605,7 +610,7 @@ static void Swizzle()
static id NSBundle_loadAndReturnError(id self, SEL sel, NSError **error)
{
SEL originalSelector = @selector(__NSBundle_loadAndReturnError:);
id result = objc_msgSend(self, originalSelector, error);
id result = ((id (*)(id, SEL, NSError **))objc_msgSend)(self, originalSelector, error);
SwizzleXCTestMethodsIfAvailable();
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion xctool/xctool-tests/FakeTaskManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static id NSTask_allocWithZone(id cls, SEL sel, NSZone *zone)
cls != objc_getClass("FakeTask")) {
return [FakeTask allocWithZone:zone];
} else {
return objc_msgSend(cls, @selector(__NSTask_allocWithZone:), zone);
return ((id (*)(id, SEL, NSZone *))objc_msgSend)(cls, @selector(__NSTask_allocWithZone:), zone);
}
}

Expand Down

0 comments on commit 65def83

Please sign in to comment.