summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-09-20 21:24:40 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-09-20 23:24:17 +0200
commit88e4563455ca183e1b77364b73d5e6173af513d3 (patch)
treeb63fcee5e953c876886cf6c2bdeaf2738ee0c795
parent06b68ac493f06723d123db5fa23b8c0a86ca7f66 (diff)
api, compat: backport exports fix
-rw-r--r--cmake/opentrack-version.cmake3
-rw-r--r--opentrack-compat/camera-names.hpp6
-rw-r--r--opentrack-compat/compat-export.hpp15
-rw-r--r--opentrack-compat/compat-import.hpp15
-rw-r--r--opentrack-compat/export.hpp22
-rw-r--r--opentrack-compat/options.hpp18
-rw-r--r--opentrack-compat/shm.h7
-rw-r--r--opentrack-compat/sleep.hpp6
-rw-r--r--opentrack/export.hpp28
-rw-r--r--opentrack/keybinding-worker.hpp8
-rw-r--r--opentrack/plugin-api.hpp8
-rw-r--r--opentrack/selected-libraries.hpp8
-rw-r--r--opentrack/shortcuts.h10
-rw-r--r--opentrack/win32-joystick.hpp24
-rw-r--r--opentrack/win32-shortcuts.h8
15 files changed, 80 insertions, 106 deletions
diff --git a/cmake/opentrack-version.cmake b/cmake/opentrack-version.cmake
index 64072e1c..9a496ebe 100644
--- a/cmake/opentrack-version.cmake
+++ b/cmake/opentrack-version.cmake
@@ -12,12 +12,13 @@ add_library(opentrack-version STATIC ${CMAKE_BINARY_DIR}/version.cc)
opentrack_compat(opentrack-version)
set(version-string "
+#define BUILD_compat
#include \"opentrack-compat/export.hpp\"
#ifdef __cplusplus
extern \"C\"
#endif
-OPENTRACK_EXPORT
+OPENTRACK_COMPAT_EXPORT
const char* opentrack_version;
const char* opentrack_version = \"${OPENTRACK_COMMIT}\";
diff --git a/opentrack-compat/camera-names.hpp b/opentrack-compat/camera-names.hpp
index c2879000..ae0c6b25 100644
--- a/opentrack-compat/camera-names.hpp
+++ b/opentrack-compat/camera-names.hpp
@@ -11,11 +11,7 @@
#include <QList>
#include <QString>
-#ifdef BUILD_compat
-# include "compat-export.hpp"
-#else
-# include "compat-import.hpp"
-#endif
+#include "export.hpp"
OPENTRACK_COMPAT_EXPORT QList<QString> get_camera_names();
OPENTRACK_COMPAT_EXPORT int camera_name_to_index(const QString &name);
diff --git a/opentrack-compat/compat-export.hpp b/opentrack-compat/compat-export.hpp
deleted file mode 100644
index 2d6f1d3d..00000000
--- a/opentrack-compat/compat-export.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#ifndef OPENTRACK_COMPAT_EXPORT
-# ifdef _WIN32
-# define OPENTRACK_COMPAT_LINKAGE __declspec(dllexport)
-# else
-# define OPENTRACK_COMPAT_LINKAGE
-# endif
-
-# ifndef _MSC_VER
-# define OPENTRACK_COMPAT_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_COMPAT_LINKAGE
-# else
-# define OPENTRACK_COMPAT_EXPORT OPENTRACK_COMPAT_LINKAGE
-# endif
-#endif
diff --git a/opentrack-compat/compat-import.hpp b/opentrack-compat/compat-import.hpp
deleted file mode 100644
index 161ccc5d..00000000
--- a/opentrack-compat/compat-import.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#pragma once
-
-#ifndef OPENTRACK_COMPAT_EXPORT
-# ifdef _WIN32
-# define OPENTRACK_COMPAT_LINKAGE __declspec(dllimport)
-# else
-# define OPENTRACK_COMPAT_LINKAGE
-# endif
-
-# ifndef _MSC_VER
-# define OPENTRACK_COMPAT_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_COMPAT_LINKAGE
-# else
-# define OPENTRACK_COMPAT_EXPORT OPENTRACK_COMPAT_LINKAGE
-# endif
-#endif
diff --git a/opentrack-compat/export.hpp b/opentrack-compat/export.hpp
index 100950a0..ba10f131 100644
--- a/opentrack-compat/export.hpp
+++ b/opentrack-compat/export.hpp
@@ -1,15 +1,27 @@
#pragma once
-#ifndef OPENTRACK_EXPORT
+#ifdef BUILD_compat
# ifdef _WIN32
-# define OPENTRACK_LINKAGE __declspec(dllexport)
+# define OPENTRACK_COMPAT_LINKAGE __declspec(dllexport)
# else
-# define OPENTRACK_LINKAGE
+# define OPENTRACK_COMPAT_LINKAGE
# endif
# ifndef _MSC_VER
-# define OPENTRACK_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_LINKAGE
+# define OPENTRACK_COMPAT_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_COMPAT_LINKAGE
# else
-# define OPENTRACK_EXPORT OPENTRACK_LINKAGE
+# define OPENTRACK_COMPAT_EXPORT OPENTRACK_COMPAT_LINKAGE
# endif
+#else
+ #ifdef _WIN32
+ # define OPENTRACK_COMPAT_LINKAGE __declspec(dllimport)
+ #else
+ # define OPENTRACK_COMPAT_LINKAGE
+ #endif
+
+ #ifndef _MSC_VER
+ # define OPENTRACK_COMPAT_EXPORT __attribute__ ((visibility ("default"))) OPENTRACK_COMPAT_LINKAGE
+ #else
+ # define OPENTRACK_COMPAT_EXPORT OPENTRACK_COMPAT_LINKAGE
+ #endif
#endif
diff --git a/opentrack-compat/options.hpp b/opentrack-compat/options.hpp
index a317a1f7..8485c167 100644
--- a/opentrack-compat/options.hpp
+++ b/opentrack-compat/options.hpp
@@ -37,11 +37,7 @@
#include <memory>
-#ifdef BUILD_compat
-# include "compat-export.hpp"
-#else
-# include "compat-import.hpp"
-#endif
+#include "export.hpp"
template<typename t> using mem = std::shared_ptr<t>;
@@ -131,7 +127,7 @@ namespace options {
bool contains(const QString& name);
void save();
bool modifiedp();
-
+
template<typename t>
t get(const QString& name)
{
@@ -160,12 +156,12 @@ namespace options {
pbundle bundle(const k& key);
void bundle_decf(const k& key);
};
-
+
OPENTRACK_COMPAT_EXPORT opt_singleton& singleton();
}
-
+
using pbundle = std::shared_ptr<opt_bundle>;
-
+
static inline pbundle bundle(const QString name) { return detail::singleton().bundle(name); }
class OPENTRACK_COMPAT_EXPORT opt_bundle : public impl_bundle
@@ -238,7 +234,7 @@ namespace options {
private:
t def;
};
-
+
struct OPENTRACK_COMPAT_EXPORT opts
{
pbundle b;
@@ -314,7 +310,7 @@ namespace options {
lb->setText(v);
base_value::connect(&v, SIGNAL(valueChanged(QString)), lb, SLOT(setText(QString)), v.SAFE_CONNTYPE);
}
-
+
template<>
inline void tie_setting(value<int>& v, QTabWidget* t)
{
diff --git a/opentrack-compat/shm.h b/opentrack-compat/shm.h
index 3edb0080..e41daaef 100644
--- a/opentrack-compat/shm.h
+++ b/opentrack-compat/shm.h
@@ -24,11 +24,8 @@
# pragma GCC diagnostic ignored "-Wattributes"
#endif
-#ifdef BUILD_compat
-# include "compat-export.hpp"
-#else
-# include "compat-import.hpp"
-#endif
+#include "export.hpp"
+
class OPENTRACK_COMPAT_EXPORT PortableLockedShm {
public:
diff --git a/opentrack-compat/sleep.hpp b/opentrack-compat/sleep.hpp
index e7c70285..0a551dcc 100644
--- a/opentrack-compat/sleep.hpp
+++ b/opentrack-compat/sleep.hpp
@@ -5,16 +5,14 @@ namespace portable
#ifdef _WIN32
# include <windows.h>
- template<typename = void>
- void sleep(unsigned milliseconds)
+ inline void sleep(unsigned milliseconds)
{
Sleep(milliseconds);
}
#else
#include <unistd.h>
- template<typename = void>
- void sleep(unsigned milliseconds)
+ inline void sleep(unsigned milliseconds)
{
usleep(milliseconds * 1000U); // takes microseconds
}
diff --git a/opentrack/export.hpp b/opentrack/export.hpp
new file mode 100644
index 00000000..a9f3521e
--- /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 fa50a974..cb1b3184 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 dba6fc82..e82f942b 100644
--- a/opentrack/plugin-api.hpp
+++ b/opentrack/plugin-api.hpp
@@ -13,11 +13,7 @@
#include <QFrame>
#include <QIcon>
-#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 5384f9e2..a2e0ff87 100644
--- a/opentrack/selected-libraries.hpp
+++ b/opentrack/selected-libraries.hpp
@@ -12,13 +12,9 @@
#include <QFrame>
-#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<dylib>;
mem<ITracker> pTracker;
mem<IFilter> pFilter;
diff --git a/opentrack/shortcuts.h b/opentrack/shortcuts.h
index 38037923..519489df 100644
--- a/opentrack/shortcuts.h
+++ b/opentrack/shortcuts.h
@@ -12,11 +12,7 @@
#include <vector>
#include <functional>
-#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<void(void)>;
using tt = std::tuple<K, fun>;
std::vector<tt> keys;
diff --git a/opentrack/win32-joystick.hpp b/opentrack/win32-joystick.hpp
index 9c888326..58f11919 100644
--- a/opentrack/win32-joystick.hpp
+++ b/opentrack/win32-joystick.hpp
@@ -31,18 +31,14 @@ struct hash<QString>
};
}
-#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<void(const QString& guid, int btn, bool held)>;
-
+
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<joy_info> 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<QString, std::shared_ptr<joy>> joys;
class enum_state
@@ -88,7 +84,7 @@ private:
std::unordered_map<QString, std::shared_ptr<joy>> joys;
QMainWindow& fake_main_window;
LPDIRECTINPUT8 di;
-
+
std::vector<QString> 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 9b2c6121..825dc03b 100644
--- a/opentrack/win32-shortcuts.h
+++ b/opentrack/win32-shortcuts.h
@@ -10,13 +10,9 @@ struct win_key;
extern QList<win_key> windows_key_mods;
extern QList<win_key> 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;