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)
CONFIG += warning_clean
DEFINES += QT_NO_JAVA_STYLE_ITERATORS
QT_SOURCE_TREE = $$PWD
QT_BUILD_TREE = $$shadowed($$PWD)

View File

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

View File

@ -44,6 +44,8 @@
QT_BEGIN_NAMESPACE
#if !defined(QT_NO_JAVA_STYLE_ITERATORS)
#define Q_DECLARE_SEQUENTIAL_ITERATOR(C) \
\
template <class T> \
@ -179,6 +181,13 @@ public: \
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>
class QKeyValueIterator
{

View File

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

View File

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

View File

@ -3,3 +3,4 @@ TARGET = tst_qfuture
QT = core core-private testlib
SOURCES = tst_qfuture.cpp
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
DEFINES -= QT_STRICT_ITERATORS
DEFINES -= QT_NO_JAVA_STYLE_ITERATORS

View File

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

View File

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

View File

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