summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2019-02-28 20:47:03 +0100
committerStanislaw Halik <sthalik@misaki.pl>2019-02-28 20:47:03 +0100
commitbfd866c6df75ad9dd805744c3acd2adf1b6644d8 (patch)
tree4bda1c3b4e904688472a4ce576dcc256fea06090 /options
parentab0512b9088cf4fea0a49229465cb78f14c0c81c (diff)
options/metatype: simplify definition
Diffstat (limited to 'options')
-rw-r--r--options/metatype.cpp17
-rw-r--r--options/metatype.hpp2
2 files changed, 8 insertions, 11 deletions
diff --git a/options/metatype.cpp b/options/metatype.cpp
index 3b8ec690..4db0b3fd 100644
--- a/options/metatype.cpp
+++ b/options/metatype.cpp
@@ -4,25 +4,22 @@
namespace options::detail {
template<typename t>
-int declare_metatype_for_type(const char* str)
+void declare_metatype_for_type(const char* str)
{
qRegisterMetaType<t>(str);
qRegisterMetaTypeStreamOperators<t>();
-
- return -1;
}
} // ns options::detail
-#define OPENTRACK_DEFINE_METATYPE2(t, sym) \
- class sym { /* NOLINT */ \
- static const int dribble; \
- }; /* NOLINT */ \
- static sym sym; \
- const int sym :: dribble = ::options::detail::declare_metatype_for_type<t>(#t);
+#define OPENTRACK_DEFINE_METATYPE2(t, ctr) \
+ namespace { /* NOLINT(cert-dcl59-cpp) */ \
+ static const char ctr = /* NOLINT(misc-definitions-in-headers) */ \
+ (::options::detail::declare_metatype_for_type<t>(#t), 0); \
+ } // anon ns
#define OPENTRACK_DEFINE_METATYPE(t) \
- OPENTRACK_DEFINE_METATYPE2(t, PP_CAT(init, __COUNTER__))
+ OPENTRACK_DEFINE_METATYPE2(t, PP_CAT(kipple_, __COUNTER__))
#define OPENTRACK_METATYPE_(x) OPENTRACK_DEFINE_METATYPE(x)
#include "metatype.hpp"
diff --git a/options/metatype.hpp b/options/metatype.hpp
index bf149200..ca0947fb 100644
--- a/options/metatype.hpp
+++ b/options/metatype.hpp
@@ -10,7 +10,7 @@
#include <QMetaType>
-#if !defined OPENTRACK_METATYPE_ || defined Q_CREATOR_RUN || defined __clang_analyzer__
+#if !defined OPENTRACK_METATYPE_
# define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x)
#else
# define OPENTRACK_METATYPE(x) Q_DECLARE_METATYPE(x) OPENTRACK_METATYPE_(x)