steipete/Aspects — pull request #18 by steipete (2014-05-12 08:12:50+00:00)
Title: Use trampolines to allow hooking methods multiple times per class hierarchy.

WIP: This still misses the assembly trampoline code for x86_64.

This fixes #2, #11 and is an alternative take on #13.
(actually my second one, after I gave up on the alloc swizzling approach.)

I don't like the fact that this requires custom assembly, but once you understand what happens here, it's really not all that scary and easily portable to new platforms. Apple basically does the same internally with their `imp_implementationWithBlock()` method.

The trampolines allow us to rename each hooked method, which then allows us to identify what IMP is actually called here, solving the super-problem when dealing with NSInvocation.

Also pining @OliverLetterer: Is the shout-out in the readme under Credits enough? Or should I add your name to the MIT license as well?

There's a lot of potential here, since this is the proper fix for the subclassing problem and a starting point to explore more wide usage, like using point-cut expression language (#10).