Move RCTFollyConvert to the correct namespace

Reviewed By: mhorowitz

Differential Revision: D4551124

fbshipit-source-id: 40a0a8ca818710a7529798b8244d9c133eb5c22d
This commit is contained in:
Pieter De Baets 2017-02-16 06:45:40 -08:00 committed by Facebook Github Bot
parent ae57b25134
commit 5d4ff693b4
8 changed files with 23 additions and 25 deletions

View File

@ -13,6 +13,7 @@
#import <React/RCTBridgeMethod.h> #import <React/RCTBridgeMethod.h>
#import <React/RCTBridgeModule.h> #import <React/RCTBridgeModule.h>
#import <React/RCTCxxUtils.h> #import <React/RCTCxxUtils.h>
#import <React/RCTFollyConvert.h>
#import <React/RCTProfile.h> #import <React/RCTProfile.h>
#import <React/RCTUtils.h> #import <React/RCTUtils.h>
@ -89,7 +90,7 @@ void RCTNativeModule::invoke(ExecutorToken token, unsigned int methodId, folly::
methodId, m_moduleData.name); methodId, m_moduleData.name);
} }
NSArray *objcParams = RCTConvertFollyDynamic(*sparams); NSArray *objcParams = convertFollyDynamicToId(*sparams);
@try { @try {
[method invokeWithBridge:bridge module:m_moduleData.instance arguments:objcParams]; [method invokeWithBridge:bridge module:m_moduleData.instance arguments:objcParams];

View File

@ -10,6 +10,7 @@
#import "RCTObjcExecutor.h" #import "RCTObjcExecutor.h"
#import <React/RCTCxxUtils.h> #import <React/RCTCxxUtils.h>
#import <React/RCTFollyConvert.h>
#import <React/RCTJavaScriptExecutor.h> #import <React/RCTJavaScriptExecutor.h>
#import <React/RCTLog.h> #import <React/RCTLog.h>
#import <React/RCTProfile.h> #import <React/RCTProfile.h>
@ -91,13 +92,13 @@ public:
const folly::dynamic &arguments) override { const folly::dynamic &arguments) override {
[m_jse callFunctionOnModule:@(module.c_str()) [m_jse callFunctionOnModule:@(module.c_str())
method:@(method.c_str()) method:@(method.c_str())
arguments:RCTConvertFollyDynamic(arguments) arguments:convertFollyDynamicToId(arguments)
callback:m_jsCallback]; callback:m_jsCallback];
} }
void invokeCallback(double callbackId, const folly::dynamic &arguments) override { void invokeCallback(double callbackId, const folly::dynamic &arguments) override {
[m_jse invokeCallbackID:@(callbackId) [m_jse invokeCallbackID:@(callbackId)
arguments:RCTConvertFollyDynamic(arguments) arguments:convertFollyDynamicToId(arguments)
callback:m_jsCallback]; callback:m_jsCallback];
} }

View File

@ -12,12 +12,14 @@
#import <React/RCTBridge+Private.h> #import <React/RCTBridge+Private.h>
#import <React/RCTBridge.h> #import <React/RCTBridge.h>
#import <React/RCTConvert.h> #import <React/RCTConvert.h>
#import <React/RCTFollyConvert.h>
#import <cxxreact/JsArgumentHelpers.h> #import <cxxreact/JsArgumentHelpers.h>
#import <folly/Memory.h> #import <folly/Memory.h>
#import "RCTCxxUtils.h" #import "RCTCxxUtils.h"
using facebook::xplat::module::CxxModule; using facebook::xplat::module::CxxModule;
using namespace facebook::react;
@implementation RCTCxxMethod @implementation RCTCxxMethod
{ {
@ -77,14 +79,14 @@ using facebook::xplat::module::CxxModule;
NSNumber *id2 = arguments[arguments.count - 1]; NSNumber *id2 = arguments[arguments.count - 1];
second = ^(std::vector<folly::dynamic> args) { second = ^(std::vector<folly::dynamic> args) {
[bridge enqueueCallback:id2 args:RCTConvertFollyDynamic(folly::dynamic(args.begin(), args.end()))]; [bridge enqueueCallback:id2 args:convertFollyDynamicToId(folly::dynamic(args.begin(), args.end()))];
}; };
} else { } else {
id1 = arguments[arguments.count - 1]; id1 = arguments[arguments.count - 1];
} }
first = ^(std::vector<folly::dynamic> args) { first = ^(std::vector<folly::dynamic> args) {
[bridge enqueueCallback:id1 args:RCTConvertFollyDynamic(folly::dynamic(args.begin(), args.end()))]; [bridge enqueueCallback:id1 args:convertFollyDynamicToId(folly::dynamic(args.begin(), args.end()))];
}; };
} }
@ -98,7 +100,7 @@ using facebook::xplat::module::CxxModule;
} else { } else {
auto result = _method->syncFunc(std::move(args)); auto result = _method->syncFunc(std::move(args));
// TODO: we should convert this to JSValue directly // TODO: we should convert this to JSValue directly
return RCTConvertFollyDynamic(result); return convertFollyDynamicToId(result);
} }
} catch (const facebook::xplat::JsArgumentException &ex) { } catch (const facebook::xplat::JsArgumentException &ex) {
RCTLogError(@"Method %@.%s argument error: %s", RCTLogError(@"Method %@.%s argument error: %s",

View File

@ -10,10 +10,13 @@
#import "RCTCxxModule.h" #import "RCTCxxModule.h"
#import <React/RCTBridge.h> #import <React/RCTBridge.h>
#import <React/RCTFollyConvert.h>
#import <React/RCTLog.h>
#import <cxxreact/CxxModule.h> #import <cxxreact/CxxModule.h>
#import "RCTCxxMethod.h" #import "RCTCxxMethod.h"
#import "RCTCxxUtils.h"
using namespace facebook::react;
@implementation RCTCxxModule @implementation RCTCxxModule
{ {
@ -65,7 +68,7 @@
NSMutableDictionary *moduleConstants = [NSMutableDictionary new]; NSMutableDictionary *moduleConstants = [NSMutableDictionary new];
for (const auto &c : _module->getConstants()) { for (const auto &c : _module->getConstants()) {
moduleConstants[@(c.first.c_str())] = RCTConvertFollyDynamic(c.second); moduleConstants[@(c.first.c_str())] = convertFollyDynamicToId(c.second);
} }
return moduleConstants; return moduleConstants;
} }

View File

@ -10,8 +10,6 @@
#import <React/RCTConvert.h> #import <React/RCTConvert.h>
#include <folly/dynamic.h> #include <folly/dynamic.h>
id RCTConvertFollyDynamic(const folly::dynamic &dyn);
@interface RCTConvert (folly) @interface RCTConvert (folly)
+ (folly::dynamic)folly_dynamic:(id)json; + (folly::dynamic)folly_dynamic:(id)json;

View File

@ -15,11 +15,6 @@
#include <jschelpers/Value.h> #include <jschelpers/Value.h>
using namespace facebook::react; using namespace facebook::react;
using namespace react::CxxUtils;
id RCTConvertFollyDynamic(const folly::dynamic &dyn) {
return convertFollyDynamicToId(dyn);
}
@implementation RCTConvert (folly) @implementation RCTConvert (folly)

View File

@ -1,5 +1,3 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/** /**
* Copyright (c) 2015-present, Facebook, Inc. * Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
@ -9,9 +7,12 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*/ */
#import <Foundation/Foundation.h>
#include <folly/dynamic.h> #include <folly/dynamic.h>
namespace react { namespace CxxUtils { namespace facebook {
namespace react {
folly::dynamic convertIdToFollyDynamic(id json); folly::dynamic convertIdToFollyDynamic(id json);
id convertFollyDynamicToId(const folly::dynamic &dyn); id convertFollyDynamicToId(const folly::dynamic &dyn);

View File

@ -1,5 +1,3 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/** /**
* Copyright (c) 2015-present, Facebook, Inc. * Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved. * All rights reserved.
@ -13,9 +11,8 @@
#import <objc/runtime.h> #import <objc/runtime.h>
#import <Foundation/Foundation.h> namespace facebook {
namespace react {
namespace react { namespace CxxUtils {
id convertFollyDynamicToId(const folly::dynamic &dyn) { id convertFollyDynamicToId(const folly::dynamic &dyn) {
// I could imagine an implementation which avoids copies by wrapping the // I could imagine an implementation which avoids copies by wrapping the