Commit Graph

1395 Commits

Author SHA1 Message Date
Alexey Edelev 6d28b38872 Error out if Protobuf|GrpcQuick components are not found
QML option of both qt_add_protobuf and qt_add_grpc calls requires
ProtobufQuick and GrpcQuick targets to be found, accordingly.
Currently calls will fail with non-intuitive error that points to
the missing linking dependencies. Trigger a FATAL_ERROR at configure
time and give a hint on how to solve this.

Fixes: QTBUG-131780
Pick-to: 6.8 6.9
Change-Id: I571aa35839a6b68b54f5a71f0ee1947445b5eb2c
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-10 14:55:59 +01:00
Topi Reinio 4ffa1fe6ff Third party code attributions: Change Id to lowercase
Each 3rd party license attribution is identified by a
unique Id key, which should be all lowercase and without
spaces. See QUIP-7 for more info about the qt_attribution.json
file format: https://contribute.qt-project.org/quips/7.

Pick-to: 6.9 6.8
Change-Id: Ic06e3d8c0bf88fe51b246b98f3c8f890cdcf8e55
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2025-01-08 14:10:28 +00:00
Dennis Oberst b8cb9396d2 QProtobufOneof: correctly forward universal references
To avoid potentially moving (const) lvalues. std::forward is the right
tool here.

Pick-to: 6.9 6.8
Change-Id: Ica59d168378d2556c91c80e5cbe7830f03e60061
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2025-01-07 17:07:25 +01:00
Thiago Macieira 226fff5db7 CMake: Add qt_autogen_tools_initial_setup calls
Add calls to qt_autogen_tools_initial_setup to avoid
'CMake Error: AUTOMOC for target' errors.

Pick-to: 6.9 6.8
Task-number: QTBUG-129918
Change-Id: I4ea262a93d778d0962fcfffd022536358eadf8a5
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2025-01-06 15:41:39 -03:00
Alexey Zerkin 4e8dddcb28 JSON serialization of google::protobuf::Timestamp well-known type
Added support for encoding google::protobuf::Timestamp in the [RFC 3339]
format in JSON. The Timestamp message has seconds and nanos fields
which were serialized as is previously. After the fix, the Timestamp is
serialized in a "field-name":"2024-11-14T06:20:11.530Z" format in JSON.

Pick-to: 6.8 6.9
Fixes: QTBUG-130555
Change-Id: I7372e541faccdb7dec9083e36b673013a9a4ce5e
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-01-06 15:18:59 +01:00
Alexey Edelev 9d680f05fd Clear the cached value when re-using the JSON deserializer
Ensure that we clear the deserializer state when re-use it after
unsuccessful deresializing.

Pick-to: 6.9 6.8
Change-Id: I6e0c489706b90e8daaa49c1872642a7cbefee2e3
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-01-06 15:18:59 +01:00
Alexey Edelev 9966fdac34 Generate the missing includes for the nested Qt types
When using the nested Qt types from either QtCore or QtGui packages
protobuf generator doesn't consider these types when generating the
includes.

Fixes: QTBUG-132182
Pick-to: 6.8 6.9
Change-Id: I6f0de0119ff9f8fd8109dd621a0d20f5dca31003
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-01-06 15:18:58 +01:00
Alexey Edelev 28f4b35830 Extend HEADER_GUARD documentation
Specify the possible values explicitly and extend the description.

Amends 4410e9c7a9

Task-number: QTBUG-125406
Pick-to: 6.9
Change-Id: Ic44b22f5959555119442672a96b0b237a6bd3813
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-06 15:18:58 +01:00
Alexey Edelev c42df9cad0 Add the map name clashing syntax test
Protoc disallows using the <field name>Entry if the respective
<field name> map field is defined. But meanwhile it allows using
<field name>_Entry as the field name, which ends up as
<field name>Entry in the generated code. The difference is in the
letter case is used for the alias we add for map entries and the
actual field name.

As the conclusion - test passes, but we should keep it in our test
suite to ensure we compliant with the protoc rules.

Pick-to: 6.8 6.9
Change-Id: I8a8d6796b6c5564b211bd11fdd23102b0031031e
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-01-06 15:18:58 +01:00
Alexey Edelev e34d99af32 Use case insensitive QByteArray::compare where applicable
Case insensitive 'QByteArray::compare' should be faster than
'QByteArray::toLower' + 'QByteArray::operator =='.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I718ff0bbbcc0f0ebaccd0998227bfbc4c6cd69fe
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-06 15:18:58 +01:00
Alexey Edelev 6e32b408a3 Move string literals out of template function definitions
Make all string literals used in scalar JSON serializers inline
constexpr.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: Icfec6fa02f2c2b867c780fad23625e158e36fdb0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-06 15:18:58 +01:00
Alexey Edelev 3ed41b5cd7 Small optimization bit in deserializeVarintCommon
Remove the end of varint flag from uchar value already, since we don't
use the top-most integer bits when applying the mask, so this can be
done at initialization already.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: Iba15265047d7d72d63ce47ab7b8980184d9b4a4f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2025-01-06 14:05:48 +01:00
Alexey Edelev e45334f4a0 Update the test certificate
The old one is expired.

Pick-to: 6.8 6.9
Change-Id: Ice0253383380ea522613a4eb781454dbf65e1464
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2025-01-06 12:34:58 +01:00
Qt Submodule Update Bot 6d529e975e Update dependencies on 'dev' in qt/qtgrpc
Change-Id: I17dec5252aec5311b850e1ae966257b9091f1a85
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-01-03 14:15:13 +00:00
Jani Heikkinen 3ecf4b41cf Bump version to 6.10.0
Change-Id: I5fd5edebedf64d9d9f133a941c7364ee2f8ad41f
Reviewed-by: Qt Submodule Update Bot <qt_submodule_update_bot@qt-project.org>
2025-01-03 14:15:12 +00:00
Dennis Oberst 826e752d20 QGrpcSerializationFormat: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I7b98f928b0b36dcfd72c8e9a0760aeb484eea7e4
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:25 +01:00
Dennis Oberst d0f7ba34bf QGrpcHttp2Channel: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: Ibad1355d15f54aa0e5eac949fbbe0efa7a2fed8f
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:22 +01:00
Dennis Oberst f56e2039bc QAbstractGrpcChannel: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I9cd36a674582f51e7319ec82ace238074df14352
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:19 +01:00
Dennis Oberst 1800de75c3 QGrpcStatus: polish documentation
To conform with the style used in other docs in Qt GRPC.

Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: Icfc62bf0c5f3a739262fafebb539a63344380f5c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:15 +01:00
Dennis Oberst 150100f3f9 QGrpcClientBase: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I14d5a88e67bca2461598331b5d3255d0bd902894
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:12 +01:00
Dennis Oberst db9ca6f955 qgrpcstream: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I3daedf68d7c0200de327adaabbbf22d1db9d7f0b
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:09 +01:00
Dennis Oberst cccade80c1 QGrpcCallReply: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I373c39f99ee7ed00ebd9a84c29876d9131790a52
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:05 +01:00
Dennis Oberst 95b5e52f3f QGrpcOperation: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: Iaa74617fa808dadb3c4427303c58d4bd8ce9b51c
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:13:02 +01:00
Dennis Oberst 93284dd9fb QGrpcChannelOptions: rework documentation
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I7662e374aa9e0514fa1238f8cc8909f3ede76317
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:12:58 +01:00
Dennis Oberst 58ea8af944 QGrpcCallOptions: rework documentation
This patch also adds qtgrpc-shared.qdoc - a place to shared common
documentation snippets.

Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I31e7cd3a254f91df19c0e7b5df4cdfac770c4388
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:12:53 +01:00
Dennis Oberst dedd3edd3f Add the clientguide example
It contains in depth documentation to get started with Qt GRPC
and replaces the 'Client Methods of the Qt GRPC Service' guide.

This will enable users to also run the code, experiment with it and
show us the error directly in case they fail to compile.

Task-number: QTBUG-125406
Fixes: QTBUG-129588
Pick-to: 6.9 6.8
Change-Id: I8f16156a13da1683bce0e31001ee6b2ff57b1824
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 15:12:50 +01:00
Dennis Oberst 298f6666fa Docs: improve qtgrpc index page
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I0873879e4014eb6aa455c6bc1bb107cc000eb56d
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
2024-12-17 11:08:04 +01:00
Dennis Oberst 6ab4321ccc Docs: create and distribute the \gRPC macro for adding trademarks
It will add the 'tm' logo to the first occurrence in the document. We
still add it to any mention of it since this will protect against
copy-paste issues when borrowing chunks of the documentation.

Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: I099633bcda78a1940c65c379328539190833d6f9
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 11:08:01 +01:00
Dennis Oberst 2123274862 Docs: simplify qt-add-grpc-example.cmake
This is one of the first introductions in how to use the cmake api. Try
to start teaching the most simplest way: reusing the application target.

Pick-to: 6.9 6.8
Change-Id: I94c070bde4dec5adf33f4f244cad0ed105c4d510
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 11:07:58 +01:00
Dennis Oberst ec8afcaca5 Docs: enforce zero warning policy
Task-number: QTBUG-125406
Pick-to: 6.9 6.8
Change-Id: Iefd0140f24ec9be66ff3655f8817ffa02ccd8dc3
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2024-12-17 11:07:55 +01:00
Alexey Edelev bb0eb679b7 Collect the .proto files in the related targets
Collect .proto files in the targets that use them in generating process.

Pick-to: 6.8 6.9
Change-Id: Iaeb6f520051fabe7b188e4f758671ca0bdaa3645
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-12-16 12:12:51 +01:00
Alexey Edelev f78028cea3 Protobuf: Add JSON deserializer benchmark
Add the benchmark of the JSON deserialzer. Re use the common
functionality in both JSON and protobuf deserializer benchmarks.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I34befe253d076793228f660b24a9983af0fbc780
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:35 +01:00
Alexey Edelev 0ef57fd3ad Deduplicate preserveUnknownFields variable
Remove the duplicated preserveUnknownFields variable in
QProtobufSerializerImpl, use the parent pointer to acquire its
value instead.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I8c81e5ea6565f056756703d5ca989b67d163dd19
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:31 +01:00
Alexey Edelev 4018090d1e Avoid looking for scalar type deserializer twice
When looking for non-packed deserializer we may make the lookup only
once, since we may predict the non-packed field from the wire type.
If it differs from the Length Delimited type and the field is Repeated
according to the stored meta info, we may conclude that the received
data is non-packed and use the corresponding deserializer.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I3ead7e8b64cda26179c7b5fc9917737b41e22882
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:28 +01:00
Alexey Edelev 0e63212ddc Avoid potential runtime stack allocation of variable in deserializeBasic
Make 'size' static constexpr. It can be calculated compile time and
stored the binary data.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I39abf998d2fdc825b6ffd0c0783ee9321dc338db
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:24 +01:00
Alexey Edelev 9bd150899f Simplify deserializeBasic for signed varints
Squash the redundant variable definitions.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I4c107896a6d57cf7df418b2bd0b19cb1ce4b965d
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:22 +01:00
Alexey Edelev 17c85b1a29 Replace std::optional::value with std::optional::operator *
'value' excepts, 'operator *' usage is preferable.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I4297e6566b147f527cc5233f5bc4ac285e36fdef
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:18 +01:00
Alexey Edelev dd77a03b0f Deduplicate the iterator increasing in deserializeVarintCommon
We may move the iterator forward right in condition. When checking
for the end of varint mask.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: Ib0893a80c29752176e9e300e05cd5ea007a58e0f
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:13 +01:00
Alexey Edelev d575f3e07b Reuse the serializedList variable in serializeListType
We may reuse the variable instead of instantiating the empty
QByteArray.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I4c0b92926af6904f5003f3511f6dcf0e89c1e42f
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:10 +01:00
Alexey Edelev dcaf650f2f Remove the useless variable initialization when serializing zigzag int
The uValue variable can be intialized by real value in place. It's zero
initialization is pointless.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I515f2f7e35c092b87c140ff95df8e4ee3a92d03a
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:07 +01:00
Alexey Edelev bbdb324316 Pass the argument of serializeVarintCommon by value
All types that the function accepts, are unsigned ints.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I3e9d07eaa6e5476a32ad889b6c8f51a3430e5a52
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:04 +01:00
Alexey Edelev e2ef159b2e Make serializeVarintCommon SCARY
Move the part that doesn't depend on template arugment to a
serializeVarintCommonImpl function. Also it makes sense to make it
out of line.

Use the impl function but not the template one when serializing
the size of length delimited fields. We trust out selves that this
type is compatible with serializeVarintCommon.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: Ifcda7ebf7b2dee209c258d64724908022cf66de9
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:01:00 +01:00
Alexey Edelev a938e362c8 Use the if_json_floating_point as isPresent trait
Compile time checks unification.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I869f13e4a8770c60d605649d8304898449ab1d69
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 12:00:56 +01:00
Alexey Edelev ff1431771f Tune the WrapProtoc lookup
Add the upper and lower case protobuf package names explicitly and keep
the protobuf package lower case for the variables consistency.

Pick-to: 6.9
Change-Id: Id8acf1d986e0274f99587d554e5dc5308f15a31d
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-12-16 12:00:46 +01:00
Alexey Edelev d288a077f5 Add the missing autotools setup for protobuf_invalid-identifier
Pick-to: 6.8 6.9
Change-Id: I51e9ed9a80d817184f2ef52c72974292b745b5c1
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 10:40:42 +01:00
Alexey Edelev fdbbe0b349 Make QProtobufJsonSerializerPrivate ctor out-of-line
Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: I8b1755108781510cc770e0e7b5ba6a6a4d0e3a15
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 09:57:59 +01:00
Alexey Edelev 6a1012792c Move the scalar protobuf type serializer to a seprate TU
Move the scalar type serializers to a separated translation units. This
make code more readable. Adjust constraints to follow common project
coding standards and make constrains compilation faster. Make complex
functions out-of-line to avoid unwanted binary expansion.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: Ib5311f392e32e5f31416448d2f306ae91155f873
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 09:57:54 +01:00
Alexey Edelev 3df9d285da Generalize deserializer in protobuf and JSON serializers
Move the generic logic of serializer to a separate class and
use this class to implement the protobuf and JSON deserialization.

This also fixed one of the conformance usecases since related
to invalid enum handling.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Fixes: QTBUG-112423
Fixes: QTBUG-112425
Fixes: QTBUG-112424
Change-Id: I400303a8666df90050a54bd7036daa0107adcce5
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 09:57:48 +01:00
Alexey Edelev 27b618fcc4 Generalize serialization in protobuf and JSON serializers
Move the generic logic of serializer to a separate class and
use this class to implement the protobuf and JSON serialization.

This also fixed one of the conformance usecases since related
to invalid enum handling.

Pick-to: 6.8 6.9
Task-number: QTBUG-128812
Change-Id: Ie78da9103e68e7701b36f7d4e4c8e83f38d3c5c2
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 09:57:44 +01:00
Alexey Edelev 76684a5ae7 Make deserialization benchmark more complicated
Use more complicated data structure when benchmarking the protobuf
deserialzer. This allows also to identify changes that have
performance impact onto the deserialization.

Pick-to: 6.8 6.9
Change-Id: Ibf3a312c18edb86d383d5e236f3dad47e8581532
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
2024-12-16 09:57:40 +01:00