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>
This commit is contained in:
Thiago Macieira 2024-02-26 20:03:46 -08:00
parent 0f56502fb6
commit 4be7c046b1
7 changed files with 17 additions and 21 deletions

View File

@ -22,13 +22,14 @@
#endif #endif
#include "quuid.h" #include "quuid.h"
#include "qvariant.h" #include "qvariant.h"
#include "qdatastream.h"
#if QT_CONFIG(regularexpression) #if QT_CONFIG(regularexpression)
# include "qregularexpression.h" # include "qregularexpression.h"
#endif #endif
#ifndef QT_BOOTSTRAPPED #ifndef QT_BOOTSTRAPPED
# include "qdatastream.h"
# include "qbitarray.h" # include "qbitarray.h"
# include "qurl.h" # include "qurl.h"
# include "qvariant.h" # include "qvariant.h"

View File

@ -2368,19 +2368,21 @@ struct QDebugStreamOperatorForType <T, false>
template<typename T, bool = QTypeTraits::has_stream_operator_v<QDataStream, T>> template<typename T, bool = QTypeTraits::has_stream_operator_v<QDataStream, T>>
struct QDataStreamOperatorForType struct QDataStreamOperatorForType
{
static constexpr QMetaTypeInterface::DataStreamOutFn dataStreamOut = nullptr;
static constexpr QMetaTypeInterface::DataStreamInFn dataStreamIn = nullptr;
};
#ifndef QT_NO_DATASTREAM
template<typename T>
struct QDataStreamOperatorForType <T, true>
{ {
static void dataStreamOut(const QMetaTypeInterface *, QDataStream &ds, const void *a) static void dataStreamOut(const QMetaTypeInterface *, QDataStream &ds, const void *a)
{ ds << *reinterpret_cast<const T *>(a); } { ds << *reinterpret_cast<const T *>(a); }
static void dataStreamIn(const QMetaTypeInterface *, QDataStream &ds, void *a) static void dataStreamIn(const QMetaTypeInterface *, QDataStream &ds, void *a)
{ ds >> *reinterpret_cast<T *>(a); } { ds >> *reinterpret_cast<T *>(a); }
}; };
#endif
template<typename T>
struct QDataStreamOperatorForType <T, false>
{
static constexpr QMetaTypeInterface::DataStreamOutFn dataStreamOut = nullptr;
static constexpr QMetaTypeInterface::DataStreamInFn dataStreamIn = nullptr;
};
// Performance optimization: // Performance optimization:
// //

View File

@ -25,7 +25,7 @@ class QDataStream;
class QIODevice; class QIODevice;
class QString; class QString;
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED) #if !defined(QT_NO_DATASTREAM)
class QDataStreamPrivate; class QDataStreamPrivate;
namespace QtPrivate { namespace QtPrivate {
class StreamStateSaver; class StreamStateSaver;

View File

@ -3329,7 +3329,7 @@ void QByteArray::clear()
d.clear(); d.clear();
} }
#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED) #if !defined(QT_NO_DATASTREAM)
/*! \relates QByteArray /*! \relates QByteArray

View File

@ -9549,7 +9549,7 @@ QString &QString::setRawData(const QChar *unicode, qsizetype size)
\sa toUcs4(), toStdWString(), toStdU16String() \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) \fn QDataStream &operator<<(QDataStream &stream, const QString &string)
\relates QString \relates QString

View File

@ -51,7 +51,6 @@ qt_internal_extend_target(Bootstrap
../../corelib/serialization/qcborcommon.cpp ../../corelib/serialization/qcborcommon.cpp
../../corelib/serialization/qcborstreamwriter.cpp ../../corelib/serialization/qcborstreamwriter.cpp
../../corelib/serialization/qcborvalue.cpp ../../corelib/serialization/qcborvalue.cpp
../../corelib/serialization/qdatastream.cpp
../../corelib/serialization/qjsonarray.cpp ../../corelib/serialization/qjsonarray.cpp
../../corelib/serialization/qjsoncbor.cpp ../../corelib/serialization/qjsoncbor.cpp
../../corelib/serialization/qjsondocument.cpp ../../corelib/serialization/qjsondocument.cpp

View File

@ -185,11 +185,8 @@ static bool writeJsonFiles(const QList<QString> &fileList, const QString &fileLi
} }
qint64 timestamp = std::numeric_limits<qint64>::min(); qint64 timestamp = std::numeric_limits<qint64>::min();
QByteArray timestampBuffer = timestampFile.readAll(); if (timestampFile.size() == sizeof(timestamp))
if (timestampBuffer.size() == sizeof(timestamp)) { timestampFile.read(reinterpret_cast<char *>(&timestamp), sizeof(timestamp));
QDataStream istream(&timestampBuffer, QIODevice::ReadOnly);
istream >> timestamp;
}
// Check if any of the metatype json files produced by automoc is newer than the last file // Check if any of the metatype json files produced by automoc is newer than the last file
// processed by cmake_automoc parser // processed by cmake_automoc parser
@ -215,11 +212,8 @@ static bool writeJsonFiles(const QList<QString> &fileList, const QString &fileLi
textStream.flush(); textStream.flush();
// Update the timestamp according the newest json file timestamp. // Update the timestamp according the newest json file timestamp.
timestampBuffer.clear();
QDataStream ostream(&timestampBuffer, QIODevice::WriteOnly);
ostream << timestamp;
timestampFile.resize(0); timestampFile.resize(0);
timestampFile.write(timestampBuffer); timestampFile.write(reinterpret_cast<char *>(&timestamp), sizeof(timestamp));
} }
return true; return true;
} }