Port some minor changes to the old bridge

Reviewed By: mhorowitz, astreet

Differential Revision: D3024252

fb-gh-sync-id: 3ea28f793d920d74caab9b8c1487957e89ea23b3
shipit-source-id: 3ea28f793d920d74caab9b8c1487957e89ea23b3
This commit is contained in:
Chris Hopman 2016-03-11 09:29:19 -08:00 committed by Facebook Github Bot 7
parent 8aa83a2d93
commit 9acf7417a8
8 changed files with 23 additions and 22 deletions

View File

@ -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 {

View File

@ -30,7 +30,7 @@ public:
virtual void onCallNativeModules(
ExecutorToken executorToken,
std::vector<MethodCall>&& 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);

View File

@ -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,

View File

@ -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<folly::dynamic> call{
(double) moduleId,
(double) methodId,
moduleId,
methodId,
std::move(arguments),
};
std::string calls = executeJSCallWithJSC(m_context, "callFunctionReturnFlushedQueue", std::move(call));

View File

@ -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,

View File

@ -16,6 +16,7 @@
#include <react/Executor.h>
#include <react/JSCExecutor.h>
#include <react/JSModulesUnbundle.h>
#include <react/MethodCall.h>
#include <react/Platform.h>
#include "JExecutorToken.h"
#include "JExecutorTokenFactory.h"
@ -648,11 +649,11 @@ public:
virtual void onCallNativeModules(
ExecutorToken executorToken,
std::vector<MethodCall>&& 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<std::string>(moduleId),
folly::to<std::string>(methodId),
std::move(arguments->array),
fromJString(env, tracingName)
);

View File

@ -58,10 +58,10 @@ void ProxyExecutor::loadApplicationUnbundle(std::unique_ptr<JSModulesUnbundle>,
"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<folly::dynamic> call{
(double) moduleId,
(double) methodId,
moduleId,
methodId,
std::move(arguments),
};
std::string result = executeJSCallWithProxy(m_executor.get(), "callFunctionReturnFlushedQueue", std::move(call));

View File

@ -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,