mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-30 05:55:48 +08:00
Replace -[RCTConvert folly_dynamic:] with direct calls to convertIdToFollyDynamic
Reviewed By: kathryngray Differential Revision: D5355734 fbshipit-source-id: 4ba1533b75c8e271a86a2d5cc3a3354e52f83db2
This commit is contained in:
committed by
Facebook Github Bot
parent
dc97e3fb4e
commit
f1cbb11620
@@ -29,6 +29,7 @@
|
|||||||
#import <React/RCTProfile.h>
|
#import <React/RCTProfile.h>
|
||||||
#import <React/RCTRedBox.h>
|
#import <React/RCTRedBox.h>
|
||||||
#import <React/RCTUtils.h>
|
#import <React/RCTUtils.h>
|
||||||
|
#import <React/RCTFollyConvert.h>
|
||||||
#import <cxxreact/CxxNativeModule.h>
|
#import <cxxreact/CxxNativeModule.h>
|
||||||
#import <cxxreact/Instance.h>
|
#import <cxxreact/Instance.h>
|
||||||
#import <cxxreact/JSBundleType.h>
|
#import <cxxreact/JSBundleType.h>
|
||||||
@@ -1005,7 +1006,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||||||
|
|
||||||
if (self->_reactInstance) {
|
if (self->_reactInstance) {
|
||||||
self->_reactInstance->callJSFunction([module UTF8String], [method UTF8String],
|
self->_reactInstance->callJSFunction([module UTF8String], [method UTF8String],
|
||||||
[RCTConvert folly_dynamic:args ?: @[]]);
|
convertIdToFollyDynamic(args ?: @[]));
|
||||||
|
|
||||||
// ensureOnJavaScriptThread may execute immediately, so use jsMessageThread, to make sure
|
// ensureOnJavaScriptThread may execute immediately, so use jsMessageThread, to make sure
|
||||||
// the block is invoked after callJSFunction
|
// the block is invoked after callJSFunction
|
||||||
@@ -1041,7 +1042,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||||||
RCTProfileEndFlowEvent();
|
RCTProfileEndFlowEvent();
|
||||||
|
|
||||||
if (self->_reactInstance) {
|
if (self->_reactInstance) {
|
||||||
self->_reactInstance->callJSCallback([cbID unsignedLongLongValue], [RCTConvert folly_dynamic:args ?: @[]]);
|
self->_reactInstance->callJSCallback([cbID unsignedLongLongValue], convertIdToFollyDynamic(args ?: @[]));
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_jsThread->runOnQueue([this, json]{
|
m_jsThread->runOnQueue([this, json]{
|
||||||
m_delegate->callNativeModules(*this, [RCTConvert folly_dynamic:json], true);
|
m_delegate->callNativeModules(*this, convertIdToFollyDynamic(json), true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ using namespace facebook::react;
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
folly::dynamic args = [RCTConvert folly_dynamic:arguments];
|
folly::dynamic args = convertIdToFollyDynamic(arguments);
|
||||||
args.resize(args.size() - _method->callbacks);
|
args.resize(args.size() - _method->callbacks);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -9,21 +9,14 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#import <React/RCTConvert.h>
|
#import <JavaScriptCore/JavaScriptCore.h>
|
||||||
#include <JavaScriptCore/JavaScriptCore.h>
|
|
||||||
#include <cxxreact/JSCExecutor.h>
|
#import <cxxreact/JSCExecutor.h>
|
||||||
#include <folly/dynamic.h>
|
#import <jschelpers/JavaScriptCore.h>
|
||||||
#include <jschelpers/JavaScriptCore.h>
|
|
||||||
|
|
||||||
@class RCTBridge;
|
@class RCTBridge;
|
||||||
@class RCTModuleData;
|
@class RCTModuleData;
|
||||||
|
|
||||||
@interface RCTConvert (folly)
|
|
||||||
|
|
||||||
+ (folly::dynamic)folly_dynamic:(id)json;
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace react {
|
namespace react {
|
||||||
|
|
||||||
|
|||||||
@@ -12,32 +12,13 @@
|
|||||||
#import <React/RCTFollyConvert.h>
|
#import <React/RCTFollyConvert.h>
|
||||||
#import <React/RCTModuleData.h>
|
#import <React/RCTModuleData.h>
|
||||||
#import <React/RCTUtils.h>
|
#import <React/RCTUtils.h>
|
||||||
#include <cxxreact/CxxNativeModule.h>
|
#import <cxxreact/CxxNativeModule.h>
|
||||||
#include <jschelpers/Value.h>
|
#import <jschelpers/Value.h>
|
||||||
|
|
||||||
#import "DispatchMessageQueueThread.h"
|
#import "DispatchMessageQueueThread.h"
|
||||||
#import "RCTCxxModule.h"
|
#import "RCTCxxModule.h"
|
||||||
#import "RCTNativeModule.h"
|
#import "RCTNativeModule.h"
|
||||||
|
|
||||||
using namespace facebook::react;
|
|
||||||
|
|
||||||
@implementation RCTConvert (folly)
|
|
||||||
|
|
||||||
+ (folly::dynamic)folly_dynamic:(id)json;
|
|
||||||
{
|
|
||||||
if (json == nil || json == (id)kCFNull) {
|
|
||||||
return nullptr;
|
|
||||||
} else {
|
|
||||||
folly::dynamic dyn = convertIdToFollyDynamic(json);
|
|
||||||
if (dyn == nil) {
|
|
||||||
RCTAssert(false, @"RCTConvert input json is of an impossible type");
|
|
||||||
}
|
|
||||||
return dyn;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@end
|
|
||||||
|
|
||||||
namespace facebook {
|
namespace facebook {
|
||||||
namespace react {
|
namespace react {
|
||||||
|
|
||||||
@@ -109,7 +90,8 @@ static NSError *errorWithException(const std::exception &e)
|
|||||||
return [NSError errorWithDomain:RCTErrorDomain code:1 userInfo:errorInfo];
|
return [NSError errorWithDomain:RCTErrorDomain code:1 userInfo:errorInfo];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSError *tryAndReturnError(const std::function<void()>& func) {
|
NSError *tryAndReturnError(const std::function<void()>& func)
|
||||||
|
{
|
||||||
try {
|
try {
|
||||||
@try {
|
@try {
|
||||||
func();
|
func();
|
||||||
@@ -133,7 +115,8 @@ NSError *tryAndReturnError(const std::function<void()>& func) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *deriveSourceURL(NSURL *url) {
|
NSString *deriveSourceURL(NSURL *url)
|
||||||
|
{
|
||||||
NSString *sourceUrl;
|
NSString *sourceUrl;
|
||||||
if (url.isFileURL) {
|
if (url.isFileURL) {
|
||||||
// Url will contain only path to resource (i.g. file:// will be removed)
|
// Url will contain only path to resource (i.g. file:// will be removed)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#import <React/RCTBridgeModule.h>
|
#import <React/RCTBridgeModule.h>
|
||||||
#import <React/RCTCxxUtils.h>
|
#import <React/RCTCxxUtils.h>
|
||||||
#import <React/RCTFollyConvert.h>
|
#import <React/RCTFollyConvert.h>
|
||||||
|
#import <React/RCTLog.h>
|
||||||
#import <React/RCTProfile.h>
|
#import <React/RCTProfile.h>
|
||||||
#import <React/RCTUtils.h>
|
#import <React/RCTUtils.h>
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ folly::dynamic RCTNativeModule::getConstants() {
|
|||||||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
||||||
@"[RCTNativeModule getConstants] moduleData.exportedConstants", nil);
|
@"[RCTNativeModule getConstants] moduleData.exportedConstants", nil);
|
||||||
NSDictionary *constants = m_moduleData.exportedConstants;
|
NSDictionary *constants = m_moduleData.exportedConstants;
|
||||||
folly::dynamic ret = [RCTConvert folly_dynamic:constants];
|
folly::dynamic ret = convertIdToFollyDynamic(constants);
|
||||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user