Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

objc_msgSend() does work on ARM64 when cast correctly. #86

Closed
jonathandann opened this issue Nov 27, 2014 · 3 comments
Closed

objc_msgSend() does work on ARM64 when cast correctly. #86

jonathandann opened this issue Nov 27, 2014 · 3 comments

Comments

@jonathandann
Copy link

+[GRMustacheKeyAccess valueForMustacheKey:inFoundationCollectionObject:] does work if you cast the call to objc_msgSend() properly.

WWDC 2014, Session 417, "What's new in LLVM".
"objc_msgSend without a typecast is usually an error."

ENABLE_STRICT_OBJC_MSGSEND can help

@groue
Copy link
Owner

groue commented Nov 28, 2014

That's very interesting, thank you @jonathandann! Let's dive into this session 😄

@groue
Copy link
Owner

groue commented Nov 28, 2014

Inspired by this WWDC session, the following code snippets actually do successfully execute NSObject's implementation of valueForKey: on NSArray, NSSet and NSOrderedSet (this trick helps us evaluating tags like {{ items.count }}):

// Using class_getMethodImplementation
typedef id (*send_type)(id, SEL, id);
send_type func = (send_type)class_getMethodImplementation([NSObject class], @selector(valueForKey:));
return func(object, @selector(valueForKey:), key);

// Using objc_msgSendSuper
typedef id (*send_type)(struct objc_super *, SEL, id key);
send_type func = (send_type)objc_msgSendSuper;
return func(&(struct objc_super){ .receiver = object, .super_class = [NSObject class] }, @selector(valueForKey:), key);

I still have to test them on arm64, and pick my favorite option :-)

This would be a nice fix to issue #70, much better than the current one (https://github.com/groue/GRMustache/blob/master/src/classes/Rendering/GRMustacheKeyAccess.m#L204-L337)

@groue
Copy link
Owner

groue commented Oct 16, 2015

This issue will become obsolete with #100.

@groue groue closed this as completed Oct 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants