diff options
Diffstat (limited to 'options/metatype.cpp')
-rw-r--r-- | options/metatype.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/options/metatype.cpp b/options/metatype.cpp index 0fa33933..e54970c0 100644 --- a/options/metatype.cpp +++ b/options/metatype.cpp @@ -1,3 +1,31 @@ -#include "defs.hpp" +#include <QMetaType> + +namespace options::detail { + +template<typename t> +int declare_metatype_for_type(const char* str) +{ + qRegisterMetaType<t>(str); + qRegisterMetaTypeStreamOperators<t>(); + + return -1; +} + +} // ns options::detail + +#define OPENTRACK_DEFINE_METATYPE2(t, ctr) \ + OPENTRACK_DEFINE_METATYPE3(t, ctr) + +#define OPENTRACK_DEFINE_METATYPE3(t, ctr) \ + OPENTRACK_DEFINE_METATYPE4(t, init_metatype_ ## ctr) + +#define OPENTRACK_DEFINE_METATYPE4(t, sym) \ + static class sym { \ + static const int dribble; \ + } sym ## _singleton; \ + const int sym :: dribble = ::options::detail::declare_metatype_for_type<t>(#t) + +#define OPENTRACK_DEFINE_METATYPE(t) OPENTRACK_DEFINE_METATYPE2(t, __COUNTER__) + #define OPENTRACK_METATYPE_(x) OPENTRACK_DEFINE_METATYPE(x) #include "metatype.hpp" |