Skip to content

Commit

Permalink
Added arm64 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dodikk committed Nov 11, 2013
1 parent 619450c commit 6f6d5f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Source/OCMock.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -922,11 +922,11 @@
030EF0E614632FF700B04273 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
DSTROOT = /tmp/OCMockLib.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCMockLib/OCMockLib-Prefix.pch";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Versions/C\"",
Expand All @@ -943,11 +943,11 @@
030EF0E714632FF700B04273 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)";
DSTROOT = /tmp/OCMockLib.dst;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "OCMockLib/OCMockLib-Prefix.pch";
IPHONEOS_DEPLOYMENT_TARGET = 5.0;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"\"$(SYSTEM_LIBRARY_DIR)/Frameworks/Foundation.framework/Versions/C\"",
Expand Down
9 changes: 8 additions & 1 deletion Source/OCMock/OCPartialMockObject.m
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,20 @@ - (void)setupForwarderForSelector:(SEL)selector
Method originalMethod = class_getInstanceMethod([self mockedClass], selector);
IMP originalImp = method_getImplementation(originalMethod);

IMP forwarderImp;

#if defined(__LP64__) && __LP64__

This comment has been minimized.

Copy link
@carllindberg

carllindberg Nov 11, 2013

This is incorrect for x86_64; this change is specific to arm64.

This comment has been minimized.

Copy link
@dodikk

dodikk Nov 12, 2013

Author Owner

Still, I did not manage to compile the library with class_getMethodImplementation_stret() for x86_64.
Not sure how to fix that properly.

This comment has been minimized.

Copy link
@carllindberg

carllindberg Nov 12, 2013

Interesting. I was pretty sure I had done that previously at least on MacOS 10.8, as I tested that. Were you using 10.9? The function is only marked OBJC_ARM64_UNAVAILABLE in the iOS headers which implies it's there on other platforms. What is it marked as in the 10.9 headers? (I don't have that available at the moment.)

I have incorporated this particular fix in my erikdoe#44 pull request as well; thought I had tested that on x86_64 too.

forwarderImp = class_getMethodImplementation(subclass, @selector(aMethodThatMustNotExist));
#else
NSMethodSignature *signature = [[self mockedClass] instanceMethodSignatureForSelector:selector];
// TODO: below we shouldn't really use getTypeEncoding because that doesn't work for methods implemented with -forwardingTargetForSelector:
IMP forwarderImp;


if([signature usesSpecialStructureReturn])
forwarderImp = class_getMethodImplementation_stret(subclass, @selector(aMethodThatMustNotExist));
else
forwarderImp = class_getMethodImplementation(subclass, @selector(aMethodThatMustNotExist));
#endif
class_addMethod(subclass, method_getName(originalMethod), forwarderImp, method_getTypeEncoding(originalMethod));

SEL aliasSelector = NSSelectorFromString([OCMRealMethodAliasPrefix stringByAppendingString:NSStringFromSelector(selector)]);
Expand Down

0 comments on commit 6f6d5f4

Please sign in to comment.