mirror of https://github.com/qt/qtgrpc.git
Merge tag 'v6.5.5-lts' into tqtc/lts-6.5-opensource
Qt 6.5.5-lts release Conflicts solved: dependencies.yaml src/tools/qtgrpcgen/clientdeclarationprinter.cpp src/tools/qtgrpcgen/clientdeclarationprinter.h src/tools/qtgrpcgen/clientdefinitionprinter.cpp src/tools/qtgrpcgen/clientdefinitionprinter.h src/tools/qtgrpcgen/grpctemplates.cpp src/tools/qtgrpcgen/grpctemplates.h src/tools/qtgrpcgen/main.cpp src/tools/qtgrpcgen/qgrpcgenerator.cpp src/tools/qtgrpcgen/qgrpcgenerator.h src/tools/qtgrpcgen/serverdeclarationprinter.cpp src/tools/qtgrpcgen/serverdeclarationprinter.h src/tools/qtprotobufgen/enumdeclarationprinter.cpp src/tools/qtprotobufgen/enumdeclarationprinter.h src/tools/qtprotobufgen/enumdefinitionprinter.cpp src/tools/qtprotobufgen/enumdefinitionprinter.h src/tools/qtprotobufgen/main.cpp src/tools/qtprotobufgen/messagedeclarationprinter.cpp src/tools/qtprotobufgen/messagedeclarationprinter.h src/tools/qtprotobufgen/messagedefinitionprinter.cpp src/tools/qtprotobufgen/messagedefinitionprinter.h src/tools/qtprotobufgen/qprotobufgenerator.cpp src/tools/qtprotobufgen/qprotobufgenerator.h src/tools/qtprotoccommon/baseprinter.cpp src/tools/qtprotoccommon/baseprinter.h src/tools/qtprotoccommon/commontemplates.cpp src/tools/qtprotoccommon/commontemplates.h src/tools/qtprotoccommon/descriptorprinterbase.h src/tools/qtprotoccommon/generatorbase.cpp src/tools/qtprotoccommon/generatorbase.h src/tools/qtprotoccommon/generatorcommon.cpp src/tools/qtprotoccommon/generatorcommon.h src/tools/qtprotoccommon/options.cpp src/tools/qtprotoccommon/options.h src/tools/qtprotoccommon/qtprotocdefs.h src/tools/qtprotoccommon/utils.cpp src/tools/qtprotoccommon/utils.h Change-Id: I6208df90618a5375ef80a19f5201a6e8a987007e
This commit is contained in:
commit
ae2b13aa17
|
@ -1,4 +1,4 @@
|
|||
set(QT_REPO_MODULE_VERSION "6.5.4")
|
||||
set(QT_REPO_MODULE_VERSION "6.5.5")
|
||||
set(QT_REPO_MODULE_PRERELEASE_VERSION_SEGMENT "alpha1")
|
||||
|
||||
set(QT_EXTRA_INTERNAL_TARGET_DEFINES "QT_LEAN_HEADERS=1")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
dependencies:
|
||||
../tqtc-qtbase:
|
||||
ref: 8ff0b254e4c3db81254782262d827f7831d15f6b
|
||||
ref: fdf57f5df57e7d12cf871699d857a71acf272e0c
|
||||
required: true
|
||||
../tqtc-qtdeclarative:
|
||||
ref: 9edb471d3a35b3dc40def86c395789086edaa983
|
||||
ref: 7ac842cba18be081ac835bf40ac475ec4c47d30b
|
||||
required: false
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "clientservice.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QGrpcHttp2Channel>
|
||||
#include <QGrpcInsecureChannelCredentials>
|
||||
|
||||
|
|
|
@ -85,6 +85,18 @@ static QString threadSafetyWarning(QLatin1StringView methodName)
|
|||
message received from server-stream.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QAbstractGrpcClient::errorOccurred(const QGrpcStatus &status);
|
||||
|
||||
Indicates that an error occurred during serialization.
|
||||
|
||||
This signal is emitted when an error with \a status occurs in the channel
|
||||
or during serialization.
|
||||
|
||||
\sa QGrpcOperation::errorOccurred
|
||||
*/
|
||||
|
||||
|
||||
class QAbstractGrpcClientPrivate : public QObjectPrivate
|
||||
{
|
||||
Q_DECLARE_PUBLIC(QAbstractGrpcClient)
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <grpcpp/channel.h>
|
||||
#include <grpcpp/create_channel.h>
|
||||
#include <grpcpp/completion_queue.h>
|
||||
#include <grpcpp/impl/codegen/byte_buffer.h>
|
||||
#include <grpcpp/impl/codegen/client_unary_call.h>
|
||||
#include <grpcpp/impl/codegen/rpc_method.h>
|
||||
|
|
|
@ -19,7 +19,7 @@ QT_BEGIN_NAMESPACE
|
|||
*/
|
||||
|
||||
/*!
|
||||
\fn template <typename T> T QGrpcOperation::read() const;
|
||||
\fn template <typename T> T QGrpcOperation::read() const
|
||||
|
||||
Reads message from raw byte array stored in QGrpcCallReply.
|
||||
|
||||
|
@ -43,6 +43,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
This signal is emitted when error with \a status occurs in channel
|
||||
or during serialization.
|
||||
|
||||
\sa QAbstractGrpcClient::errorOccurred
|
||||
*/
|
||||
|
||||
class QGrpcOperationPrivate : public QObjectPrivate
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
\li No need to integrate generated code into project tree manually.
|
||||
\li Convenient serialization and deserialization API.
|
||||
\li Integrated properties mechanism for generated protobuf messages.
|
||||
\li Integrated gRPC-client support (see \l {Qt GRPC}{QtGrpc module}).
|
||||
\li Integrated gRPC-client support (see \l {Qt GRPC}{Qt GRPC module}).
|
||||
\endlist
|
||||
|
||||
\section2 Incoming features
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#include <QtProtobuf/qabstractprotobufserializer.h>
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QABSTRACTPROTOBUFSERIALIZER_H
|
||||
#define QABSTRACTPROTOBUFSERIALIZER_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2020 Alexey Edelev <semlanik@gmail.com>
|
||||
// Copyright (C) 2022 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
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QPROTOBUFLAZYMESSAGEPOINTER_H
|
||||
#define QPROTOBUFLAZYMESSAGEPOINTER_H
|
||||
|
@ -9,8 +9,6 @@
|
|||
|
||||
#include <QtProtobuf/qprotobufmessage.h>
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
namespace QtProtobufPrivate {
|
||||
class QProtobufLazyMessagePointerBase
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (C) 2022 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
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#include "qprotobufmessage_p.h"
|
||||
#include "qprotobufmessage.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (C) 2022 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
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef Q_PROTOBUF_MESSAGE_H
|
||||
#define Q_PROTOBUF_MESSAGE_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (C) 2022 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
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef Q_PROTOBUF_MESSAGE_P_H
|
||||
#define Q_PROTOBUF_MESSAGE_P_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QPROTOBUFOBJECT_H
|
||||
#define QPROTOBUFOBJECT_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QPROTOBUFSELFCHECKITERATOR_H
|
||||
#define QPROTOBUFSELFCHECKITERATOR_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>, Viktor Kopp <vifactor@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#include "qprotobufserializer.h"
|
||||
#include "qprotobufserializer_p.h"
|
||||
|
@ -70,7 +70,6 @@ QtProtobufPrivate::SerializationHandler QtProtobufPrivate::findHandler(QMetaType
|
|||
\since 6.5
|
||||
\brief The QProtobufSerializer class is interface that represents
|
||||
basic functions for serialization/deserialization.
|
||||
\reentrant
|
||||
|
||||
The QProtobufSerializer class registers serializers/deserializers for
|
||||
classes implementing a protobuf message, inheriting QProtobufMessage. These
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QPROTOBUFSERIALIZER_H
|
||||
#define QPROTOBUFSERIALIZER_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>, Viktor Kopp <vifactor@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QPROTOBUFSERIALIZER_P_H
|
||||
#define QPROTOBUFSERIALIZER_P_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (C) 2022 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
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QTPROTOBUFGLOBAL_H
|
||||
#define QTPROTOBUFGLOBAL_H
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#include "qtprotobuflogging_p.h"
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QTPROTOBUFLOGGING_P_H
|
||||
#define QTPROTOBUFLOGGING_P_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#include <QtProtobuf/qtprotobufglobal.h>
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
|||
#include <QtProtobuf/private/qtprotobuflogging_p.h>
|
||||
|
||||
#include "qtprotobuftypes.h"
|
||||
#include "qprotobufobject.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <limits>
|
||||
|
@ -318,8 +317,8 @@ QT_IMPL_METATYPE_EXTERN_TAGGED(QtProtobuf::sfixed64, QtProtobuf_sfixed64)
|
|||
\value Varint int32, int64, uint32, uint64, sint32, sint64, bool, enum
|
||||
\value Fixed64 fixed64, sfixed64, double
|
||||
\value LengthDelimited string, bytes, embedded messages, packed repeated fields
|
||||
\value StartGroup groups. Deprecated in proto syntax 3. Not supported by QtProtobuf.
|
||||
\value EndGroup groups. Deprecated in proto syntax 3. Not supported by QtProtobuf.
|
||||
\value StartGroup groups. Deprecated in proto syntax 3. Not supported by Qt Protobuf.
|
||||
\value EndGroup groups. Deprecated in proto syntax 3. Not supported by Qt Protobuf.
|
||||
\value Fixed32 fixed32, sfixed32, float
|
||||
|
||||
\sa {https://protobuf.dev/programming-guides/encoding} {encoding}
|
||||
|
@ -349,7 +348,7 @@ QT_IMPL_METATYPE_EXTERN_TAGGED(QtProtobuf::sfixed64, QtProtobuf_sfixed64)
|
|||
|
||||
/*!
|
||||
\namespace QtProtobuf
|
||||
\brief The QtProtobuf namespace contains type aliases and classes needed to support QtProtobuf.
|
||||
\brief The QtProtobuf namespace contains type aliases and classes needed to support Qt Protobuf.
|
||||
\inmodule QtProtobuf
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (C) 2022 The Qt Company Ltd.
|
||||
// Copyright (C) 2019 Alexey Edelev <semlanik@gmail.com>
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial
|
||||
|
||||
#ifndef QTPROTOBUFTYPES_H
|
||||
#define QTPROTOBUFTYPES_H
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
\inmodule QtProtobuf
|
||||
\ingroup explanation
|
||||
|
||||
The \c qtprotobufgen tool can be used to generate QtProtobuf classes from a
|
||||
The \c qtprotobufgen tool can be used to generate Qt Protobuf classes from a
|
||||
protobuf schema. The tool is provided by the CMake \c {Qt6::ProtobufTools}
|
||||
package. It works as an extension to Google's \c protoc tool.
|
||||
|
||||
|
|
|
@ -174,12 +174,10 @@ function(qt6_add_grpc target type)
|
|||
set(generated_headers "${generated_files}")
|
||||
list(FILTER generated_headers INCLUDE REGEX ".+\\.h$")
|
||||
|
||||
if(is_static OR is_shared)
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
AUTOMOC ON
|
||||
)
|
||||
endif()
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
AUTOMOC ON
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_compile_options(${target}
|
||||
|
|
|
@ -79,7 +79,8 @@ function(_qt_internal_protoc_generate target generator output_directory)
|
|||
|
||||
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)
|
||||
if(QT_INTERNAL_AVOID_USING_PROTOBUF_TMP_OUTPUT_DIR OR is_generator_imported
|
||||
OR NOT CMAKE_GENERATOR MATCHES "^Ninja")
|
||||
set(tmp_output_directory "${output_directory}")
|
||||
else()
|
||||
set(tmp_output_directory "${output_directory}/.tmp")
|
||||
|
@ -131,7 +132,8 @@ function(_qt_internal_protoc_generate target generator output_directory)
|
|||
"${proto_includes_string}"
|
||||
)
|
||||
|
||||
unset(extra_copy_commands)
|
||||
set(extra_copy_commands "")
|
||||
set(temporary_files "")
|
||||
if(NOT tmp_output_directory STREQUAL output_directory)
|
||||
foreach(f IN LISTS generated_files)
|
||||
get_filename_component(filename "${f}" NAME)
|
||||
|
@ -143,11 +145,17 @@ function(_qt_internal_protoc_generate target generator output_directory)
|
|||
calling _qt_internal_protoc_generate"
|
||||
)
|
||||
endif()
|
||||
list(APPEND temporary_files "${tmp_output_directory}/${f_rel}")
|
||||
list(APPEND extra_copy_commands COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different "${tmp_output_directory}/${f_rel}" "${f}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
set(byproducts "")
|
||||
if(temporary_files)
|
||||
set(byproducts BYPRODUCTS ${temporary_files})
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${generated_files}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DPROTOC_EXECUTABLE=$<TARGET_FILE:WrapProtoc::WrapProtoc>
|
||||
|
@ -157,6 +165,7 @@ function(_qt_internal_protoc_generate target generator output_directory)
|
|||
-P
|
||||
${__qt_protobuf_macros_module_base_dir}/QtProtocCommandWrapper.cmake
|
||||
${extra_copy_commands}
|
||||
${byproducts}
|
||||
WORKING_DIRECTORY ${output_directory}
|
||||
DEPENDS
|
||||
${QT_CMAKE_EXPORT_NAMESPACE}::${generator}
|
||||
|
@ -346,16 +355,19 @@ function(qt6_add_protobuf target)
|
|||
|
||||
target_sources(${target} PRIVATE ${generated_headers} ${generated_sources})
|
||||
|
||||
if(is_static OR is_shared)
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
AUTOMOC ON
|
||||
)
|
||||
endif()
|
||||
set_target_properties(${target}
|
||||
PROPERTIES
|
||||
AUTOMOC ON
|
||||
)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_compile_options(${target}
|
||||
PRIVATE "/Zc:__cplusplus" "/permissive-" "/bigobj")
|
||||
if(WIN32)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||
target_compile_options(${target}
|
||||
PRIVATE "/Zc:__cplusplus" "/permissive-" "/bigobj")
|
||||
elseif(MINGW)
|
||||
target_compile_options(${target}
|
||||
PRIVATE "-Wa,-mbig-obj")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(${target} PRIVATE
|
||||
|
|
|
@ -36,7 +36,7 @@ void EnumDeclarationPrinter::printEnum()
|
|||
int numValues = m_descriptor->value_count();
|
||||
for (int j = 0; j < numValues; ++j) {
|
||||
const EnumValueDescriptor *valueDescr = m_descriptor->value(j);
|
||||
m_printer->Print({ { "enumvalue", utils::capitalizeAsciiName(valueDescr->name()) },
|
||||
m_printer->Print({ { "enumvalue", common::qualifiedCppName(valueDescr->name()) },
|
||||
{ "value", std::to_string(valueDescr->number()) } },
|
||||
CommonTemplates::EnumFieldTemplate());
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ void MessageDeclarationPrinter::printQEnums()
|
|||
Indent();
|
||||
for (int j = 0; j < enumDescr->value_count(); ++j) {
|
||||
const auto *valueDescr = enumDescr->value(j);
|
||||
m_printer->Print({ { "enumvalue", utils::capitalizeAsciiName(valueDescr->name()) },
|
||||
m_printer->Print({ { "enumvalue", common::qualifiedCppName(valueDescr->name()) },
|
||||
{ "value", std::to_string(valueDescr->number()) } },
|
||||
CommonTemplates::EnumFieldTemplate());
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ void MessageDefinitionPrinter::printInitializationList()
|
|||
break;
|
||||
case FieldDescriptor::TYPE_ENUM:
|
||||
propertyMap["initializer"] = propertyMap["scope_type"]
|
||||
+ "::" + field->enum_type()->value(0)->name();
|
||||
+ "::" +common::qualifiedCppName(field->enum_type()->value(0)->name());
|
||||
break;
|
||||
default:
|
||||
propertyMap["initializer"] = "";
|
||||
|
|
|
@ -39,6 +39,31 @@ const std::vector<std::string> &CommonTemplates::ListOfQmlExceptions()
|
|||
return vec;
|
||||
}
|
||||
|
||||
const std::set<std::string_view> &CommonTemplates::ListOfCppExceptions()
|
||||
{
|
||||
static std::set<std::string_view> cppExceptions{
|
||||
"NULL", "alignas", "alignof", "and", "and_eq",
|
||||
"asm", "auto", "bitand", "bitor", "bool",
|
||||
"break", "case", "catch", "char", "class",
|
||||
"compl", "const", "constexpr", "const_cast", "continue",
|
||||
"decltype", "default", "delete", "do", "double",
|
||||
"dynamic_cast", "else", "enum", "explicit", "export",
|
||||
"extern", "false", "float", "for", "friend",
|
||||
"goto", "if", "inline", "int", "long",
|
||||
"mutable", "namespace", "new", "noexcept", "not",
|
||||
"not_eq", "nullptr", "operator", "or", "or_eq",
|
||||
"private", "protected", "public", "register", "reinterpret_cast",
|
||||
"return", "short", "signed", "sizeof", "static",
|
||||
"static_assert", "static_cast", "struct", "switch", "template",
|
||||
"this", "thread_local", "throw", "true", "try",
|
||||
"typedef", "typeid", "typename", "union", "unsigned",
|
||||
"using", "virtual", "void", "volatile", "wchar_t",
|
||||
"while", "xor", "xor_eq"
|
||||
};
|
||||
|
||||
return cppExceptions;
|
||||
}
|
||||
|
||||
const char *CommonTemplates::DefaultProtobufIncludesTemplate()
|
||||
{
|
||||
return "#include <QtCore/QMetaType>\n"
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#define QTPROTOCCOMMON_TEMPLATES_H
|
||||
|
||||
#include <unordered_map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <google/protobuf/descriptor.h>
|
||||
|
||||
|
@ -15,6 +16,7 @@ class CommonTemplates
|
|||
{
|
||||
public:
|
||||
static const std::vector<std::string> &ListOfQmlExceptions();
|
||||
static const std::set<std::string_view> &ListOfCppExceptions();
|
||||
static const char *ProtoSuffix();
|
||||
static const char *DefaultProtobufIncludesTemplate();
|
||||
static const char *QmlProtobufIncludesTemplate();
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <string_view>
|
||||
|
||||
using namespace ::google::protobuf;
|
||||
using namespace ::google::protobuf::io;
|
||||
|
@ -379,7 +380,7 @@ PropertyMap common::producePropertyMap(const FieldDescriptor *field, const Descr
|
|||
scriptable = "false";
|
||||
}
|
||||
|
||||
std::string propertyName = qualifiedName(utils::deCapitalizeAsciiName(field->camelcase_name()));
|
||||
std::string propertyName = qualifiedCppName(qualifiedQmlName(utils::deCapitalizeAsciiName(field->camelcase_name())));
|
||||
std::string propertyNameCap = utils::capitalizeAsciiName(propertyName);
|
||||
|
||||
propertyMap["property_name"] = propertyName;
|
||||
|
@ -407,7 +408,7 @@ PropertyMap common::producePropertyMap(const FieldDescriptor *field, const Descr
|
|||
return propertyMap;
|
||||
}
|
||||
|
||||
std::string common::qualifiedName(const std::string &name)
|
||||
std::string common::qualifiedQmlName(const std::string &name)
|
||||
{
|
||||
std::string fieldName(name);
|
||||
const std::vector<std::string> &searchExceptions = CommonTemplates::ListOfQmlExceptions();
|
||||
|
@ -417,6 +418,11 @@ std::string common::qualifiedName(const std::string &name)
|
|||
return fieldName;
|
||||
}
|
||||
|
||||
std::string common::qualifiedCppName(const std::string &name)
|
||||
{
|
||||
return utils::contains(CommonTemplates::ListOfCppExceptions(), name) ? name + "_" : name;
|
||||
}
|
||||
|
||||
bool common::isLocalEnum(const EnumDescriptor *type, const Descriptor *scope)
|
||||
{
|
||||
assert(type != nullptr);
|
||||
|
|
|
@ -118,7 +118,8 @@ struct common {
|
|||
static MethodMap produceMethodMap(const MethodDescriptor *method, const std::string &scope);
|
||||
static TypeMap produceServiceTypeMap(const ServiceDescriptor *service, const Descriptor *scope);
|
||||
static TypeMap produceClientTypeMap(const ServiceDescriptor *service, const Descriptor *scope);
|
||||
static std::string qualifiedName(const std::string &name);
|
||||
static std::string qualifiedQmlName(const std::string &name);
|
||||
static std::string qualifiedCppName(const std::string &name);
|
||||
static bool isLocalEnum(const EnumDescriptor *type, const google::protobuf::Descriptor *scope);
|
||||
static EnumVisibility enumVisibility(const EnumDescriptor *type, const Descriptor *scope);
|
||||
static bool hasQmlAlias(const FieldDescriptor *field);
|
||||
|
|
|
@ -20,15 +20,10 @@ const QLatin1StringView grpcGenQtprotobufKey(" --plugin=protoc-gen-qtgrpc=");
|
|||
const QLatin1StringView optKey(" --qtgrpc_opt=");
|
||||
const QLatin1StringView outputKey(" --qtgrpc_out=");
|
||||
const QLatin1StringView includeKey(" -I");
|
||||
#if defined(PROTOC_EXECUTABLE)
|
||||
#ifndef PROTOC_EXECUTABLE
|
||||
# error PROTOC_EXECUTABLE definition must be set and point to the valid protoc executable
|
||||
#endif
|
||||
const QLatin1StringView protocolBufferCompiler(XSTR(PROTOC_EXECUTABLE));
|
||||
#else
|
||||
#if defined(Q_OS_WIN)
|
||||
const QLatin1StringView protocolBufferCompiler("protoc.exe");
|
||||
#else
|
||||
const QLatin1StringView protocolBufferCompiler("protoc");
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
const QLatin1StringView qtgrpcgen("/qtgrpcgen.exe");
|
||||
#else
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
class QtProtobufEnumTypesSerializationTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
private slots:
|
||||
void SimpleEnumMessageSerializeTest();
|
||||
void RepeatedEnumMessageTest();
|
||||
|
||||
private slots:
|
||||
void init() {
|
||||
m_serializer.reset(new QProtobufSerializer);
|
||||
}
|
||||
|
@ -23,6 +22,7 @@ private:
|
|||
};
|
||||
|
||||
using namespace qtprotobufnamespace::tests;
|
||||
using namespace Qt::Literals::StringLiterals;
|
||||
|
||||
void QtProtobufEnumTypesSerializationTest::SimpleEnumMessageSerializeTest()
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ void QtProtobufEnumTypesSerializationTest::SimpleEnumMessageSerializeTest()
|
|||
test.setLocalEnum(SimpleEnumMessage::LOCAL_ENUM_VALUE2);
|
||||
QByteArray result = test.serialize(m_serializer.get());
|
||||
QCOMPARE(result.size(), 2);
|
||||
QCOMPARE(result.toHex().toStdString().c_str(), "0802");
|
||||
QCOMPARE(result.toHex(), "0802"_ba);
|
||||
}
|
||||
|
||||
void QtProtobufEnumTypesSerializationTest::RepeatedEnumMessageTest()
|
||||
|
@ -44,12 +44,10 @@ void QtProtobufEnumTypesSerializationTest::RepeatedEnumMessageTest()
|
|||
RepeatedEnumMessage::LOCAL_ENUM_VALUE2,
|
||||
RepeatedEnumMessage::LOCAL_ENUM_VALUE3});
|
||||
QByteArray result = msg.serialize(m_serializer.get());
|
||||
QCOMPARE(result.toHex().toStdString().c_str(),
|
||||
"0a06000102010203");
|
||||
QCOMPARE(result.toHex(), "0a06000102010203"_ba);
|
||||
msg.setLocalEnumList({});
|
||||
result = msg.serialize(m_serializer.get());
|
||||
QCOMPARE(result.toHex().toStdString().c_str(),
|
||||
"");
|
||||
QCOMPARE(result.toHex(), ""_ba);
|
||||
}
|
||||
|
||||
QTEST_MAIN(QtProtobufEnumTypesSerializationTest)
|
||||
|
|
|
@ -75,8 +75,42 @@ message MessageEnumReserved {
|
|||
enumValue2 = 2;
|
||||
}
|
||||
|
||||
enum UpperCaseEnum {
|
||||
EnumValue0 = 0;
|
||||
EnumValue1 = 1;
|
||||
EnumValue2 = 2;
|
||||
}
|
||||
|
||||
enum UnderScoreEnum {
|
||||
_enumUnderscoreValue0 = 0;
|
||||
_EnumUnderscoreValue1 = 1;
|
||||
}
|
||||
}
|
||||
|
||||
message CppKeywords {
|
||||
bool private = 1;
|
||||
bool if = 2;
|
||||
bool else = 3;
|
||||
bool for = 4;
|
||||
bool while = 5;
|
||||
bool switch = 6;
|
||||
bool case = 7;
|
||||
bool do = 8;
|
||||
bool goto = 9;
|
||||
}
|
||||
|
||||
message int {
|
||||
enum long {
|
||||
bool = 0;
|
||||
char = 1;
|
||||
float = 2;
|
||||
double = 3;
|
||||
unsigned = 4;
|
||||
}
|
||||
|
||||
long enum = 1;
|
||||
}
|
||||
|
||||
message if {
|
||||
bool else = 1;
|
||||
}
|
||||
|
|
|
@ -93,9 +93,9 @@ void QtProtobufSyntaxTest::LowerCaseEnumTest()
|
|||
}
|
||||
}
|
||||
QVERIFY(simpleEnum.isValid());
|
||||
QCOMPARE(simpleEnum.key(0), "EnumValue0");
|
||||
QCOMPARE(simpleEnum.key(1), "EnumValue1");
|
||||
QCOMPARE(simpleEnum.key(2), "EnumValue2");
|
||||
QCOMPARE(simpleEnum.key(0), "enumValue0");
|
||||
QCOMPARE(simpleEnum.key(1), "enumValue1");
|
||||
QCOMPARE(simpleEnum.key(2), "enumValue2");
|
||||
}
|
||||
|
||||
QTEST_MAIN(QtProtobufSyntaxTest)
|
||||
|
|
|
@ -21,15 +21,10 @@ const QLatin1StringView protocGenQtprotobufKey(" --plugin=protoc-gen-qtprotobuf=
|
|||
const QLatin1StringView optKey(" --qtprotobuf_opt=");
|
||||
const QLatin1StringView outputKey(" --qtprotobuf_out=");
|
||||
const QLatin1StringView includeKey(" -I");
|
||||
#if defined(PROTOC_EXECUTABLE)
|
||||
#ifndef PROTOC_EXECUTABLE
|
||||
# error PROTOC_EXECUTABLE definition must be set and point to the valid protoc executable
|
||||
#endif
|
||||
const QLatin1StringView protocolBufferCompiler(XSTR(PROTOC_EXECUTABLE));
|
||||
#else
|
||||
#if defined(Q_OS_WIN)
|
||||
const QLatin1StringView protocolBufferCompiler("protoc.exe");
|
||||
#else
|
||||
const QLatin1StringView protocolBufferCompiler("protoc");
|
||||
#endif
|
||||
#endif
|
||||
#if defined(Q_OS_WIN)
|
||||
const QLatin1StringView qtprotobufgen("/qtprotobufgen.exe");
|
||||
#else
|
||||
|
@ -246,8 +241,8 @@ void tst_qtprotobufgen::cmakeGeneratedFile()
|
|||
QFile expectedResultFile(m_expectedResult + folder + fileName + extension);
|
||||
QFile generatedFile(m_cmakeGenerated + folder + fileName + extension);
|
||||
|
||||
QVERIFY(expectedResultFile.exists());
|
||||
QVERIFY(generatedFile.exists());
|
||||
QVERIFY2(expectedResultFile.exists(), qPrintable(expectedResultFile.fileName()));
|
||||
QVERIFY2(generatedFile.exists(), qPrintable(expectedResultFile.fileName()));
|
||||
|
||||
QVERIFY2(expectedResultFile.open(QIODevice::ReadOnly | QIODevice::Text),
|
||||
msgCannotReadFile(expectedResultFile).constData());
|
||||
|
|
Loading…
Reference in New Issue