mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Serialize params when making/queuing native call
Reviewed By: mhorowitz Differential Revision: D3460507 fbshipit-source-id: a0600ffe3da89791af3eb64fc2973eb6aafa7d2b
This commit is contained in:
committed by
Facebook Github Bot
parent
e3f96acf26
commit
df6d18358e
@@ -119,12 +119,17 @@ JSCExecutor::JSCExecutor(std::shared_ptr<ExecutorDelegate> delegate,
|
||||
}
|
||||
|
||||
folly::dynamic config =
|
||||
folly::dynamic::object("remoteModuleConfig", std::move(nativeModuleConfig));
|
||||
folly::dynamic::object
|
||||
("remoteModuleConfig", std::move(nativeModuleConfig));
|
||||
|
||||
|
||||
SystraceSection t("setGlobalVariable");
|
||||
setGlobalVariable(
|
||||
"__fbBatchedBridgeConfig",
|
||||
folly::make_unique<JSBigStdString>(detail::toStdString(folly::toJson(config))));
|
||||
setGlobalVariable(
|
||||
"__fbBatchedBridgeSerializeNativeParams",
|
||||
folly::make_unique<JSBigStdString>(""));
|
||||
}
|
||||
|
||||
JSCExecutor::JSCExecutor(
|
||||
|
||||
@@ -51,16 +51,20 @@ std::vector<MethodCall> parseMethodCalls(const std::string& json) throw(std::inv
|
||||
|
||||
std::vector<MethodCall> methodCalls;
|
||||
for (size_t i = 0; i < moduleIds.size(); i++) {
|
||||
auto paramsValue = params[i];
|
||||
if (!params[i].isString()) {
|
||||
throw std::invalid_argument(
|
||||
folly::to<std::string>("Call argument isn't a string"));
|
||||
}
|
||||
auto paramsValue = folly::parseJson(params[i].asString());
|
||||
if (!paramsValue.isArray()) {
|
||||
throw std::invalid_argument(
|
||||
folly::to<std::string>("Call argument isn't an array"));
|
||||
folly::to<std::string>("Parsed params isn't an array"));
|
||||
}
|
||||
|
||||
methodCalls.emplace_back(
|
||||
moduleIds[i].getInt(),
|
||||
methodIds[i].getInt(),
|
||||
std::move(params[i]),
|
||||
std::move(paramsValue),
|
||||
callId);
|
||||
|
||||
// only incremement callid if contains valid callid as callid is optional
|
||||
|
||||
Reference in New Issue
Block a user