Skip to content

Commit

Permalink
Move RCTFollyConvert to the correct namespace
Browse files Browse the repository at this point in the history
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 5d4ff69
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 25 deletions.
3 changes: 2 additions & 1 deletion React/CxxBridge/RCTNativeModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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];
Expand Down
5 changes: 3 additions & 2 deletions React/CxxBridge/RCTObjcExecutor.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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];
}

Expand Down
8 changes: 5 additions & 3 deletions React/CxxModule/RCTCxxMethod.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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()))];
};
}

Expand All @@ -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",
Expand Down
7 changes: 5 additions & 2 deletions React/CxxModule/RCTCxxModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 0 additions & 2 deletions React/CxxModule/RCTCxxUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions React/CxxModule/RCTCxxUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
9 changes: 5 additions & 4 deletions React/CxxUtils/RCTFollyConvert.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copyright 2004-present Facebook. All Rights Reserved.

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
Expand All @@ -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);

}}
} }
9 changes: 3 additions & 6 deletions React/CxxUtils/RCTFollyConvert.mm
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// Copyright 2004-present Facebook. All Rights Reserved.

/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
Expand All @@ -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
Expand Down Expand Up @@ -113,4 +110,4 @@ id convertFollyDynamicToId(const folly::dynamic &dyn) {
return nil;
}

}}
} }

0 comments on commit 5d4ff69

Please sign in to comment.