mirror of
https://github.com/status-im/react-native.git
synced 2025-01-13 19:15:05 +00:00
Move initializedExecutorWithContextProvider API
Reviewed By: dcaspi Differential Revision: D4558591 fbshipit-source-id: 821d6a6d4e42d1c67559fde102a0558eb623733b
This commit is contained in:
parent
096acbd53d
commit
0c8e925a18
@ -44,28 +44,6 @@ RCT_EXTERN NSString *const RCTFBJSContextClassKey;
|
||||
*/
|
||||
RCT_EXTERN NSString *const RCTFBJSValueClassKey;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* May be used to pre-create the JSContext to make RCTJSCExecutor creation less costly.
|
||||
* Avoid using this; it's experimental and is not likely to be supported long-term.
|
||||
*/
|
||||
@interface RCTJSContextProvider : NSObject
|
||||
|
||||
- (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary
|
||||
tryBytecode:(BOOL)tryBytecode;
|
||||
|
||||
/**
|
||||
* Marks whether the provider uses the custom implementation of JSC and not the system one.
|
||||
*/
|
||||
@property (nonatomic, readonly, assign) BOOL useCustomJSCLibrary;
|
||||
|
||||
/**
|
||||
* Marks whether it is safe to try and run bytecode if given the choice.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL tryBytecode;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Uses a JavaScriptCore context as the execution engine.
|
||||
*/
|
||||
@ -104,14 +82,6 @@ RCT_EXTERN NSString *const RCTFBJSValueClassKey;
|
||||
- (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary
|
||||
tryBytecode:(BOOL)tryBytecode;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* Pass a RCTJSContextProvider object to use an NSThread/JSContext pair that have already been created.
|
||||
* The underlying JSContext will be returned in the JSContext pointer if it is non-NULL.
|
||||
*/
|
||||
+ (instancetype)initializedExecutorWithContextProvider:(RCTJSContextProvider *)JSContextProvider
|
||||
JSContext:(JSContext **)JSContext;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* synchronouslyExecuteApplicationScript:sourceURL:JSContext:error:
|
||||
@ -140,3 +110,32 @@ RCT_EXTERN NSString *const RCTFBJSValueClassKey;
|
||||
- (JSContext *)jsContext;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* May be used to pre-create the JSContext to make RCTJSCExecutor creation less costly.
|
||||
* Avoid using this; it's experimental and is not likely to be supported long-term.
|
||||
*/
|
||||
@interface RCTJSContextProvider : NSObject
|
||||
|
||||
- (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary
|
||||
tryBytecode:(BOOL)tryBytecode;
|
||||
|
||||
/**
|
||||
* Marks whether the provider uses the custom implementation of JSC and not the system one.
|
||||
*/
|
||||
@property (nonatomic, readonly, assign) BOOL useCustomJSCLibrary;
|
||||
|
||||
/**
|
||||
* Marks whether it is safe to try and run bytecode if given the choice.
|
||||
*/
|
||||
@property (nonatomic, readonly) BOOL tryBytecode;
|
||||
|
||||
/**
|
||||
* @experimental
|
||||
* Create an RCTJSCExecutor from an provider instance. This may only be called once.
|
||||
* The underlying JSContext will be returned in the JSContext pointer if it is non-NULL.
|
||||
*/
|
||||
- (RCTJSCExecutor *)createExecutorWithContext:(JSContext **)JSContext;
|
||||
|
||||
@end
|
||||
|
@ -92,11 +92,6 @@ struct RCTJSContextData {
|
||||
JSContext *context;
|
||||
};
|
||||
|
||||
@interface RCTJSContextProvider ()
|
||||
/** May only be called once, or deadlock will result. */
|
||||
- (RCTJSContextData)data;
|
||||
@end
|
||||
|
||||
@interface RCTJavaScriptContext : NSObject <RCTInvalidating>
|
||||
|
||||
@property (nonatomic, strong, readonly) JSContext *context;
|
||||
@ -258,16 +253,6 @@ static NSThread *newJavaScriptThread(void)
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (instancetype)initializedExecutorWithContextProvider:(RCTJSContextProvider *)JSContextProvider
|
||||
JSContext:(JSContext **)JSContext
|
||||
{
|
||||
const RCTJSContextData data = JSContextProvider.data;
|
||||
if (JSContext) {
|
||||
*JSContext = data.context;
|
||||
}
|
||||
return [[RCTJSCExecutor alloc] initWithJSContextData:data];
|
||||
}
|
||||
|
||||
- (instancetype)initWithJSContextData:(const RCTJSContextData &)data
|
||||
{
|
||||
if (self = [super init]) {
|
||||
@ -1051,4 +1036,14 @@ static NSData *loadRAMBundle(NSURL *sourceURL, NSError **error, RandomAccessBund
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
- (RCTJSCExecutor *)createExecutorWithContext:(JSContext **)JSContext
|
||||
{
|
||||
const RCTJSContextData data = self.data;
|
||||
if (JSContext) {
|
||||
*JSContext = data.context;
|
||||
}
|
||||
return [[RCTJSCExecutor alloc] initWithJSContextData:data];
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user