summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2024-02-26 20:03:46 -0800
committerThiago Macieira <thiago.macieira@intel.com>2024-03-13 00:00:48 -0800
commit4be7c046b1792a97e6e3e5c9dd9e3f71ffb11529 (patch)
tree9cfaa81a03cec30c680510a89345b8762262ba9c
parent0f56502fb6f062c6d2308198c93412c34525125b (diff)
Bootstrap: remove QDataStream
It was only used by the cmake_automoc_parser so it would write a 64-bit in big-endian format. So bypass QDataStream and write it native endianness. Change-Id: I01ec3c774d9943adb903fffd17b79c78e56db4cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
-rw-r--r--src/corelib/kernel/qmetatype.cpp3
-rw-r--r--src/corelib/kernel/qmetatype.h16
-rw-r--r--src/corelib/serialization/qdatastream.h2
-rw-r--r--src/corelib/text/qbytearray.cpp2
-rw-r--r--src/corelib/text/qstring.cpp2
-rw-r--r--src/tools/bootstrap/CMakeLists.txt1
-rw-r--r--src/tools/cmake_automoc_parser/main.cpp12
7 files changed, 17 insertions, 21 deletions
diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index ebe79e0232..3ccff5ae5f 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -22,13 +22,14 @@
#endif
#include "quuid.h"
#include "qvariant.h"
-#include "qdatastream.h"
#if QT_CONFIG(regularexpression)
# include "qregularexpression.h"
#endif
#ifndef QT_BOOTSTRAPPED
+# include "qdatastream.h"
+
# include "qbitarray.h"
# include "qurl.h"
# include "qvariant.h"
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 5528c2f459..9c1fdeecdd 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -2369,18 +2369,20 @@ struct QDebugStreamOperatorForType <T, false>
template<typename T, bool = QTypeTraits::has_stream_operator_v<QDataStream, T>>
struct QDataStreamOperatorForType
{
- static void dataStreamOut(const QMetaTypeInterface *, QDataStream &ds, const void *a)
- { ds << *reinterpret_cast<const T *>(a); }
- static void dataStreamIn(const QMetaTypeInterface *, QDataStream &ds, void *a)
- { ds >> *reinterpret_cast<T *>(a); }
+ static constexpr QMetaTypeInterface::DataStreamOutFn dataStreamOut = nullptr;
+ static constexpr QMetaTypeInterface::DataStreamInFn dataStreamIn = nullptr;
};
+#ifndef QT_NO_DATASTREAM
template<typename T>
-struct QDataStreamOperatorForType <T, false>
+struct QDataStreamOperatorForType <T, true>
{
- static constexpr QMetaTypeInterface::DataStreamOutFn dataStreamOut = nullptr;
- static constexpr QMetaTypeInterface::DataStreamInFn dataStreamIn = nullptr;
+ static void dataStreamOut(const QMetaTypeInterface *, QDataStream &ds, const void *a)
+ { ds << *reinterpret_cast<const T *>(a); }
+ static void dataStreamIn(const QMetaTypeInterface *, QDataStream &ds, void *a)
+ { ds >> *reinterpret_cast<T *>(a); }
};
+#endif
// Performance optimization:
//
diff --git a/src/corelib/serialization/qdatastream.h b/src/corelib/serialization/qdatastream.h
index d3932372fa..cf37df71d7 100644
--- a/src/corelib/serialization/qdatastream.h
+++ b/src/corelib/serialization/qdatastream.h
@@ -25,7 +25,7 @@ class QDataStream;
class QIODevice;
class QString;
-#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
+#if !defined(QT_NO_DATASTREAM)
class QDataStreamPrivate;
namespace QtPrivate {
class StreamStateSaver;
diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp
index cacf8cbf63..522ae475e6 100644
--- a/src/corelib/text/qbytearray.cpp
+++ b/src/corelib/text/qbytearray.cpp
@@ -3329,7 +3329,7 @@ void QByteArray::clear()
d.clear();
}
-#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
+#if !defined(QT_NO_DATASTREAM)
/*! \relates QByteArray
diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp
index 38df9b6f4d..9bc41bd313 100644
--- a/src/corelib/text/qstring.cpp
+++ b/src/corelib/text/qstring.cpp
@@ -9549,7 +9549,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa toUcs4(), toStdWString(), toStdU16String()
*/
-#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
+#if !defined(QT_NO_DATASTREAM)
/*!
\fn QDataStream &operator<<(QDataStream &stream, const QString &string)
\relates QString
diff --git a/src/tools/bootstrap/CMakeLists.txt b/src/tools/bootstrap/CMakeLists.txt
index 4c64cb5183..a3babd89aa 100644
--- a/src/tools/bootstrap/CMakeLists.txt
+++ b/src/tools/bootstrap/CMakeLists.txt
@@ -51,7 +51,6 @@ qt_internal_extend_target(Bootstrap
../../corelib/serialization/qcborcommon.cpp
../../corelib/serialization/qcborstreamwriter.cpp
../../corelib/serialization/qcborvalue.cpp
- ../../corelib/serialization/qdatastream.cpp
../../corelib/serialization/qjsonarray.cpp
../../corelib/serialization/qjsoncbor.cpp
../../corelib/serialization/qjsondocument.cpp
diff --git a/src/tools/cmake_automoc_parser/main.cpp b/src/tools/cmake_automoc_parser/main.cpp
index 86e10d48ad..de484b184b 100644
--- a/src/tools/cmake_automoc_parser/main.cpp
+++ b/src/tools/cmake_automoc_parser/main.cpp
@@ -185,11 +185,8 @@ static bool writeJsonFiles(const QList<QString> &fileList, const QString &fileLi
}
qint64 timestamp = std::numeric_limits<qint64>::min();
- QByteArray timestampBuffer = timestampFile.readAll();
- if (timestampBuffer.size() == sizeof(timestamp)) {
- QDataStream istream(&timestampBuffer, QIODevice::ReadOnly);
- istream >> timestamp;
- }
+ if (timestampFile.size() == sizeof(timestamp))
+ timestampFile.read(reinterpret_cast<char *>(&timestamp), sizeof(timestamp));
// Check if any of the metatype json files produced by automoc is newer than the last file
// processed by cmake_automoc parser
@@ -215,11 +212,8 @@ static bool writeJsonFiles(const QList<QString> &fileList, const QString &fileLi
textStream.flush();
// Update the timestamp according the newest json file timestamp.
- timestampBuffer.clear();
- QDataStream ostream(&timestampBuffer, QIODevice::WriteOnly);
- ostream << timestamp;
timestampFile.resize(0);
- timestampFile.write(timestampBuffer);
+ timestampFile.write(reinterpret_cast<char *>(&timestamp), sizeof(timestamp));
}
return true;
}