mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-23 03:50:11 +08:00
Revert D4840716: Refactor interfaces
Differential Revision: D4840716 fbshipit-source-id: 1b6a6050d78ccbbd3c817621df1c1c989594fdb1
This commit is contained in:
committed by
Facebook Github Bot
parent
77bee75893
commit
5f37483466
@@ -39,6 +39,7 @@ cxx_library(
|
||||
preprocessor_flags = [
|
||||
"-DLOG_TAG=\"ReactNativeJNI\"",
|
||||
"-DWITH_FBSYSTRACE=1",
|
||||
"-DWITH_INSPECTOR=1",
|
||||
],
|
||||
soname = "libreactnativejnifb.$(ext)",
|
||||
visibility = [
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
// Copyright 2004-present Facebook. All Rights Reserved.
|
||||
|
||||
#include "JInspector.h"
|
||||
#include <jschelpers/JavaScriptCore.h>
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
#ifdef WITH_INSPECTOR
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
namespace {
|
||||
|
||||
class RemoteConnection : public IRemoteConnection {
|
||||
class RemoteConnection : public Inspector::RemoteConnection {
|
||||
public:
|
||||
RemoteConnection(jni::alias_ref<JRemoteConnection::javaobject> connection)
|
||||
: connection_(jni::make_global(connection)) {}
|
||||
|
||||
virtual void onMessage(std::string message) override {
|
||||
void onMessage(std::string message) override {
|
||||
connection_->onMessage(message);
|
||||
}
|
||||
|
||||
virtual void onDisconnect() override {
|
||||
void onDisconnect() override {
|
||||
connection_->onDisconnect();
|
||||
}
|
||||
private:
|
||||
@@ -43,7 +42,7 @@ void JRemoteConnection::onDisconnect() const {
|
||||
method(self());
|
||||
}
|
||||
|
||||
JLocalConnection::JLocalConnection(std::unique_ptr<ILocalConnection> connection)
|
||||
JLocalConnection::JLocalConnection(std::unique_ptr<Inspector::LocalConnection> connection)
|
||||
: connection_(std::move(connection)) {}
|
||||
|
||||
void JLocalConnection::sendMessage(std::string message) {
|
||||
@@ -61,17 +60,13 @@ void JLocalConnection::registerNatives() {
|
||||
});
|
||||
}
|
||||
|
||||
static IInspector* getInspectorInstance() {
|
||||
return JSC_JSInspectorGetInstance(true /*useCustomJSC*/);
|
||||
}
|
||||
|
||||
jni::global_ref<JInspector::javaobject> JInspector::instance(jni::alias_ref<jclass>) {
|
||||
static auto instance = jni::make_global(newObjectCxxArgs(getInspectorInstance()/*&Inspector::instance()*/));
|
||||
static auto instance = jni::make_global(newObjectCxxArgs(&Inspector::instance()));
|
||||
return instance;
|
||||
}
|
||||
|
||||
jni::local_ref<jni::JArrayClass<JPage::javaobject>> JInspector::getPages() {
|
||||
std::vector<InspectorPage> pages = inspector_->getPages();
|
||||
std::vector<Inspector::Page> pages = inspector_->getPages();
|
||||
auto array = jni::JArrayClass<JPage::javaobject>::newArray(pages.size());
|
||||
for (size_t i = 0; i < pages.size(); i++) {
|
||||
(*array)[i] = JPage::create(pages[i].id, pages[i].title);
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
#ifdef WITH_INSPECTOR
|
||||
|
||||
#include <jschelpers/InspectorInterfaces.h>
|
||||
#include <inspector/Inspector.h>
|
||||
|
||||
#include <fb/fbjni.h>
|
||||
#include <folly/Memory.h>
|
||||
@@ -31,14 +31,14 @@ class JLocalConnection : public jni::HybridClass<JLocalConnection> {
|
||||
public:
|
||||
static constexpr auto kJavaDescriptor = "Lcom/facebook/react/bridge/Inspector$LocalConnection;";
|
||||
|
||||
JLocalConnection(std::unique_ptr<ILocalConnection> connection);
|
||||
JLocalConnection(std::unique_ptr<Inspector::LocalConnection> connection);
|
||||
|
||||
void sendMessage(std::string message);
|
||||
void disconnect();
|
||||
|
||||
static void registerNatives();
|
||||
private:
|
||||
std::unique_ptr<ILocalConnection> connection_;
|
||||
std::unique_ptr<Inspector::LocalConnection> connection_;
|
||||
};
|
||||
|
||||
class JInspector : public jni::HybridClass<JInspector> {
|
||||
@@ -54,9 +54,9 @@ public:
|
||||
private:
|
||||
friend HybridBase;
|
||||
|
||||
JInspector(IInspector* inspector) : inspector_(inspector) {}
|
||||
JInspector(Inspector* inspector) : inspector_(inspector) {}
|
||||
|
||||
IInspector* inspector_;
|
||||
Inspector* inspector_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "JCallback.h"
|
||||
#include "JSLogging.h"
|
||||
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
#ifdef WITH_INSPECTOR
|
||||
#include "JInspector.h"
|
||||
#endif
|
||||
|
||||
@@ -171,7 +171,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
CxxModuleWrapperBase::registerNatives();
|
||||
CxxModuleWrapper::registerNatives();
|
||||
JCallbackImpl::registerNatives();
|
||||
#ifdef WITH_FBJSCEXTENSIONS
|
||||
#ifdef WITH_INSPECTOR
|
||||
JInspector::registerNatives();
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user