diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-06-22 16:53:28 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-06-26 23:01:53 +0200 |
commit | ceee2f51c7c97bd8e6c2702b7b1fe811ef912711 (patch) | |
tree | adba786722c5c484b8ca01ee8d2f141c9cee7b8d /options | |
parent | 5e67fb0e8a94f9180cb304023242ac54e0def45b (diff) |
options/metatype: simplify
Diffstat (limited to 'options')
-rw-r--r-- | options/defs.hpp | 22 | ||||
-rw-r--r-- | options/metatype.cpp | 11 | ||||
-rw-r--r-- | options/metatype.hpp | 21 |
3 files changed, 26 insertions, 28 deletions
diff --git a/options/defs.hpp b/options/defs.hpp index f14a1cbe..58846cc3 100644 --- a/options/defs.hpp +++ b/options/defs.hpp @@ -1,5 +1,7 @@ #pragma once +#include "compat/macros.hpp" + #include <QString> #include <QMetaType> @@ -8,23 +10,19 @@ #define OTR_OPTIONS_EXPAND2(x) x #define OTR_OPTIONS_EXPAND1(x) OTR_OPTIONS_EXPAND2(x) -#define OPENTRACK_REGISTER_METATYPE2(t, ctr) \ - OPENTRACK_REGISTER_METATYPE3(t, ctr) +#define OPENTRACK_DEFINE_METATYPE2(t, ctr) \ + OPENTRACK_DEFINE_METATYPE3(t, ctr) -#define OPENTRACK_REGISTER_METATYPE3(t, sym) \ - OPENTRACK_REGISTER_METATYPE4(t, init_metatype_ ## sym) +#define OPENTRACK_DEFINE_METATYPE3(t, ctr) \ + OPENTRACK_DEFINE_METATYPE4(t, init_metatype_ ## ctr) -#define OPENTRACK_REGISTER_METATYPE4(t, sym) \ - class sym { \ +#define OPENTRACK_DEFINE_METATYPE4(t, sym) \ + static class sym { \ static const int dribble; \ } sym ## _singleton; \ - const int sym :: dribble = ::options::detail::custom_type_initializer::declare_for_type<t>(#t) + const int sym :: dribble = ::options::detail::custom_type_initializer::declare_for_type<t>(#t); -#if defined Q_CREATOR_RUN -# define OPENTRACK_DEFINE_METATYPE(t) -#else -# define OPENTRACK_DEFINE_METATYPE(t) OPENTRACK_REGISTER_METATYPE2(t, OTR_OPTIONS_EXPAND1(__COUNTER__)) -#endif +#define OPENTRACK_DEFINE_METATYPE(t) OPENTRACK_DEFINE_METATYPE2(t, __COUNTER__) namespace options { namespace detail { diff --git a/options/metatype.cpp b/options/metatype.cpp index ddfdcef9..0fa33933 100644 --- a/options/metatype.cpp +++ b/options/metatype.cpp @@ -1,10 +1,3 @@ -#include "metatype.hpp" #include "defs.hpp" - -OPENTRACK_DEFINE_METATYPE(::options::slider_value); -OPENTRACK_DEFINE_METATYPE(QList<double>); -OPENTRACK_DEFINE_METATYPE(QList<float>); -OPENTRACK_DEFINE_METATYPE(QList<int>); -OPENTRACK_DEFINE_METATYPE(QList<bool>); -OPENTRACK_DEFINE_METATYPE(QList<QString>); -OPENTRACK_DEFINE_METATYPE(QList<QPointF>); +#define OPENTRACK_METATYPE_(x) OPENTRACK_DEFINE_METATYPE(x) +#include "metatype.hpp" diff --git a/options/metatype.hpp b/options/metatype.hpp index 0c78f556..023c1a36 100644 --- a/options/metatype.hpp +++ b/options/metatype.hpp @@ -6,13 +6,20 @@ #include <QDebug> #include "slider.hpp" +#include "defs.hpp" -Q_DECLARE_METATYPE(QList<double>) -Q_DECLARE_METATYPE(QList<float>) -Q_DECLARE_METATYPE(QList<int>) -Q_DECLARE_METATYPE(QList<bool>) -Q_DECLARE_METATYPE(QList<QString>) -Q_DECLARE_METATYPE(QList<QPointF>) -Q_DECLARE_METATYPE(::options::slider_value) +#ifndef OPENTRACK_METATYPE_ +# define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x) +#else +# define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x) OPENTRACK_METATYPE_(x) +#endif + +OPENTRACK_METATYPE(QList<double>) +OPENTRACK_METATYPE(QList<float>) +OPENTRACK_METATYPE(QList<int>) +OPENTRACK_METATYPE(QList<bool>) +OPENTRACK_METATYPE(QList<QString>) +OPENTRACK_METATYPE(QList<QPointF>) +OPENTRACK_METATYPE(::options::slider_value) |