Add QT_NO_JAVA_STYLE_ITERATORS and mark QtBase free of it

... except for tests, which manually undefine the macro.

Like QT_NO_FOREACH, this is a technical way to keep JSI-free
modules JSI-free going forward.

Change-Id: Icf1342da00a700f42f9e32a253d1cdb94c38dd7e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Marc Mutz 2019-05-23 13:55:07 +02:00
parent f99bbfb9ea
commit f70905448f
10 changed files with 26 additions and 0 deletions

View File

@ -1,6 +1,8 @@
load(qt_build_config) load(qt_build_config)
CONFIG += warning_clean CONFIG += warning_clean
DEFINES += QT_NO_JAVA_STYLE_ITERATORS
QT_SOURCE_TREE = $$PWD QT_SOURCE_TREE = $$PWD
QT_BUILD_TREE = $$shadowed($$PWD) QT_BUILD_TREE = $$shadowed($$PWD)

View File

@ -48,8 +48,11 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
typedef QListIterator<QByteArray> QByteArrayListIterator; typedef QListIterator<QByteArray> QByteArrayListIterator;
typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator; typedef QMutableListIterator<QByteArray> QMutableByteArrayListIterator;
#endif
#ifndef Q_CLANG_QDOC #ifndef Q_CLANG_QDOC
typedef QList<QByteArray> QByteArrayList; typedef QList<QByteArray> QByteArrayList;

View File

@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
#define Q_DECLARE_SEQUENTIAL_ITERATOR(C) \ #define Q_DECLARE_SEQUENTIAL_ITERATOR(C) \
\ \
template <class T> \ template <class T> \
@ -179,6 +181,13 @@ public: \
n = c->end(); return false; } \ n = c->end(); return false; } \
}; };
#else // QT_NO_JAVA_STYLE_ITERATORS
#define Q_DECLARE_SEQUENTIAL_ITERATOR(C)
#define Q_DECLARE_MUTABLE_SEQUENTIAL_ITERATOR(C)
#define Q_DECLARE_ASSOCIATIVE_ITERATOR(C)
#define Q_DECLARE_MUTABLE_ASSOCIATIVE_ITERATOR(C)
#endif // QT_NO_JAVA_STYLE_ITERATORS
template<typename Key, typename T, class Iterator> template<typename Key, typename T, class Iterator>
class QKeyValueIterator class QKeyValueIterator
{ {

View File

@ -402,6 +402,7 @@ QList<T> QList<T>::fromSet(const QSet<T> &set)
Q_DECLARE_SEQUENTIAL_ITERATOR(Set) Q_DECLARE_SEQUENTIAL_ITERATOR(Set)
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
template <typename T> template <typename T>
class QMutableSetIterator class QMutableSetIterator
{ {
@ -433,6 +434,7 @@ public:
{ while (c->constBegin() != i) if (*(n = --i) == t) return true; { while (c->constBegin() != i) if (*(n = --i) == t) return true;
n = c->end(); return false; } n = c->end(); return false; }
}; };
#endif // QT_NO_JAVA_STYLE_ITERATORS
QT_END_NAMESPACE QT_END_NAMESPACE

View File

@ -54,8 +54,10 @@ QT_BEGIN_NAMESPACE
class QRegExp; class QRegExp;
class QRegularExpression; class QRegularExpression;
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
typedef QListIterator<QString> QStringListIterator; typedef QListIterator<QString> QStringListIterator;
typedef QMutableListIterator<QString> QMutableStringListIterator; typedef QMutableListIterator<QString> QMutableStringListIterator;
#endif
class QStringList; class QStringList;

View File

@ -3,3 +3,4 @@ TARGET = tst_qfuture
QT = core core-private testlib QT = core core-private testlib
SOURCES = tst_qfuture.cpp SOURCES = tst_qfuture.cpp
DEFINES += QT_STRICT_ITERATORS DEFINES += QT_STRICT_ITERATORS
DEFINES -= QT_NO_JAVA_STYLE_ITERATORS

View File

@ -5,3 +5,4 @@ QT = core testlib
# This test does not work with strict iterators # This test does not work with strict iterators
DEFINES -= QT_STRICT_ITERATORS DEFINES -= QT_STRICT_ITERATORS
DEFINES -= QT_NO_JAVA_STYLE_ITERATORS

View File

@ -2,3 +2,5 @@ CONFIG += testcase
TARGET = tst_qhash TARGET = tst_qhash
QT = core testlib QT = core testlib
SOURCES = $$PWD/tst_qhash.cpp SOURCES = $$PWD/tst_qhash.cpp
DEFINES -= QT_NO_JAVA_STYLE_ITERATORS

View File

@ -2,3 +2,5 @@ CONFIG += testcase
TARGET = tst_qmap TARGET = tst_qmap
QT = core testlib QT = core testlib
SOURCES = $$PWD/tst_qmap.cpp SOURCES = $$PWD/tst_qmap.cpp
DEFINES -= QT_NO_JAVA_STYLE_ITERATORS

View File

@ -2,3 +2,5 @@ CONFIG += testcase
TARGET = tst_qset TARGET = tst_qset
QT = core testlib QT = core testlib
SOURCES = tst_qset.cpp SOURCES = tst_qset.cpp
DEFINES -= QT_NO_JAVA_STYLE_ITERATORS