diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-06 12:44:13 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-07-06 12:48:13 +0200 |
commit | f4b1e06604c74bb56a88c7e9284c77ffbd1acc78 (patch) | |
tree | 1c7f96776b7c8a5db9d649c91f441105205498ad | |
parent | fcb8ca75c0c274be2321f0ba91e9f129ae63e354 (diff) |
make "make_dylib_instance" part of public API
For @gagagu.
Issue: #151
-rw-r--r-- | opentrack/plugin-support.hpp | 9 | ||||
-rw-r--r-- | opentrack/selected-libraries.cpp | 15 |
2 files changed, 12 insertions, 12 deletions
diff --git a/opentrack/plugin-support.hpp b/opentrack/plugin-support.hpp index 627bce6a..32f79e0e 100644 --- a/opentrack/plugin-support.hpp +++ b/opentrack/plugin-support.hpp @@ -247,3 +247,12 @@ private: return ret; } }; + +template<typename t> +mem<t> make_dylib_instance(mem<dylib> lib) +{ + mem<t> ret; + if (lib != nullptr && lib->Constructor) + ret = mem<t>(reinterpret_cast<t*>(reinterpret_cast<OPENTRACK_CTOR_FUNPTR>(lib->Constructor)())); + return ret; +} diff --git a/opentrack/selected-libraries.cpp b/opentrack/selected-libraries.cpp index 7617ce90..c39ee3f5 100644 --- a/opentrack/selected-libraries.cpp +++ b/opentrack/selected-libraries.cpp @@ -5,22 +5,13 @@ SelectedLibraries::~SelectedLibraries() { } -template<typename t> -static mem<t> make_instance(mem<dylib> lib) -{ - mem<t> ret; - if (lib != nullptr && lib->Constructor) - ret = mem<t>(reinterpret_cast<t*>(reinterpret_cast<OPENTRACK_CTOR_FUNPTR>(lib->Constructor)())); - return ret; -} - SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dylibptr f) : pTracker(nullptr), pFilter(nullptr), pProtocol(nullptr), correct(false) { - pProtocol = make_instance<IProtocol>(p); + pProtocol = make_dylib_instance<IProtocol>(p); if (!pProtocol) { @@ -35,8 +26,8 @@ SelectedLibraries::SelectedLibraries(QFrame* frame, dylibptr t, dylibptr p, dyli return; } - pTracker = make_instance<ITracker>(t); - pFilter = make_instance<IFilter>(f); + pTracker = make_dylib_instance<ITracker>(t); + pFilter = make_dylib_instance<IFilter>(f); if (!pTracker) { |