From ce4343a52f68ce0759d712c79d3acd37ecd954b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Mon, 21 Nov 2011 14:08:52 +0100 Subject: Code cleanup in QVariant and QMetaType. QMetaTypeGuiHelper was generalized and renamed to QMetaTypeInterface. From now all types will have common interface which can be used for basic operations. Change-Id: I50d67f4a8081fa0f75c9d530a8211593ec37bc55 Reviewed-by: Olivier Goffart --- src/gui/kernel/qguivariant.cpp | 155 ++--------------------------------------- 1 file changed, 7 insertions(+), 148 deletions(-) (limited to 'src/gui/kernel/qguivariant.cpp') diff --git a/src/gui/kernel/qguivariant.cpp b/src/gui/kernel/qguivariant.cpp index f0baf7064c..9198e7f119 100644 --- a/src/gui/kernel/qguivariant.cpp +++ b/src/gui/kernel/qguivariant.cpp @@ -474,158 +474,17 @@ const QVariant::Handler qt_gui_variant_handler = { #endif }; -struct QMetaTypeGuiHelper -{ - QMetaType::Creator creator; - QMetaType::Deleter deleter; -#ifndef QT_NO_DATASTREAM - QMetaType::SaveOperator saveOp; - QMetaType::LoadOperator loadOp; -#endif - QMetaType::Constructor constructor; - QMetaType::Destructor destructor; - int size; -}; - -extern Q_CORE_EXPORT const QMetaTypeGuiHelper *qMetaTypeGuiHelper; - - -#ifdef QT_NO_DATASTREAM -# define Q_DECL_METATYPE_HELPER(TYPE) \ - typedef void *(*QCreate##TYPE)(const TYPE *); \ - static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper; \ - typedef void (*QDelete##TYPE)(TYPE *); \ - static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper; \ - typedef void *(*QConstruct##TYPE)(void *, const TYPE *); \ - static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper; \ - typedef void (*QDestruct##TYPE)(TYPE *); \ - static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDestructHelper; -#else -# define Q_DECL_METATYPE_HELPER(TYPE) \ - typedef void *(*QCreate##TYPE)(const TYPE *); \ - static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper; \ - typedef void (*QDelete##TYPE)(TYPE *); \ - static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper; \ - typedef void *(*QConstruct##TYPE)(void *, const TYPE *); \ - static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper; \ - typedef void (*QDestruct##TYPE)(TYPE *); \ - static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDestructHelper; \ - typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \ - static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper; \ - typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \ - static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper; -#endif - -Q_DECL_METATYPE_HELPER(QFont) -Q_DECL_METATYPE_HELPER(QPixmap) -Q_DECL_METATYPE_HELPER(QBrush) -Q_DECL_METATYPE_HELPER(QColor) -Q_DECL_METATYPE_HELPER(QPalette) -Q_DECL_METATYPE_HELPER(QImage) -Q_DECL_METATYPE_HELPER(QPolygon) -Q_DECL_METATYPE_HELPER(QRegion) -Q_DECL_METATYPE_HELPER(QBitmap) -#ifndef QT_NO_CURSOR -Q_DECL_METATYPE_HELPER(QCursor) -#endif -#ifndef QT_NO_SHORTCUT -Q_DECL_METATYPE_HELPER(QKeySequence) -#endif -Q_DECL_METATYPE_HELPER(QPen) -Q_DECL_METATYPE_HELPER(QTextLength) -Q_DECL_METATYPE_HELPER(QTextFormat) -Q_DECL_METATYPE_HELPER(QMatrix) -Q_DECL_METATYPE_HELPER(QTransform) -#ifndef QT_NO_MATRIX4X4 -Q_DECL_METATYPE_HELPER(QMatrix4x4) -#endif -#ifndef QT_NO_VECTOR2D -Q_DECL_METATYPE_HELPER(QVector2D) -#endif -#ifndef QT_NO_VECTOR3D -Q_DECL_METATYPE_HELPER(QVector3D) -#endif -#ifndef QT_NO_VECTOR4D -Q_DECL_METATYPE_HELPER(QVector4D) -#endif -#ifndef QT_NO_QUATERNION -Q_DECL_METATYPE_HELPER(QQuaternion) -#endif -Q_DECL_METATYPE_HELPER(QPolygonF) +extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeGuiHelper; -#ifdef QT_NO_DATASTREAM -# define Q_IMPL_METATYPE_HELPER(TYPE) \ - { reinterpret_cast(qCreate##TYPE), \ - reinterpret_cast(qDelete##TYPE), \ - reinterpret_cast(qConstruct##TYPE), \ - reinterpret_cast(qDestruct##TYPE), \ - sizeof(TYPE) \ - } -#else -# define Q_IMPL_METATYPE_HELPER(TYPE) \ - { reinterpret_cast(qCreate##TYPE), \ - reinterpret_cast(qDelete##TYPE), \ - reinterpret_cast(qSave##TYPE), \ - reinterpret_cast(qLoad##TYPE), \ - reinterpret_cast(qConstruct##TYPE), \ - reinterpret_cast(qDestruct##TYPE), \ - sizeof(TYPE) \ - } -#endif +#define QT_IMPL_METATYPEINTERFACE_GUI_TYPES(MetaTypeName, MetaTypeId, RealName) \ + QMetaTypeInterface(static_cast(0)), -static const QMetaTypeGuiHelper qVariantGuiHelper[] = { - Q_IMPL_METATYPE_HELPER(QFont), - Q_IMPL_METATYPE_HELPER(QPixmap), - Q_IMPL_METATYPE_HELPER(QBrush), - Q_IMPL_METATYPE_HELPER(QColor), - Q_IMPL_METATYPE_HELPER(QPalette), - Q_IMPL_METATYPE_HELPER(QImage), - Q_IMPL_METATYPE_HELPER(QPolygon), - Q_IMPL_METATYPE_HELPER(QRegion), - Q_IMPL_METATYPE_HELPER(QBitmap), -#ifdef QT_NO_CURSOR - {0, 0, 0, 0, 0, 0, 0}, -#else - Q_IMPL_METATYPE_HELPER(QCursor), -#endif -#ifdef QT_NO_SHORTCUT - {0, 0, 0, 0, 0, 0, 0}, -#else - Q_IMPL_METATYPE_HELPER(QKeySequence), -#endif - Q_IMPL_METATYPE_HELPER(QPen), - Q_IMPL_METATYPE_HELPER(QTextLength), - Q_IMPL_METATYPE_HELPER(QTextFormat), - Q_IMPL_METATYPE_HELPER(QMatrix), - Q_IMPL_METATYPE_HELPER(QTransform), -#ifndef QT_NO_MATRIX4X4 - Q_IMPL_METATYPE_HELPER(QMatrix4x4), -#else - {0, 0, 0, 0, 0, 0, 0}, -#endif -#ifndef QT_NO_VECTOR2D - Q_IMPL_METATYPE_HELPER(QVector2D), -#else - {0, 0, 0, 0, 0, 0, 0}, -#endif -#ifndef QT_NO_VECTOR3D - Q_IMPL_METATYPE_HELPER(QVector3D), -#else - {0, 0, 0, 0, 0, 0, 0}, -#endif -#ifndef QT_NO_VECTOR4D - Q_IMPL_METATYPE_HELPER(QVector4D), -#else - {0, 0, 0, 0, 0, 0, 0}, -#endif -#ifndef QT_NO_QUATERNION - Q_IMPL_METATYPE_HELPER(QQuaternion), -#else - {0, 0, 0, 0, 0, 0, 0}, -#endif - Q_IMPL_METATYPE_HELPER(QPolygonF) +static const QMetaTypeInterface qVariantGuiHelper[] = { + QT_FOR_EACH_STATIC_GUI_CLASS(QT_IMPL_METATYPEINTERFACE_GUI_TYPES) }; +#undef QT_IMPL_METATYPEINTERFACE_GUI_TYPES + static const QVariant::Handler *qt_guivariant_last_handler = 0; int qRegisterGuiVariant() { -- cgit v1.2.3