From 5a4787dca01c302dd462a76222dfbf28c8951a8d Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Fri, 9 Feb 2018 14:29:21 +0100 Subject: Modernize the "regularexpression" feature Use QT_CONFIG(regularexpression), disentangle it from QT_BOOTSTRAPPED, switch it off in the bootstrap build, remove the #ifdefs from qregularexpression.{h|cpp}, and add QT_REQUIRE_CONFIG(regularexpression) to the header. qregularexpression.{h|cpp} are already correctly excluded in tools.pri if !qtConfig(regularexpression). Change-Id: I21de154a6a118b76f99003d3acb72ac1e220d302 Reviewed-by: Oswald Buddenhagen --- src/corelib/kernel/qmetatype.cpp | 17 ++++++++++------- src/corelib/kernel/qmetatype_p.h | 2 +- src/corelib/kernel/qobject.cpp | 8 +++++--- src/corelib/kernel/qobject.h | 6 +++--- src/corelib/kernel/qvariant.cpp | 16 +++++++++------- src/corelib/kernel/qvariant.h | 16 ++++++++-------- 6 files changed, 36 insertions(+), 29 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 5abc2ebd70..518381712a 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -53,12 +53,15 @@ #include "qdatastream.h" #include "qmetatypeswitcher_p.h" +#if QT_CONFIG(regularexpression) +# include "qregularexpression.h" +#endif + #ifndef QT_BOOTSTRAPPED # include "qbitarray.h" # include "qurl.h" # include "qvariant.h" # include "qabstractitemmodel.h" -# include "qregularexpression.h" # include "qjsonvalue.h" # include "qjsonobject.h" # include "qjsonarray.h" @@ -1481,12 +1484,12 @@ bool QMetaType::save(QDataStream &stream, int type, const void *data) stream << *static_cast(data); break; #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) case QMetaType::QRegularExpression: stream << *static_cast(data); break; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED case QMetaType::QEasingCurve: stream << *static_cast(data); break; @@ -1711,12 +1714,12 @@ bool QMetaType::load(QDataStream &stream, int type, void *data) stream >> *static_cast< NS(QRegExp)*>(data); break; #endif -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) case QMetaType::QRegularExpression: stream >> *static_cast< NS(QRegularExpression)*>(data); break; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED case QMetaType::QEasingCurve: stream >> *static_cast< NS(QEasingCurve)*>(data); break; diff --git a/src/corelib/kernel/qmetatype_p.h b/src/corelib/kernel/qmetatype_p.h index 6f1334d082..0bf6bcb922 100644 --- a/src/corelib/kernel/qmetatype_p.h +++ b/src/corelib/kernel/qmetatype_p.h @@ -219,7 +219,7 @@ template<> struct TypeDefinition { static const bool IsAvailable = fals #ifdef QT_NO_REGEXP template<> struct TypeDefinition { static const bool IsAvailable = false; }; #endif -#if defined(QT_BOOTSTRAPPED) || defined(QT_NO_REGULAREXPRESSION) +#if !QT_CONFIG(regularexpression) template<> struct TypeDefinition { static const bool IsAvailable = false; }; #endif #ifdef QT_NO_SHORTCUT diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 9e1c3a50cb..dcc1bb5814 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -50,7 +50,9 @@ #include "qvariant.h" #include "qmetaobject.h" #include -#include +#if QT_CONFIG(regularexpression) +# include +#endif #include #include #include @@ -1921,7 +1923,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegExp &re, } #endif // QT_NO_REGEXP -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) /*! \internal */ @@ -1943,7 +1945,7 @@ void qt_qFindChildren_helper(const QObject *parent, const QRegularExpression &re qt_qFindChildren_helper(obj, re, mo, list, options); } } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) /*! \internal diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h index 0e608a3208..aac9bcdee9 100644 --- a/src/corelib/kernel/qobject.h +++ b/src/corelib/kernel/qobject.h @@ -74,7 +74,7 @@ class QWidget; #ifndef QT_NO_REGEXP class QRegExp; #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) class QRegularExpression; #endif #ifndef QT_NO_USERDATA @@ -187,7 +187,7 @@ public: } #endif -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) template inline QList findChildren(const QRegularExpression &re, Qt::FindChildOptions options = Qt::FindChildrenRecursively) const { @@ -197,7 +197,7 @@ public: reinterpret_cast *>(&list), options); return list; } -#endif +#endif // QT_CONFIG(regularexpression) inline const QObjectList &children() const { return d_ptr->children; } diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index f77831c703..c3c36e05d7 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -48,7 +48,9 @@ #include "qdatetime.h" #include "qeasingcurve.h" #include "qlist.h" +#if QT_CONFIG(regularexpression) #include "qregularexpression.h" +#endif #include "qstring.h" #include "qstringlist.h" #include "qurl.h" @@ -1941,12 +1943,12 @@ QVariant::QVariant(const QRegExp ®Exp) : d(RegExp) { v_construct(&d, regExp); } #endif // QT_NO_REGEXP -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QVariant::QVariant(const QRegularExpression &re) : d(RegularExpression) { v_construct(&d, re); } -#endif +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED QVariant::QVariant(const QUuid &uuid) : d(Uuid) { v_construct(&d, uuid); } @@ -2650,7 +2652,7 @@ QRegExp QVariant::toRegExp() const } #endif -#ifndef QT_BOOTSTRAPPED +#if QT_CONFIG(regularexpression) /*! \fn QRegularExpression QVariant::toRegularExpression() const \since 5.0 @@ -2660,13 +2662,13 @@ QRegExp QVariant::toRegExp() const \sa canConvert(), convert() */ -#ifndef QT_NO_REGULAREXPRESSION QRegularExpression QVariant::toRegularExpression() const { return qVariantToHelper(d, handlerManager); } -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED /*! \since 5.0 @@ -2758,7 +2760,7 @@ QJsonDocument QVariant::toJsonDocument() const { return qVariantToHelper(d, handlerManager); } -#endif +#endif // QT_BOOTSTRAPPED /*! \fn QChar QVariant::toChar() const diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 7ce4e1a4d8..361768ef00 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -81,9 +81,9 @@ class QRectF; #ifndef QT_NO_REGEXP class QRegExp; #endif // QT_NO_REGEXP -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) class QRegularExpression; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) class QTextFormat; class QTextLength; class QUrl; @@ -248,10 +248,10 @@ class Q_CORE_EXPORT QVariant #ifndef QT_NO_REGEXP QVariant(const QRegExp ®Exp); #endif // QT_NO_REGEXP -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QVariant(const QRegularExpression &re); -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED QVariant(const QUrl &url); QVariant(const QEasingCurve &easing); QVariant(const QUuid &uuid); @@ -322,10 +322,10 @@ class Q_CORE_EXPORT QVariant #ifndef QT_NO_REGEXP QRegExp toRegExp() const; #endif // QT_NO_REGEXP -#ifndef QT_BOOTSTRAPPED -#ifndef QT_NO_REGULAREXPRESSION +#if QT_CONFIG(regularexpression) QRegularExpression toRegularExpression() const; -#endif // QT_NO_REGULAREXPRESSION +#endif // QT_CONFIG(regularexpression) +#ifndef QT_BOOTSTRAPPED QUrl toUrl() const; QEasingCurve toEasingCurve() const; QUuid toUuid() const; -- cgit v1.2.3