Remove duplicated template code.
authorJędrzej Nowacki <jedrzej.nowacki@nokia.com>
Fri, 23 Mar 2012 16:14:52 +0000 (17:14 +0100)
committerQt by Nokia <qt-info@nokia.com>
Tue, 3 Apr 2012 01:29:55 +0000 (03:29 +0200)
Unify TypeDefinitions specializations. I'm not aware of any reason why
QVariant should have a separate set of supported types during
bootstrapping phase. It would cause only crashes.

As a side effect the patch reduces size of core and gui libraries.

Change-Id: I5140d9d3daee39a0171bc718bf46dab6b28085ec
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
src/corelib/kernel/qmetatype.cpp
src/corelib/kernel/qmetatype_p.h
src/corelib/kernel/qvariant.cpp
src/gui/kernel/qguivariant.cpp

index 7ddf187..fba1aaf 100644 (file)
 #include "qvariant.h"
 #include "qmetatypeswitcher_p.h"
 
-#ifdef QT_BOOTSTRAPPED
-# ifndef QT_NO_GEOM_VARIANT
-#  define QT_NO_GEOM_VARIANT
-# endif
-#else
+#ifndef QT_BOOTSTRAPPED
 #  include "qbitarray.h"
 #  include "qurl.h"
 #  include "qvariant.h"
@@ -83,49 +79,12 @@ QT_BEGIN_NAMESPACE
 
 
 namespace {
-template<typename T>
-struct TypeDefinition {
-    static const bool IsAvailable = true;
-};
-
 struct DefinedTypesFilter {
     template<typename T>
     struct Acceptor {
-        static const bool IsAccepted = TypeDefinition<T>::IsAvailable && QTypeModuleInfo<T>::IsCore;
+        static const bool IsAccepted = QtMetaTypePrivate::TypeDefinition<T>::IsAvailable && QTypeModuleInfo<T>::IsCore;
     };
 };
-
-// Ignore these types, as incomplete
-#ifdef QT_NO_GEOM_VARIANT
-template<> struct TypeDefinition<QRect> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QRectF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QSize> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QSizeF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QLine> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QLineF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QPoint> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QPointF> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_BOOTSTRAPPED
-template<> struct TypeDefinition<QVariantMap> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QVariantHash> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QVariantList> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QVariant> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QBitArray> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QUrl> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QEasingCurve> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonValue> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonObject> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonArray> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonDocument> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_REGEXP
-template<> struct TypeDefinition<QRegExp> { static const bool IsAvailable = false; };
-#endif
-#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGEXP)
-template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; };
-#endif
 } // namespace
 
 /*!
index c73f8d0..2ab4a38 100644 (file)
@@ -182,6 +182,62 @@ public:
     /*flags*/ 0 \
 }
 
+namespace QtMetaTypePrivate {
+template<typename T>
+struct TypeDefinition {
+    static const bool IsAvailable = true;
+};
+
+// Ignore these types, as incomplete
+#ifdef QT_BOOTSTRAPPED
+template<> struct TypeDefinition<QBitArray> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QEasingCurve> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QJsonArray> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QJsonDocument> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QJsonObject> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QJsonValue> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QUrl> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_GEOM_VARIANT
+template<> struct TypeDefinition<QRect> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QRectF> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QSize> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QSizeF> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QLine> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QLineF> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QPoint> { static const bool IsAvailable = false; };
+template<> struct TypeDefinition<QPointF> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_REGEXP
+template<> struct TypeDefinition<QRegExp> { static const bool IsAvailable = false; };
+#endif
+#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGEXP)
+template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_SHORTCUT
+template<> struct TypeDefinition<QKeySequence> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_CURSOR
+template<> struct TypeDefinition<QCursor> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_MATRIX4X4
+template<> struct TypeDefinition<QMatrix4x4> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_VECTOR2D
+template<> struct TypeDefinition<QVector2D> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_VECTOR3D
+template<> struct TypeDefinition<QVector3D> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_VECTOR4D
+template<> struct TypeDefinition<QVector4D> { static const bool IsAvailable = false; };
+#endif
+#ifdef QT_NO_QUATERNION
+template<> struct TypeDefinition<QQuaternion> { static const bool IsAvailable = false; };
+#endif
+} //namespace QtMetaTypePrivate
+
 QT_END_NAMESPACE
 
 #endif // QMETATYPE_P_H
index b687c01..da60171 100644 (file)
@@ -100,40 +100,13 @@ public:
 }  // namespace
 
 namespace {
-template<typename T>
-struct TypeDefinition {
-    static const bool IsAvailable = true;
-};
-
-// Ignore these types, as incomplete
-#ifdef QT_BOOTSTRAPPED
-template<> struct TypeDefinition<QEasingCurve> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QModelIndex> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QUrl> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QRegularExpression> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonValue> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonObject> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonArray> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QJsonDocument> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_GEOM_VARIANT
-template<> struct TypeDefinition<QRect> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QRectF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QSize> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QSizeF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QLine> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QLineF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QPoint> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QPointF> { static const bool IsAvailable = false; };
-#endif
-
 struct CoreTypesFilter {
     template<typename T>
     struct Acceptor {
-        static const bool IsAccepted = QTypeModuleInfo<T>::IsCore && TypeDefinition<T>::IsAvailable;
+        static const bool IsAccepted = QTypeModuleInfo<T>::IsCore && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable;
     };
 };
-} // annonymous used to hide TypeDefinition
+} // annonymous
 
 namespace { // annonymous used to hide QVariant handlers
 
index 531afee..436688a 100644 (file)
@@ -98,52 +98,13 @@ QT_BEGIN_NAMESPACE
 Q_CORE_EXPORT const QVariant::Handler *qcoreVariantHandler();
 
 namespace {
-template<typename T>
-struct TypeDefinition {
-    static const bool IsAvailable = true;
-};
-// Ignore these types, as incomplete
-#ifdef QT_NO_GEOM_VARIANT
-template<> struct TypeDefinition<QRect> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QRectF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QSize> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QSizeF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QLine> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QLineF> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QPoint> { static const bool IsAvailable = false; };
-template<> struct TypeDefinition<QPointF> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_SHORTCUT
-template<> struct TypeDefinition<QKeySequence> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_CURSOR
-template<> struct TypeDefinition<QCursor> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_MATRIX4X4
-template<> struct TypeDefinition<QMatrix4x4> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_VECTOR2D
-template<> struct TypeDefinition<QVector2D> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_VECTOR3D
-template<> struct TypeDefinition<QVector3D> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_VECTOR4D
-template<> struct TypeDefinition<QVector4D> { static const bool IsAvailable = false; };
-#endif
-#ifdef QT_NO_QUATERNION
-template<> struct TypeDefinition<QQuaternion> { static const bool IsAvailable = false; };
-#endif
-
 struct GuiTypesFilter {
     template<typename T>
     struct Acceptor {
-        static const bool IsAccepted = QTypeModuleInfo<T>::IsGui && TypeDefinition<T>::IsAvailable;
+        static const bool IsAccepted = QTypeModuleInfo<T>::IsGui && QtMetaTypePrivate::TypeDefinition<T>::IsAvailable;
     };
 };
-} // namespace used to hide TypeDefinition
 
-namespace {
 static void construct(QVariant::Private *x, const void *copy)
 {
     const int type = x->type;