mirror of
https://github.com/status-im/react-native.git
synced 2025-02-06 14:43:49 +00:00
Remove needless helper method
Summary: I think this obscures more than it helps. Remove it. Reviewed By: javache Differential Revision: D3528677 fbshipit-source-id: d90a636a6e34b66563d9a02e255c6ebc4cee1294
This commit is contained in:
parent
2b397c5094
commit
222060b218
@ -111,11 +111,6 @@ struct RandomAccessBundleStartupCode {
|
|||||||
|
|
||||||
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||||
|
|
||||||
- (JSGlobalContextRef)ctx
|
|
||||||
{
|
|
||||||
return _context.JSGlobalContextRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL)isValid
|
- (BOOL)isValid
|
||||||
{
|
{
|
||||||
return _context != nil;
|
return _context != nil;
|
||||||
@ -362,16 +357,16 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
strongSelf->_jscWrapper = RCTJSCWrapperCreate(strongSelf->_useCustomJSCLibrary);
|
strongSelf->_jscWrapper = RCTJSCWrapperCreate(strongSelf->_useCustomJSCLibrary);
|
||||||
[strongSelf->_performanceLogger markStopForTag:RCTPLJSCWrapperOpenLibrary];
|
[strongSelf->_performanceLogger markStopForTag:RCTPLJSCWrapperOpenLibrary];
|
||||||
|
|
||||||
|
JSContext *context = strongSelf.context.context;
|
||||||
|
|
||||||
if (strongSelf->_jscWrapper->configureJSContextForIOS != NULL) {
|
if (strongSelf->_jscWrapper->configureJSContextForIOS != NULL) {
|
||||||
NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
|
NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject];
|
||||||
RCTAssert(cachesPath != nil, @"cachesPath should not be nil");
|
RCTAssert(cachesPath != nil, @"cachesPath should not be nil");
|
||||||
if (cachesPath) {
|
if (cachesPath) {
|
||||||
strongSelf->_jscWrapper->configureJSContextForIOS(strongSelf.context.ctx, [cachesPath UTF8String]);
|
strongSelf->_jscWrapper->configureJSContextForIOS(context.JSGlobalContextRef, [cachesPath UTF8String]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Synchronous hooks:
|
|
||||||
JSContext *context = strongSelf.context.context;
|
|
||||||
[[self class] installSynchronousHooksOnContext:context];
|
[[self class] installSynchronousHooksOnContext:context];
|
||||||
|
|
||||||
context[@"nativeRequireModuleConfig"] = ^NSString *(NSString *moduleName) {
|
context[@"nativeRequireModuleConfig"] = ^NSString *(NSString *moduleName) {
|
||||||
@ -432,7 +427,7 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
RCTJSCWrapper *jscWrapper = strongSelf2->_jscWrapper;
|
RCTJSCWrapper *jscWrapper = strongSelf2->_jscWrapper;
|
||||||
JSStringRef execJSString = jscWrapper->JSStringCreateWithUTF8CString(sourceCode.UTF8String);
|
JSStringRef execJSString = jscWrapper->JSStringCreateWithUTF8CString(sourceCode.UTF8String);
|
||||||
JSStringRef jsURL = jscWrapper->JSStringCreateWithUTF8CString(sourceCodeURL.UTF8String);
|
JSStringRef jsURL = jscWrapper->JSStringCreateWithUTF8CString(sourceCodeURL.UTF8String);
|
||||||
jscWrapper->JSEvaluateScript(strongSelf2->_context.ctx, execJSString, NULL, jsURL, 0, NULL);
|
jscWrapper->JSEvaluateScript(strongSelf2->_context.context.JSGlobalContextRef, execJSString, NULL, jsURL, 0, NULL);
|
||||||
jscWrapper->JSStringRelease(jsURL);
|
jscWrapper->JSStringRelease(jsURL);
|
||||||
jscWrapper->JSStringRelease(execJSString);
|
jscWrapper->JSStringRelease(execJSString);
|
||||||
};
|
};
|
||||||
@ -566,9 +561,10 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
JSValueRef errorJSRef = NULL;
|
JSValueRef errorJSRef = NULL;
|
||||||
JSValueRef resultJSRef = NULL;
|
JSValueRef resultJSRef = NULL;
|
||||||
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
|
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
|
||||||
JSGlobalContextRef contextJSRef = jscWrapper->JSContextGetGlobalContext(strongSelf->_context.ctx);
|
JSGlobalContextRef ctx = strongSelf->_context.context.JSGlobalContextRef;
|
||||||
|
JSGlobalContextRef contextJSRef = jscWrapper->JSContextGetGlobalContext(ctx);
|
||||||
JSContext *context = strongSelf->_context.context;
|
JSContext *context = strongSelf->_context.context;
|
||||||
JSObjectRef globalObjectJSRef = jscWrapper->JSContextGetGlobalObject(strongSelf->_context.ctx);
|
JSObjectRef globalObjectJSRef = jscWrapper->JSContextGetGlobalObject(ctx);
|
||||||
|
|
||||||
// get the BatchedBridge object
|
// get the BatchedBridge object
|
||||||
JSValueRef batchedBridgeRef = strongSelf->_batchedBridgeRef;
|
JSValueRef batchedBridgeRef = strongSelf->_batchedBridgeRef;
|
||||||
@ -668,7 +664,8 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
|
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
|
||||||
JSStringRef execJSString = jscWrapper->JSStringCreateWithUTF8CString((const char *)script.bytes);
|
JSStringRef execJSString = jscWrapper->JSStringCreateWithUTF8CString((const char *)script.bytes);
|
||||||
JSStringRef bundleURL = jscWrapper->JSStringCreateWithUTF8CString(sourceURL.absoluteString.UTF8String);
|
JSStringRef bundleURL = jscWrapper->JSStringCreateWithUTF8CString(sourceURL.absoluteString.UTF8String);
|
||||||
JSValueRef result = jscWrapper->JSEvaluateScript(strongSelf->_context.ctx, execJSString, NULL, bundleURL, 0, &jsError);
|
JSGlobalContextRef ctx = strongSelf->_context.context.JSGlobalContextRef;
|
||||||
|
JSValueRef result = jscWrapper->JSEvaluateScript(ctx, execJSString, NULL, bundleURL, 0, &jsError);
|
||||||
jscWrapper->JSStringRelease(bundleURL);
|
jscWrapper->JSStringRelease(bundleURL);
|
||||||
jscWrapper->JSStringRelease(execJSString);
|
jscWrapper->JSStringRelease(execJSString);
|
||||||
|
|
||||||
@ -677,7 +674,7 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
if (onComplete) {
|
if (onComplete) {
|
||||||
NSError *error;
|
NSError *error;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
error = RCTNSErrorFromJSError(jscWrapper, strongSelf->_context.ctx, jsError);
|
error = RCTNSErrorFromJSError(jscWrapper, ctx, jsError);
|
||||||
}
|
}
|
||||||
onComplete(error);
|
onComplete(error);
|
||||||
}
|
}
|
||||||
@ -719,7 +716,8 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
|
|
||||||
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
|
RCTJSCWrapper *jscWrapper = strongSelf->_jscWrapper;
|
||||||
JSStringRef execJSString = jscWrapper->JSStringCreateWithCFString((__bridge CFStringRef)script);
|
JSStringRef execJSString = jscWrapper->JSStringCreateWithCFString((__bridge CFStringRef)script);
|
||||||
JSValueRef valueToInject = jscWrapper->JSValueMakeFromJSONString(strongSelf->_context.ctx, execJSString);
|
JSGlobalContextRef ctx = strongSelf->_context.context.JSGlobalContextRef;
|
||||||
|
JSValueRef valueToInject = jscWrapper->JSValueMakeFromJSONString(ctx, execJSString);
|
||||||
jscWrapper->JSStringRelease(execJSString);
|
jscWrapper->JSStringRelease(execJSString);
|
||||||
|
|
||||||
if (!valueToInject) {
|
if (!valueToInject) {
|
||||||
@ -733,9 +731,9 @@ static void RCTInstallJSCProfiler(RCTBridge *bridge, JSContextRef context)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSObjectRef globalObject = jscWrapper->JSContextGetGlobalObject(strongSelf->_context.ctx);
|
JSObjectRef globalObject = jscWrapper->JSContextGetGlobalObject(ctx);
|
||||||
JSStringRef JSName = jscWrapper->JSStringCreateWithCFString((__bridge CFStringRef)objectName);
|
JSStringRef JSName = jscWrapper->JSStringCreateWithCFString((__bridge CFStringRef)objectName);
|
||||||
jscWrapper->JSObjectSetProperty(strongSelf->_context.ctx, globalObject, JSName, valueToInject, kJSPropertyAttributeNone, NULL);
|
jscWrapper->JSObjectSetProperty(ctx, globalObject, JSName, valueToInject, kJSPropertyAttributeNone, NULL);
|
||||||
jscWrapper->JSStringRelease(JSName);
|
jscWrapper->JSStringRelease(JSName);
|
||||||
if (onComplete) {
|
if (onComplete) {
|
||||||
onComplete(nil);
|
onComplete(nil);
|
||||||
@ -764,14 +762,15 @@ static void executeRandomAccessModule(RCTJSCExecutor *executor, uint32_t moduleI
|
|||||||
JSStringRef code = jscWrapper->JSStringCreateWithUTF8CString(data.get());
|
JSStringRef code = jscWrapper->JSStringCreateWithUTF8CString(data.get());
|
||||||
JSValueRef jsError = NULL;
|
JSValueRef jsError = NULL;
|
||||||
JSStringRef sourceURL = jscWrapper->JSStringCreateWithUTF8CString(url);
|
JSStringRef sourceURL = jscWrapper->JSStringCreateWithUTF8CString(url);
|
||||||
JSValueRef result = jscWrapper->JSEvaluateScript(executor->_context.ctx, code, NULL, sourceURL, 0, &jsError);
|
JSGlobalContextRef ctx = executor->_context.context.JSGlobalContextRef;
|
||||||
|
JSValueRef result = jscWrapper->JSEvaluateScript(ctx, code, NULL, sourceURL, 0, &jsError);
|
||||||
|
|
||||||
jscWrapper->JSStringRelease(code);
|
jscWrapper->JSStringRelease(code);
|
||||||
jscWrapper->JSStringRelease(sourceURL);
|
jscWrapper->JSStringRelease(sourceURL);
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
RCTFatal(RCTNSErrorFromJSError(jscWrapper, executor->_context.ctx, jsError));
|
RCTFatal(RCTNSErrorFromJSError(jscWrapper, ctx, jsError));
|
||||||
[executor invalidate];
|
[executor invalidate];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -891,7 +890,7 @@ RCT_EXPORT_METHOD(setContextName:(nonnull NSString *)name)
|
|||||||
{
|
{
|
||||||
if (_jscWrapper->JSGlobalContextSetName != NULL) {
|
if (_jscWrapper->JSGlobalContextSetName != NULL) {
|
||||||
JSStringRef JSName = _jscWrapper->JSStringCreateWithCFString((__bridge CFStringRef)name);
|
JSStringRef JSName = _jscWrapper->JSStringCreateWithCFString((__bridge CFStringRef)name);
|
||||||
_jscWrapper->JSGlobalContextSetName(_context.ctx, JSName);
|
_jscWrapper->JSGlobalContextSetName(_context.context.JSGlobalContextRef, JSName);
|
||||||
_jscWrapper->JSStringRelease(JSName);
|
_jscWrapper->JSStringRelease(JSName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user