From 4b023e248747a589f2402b03f1967b999e3bb3b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Fri, 23 Mar 2012 17:14:52 +0100 Subject: Remove duplicated template code. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-by: João Abecasis --- src/corelib/kernel/qmetatype.cpp | 45 ++------------------------------ src/corelib/kernel/qmetatype_p.h | 56 ++++++++++++++++++++++++++++++++++++++++ src/corelib/kernel/qvariant.cpp | 31 ++-------------------- 3 files changed, 60 insertions(+), 72 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 7ddf187b88..fba1aaf9b6 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -54,11 +54,7 @@ #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 -struct TypeDefinition { - static const bool IsAvailable = true; -}; - struct DefinedTypesFilter { template struct Acceptor { - static const bool IsAccepted = TypeDefinition::IsAvailable && QTypeModuleInfo::IsCore; + static const bool IsAccepted = QtMetaTypePrivate::TypeDefinition::IsAvailable && QTypeModuleInfo::IsCore; }; }; - -// Ignore these types, as incomplete -#ifdef QT_NO_GEOM_VARIANT -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -#endif -#ifdef QT_BOOTSTRAPPED -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -#endif -#ifdef QT_NO_REGEXP -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -#endif -#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGEXP) -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -#endif } // namespace /*! diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index c73f8d0a20..2ab4a3896f 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -182,6 +182,62 @@ public: /*flags*/ 0 \ } +namespace QtMetaTypePrivate { +template +struct TypeDefinition { + static const bool IsAvailable = true; +}; + +// Ignore these types, as incomplete +#ifdef QT_BOOTSTRAPPED +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_GEOM_VARIANT +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_REGEXP +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGEXP) +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_SHORTCUT +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_CURSOR +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_MATRIX4X4 +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_VECTOR2D +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_VECTOR3D +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_VECTOR4D +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +#ifdef QT_NO_QUATERNION +template<> struct TypeDefinition { static const bool IsAvailable = false; }; +#endif +} //namespace QtMetaTypePrivate + QT_END_NAMESPACE #endif // QMETATYPE_P_H diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index b687c01238..da6017127f 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -100,40 +100,13 @@ public: } // namespace namespace { -template -struct TypeDefinition { - static const bool IsAvailable = true; -}; - -// Ignore these types, as incomplete -#ifdef QT_BOOTSTRAPPED -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -#endif -#ifdef QT_NO_GEOM_VARIANT -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -template<> struct TypeDefinition { static const bool IsAvailable = false; }; -#endif - struct CoreTypesFilter { template struct Acceptor { - static const bool IsAccepted = QTypeModuleInfo::IsCore && TypeDefinition::IsAvailable; + static const bool IsAccepted = QTypeModuleInfo::IsCore && QtMetaTypePrivate::TypeDefinition::IsAvailable; }; }; -} // annonymous used to hide TypeDefinition +} // annonymous namespace { // annonymous used to hide QVariant handlers -- cgit v1.2.3