mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-28 22:46:52 +08:00
Fix [JSValue ...] & [JSContext ...] access with custom JSC
Reviewed By: bnham Differential Revision: D3859956 fbshipit-source-id: 966aba9a267371eb553b8be574fa247b21930d1c
This commit is contained in:
committed by
Facebook Github Bot 0
parent
449c195941
commit
dfcfb90baa
@@ -27,6 +27,23 @@ RCT_EXTERN NSString *const RCTJSCThreadName;
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTJavaScriptContextCreatedNotification;
|
||||
|
||||
/**
|
||||
* A key to a reference to a JSContext class, held in the the current thread's
|
||||
* dictionary. The reference would point to the JSContext class in the JS VM
|
||||
* used in React (or ComponenetScript). It is recommended not to access it
|
||||
* through the thread's dictionary, but rather to use the `FBJSCurrentContext()`
|
||||
* accessor, which will return the current JSContext in the currently used VM.
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTFBJSContextClassKey;
|
||||
|
||||
/**
|
||||
* A key to a reference to a JSValue class, held in the the current thread's
|
||||
* dictionary. The reference would point to the JSValue class in the JS VM
|
||||
* used in React (or ComponenetScript). It is recommended not to access it
|
||||
* through the thread's dictionary, but rather to use the `FBJSValue()` accessor.
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTFBJSValueClassKey;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* May be used to pre-create the JSContext to make RCTJSCExecutor creation less costly.
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
NSString *const RCTJSCThreadName = @"com.facebook.react.JavaScript";
|
||||
NSString *const RCTJavaScriptContextCreatedNotification = @"RCTJavaScriptContextCreatedNotification";
|
||||
RCT_EXTERN NSString *const RCTFBJSContextClassKey = @"_RCTFBJSContextClassKey";
|
||||
RCT_EXTERN NSString *const RCTFBJSValueClassKey = @"_RCTFBJSValueClassKey";
|
||||
|
||||
static NSString *const RCTJSCProfilerEnabledDefaultsKey = @"RCTJSCProfilerEnabled";
|
||||
|
||||
@@ -346,6 +348,12 @@ static NSThread *newJavaScriptThread(void)
|
||||
installBasicSynchronousHooksOnContext(context);
|
||||
}
|
||||
|
||||
NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary];
|
||||
if (!threadDictionary[RCTFBJSContextClassKey] || !threadDictionary[RCTFBJSValueClassKey]) {
|
||||
threadDictionary[RCTFBJSContextClassKey] = self->_jscWrapper->JSContext;
|
||||
threadDictionary[RCTFBJSValueClassKey] = self->_jscWrapper->JSValue;
|
||||
}
|
||||
|
||||
__weak RCTJSCExecutor *weakSelf = self;
|
||||
|
||||
context[@"nativeRequireModuleConfig"] = ^NSArray *(NSString *moduleName) {
|
||||
|
||||
Reference in New Issue
Block a user