From 42a5568419fb1fea6ffdd59725f065949d799a7f Mon Sep 17 00:00:00 2001 From: Alexey Lang Date: Mon, 6 Jun 2016 11:10:24 -0700 Subject: [PATCH] Change API for using custom JSC Reviewed By: javache Differential Revision: D3392219 fbshipit-source-id: ae372dfe9ceab7f7c2da69c731515a05eb3b020a --- React/Executors/RCTJSCExecutor.h | 11 +++++------ React/Executors/RCTJSCExecutor.mm | 21 ++++++++------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/React/Executors/RCTJSCExecutor.h b/React/Executors/RCTJSCExecutor.h index f5b91bf8f..db690042e 100644 --- a/React/Executors/RCTJSCExecutor.h +++ b/React/Executors/RCTJSCExecutor.h @@ -31,18 +31,17 @@ RCT_EXTERN NSString *const RCTJavaScriptContextCreatedNotification; @interface RCTJSCExecutor : NSObject /** - * Sets a type of JSC library (system or custom) that's used - * to initialize RCTJSCWrapper. + * Returns whether executor uses custom JSC library. + * This value is used to initialize RCTJSCWrapper. * @default is NO. */ -+ (void)setUseCustomJSCLibrary:(BOOL)useCustomLibrary; +@property (nonatomic, readonly, assign) BOOL useCustomJSCLibrary; /** - * Gets a type of JSC library (system or custom) that's used + * Inits a new executor instance with given flag that's used * to initialize RCTJSCWrapper. - * @default is NO. */ -+ (BOOL)useCustomJSCLibrary; +- (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary; /** * Create a NSError from a JSError object. diff --git a/React/Executors/RCTJSCExecutor.mm b/React/Executors/RCTJSCExecutor.mm index 91e80d7b8..a65cd36c4 100644 --- a/React/Executors/RCTJSCExecutor.mm +++ b/React/Executors/RCTJSCExecutor.mm @@ -135,6 +135,7 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init) RandomAccessBundleData _randomAccessBundle; RCTJSCWrapper *_jscWrapper; + BOOL _useCustomJSCLibrary; } @synthesize valid = _valid; @@ -262,21 +263,15 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context) } } -static BOOL useCustomJSCLibrary = NO; - -+ (void)setUseCustomJSCLibrary:(BOOL)useCustomLibrary -{ - useCustomJSCLibrary = useCustomLibrary; -} - -+ (BOOL)useCustomJSCLibrary -{ - return useCustomJSCLibrary; -} - - (instancetype)init +{ + return [self initWithUseCustomJSCLibrary:NO]; +} + +- (instancetype)initWithUseCustomJSCLibrary:(BOOL)useCustomJSCLibrary { if (self = [super init]) { + _useCustomJSCLibrary = useCustomJSCLibrary; _valid = YES; _javaScriptThread = [[NSThread alloc] initWithTarget:[self class] @@ -333,7 +328,7 @@ static BOOL useCustomJSCLibrary = NO; return; } - strongSelf->_jscWrapper = RCTJSCWrapperCreate(useCustomJSCLibrary); + strongSelf->_jscWrapper = RCTJSCWrapperCreate(strongSelf->_useCustomJSCLibrary); }];