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

Already on GitHub? Sign in to your account

Test uses of super #1

Open
robrix opened this Issue Oct 7, 2010 · 4 comments

Comments

Projects
None yet
2 participants
Owner

robrix commented Oct 7, 2010

Is special handling required for super? Specifically:

  1. In methods mixed into a class: a method in concrete protocol A calls some method on super; the protocol is mixed into class B; the method should call B’s superclass’ implementation, not A’s superclass (i.e. RXConcreteProtocol). @hatfinch suggests implementing -[RXConcreteProtocol forwardInvocation:] if necessary. objc_msgSendSuper appears to receive some precalculated information about the superclass as its first argument. If this is generated at runtime then no special handling is likely to be required, but if it’s generated at compile-time (which seems to be the case) then more effort is necessary.
  2. In methods calling a mixed-in method on their superclass. (I expect this to function correctly already, but it needs to be tested.)

Ideally this should function identically to any normal method in both cases.

h/t @hatfinch

Just looked into this again and discovered you need something like:

struct objc_super s = { self, [self superclass] };
objc_msgSendSuper(&s, @selector(foo));

Should be possible to use a trampoline and category on NSObject to achieve cleaner syntax, e.g.

[[self runtimeSuper] foo];

Owner

robrix commented Jul 27, 2011

Thanks!

Spoke too soon and was corrected by Apple's Runtime Wrangler:

http://lists.apple.com/archives/Objc-language/2011/Jul/msg00049.html

Owner

robrix commented Jul 27, 2011

block object IMPs sound like they might be promising.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment