From 88e4563455ca183e1b77364b73d5e6173af513d3 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 20 Sep 2016 21:24:40 +0200 Subject: api, compat: backport exports fix --- opentrack/export.hpp | 28 ++++++++++++++++++++++++++++ opentrack/keybinding-worker.hpp | 8 ++------ opentrack/plugin-api.hpp | 8 ++------ opentrack/selected-libraries.hpp | 8 ++------ opentrack/shortcuts.h | 10 +++------- opentrack/win32-joystick.hpp | 24 ++++++++++-------------- opentrack/win32-shortcuts.h | 8 ++------ 7 files changed, 49 insertions(+), 45 deletions(-) create mode 100644 opentrack/export.hpp (limited to 'opentrack') diff --git a/opentrack/export.hpp b/opentrack/export.hpp new file mode 100644 index 000000000..a9f3521ee --- /dev/null +++ b/opentrack/export.hpp @@ -0,0 +1,28 @@ +#pragma once + +#ifdef BUILD_api +# ifdef _WIN32 +# define OPENTRACK_API_LINKAGE __declspec(dllexport) +# else +# define OPENTRACK_API_LINKAGE +# endif + +# ifndef _MSC_VER +# define OPENTRACK_API_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_API_LINKAGE +# else +# define OPENTRACK_API_EXPORT OPENTRACK_API_LINKAGE +# endif + +#else + #ifdef _WIN32 + # define OPENTRACK_API_LINKAGE __declspec(dllimport) + #else + # define OPENTRACK_API_LINKAGE + #endif + + #ifndef _MSC_VER + # define OPENTRACK_API_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_API_LINKAGE + #else + # define OPENTRACK_API_EXPORT OPENTRACK_API_LINKAGE + #endif +#endif diff --git a/opentrack/keybinding-worker.hpp b/opentrack/keybinding-worker.hpp index fa50a9742..cb1b3184f 100644 --- a/opentrack/keybinding-worker.hpp +++ b/opentrack/keybinding-worker.hpp @@ -8,11 +8,7 @@ #pragma once -#ifdef BUILD_api -# include "opentrack-compat/export.hpp" -#else -# include "opentrack-compat/import.hpp" -#endif +#include "export.hpp" #include "opentrack-compat/timer.hpp" #include "opentrack/win32-joystick.hpp" @@ -41,7 +37,7 @@ public: bool should_process(); }; -struct OPENTRACK_EXPORT KeybindingWorker : private QThread +struct OPENTRACK_API_EXPORT KeybindingWorker : private QThread { private: LPDIRECTINPUT8 din; diff --git a/opentrack/plugin-api.hpp b/opentrack/plugin-api.hpp index dba6fc82f..e82f942bf 100644 --- a/opentrack/plugin-api.hpp +++ b/opentrack/plugin-api.hpp @@ -13,11 +13,7 @@ #include #include -#ifdef BUILD_api -# include "opentrack-compat/export.hpp" -#else -# include "opentrack-compat/import.hpp" -#endif +#include "export.hpp" #ifndef OPENTRACK_PLUGIN_EXPORT # ifdef _WIN32 @@ -39,7 +35,7 @@ enum Axis { namespace plugin_api { namespace detail { -class OPENTRACK_EXPORT BaseDialog : public QWidget +class OPENTRACK_API_EXPORT BaseDialog : public QWidget { Q_OBJECT public: diff --git a/opentrack/selected-libraries.hpp b/opentrack/selected-libraries.hpp index 5384f9e22..a2e0ff87d 100644 --- a/opentrack/selected-libraries.hpp +++ b/opentrack/selected-libraries.hpp @@ -12,13 +12,9 @@ #include -#ifdef BUILD_api -# include "opentrack-compat/export.hpp" -#else -# include "opentrack-compat/import.hpp" -#endif +#include "export.hpp" -struct OPENTRACK_EXPORT SelectedLibraries { +struct OPENTRACK_API_EXPORT SelectedLibraries { using dylibptr = mem; mem pTracker; mem pFilter; diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h index 380379234..519489df4 100644 --- a/opentrack/shortcuts.h +++ b/opentrack/shortcuts.h @@ -12,11 +12,7 @@ #include #include -#ifdef BUILD_api -# include "opentrack-compat/export.hpp" -#else -# include "opentrack-compat/import.hpp" -#endif +#include "export.hpp" #include "qxt-mini/QxtGlobalShortcut" #include "opentrack-compat/options.hpp" @@ -28,7 +24,7 @@ using namespace options; -struct OPENTRACK_EXPORT Shortcuts : public QObject { +struct OPENTRACK_API_EXPORT Shortcuts : public QObject { Q_OBJECT public: @@ -39,7 +35,7 @@ public: Key #endif ; - + using fun = std::function; using tt = std::tuple; std::vector keys; diff --git a/opentrack/win32-joystick.hpp b/opentrack/win32-joystick.hpp index 9c888326d..58f119190 100644 --- a/opentrack/win32-joystick.hpp +++ b/opentrack/win32-joystick.hpp @@ -31,18 +31,14 @@ struct hash }; } -#ifdef BUILD_api -# include "opentrack-compat/export.hpp" -#else -# include "opentrack-compat/import.hpp" -#endif +#include "export.hpp" -struct OPENTRACK_EXPORT win32_joy_ctx +struct OPENTRACK_API_EXPORT win32_joy_ctx { using fn = std::function; - + enum { joy_axis_size = 65535 }; - + struct joy_info { QString name, guid; @@ -51,10 +47,10 @@ struct OPENTRACK_EXPORT win32_joy_ctx void poll(fn f); bool poll_axis(const QString& guid, int axes[8]); std::vector get_joy_info(); - + win32_joy_ctx(const win32_joy_ctx&) = delete; win32_joy_ctx& operator=(const win32_joy_ctx&) = delete; - + win32_joy_ctx(); ~win32_joy_ctx(); void refresh(); @@ -62,10 +58,10 @@ private: QMutex mtx; QMainWindow fake_main_window; LPDIRECTINPUT8 di; - + static QString guid_to_string(const GUID guid); void release(); - + struct joy { LPDIRECTINPUTDEVICE8 joy_handle; @@ -80,7 +76,7 @@ private: void release(); bool poll(fn f); }; - + std::unordered_map> joys; class enum_state @@ -88,7 +84,7 @@ private: std::unordered_map> joys; QMainWindow& fake_main_window; LPDIRECTINPUT8 di; - + std::vector all; static BOOL CALLBACK EnumJoysticksCallback(const DIDEVICEINSTANCE* pdidInstance, VOID* pContext); static BOOL CALLBACK EnumObjectsCallback(const DIDEVICEOBJECTINSTANCE* pdidoi, VOID* ctx); diff --git a/opentrack/win32-shortcuts.h b/opentrack/win32-shortcuts.h index 9b2c61215..825dc03b8 100644 --- a/opentrack/win32-shortcuts.h +++ b/opentrack/win32-shortcuts.h @@ -10,13 +10,9 @@ struct win_key; extern QList windows_key_mods; extern QList windows_key_sequences; -#ifdef BUILD_api -# include "opentrack-compat/export.hpp" -#else -# include "opentrack-compat/import.hpp" -#endif +#include "export.hpp" -struct OPENTRACK_EXPORT win_key +struct OPENTRACK_API_EXPORT win_key { win_key(int win, Qt::Key qt) : win(win), qt(qt) {} int win; -- cgit v1.2.3