Permalink
Browse files

Move RCTFollyConvert to the correct namespace

Reviewed By: mhorowitz

Differential Revision: D4551124

fbshipit-source-id: 40a0a8ca818710a7529798b8244d9c133eb5c22d
  • Loading branch information...
javache authored and facebook-github-bot committed Feb 16, 2017
1 parent ae57b25 commit 5d4ff693b403e9c7ab60c8e94f5e75c0c8fad361
@@ -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 @@
methodId, m_moduleData.name);
}
NSArray *objcParams = RCTConvertFollyDynamic(*sparams);
NSArray *objcParams = convertFollyDynamicToId(*sparams);
@try {
[method invokeWithBridge:bridge module:m_moduleData.instance arguments:objcParams];
@@ -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 @@ void callFunction(const std::string &module, const std::string &method,
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];
}
@@ -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 @@ - (id)invokeWithBridge:(RCTBridge *)bridge
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 @@ - (id)invokeWithBridge:(RCTBridge *)bridge
} 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",
@@ -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 @@ - (NSDictionary *)constantsToExport
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;
}
@@ -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;
@@ -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)
@@ -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);
}}
} }
@@ -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 @@ id convertFollyDynamicToId(const folly::dynamic &dyn) {
return nil;
}
}}
} }

0 comments on commit 5d4ff69

Please sign in to comment.