mirror of https://github.com/qt/qtgrpc.git
Add the missing generating of the C++ exports to the qtgrpcgen
Make the generating of C++ exports common for both generators. The confilicting generation should be resolved by the tools that running the generators. Qt CMake API handles this situation. Fixes: QTBUG-121856 Pick-to: 6.7 Change-Id: Ie2452f52d755ade2909107885dac774ff8678daa Reviewed-by: Tatiana Borisova <tatiana.borisova@qt.io>
This commit is contained in:
parent
5cfbff8609
commit
b75bc17c33
|
|
@ -154,7 +154,7 @@ function(qt6_add_grpc target type)
|
|||
_qt_internal_protoc_generate_cpp_exports(generated_export generated_export_options
|
||||
${target} "${arg_EXPORT_MACRO}")
|
||||
if(generated_export)
|
||||
list(APPEND cpp_sources "${generated_export}") # TODO: Unused, see QTBUG-121856
|
||||
list(APPEND generated_files "${generated_export}")
|
||||
endif()
|
||||
list(APPEND generation_options "${generated_export_options}")
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -181,6 +181,11 @@ bool QGrpcGenerator::GenerateClientServices(const FileDescriptor *file,
|
|||
clientHeaderPrinter->Print("\n");
|
||||
|
||||
std::set<std::string> internalIncludes = QGrpcGenerator::GetInternalIncludes(file);
|
||||
if (!Options::instance().exportMacroFilename().empty()) {
|
||||
std::string exportMacroFilename = Options::instance().exportMacroFilename();
|
||||
internalIncludes.insert(utils::removeFileSuffix(exportMacroFilename));
|
||||
}
|
||||
|
||||
for (const auto &include : internalIncludes) {
|
||||
clientHeaderPrinter->Print({ { "include", include } },
|
||||
CommonTemplates::InternalIncludeTemplate());
|
||||
|
|
@ -243,5 +248,5 @@ bool QGrpcGenerator::GenerateAll(const std::vector<const FileDescriptor *> &file
|
|||
std::string *error) const
|
||||
{
|
||||
Options::setFromString(parameter, qtprotoccommon::Options::QtGrpcGen);
|
||||
return CodeGenerator::GenerateAll(files, parameter, generatorContext, error);
|
||||
return GeneratorBase::GenerateAll(files, parameter, generatorContext, error);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,32 +118,6 @@ void QProtobufGenerator::GenerateSources(const FileDescriptor *file,
|
|||
|
||||
}
|
||||
|
||||
bool QProtobufGenerator::GenerateAll(const std::vector<const FileDescriptor *> &files,
|
||||
const std::string ¶meter, GeneratorContext *generatorContext,
|
||||
std::string *error) const
|
||||
{
|
||||
assert(!files.empty());
|
||||
assert(generatorContext != nullptr);
|
||||
|
||||
Options::setFromString(parameter);
|
||||
if (Options::instance().generateMacroExportFile()) {
|
||||
std::string exportMacroName = Options::instance().exportMacro();
|
||||
std::string exportMacroFilename = Options::instance().exportMacroFilename();
|
||||
|
||||
assert(!exportMacroName.empty());
|
||||
assert(!exportMacroFilename.empty());
|
||||
|
||||
std::unique_ptr<io::ZeroCopyOutputStream> headerStream(generatorContext
|
||||
->Open(exportMacroFilename));
|
||||
std::shared_ptr<Printer> headerPrinter(new Printer(headerStream.get(), '$'));
|
||||
printDisclaimer(headerPrinter.get());
|
||||
headerPrinter->Print({ { "export_macro", Options::instance().exportMacro() } },
|
||||
CommonTemplates::ExportMacroTemplate());
|
||||
headerPrinter->PrintRaw("\n");
|
||||
}
|
||||
return CodeGenerator::GenerateAll(files, parameter, generatorContext, error);
|
||||
}
|
||||
|
||||
void QProtobufGenerator::GenerateHeader(const FileDescriptor *file,
|
||||
GeneratorContext *generatorContext) const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,10 +24,6 @@ class QProtobufGenerator : public qtprotoccommon::GeneratorBase
|
|||
public:
|
||||
QProtobufGenerator();
|
||||
~QProtobufGenerator();
|
||||
bool GenerateAll(const std::vector<const ::google::protobuf::FileDescriptor *> &files,
|
||||
const std::string ¶meter,
|
||||
::google::protobuf::compiler::GeneratorContext *generatorContext,
|
||||
std::string *error) const override;
|
||||
bool Generate(const ::google::protobuf::FileDescriptor *file,
|
||||
const std::string ¶meter,
|
||||
::google::protobuf::compiler::GeneratorContext *generatorContext,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,25 @@ bool GeneratorBase::GenerateAll(const std::vector<const FileDescriptor *> &files
|
|||
const std::string ¶meter, GeneratorContext *generatorContext,
|
||||
std::string *error) const
|
||||
{
|
||||
assert(!files.empty());
|
||||
assert(generatorContext != nullptr);
|
||||
|
||||
Options::setFromString(parameter);
|
||||
if (Options::instance().generateMacroExportFile()) {
|
||||
std::string exportMacroName = Options::instance().exportMacro();
|
||||
std::string exportMacroFilename = Options::instance().exportMacroFilename();
|
||||
|
||||
assert(!exportMacroName.empty());
|
||||
assert(!exportMacroFilename.empty());
|
||||
|
||||
std::unique_ptr<io::ZeroCopyOutputStream> headerStream(generatorContext
|
||||
->Open(exportMacroFilename));
|
||||
std::shared_ptr<Printer> headerPrinter(new Printer(headerStream.get(), '$'));
|
||||
printDisclaimer(headerPrinter.get());
|
||||
headerPrinter->Print({ { "export_macro", exportMacroName } },
|
||||
CommonTemplates::ExportMacroTemplate());
|
||||
headerPrinter->PrintRaw("\n");
|
||||
}
|
||||
return CodeGenerator::GenerateAll(files, parameter, generatorContext, error);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -35,6 +35,26 @@ qt_add_grpc(tst_qtgrpcgen CLIENT
|
|||
|
||||
qt_autogen_tools_initial_setup(tst_qtgrpcgen)
|
||||
|
||||
|
||||
qt_add_grpc(tst_qtgrpcgen_client_grpc_only CLIENT
|
||||
PROTO_FILES
|
||||
../shared/data/proto/testservice.proto
|
||||
GENERATE_PACKAGE_SUBFOLDERS
|
||||
OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated/separate/grpc"
|
||||
)
|
||||
qt_autogen_tools_initial_setup(tst_qtgrpcgen_client_grpc_only)
|
||||
|
||||
qt_add_protobuf(tst_qtgrpcgen_protobuf_only
|
||||
OUTPUT_DIRECTORY
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated/separate/protobuf"
|
||||
GENERATE_PACKAGE_SUBFOLDERS
|
||||
PROTO_FILES
|
||||
../shared/data/proto/testservice.proto
|
||||
)
|
||||
qt_autogen_tools_initial_setup(tst_qtgrpcgen_protobuf_only)
|
||||
|
||||
target_link_libraries(tst_qtgrpcgen_client_grpc_only PRIVATE tst_qtgrpcgen_protobuf_only)
|
||||
|
||||
if(TARGET Qt6::Qml)
|
||||
qt_internal_extend_target(tst_qtgrpcgen
|
||||
DEFINES
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
|
||||
|
||||
#include "qtgrpc/tests/testservice_client.grpc.qpb.h"
|
||||
|
||||
namespace qtgrpc::tests {
|
||||
namespace TestService {
|
||||
using namespace Qt::StringLiterals;
|
||||
|
||||
Client::Client(QObject *parent)
|
||||
: QAbstractGrpcClient("qtgrpc.tests.TestService"_L1, parent)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<QGrpcCallReply> Client::testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
|
||||
{
|
||||
return call("testMethod"_L1, arg, options);
|
||||
}
|
||||
|
||||
void Client::testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QObject *context, const std::function<void(std::shared_ptr<QGrpcCallReply>)> &callback, const QGrpcCallOptions &options)
|
||||
{
|
||||
std::shared_ptr<QGrpcCallReply> reply = call("testMethod"_L1, arg, options);
|
||||
QObject::connect(reply.get(), &QGrpcCallReply::finished, context, [reply, callback]() {
|
||||
callback(reply);
|
||||
}, Qt::SingleShotConnection);
|
||||
}
|
||||
|
||||
std::shared_ptr<QGrpcServerStream> Client::streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
|
||||
{
|
||||
return startStream<QGrpcServerStream>("testMethodServerStream"_L1, arg, options);
|
||||
}
|
||||
|
||||
std::shared_ptr<QGrpcClientStream> Client::streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
|
||||
{
|
||||
return startStream<QGrpcClientStream>("testMethodClientStream"_L1, arg, options);
|
||||
}
|
||||
|
||||
std::shared_ptr<QGrpcBidirStream> Client::streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options)
|
||||
{
|
||||
return startStream<QGrpcBidirStream>("testMethodBiStream"_L1, arg, options);
|
||||
}
|
||||
|
||||
} // namespace TestService
|
||||
} // namespace qtgrpc::tests
|
||||
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
|
||||
|
||||
#ifndef QPROTOBUF_TESTSERVICE_CLIENT_H
|
||||
#define QPROTOBUF_TESTSERVICE_CLIENT_H
|
||||
|
||||
#include <QtProtobuf/qprotobufmessage.h>
|
||||
#include <QtProtobuf/qprotobufobject.h>
|
||||
#include <QtProtobuf/qprotobuflazymessagepointer.h>
|
||||
|
||||
#include <QtGrpc/qabstractgrpcclient.h>
|
||||
#include <QtGrpc/qgrpccallreply.h>
|
||||
#include <QtGrpc/qgrpcstream.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "qtgrpc/tests/testservice.qpb.h"
|
||||
#include "tst_qtgrpcgen_client_grpc_only_exports.qpb.h"
|
||||
|
||||
namespace qtgrpc::tests {
|
||||
namespace TestService {
|
||||
|
||||
class QPB_TST_QTGRPCGEN_CLIENT_GRPC_ONLY_EXPORT Client : public QAbstractGrpcClient
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Client(QObject *parent = nullptr);
|
||||
std::shared_ptr<QGrpcCallReply> testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
|
||||
Q_INVOKABLE void testMethod(const qtgrpc::tests::SimpleStringMessage &arg, const QObject *context, const std::function<void(std::shared_ptr<QGrpcCallReply>)> &callback, const QGrpcCallOptions &options = {});
|
||||
|
||||
std::shared_ptr<QGrpcServerStream> streamTestMethodServerStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
|
||||
|
||||
std::shared_ptr<QGrpcClientStream> streamTestMethodClientStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
|
||||
|
||||
std::shared_ptr<QGrpcBidirStream> streamTestMethodBiStream(const qtgrpc::tests::SimpleStringMessage &arg, const QGrpcCallOptions &options = {});
|
||||
|
||||
|
||||
};
|
||||
} // namespace TestService
|
||||
} // namespace qtgrpc::tests
|
||||
|
||||
#endif // QPROTOBUF_TESTSERVICE_CLIENT_H
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
|
||||
|
||||
#if defined(QT_SHARED) || !defined(QT_STATIC)
|
||||
# if defined(QT_BUILD_TST_QTGRPCGEN_CLIENT_GRPC_ONLY_LIB)
|
||||
# define QPB_TST_QTGRPCGEN_CLIENT_GRPC_ONLY_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define QPB_TST_QTGRPCGEN_CLIENT_GRPC_ONLY_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define QPB_TST_QTGRPCGEN_CLIENT_GRPC_ONLY_EXPORT
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,356 @@
|
|||
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
|
||||
|
||||
#include "qtgrpc/tests/testservice.qpb.h"
|
||||
#include <QtProtobuf/qprotobufregistration.h>
|
||||
#include <cmath>
|
||||
|
||||
namespace qtgrpc::tests {
|
||||
|
||||
class SimpleStringMessage_QtProtobufData : public QSharedData
|
||||
{
|
||||
public:
|
||||
SimpleStringMessage_QtProtobufData()
|
||||
: QSharedData()
|
||||
{
|
||||
}
|
||||
|
||||
SimpleStringMessage_QtProtobufData(const SimpleStringMessage_QtProtobufData &other)
|
||||
: QSharedData(other),
|
||||
m_testFieldString(other.m_testFieldString)
|
||||
{
|
||||
}
|
||||
|
||||
QString m_testFieldString;
|
||||
};
|
||||
|
||||
SimpleStringMessage::~SimpleStringMessage() = default;
|
||||
|
||||
static constexpr struct {
|
||||
QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
|
||||
const std::array<uint, 5> qt_protobuf_SimpleStringMessage_uint_data;
|
||||
const char qt_protobuf_SimpleStringMessage_char_data[50];
|
||||
} qt_protobuf_SimpleStringMessage_metadata {
|
||||
// data
|
||||
{
|
||||
0, /* = version */
|
||||
1, /* = num fields */
|
||||
2, /* = field number offset */
|
||||
3, /* = property index offset */
|
||||
4, /* = field flags offset */
|
||||
32, /* = message full name length */
|
||||
},
|
||||
// uint_data
|
||||
{
|
||||
// JSON name offsets:
|
||||
33, /* = testFieldString */
|
||||
49, /* = end-of-string-marker */
|
||||
// Field numbers:
|
||||
6, /* = testFieldString */
|
||||
// Property indices:
|
||||
0, /* = testFieldString */
|
||||
// Field flags:
|
||||
QtProtobufPrivate::NoFlags, /* = testFieldString */
|
||||
},
|
||||
// char_data
|
||||
/* metadata char_data: */
|
||||
"qtgrpc.tests.SimpleStringMessage\0" /* = full message name */
|
||||
/* field char_data: */
|
||||
"testFieldString\0"
|
||||
};
|
||||
|
||||
const QtProtobufPrivate::QProtobufPropertyOrdering SimpleStringMessage::staticPropertyOrdering = {
|
||||
&qt_protobuf_SimpleStringMessage_metadata.data
|
||||
};
|
||||
|
||||
void SimpleStringMessage::registerTypes()
|
||||
{
|
||||
qRegisterMetaType<SimpleStringMessage>();
|
||||
qRegisterMetaType<SimpleStringMessageRepeated>();
|
||||
}
|
||||
|
||||
SimpleStringMessage::SimpleStringMessage()
|
||||
: QProtobufMessage(&SimpleStringMessage::staticMetaObject, &SimpleStringMessage::staticPropertyOrdering),
|
||||
dptr(new SimpleStringMessage_QtProtobufData)
|
||||
{
|
||||
}
|
||||
|
||||
SimpleStringMessage::SimpleStringMessage(const SimpleStringMessage &other)
|
||||
: QProtobufMessage(other),
|
||||
dptr(other.dptr)
|
||||
{
|
||||
}
|
||||
SimpleStringMessage &SimpleStringMessage::operator =(const SimpleStringMessage &other)
|
||||
{
|
||||
QProtobufMessage::operator=(other);
|
||||
dptr = other.dptr;
|
||||
return *this;
|
||||
}
|
||||
SimpleStringMessage::SimpleStringMessage(SimpleStringMessage &&other) noexcept
|
||||
: QProtobufMessage(std::move(other)),
|
||||
dptr(std::move(other.dptr))
|
||||
{
|
||||
}
|
||||
SimpleStringMessage &SimpleStringMessage::operator =(SimpleStringMessage &&other) noexcept
|
||||
{
|
||||
QProtobufMessage::operator=(std::move(other));
|
||||
dptr.swap(other.dptr);
|
||||
return *this;
|
||||
}
|
||||
bool SimpleStringMessage::operator ==(const SimpleStringMessage &other) const
|
||||
{
|
||||
return QProtobufMessage::isEqual(*this, other)
|
||||
&& dptr->m_testFieldString == other.dptr->m_testFieldString;
|
||||
}
|
||||
|
||||
bool SimpleStringMessage::operator !=(const SimpleStringMessage &other) const
|
||||
{
|
||||
return !this->operator ==(other);
|
||||
}
|
||||
|
||||
QString SimpleStringMessage::testFieldString() const
|
||||
{
|
||||
return dptr->m_testFieldString;
|
||||
}
|
||||
|
||||
void SimpleStringMessage::setTestFieldString(const QString &testFieldString)
|
||||
{
|
||||
if (dptr->m_testFieldString != testFieldString) {
|
||||
dptr.detach();
|
||||
dptr->m_testFieldString = testFieldString;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class SimpleIntMessage_QtProtobufData : public QSharedData
|
||||
{
|
||||
public:
|
||||
SimpleIntMessage_QtProtobufData()
|
||||
: QSharedData(),
|
||||
m_testField(0)
|
||||
{
|
||||
}
|
||||
|
||||
SimpleIntMessage_QtProtobufData(const SimpleIntMessage_QtProtobufData &other)
|
||||
: QSharedData(other),
|
||||
m_testField(other.m_testField)
|
||||
{
|
||||
}
|
||||
|
||||
QtProtobuf::sint32 m_testField;
|
||||
};
|
||||
|
||||
SimpleIntMessage::~SimpleIntMessage() = default;
|
||||
|
||||
static constexpr struct {
|
||||
QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
|
||||
const std::array<uint, 5> qt_protobuf_SimpleIntMessage_uint_data;
|
||||
const char qt_protobuf_SimpleIntMessage_char_data[41];
|
||||
} qt_protobuf_SimpleIntMessage_metadata {
|
||||
// data
|
||||
{
|
||||
0, /* = version */
|
||||
1, /* = num fields */
|
||||
2, /* = field number offset */
|
||||
3, /* = property index offset */
|
||||
4, /* = field flags offset */
|
||||
29, /* = message full name length */
|
||||
},
|
||||
// uint_data
|
||||
{
|
||||
// JSON name offsets:
|
||||
30, /* = testField */
|
||||
40, /* = end-of-string-marker */
|
||||
// Field numbers:
|
||||
1, /* = testField */
|
||||
// Property indices:
|
||||
0, /* = testField */
|
||||
// Field flags:
|
||||
QtProtobufPrivate::NoFlags, /* = testField */
|
||||
},
|
||||
// char_data
|
||||
/* metadata char_data: */
|
||||
"qtgrpc.tests.SimpleIntMessage\0" /* = full message name */
|
||||
/* field char_data: */
|
||||
"testField\0"
|
||||
};
|
||||
|
||||
const QtProtobufPrivate::QProtobufPropertyOrdering SimpleIntMessage::staticPropertyOrdering = {
|
||||
&qt_protobuf_SimpleIntMessage_metadata.data
|
||||
};
|
||||
|
||||
void SimpleIntMessage::registerTypes()
|
||||
{
|
||||
qRegisterMetaType<SimpleIntMessage>();
|
||||
qRegisterMetaType<SimpleIntMessageRepeated>();
|
||||
}
|
||||
|
||||
SimpleIntMessage::SimpleIntMessage()
|
||||
: QProtobufMessage(&SimpleIntMessage::staticMetaObject, &SimpleIntMessage::staticPropertyOrdering),
|
||||
dptr(new SimpleIntMessage_QtProtobufData)
|
||||
{
|
||||
}
|
||||
|
||||
SimpleIntMessage::SimpleIntMessage(const SimpleIntMessage &other)
|
||||
: QProtobufMessage(other),
|
||||
dptr(other.dptr)
|
||||
{
|
||||
}
|
||||
SimpleIntMessage &SimpleIntMessage::operator =(const SimpleIntMessage &other)
|
||||
{
|
||||
QProtobufMessage::operator=(other);
|
||||
dptr = other.dptr;
|
||||
return *this;
|
||||
}
|
||||
SimpleIntMessage::SimpleIntMessage(SimpleIntMessage &&other) noexcept
|
||||
: QProtobufMessage(std::move(other)),
|
||||
dptr(std::move(other.dptr))
|
||||
{
|
||||
}
|
||||
SimpleIntMessage &SimpleIntMessage::operator =(SimpleIntMessage &&other) noexcept
|
||||
{
|
||||
QProtobufMessage::operator=(std::move(other));
|
||||
dptr.swap(other.dptr);
|
||||
return *this;
|
||||
}
|
||||
bool SimpleIntMessage::operator ==(const SimpleIntMessage &other) const
|
||||
{
|
||||
return QProtobufMessage::isEqual(*this, other)
|
||||
&& dptr->m_testField == other.dptr->m_testField;
|
||||
}
|
||||
|
||||
bool SimpleIntMessage::operator !=(const SimpleIntMessage &other) const
|
||||
{
|
||||
return !this->operator ==(other);
|
||||
}
|
||||
|
||||
QtProtobuf::sint32 SimpleIntMessage::testField() const
|
||||
{
|
||||
return dptr->m_testField;
|
||||
}
|
||||
|
||||
void SimpleIntMessage::setTestField(const QtProtobuf::sint32 &testField)
|
||||
{
|
||||
if (dptr->m_testField != testField) {
|
||||
dptr.detach();
|
||||
dptr->m_testField = testField;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class BlobMessage_QtProtobufData : public QSharedData
|
||||
{
|
||||
public:
|
||||
BlobMessage_QtProtobufData()
|
||||
: QSharedData()
|
||||
{
|
||||
}
|
||||
|
||||
BlobMessage_QtProtobufData(const BlobMessage_QtProtobufData &other)
|
||||
: QSharedData(other),
|
||||
m_testBytes(other.m_testBytes)
|
||||
{
|
||||
}
|
||||
|
||||
QByteArray m_testBytes;
|
||||
};
|
||||
|
||||
BlobMessage::~BlobMessage() = default;
|
||||
|
||||
static constexpr struct {
|
||||
QtProtobufPrivate::QProtobufPropertyOrdering::Data data;
|
||||
const std::array<uint, 5> qt_protobuf_BlobMessage_uint_data;
|
||||
const char qt_protobuf_BlobMessage_char_data[36];
|
||||
} qt_protobuf_BlobMessage_metadata {
|
||||
// data
|
||||
{
|
||||
0, /* = version */
|
||||
1, /* = num fields */
|
||||
2, /* = field number offset */
|
||||
3, /* = property index offset */
|
||||
4, /* = field flags offset */
|
||||
24, /* = message full name length */
|
||||
},
|
||||
// uint_data
|
||||
{
|
||||
// JSON name offsets:
|
||||
25, /* = testBytes */
|
||||
35, /* = end-of-string-marker */
|
||||
// Field numbers:
|
||||
1, /* = testBytes */
|
||||
// Property indices:
|
||||
0, /* = testBytes */
|
||||
// Field flags:
|
||||
QtProtobufPrivate::NoFlags, /* = testBytes */
|
||||
},
|
||||
// char_data
|
||||
/* metadata char_data: */
|
||||
"qtgrpc.tests.BlobMessage\0" /* = full message name */
|
||||
/* field char_data: */
|
||||
"testBytes\0"
|
||||
};
|
||||
|
||||
const QtProtobufPrivate::QProtobufPropertyOrdering BlobMessage::staticPropertyOrdering = {
|
||||
&qt_protobuf_BlobMessage_metadata.data
|
||||
};
|
||||
|
||||
void BlobMessage::registerTypes()
|
||||
{
|
||||
qRegisterMetaType<BlobMessage>();
|
||||
qRegisterMetaType<BlobMessageRepeated>();
|
||||
}
|
||||
|
||||
BlobMessage::BlobMessage()
|
||||
: QProtobufMessage(&BlobMessage::staticMetaObject, &BlobMessage::staticPropertyOrdering),
|
||||
dptr(new BlobMessage_QtProtobufData)
|
||||
{
|
||||
}
|
||||
|
||||
BlobMessage::BlobMessage(const BlobMessage &other)
|
||||
: QProtobufMessage(other),
|
||||
dptr(other.dptr)
|
||||
{
|
||||
}
|
||||
BlobMessage &BlobMessage::operator =(const BlobMessage &other)
|
||||
{
|
||||
QProtobufMessage::operator=(other);
|
||||
dptr = other.dptr;
|
||||
return *this;
|
||||
}
|
||||
BlobMessage::BlobMessage(BlobMessage &&other) noexcept
|
||||
: QProtobufMessage(std::move(other)),
|
||||
dptr(std::move(other.dptr))
|
||||
{
|
||||
}
|
||||
BlobMessage &BlobMessage::operator =(BlobMessage &&other) noexcept
|
||||
{
|
||||
QProtobufMessage::operator=(std::move(other));
|
||||
dptr.swap(other.dptr);
|
||||
return *this;
|
||||
}
|
||||
bool BlobMessage::operator ==(const BlobMessage &other) const
|
||||
{
|
||||
return QProtobufMessage::isEqual(*this, other)
|
||||
&& dptr->m_testBytes == other.dptr->m_testBytes;
|
||||
}
|
||||
|
||||
bool BlobMessage::operator !=(const BlobMessage &other) const
|
||||
{
|
||||
return !this->operator ==(other);
|
||||
}
|
||||
|
||||
QByteArray BlobMessage::testBytes() const
|
||||
{
|
||||
return dptr->m_testBytes;
|
||||
}
|
||||
|
||||
void BlobMessage::setTestBytes(const QByteArray &testBytes)
|
||||
{
|
||||
if (dptr->m_testBytes != testBytes) {
|
||||
dptr.detach();
|
||||
dptr->m_testBytes = testBytes;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace qtgrpc::tests
|
||||
|
||||
#include "moc_testservice.qpb.cpp"
|
||||
|
|
@ -0,0 +1,150 @@
|
|||
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
|
||||
|
||||
#ifndef QPROTOBUF_TESTSERVICE_H
|
||||
#define QPROTOBUF_TESTSERVICE_H
|
||||
|
||||
#include <QtProtobuf/qprotobufmessage.h>
|
||||
#include <QtProtobuf/qprotobufobject.h>
|
||||
#include <QtProtobuf/qprotobuflazymessagepointer.h>
|
||||
|
||||
#include <QtCore/qbytearray.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include "tst_qtgrpcgen_protobuf_only_exports.qpb.h"
|
||||
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qshareddata.h>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
namespace qtgrpc::tests {
|
||||
class SimpleStringMessage;
|
||||
using SimpleStringMessageRepeated = QList<SimpleStringMessage>;
|
||||
namespace SimpleStringMessage_QtProtobufNested {
|
||||
enum class QtProtobufFieldEnum;
|
||||
} // namespace SimpleStringMessage_QtProtobufNested
|
||||
|
||||
class SimpleIntMessage;
|
||||
using SimpleIntMessageRepeated = QList<SimpleIntMessage>;
|
||||
namespace SimpleIntMessage_QtProtobufNested {
|
||||
enum class QtProtobufFieldEnum;
|
||||
} // namespace SimpleIntMessage_QtProtobufNested
|
||||
|
||||
class BlobMessage;
|
||||
using BlobMessageRepeated = QList<BlobMessage>;
|
||||
namespace BlobMessage_QtProtobufNested {
|
||||
enum class QtProtobufFieldEnum;
|
||||
} // namespace BlobMessage_QtProtobufNested
|
||||
|
||||
|
||||
class SimpleStringMessage_QtProtobufData;
|
||||
class QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT SimpleStringMessage : public QProtobufMessage
|
||||
{
|
||||
Q_GADGET
|
||||
Q_PROTOBUF_OBJECT
|
||||
Q_PROPERTY(QString testFieldString READ testFieldString WRITE setTestFieldString SCRIPTABLE true)
|
||||
|
||||
public:
|
||||
using QtProtobufFieldEnum = SimpleStringMessage_QtProtobufNested::QtProtobufFieldEnum;
|
||||
SimpleStringMessage();
|
||||
~SimpleStringMessage();
|
||||
SimpleStringMessage(const SimpleStringMessage &other);
|
||||
SimpleStringMessage &operator =(const SimpleStringMessage &other);
|
||||
SimpleStringMessage(SimpleStringMessage &&other) noexcept;
|
||||
SimpleStringMessage &operator =(SimpleStringMessage &&other) noexcept;
|
||||
bool operator ==(const SimpleStringMessage &other) const;
|
||||
bool operator !=(const SimpleStringMessage &other) const;
|
||||
|
||||
QString testFieldString() const;
|
||||
void setTestFieldString(const QString &testFieldString);
|
||||
static void registerTypes();
|
||||
|
||||
private:
|
||||
QExplicitlySharedDataPointer<SimpleStringMessage_QtProtobufData> dptr;
|
||||
};
|
||||
namespace SimpleStringMessage_QtProtobufNested {
|
||||
Q_NAMESPACE_EXPORT(QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT)
|
||||
|
||||
enum class QtProtobufFieldEnum {
|
||||
TestFieldStringProtoFieldNumber = 6,
|
||||
};
|
||||
Q_ENUM_NS(QtProtobufFieldEnum)
|
||||
|
||||
} // namespace SimpleStringMessage_QtProtobufNested
|
||||
|
||||
class SimpleIntMessage_QtProtobufData;
|
||||
class QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT SimpleIntMessage : public QProtobufMessage
|
||||
{
|
||||
Q_GADGET
|
||||
Q_PROTOBUF_OBJECT
|
||||
Q_PROPERTY(QtProtobuf::sint32 testField READ testField WRITE setTestField SCRIPTABLE true)
|
||||
|
||||
public:
|
||||
using QtProtobufFieldEnum = SimpleIntMessage_QtProtobufNested::QtProtobufFieldEnum;
|
||||
SimpleIntMessage();
|
||||
~SimpleIntMessage();
|
||||
SimpleIntMessage(const SimpleIntMessage &other);
|
||||
SimpleIntMessage &operator =(const SimpleIntMessage &other);
|
||||
SimpleIntMessage(SimpleIntMessage &&other) noexcept;
|
||||
SimpleIntMessage &operator =(SimpleIntMessage &&other) noexcept;
|
||||
bool operator ==(const SimpleIntMessage &other) const;
|
||||
bool operator !=(const SimpleIntMessage &other) const;
|
||||
|
||||
QtProtobuf::sint32 testField() const;
|
||||
void setTestField(const QtProtobuf::sint32 &testField);
|
||||
static void registerTypes();
|
||||
|
||||
private:
|
||||
QExplicitlySharedDataPointer<SimpleIntMessage_QtProtobufData> dptr;
|
||||
};
|
||||
namespace SimpleIntMessage_QtProtobufNested {
|
||||
Q_NAMESPACE_EXPORT(QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT)
|
||||
|
||||
enum class QtProtobufFieldEnum {
|
||||
TestFieldProtoFieldNumber = 1,
|
||||
};
|
||||
Q_ENUM_NS(QtProtobufFieldEnum)
|
||||
|
||||
} // namespace SimpleIntMessage_QtProtobufNested
|
||||
|
||||
class BlobMessage_QtProtobufData;
|
||||
class QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT BlobMessage : public QProtobufMessage
|
||||
{
|
||||
Q_GADGET
|
||||
Q_PROTOBUF_OBJECT
|
||||
Q_PROPERTY(QByteArray testBytes READ testBytes WRITE setTestBytes SCRIPTABLE true)
|
||||
|
||||
public:
|
||||
using QtProtobufFieldEnum = BlobMessage_QtProtobufNested::QtProtobufFieldEnum;
|
||||
BlobMessage();
|
||||
~BlobMessage();
|
||||
BlobMessage(const BlobMessage &other);
|
||||
BlobMessage &operator =(const BlobMessage &other);
|
||||
BlobMessage(BlobMessage &&other) noexcept;
|
||||
BlobMessage &operator =(BlobMessage &&other) noexcept;
|
||||
bool operator ==(const BlobMessage &other) const;
|
||||
bool operator !=(const BlobMessage &other) const;
|
||||
|
||||
QByteArray testBytes() const;
|
||||
void setTestBytes(const QByteArray &testBytes);
|
||||
static void registerTypes();
|
||||
|
||||
private:
|
||||
QExplicitlySharedDataPointer<BlobMessage_QtProtobufData> dptr;
|
||||
};
|
||||
namespace BlobMessage_QtProtobufNested {
|
||||
Q_NAMESPACE_EXPORT(QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT)
|
||||
|
||||
enum class QtProtobufFieldEnum {
|
||||
TestBytesProtoFieldNumber = 1,
|
||||
};
|
||||
Q_ENUM_NS(QtProtobufFieldEnum)
|
||||
|
||||
} // namespace BlobMessage_QtProtobufNested
|
||||
} // namespace qtgrpc::tests
|
||||
|
||||
Q_DECLARE_METATYPE(qtgrpc::tests::SimpleStringMessage)
|
||||
Q_DECLARE_METATYPE(qtgrpc::tests::SimpleIntMessage)
|
||||
Q_DECLARE_METATYPE(qtgrpc::tests::BlobMessage)
|
||||
#endif // QPROTOBUF_TESTSERVICE_H
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
#include <QtProtobuf/qprotobufregistration.h>
|
||||
#include "qtgrpc/tests/testservice.qpb.h"
|
||||
|
||||
namespace qtgrpc::tests {
|
||||
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarSimpleStringMessage(qRegisterProtobufType<SimpleStringMessage>);
|
||||
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarSimpleIntMessage(qRegisterProtobufType<SimpleIntMessage>);
|
||||
static QtProtobuf::ProtoTypeRegistrar ProtoTypeRegistrarBlobMessage(qRegisterProtobufType<BlobMessage>);
|
||||
static bool RegisterTestserviceProtobufTypes = [](){ qRegisterProtobufTypes(); return true; }();
|
||||
} // namespace qtgrpc::tests
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */
|
||||
|
||||
#if defined(QT_SHARED) || !defined(QT_STATIC)
|
||||
# if defined(QT_BUILD_TST_QTGRPCGEN_PROTOBUF_ONLY_LIB)
|
||||
# define QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT Q_DECL_EXPORT
|
||||
# else
|
||||
# define QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT Q_DECL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define QPB_TST_QTGRPCGEN_PROTOBUF_ONLY_EXPORT
|
||||
#endif
|
||||
|
||||
|
|
@ -189,19 +189,37 @@ void tst_qtgrpcgen::cmakeGeneratedFile_data()
|
|||
QTest::addColumn<QString>("extension");
|
||||
QTest::addColumn<QString>("cmakeGenerationFolder");
|
||||
|
||||
const QLatin1StringView extensions[] = { cppProtobufGenExtension,
|
||||
headerProtobufGenExtension,
|
||||
cppExtension,
|
||||
headerExtension };
|
||||
const QLatin1StringView protobufExtensions[] = { cppProtobufGenExtension,
|
||||
headerProtobufGenExtension };
|
||||
|
||||
for (const auto extension : extensions) {
|
||||
const QLatin1StringView grpcExtensions[] = { cppExtension, headerExtension };
|
||||
|
||||
for (const auto extension : grpcExtensions) {
|
||||
QTest::addRow("testservice%s", extension.data())
|
||||
<< "testservice"
|
||||
<< "/folder/qtgrpc/tests/"
|
||||
<< QString(extension)
|
||||
<< m_cmakeGenerated;
|
||||
|
||||
QTest::addRow("separate/grpc/testservice%s", extension.data())
|
||||
<< "testservice"
|
||||
<< "/separate/grpc/qtgrpc/tests/" << QString(extension) << m_cmakeGenerated;
|
||||
}
|
||||
|
||||
for (const auto extension : protobufExtensions) {
|
||||
QTest::addRow("testservice%s", extension.data())
|
||||
<< "testservice"
|
||||
<< "/folder/qtgrpc/tests/" << QString(extension) << m_cmakeGenerated;
|
||||
|
||||
QTest::addRow("separate/protobuf/testservice%s", extension.data())
|
||||
<< "testservice"
|
||||
<< "/separate/protobuf/qtgrpc/tests/" << QString(extension) << m_cmakeGenerated;
|
||||
}
|
||||
|
||||
QTest::addRow("tst_qtgrpcgen_client_grpc_only_exports.qpb.h")
|
||||
<< "tst_qtgrpcgen_client_grpc_only_exports.qpb.h"
|
||||
<< "/separate/grpc/" << QString() << m_cmakeGenerated;
|
||||
|
||||
#ifdef HAVE_QML
|
||||
const QLatin1StringView qmlExtensions[] = { cppExtension,
|
||||
headerExtension };
|
||||
|
|
@ -226,7 +244,7 @@ void tst_qtgrpcgen::cmakeGeneratedFile()
|
|||
QFile expectedResultFile(m_expectedResult + folder + fileName + extension);
|
||||
QFile generatedFile(cmakeGenerationFolder + folder + fileName + extension);
|
||||
|
||||
QVERIFY(expectedResultFile.exists());
|
||||
QVERIFY2(expectedResultFile.exists(), qPrintable(expectedResultFile.fileName()));
|
||||
QVERIFY(generatedFile.exists());
|
||||
|
||||
QVERIFY2(expectedResultFile.open(QIODevice::ReadOnly | QIODevice::Text),
|
||||
|
|
|
|||
|
|
@ -25,6 +25,14 @@ qt_internal_add_test(tst_grpc_client_unarycall_qml
|
|||
Qt::Grpc
|
||||
)
|
||||
|
||||
qt_add_grpc(tst_grpc_client_unarycall_qml_gen CLIENT
|
||||
PROTO_FILES
|
||||
../../shared/data/proto/testservice.proto
|
||||
QML
|
||||
OUTPUT_DIRECTORY
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated_qml"
|
||||
)
|
||||
|
||||
qt_add_protobuf(tst_grpc_client_unarycall_qml_gen
|
||||
PROTO_FILES
|
||||
../../shared/data/proto/testservice.proto
|
||||
|
|
@ -34,14 +42,6 @@ qt_add_protobuf(tst_grpc_client_unarycall_qml_gen
|
|||
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated_qml"
|
||||
)
|
||||
|
||||
qt_add_grpc(tst_grpc_client_unarycall_qml_gen CLIENT
|
||||
PROTO_FILES
|
||||
../../shared/data/proto/testservice.proto
|
||||
QML
|
||||
OUTPUT_DIRECTORY
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/qt_grpc_generated_qml"
|
||||
)
|
||||
|
||||
qt_policy(SET QTP0001 NEW)
|
||||
|
||||
qt_add_qml_module(tst_grpc_client_unarycall_qml
|
||||
|
|
|
|||
Loading…
Reference in New Issue