diff --git a/React/CxxBridge/RCTNativeModule.mm b/React/CxxBridge/RCTNativeModule.mm index 475fde4b8..a150bd42e 100644 --- a/React/CxxBridge/RCTNativeModule.mm +++ b/React/CxxBridge/RCTNativeModule.mm @@ -13,6 +13,7 @@ #import #import #import +#import #import #import @@ -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]; diff --git a/React/CxxBridge/RCTObjcExecutor.mm b/React/CxxBridge/RCTObjcExecutor.mm index 0f5132cf1..2b70c15fe 100644 --- a/React/CxxBridge/RCTObjcExecutor.mm +++ b/React/CxxBridge/RCTObjcExecutor.mm @@ -10,6 +10,7 @@ #import "RCTObjcExecutor.h" #import +#import #import #import #import @@ -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]; } diff --git a/React/CxxModule/RCTCxxMethod.mm b/React/CxxModule/RCTCxxMethod.mm index cd5b7f86c..de8375e6e 100644 --- a/React/CxxModule/RCTCxxMethod.mm +++ b/React/CxxModule/RCTCxxMethod.mm @@ -12,12 +12,14 @@ #import #import #import +#import #import #import #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 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 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", diff --git a/React/CxxModule/RCTCxxModule.mm b/React/CxxModule/RCTCxxModule.mm index 61df218be..a2be24170 100644 --- a/React/CxxModule/RCTCxxModule.mm +++ b/React/CxxModule/RCTCxxModule.mm @@ -10,10 +10,13 @@ #import "RCTCxxModule.h" #import +#import +#import #import #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; } diff --git a/React/CxxModule/RCTCxxUtils.h b/React/CxxModule/RCTCxxUtils.h index 4755e3678..0891f20e5 100644 --- a/React/CxxModule/RCTCxxUtils.h +++ b/React/CxxModule/RCTCxxUtils.h @@ -10,8 +10,6 @@ #import #include -id RCTConvertFollyDynamic(const folly::dynamic &dyn); - @interface RCTConvert (folly) + (folly::dynamic)folly_dynamic:(id)json; diff --git a/React/CxxModule/RCTCxxUtils.mm b/React/CxxModule/RCTCxxUtils.mm index c2475defc..caa986609 100644 --- a/React/CxxModule/RCTCxxUtils.mm +++ b/React/CxxModule/RCTCxxUtils.mm @@ -15,11 +15,6 @@ #include using namespace facebook::react; -using namespace react::CxxUtils; - -id RCTConvertFollyDynamic(const folly::dynamic &dyn) { - return convertFollyDynamicToId(dyn); -} @implementation RCTConvert (folly) diff --git a/React/CxxUtils/RCTFollyConvert.h b/React/CxxUtils/RCTFollyConvert.h index c73620bb5..c5a16f20c 100644 --- a/React/CxxUtils/RCTFollyConvert.h +++ b/React/CxxUtils/RCTFollyConvert.h @@ -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 + #include -namespace react { namespace CxxUtils { +namespace facebook { +namespace react { folly::dynamic convertIdToFollyDynamic(id json); id convertFollyDynamicToId(const folly::dynamic &dyn); -}} +} } diff --git a/React/CxxUtils/RCTFollyConvert.mm b/React/CxxUtils/RCTFollyConvert.mm index a60470166..b75a7f723 100644 --- a/React/CxxUtils/RCTFollyConvert.mm +++ b/React/CxxUtils/RCTFollyConvert.mm @@ -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 -#import - -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; } -}} +} }