Pass expanded folly::dynamic as argument to sync nativeHook
Reviewed By: mhorowitz Differential Revision: D4409865 fbshipit-source-id: f99e02e36bf691fa5b4a5affce1fa4fd4cf321a6
This commit is contained in:
parent
2a638c2ee7
commit
919e49a8b8
|
@ -163,10 +163,6 @@ class NewJavaNativeModule : public NativeModule {
|
|||
std::vector<MethodDescriptor> methodDescriptors_;
|
||||
|
||||
MethodCallResult invokeInner(ExecutorToken token, unsigned int reactMethodId, folly::dynamic&& params) {
|
||||
if (!params.isArray()) {
|
||||
throw std::invalid_argument(
|
||||
folly::to<std::string>("method parameters should be array, but are ", params.typeName()));
|
||||
}
|
||||
return methods_[reactMethodId].invoke(instance_, module_.get(), token, params);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -163,20 +163,7 @@ MethodCallResult CxxNativeModule::callSerializableNativeHook(
|
|||
" is asynchronous but invoked synchronously"));
|
||||
}
|
||||
|
||||
if (!args.isString()) {
|
||||
throw std::invalid_argument(
|
||||
folly::to<std::string>("method parameters should be string, but are ", args.typeName()));
|
||||
}
|
||||
|
||||
folly::dynamic params = folly::parseJson(args.stringPiece());
|
||||
|
||||
if (!params.isArray()) {
|
||||
throw std::invalid_argument(
|
||||
folly::to<std::string>("parsed method parameters should be array, but are ",
|
||||
args.typeName()));
|
||||
}
|
||||
|
||||
return { method.syncFunc(std::move(params)), false };
|
||||
return { method.syncFunc(std::move(args)), false };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -264,7 +264,6 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) {
|
|||
installNativeHook<&JSCExecutor::nativeStartWorker>("nativeStartWorker");
|
||||
installNativeHook<&JSCExecutor::nativePostMessageToWorker>("nativePostMessageToWorker");
|
||||
installNativeHook<&JSCExecutor::nativeTerminateWorker>("nativeTerminateWorker");
|
||||
installNativeHook<&JSCExecutor::nativeCallSyncHook>("nativeCallSyncHook");
|
||||
|
||||
installGlobalFunction(m_context, "nativeLoggingHook", JSNativeHooks::loggingHook);
|
||||
installGlobalFunction(m_context, "nativePerformanceNow", JSNativeHooks::nowHook);
|
||||
|
@ -867,13 +866,18 @@ JSValueRef JSCExecutor::nativeCallSyncHook(
|
|||
|
||||
unsigned int moduleId = Value(m_context, arguments[0]).asUnsignedInteger();
|
||||
unsigned int methodId = Value(m_context, arguments[1]).asUnsignedInteger();
|
||||
std::string argsJson = Value(m_context, arguments[2]).toJSONString();
|
||||
folly::dynamic args = folly::parseJson(Value(m_context, arguments[2]).toJSONString());
|
||||
|
||||
if (!args.isArray()) {
|
||||
throw std::invalid_argument(
|
||||
folly::to<std::string>("method parameters should be array, but are ", args.typeName()));
|
||||
}
|
||||
|
||||
MethodCallResult result = m_delegate->callSerializableNativeHook(
|
||||
*this,
|
||||
moduleId,
|
||||
methodId,
|
||||
argsJson);
|
||||
std::move(args));
|
||||
if (result.isUndefined) {
|
||||
return Value::makeUndefined(m_context);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue