diff options
author | Jędrzej Nowacki <jedrzej.nowacki@nokia.com> | 2011-11-21 14:08:52 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-11-22 19:05:18 +0100 |
commit | ce4343a52f68ce0759d712c79d3acd37ecd954b1 (patch) | |
tree | d6aeb9946f4aeb9afeaf941b7840e9f7539c0a5f /src/widgets/kernel/qwidgetsvariant.cpp | |
parent | dae1df576f5dd468c5f9d118d9db9ece820de18a (diff) |
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 <ogoffart@woboq.com>
Diffstat (limited to 'src/widgets/kernel/qwidgetsvariant.cpp')
-rw-r--r-- | src/widgets/kernel/qwidgetsvariant.cpp | 80 |
1 files changed, 8 insertions, 72 deletions
diff --git a/src/widgets/kernel/qwidgetsvariant.cpp b/src/widgets/kernel/qwidgetsvariant.cpp index dcffa0e87e..2e945d28e1 100644 --- a/src/widgets/kernel/qwidgetsvariant.cpp +++ b/src/widgets/kernel/qwidgetsvariant.cpp @@ -45,6 +45,7 @@ #include "qsizepolicy.h" #include "private/qvariant_p.h" +#include <private/qmetatype_p.h> QT_BEGIN_NAMESPACE @@ -137,82 +138,17 @@ static const QVariant::Handler widgets_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 *qMetaTypeWidgetsHelper; - - -#ifdef QT_NO_DATASTREAM -# define Q_DECL_METATYPE_HELPER(TYPE) \ - typedef void *(*QCreate##TYPE)(const TYPE *); \ - static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \ - typedef void (*QDelete##TYPE)(TYPE *); \ - static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \ - typedef void *(*QConstruct##TYPE)(void *, const TYPE *); \ - static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \ - typedef void (*QDestruct##TYPE)(TYPE *); \ - static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDestructHelper<TYPE>; -#else -# define Q_DECL_METATYPE_HELPER(TYPE) \ - typedef void *(*QCreate##TYPE)(const TYPE *); \ - static const QCreate##TYPE qCreate##TYPE = qMetaTypeCreateHelper<TYPE>; \ - typedef void (*QDelete##TYPE)(TYPE *); \ - static const QDelete##TYPE qDelete##TYPE = qMetaTypeDeleteHelper<TYPE>; \ - typedef void *(*QConstruct##TYPE)(void *, const TYPE *); \ - static const QConstruct##TYPE qConstruct##TYPE = qMetaTypeConstructHelper<TYPE>; \ - typedef void (*QDestruct##TYPE)(TYPE *); \ - static const QDestruct##TYPE qDestruct##TYPE = qMetaTypeDestructHelper<TYPE>; \ - typedef void (*QSave##TYPE)(QDataStream &, const TYPE *); \ - static const QSave##TYPE qSave##TYPE = qMetaTypeSaveHelper<TYPE>; \ - typedef void (*QLoad##TYPE)(QDataStream &, TYPE *); \ - static const QLoad##TYPE qLoad##TYPE = qMetaTypeLoadHelper<TYPE>; -#endif +extern Q_CORE_EXPORT const QMetaTypeInterface *qMetaTypeWidgetsHelper; -#ifndef QT_NO_ICON -Q_DECL_METATYPE_HELPER(QIcon) -#endif -Q_DECL_METATYPE_HELPER(QSizePolicy) - -#ifdef QT_NO_DATASTREAM -# define Q_IMPL_METATYPE_HELPER(TYPE) \ - { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \ - reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \ - reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \ - reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \ - sizeof(TYPE) \ - } -#else -# define Q_IMPL_METATYPE_HELPER(TYPE) \ - { reinterpret_cast<QMetaType::Creator>(qCreate##TYPE), \ - reinterpret_cast<QMetaType::Deleter>(qDelete##TYPE), \ - reinterpret_cast<QMetaType::SaveOperator>(qSave##TYPE), \ - reinterpret_cast<QMetaType::LoadOperator>(qLoad##TYPE), \ - reinterpret_cast<QMetaType::Constructor>(qConstruct##TYPE), \ - reinterpret_cast<QMetaType::Destructor>(qDestruct##TYPE), \ - sizeof(TYPE) \ - } -#endif +#define QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES(MetaTypeName, MetaTypeId, RealName) \ + QMetaTypeInterface(static_cast<RealName*>(0)), -static const QMetaTypeGuiHelper qVariantWidgetsHelper[] = { -#ifdef QT_NO_ICON - {0, 0, 0, 0}, -#else - Q_IMPL_METATYPE_HELPER(QIcon), -#endif - Q_IMPL_METATYPE_HELPER(QSizePolicy), +static const QMetaTypeInterface qVariantWidgetsHelper[] = { + QT_FOR_EACH_STATIC_WIDGETS_CLASS(QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES) }; +#undef QT_IMPL_METATYPEINTERFACE_WIDGETS_TYPES + extern Q_GUI_EXPORT const QVariant::Handler *qt_widgets_variant_handler; int qRegisterWidgetsVariant() |