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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,3 @@
// Copyright 2004-present Facebook. All Rights Reserved.
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
@ -9,11 +7,14 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <Foundation/Foundation.h>
#include <folly/dynamic.h>
namespace react { namespace CxxUtils {
namespace facebook {
namespace react {
folly::dynamic convertIdToFollyDynamic(id json);
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.
* All rights reserved.
@ -13,9 +11,8 @@
#import <objc/runtime.h>
#import <Foundation/Foundation.h>
namespace react { namespace CxxUtils {
namespace facebook {
namespace react {
id convertFollyDynamicToId(const folly::dynamic &dyn) {
// I could imagine an implementation which avoids copies by wrapping the
@ -113,4 +110,4 @@ folly::dynamic convertIdToFollyDynamic(id json)
return nil;
}
}}
} }