-
Notifications
You must be signed in to change notification settings - Fork 496
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
Selector Signal Interoperability. #33
Conversation
IMP impl = method_getImplementation(method); | ||
|
||
if (impl != _objc_msgForward) { | ||
class_replaceMethod(object_getClass(self), aliasSelector, impl, method_getTypeEncoding(method)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks nasty, but there is no other reliable way to invoke a specific IMP with NSInvocation
in the standard toolbox.
Hmm, not ready yet. Had a problem with KVO.
|
b745261
to
84aa0a4
Compare
# Conflicts: # .travis.yml
Swift PR: ReactiveCocoa/ReactiveCocoa#3302 1. Improved performance in general method interception. 2. Reduced the overhead of computing selector aliases. 3. Reliable invocation of the next implementation of `-forwardInvocation:`, `-methodSignatureForSelector:` and `-respondsToSelector:` in the superclass hierarchy.
596b3fa
to
4dac92c
Compare
This reverts commit 83f16d5.
What's the state of this PR? |
@sprynmr Still working in testing progress |
Gonna port back a few changes from the Swift version. |
…-latest-complete-if-no-inner-signal-is-sent RACSignal+Operations: make -switchToLatest complete in all scenarios.
Included test cases from #27.
Terminology
Stated class: The class the instance meant to be at compile time.
Runtime subclass: The subclass of the perceived class created at runtime.
Summary
RAC now respects any further swizzling of
forwardInvocation:
,responseToSelector:
and method implementations made to the stated class.The PR also fixed a bug that caused an unrecognised selector exception when calling a setter that has been swizzled by KVO and subsequently by RAC.
Implementation Notes
Before the PR, RAC grabs the IMP of any selector by searching through the inheritance hierarchy, and aliases it or preserves it before replacing the IMP with
_objc_msgForward
or its custom implementation.After the PR, RAC generally does not alias any IMP, and relies on the ObjC runtime at the call time to resolve & call the method with an IMP swapping trick.
What's not solved
Interoperability with frameworks (except Cocoa KVO) that isa-swizzle an instance and provide custom implementations for the following selectors in the runtime subclass:
forwardInvocation:
,methodSignatureForSelector:
, andrespondsToSelector:
.Related: ReactiveCocoa/ReactiveCocoa#1561