Permalink
Browse files

Replace -[RCTConvert folly_dynamic:] with direct calls to convertIdTo…

…FollyDynamic

Reviewed By: kathryngray

Differential Revision: D5355734

fbshipit-source-id: 4ba1533b75c8e271a86a2d5cc3a3354e52f83db2
  • Loading branch information...
javache authored and facebook-github-bot committed Jul 10, 2017
1 parent dc97e3f commit f1cbb11620c1609189daf5370f0dba86ceb7d275
@@ -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 @@ - (void)enqueueJSCall:(NSString *)module method:(NSString *)method args:(NSArray
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 @@ - (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args
RCTProfileEndFlowEvent();
if (self->_reactInstance) {
self->_reactInstance->callJSCallback([cbID unsignedLongLongValue], [RCTConvert folly_dynamic:args ?: @[]]);
self->_reactInstance->callJSCallback([cbID unsignedLongLongValue], convertIdToFollyDynamic(args ?: @[]));
}
}];
}
@@ -50,7 +50,7 @@
}
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 @@ - (id)invokeWithBridge:(RCTBridge *)bridge
};
}
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 @@ @implementation RCTConvert (folly)
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 @@ @implementation RCTConvert (folly)
}
}
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 @@
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;
}

0 comments on commit f1cbb11

Please sign in to comment.