From 709fe557a3a5c2dc8675472dac9325f8efdff004 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 7 Dec 2018 08:43:03 +0100 Subject: clean up a bit --- api/plugin-api.cpp | 46 ++++++++++++++++++++++++---------------------- api/plugin-support.hpp | 29 +++++++++++++++-------------- 2 files changed, 39 insertions(+), 36 deletions(-) (limited to 'api') diff --git a/api/plugin-api.cpp b/api/plugin-api.cpp index 5a485d62..404ed434 100644 --- a/api/plugin-api.cpp +++ b/api/plugin-api.cpp @@ -2,7 +2,28 @@ #include -using namespace plugin_api::detail; +namespace plugin_api::detail { + +BaseDialog::BaseDialog() = default; +void BaseDialog::closeEvent(QCloseEvent*) +{ + if (isVisible()) + { + hide(); + emit closing(); + } +} + +void BaseDialog::done(int) +{ + if (isVisible()) + { + hide(); + close(); + } +} + +} // ns plugin_api::detail // these exist so that vtable is emitted in a single compilation unit, not all of them. @@ -15,17 +36,6 @@ IExtension::~IExtension() = default; void ITrackerDialog::register_tracker(ITracker*) {} void ITrackerDialog::unregister_tracker() {} -BaseDialog::BaseDialog() = default; - -void BaseDialog::closeEvent(QCloseEvent*) -{ - if (isVisible()) - { - hide(); - emit closing(); - } -} - bool ITracker::center() { return false; } module_status ITracker::status_ok() @@ -46,15 +56,6 @@ IProtocolDialog::IProtocolDialog() = default; ITracker::ITracker() = default; ITrackerDialog::ITrackerDialog() = default; -void BaseDialog::done(int) -{ - if (isVisible()) - { - hide(); - close(); - } -} - IExtensionDialog::~IExtensionDialog() = default; bool module_status::is_ok() const @@ -71,6 +72,7 @@ module_status module_status_mixin::error(const QString& error) return module_status(error.isEmpty() ? "Unknown error" : error); } - Metadata::Metadata() = default; Metadata::~Metadata() = default; + + diff --git a/api/plugin-support.hpp b/api/plugin-support.hpp index 5062a688..34eee1a4 100644 --- a/api/plugin-support.hpp +++ b/api/plugin-support.hpp @@ -31,8 +31,10 @@ #define OPENTRACK_SOLIB_PREFIX "" -extern "C" typedef void* (*OPENTRACK_CTOR_FUNPTR)(void); -extern "C" typedef Metadata_* (*OPENTRACK_METADATA_FUNPTR)(void); +extern "C" { + using module_ctor_t = void* (*)(void); + using module_metadata_t = Metadata_* (*)(void); +} struct dylib final { @@ -63,26 +65,25 @@ struct dylib final if (check(!handle.load())) return; - if (check((Dialog = (OPENTRACK_CTOR_FUNPTR) handle.resolve("GetDialog"), !Dialog))) + if (check((Dialog = (module_ctor_t) handle.resolve("GetDialog"), !Dialog))) return; - if (check((Constructor = (OPENTRACK_CTOR_FUNPTR) handle.resolve("GetConstructor"), !Constructor))) + if (check((Constructor = (module_ctor_t) handle.resolve("GetConstructor"), !Constructor))) return; - if (check((Meta = (OPENTRACK_METADATA_FUNPTR) handle.resolve("GetMetadata"), !Meta))) + if (check((Meta = (module_metadata_t) handle.resolve("GetMetadata"), !Meta))) return; - auto m = std::unique_ptr(Meta()); + std::unique_ptr m{Meta()}; icon = m->icon(); name = m->name(); type = t; } - ~dylib() - { - // QLibrary refcounts the .dll's so don't forcefully unload - } + + // QLibrary refcounts the .dll's so don't forcefully unload + ~dylib() = default; static QList> enum_libraries(const QString& library_path) { @@ -134,9 +135,9 @@ struct dylib final QIcon icon; QString name; - OPENTRACK_CTOR_FUNPTR Dialog; - OPENTRACK_CTOR_FUNPTR Constructor; - OPENTRACK_METADATA_FUNPTR Meta; + module_ctor_t Dialog; + module_ctor_t Constructor; + module_metadata_t Meta; private: QLibrary handle; @@ -242,6 +243,6 @@ static inline std::shared_ptr make_dylib_instance(const std::shared_ptr ret; if (lib != nullptr && lib->Constructor) - ret = std::shared_ptr(reinterpret_cast(reinterpret_cast(lib->Constructor)())); + ret = std::shared_ptr(reinterpret_cast(reinterpret_cast(lib->Constructor)())); return ret; } -- cgit v1.2.3