summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qmetatype.cpp
diff options
context:
space:
mode:
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>2011-10-14 09:22:46 +0200
committerQt by Nokia <qt-info@nokia.com>2011-11-09 10:11:02 +0100
commit7f35d5849e7233efac16c12271c58a049923b1c0 (patch)
tree359c3dbef0395a6643c8cb346796e9c6fea31d3f /src/corelib/kernel/qmetatype.cpp
parent7ae1e3945507bcaab5bd4ed7a3911fcfa889327a (diff)
Refactor QMetaType types.
QMetaType::Type enum is the main source of type ids. Currently there are many tasks that can be replaced by a smart macro that can iterate over all types. The patch introduces series of FOR_EACH_ macros that may be used for code generation. As the first step the macro was used for Q_DECLARE_BUILTIN_METATYPE to make sure that no type was forgotten. Second step was to use created macros in autotest to improve tests coverage. Change-Id: I34e9ad7bacf02b44b028bc1aad20b1241aacebd3 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib/kernel/qmetatype.cpp')
-rw-r--r--src/corelib/kernel/qmetatype.cpp30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index b95b71d5e2..e462be5e31 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -231,9 +231,14 @@ QT_BEGIN_NAMESPACE
#define QT_ADD_STATIC_METATYPE(STR, TP) \
{ STR, sizeof(STR) - 1, TP }
+#define QT_ADD_STATIC_METATYPE_ALIASES_ITER(MetaTypeName, TypeId, AliasingName, RealNameStr) \
+ QT_ADD_STATIC_METATYPE(RealNameStr, QMetaType::MetaTypeName),
+
+#define QT_ADD_STATIC_METATYPE_HACKS_ITER(MetaTypeName, TypeId, Name) \
+ QT_ADD_STATIC_METATYPE(#Name, MetaTypeName),
+
/* Note: these MUST be in the order of the enums */
static const struct { const char * typeName; int typeNameLength; int type; } types[] = {
-
/* All Core types */
QT_ADD_STATIC_METATYPE("void", QMetaType::Void),
QT_ADD_STATIC_METATYPE("bool", QMetaType::Bool),
@@ -307,27 +312,8 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
QT_ADD_STATIC_METATYPE("QVariant", QMetaType::QVariant),
/* Type aliases - order doesn't matter */
- QT_ADD_STATIC_METATYPE("unsigned long", QMetaType::ULong),
- QT_ADD_STATIC_METATYPE("unsigned int", QMetaType::UInt),
- QT_ADD_STATIC_METATYPE("unsigned short", QMetaType::UShort),
- QT_ADD_STATIC_METATYPE("unsigned char", QMetaType::UChar),
- QT_ADD_STATIC_METATYPE("long long", QMetaType::LongLong),
- QT_ADD_STATIC_METATYPE("unsigned long long", QMetaType::ULongLong),
- QT_ADD_STATIC_METATYPE("qint8", QMetaType::Char),
- QT_ADD_STATIC_METATYPE("signed char", QMetaType::Char),
- QT_ADD_STATIC_METATYPE("quint8", QMetaType::UChar),
- QT_ADD_STATIC_METATYPE("qint16", QMetaType::Short),
- QT_ADD_STATIC_METATYPE("quint16", QMetaType::UShort),
- QT_ADD_STATIC_METATYPE("qint32", QMetaType::Int),
- QT_ADD_STATIC_METATYPE("quint32", QMetaType::UInt),
- QT_ADD_STATIC_METATYPE("qint64", QMetaType::LongLong),
- QT_ADD_STATIC_METATYPE("quint64", QMetaType::ULongLong),
- QT_ADD_STATIC_METATYPE("QList<QVariant>", QMetaType::QVariantList),
- QT_ADD_STATIC_METATYPE("QMap<QString,QVariant>", QMetaType::QVariantMap),
- QT_ADD_STATIC_METATYPE("QHash<QString,QVariant>", QMetaType::QVariantHash),
- // let QMetaTypeId2 figure out the type at compile time
- QT_ADD_STATIC_METATYPE("qreal", QMetaTypeId2<qreal>::MetaType),
-
+ QT_FOR_EACH_STATIC_ALIAS_TYPE(QT_ADD_STATIC_METATYPE_ALIASES_ITER)
+ QT_FOR_EACH_STATIC_HACKS_TYPE(QT_ADD_STATIC_METATYPE_HACKS_ITER)
{0, 0, QMetaType::Void}
};