summaryrefslogtreecommitdiffhomepage
path: root/api
diff options
context:
space:
mode:
Diffstat (limited to 'api')
-rw-r--r--api/plugin-api.cpp46
-rw-r--r--api/plugin-support.hpp29
2 files changed, 39 insertions, 36 deletions
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 <utility>
-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<Metadata_>(Meta());
+ std::unique_ptr<Metadata_> 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<std::shared_ptr<dylib>> 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<t> make_dylib_instance(const std::shared_ptr<dylib
{
std::shared_ptr<t> ret;
if (lib != nullptr && lib->Constructor)
- ret = std::shared_ptr<t>(reinterpret_cast<t*>(reinterpret_cast<OPENTRACK_CTOR_FUNPTR>(lib->Constructor)()));
+ ret = std::shared_ptr<t>(reinterpret_cast<t*>(reinterpret_cast<module_ctor_t>(lib->Constructor)()));
return ret;
}