Rename all The c++ JNI classes

Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/272

Reviewed By: passy

Differential Revision: D9861432

Pulled By: jknoxville

fbshipit-source-id: 523b8fc28541b922bbcc0939514f4ddd0a3fc1b0
This commit is contained in:
John Knox
2018-09-18 07:16:56 -07:00
committed by Facebook Github Bot
parent a480be90a2
commit 9d9fa17134
14 changed files with 94 additions and 94 deletions

View File

@@ -21,7 +21,7 @@
#include <Sonar/SonarClient.h> #include <Sonar/SonarClient.h>
#include <Sonar/SonarWebSocket.h> #include <Sonar/SonarWebSocket.h>
#include <Sonar/SonarConnection.h> #include <Sonar/SonarConnection.h>
#include <Sonar/SonarResponder.h> #include <Sonar/FlipperResponder.h>
#include <Sonar/SonarStateUpdateListener.h> #include <Sonar/SonarStateUpdateListener.h>
#include <Sonar/SonarState.h> #include <Sonar/SonarState.h>
@@ -62,11 +62,11 @@ class JEventBase : public jni::HybridClass<JEventBase> {
folly::EventBase eventBase_; folly::EventBase eventBase_;
}; };
class JSonarObject : public jni::JavaClass<JSonarObject> { class JFlipperObject : public jni::JavaClass<JFlipperObject> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarObject;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarObject;";
static jni::local_ref<JSonarObject> create(const folly::dynamic& json) { static jni::local_ref<JFlipperObject> create(const folly::dynamic& json) {
return newInstance(folly::toJson(json)); return newInstance(folly::toJson(json));
} }
@@ -76,11 +76,11 @@ class JSonarObject : public jni::JavaClass<JSonarObject> {
} }
}; };
class JSonarArray : public jni::JavaClass<JSonarArray> { class JFlipperArray : public jni::JavaClass<JFlipperArray> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarArray;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarArray;";
static jni::local_ref<JSonarArray> create(const folly::dynamic& json) { static jni::local_ref<JFlipperArray> create(const folly::dynamic& json) {
return newInstance(folly::toJson(json)); return newInstance(folly::toJson(json));
} }
@@ -90,75 +90,75 @@ class JSonarArray : public jni::JavaClass<JSonarArray> {
} }
}; };
class JSonarResponder : public jni::JavaClass<JSonarResponder> { class JFlipperResponder : public jni::JavaClass<JFlipperResponder> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarResponder;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/FlipperResponder;";
}; };
class JSonarResponderImpl : public jni::HybridClass<JSonarResponderImpl, JSonarResponder> { class JFlipperResponderImpl : public jni::HybridClass<JFlipperResponderImpl, JFlipperResponder> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/android/SonarResponderImpl;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/android/SonarResponderImpl;";
static void registerNatives() { static void registerNatives() {
registerHybrid({ registerHybrid({
makeNativeMethod("successObject", JSonarResponderImpl::successObject), makeNativeMethod("successObject", JFlipperResponderImpl::successObject),
makeNativeMethod("successArray", JSonarResponderImpl::successArray), makeNativeMethod("successArray", JFlipperResponderImpl::successArray),
makeNativeMethod("error", JSonarResponderImpl::error), makeNativeMethod("error", JFlipperResponderImpl::error),
}); });
} }
void successObject(jni::alias_ref<JSonarObject> json) { void successObject(jni::alias_ref<JFlipperObject> json) {
_responder->success(json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object()); _responder->success(json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object());
} }
void successArray(jni::alias_ref<JSonarArray> json) { void successArray(jni::alias_ref<JFlipperArray> json) {
_responder->success(json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object()); _responder->success(json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object());
} }
void error(jni::alias_ref<JSonarObject> json) { void error(jni::alias_ref<JFlipperObject> json) {
_responder->error(json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object()); _responder->error(json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object());
} }
private: private:
friend HybridBase; friend HybridBase;
std::shared_ptr<SonarResponder> _responder; std::shared_ptr<FlipperResponder> _responder;
JSonarResponderImpl(std::shared_ptr<SonarResponder> responder): _responder(std::move(responder)) {} JFlipperResponderImpl(std::shared_ptr<FlipperResponder> responder): _responder(std::move(responder)) {}
}; };
class JSonarReceiver : public jni::JavaClass<JSonarReceiver> { class JFlipperReceiver : public jni::JavaClass<JFlipperReceiver> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarReceiver;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarReceiver;";
void receive(const folly::dynamic params, std::shared_ptr<SonarResponder> responder) const { void receive(const folly::dynamic params, std::shared_ptr<FlipperResponder> responder) const {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSonarObject::javaobject>, jni::alias_ref<JSonarResponder::javaobject>)>("onReceive"); static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFlipperObject::javaobject>, jni::alias_ref<JFlipperResponder::javaobject>)>("onReceive");
method(self(), JSonarObject::create(std::move(params)), JSonarResponderImpl::newObjectCxxArgs(responder)); method(self(), JFlipperObject::create(std::move(params)), JFlipperResponderImpl::newObjectCxxArgs(responder));
} }
}; };
class JSonarConnection : public jni::JavaClass<JSonarConnection> { class JFlipperConnection : public jni::JavaClass<JFlipperConnection> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarConnection;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarConnection;";
}; };
class JSonarConnectionImpl : public jni::HybridClass<JSonarConnectionImpl, JSonarConnection> { class JFlipperConnectionImpl : public jni::HybridClass<JFlipperConnectionImpl, JFlipperConnection> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/android/SonarConnectionImpl;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/android/SonarConnectionImpl;";
static void registerNatives() { static void registerNatives() {
registerHybrid({ registerHybrid({
makeNativeMethod("sendObject", JSonarConnectionImpl::sendObject), makeNativeMethod("sendObject", JFlipperConnectionImpl::sendObject),
makeNativeMethod("sendArray", JSonarConnectionImpl::sendArray), makeNativeMethod("sendArray", JFlipperConnectionImpl::sendArray),
makeNativeMethod("reportError", JSonarConnectionImpl::reportError), makeNativeMethod("reportError", JFlipperConnectionImpl::reportError),
makeNativeMethod("receive", JSonarConnectionImpl::receive), makeNativeMethod("receive", JFlipperConnectionImpl::receive),
}); });
} }
void sendObject(const std::string method, jni::alias_ref<JSonarObject> json) { void sendObject(const std::string method, jni::alias_ref<JFlipperObject> json) {
_connection->send(std::move(method), json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object()); _connection->send(std::move(method), json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object());
} }
void sendArray(const std::string method, jni::alias_ref<JSonarArray> json) { void sendArray(const std::string method, jni::alias_ref<JFlipperArray> json) {
_connection->send(std::move(method), json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object()); _connection->send(std::move(method), json ? folly::parseJson(json->toJsonString()) : folly::dynamic::object());
} }
@@ -166,9 +166,9 @@ class JSonarConnectionImpl : public jni::HybridClass<JSonarConnectionImpl, JSona
_connection->error(throwable->toString(), throwable->getStackTrace()->toString()); _connection->error(throwable->toString(), throwable->getStackTrace()->toString());
} }
void receive(const std::string method, jni::alias_ref<JSonarReceiver> receiver) { void receive(const std::string method, jni::alias_ref<JFlipperReceiver> receiver) {
auto global = make_global(receiver); auto global = make_global(receiver);
_connection->receive(std::move(method), [global] (const folly::dynamic& params, std::unique_ptr<SonarResponder> responder) { _connection->receive(std::move(method), [global] (const folly::dynamic& params, std::unique_ptr<FlipperResponder> responder) {
global->receive(params, std::move(responder)); global->receive(params, std::move(responder));
}); });
} }
@@ -177,10 +177,10 @@ class JSonarConnectionImpl : public jni::HybridClass<JSonarConnectionImpl, JSona
friend HybridBase; friend HybridBase;
std::shared_ptr<SonarConnection> _connection; std::shared_ptr<SonarConnection> _connection;
JSonarConnectionImpl(std::shared_ptr<SonarConnection> connection): _connection(std::move(connection)) {} JFlipperConnectionImpl(std::shared_ptr<SonarConnection> connection): _connection(std::move(connection)) {}
}; };
class JSonarPlugin : public jni::JavaClass<JSonarPlugin> { class JFlipperPlugin : public jni::JavaClass<JFlipperPlugin> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarPlugin;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarPlugin;";
@@ -190,8 +190,8 @@ class JSonarPlugin : public jni::JavaClass<JSonarPlugin> {
} }
void didConnect(std::shared_ptr<SonarConnection> conn) { void didConnect(std::shared_ptr<SonarConnection> conn) {
static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JSonarConnection::javaobject>)>("onConnect"); static const auto method = javaClassStatic()->getMethod<void(jni::alias_ref<JFlipperConnection::javaobject>)>("onConnect");
method(self(), JSonarConnectionImpl::newObjectCxxArgs(conn)); method(self(), JFlipperConnectionImpl::newObjectCxxArgs(conn));
} }
void didDisconnect() { void didDisconnect() {
@@ -200,7 +200,7 @@ class JSonarPlugin : public jni::JavaClass<JSonarPlugin> {
} }
}; };
class JSonarStateUpdateListener : public jni::JavaClass<JSonarStateUpdateListener> { class JFlipperStateUpdateListener : public jni::JavaClass<JFlipperStateUpdateListener> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarStateUpdateListener;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/core/SonarStateUpdateListener;";
@@ -222,18 +222,18 @@ class JSonarStateUpdateListener : public jni::JavaClass<JSonarStateUpdateListene
} }
}; };
class AndroidSonarStateUpdateListener : public SonarStateUpdateListener { class AndroidFlipperStateUpdateListener : public SonarStateUpdateListener {
public: public:
AndroidSonarStateUpdateListener(jni::alias_ref<JSonarStateUpdateListener> stateListener); AndroidFlipperStateUpdateListener(jni::alias_ref<JFlipperStateUpdateListener> stateListener);
void onUpdate(); void onUpdate();
private: private:
jni::global_ref<JSonarStateUpdateListener> jStateListener; jni::global_ref<JFlipperStateUpdateListener> jStateListener;
}; };
class JSonarPluginWrapper : public SonarPlugin { class JFlipperPluginWrapper : public SonarPlugin {
public: public:
jni::global_ref<JSonarPlugin> jplugin; jni::global_ref<JFlipperPlugin> jplugin;
virtual std::string identifier() const override { virtual std::string identifier() const override {
return jplugin->identifier(); return jplugin->identifier();
@@ -247,7 +247,7 @@ class JSonarPluginWrapper : public SonarPlugin {
jplugin->didDisconnect(); jplugin->didDisconnect();
} }
JSonarPluginWrapper(jni::global_ref<JSonarPlugin> plugin): jplugin(plugin) {} JFlipperPluginWrapper(jni::global_ref<JFlipperPlugin> plugin): jplugin(plugin) {}
}; };
struct JStateSummary : public jni::JavaClass<JStateSummary> { struct JStateSummary : public jni::JavaClass<JStateSummary> {
@@ -265,27 +265,27 @@ public:
}; };
class JSonarClient : public jni::HybridClass<JSonarClient> { class JFlipperClient : public jni::HybridClass<JFlipperClient> {
public: public:
constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/android/SonarClientImpl;"; constexpr static auto kJavaDescriptor = "Lcom/facebook/sonar/android/SonarClientImpl;";
static void registerNatives() { static void registerNatives() {
registerHybrid({ registerHybrid({
makeNativeMethod("init", JSonarClient::init), makeNativeMethod("init", JFlipperClient::init),
makeNativeMethod("getInstance", JSonarClient::getInstance), makeNativeMethod("getInstance", JFlipperClient::getInstance),
makeNativeMethod("start", JSonarClient::start), makeNativeMethod("start", JFlipperClient::start),
makeNativeMethod("stop", JSonarClient::stop), makeNativeMethod("stop", JFlipperClient::stop),
makeNativeMethod("addPlugin", JSonarClient::addPlugin), makeNativeMethod("addPlugin", JFlipperClient::addPlugin),
makeNativeMethod("removePlugin", JSonarClient::removePlugin), makeNativeMethod("removePlugin", JFlipperClient::removePlugin),
makeNativeMethod("subscribeForUpdates", JSonarClient::subscribeForUpdates), makeNativeMethod("subscribeForUpdates", JFlipperClient::subscribeForUpdates),
makeNativeMethod("unsubscribe", JSonarClient::unsubscribe), makeNativeMethod("unsubscribe", JFlipperClient::unsubscribe),
makeNativeMethod("getPlugin", JSonarClient::getPlugin), makeNativeMethod("getPlugin", JFlipperClient::getPlugin),
makeNativeMethod("getState", JSonarClient::getState), makeNativeMethod("getState", JFlipperClient::getState),
makeNativeMethod("getStateSummary", JSonarClient::getStateSummary), makeNativeMethod("getStateSummary", JFlipperClient::getStateSummary),
}); });
} }
static jni::alias_ref<JSonarClient::javaobject> getInstance(jni::alias_ref<jclass>) { static jni::alias_ref<JFlipperClient::javaobject> getInstance(jni::alias_ref<jclass>) {
static auto client = make_global(newObjectCxxArgs()); static auto client = make_global(newObjectCxxArgs());
return client; return client;
} }
@@ -298,19 +298,19 @@ class JSonarClient : public jni::HybridClass<JSonarClient> {
SonarClient::instance()->stop(); SonarClient::instance()->stop();
} }
void addPlugin(jni::alias_ref<JSonarPlugin> plugin) { void addPlugin(jni::alias_ref<JFlipperPlugin> plugin) {
auto wrapper = std::make_shared<JSonarPluginWrapper>(make_global(plugin)); auto wrapper = std::make_shared<JFlipperPluginWrapper>(make_global(plugin));
SonarClient::instance()->addPlugin(wrapper); SonarClient::instance()->addPlugin(wrapper);
} }
void removePlugin(jni::alias_ref<JSonarPlugin> plugin) { void removePlugin(jni::alias_ref<JFlipperPlugin> plugin) {
auto client = SonarClient::instance(); auto client = SonarClient::instance();
client->removePlugin(client->getPlugin(plugin->identifier())); client->removePlugin(client->getPlugin(plugin->identifier()));
} }
void subscribeForUpdates(jni::alias_ref<JSonarStateUpdateListener> stateListener) { void subscribeForUpdates(jni::alias_ref<JFlipperStateUpdateListener> stateListener) {
auto client = SonarClient::instance(); auto client = SonarClient::instance();
mStateListener = std::make_shared<AndroidSonarStateUpdateListener>(stateListener); mStateListener = std::make_shared<AndroidFlipperStateUpdateListener>(stateListener);
client->setStateListener(mStateListener); client->setStateListener(mStateListener);
} }
@@ -339,10 +339,10 @@ class JSonarClient : public jni::HybridClass<JSonarClient> {
return summary; return summary;
} }
jni::alias_ref<JSonarPlugin> getPlugin(const std::string& identifier) { jni::alias_ref<JFlipperPlugin> getPlugin(const std::string& identifier) {
auto plugin = SonarClient::instance()->getPlugin(identifier); auto plugin = SonarClient::instance()->getPlugin(identifier);
if (plugin) { if (plugin) {
auto wrapper = std::static_pointer_cast<JSonarPluginWrapper>(plugin); auto wrapper = std::static_pointer_cast<JFlipperPluginWrapper>(plugin);
return wrapper->jplugin; return wrapper->jplugin;
} else { } else {
return nullptr; return nullptr;
@@ -379,24 +379,24 @@ class JSonarClient : public jni::HybridClass<JSonarClient> {
private: private:
friend HybridBase; friend HybridBase;
std::shared_ptr<SonarStateUpdateListener> mStateListener = nullptr; std::shared_ptr<SonarStateUpdateListener> mStateListener = nullptr;
JSonarClient() {} JFlipperClient() {}
}; };
} // namespace } // namespace
jint JNI_OnLoad(JavaVM* vm, void*) { jint JNI_OnLoad(JavaVM* vm, void*) {
return jni::initialize(vm, [] { return jni::initialize(vm, [] {
JSonarClient::registerNatives(); JFlipperClient::registerNatives();
JSonarConnectionImpl::registerNatives(); JFlipperConnectionImpl::registerNatives();
JSonarResponderImpl::registerNatives(); JFlipperResponderImpl::registerNatives();
JEventBase::registerNatives(); JEventBase::registerNatives();
}); });
} }
AndroidSonarStateUpdateListener::AndroidSonarStateUpdateListener(jni::alias_ref<JSonarStateUpdateListener> stateListener) { AndroidFlipperStateUpdateListener::AndroidFlipperStateUpdateListener(jni::alias_ref<JFlipperStateUpdateListener> stateListener) {
jStateListener = jni::make_global(stateListener); jStateListener = jni::make_global(stateListener);
} }
void AndroidSonarStateUpdateListener::onUpdate() { void AndroidFlipperStateUpdateListener::onUpdate() {
jStateListener->onUpdate(); jStateListener->onUpdate();
} }

View File

@@ -8,7 +8,7 @@
package com.facebook.sonar.core; package com.facebook.sonar.core;
/** /**
* SonarResponder is used to asyncronously response to a messaged recieved from the Sonar desktop * FlipperResponder is used to asyncronously response to a messaged recieved from the Sonar desktop
* app. The Sonar Responder will automatically wrap the response in an approriate object depending * app. The Sonar Responder will automatically wrap the response in an approriate object depending
* on if it is an error or not. * on if it is an error or not.
*/ */

View File

@@ -66,7 +66,7 @@ Using the `SonarConnection` object you can register a receiver of a desktop meth
```java ```java
connection.receive("getData", new SonarReceiver() { connection.receive("getData", new SonarReceiver() {
@Override @Override
public void onReceive(SonarObject params, SonarResponder responder) throws Exception { public void onReceive(SonarObject params, FlipperResponder responder) throws Exception {
responder.success( responder.success(
new SonarObject.Builder() new SonarObject.Builder()
.put("data", MyData.get()) .put("data", MyData.get())
@@ -87,7 +87,7 @@ connection.receive("getData", new SonarReceiver() {
- (void)didConnect:(SonarConnection*)connection - (void)didConnect:(SonarConnection*)connection
{ {
[connection receive:@"getData" withBlock:^(NSDictionary *params, SonarResponder *responder) { [connection receive:@"getData" withBlock:^(NSDictionary *params, FlipperResponder *responder) {
[responder success:@{ [responder success:@{
@"data":[MyData get], @"data":[MyData get],
}]; }];
@@ -104,7 +104,7 @@ connection.receive("getData", new SonarReceiver() {
```c++ ```c++
void MySonarPlugin::didConnect(std::shared_ptr<SonarConnection> conn) { void MySonarPlugin::didConnect(std::shared_ptr<SonarConnection> conn) {
conn->receive("getData", [](const folly::dynamic &params, conn->receive("getData", [](const folly::dynamic &params,
std::unique_ptr<SonarResponder> responder) { std::unique_ptr<FlipperResponder> responder) {
dynamic response = folly::dynamic::object("data", getMyData()); dynamic response = folly::dynamic::object("data", getMyData());
responder->success(response); responder->success(response);
}); });

View File

@@ -64,7 +64,7 @@ Pod::Spec.new do |spec|
'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKResponseInfo.h', 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SKResponseInfo.h',
'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SonarKitNetworkPlugin.h', 'iOS/Plugins/SonarKitNetworkPlugin/SonarKitNetworkPlugin/SonarKitNetworkPlugin.h',
'iOS/FBDefines/FBMacros.h', 'iOS/FBDefines/FBMacros.h',
'iOS/SonarKit/**/{FlipperStateUpdateListener,SonarClient,SonarPlugin,SonarConnection,SonarResponder,SKMacros}.h' 'iOS/SonarKit/**/{FlipperStateUpdateListener,SonarClient,SonarPlugin,SonarConnection,FlipperResponder,SKMacros}.h'
header_search_paths = "\"$(PODS_ROOT)/SonarKit/iOS/SonarKit\" \"$(PODS_ROOT)\"/Headers/Private/SonarKit/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\"" header_search_paths = "\"$(PODS_ROOT)/SonarKit/iOS/SonarKit\" \"$(PODS_ROOT)\"/Headers/Private/SonarKit/** \"$(PODS_ROOT)/boost-for-react-native\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/PeerTalkSonar\""
ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", ss.pod_target_xcconfig = { "USE_HEADERMAP" => "NO",
"DEFINES_MODULE" => "YES", "DEFINES_MODULE" => "YES",

View File

@@ -100,7 +100,7 @@
53D4C50A20A5B72800613A96 /* SonarClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1120A4BAB900A371E3 /* SonarClient.h */; }; 53D4C50A20A5B72800613A96 /* SonarClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1120A4BAB900A371E3 /* SonarClient.h */; };
53D4C50B20A5B72800613A96 /* SonarConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1820A4BAB900A371E3 /* SonarConnection.h */; }; 53D4C50B20A5B72800613A96 /* SonarConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1820A4BAB900A371E3 /* SonarConnection.h */; };
53D4C50C20A5B72800613A96 /* SonarPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1620A4BAB900A371E3 /* SonarPlugin.h */; }; 53D4C50C20A5B72800613A96 /* SonarPlugin.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1620A4BAB900A371E3 /* SonarPlugin.h */; };
53D4C50D20A5B72800613A96 /* SonarResponder.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1320A4BAB900A371E3 /* SonarResponder.h */; }; 53D4C50D20A5B72800613A96 /* FlipperResponder.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1320A4BAB900A371E3 /* FlipperResponder.h */; };
53D4C50F20A5B72800613A96 /* SKPortForwardingServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1B20A4BABA00A371E3 /* SKPortForwardingServer.h */; }; 53D4C50F20A5B72800613A96 /* SKPortForwardingServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1B20A4BABA00A371E3 /* SKPortForwardingServer.h */; };
53D4C51020A5B72800613A96 /* SKPortForwardingCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1C20A4BABA00A371E3 /* SKPortForwardingCommon.h */; }; 53D4C51020A5B72800613A96 /* SKPortForwardingCommon.h in Headers */ = {isa = PBXBuildFile; fileRef = 53D19A1C20A4BABA00A371E3 /* SKPortForwardingCommon.h */; };
53D4C51220A5B89900613A96 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53D4C51120A5B89900613A96 /* Foundation.framework */; }; 53D4C51220A5B89900613A96 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 53D4C51120A5B89900613A96 /* Foundation.framework */; };
@@ -195,7 +195,7 @@
53D19A1020A4BAB900A371E3 /* SKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKMacros.h; sourceTree = "<group>"; }; 53D19A1020A4BAB900A371E3 /* SKMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SKMacros.h; sourceTree = "<group>"; };
53D19A1120A4BAB900A371E3 /* SonarClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarClient.h; sourceTree = "<group>"; }; 53D19A1120A4BAB900A371E3 /* SonarClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarClient.h; sourceTree = "<group>"; };
53D19A1220A4BAB900A371E3 /* SonarClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SonarClient.mm; sourceTree = "<group>"; }; 53D19A1220A4BAB900A371E3 /* SonarClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SonarClient.mm; sourceTree = "<group>"; };
53D19A1320A4BAB900A371E3 /* SonarResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarResponder.h; sourceTree = "<group>"; }; 53D19A1320A4BAB900A371E3 /* FlipperResponder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FlipperResponder.h; sourceTree = "<group>"; };
53D19A1420A4BAB900A371E3 /* SonarUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SonarUtil.m; sourceTree = "<group>"; }; 53D19A1420A4BAB900A371E3 /* SonarUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SonarUtil.m; sourceTree = "<group>"; };
53D19A1620A4BAB900A371E3 /* SonarPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarPlugin.h; sourceTree = "<group>"; }; 53D19A1620A4BAB900A371E3 /* SonarPlugin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarPlugin.h; sourceTree = "<group>"; };
53D19A1820A4BAB900A371E3 /* SonarConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarConnection.h; sourceTree = "<group>"; }; 53D19A1820A4BAB900A371E3 /* SonarConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SonarConnection.h; sourceTree = "<group>"; };
@@ -427,7 +427,7 @@
53D19A1220A4BAB900A371E3 /* SonarClient.mm */, 53D19A1220A4BAB900A371E3 /* SonarClient.mm */,
53D19A1820A4BAB900A371E3 /* SonarConnection.h */, 53D19A1820A4BAB900A371E3 /* SonarConnection.h */,
53D19A1620A4BAB900A371E3 /* SonarPlugin.h */, 53D19A1620A4BAB900A371E3 /* SonarPlugin.h */,
53D19A1320A4BAB900A371E3 /* SonarResponder.h */, 53D19A1320A4BAB900A371E3 /* FlipperResponder.h */,
53D19A1420A4BAB900A371E3 /* SonarUtil.m */, 53D19A1420A4BAB900A371E3 /* SonarUtil.m */,
53D19A1920A4BABA00A371E3 /* Utilities */, 53D19A1920A4BABA00A371E3 /* Utilities */,
53D19A0920A4BA3600A371E3 /* Info.plist */, 53D19A0920A4BA3600A371E3 /* Info.plist */,
@@ -504,7 +504,7 @@
537A854221123223004A52BB /* SKSwizzle.h in Headers */, 537A854221123223004A52BB /* SKSwizzle.h in Headers */,
537A853321123223004A52BB /* SKComponentHostingViewDescriptor.h in Headers */, 537A853321123223004A52BB /* SKComponentHostingViewDescriptor.h in Headers */,
537A853221123223004A52BB /* SonarKitLayoutComponentKitSupport.h in Headers */, 537A853221123223004A52BB /* SonarKitLayoutComponentKitSupport.h in Headers */,
53D4C50D20A5B72800613A96 /* SonarResponder.h in Headers */, 53D4C50D20A5B72800613A96 /* FlipperResponder.h in Headers */,
537A853D21123223004A52BB /* SKHighlightOverlay.h in Headers */, 537A853D21123223004A52BB /* SKHighlightOverlay.h in Headers */,
537A854C21123223004A52BB /* SonarKitLayoutPlugin.h in Headers */, 537A854C21123223004A52BB /* SonarKitLayoutPlugin.h in Headers */,
537A850E21123223004A52BB /* SonarKitNetworkPlugin.h in Headers */, 537A850E21123223004A52BB /* SonarKitNetworkPlugin.h in Headers */,

View File

@@ -34,7 +34,7 @@
- (void)receive:(NSString *)method withBlock:(SonarReceiver)receiver - (void)receive:(NSString *)method withBlock:(SonarReceiver)receiver
{ {
const auto lambda = [receiver](const folly::dynamic &message, const auto lambda = [receiver](const folly::dynamic &message,
std::unique_ptr<facebook::flipper::SonarResponder> responder) { std::unique_ptr<facebook::flipper::FlipperResponder> responder) {
@autoreleasepool { @autoreleasepool {
SonarCppBridgingResponder *const objCResponder = SonarCppBridgingResponder *const objCResponder =
[[SonarCppBridgingResponder alloc] initWithCppResponder:std::move(responder)]; [[SonarCppBridgingResponder alloc] initWithCppResponder:std::move(responder)];

View File

@@ -5,7 +5,7 @@
* file in the root directory of this source tree. * file in the root directory of this source tree.
* *
*/ */
#import <Sonar/SonarResponder.h> #import <Sonar/FlipperResponder.h>
#import <SonarKit/SonarResponder.h> #import <SonarKit/SonarResponder.h>
/** /**
@@ -14,5 +14,5 @@ that forwards messages to the underlying C++ responder. This class allows
pure Objective-C plugins to send messages to the underlying responder. pure Objective-C plugins to send messages to the underlying responder.
*/ */
@interface SonarCppBridgingResponder : NSObject <SonarResponder> @interface SonarCppBridgingResponder : NSObject <SonarResponder>
- (instancetype)initWithCppResponder:(std::unique_ptr<facebook::flipper::SonarResponder>)responder; - (instancetype)initWithCppResponder:(std::unique_ptr<facebook::flipper::FlipperResponder>)responder;
@end @end

View File

@@ -10,10 +10,10 @@
#import <FBCxxUtils/FBCxxFollyDynamicConvert.h> #import <FBCxxUtils/FBCxxFollyDynamicConvert.h>
@implementation SonarCppBridgingResponder { @implementation SonarCppBridgingResponder {
std::unique_ptr<facebook::flipper::SonarResponder> responder_; std::unique_ptr<facebook::flipper::FlipperResponder> responder_;
} }
- (instancetype)initWithCppResponder:(std::unique_ptr<facebook::flipper::SonarResponder>)responder - (instancetype)initWithCppResponder:(std::unique_ptr<facebook::flipper::FlipperResponder>)responder
{ {
if (!responder) { if (!responder) {
return nil; return nil;

View File

@@ -14,12 +14,12 @@ namespace facebook {
namespace flipper { namespace flipper {
/** /**
* SonarResponder is used to asynchronously respond to messages * FlipperResponder is used to asynchronously respond to messages
* received from the Sonar desktop app. * received from the Sonar desktop app.
*/ */
class SonarResponder { class FlipperResponder {
public: public:
virtual ~SonarResponder(){}; virtual ~FlipperResponder(){};
/** /**
* Deliver a successful response to the Sonar desktop app. * Deliver a successful response to the Sonar desktop app.
@@ -32,5 +32,5 @@ class SonarResponder {
virtual void error(const folly::dynamic& response) const = 0; virtual void error(const folly::dynamic& response) const = 0;
}; };
} // namespace flipper } // namespace sonar
} // namespace facebook } // namespace facebook

View File

@@ -8,7 +8,7 @@
#pragma once #pragma once
#include <Sonar/SonarResponder.h> #include <Sonar/FlipperResponder.h>
#include <folly/json.h> #include <folly/json.h>
#include <functional> #include <functional>
#include <string> #include <string>
@@ -23,7 +23,7 @@ with corresponding identifiers.
class SonarConnection { class SonarConnection {
public: public:
using SonarReceiver = std::function< using SonarReceiver = std::function<
void(const folly::dynamic&, std::unique_ptr<SonarResponder>)>; void(const folly::dynamic&, std::unique_ptr<FlipperResponder>)>;
virtual ~SonarConnection() {} virtual ~SonarConnection() {}

View File

@@ -24,7 +24,7 @@ class SonarConnectionImpl : public SonarConnection {
void call( void call(
const std::string& method, const std::string& method,
const folly::dynamic& params, const folly::dynamic& params,
std::unique_ptr<SonarResponder> responder) { std::unique_ptr<FlipperResponder> responder) {
if (receivers_.find(method) == receivers_.end()) { if (receivers_.find(method) == receivers_.end()) {
throw std::out_of_range("receiver " + method + " not found."); throw std::out_of_range("receiver " + method + " not found.");
} }

View File

@@ -8,14 +8,14 @@
#pragma once #pragma once
#include <Sonar/SonarResponder.h> #include <Sonar/FlipperResponder.h>
#include <Sonar/SonarWebSocket.h> #include <Sonar/SonarWebSocket.h>
#include <folly/json.h> #include <folly/json.h>
namespace facebook { namespace facebook {
namespace flipper { namespace flipper {
class SonarResponderImpl : public SonarResponder { class SonarResponderImpl : public FlipperResponder {
public: public:
SonarResponderImpl(SonarWebSocket* socket, int64_t responseID) SonarResponderImpl(SonarWebSocket* socket, int64_t responseID)
: socket_(socket), responseID_(responseID) {} : socket_(socket), responseID_(responseID) {}

View File

@@ -8,14 +8,14 @@
#pragma once #pragma once
#include <Sonar/SonarResponder.h> #include <Sonar/FlipperResponder.h>
#include <folly/json.h> #include <folly/json.h>
#include <vector> #include <vector>
namespace facebook { namespace facebook {
namespace flipper { namespace flipper {
class SonarResponderMock : public SonarResponder { class SonarResponderMock : public FlipperResponder {
public: public:
SonarResponderMock( SonarResponderMock(
std::vector<folly::dynamic>* successes = nullptr, std::vector<folly::dynamic>* successes = nullptr,

View File

@@ -207,7 +207,7 @@ TEST(SonarClientTests, testExecute) {
const auto connectionCallback = [](std::shared_ptr<SonarConnection> conn) { const auto connectionCallback = [](std::shared_ptr<SonarConnection> conn) {
const auto receiver = [](const dynamic &params, const auto receiver = [](const dynamic &params,
std::unique_ptr<SonarResponder> responder) { std::unique_ptr<FlipperResponder> responder) {
dynamic payload = dynamic::object("message", "yes_i_hear_u"); dynamic payload = dynamic::object("message", "yes_i_hear_u");
responder->success(payload); responder->success(payload);
}; };
@@ -236,7 +236,7 @@ TEST(SonarClientTests, testExecuteWithParams) {
const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) { const auto connectionCallback = [&](std::shared_ptr<SonarConnection> conn) {
const auto receiver = [](const dynamic &params, const auto receiver = [](const dynamic &params,
std::unique_ptr<SonarResponder> responder) { std::unique_ptr<FlipperResponder> responder) {
const auto &first = params["first"].asString(); const auto &first = params["first"].asString();
const auto &second = params["second"].asString(); const auto &second = params["second"].asString();
std::map<std::string, std::string> m{{"dog", "woof"}, {"cat", "meow"}}; std::map<std::string, std::string> m{{"dog", "woof"}, {"cat", "meow"}};