Skip to content

Commit 5f37483

Browse files
majakfacebook-github-bot
authored andcommitted
Revert D4840716: Refactor interfaces
Differential Revision: D4840716 fbshipit-source-id: 1b6a6050d78ccbbd3c817621df1c1c989594fdb1
1 parent 77bee75 commit 5f37483

File tree

11 files changed

+35
-126
lines changed

11 files changed

+35
-126
lines changed

ReactAndroid/src/main/jni/xreact/jni/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ cxx_library(
3939
preprocessor_flags = [
4040
"-DLOG_TAG=\"ReactNativeJNI\"",
4141
"-DWITH_FBSYSTRACE=1",
42+
"-DWITH_INSPECTOR=1",
4243
],
4344
soname = "libreactnativejnifb.$(ext)",
4445
visibility = [

ReactAndroid/src/main/jni/xreact/jni/JInspector.cpp

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
// Copyright 2004-present Facebook. All Rights Reserved.
22

33
#include "JInspector.h"
4-
#include <jschelpers/JavaScriptCore.h>
54

6-
#ifdef WITH_FBJSCEXTENSIONS
5+
#ifdef WITH_INSPECTOR
76

87
namespace facebook {
98
namespace react {
109

1110
namespace {
1211

13-
class RemoteConnection : public IRemoteConnection {
12+
class RemoteConnection : public Inspector::RemoteConnection {
1413
public:
1514
RemoteConnection(jni::alias_ref<JRemoteConnection::javaobject> connection)
1615
: connection_(jni::make_global(connection)) {}
1716

18-
virtual void onMessage(std::string message) override {
17+
void onMessage(std::string message) override {
1918
connection_->onMessage(message);
2019
}
2120

22-
virtual void onDisconnect() override {
21+
void onDisconnect() override {
2322
connection_->onDisconnect();
2423
}
2524
private:
@@ -43,7 +42,7 @@ void JRemoteConnection::onDisconnect() const {
4342
method(self());
4443
}
4544

46-
JLocalConnection::JLocalConnection(std::unique_ptr<ILocalConnection> connection)
45+
JLocalConnection::JLocalConnection(std::unique_ptr<Inspector::LocalConnection> connection)
4746
: connection_(std::move(connection)) {}
4847

4948
void JLocalConnection::sendMessage(std::string message) {
@@ -61,17 +60,13 @@ void JLocalConnection::registerNatives() {
6160
});
6261
}
6362

64-
static IInspector* getInspectorInstance() {
65-
return JSC_JSInspectorGetInstance(true /*useCustomJSC*/);
66-
}
67-
6863
jni::global_ref<JInspector::javaobject> JInspector::instance(jni::alias_ref<jclass>) {
69-
static auto instance = jni::make_global(newObjectCxxArgs(getInspectorInstance()/*&Inspector::instance()*/));
64+
static auto instance = jni::make_global(newObjectCxxArgs(&Inspector::instance()));
7065
return instance;
7166
}
7267

7368
jni::local_ref<jni::JArrayClass<JPage::javaobject>> JInspector::getPages() {
74-
std::vector<InspectorPage> pages = inspector_->getPages();
69+
std::vector<Inspector::Page> pages = inspector_->getPages();
7570
auto array = jni::JArrayClass<JPage::javaobject>::newArray(pages.size());
7671
for (size_t i = 0; i < pages.size(); i++) {
7772
(*array)[i] = JPage::create(pages[i].id, pages[i].title);

ReactAndroid/src/main/jni/xreact/jni/JInspector.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
#pragma once
44

5-
#ifdef WITH_FBJSCEXTENSIONS
5+
#ifdef WITH_INSPECTOR
66

7-
#include <jschelpers/InspectorInterfaces.h>
7+
#include <inspector/Inspector.h>
88

99
#include <fb/fbjni.h>
1010
#include <folly/Memory.h>
@@ -31,14 +31,14 @@ class JLocalConnection : public jni::HybridClass<JLocalConnection> {
3131
public:
3232
static constexpr auto kJavaDescriptor = "Lcom/facebook/react/bridge/Inspector$LocalConnection;";
3333

34-
JLocalConnection(std::unique_ptr<ILocalConnection> connection);
34+
JLocalConnection(std::unique_ptr<Inspector::LocalConnection> connection);
3535

3636
void sendMessage(std::string message);
3737
void disconnect();
3838

3939
static void registerNatives();
4040
private:
41-
std::unique_ptr<ILocalConnection> connection_;
41+
std::unique_ptr<Inspector::LocalConnection> connection_;
4242
};
4343

4444
class JInspector : public jni::HybridClass<JInspector> {
@@ -54,9 +54,9 @@ class JInspector : public jni::HybridClass<JInspector> {
5454
private:
5555
friend HybridBase;
5656

57-
JInspector(IInspector* inspector) : inspector_(inspector) {}
57+
JInspector(Inspector* inspector) : inspector_(inspector) {}
5858

59-
IInspector* inspector_;
59+
Inspector* inspector_;
6060
};
6161

6262
}

ReactAndroid/src/main/jni/xreact/jni/OnLoad.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include "JCallback.h"
1919
#include "JSLogging.h"
2020

21-
#ifdef WITH_FBJSCEXTENSIONS
21+
#ifdef WITH_INSPECTOR
2222
#include "JInspector.h"
2323
#endif
2424

@@ -171,7 +171,7 @@ extern "C" JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
171171
CxxModuleWrapperBase::registerNatives();
172172
CxxModuleWrapper::registerNatives();
173173
JCallbackImpl::registerNatives();
174-
#ifdef WITH_FBJSCEXTENSIONS
174+
#ifdef WITH_INSPECTOR
175175
JInspector::registerNatives();
176176
#endif
177177

ReactCommon/cxxreact/BUCK

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ if THIS_IS_FBANDROID:
3939
'-DWITH_JSC_MEMORY_PRESSURE=1',
4040
'-DWITH_REACT_INTERNAL_SETTINGS=1',
4141
'-DWITH_FB_MEMORY_PROFILING=1',
42+
'-DWITH_INSPECTOR=1',
4243
],
4344
deps = JSC_DEPS,
4445
visibility = [

ReactCommon/cxxreact/JSCExecutor.cpp

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
#include <jschelpers/JSCHelpers.h>
2020
#include <jschelpers/Value.h>
21-
#include <jschelpers/InspectorInterfaces.h>
21+
22+
#ifdef WITH_INSPECTOR
23+
#include <inspector/Inspector.h>
24+
#endif
2225

2326
#include "JSBundleType.h"
2427
#include "Platform.h"
@@ -217,16 +220,6 @@ void JSCExecutor::setContextName(const std::string& name) {
217220
JSC_JSGlobalContextSetName(m_context, jsName);
218221
}
219222

220-
static bool canUseInspector(JSContextRef context) {
221-
#if defined(__APPLE__)
222-
return isCustomJSCPtr(context);
223-
#elif defined(WITH_FBJSCEXTENSIONS)
224-
return true;
225-
#else
226-
return false;
227-
#endif
228-
}
229-
230223
void JSCExecutor::initOnJSVMThread() throw(JSException) {
231224
SystraceSection s("JSCExecutor.initOnJSVMThread");
232225

@@ -260,10 +253,9 @@ void JSCExecutor::initOnJSVMThread() throw(JSException) {
260253
// Add a pointer to ourselves so we can retrieve it later in our hooks
261254
Object::getGlobalObject(m_context).setPrivate(this);
262255

263-
if (canUseInspector(m_context)) {
264-
IInspector* pInspector = JSC_JSInspectorGetInstance(true);
265-
pInspector->registerGlobalContext("main", m_context);
266-
}
256+
#ifdef WITH_INSPECTOR
257+
Inspector::instance().registerGlobalContext("main", m_context);
258+
#endif
267259

268260
installNativeHook<&JSCExecutor::nativeFlushQueueImmediate>("nativeFlushQueueImmediate");
269261
installNativeHook<&JSCExecutor::nativeCallSyncHook>("nativeCallSyncHook");
@@ -319,10 +311,9 @@ void JSCExecutor::terminateOnJSVMThread() {
319311

320312
m_nativeModules.reset();
321313

322-
if (canUseInspector(m_context)) {
323-
IInspector* pInspector = JSC_JSInspectorGetInstance(true);
324-
pInspector->unregisterGlobalContext(m_context);
325-
}
314+
#ifdef WITH_INSPECTOR
315+
Inspector::instance().unregisterGlobalContext(m_context);
316+
#endif
326317

327318
JSC_JSGlobalContextRelease(m_context);
328319
m_context = nullptr;

ReactCommon/jschelpers/BUCK

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
EXPORTED_HEADERS = [
2-
"InspectorInterfaces.h",
32
"JavaScriptCore.h",
43
"JSCHelpers.h",
54
"JSCWrapper.h",

ReactCommon/jschelpers/InspectorInterfaces.h

Lines changed: 0 additions & 55 deletions
This file was deleted.

ReactCommon/jschelpers/JSCWrapper.h

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,19 @@
1515
#include <jsc_stringref.h>
1616
#endif
1717

18-
#include <jschelpers/InspectorInterfaces.h>
19-
20-
#if JSCINTERNAL || (!defined(__APPLE__))
21-
#define JSC_IMPORT extern "C"
22-
#else
23-
#define JSC_IMPORT extern
24-
#endif
25-
26-
JSC_IMPORT facebook::react::IInspector* JSInspectorGetInstance();
27-
28-
// This is used to substitute an alternate JSC implementation for
29-
// testing. These calls must all be ABI compatible with the standard JSC.
30-
JSC_IMPORT void configureJSCForIOS(std::string); // TODO: replace with folly::dynamic once supported
31-
JSC_IMPORT JSValueRef JSEvaluateBytecodeBundle(JSContextRef, JSObjectRef, int, JSStringRef, JSValueRef*);
32-
JSC_IMPORT bool JSSamplingProfilerEnabled();
33-
JSC_IMPORT void JSStartSamplingProfilingOnMainJSCThread(JSGlobalContextRef);
34-
JSC_IMPORT JSValueRef JSPokeSamplingProfiler(JSContextRef);
35-
3618
#if defined(__APPLE__)
3719
#import <objc/objc.h>
3820
#import <JavaScriptCore/JSStringRefCF.h>
3921
#import <string>
4022

23+
// This is used to substitute an alternate JSC implementation for
24+
// testing. These calls must all be ABI compatible with the standard JSC.
25+
extern void configureJSCForIOS(std::string); // TODO: replace with folly::dynamic once supported
26+
extern JSValueRef JSEvaluateBytecodeBundle(JSContextRef, JSObjectRef, int, JSStringRef, JSValueRef*);
27+
extern bool JSSamplingProfilerEnabled();
28+
extern void JSStartSamplingProfilingOnMainJSCThread(JSGlobalContextRef);
29+
extern JSValueRef JSPokeSamplingProfiler(JSContextRef);
30+
4131
/**
4232
* JSNoBytecodeFileFormatVersion
4333
*
@@ -124,8 +114,6 @@ struct JSCWrapper {
124114
JSC_WRAPPER_METHOD(JSPokeSamplingProfiler);
125115
JSC_WRAPPER_METHOD(JSStartSamplingProfilingOnMainJSCThread);
126116

127-
JSC_WRAPPER_METHOD(JSInspectorGetInstance);
128-
129117
JSC_WRAPPER_METHOD(configureJSCForIOS);
130118

131119
// Objective-C API

ReactCommon/jschelpers/JavaScriptCore.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ jsc_poison(JSObjectMakeArrayBufferWithBytesNoCopy JSObjectMakeTypedArray
182182
jsc_poison(JSSamplingProfilerEnabled JSPokeSamplingProfiler
183183
JSStartSamplingProfilingOnMainJSCThread)
184184

185-
#define JSC_JSInspectorGetInstance(...) __jsc_bool_wrapper(JSInspectorGetInstance, __VA_ARGS__)
186-
jsc_poison(JSInspectorGetInstance)
187-
188-
189185
#define JSC_configureJSCForIOS(...) __jsc_bool_wrapper(configureJSCForIOS, __VA_ARGS__)
190186

191187
jsc_poison(configureJSCForIOS)

0 commit comments

Comments
 (0)