Rename Registrar to PluginRegistrar in Win/GLFW C API (flutter/engine#21058)

This commit is contained in:
stuartmorgan 2020-09-09 20:15:03 -04:00 committed by GitHub
parent f034712531
commit dda761af69
14 changed files with 43 additions and 39 deletions

View File

@ -91,8 +91,8 @@ class PluginRegistrarManager {
auto insert_result =
registrars_.emplace(registrar_ref, std::make_unique<T>(registrar_ref));
auto& registrar_pair = *(insert_result.first);
FlutterDesktopRegistrarSetDestructionHandler(registrar_pair.first,
OnRegistrarDestroyed);
FlutterDesktopPluginRegistrarSetDestructionHandler(registrar_pair.first,
OnRegistrarDestroyed);
return static_cast<T*>(registrar_pair.second.get());
}

View File

@ -17,7 +17,7 @@ namespace flutter {
PluginRegistrar::PluginRegistrar(FlutterDesktopPluginRegistrarRef registrar)
: registrar_(registrar) {
auto core_messenger = FlutterDesktopRegistrarGetMessenger(registrar_);
auto core_messenger = FlutterDesktopPluginRegistrarGetMessenger(registrar_);
messenger_ = std::make_unique<BinaryMessengerImpl>(core_messenger);
}

View File

@ -39,8 +39,8 @@ class TestApi : public testing::StubFlutterApi {
last_message_callback_set_ = callback;
}
void RegistrarSetDestructionHandler(
FlutterDesktopOnRegistrarDestroyed callback) override {
void PluginRegistrarSetDestructionHandler(
FlutterDesktopOnPluginRegistrarDestroyed callback) override {
last_destruction_callback_set_ = callback;
}
@ -48,14 +48,15 @@ class TestApi : public testing::StubFlutterApi {
FlutterDesktopMessageCallback last_message_callback_set() {
return last_message_callback_set_;
}
FlutterDesktopOnRegistrarDestroyed last_destruction_callback_set() {
FlutterDesktopOnPluginRegistrarDestroyed last_destruction_callback_set() {
return last_destruction_callback_set_;
}
private:
const uint8_t* last_data_sent_ = nullptr;
FlutterDesktopMessageCallback last_message_callback_set_ = nullptr;
FlutterDesktopOnRegistrarDestroyed last_destruction_callback_set_ = nullptr;
FlutterDesktopOnPluginRegistrarDestroyed last_destruction_callback_set_ =
nullptr;
};
// A PluginRegistrar whose destruction can be watched for by tests.

View File

@ -38,17 +38,17 @@ ScopedStubFlutterApi::~ScopedStubFlutterApi() {
// Forwarding dummy implementations of the C API.
FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger(
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar) {
// The stub ignores this, so just return an arbitrary non-zero value.
return reinterpret_cast<FlutterDesktopMessengerRef>(1);
}
void FlutterDesktopRegistrarSetDestructionHandler(
void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
if (s_stub_implementation) {
s_stub_implementation->RegistrarSetDestructionHandler(callback);
s_stub_implementation->PluginRegistrarSetDestructionHandler(callback);
}
}

View File

@ -34,9 +34,9 @@ class StubFlutterApi {
virtual ~StubFlutterApi() {}
// Called for FlutterDesktopRegistrarSetDestructionHandler.
virtual void RegistrarSetDestructionHandler(
FlutterDesktopOnRegistrarDestroyed callback) {}
// Called for FlutterDesktopPluginRegistrarSetDestructionHandler.
virtual void PluginRegistrarSetDestructionHandler(
FlutterDesktopOnPluginRegistrarDestroyed callback) {}
// Called for FlutterDesktopMessengerSend.
virtual bool MessengerSend(const char* channel,

View File

@ -19,17 +19,18 @@ extern "C" {
typedef struct FlutterDesktopPluginRegistrar* FlutterDesktopPluginRegistrarRef;
// Function pointer type for registrar destruction callback.
typedef void (*FlutterDesktopOnRegistrarDestroyed)(
typedef void (*FlutterDesktopOnPluginRegistrarDestroyed)(
FlutterDesktopPluginRegistrarRef);
// Returns the engine messenger associated with this registrar.
FLUTTER_EXPORT FlutterDesktopMessengerRef
FlutterDesktopRegistrarGetMessenger(FlutterDesktopPluginRegistrarRef registrar);
FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar);
// Registers a callback to be called when the plugin registrar is destroyed.
FLUTTER_EXPORT void FlutterDesktopRegistrarSetDestructionHandler(
FLUTTER_EXPORT void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback);
FlutterDesktopOnPluginRegistrarDestroyed callback);
#if defined(__cplusplus)
} // extern "C"

View File

@ -23,7 +23,7 @@ class PluginRegistrarGlfw : public PluginRegistrar {
explicit PluginRegistrarGlfw(FlutterDesktopPluginRegistrarRef core_registrar)
: PluginRegistrar(core_registrar) {
window_ = std::make_unique<FlutterWindow>(
FlutterDesktopRegistrarGetWindow(core_registrar));
FlutterDesktopPluginRegistrarGetWindow(core_registrar));
}
virtual ~PluginRegistrarGlfw() = default;
@ -39,7 +39,8 @@ class PluginRegistrarGlfw : public PluginRegistrar {
// If set, then the parent window should disable input callbacks
// while waiting for the handler for messages on that channel to run.
void EnableInputBlockingForChannel(const std::string& channel) {
FlutterDesktopRegistrarEnableInputBlocking(registrar(), channel.c_str());
FlutterDesktopPluginRegistrarEnableInputBlocking(registrar(),
channel.c_str());
}
private:

View File

@ -183,10 +183,10 @@ FlutterDesktopPluginRegistrarRef FlutterDesktopGetPluginRegistrar(
return reinterpret_cast<FlutterDesktopPluginRegistrarRef>(2);
}
void FlutterDesktopRegistrarEnableInputBlocking(
void FlutterDesktopPluginRegistrarEnableInputBlocking(
FlutterDesktopPluginRegistrarRef registrar,
const char* channel) {
if (s_stub_implementation) {
s_stub_implementation->RegistrarEnableInputBlocking(channel);
s_stub_implementation->PluginRegistrarEnableInputBlocking(channel);
}
}

View File

@ -89,8 +89,8 @@ class StubFlutterGlfwApi {
// Called for FlutterDesktopShutDownEngine.
virtual bool ShutDownEngine() { return true; }
// Called for FlutterDesktopRegistrarEnableInputBlocking.
virtual void RegistrarEnableInputBlocking(const char* channel) {}
// Called for FlutterDesktopPluginRegistrarEnableInputBlocking.
virtual void PluginRegistrarEnableInputBlocking(const char* channel) {}
};
// A test helper that owns a stub implementation, making it the test stub for

View File

@ -138,7 +138,7 @@ struct FlutterDesktopPluginRegistrar {
FlutterDesktopEngineState* engine;
// Callback to be called on registrar destruction.
FlutterDesktopOnRegistrarDestroyed destruction_handler;
FlutterDesktopOnPluginRegistrarDestroyed destruction_handler;
};
// State associated with the messenger used to communicate with the engine.
@ -963,24 +963,24 @@ bool FlutterDesktopShutDownEngine(FlutterDesktopEngineRef engine) {
return (result == kSuccess);
}
void FlutterDesktopRegistrarEnableInputBlocking(
void FlutterDesktopPluginRegistrarEnableInputBlocking(
FlutterDesktopPluginRegistrarRef registrar,
const char* channel) {
registrar->engine->message_dispatcher->EnableInputBlockingForChannel(channel);
}
FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger(
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar) {
return registrar->engine->messenger.get();
}
void FlutterDesktopRegistrarSetDestructionHandler(
void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
registrar->destruction_handler = callback;
}
FlutterDesktopWindowRef FlutterDesktopRegistrarGetWindow(
FlutterDesktopWindowRef FlutterDesktopPluginRegistrarGetWindow(
FlutterDesktopPluginRegistrarRef registrar) {
FlutterDesktopWindowControllerState* controller =
registrar->engine->window_controller;

View File

@ -221,8 +221,8 @@ FLUTTER_EXPORT bool FlutterDesktopShutDownEngine(
// Returns the window associated with this registrar's engine instance.
//
// This is a GLFW shell-specific extension to flutter_plugin_registrar.h
FLUTTER_EXPORT FlutterDesktopWindowRef
FlutterDesktopRegistrarGetWindow(FlutterDesktopPluginRegistrarRef registrar);
FLUTTER_EXPORT FlutterDesktopWindowRef FlutterDesktopPluginRegistrarGetWindow(
FlutterDesktopPluginRegistrarRef registrar);
// Enables input blocking on the given channel.
//
@ -235,7 +235,7 @@ FlutterDesktopRegistrarGetWindow(FlutterDesktopPluginRegistrarRef registrar);
// default of disabled.
//
// This is a GLFW shell-specific extension to flutter_plugin_registrar.h
FLUTTER_EXPORT void FlutterDesktopRegistrarEnableInputBlocking(
FLUTTER_EXPORT void FlutterDesktopPluginRegistrarEnableInputBlocking(
FlutterDesktopPluginRegistrarRef registrar,
const char* channel);

View File

@ -196,14 +196,14 @@ void FlutterDesktopResyncOutputStreams() {
// Implementations of common/cpp/ API methods.
FlutterDesktopMessengerRef FlutterDesktopRegistrarGetMessenger(
FlutterDesktopMessengerRef FlutterDesktopPluginRegistrarGetMessenger(
FlutterDesktopPluginRegistrarRef registrar) {
return registrar->engine->messenger();
}
void FlutterDesktopRegistrarSetDestructionHandler(
void FlutterDesktopPluginRegistrarSetDestructionHandler(
FlutterDesktopPluginRegistrarRef registrar,
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
registrar->engine->SetPluginRegistrarDestructionCallback(callback);
}

View File

@ -217,7 +217,7 @@ FlutterDesktopPluginRegistrarRef FlutterWindowsEngine::GetRegistrar() {
}
void FlutterWindowsEngine::SetPluginRegistrarDestructionCallback(
FlutterDesktopOnRegistrarDestroyed callback) {
FlutterDesktopOnPluginRegistrarDestroyed callback) {
plugin_registrar_destruction_callback_ = callback;
}

View File

@ -63,7 +63,7 @@ class FlutterWindowsEngine {
// Sets |callback| to be called when the plugin registrar is destroyed.
void SetPluginRegistrarDestructionCallback(
FlutterDesktopOnRegistrarDestroyed callback);
FlutterDesktopOnPluginRegistrarDestroyed callback);
FLUTTER_API_SYMBOL(FlutterEngine) engine() { return engine_; }
@ -115,7 +115,8 @@ class FlutterWindowsEngine {
// A callback to be called when the engine (and thus the plugin registrar)
// is being destroyed.
FlutterDesktopOnRegistrarDestroyed plugin_registrar_destruction_callback_;
FlutterDesktopOnPluginRegistrarDestroyed
plugin_registrar_destruction_callback_;
// The manager for WindowProc delegate registration and callbacks.
std::unique_ptr<Win32WindowProcDelegateManager> window_proc_delegate_manager_;