Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package qt6-grpc for openSUSE:Factory checked in at 2023-07-26 13:22:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/qt6-grpc (Old) and /work/SRC/openSUSE:Factory/.qt6-grpc.new.15225 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "qt6-grpc" Wed Jul 26 13:22:34 2023 rev:4 rq:1099990 version:6.5.2 Changes: -------- --- /work/SRC/openSUSE:Factory/qt6-grpc/qt6-grpc.changes 2023-07-06 18:28:42.739160270 +0200 +++ /work/SRC/openSUSE:Factory/.qt6-grpc.new.15225/qt6-grpc.changes 2023-07-26 13:22:57.387657141 +0200 @@ -1,0 +2,6 @@ +Thu Jul 20 08:50:52 UTC 2023 - Christophe Marin <christo...@krop.fr> + +- Update to 6.5.2 + * https://www.qt.io/blog/qt-6.5.2-released-1 + +------------------------------------------------------------------- Old: ---- qtgrpc-everywhere-src-6.5.1.tar.xz New: ---- qtgrpc-everywhere-src-6.5.2.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ qt6-grpc.spec ++++++ --- /var/tmp/diff_new_pack.9gPUD7/_old 2023-07-26 13:22:58.523663570 +0200 +++ /var/tmp/diff_new_pack.9gPUD7/_new 2023-07-26 13:22:58.527663593 +0200 @@ -16,7 +16,7 @@ # -%define real_version 6.5.1 +%define real_version 6.5.2 %define short_version 6.5 %define short_name qtgrpc %define tar_name qtgrpc-everywhere-src @@ -28,12 +28,12 @@ %endif # Name: qt6-grpc%{?pkg_suffix} -Version: 6.5.1 +Version: 6.5.2 Release: 0 Summary: gRPC and Protobuf generator and bindings for Qt framework License: GPL-3.0-or-later URL: https://www.qt.io -Source: https://download.qt.io/official_releases/qt/%{short_version}/%{real_version}%{tar_suffix}/submodules/%{tar_name}-%{real_version}%{tar_suffix}.tar.xz +Source: https://www.nic.funet.fi/pub/mirrors/download.qt-project.org/official_releases/qt/%{short_version}/%{real_version}%{tar_suffix}/submodules/%{tar_name}-%{real_version}%{tar_suffix}.tar.xz # PATCH-FIX-UPSTREAM Patch0: 0001-Fix-include-of-std-set.patch Patch1: 0002-Remove-protobuf-logging.h-include.patch ++++++ qtgrpc-everywhere-src-6.5.1.tar.xz -> qtgrpc-everywhere-src-6.5.2.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/.cmake.conf new/qtgrpc-everywhere-src-6.5.2/.cmake.conf --- old/qtgrpc-everywhere-src-6.5.1/.cmake.conf 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/.cmake.conf 2023-07-07 14:29:20.000000000 +0200 @@ -1,4 +1,4 @@ -set(QT_REPO_MODULE_VERSION "6.5.1") +set(QT_REPO_MODULE_VERSION "6.5.2") set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1") set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1") diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/.tag new/qtgrpc-everywhere-src-6.5.2/.tag --- old/qtgrpc-everywhere-src-6.5.1/.tag 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/.tag 2023-07-07 14:29:20.000000000 +0200 @@ -1 +1 @@ -94446d021a34daee99dbcda389dcd8a5e9a0c76c +0646deb7aeb7410febd0419dcbd964505f178690 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/CMakeLists.txt new/qtgrpc-everywhere-src-6.5.2/CMakeLists.txt --- old/qtgrpc-everywhere-src-6.5.1/CMakeLists.txt 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/CMakeLists.txt 2023-07-07 14:29:20.000000000 +0200 @@ -14,6 +14,7 @@ find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core) find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Network Gui Widgets Quick QuickControls2) +qt_internal_project_setup() # Try to find Qt6::qtprotobufgen and Qt6::qtgrpcgen targets from host tools # when cross-compiling. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/dependencies.yaml new/qtgrpc-everywhere-src-6.5.2/dependencies.yaml --- old/qtgrpc-everywhere-src-6.5.1/dependencies.yaml 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/dependencies.yaml 2023-07-07 14:29:20.000000000 +0200 @@ -1,7 +1,7 @@ dependencies: ../qtbase: - ref: 55aee8697512af105dfefabc1e2ec41d4df1e45e + ref: af457a9f0f7eb1a2a7d11f495da508faab91a442 required: true ../qtdeclarative: - ref: 65651dc1d333e2aded18b0d6f0b71c35e5b40c1c + ref: f289063ff19588a11dd79213632785cfda2909a0 required: false diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/examples/grpc/chat/client/CMakeLists.txt new/qtgrpc-everywhere-src-6.5.2/examples/grpc/chat/client/CMakeLists.txt --- old/qtgrpc-everywhere-src-6.5.1/examples/grpc/chat/client/CMakeLists.txt 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/examples/grpc/chat/client/CMakeLists.txt 2023-07-07 14:29:20.000000000 +0200 @@ -23,7 +23,7 @@ qt_add_qml_module(grpcchatclient URI qtgrpc.examples.chat VERSION 1.0 - AUTO_RESOURCE_PREFIX + RESOURCE_PREFIX "/qt/qml" QML_FILES Main.qml ChatInputField.qml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/examples/grpc/magic8ball/CMakeLists.txt new/qtgrpc-everywhere-src-6.5.2/examples/grpc/magic8ball/CMakeLists.txt --- old/qtgrpc-everywhere-src-6.5.1/examples/grpc/magic8ball/CMakeLists.txt 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/examples/grpc/magic8ball/CMakeLists.txt 2023-07-07 14:29:20.000000000 +0200 @@ -35,7 +35,7 @@ qt_add_qml_module(magic8ball URI qtgrpc.examples.magic8ball VERSION 1.0 - AUTO_RESOURCE_PREFIX + RESOURCE_PREFIX "/qt/qml" SOURCES clientservice.h clientservice.cpp diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/grpc/qgrpcchannel.cpp new/qtgrpc-everywhere-src-6.5.2/src/grpc/qgrpcchannel.cpp --- old/qtgrpc-everywhere-src-6.5.1/src/grpc/qgrpcchannel.cpp 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/grpc/qgrpcchannel.cpp 2023-07-07 14:29:20.000000000 +0200 @@ -136,7 +136,6 @@ grpc::ByteBuffer request = parseQByteArray(data); thread = QThread::create([this, request, channel, method = toStdString(method)] { grpc::ByteBuffer callResponse; - QByteArray data; grpc::Status callStatus; callStatus = grpc::internal::BlockingUnaryCall( diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/grpc/qgrpcchannel_p.h new/qtgrpc-everywhere-src-6.5.2/src/grpc/qgrpcchannel_p.h --- old/qtgrpc-everywhere-src-6.5.1/src/grpc/qgrpcchannel_p.h 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/grpc/qgrpcchannel_p.h 2023-07-07 14:29:20.000000000 +0200 @@ -16,15 +16,17 @@ // We mean it. // -#include <QtCore/QObject> -#include <QtCore/QThread> -#include <QtCore/qbytearray.h> #include <QtGrpc/qabstractgrpcclient.h> #include <QtGrpc/qabstractgrpccredentials.h> #include <QtGrpc/qgrpccallreply.h> #include <QtGrpc/qgrpcchannel.h> #include <QtGrpc/qgrpccredentials.h> #include <QtGrpc/qgrpcstream.h> +#include <QtGrpc/private/qtgrpcglobal_p.h> + +#include <QtCore/QObject> +#include <QtCore/QThread> +#include <QtCore/qbytearray.h> QT_REQUIRE_CONFIG(native_grpc); #include <grpcpp/channel.h> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/grpc/qtgrpcglobal_p.h new/qtgrpc-everywhere-src-6.5.2/src/grpc/qtgrpcglobal_p.h --- old/qtgrpc-everywhere-src-6.5.1/src/grpc/qtgrpcglobal_p.h 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/grpc/qtgrpcglobal_p.h 2023-07-07 14:29:20.000000000 +0200 @@ -18,6 +18,7 @@ #include <QtGrpc/qtgrpcglobal.h> #include <QtCore/qloggingcategory.h> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(Grpc) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufmessage.cpp new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufmessage.cpp --- old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufmessage.cpp 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufmessage.cpp 2023-07-07 14:29:20.000000000 +0200 @@ -59,6 +59,15 @@ ++unknownEntries[entry.toByteArray()]; } +std::optional<QMetaProperty> QProtobufMessagePrivate::metaProperty(QAnyStringView name) const +{ + const int index = getPropertyIndex(name); + const QMetaProperty property = metaObject->property(index); + if (property.isValid()) + return property; + return std::nullopt; +} + /*! Set the property \a propertyName to the value stored in \a value. @@ -72,11 +81,10 @@ { Q_D(QProtobufMessage); - int index = d->getPropertyIndex(propertyName); - const QMetaProperty &property = d->metaObject->property(index); - if (!property.isValid()) - return false; - return property.writeOnGadget(this, value); + if (auto mp = d->metaProperty(propertyName)) + return mp->writeOnGadget(this, value); + + return false; } /*! @@ -88,9 +96,9 @@ { Q_D(const QProtobufMessage); - int index = d->getPropertyIndex(propertyName); - const QMetaProperty &property = d->metaObject->property(index); - return property.readOnGadget(this); + if (const auto mp = d->metaProperty(propertyName)) + return mp->readOnGadget(this); + return {}; } /*! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufmessage_p.h new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufmessage_p.h --- old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufmessage_p.h 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufmessage_p.h 2023-07-07 14:29:20.000000000 +0200 @@ -15,14 +15,20 @@ // We mean it. // +#include "qprotobufmessage.h" + #include <QtProtobuf/qtprotobufglobal.h> + #include <QtCore/qtconfigmacros.h> #include <QtCore/qhash.h> +#include <QtCore/private/qglobal_p.h> -#include "qprotobufmessage.h" +#include <optional> QT_BEGIN_NAMESPACE +class QMetaProperty; + class QProtobufMessagePrivate { public: @@ -36,6 +42,8 @@ int getPropertyIndex(QAnyStringView propertyName) const; void storeUnknownEntry(QByteArrayView entry); + std::optional<QMetaProperty> metaProperty(QAnyStringView name) const; + static QProtobufMessagePrivate *get(QProtobufMessage *message) { return message->d_func(); } static const QProtobufMessagePrivate *get(const QProtobufMessage *message) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufserializer.cpp new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufserializer.cpp --- old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufserializer.cpp 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufserializer.cpp 2023-07-07 14:29:20.000000000 +0200 @@ -121,81 +121,38 @@ using namespace Qt::StringLiterals; using namespace QtProtobufPrivate; -template<> -Q_REQUIRED_RESULT -QByteArray QProtobufSerializerPrivate::serializeListType<QByteArray>(const QByteArrayList &listValue, int &outFieldIndex) -{ - qProtoDebug("listValue.count %" PRIdQSIZETYPE " outFieldIndex %d", listValue.count(), - outFieldIndex); - - if (listValue.isEmpty()) { - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return QByteArray(); - } - - QByteArray serializedList; - for (const QByteArray &value : listValue) { - serializedList.append(QProtobufSerializerPrivate::encodeHeader( - outFieldIndex, QtProtobuf::WireTypes::LengthDelimited)); - serializedList.append(serializeLengthDelimited(value, false)); - } - - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return serializedList; -} - -template<> -Q_REQUIRED_RESULT -bool QProtobufSerializerPrivate::deserializeList<QByteArray>(QProtobufSelfcheckIterator &it, QVariant &previousValue) -{ - qProtoDebug("currentByte: 0x%x", *it); - - std::optional<QByteArray> result = deserializeLengthDelimited(it); - if (result) { - QByteArrayList list = previousValue.value<QByteArrayList>(); - list.append(std::move(*result)); - previousValue.setValue(list); - return true; - } - return false; -} - -template<> -Q_REQUIRED_RESULT -bool QProtobufSerializerPrivate::deserializeList<QString>(QProtobufSelfcheckIterator &it, QVariant &previousValue) -{ - qProtoDebug("currentByte: 0x%x", *it); - - std::optional<QByteArray> result = deserializeLengthDelimited(it); - if (result) { - QStringList list = previousValue.value<QStringList>(); - list.append(QString::fromUtf8(*result)); - previousValue.setValue(list); - return true; - } - return false; -} - template<std::size_t N> using SerializerRegistryType = std::array<QProtobufSerializerPrivate::ProtobufSerializationHandler, N>; namespace { -#define QT_CONSTRUCT_PROTOBUF_SERIALIZATION_HANDLER(Type, WireType) \ - { \ - QMetaType::fromType<Type>(), \ - QProtobufSerializerPrivate::serializeWrapper< \ - Type, QProtobufSerializerPrivate::serializeBasic<Type>>, \ - QProtobufSerializerPrivate::deserializeBasic<Type>, WireType \ - } -#define QT_CONSTRUCT_PROTOBUF_LIST_SERIALIZATION_HANDLER(ListType, Type) \ - { \ - QMetaType::fromType<ListType>(), \ - QProtobufSerializerPrivate::serializeWrapper< \ - ListType, QProtobufSerializerPrivate::serializeListType<Type>>, \ - QProtobufSerializerPrivate::deserializeList<Type>, \ - QtProtobuf::WireTypes::LengthDelimited \ - } +#define QT_CONSTRUCT_PROTOBUF_SERIALIZATION_HANDLER(Type, WireType) \ + { \ + QMetaType::fromType<Type>(), \ + QProtobufSerializerPrivate::serializeWrapper< \ + Type, QProtobufSerializerPrivate::serializeBasic<Type>>, \ + QProtobufSerializerPrivate::deserializeBasic<Type>, \ + QProtobufSerializerPrivate::isPresent<Type>, WireType \ + } +#define QT_CONSTRUCT_PROTOBUF_LIST_SERIALIZATION_HANDLER(ListType, Type) \ + { \ + QMetaType::fromType<ListType>(), \ + QProtobufSerializerPrivate::serializeWrapper< \ + ListType, QProtobufSerializerPrivate::serializeListType<Type>>, \ + QProtobufSerializerPrivate::deserializeList<Type>, \ + QProtobufSerializerPrivate::isPresent<ListType>, \ + QtProtobuf::WireTypes::LengthDelimited \ + } + +#define QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER(ListType, Type, WireType) \ +{ \ +QMetaType::fromType<ListType>(), \ + QProtobufSerializerPrivate::serializeNonPackedWrapper< \ + ListType, QProtobufSerializerPrivate::serializeNonPackedList<Type>>, \ + QProtobufSerializerPrivate::deserializeNonPackedList<Type>, \ + QProtobufSerializerPrivate::isPresent<ListType>, WireType \ +} + constexpr SerializerRegistryType<30> IntegratedTypesSerializers = { { QT_CONSTRUCT_PROTOBUF_SERIALIZATION_HANDLER(float, QtProtobuf::WireTypes::Fixed32), QT_CONSTRUCT_PROTOBUF_SERIALIZATION_HANDLER(double, QtProtobuf::WireTypes::Fixed64), @@ -246,23 +203,17 @@ QT_CONSTRUCT_PROTOBUF_LIST_SERIALIZATION_HANDLER(QtProtobuf::sfixed64List, QtProtobuf::sfixed64), QT_CONSTRUCT_PROTOBUF_LIST_SERIALIZATION_HANDLER(QtProtobuf::boolList, QtProtobuf::boolean), - QT_CONSTRUCT_PROTOBUF_LIST_SERIALIZATION_HANDLER(QStringList, QString), - QT_CONSTRUCT_PROTOBUF_LIST_SERIALIZATION_HANDLER(QByteArrayList, QByteArray), + QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER( + QStringList, QString, QtProtobuf::WireTypes::LengthDelimited), + QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER( + QByteArrayList, QByteArray, QtProtobuf::WireTypes::LengthDelimited), } }; -#define QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER(ListType, Type, WireType) \ - { \ - QMetaType::fromType<ListType>(), \ - QProtobufSerializerPrivate::serializeWrapper< \ - ListType, \ - QProtobufSerializerPrivate::serializeNonPackedListTypeCommon<Type, WireType>>, \ - QProtobufSerializerPrivate::deserializeNonPackedList<Type>, WireType \ - } constexpr SerializerRegistryType<13> IntegratedNonPackedSerializers = { { - QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER( - QtProtobuf::floatList, float, QtProtobuf::WireTypes::Fixed32), - QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER( - QtProtobuf::doubleList, double, QtProtobuf::WireTypes::Fixed64), + QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER(QtProtobuf::floatList, float, + QtProtobuf::WireTypes::Fixed32), + QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER(QtProtobuf::doubleList, double, + QtProtobuf::WireTypes::Fixed64), QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER( QtProtobuf::int32List, QtProtobuf::int32, QtProtobuf::WireTypes::Varint), QT_CONSTRUCT_PROTOBUF_NON_PACKED_LIST_SERIALIZATION_HANDLER( @@ -397,10 +348,10 @@ const QtProtobufPrivate::QProtobufPropertyOrdering &ordering, const QProtobufPropertyOrderingInfo &fieldInfo) const { - QByteArray result = QProtobufSerializerPrivate::encodeHeader( - fieldInfo.getFieldNumber(), QtProtobuf::WireTypes::LengthDelimited); - result.append(QProtobufSerializerPrivate::prependLengthDelimitedSize( - serializeMessage(message, ordering))); + QByteArray result = QProtobufSerializerPrivate::prependLengthDelimitedSize( + serializeMessage(message, ordering)); + result.prepend(QProtobufSerializerPrivate::encodeHeader( + fieldInfo.getFieldNumber(), QtProtobuf::WireTypes::LengthDelimited)); return result; } @@ -465,10 +416,15 @@ QProtobufSerializer::serializeMapPair(const QVariant &key, const QVariant &value, const QProtobufPropertyOrderingInfo &fieldInfo) const { + auto keyHandler = findIntegratedTypeHandler(key.metaType(), false); + Q_ASSERT_X(keyHandler, "QProtobufSerializer", "Map key is not an integrated type."); + QByteArray result = QProtobufSerializerPrivate::encodeHeader( fieldInfo.getFieldNumber(), QtProtobuf::WireTypes::LengthDelimited); + result.append(QProtobufSerializerPrivate::prependLengthDelimitedSize( - d_ptr->serializeProperty(key, fieldInfo.infoForMapKey()) + keyHandler->serializer( + key, QProtobufSerializerPrivate::encodeHeader(1, keyHandler->wireType)) + d_ptr->serializeProperty(value, fieldInfo.infoForMapValue()))); return result; } @@ -494,12 +450,13 @@ QByteArray QProtobufSerializer::serializeEnum(QtProtobuf::int64 value, const QProtobufPropertyOrderingInfo &fieldInfo) const { + if (value == 0) + return {}; + QtProtobuf::WireTypes type = QtProtobuf::WireTypes::Varint; - int fieldIndex = fieldInfo.getFieldNumber(); - QByteArray result = QProtobufSerializerPrivate::serializeBasic<QtProtobuf::int64>(value, fieldIndex); - if (fieldIndex != QtProtobufPrivate::NotUsedFieldIndex) - result.prepend(QProtobufSerializerPrivate::encodeHeader(fieldIndex, type)); - return result; + int fieldNumber = fieldInfo.getFieldNumber(); + return QProtobufSerializerPrivate::encodeHeader(fieldNumber, type) + + QProtobufSerializerPrivate::serializeBasic<QtProtobuf::int64>(value); } /*! @@ -512,13 +469,17 @@ QProtobufSerializer::serializeEnumList(const QList<QtProtobuf::int64> &value, const QProtobufPropertyOrderingInfo &fieldInfo) const { - QtProtobuf::WireTypes type = QtProtobuf::WireTypes::LengthDelimited; - int fieldIndex = fieldInfo.getFieldNumber(); - QByteArray result = - QProtobufSerializerPrivate::serializeListType<QtProtobuf::int64>(value, fieldIndex); - if (fieldIndex != QtProtobufPrivate::NotUsedFieldIndex) - result.prepend(QProtobufSerializerPrivate::encodeHeader(fieldIndex, type)); - return result; + if (value.isEmpty()) { + return {}; + } + + auto header = QProtobufSerializerPrivate::encodeHeader(fieldInfo.getFieldNumber(), + QtProtobuf::WireTypes::LengthDelimited); + + if (fieldInfo.getFieldFlags() & QtProtobufPrivate::NonPacked) + return QProtobufSerializerPrivate::serializeNonPackedList<QtProtobuf::int64>(value, header); + + return header + QProtobufSerializerPrivate::serializeListType<QtProtobuf::int64>(value); } /*! @@ -607,7 +568,6 @@ QProtobufSerializerPrivate::serializeProperty(const QVariant &propertyValue, const QProtobufPropertyOrderingInfo &fieldInfo) { - QtProtobuf::WireTypes type = QtProtobuf::WireTypes::Unknown; QMetaType metaType = propertyValue.metaType(); qProtoDebug() << "propertyValue" << propertyValue << "fieldIndex" << fieldInfo.getFieldNumber() @@ -618,26 +578,26 @@ return {}; } - QByteArray result; - //TODO: replace with some common function auto basicHandler = findIntegratedTypeHandler( metaType, fieldInfo.getFieldFlags() & QtProtobufPrivate::NonPacked); if (basicHandler) { - type = basicHandler->wireType; - int fieldIndex = fieldInfo.getFieldNumber(); - result.append(basicHandler->serializer(propertyValue, fieldIndex)); - if (fieldIndex != QtProtobufPrivate::NotUsedFieldIndex - && type != QtProtobuf::WireTypes::Unknown) { - result.prepend(QProtobufSerializerPrivate::encodeHeader(fieldIndex, type)); - } - } else { - auto handler = QtProtobufPrivate::findHandler(metaType); - if (!handler.serializer) { - qProtoWarning() << "No serializer for type" << propertyValue.typeName(); - return result; + if (!basicHandler->isPresent(propertyValue)) { + return {}; } - handler.serializer(q_ptr, propertyValue, fieldInfo, result); + + QByteArray header = QProtobufSerializerPrivate::encodeHeader(fieldInfo.getFieldNumber(), + basicHandler->wireType); + return basicHandler->serializer(propertyValue, header); + } + + auto handler = QtProtobufPrivate::findHandler(metaType); + if (!handler.serializer) { + qProtoWarning() << "No serializer for type" << propertyValue.typeName(); + return {}; } + QByteArray result; + handler.serializer(q_ptr, propertyValue, fieldInfo, result); + return result; } @@ -688,10 +648,34 @@ newPropertyValue = metaProperty.readOnGadget(message); QMetaType metaType = metaProperty.metaType(); - //TODO: replace with some common function - auto basicHandler = findIntegratedTypeHandler( - metaType, ordering.getFieldFlags(index) & QtProtobufPrivate::NonPacked); + bool isNonPacked = ordering.getFieldFlags(index) & QtProtobufPrivate::NonPacked; + auto basicHandler = findIntegratedTypeHandler(metaType, isNonPacked); + if (basicHandler) { + if (basicHandler->wireType != wireType) { + // If the handler wiretype mismatches the wiretype received from the + // wire that most probably means that we received the list in wrong + // format. This can happen because of mismatch of the field packed + // option in the protobuf schema on the wire ends. Invert the + // isNonPacked flag and try to find the handler one more time to make + // sure that we cover this exceptional case. + // See the conformance tests + // Required.Proto3.ProtobufInput.ValidDataRepeated.*.UnpackedInput + // for details. + basicHandler = findIntegratedTypeHandler(metaType, !isNonPacked); + if (!basicHandler || basicHandler->wireType != wireType) { + setDeserializationError( + QAbstractProtobufSerializer::InvalidHeaderError, + QCoreApplication::translate("QtProtobuf", + "Message received has invalid wiretype for the " + "field number %1. Expected %2, received %3") + .arg(fieldNumber) + .arg(static_cast<int>(basicHandler->wireType)) + .arg(static_cast<int>(wireType))); + return false; + } + } + if (!basicHandler->deserializer(it, newPropertyValue)) { setUnexpectedEndOfStreamError(); return false; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufserializer.h new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufserializer.h --- old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufserializer.h 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufserializer.h 2023-07-07 14:29:20.000000000 +0200 @@ -16,6 +16,7 @@ #include <QtCore/QMetaObject> #include <functional> +#include <memory> QT_BEGIN_NAMESPACE @@ -147,10 +148,9 @@ const QProtobufPropertyOrderingInfo &fieldInfo, QByteArray &buffer) { Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null"); - QHash<K, V> mapValue = value.value<QHash<K, V>>(); - for (auto it = mapValue.constBegin(); it != mapValue.constEnd(); it++) { - buffer.append(serializer->serializeMapPair(QVariant::fromValue<K>(it.key()), - QVariant::fromValue<V>(it.value()), fieldInfo)); + for (const auto &[k, v] : value.value<QHash<K, V>>().asKeyValueRange()) { + buffer.append(serializer->serializeMapPair(QVariant::fromValue<K>(k), + QVariant::fromValue<V>(v), fieldInfo)); } } @@ -165,13 +165,9 @@ const QProtobufPropertyOrderingInfo &fieldInfo, QByteArray &buffer) { Q_ASSERT_X(serializer != nullptr, "QProtobufSerializer", "Serializer is null"); - QHash<K, std::shared_ptr<V>> mapValue = value.value<QHash<K, std::shared_ptr<V>>>(); - for (auto it = mapValue.constBegin(); it != mapValue.constEnd(); it++) { - if (it.value() == nullptr) - continue; - buffer.append(serializer->serializeMapPair(QVariant::fromValue<K>(it.key()), - QVariant::fromValue<V *>(it.value().get()), - fieldInfo)); + for (const auto &[k, v] : value.value<QHash<K, std::shared_ptr<V>>>().asKeyValueRange()) { + buffer.append(serializer->serializeMapPair(QVariant::fromValue<K>(k), + QVariant::fromValue<V *>(v.get()), fieldInfo)); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufserializer_p.h new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufserializer_p.h --- old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qprotobufserializer_p.h 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qprotobufserializer_p.h 2023-07-07 14:29:20.000000000 +0200 @@ -116,11 +116,22 @@ struct IsI32OrI64 : std::integral_constant<bool, IsI64<V>::value || IsI32<V>::value> {}; + // Tests if V is the length-delimited non-message, non-list type. + // QString | QByteArray + template<typename V> + struct IsLengthDelimited + : std::integral_constant< + bool, std::is_same<V, QString>::value || std::is_same<V, QByteArray>::value> + { + }; + public: // Serializer is interface function for serialize method - using Serializer = QByteArray (*)(const QVariant &, int &); + using Serializer = QByteArray (*)(const QVariant &, const QByteArray &); // Deserializer is interface function for deserialize method using Deserializer = bool (*)(QProtobufSelfcheckIterator &, QVariant &); + // Function checks if value in QVariant is considered to be non-ignorable. + using IsPresentChecker = bool (*)(const QVariant &); // SerializationHandlers contains set of objects that required for class // serializaion/deserialization @@ -129,9 +140,22 @@ QMetaType metaType; Serializer serializer; // serializer assigned to class Deserializer deserializer; // deserializer assigned to class + IsPresentChecker isPresent; // checks if contains non-ignorable value QtProtobuf::WireTypes wireType; // Serialization WireType }; + template<typename V, std::enable_if_t<IsI32OrI64<V>::value || IsInt<V>::value, int> = 0> + static bool isPresent(const QVariant &value) + { + return value.value<V>() != 0; + } + + template<typename V, std::enable_if_t<!IsI32OrI64<V>::value && !IsInt<V>::value, int> = 0> + static bool isPresent(const QVariant &value) + { + return !value.value<V>().isEmpty(); + } + explicit QProtobufSerializerPrivate(QProtobufSerializer *q); ~QProtobufSerializerPrivate() = default; // ########################################################################### @@ -141,8 +165,11 @@ template<typename V, typename std::enable_if_t<IsUnsignedInt<V>::value, int> = 0> static QByteArray serializeVarintCommon(const V &value) { + if (value == 0) + return QByteArray(1, char(0)); + qProtoDebug() << "value" << value; - V varint = value; + quint64 varint = value; QByteArray result; while (varint != 0) { @@ -152,10 +179,8 @@ varint >>= 7; } - if (result.isEmpty()) - result.append('\0'); - result.data()[result.size() - 1] &= ~0b10000000; + return result; } @@ -167,42 +192,13 @@ memory value: Value to serialize - outFieldIndex: Index of the value in parent structure (ignored) returns a byte array with 'value' encoded */ - template<typename V, typename std::enable_if_t<std::is_floating_point<V>::value, int> = 0> - static QByteArray serializeBasic(const V &value, int &outFieldIndex) - { - qProtoDebug() << "value" << value; - - if (value == 0 && outFieldIndex != QtProtobufPrivate::NotUsedFieldIndex) { - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return {}; - } - - // Reserve required number of bytes - QByteArray result(sizeof(V), Qt::Uninitialized); - qToUnaligned(qToLittleEndian(value), result.data()); - return result; - } - - /* - Serialization of fixed length integral types - - value: Value to serialize - outFieldIndex: Index of the value in parent structure (ignored) - Returns a byte array with 'value' encoded - */ - template<typename V, typename std::enable_if_t<IsFixedInt<V>::value, int> = 0> - static QByteArray serializeBasic(const V &value, int &outFieldIndex) + template<typename V, typename std::enable_if_t<IsI32OrI64<V>::value, int> = 0> + static QByteArray serializeBasic(const V &value) { qProtoDebug() << "value" << value; - if (value == 0 && outFieldIndex != QtProtobufPrivate::NotUsedFieldIndex) { - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return {}; - } - // Reserve required number of bytes QByteArray result(sizeof(V), Qt::Uninitialized); qToUnaligned(qToLittleEndian(value), result.data()); @@ -216,11 +212,10 @@ [0]: https://protobuf.dev/programming-guides/encoding value: Value to serialize - outFieldIndex: Index of the value in parent structure Returns a byte array with 'value' encoded */ template<typename V, typename std::enable_if_t<IsZigZagInt<V>::value, int> = 0> - static QByteArray serializeBasic(const V &value, int &outFieldIndex) + static QByteArray serializeBasic(const V &value) { qProtoDebug() << "value" << value; using UV = std::make_unsigned_t<V>; @@ -229,16 +224,16 @@ // Use ZigZag convertion first and apply unsigned variant next V zigZagValue = (value << 1) ^ (value >> (sizeof(UV) * 8 - 1)); uValue = static_cast<UV>(zigZagValue); - return serializeBasic(uValue, outFieldIndex); + return serializeBasic(uValue); } template<typename V, typename std::enable_if_t<IsSignedInt<V>::value, int> = 0> - static QByteArray serializeBasic(const V &value, int &outFieldIndex) + static QByteArray serializeBasic(const V &value) { qProtoDebug() << "value" << value; // Non-ZigZag signed integers should always be (de)serialized as the // QtProtobuf::uint64 - return serializeBasic(static_cast<QtProtobuf::uint64>(value), outFieldIndex); + return serializeBasic(static_cast<QtProtobuf::uint64>(value)); } /*! @@ -251,110 +246,57 @@ [0]: https://protobuf.dev/programming-guides/encoding value: Value to serialize - outFieldIndex: Index of the value in parent structure Returns a byte array with 'value' encoded */ template<typename V, typename std::enable_if_t<IsUnsignedInt<V>::value, int> = 0> - static QByteArray serializeBasic(const V &value, int &outFieldIndex) + static QByteArray serializeBasic(const V &value) { qProtoDebug() << "value" << value; - quint64 varint = quint64(value); - QByteArray result; - - while (varint != 0) { - // Put 7 bits to result buffer and mark as "not last" (0b10000000) - result.append((varint & 0b01111111) | 0b10000000); - // Divide values to chunks of 7 bits and move to next chunk - varint >>= 7; - } - - // Invalidate field index in case if serialized result is empty - // NOTE: the field will not be sent if its index is equal to NotUsedFieldIndex - if (result.size() == 0) { - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - } else { - // Mark last chunk as last by clearing last bit - result.data()[result.size() - 1] &= ~0b10000000; - } - return result; + return serializeVarintCommon(value); } //------------------QString and QByteArray types serializers----------------- - template<typename V, typename std::enable_if_t<std::is_same<V, QString>::value, int> = 0> - static QByteArray serializeBasic(const V &value, int & /*outFieldIndex*/) - { - return serializeLengthDelimited(value.toUtf8()); - } - - template<typename V, typename std::enable_if_t<std::is_same<V, QByteArray>::value, int> = 0> - static QByteArray serializeBasic(const V &value, int & /*outFieldIndex*/) + template<typename V, typename std::enable_if_t<IsLengthDelimited<V>::value, int> = 0> + static QByteArray serializeBasic(const V &value) { - return serializeLengthDelimited(value); + qProtoDebug("data.size: %" PRIdQSIZETYPE, value.size()); + // Varint serialize field size and apply result as starting point + if constexpr (std::is_same<V, QString>::value) + return prependLengthDelimitedSize(value.toUtf8()); + else + return prependLengthDelimitedSize(value); } //--------------------------List types serializers--------------------------- - template<typename V, typename std::enable_if_t<!std::is_same<V, QString>::value, int> = 0> - static QByteArray serializeListType(const QList<V> &listValue, int &outFieldIndex) + template<typename V, typename std::enable_if_t<!IsLengthDelimited<V>::value, int> = 0> + static QByteArray serializeListType(const QList<V> &listValue) { - qProtoDebug("listValue.count %" PRIdQSIZETYPE " outFieldIndex %d", listValue.count(), - outFieldIndex); + qProtoDebug("listValue.count %" PRIdQSIZETYPE, listValue.count()); - if (listValue.count() <= 0) { - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return QByteArray(); + if (listValue.isEmpty()) { + return {}; } - int empty = QtProtobufPrivate::NotUsedFieldIndex; QByteArray serializedList; for (auto &value : listValue) { - QByteArray element = serializeBasic<V>(value, empty); - if (element.isEmpty()) - element.append('\0'); - serializedList.append(element); + serializedList.append(serializeBasic<V>(value)); } // If internal field type is not LengthDelimited, exact amount of fields to be specified serializedList = prependLengthDelimitedSize(serializedList); return serializedList; } - template<typename V, typename std::enable_if_t<std::is_same<V, QString>::value, int> = 0> - static QByteArray serializeListType(const QStringList &listValue, int &outFieldIndex) + template<typename V, + typename std::enable_if_t< + IsInt<V>::value || IsI32OrI64<V>::value || IsLengthDelimited<V>::value, int> = + 0> + static QByteArray serializeNonPackedList(const QList<V> &listValue, const QByteArray &header) { - qProtoDebug("listValue.count %" PRIdQSIZETYPE " outFieldIndex %d", listValue.count(), - outFieldIndex); - - if (listValue.count() <= 0) { - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return QByteArray(); - } - - QByteArray serializedList; - for (const QString &value : listValue) { - serializedList.append(QProtobufSerializerPrivate::encodeHeader( - outFieldIndex, QtProtobuf::WireTypes::LengthDelimited)); - serializedList.append(serializeLengthDelimited(value.toUtf8(), false)); - } - - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return serializedList; - } - - template<typename V, QtProtobuf::WireTypes W, - typename std::enable_if_t<IsInt<V>::value || IsI32OrI64<V>::value, int> = 0> - static QByteArray serializeNonPackedListTypeCommon(const QList<V> &listValue, - int &outFieldIndex) - { - qProtoDebug("listValue.count %" PRIdQSIZETYPE " outFieldIndex %d", listValue.count(), - outFieldIndex); - QByteArray header = QProtobufSerializerPrivate::encodeHeader(outFieldIndex, W); - outFieldIndex = QtProtobufPrivate::NotUsedFieldIndex; + qProtoDebug("listValue.count %" PRIdQSIZETYPE, listValue.count()); QByteArray serializedList; for (auto &value : listValue) { serializedList.append(header); - QByteArray element = serializeBasic<V>(value, outFieldIndex); - if (element.isEmpty()) - element.append('\0'); - serializedList.append(element); + serializedList.append(serializeBasic<V>(value)); } return serializedList; } @@ -443,20 +385,7 @@ } //-----------------QString and QByteArray types deserializers---------------- - template<typename V, typename std::enable_if_t<std::is_same<QByteArray, V>::value, int> = 0> - Q_REQUIRED_RESULT static bool deserializeBasic(QProtobufSelfcheckIterator &it, - QVariant &variantValue) - { - std::optional<QByteArray> result = deserializeLengthDelimited(it); - if (!result) { - variantValue = QVariant(); - return false; - } - variantValue = QVariant::fromValue(*result); - return true; - } - - template<typename V, typename std::enable_if_t<std::is_same<QString, V>::value, int> = 0> + template<typename V, typename std::enable_if_t<IsLengthDelimited<V>::value, int> = 0> Q_REQUIRED_RESULT static bool deserializeBasic(QProtobufSelfcheckIterator &it, QVariant &variantValue) { @@ -465,7 +394,10 @@ variantValue = QVariant(); return false; } - variantValue = QVariant::fromValue(QString::fromUtf8(*result)); + if constexpr (std::is_same<QString, V>::value) + variantValue = QVariant::fromValue(QString::fromUtf8(*result)); + else + variantValue = QVariant::fromValue(*result); return true; } @@ -532,18 +464,6 @@ return { result }; } - static QByteArray serializeLengthDelimited(const QByteArray &data, bool optional = true) - { - qProtoDebug("data.size: %" PRIdQSIZETYPE " data: %s", data.size(), data.toHex().data()); - if (optional && data.isEmpty()) - return {}; - - QByteArray result(data); - // Varint serialize field size and apply result as starting point - result = prependLengthDelimitedSize(result); - return result; - } - Q_REQUIRED_RESULT static bool decodeHeader(QProtobufSelfcheckIterator &it, int &fieldIndex, QtProtobuf::WireTypes &wireType); @@ -560,14 +480,17 @@ return serializeVarintCommon<uint32_t>(data.size()) + data; } - template<typename T, QByteArray (*s)(const T &, int &)> - static QByteArray serializeWrapper(const QVariant &variantValue, int &fieldIndex) + template<typename T, QByteArray (*s)(const T &)> + static QByteArray serializeWrapper(const QVariant &variantValue, const QByteArray &header) { - if (variantValue.isNull()) { - fieldIndex = QtProtobufPrivate::NotUsedFieldIndex; - return QByteArray(); - } - return s(variantValue.value<T>(), fieldIndex); + return header + s(variantValue.value<T>()); + } + + template<typename T, QByteArray (*s)(const T &, const QByteArray &)> + static QByteArray serializeNonPackedWrapper(const QVariant &variantValue, + const QByteArray &header) + { + return s(variantValue.value<T>(), header); } // this set of 3 methods is used to skip bytes corresponding to an unexpected property diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qtprotobuflogging_p.h new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qtprotobuflogging_p.h --- old/qtgrpc-everywhere-src-6.5.1/src/protobuf/qtprotobuflogging_p.h 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/protobuf/qtprotobuflogging_p.h 2023-07-07 14:29:20.000000000 +0200 @@ -17,6 +17,7 @@ // #include <QtCore/qloggingcategory.h> +#include <QtCore/private/qglobal_p.h> QT_BEGIN_NAMESPACE Q_DECLARE_LOGGING_CATEGORY(Protobuf) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/tools/qtgrpcgen/Qt6GrpcToolsMacros.cmake new/qtgrpc-everywhere-src-6.5.2/src/tools/qtgrpcgen/Qt6GrpcToolsMacros.cmake --- old/qtgrpc-everywhere-src-6.5.1/src/tools/qtgrpcgen/Qt6GrpcToolsMacros.cmake 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/tools/qtgrpcgen/Qt6GrpcToolsMacros.cmake 2023-07-07 14:29:20.000000000 +0200 @@ -169,6 +169,7 @@ PROTO_FILES ${proto_files} PROTO_INCLUDES ${proto_includes} GENERATED_FILES ${generated_files} + OPTIONS ${generation_options} ) target_sources(${target} PRIVATE ${generated_files}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/src/tools/qtprotobufgen/Qt6ProtobufToolsMacros.cmake new/qtgrpc-everywhere-src-6.5.2/src/tools/qtprotobufgen/Qt6ProtobufToolsMacros.cmake --- old/qtgrpc-everywhere-src-6.5.1/src/tools/qtprotobufgen/Qt6ProtobufToolsMacros.cmake 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/src/tools/qtprotobufgen/Qt6ProtobufToolsMacros.cmake 2023-07-07 14:29:20.000000000 +0200 @@ -57,8 +57,9 @@ # PROTO_INCLUDES - list of the protobuf include paths. # GENERATED_FILES - list of files that are expected # to be genreated by the custom generator plugin. +# OPTIONS - list of the generator-specific options. function(_qt_internal_protoc_generate target generator output_directory) - cmake_parse_arguments(arg "" "" "PROTO_FILES;PROTO_INCLUDES;GENERATED_FILES" ${ARGN}) + cmake_parse_arguments(arg "" "" "PROTO_FILES;PROTO_INCLUDES;GENERATED_FILES;OPTIONS" ${ARGN}) if(NOT arg_PROTO_FILES) message(FATAL_ERROR "PROTO_FILES list is empty.") @@ -70,11 +71,12 @@ endif() if(NOT arg_GENERATED_FILES) - set(generated_files "${arg_GENERATED_FILES}") message(FATAL_ERROR "List of generated sources for target '${target}' is empty") endif() + set(generated_files "${arg_GENERATED_FILES}") + get_filename_component(output_directory "${output_directory}" REALPATH) get_target_property(is_generator_imported ${QT_CMAKE_EXPORT_NAMESPACE}::${generator} IMPORTED) if(QT_INTERNAL_AVOID_USING_PROTOBUF_TMP_OUTPUT_DIR OR is_generator_imported) @@ -108,7 +110,11 @@ ) endif() list(JOIN arg_PROTO_FILES "\\$<SEMICOLON>" proto_files_string) - list(JOIN generation_options "\\\\$<SEMICOLON>" generation_options_string) + if(arg_OPTIONS) + list(JOIN arg_OPTIONS "\\\\$<SEMICOLON>" generation_options_string) + else() + set(generation_options_string "") + endif() string(JOIN "\\$<SEMICOLON>" protoc_arguments "--plugin=protoc-gen-${generator}=${generator_file}" "--${generator}_out=${tmp_output_directory}" @@ -316,6 +322,7 @@ PROTO_FILES ${proto_files} PROTO_INCLUDES ${proto_includes} GENERATED_FILES ${generated_files} + OPTIONS ${generation_options} ) # Filter generated headers diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/CMakeLists.txt new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/CMakeLists.txt --- old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/CMakeLists.txt 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/CMakeLists.txt 2023-07-07 14:29:20.000000000 +0200 @@ -13,5 +13,6 @@ add_subdirectory(nested) add_subdirectory(converters) add_subdirectory(duplicated_metatypes) + add_subdirectory(recursive) endif() add_subdirectory(qprotobuflazymessagepointer) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/basic/tst_protobuf_raw_serializers.cpp new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/basic/tst_protobuf_raw_serializers.cpp --- old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/basic/tst_protobuf_raw_serializers.cpp 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/basic/tst_protobuf_raw_serializers.cpp 2023-07-07 14:29:20.000000000 +0200 @@ -2,7 +2,6 @@ // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 #include "basicmessages.qpb.h" -#include "fieldindexrange.qpb.h" #include <QtTest/QtTest> #include <QProtobufSerializer> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/basic/tst_protobuf_serialization_basictypes.cpp new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/basic/tst_protobuf_serialization_basictypes.cpp --- old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/basic/tst_protobuf_serialization_basictypes.cpp 2023-05-16 11:46:03.000000000 +0200 +++ new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/basic/tst_protobuf_serialization_basictypes.cpp 2023-07-07 14:29:20.000000000 +0200 @@ -468,7 +468,6 @@ SimpleBytesMessage msg; QByteArray result = msg.serialize(m_serializer.get()); - QEXPECT_FAIL("", "The result of serialization can be either an empty message or a message of size zero.", Continue); QVERIFY(result.isEmpty()); } @@ -477,7 +476,6 @@ SimpleStringMessage msg; QByteArray result = msg.serialize(m_serializer.get()); - QEXPECT_FAIL("", "The result of serialization can be either an empty message or a message of size zero.", Continue); QVERIFY(result.isEmpty()); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/recursive/CMakeLists.txt new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/recursive/CMakeLists.txt --- old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/recursive/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/recursive/CMakeLists.txt 2023-07-07 14:29:20.000000000 +0200 @@ -0,0 +1,20 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt6_add_protobuf(tst_protobuf_recursive_gen + PROTO_FILES + recursive.proto + OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_protobuf_generated" +) +qt_autogen_tools_initial_setup(tst_protobuf_recursive_gen) + +qt_internal_add_test(tst_protobuf_recursive + SOURCES + tst_protobuf_recursive.cpp + INCLUDE_DIRECTORIES + ../shared + LIBRARIES + Qt::Test + Qt::Protobuf + tst_protobuf_recursive_gen +) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/recursive/recursive.proto new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/recursive/recursive.proto --- old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/recursive/recursive.proto 1970-01-01 01:00:00.000000000 +0100 +++ new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/recursive/recursive.proto 2023-07-07 14:29:20.000000000 +0200 @@ -0,0 +1,11 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +syntax = "proto3"; + +package qtprotobufnamespace.tests; + +message RecursiveMessage +{ + int32 testFieldInt = 1; + RecursiveMessage testFieldRecursive = 2; +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/recursive/tst_protobuf_recursive.cpp new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/recursive/tst_protobuf_recursive.cpp --- old/qtgrpc-everywhere-src-6.5.1/tests/auto/protobuf/recursive/tst_protobuf_recursive.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/qtgrpc-everywhere-src-6.5.2/tests/auto/protobuf/recursive/tst_protobuf_recursive.cpp 2023-07-07 14:29:20.000000000 +0200 @@ -0,0 +1,72 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// Copyright (C) 2022 Alexey Edelev <semla...@gmail.com>, Viktor Kopp <vifac...@gmail.com> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +#include "recursive.qpb.h" + +#include <QMetaProperty> +#include <QSignalSpy> +#include <QTest> +#include <QDebug> + +#include <qprotobufserializer.h> +#include <qtprotobuftestscommon.h> + +class QtProtobufRecursiveTest : public QObject +{ + Q_OBJECT +private slots: + void init() { m_serializer.reset(new QProtobufSerializer); } + void SerializationTest(); + void DeserializationTest(); + +private: + std::unique_ptr<QProtobufSerializer> m_serializer; +}; + +using namespace qtprotobufnamespace::tests; + +void initRecursive(RecursiveMessage &parent, int ×) +{ + if (times == 0) + return; + --times; + + RecursiveMessage child; + child.setTestFieldInt(times); + initRecursive(child, times); + parent.setTestFieldRecursive(child); +} + +void QtProtobufRecursiveTest::SerializationTest() +{ + int times = 10; + RecursiveMessage msg; + QCOMPARE(msg.serialize(m_serializer.get()).toHex(), ""); + initRecursive(msg, times); + QCOMPARE(msg.serialize(m_serializer.get()).toHex(), + "12240809" + "12200808" + "121c0807" + "12180806" + "12140805" + "12100804" + "120c0803" + "12080802" + "12040801" + "1200"); +} + +void QtProtobufRecursiveTest::DeserializationTest() +{ + RecursiveMessage msg; + msg.deserialize(m_serializer.get(), QByteArray::fromHex("083712080836120412020835")); + + QCOMPARE(msg.testFieldInt(), 55); + QCOMPARE(msg.testFieldRecursive().testFieldInt(), 54); + QCOMPARE(msg.testFieldRecursive().testFieldRecursive().testFieldInt(), 0); + QCOMPARE(msg.testFieldRecursive().testFieldRecursive().testFieldRecursive().testFieldInt(), 53); +} + +QTEST_MAIN(QtProtobufRecursiveTest) +#include "tst_protobuf_recursive.moc"