mirror of
https://github.com/status-im/react-native.git
synced 2025-02-04 13:44:04 +00:00
[ReactNative] Avoid method clashing on categories
Summary: @public Include `js_name` and `__LINE__` on exported methods' generated names + use the method implementation instead of `objc_msgSend` on the bridge, so it still works in case of clashing. Test Plan: Everything still working, otherwise it'd crash at startup.
This commit is contained in:
parent
efd386eba2
commit
d270dca210
@ -496,7 +496,8 @@ static RCTSparseArray *RCTExportedMethodsByModuleID(void)
|
||||
Method method = methods[i];
|
||||
SEL selector = method_getName(method);
|
||||
if ([NSStringFromSelector(selector) hasPrefix:@"__rct_export__"]) {
|
||||
NSArray *entries = ((NSArray *(*)(id, SEL))objc_msgSend)(moduleClass, selector);
|
||||
IMP imp = method_getImplementation(method);
|
||||
NSArray *entries = ((NSArray *(*)(id, SEL))imp)(moduleClass, selector);
|
||||
RCTModuleMethod *moduleMethod =
|
||||
[[RCTModuleMethod alloc] initWithObjCMethodName:entries[1]
|
||||
JSMethodName:entries[0]
|
||||
@ -1018,7 +1019,7 @@ RCT_INNER_BRIDGE_ONLY(_invokeAndProcessModule:(NSString *)module method:(NSStrin
|
||||
|
||||
if ([module conformsToProtocol:@protocol(RCTFrameUpdateObserver)]) {
|
||||
[_frameUpdateObservers addObject:module];
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ extern const dispatch_queue_t RCTJSThread;
|
||||
* Like RCT_EXTERN_REMAP_METHOD, but allows setting a custom JavaScript name.
|
||||
*/
|
||||
#define RCT_EXTERN_REMAP_METHOD(js_name, method) \
|
||||
+ (NSArray *)RCT_CONCAT(__rct_export__, __COUNTER__) { \
|
||||
+ (NSArray *)RCT_CONCAT(__rct_export__, RCT_CONCAT(js_name, RCT_CONCAT(__LINE__, __COUNTER__))) { \
|
||||
return @[@#js_name, @#method]; \
|
||||
} \
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user