Skip to content

Commit

Permalink
Fix 64 bit usage
Browse files Browse the repository at this point in the history
  • Loading branch information
steipete committed May 10, 2014
1 parent c7f8839 commit f048a2e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Aspects.m
Original file line number Diff line number Diff line change
Expand Up @@ -236,16 +236,16 @@ static BOOL aspect_isMsgForwardIMP(IMP impl) {
}

static IMP aspect_getMsgForwardIMP(NSObject *self, SEL selector) {
BOOL methodReturnsStructValue = NO;
IMP msgForwardIMP = _objc_msgForward;
#if !defined(__arm64__)
// As an ugly internal runtime implementation detail in the 32bit runtime, we need to determine of the method we hook returns a struct or anything larger than id.
// https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/LowLevelABI/000-Introduction/introduction.html
// https://github.com/ReactiveCocoa/ReactiveCocoa/issues/783
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042e/IHI0042E_aapcs.pdf (Section 5.4)
Method method = class_getInstanceMethod(self.class, selector);
const char *encoding = method_getTypeEncoding(method);
methodReturnsStructValue = encoding[0] == _C_STRUCT_B;
if ( methodReturnsStructValue ) {
BOOL methodReturnsStructValue = encoding[0] == _C_STRUCT_B;
if (methodReturnsStructValue) {
@try {
NSUInteger valueSize = 0;
NSGetSizeAndAlignment(encoding, &valueSize, NULL);
Expand All @@ -255,8 +255,11 @@ static IMP aspect_getMsgForwardIMP(NSObject *self, SEL selector) {
}
} @catch (NSException *e) {}
}
if (methodReturnsStructValue) {
msgForwardIMP = (IMP)_objc_msgForward_stret;
}
#endif
return methodReturnsStructValue ? (IMP)_objc_msgForward_stret : _objc_msgForward;
return msgForwardIMP;
}

static void aspect_prepareClassAndHookSelector(NSObject *self, SEL selector, NSError **error) {
Expand Down

0 comments on commit f048a2e

Please sign in to comment.