diff options
Diffstat (limited to 'opentrack')
-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) { |