diff --git a/ReactAndroid/src/main/jni/react/Bridge.cpp b/ReactAndroid/src/main/jni/react/Bridge.cpp index 6654e8bd4..83f0aaa6b 100644 --- a/ReactAndroid/src/main/jni/react/Bridge.cpp +++ b/ReactAndroid/src/main/jni/react/Bridge.cpp @@ -47,8 +47,8 @@ void Bridge::loadApplicationUnbundle( void Bridge::callFunction( ExecutorToken executorToken, - const double moduleId, - const double methodId, + const std::string& moduleId, + const std::string& methodId, const folly::dynamic& arguments, const std::string& tracingName) { if (*m_destroyed) { @@ -174,7 +174,7 @@ void Bridge::callNativeModules(JSExecutor& executor, const std::string& callJSON if (*m_destroyed) { return; } - m_callback->onCallNativeModules(getTokenForExecutor(executor), parseMethodCalls(callJSON), isEndOfBatch); + m_callback->onCallNativeModules(getTokenForExecutor(executor), callJSON, isEndOfBatch); } ExecutorToken Bridge::getMainExecutorToken() const { diff --git a/ReactAndroid/src/main/jni/react/Bridge.h b/ReactAndroid/src/main/jni/react/Bridge.h index 3618ef04f..b8abccdfd 100644 --- a/ReactAndroid/src/main/jni/react/Bridge.h +++ b/ReactAndroid/src/main/jni/react/Bridge.h @@ -30,7 +30,7 @@ public: virtual void onCallNativeModules( ExecutorToken executorToken, - std::vector&& calls, + const std::string& callJSON, bool isEndOfBatch) = 0; virtual void onExecutorUnregistered(ExecutorToken executorToken) = 0; @@ -66,8 +66,8 @@ public: */ void callFunction( ExecutorToken executorToken, - const double moduleId, - const double methodId, + const std::string& moduleId, + const std::string& methodId, const folly::dynamic& args, const std::string& tracingName); diff --git a/ReactAndroid/src/main/jni/react/Executor.h b/ReactAndroid/src/main/jni/react/Executor.h index 6f392a3cd..07aea900a 100644 --- a/ReactAndroid/src/main/jni/react/Executor.h +++ b/ReactAndroid/src/main/jni/react/Executor.h @@ -47,7 +47,7 @@ public: * method ID and optional additional arguments in JS. The executor is responsible * for using Bridge->callNativeModules to invoke any necessary native modules methods. */ - virtual void callFunction(const double moduleId, const double methodId, const folly::dynamic& arguments) = 0; + virtual void callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) = 0; /** * Executes BatchedBridge.invokeCallbackAndReturnFlushedQueue with the cbID, diff --git a/ReactAndroid/src/main/jni/react/JSCExecutor.cpp b/ReactAndroid/src/main/jni/react/JSCExecutor.cpp index feb9c63f9..a97a9ae6f 100644 --- a/ReactAndroid/src/main/jni/react/JSCExecutor.cpp +++ b/ReactAndroid/src/main/jni/react/JSCExecutor.cpp @@ -244,11 +244,11 @@ void JSCExecutor::flush() { m_bridge->callNativeModules(*this, calls, true); } -void JSCExecutor::callFunction(const double moduleId, const double methodId, const folly::dynamic& arguments) { +void JSCExecutor::callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) { // TODO: Make this a first class function instead of evaling. #9317773 std::vector call{ - (double) moduleId, - (double) methodId, + moduleId, + methodId, std::move(arguments), }; std::string calls = executeJSCallWithJSC(m_context, "callFunctionReturnFlushedQueue", std::move(call)); diff --git a/ReactAndroid/src/main/jni/react/JSCExecutor.h b/ReactAndroid/src/main/jni/react/JSCExecutor.h index 7f41170c8..7c704d077 100644 --- a/ReactAndroid/src/main/jni/react/JSCExecutor.h +++ b/ReactAndroid/src/main/jni/react/JSCExecutor.h @@ -58,8 +58,8 @@ public: const std::string& startupCode, const std::string& sourceURL) override; virtual void callFunction( - const double moduleId, - const double methodId, + const std::string& moduleId, + const std::string& methodId, const folly::dynamic& arguments) override; virtual void invokeCallback( const double callbackId, diff --git a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp index 2ba655531..4c0722307 100644 --- a/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp +++ b/ReactAndroid/src/main/jni/react/jni/OnLoad.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "JExecutorToken.h" #include "JExecutorTokenFactory.h" @@ -648,11 +649,11 @@ public: virtual void onCallNativeModules( ExecutorToken executorToken, - std::vector&& calls, + const std::string& callJSON, bool isEndOfBatch) override { - executeCallbackOnCallbackQueueThread([executorToken, calls, isEndOfBatch] (ResolvedWeakReference& callback) { + executeCallbackOnCallbackQueueThread([executorToken, callJSON, isEndOfBatch] (ResolvedWeakReference& callback) { JNIEnv* env = Environment::current(); - for (auto& call : calls) { + for (auto& call : react::parseMethodCalls(callJSON)) { makeJavaCall(env, executorToken, callback, call); if (env->ExceptionCheck()) { return; @@ -780,8 +781,8 @@ static void callFunction(JNIEnv* env, jobject obj, JExecutorToken::jhybridobject try { bridge->callFunction( cthis(wrap_alias(jExecutorToken))->getExecutorToken(wrap_alias(jExecutorToken)), - (double) moduleId, - (double) methodId, + folly::to(moduleId), + folly::to(methodId), std::move(arguments->array), fromJString(env, tracingName) ); diff --git a/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp b/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp index 07743bed8..4ad7a8eb0 100644 --- a/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp +++ b/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.cpp @@ -58,10 +58,10 @@ void ProxyExecutor::loadApplicationUnbundle(std::unique_ptr, "Loading application unbundles is not supported for proxy executors"); } -void ProxyExecutor::callFunction(const double moduleId, const double methodId, const folly::dynamic& arguments) { +void ProxyExecutor::callFunction(const std::string& moduleId, const std::string& methodId, const folly::dynamic& arguments) { std::vector call{ - (double) moduleId, - (double) methodId, + moduleId, + methodId, std::move(arguments), }; std::string result = executeJSCallWithProxy(m_executor.get(), "callFunctionReturnFlushedQueue", std::move(call)); diff --git a/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.h b/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.h index c66346424..c06ee9287 100644 --- a/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.h +++ b/ReactAndroid/src/main/jni/react/jni/ProxyExecutor.h @@ -39,8 +39,8 @@ public: const std::string& startupCode, const std::string& sourceURL) override; virtual void callFunction( - const double moduleId, - const double methodId, + const std::string& moduleId, + const std::string& methodId, const folly::dynamic& arguments) override; virtual void invokeCallback( const double callbackId,