mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Rename JSCallInvoker{,Holder} to CallInvoker{,Holder}
Summary: ## Motivation The concept behind JSCallInvoker doesn't necessarily have to apply only to the JS thread. On Android, we need to re-use this abstraction to allow execution of async method calls on the NativeModules thread. Reviewed By: PeteTheHeat Differential Revision: D17377313 fbshipit-source-id: 3d9075cbfce0b908d800a366947cfd16a3013d1c
This commit is contained in:
committed by
Facebook Github Bot
parent
60b57bad54
commit
4c998fd05d
@@ -47,7 +47,7 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react/uimanager/common:common"),
|
||||
react_native_target("java/com/facebook/react/module/annotations:annotations"),
|
||||
react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"),
|
||||
react_native_target("java/com/facebook/react/turbomodule/core:jscallinvokerholder"),
|
||||
react_native_target("java/com/facebook/react/turbomodule/core:callinvokerholder"),
|
||||
] + ([react_native_target("jni/react/jni:jni")] if not IS_OSS_BUILD else []),
|
||||
exported_deps = [
|
||||
react_native_dep("java/com/facebook/jni:jni"),
|
||||
|
||||
@@ -10,7 +10,7 @@ import androidx.annotation.Nullable;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.turbomodule.core.interfaces.JSCallInvokerHolder;
|
||||
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -110,7 +110,7 @@ public interface CatalystInstance
|
||||
* Returns a hybrid object that contains a pointer to JSCallInvoker. Required for
|
||||
* TurboModuleManager initialization.
|
||||
*/
|
||||
JSCallInvokerHolder getJSCallInvokerHolder();
|
||||
CallInvokerHolder getJSCallInvokerHolder();
|
||||
|
||||
/**
|
||||
* For the time being, we want code relying on the old infra to also work with TurboModules.
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.facebook.react.common.ReactConstants;
|
||||
import com.facebook.react.common.annotations.VisibleForTesting;
|
||||
import com.facebook.react.config.ReactFeatureFlags;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
import com.facebook.react.turbomodule.core.JSCallInvokerHolderImpl;
|
||||
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry;
|
||||
import com.facebook.systrace.Systrace;
|
||||
@@ -107,7 +107,7 @@ public class CatalystInstanceImpl implements CatalystInstance {
|
||||
|
||||
private static native HybridData initHybrid();
|
||||
|
||||
public native JSCallInvokerHolderImpl getJSCallInvokerHolder();
|
||||
public native CallInvokerHolderImpl getJSCallInvokerHolder();
|
||||
|
||||
private CatalystInstanceImpl(
|
||||
final ReactQueueConfigurationSpec reactQueueConfigurationSpec,
|
||||
|
||||
@@ -6,7 +6,7 @@ rn_android_library(
|
||||
[
|
||||
"*.java",
|
||||
],
|
||||
exclude = ["JSCallInvokerHolderImpl.java"],
|
||||
exclude = ["CallInvokerHolderImpl.java"],
|
||||
),
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
@@ -25,7 +25,7 @@ rn_android_library(
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/config:config"),
|
||||
react_native_target("java/com/facebook/react:react"),
|
||||
":jscallinvokerholder",
|
||||
":callinvokerholder",
|
||||
],
|
||||
exported_deps = [
|
||||
react_native_target("java/com/facebook/react/turbomodule/core/interfaces:interfaces"),
|
||||
@@ -33,8 +33,8 @@ rn_android_library(
|
||||
)
|
||||
|
||||
rn_android_library(
|
||||
name = "jscallinvokerholder",
|
||||
srcs = ["JSCallInvokerHolderImpl.java"],
|
||||
name = "callinvokerholder",
|
||||
srcs = ["CallInvokerHolderImpl.java"],
|
||||
required_for_source_only_abi = True,
|
||||
visibility = [
|
||||
"PUBLIC",
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@
|
||||
package com.facebook.react.turbomodule.core;
|
||||
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.react.turbomodule.core.interfaces.JSCallInvokerHolder;
|
||||
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
/**
|
||||
@@ -15,14 +15,14 @@ import com.facebook.soloader.SoLoader;
|
||||
* TurboModuleManager. Therefore, we need to wrap JSCallInvoker within a hybrid class so that we may
|
||||
* pass it from CatalystInstance, through Java, to TurboModuleManager::initHybrid.
|
||||
*/
|
||||
public class JSCallInvokerHolderImpl implements JSCallInvokerHolder {
|
||||
public class CallInvokerHolderImpl implements CallInvokerHolder {
|
||||
static {
|
||||
SoLoader.loadLibrary("turbomodulejsijni");
|
||||
}
|
||||
|
||||
private final HybridData mHybridData;
|
||||
|
||||
private JSCallInvokerHolderImpl(HybridData hd) {
|
||||
private CallInvokerHolderImpl(HybridData hd) {
|
||||
mHybridData = hd;
|
||||
}
|
||||
}
|
||||
+4
-5
@@ -12,7 +12,7 @@ import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.JSIModule;
|
||||
import com.facebook.react.bridge.JavaScriptContextHolder;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.turbomodule.core.interfaces.JSCallInvokerHolder;
|
||||
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
@@ -39,9 +39,8 @@ public class TurboModuleManager implements JSIModule, TurboModuleRegistry {
|
||||
public TurboModuleManager(
|
||||
JavaScriptContextHolder jsContext,
|
||||
TurboModuleManagerDelegate tmmDelegate,
|
||||
JSCallInvokerHolder instanceHolder) {
|
||||
mHybridData =
|
||||
initHybrid(jsContext.get(), (JSCallInvokerHolderImpl) instanceHolder, tmmDelegate);
|
||||
CallInvokerHolder instanceHolder) {
|
||||
mHybridData = initHybrid(jsContext.get(), (CallInvokerHolderImpl) instanceHolder, tmmDelegate);
|
||||
mTurbomoduleManagerDelegate = tmmDelegate;
|
||||
}
|
||||
|
||||
@@ -79,7 +78,7 @@ public class TurboModuleManager implements JSIModule, TurboModuleRegistry {
|
||||
}
|
||||
|
||||
private native HybridData initHybrid(
|
||||
long jsContext, JSCallInvokerHolderImpl jsQueue, TurboModuleManagerDelegate tmmDelegate);
|
||||
long jsContext, CallInvokerHolderImpl jsQueue, TurboModuleManagerDelegate tmmDelegate);
|
||||
|
||||
private native void installJSIBindings();
|
||||
|
||||
|
||||
+5
-5
@@ -7,11 +7,11 @@
|
||||
package com.facebook.react.turbomodule.core.interfaces;
|
||||
|
||||
/**
|
||||
* JSCallInvoker is created by CatalystInstance.cpp, but used by TurboModuleManager.cpp. Both C++
|
||||
* classes are instantiated at different times/places. Therefore, to pass the JSCallInvoker instance
|
||||
* from CatalystInstance to TurboModuleManager, we make it take a trip through Java.
|
||||
* JS CallInvoker is created by CatalystInstance.cpp, but used by TurboModuleManager.cpp. Both C++
|
||||
* classes are instantiated at different times/places. Therefore, to pass the JS CallInvoker
|
||||
* instance from CatalystInstance to TurboModuleManager, we make it take a trip through Java.
|
||||
*
|
||||
* <p>This interface represents the opaque Java object that contains a pointer to and instance of
|
||||
* JSCallInvoker.
|
||||
* CallInvoker.
|
||||
*/
|
||||
public interface JSCallInvokerHolder {}
|
||||
public interface CallInvokerHolder {}
|
||||
@@ -15,15 +15,15 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
|
||||
|
||||
LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall
|
||||
|
||||
LOCAL_STATIC_LIBRARIES = libjscallinvoker
|
||||
LOCAL_STATIC_LIBRARIES = libcallinvoker
|
||||
|
||||
LOCAL_SHARED_LIBRARIES = libfb
|
||||
|
||||
# Name of this module.
|
||||
LOCAL_MODULE := jscallinvokerholder
|
||||
LOCAL_MODULE := callinvokerholder
|
||||
|
||||
# Compile all local c++ files
|
||||
LOCAL_SRC_FILES := $(LOCAL_PATH)/ReactCommon/JSCallInvokerHolder.cpp
|
||||
LOCAL_SRC_FILES := $(LOCAL_PATH)/ReactCommon/CallInvokerHolder.cpp
|
||||
|
||||
# Build the files in this directory as a shared library
|
||||
include $(BUILD_STATIC_LIBRARY)
|
||||
|
||||
@@ -32,19 +32,19 @@ rn_xplat_cxx_library(
|
||||
],
|
||||
exported_deps = [
|
||||
"fbsource//xplat/jsi:jsi",
|
||||
":jscallinvokerholder",
|
||||
":callinvokerholder",
|
||||
react_native_xplat_target("turbomodule/core:core"),
|
||||
],
|
||||
)
|
||||
|
||||
rn_xplat_cxx_library(
|
||||
name = "jscallinvokerholder",
|
||||
name = "callinvokerholder",
|
||||
srcs = [
|
||||
"ReactCommon/JSCallInvokerHolder.cpp",
|
||||
"ReactCommon/CallInvokerHolder.cpp",
|
||||
],
|
||||
header_namespace = "",
|
||||
exported_headers = {
|
||||
"ReactCommon/JSCallInvokerHolder.h": "ReactCommon/JSCallInvokerHolder.h",
|
||||
"ReactCommon/CallInvokerHolder.h": "ReactCommon/CallInvokerHolder.h",
|
||||
},
|
||||
compiler_flags = [
|
||||
"-fexceptions",
|
||||
@@ -65,6 +65,6 @@ rn_xplat_cxx_library(
|
||||
"PUBLIC",
|
||||
],
|
||||
exported_deps = [
|
||||
react_native_xplat_target("jscallinvoker:jscallinvoker"),
|
||||
react_native_xplat_target("callinvoker:callinvoker"),
|
||||
],
|
||||
)
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
#include "CallInvokerHolder.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
CallInvokerHolder::CallInvokerHolder(
|
||||
std::shared_ptr<CallInvoker> callInvoker)
|
||||
: _callInvoker(callInvoker) {}
|
||||
|
||||
std::shared_ptr<CallInvoker> CallInvokerHolder::getCallInvoker() {
|
||||
return _callInvoker;
|
||||
}
|
||||
|
||||
void CallInvokerHolder::registerNatives() {}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
+7
-7
@@ -8,25 +8,25 @@
|
||||
#pragma once
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <ReactCommon/JSCallInvoker.h>
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <memory>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
class JSCallInvokerHolder
|
||||
: public jni::HybridClass<JSCallInvokerHolder> {
|
||||
class CallInvokerHolder
|
||||
: public jni::HybridClass<CallInvokerHolder> {
|
||||
public:
|
||||
static auto constexpr kJavaDescriptor =
|
||||
"Lcom/facebook/react/turbomodule/core/JSCallInvokerHolderImpl;";
|
||||
"Lcom/facebook/react/turbomodule/core/CallInvokerHolderImpl;";
|
||||
|
||||
static void registerNatives();
|
||||
std::shared_ptr<JSCallInvoker> getJSCallInvoker();
|
||||
std::shared_ptr<CallInvoker> getCallInvoker();
|
||||
|
||||
private:
|
||||
friend HybridBase;
|
||||
JSCallInvokerHolder(std::shared_ptr<JSCallInvoker> jsCallInvoker);
|
||||
std::shared_ptr<JSCallInvoker> _jsCallInvoker;
|
||||
CallInvokerHolder(std::shared_ptr<CallInvoker> callInvoker);
|
||||
std::shared_ptr<CallInvoker> _callInvoker;
|
||||
};
|
||||
|
||||
} // namespace react
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
#include "JSCallInvokerHolder.h"
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
JSCallInvokerHolder::JSCallInvokerHolder(
|
||||
std::shared_ptr<JSCallInvoker> jsCallInvoker)
|
||||
: _jsCallInvoker(jsCallInvoker) {}
|
||||
|
||||
std::shared_ptr<JSCallInvoker> JSCallInvokerHolder::getJSCallInvoker() {
|
||||
return _jsCallInvoker;
|
||||
}
|
||||
|
||||
void JSCallInvokerHolder::registerNatives() {}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
+3
-3
@@ -23,7 +23,7 @@ namespace react {
|
||||
TurboModuleManager::TurboModuleManager(
|
||||
jni::alias_ref<TurboModuleManager::javaobject> jThis,
|
||||
jsi::Runtime* rt,
|
||||
std::shared_ptr<JSCallInvoker> jsCallInvoker,
|
||||
std::shared_ptr<CallInvoker> jsCallInvoker,
|
||||
jni::alias_ref<TurboModuleManagerDelegate::javaobject> delegate
|
||||
):
|
||||
javaPart_(jni::make_global(jThis)),
|
||||
@@ -35,10 +35,10 @@ TurboModuleManager::TurboModuleManager(
|
||||
jni::local_ref<TurboModuleManager::jhybriddata> TurboModuleManager::initHybrid(
|
||||
jni::alias_ref<jhybridobject> jThis,
|
||||
jlong jsContext,
|
||||
jni::alias_ref<JSCallInvokerHolder::javaobject> jsCallInvokerHolder,
|
||||
jni::alias_ref<CallInvokerHolder::javaobject> jsCallInvokerHolder,
|
||||
jni::alias_ref<TurboModuleManagerDelegate::javaobject> delegate
|
||||
) {
|
||||
auto jsCallInvoker = jsCallInvokerHolder->cthis()->getJSCallInvoker();
|
||||
auto jsCallInvoker = jsCallInvokerHolder->cthis()->getCallInvoker();
|
||||
|
||||
return makeCxxInstance(jThis, (jsi::Runtime *) jsContext, jsCallInvoker, delegate);
|
||||
}
|
||||
|
||||
+4
-4
@@ -15,7 +15,7 @@
|
||||
#include <ReactCommon/JavaTurboModule.h>
|
||||
#include <react/jni/CxxModuleWrapper.h>
|
||||
#include <react/jni/JMessageQueueThread.h>
|
||||
#include <ReactCommon/JSCallInvokerHolder.h>
|
||||
#include <ReactCommon/CallInvokerHolder.h>
|
||||
#include <ReactCommon/TurboModuleManagerDelegate.h>
|
||||
|
||||
namespace facebook {
|
||||
@@ -27,7 +27,7 @@ public:
|
||||
static jni::local_ref<jhybriddata> initHybrid(
|
||||
jni::alias_ref<jhybridobject> jThis,
|
||||
jlong jsContext,
|
||||
jni::alias_ref<JSCallInvokerHolder::javaobject> jsCallInvokerHolder,
|
||||
jni::alias_ref<CallInvokerHolder::javaobject> jsCallInvokerHolder,
|
||||
jni::alias_ref<TurboModuleManagerDelegate::javaobject> delegate
|
||||
);
|
||||
static void registerNatives();
|
||||
@@ -35,7 +35,7 @@ private:
|
||||
friend HybridBase;
|
||||
jni::global_ref<TurboModuleManager::javaobject> javaPart_;
|
||||
jsi::Runtime* runtime_;
|
||||
std::shared_ptr<JSCallInvoker> jsCallInvoker_;
|
||||
std::shared_ptr<CallInvoker> jsCallInvoker_;
|
||||
jni::global_ref<TurboModuleManagerDelegate::javaobject> delegate_;
|
||||
|
||||
/**
|
||||
@@ -50,7 +50,7 @@ private:
|
||||
explicit TurboModuleManager(
|
||||
jni::alias_ref<TurboModuleManager::jhybridobject> jThis,
|
||||
jsi::Runtime *rt,
|
||||
std::shared_ptr<JSCallInvoker> jsCallInvoker,
|
||||
std::shared_ptr<CallInvoker> jsCallInvoker,
|
||||
jni::alias_ref<TurboModuleManagerDelegate::javaobject> delegate
|
||||
);
|
||||
};
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <ReactCommon/JavaTurboModule.h>
|
||||
#include <ReactCommon/JSCallInvoker.h>
|
||||
#include <ReactCommon/CallInvoker.h>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
|
||||
@@ -20,8 +20,8 @@ class TurboModuleManagerDelegate : public jni::HybridClass<TurboModuleManagerDel
|
||||
public:
|
||||
static auto constexpr kJavaDescriptor = "Lcom/facebook/react/turbomodule/core/TurboModuleManagerDelegate;";
|
||||
|
||||
virtual std::shared_ptr<TurboModule> getTurboModule(std::string name, jni::alias_ref<JTurboModule> turboModule, std::shared_ptr<JSCallInvoker> jsInvoker) = 0;
|
||||
virtual std::shared_ptr<TurboModule> getTurboModule(std::string name, std::shared_ptr<JSCallInvoker> jsInvoker) = 0;
|
||||
virtual std::shared_ptr<TurboModule> getTurboModule(std::string name, jni::alias_ref<JTurboModule> turboModule, std::shared_ptr<CallInvoker> jsInvoker) = 0;
|
||||
virtual std::shared_ptr<TurboModule> getTurboModule(std::string name, std::shared_ptr<CallInvoker> jsInvoker) = 0;
|
||||
|
||||
private:
|
||||
friend HybridBase;
|
||||
|
||||
Reference in New Issue
Block a user