Replace -[RCTConvert folly_dynamic:] with direct calls to convertIdToFollyDynamic
Reviewed By: kathryngray Differential Revision: D5355734 fbshipit-source-id: 4ba1533b75c8e271a86a2d5cc3a3354e52f83db2
This commit is contained in:
parent
dc97e3fb4e
commit
f1cbb11620
|
@ -29,6 +29,7 @@
|
|||
#import <React/RCTProfile.h>
|
||||
#import <React/RCTRedBox.h>
|
||||
#import <React/RCTUtils.h>
|
||||
#import <React/RCTFollyConvert.h>
|
||||
#import <cxxreact/CxxNativeModule.h>
|
||||
#import <cxxreact/Instance.h>
|
||||
#import <cxxreact/JSBundleType.h>
|
||||
|
@ -1005,7 +1006,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
|
||||
if (self->_reactInstance) {
|
||||
self->_reactInstance->callJSFunction([module UTF8String], [method UTF8String],
|
||||
[RCTConvert folly_dynamic:args ?: @[]]);
|
||||
convertIdToFollyDynamic(args ?: @[]));
|
||||
|
||||
// ensureOnJavaScriptThread may execute immediately, so use jsMessageThread, to make sure
|
||||
// the block is invoked after callJSFunction
|
||||
|
@ -1041,7 +1042,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
|||
RCTProfileEndFlowEvent();
|
||||
|
||||
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_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);
|
||||
|
||||
try {
|
||||
|
|
|
@ -9,21 +9,14 @@
|
|||
|
||||
#include <memory>
|
||||
|
||||
#import <React/RCTConvert.h>
|
||||
#include <JavaScriptCore/JavaScriptCore.h>
|
||||
#include <cxxreact/JSCExecutor.h>
|
||||
#include <folly/dynamic.h>
|
||||
#include <jschelpers/JavaScriptCore.h>
|
||||
#import <JavaScriptCore/JavaScriptCore.h>
|
||||
|
||||
#import <cxxreact/JSCExecutor.h>
|
||||
#import <jschelpers/JavaScriptCore.h>
|
||||
|
||||
@class RCTBridge;
|
||||
@class RCTModuleData;
|
||||
|
||||
@interface RCTConvert (folly)
|
||||
|
||||
+ (folly::dynamic)folly_dynamic:(id)json;
|
||||
|
||||
@end
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
|
|
|
@ -12,32 +12,13 @@
|
|||
#import <React/RCTFollyConvert.h>
|
||||
#import <React/RCTModuleData.h>
|
||||
#import <React/RCTUtils.h>
|
||||
#include <cxxreact/CxxNativeModule.h>
|
||||
#include <jschelpers/Value.h>
|
||||
#import <cxxreact/CxxNativeModule.h>
|
||||
#import <jschelpers/Value.h>
|
||||
|
||||
#import "DispatchMessageQueueThread.h"
|
||||
#import "RCTCxxModule.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 react {
|
||||
|
||||
|
@ -109,7 +90,8 @@ static NSError *errorWithException(const std::exception &e)
|
|||
return [NSError errorWithDomain:RCTErrorDomain code:1 userInfo:errorInfo];
|
||||
}
|
||||
|
||||
NSError *tryAndReturnError(const std::function<void()>& func) {
|
||||
NSError *tryAndReturnError(const std::function<void()>& func)
|
||||
{
|
||||
try {
|
||||
@try {
|
||||
func();
|
||||
|
@ -133,7 +115,8 @@ NSError *tryAndReturnError(const std::function<void()>& func) {
|
|||
}
|
||||
}
|
||||
|
||||
NSString *deriveSourceURL(NSURL *url) {
|
||||
NSString *deriveSourceURL(NSURL *url)
|
||||
{
|
||||
NSString *sourceUrl;
|
||||
if (url.isFileURL) {
|
||||
// Url will contain only path to resource (i.g. file:// will be removed)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#import <React/RCTBridgeModule.h>
|
||||
#import <React/RCTCxxUtils.h>
|
||||
#import <React/RCTFollyConvert.h>
|
||||
#import <React/RCTLog.h>
|
||||
#import <React/RCTProfile.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
|
@ -49,7 +50,7 @@ folly::dynamic RCTNativeModule::getConstants() {
|
|||
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways,
|
||||
@"[RCTNativeModule getConstants] moduleData.exportedConstants", nil);
|
||||
NSDictionary *constants = m_moduleData.exportedConstants;
|
||||
folly::dynamic ret = [RCTConvert folly_dynamic:constants];
|
||||
folly::dynamic ret = convertIdToFollyDynamic(constants);
|
||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue