mirror of https://github.com/qt/qtgrpc.git
Registration of Qt Protobuf types is moved into auto-generated code
- updated qtprotobufgen test respectively Task-number: QTBUG-104513 Pick-to: 6.6 Change-Id: I6b7c4a963602e6885c9f7412485c6c49c057081b Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
parent
27c1aacb5c
commit
1b6b1aab83
|
|
@ -156,7 +156,7 @@ bool QProtobufGenerator::GenerateAll(const std::vector<const FileDescriptor *> &
|
|||
for (const FileDescriptor *file: files) {
|
||||
GenerateQmlPluginSource(file, registrationPluginPrinter);
|
||||
}
|
||||
|
||||
registrationPluginPrinter->Print(CommonTemplates::QmlRegisterProtobufTypes());
|
||||
registrationPluginPrinter->Indent();
|
||||
registrationPluginPrinter->Indent();
|
||||
registrationPluginPrinter->Print(CommonTemplates::SimpleBlockEnclosureTemplate());
|
||||
|
|
@ -182,9 +182,10 @@ void QProtobufGenerator::GenerateQmlPluginIntro(Printer *printer,
|
|||
}
|
||||
printDisclaimer(printer);
|
||||
|
||||
const std::array<std::string, 3> qmlHeaders = {"QtQml/qqmlextensionplugin.h",
|
||||
const std::array<std::string, 4> qmlHeaders = {"QtQml/qqmlextensionplugin.h",
|
||||
"QtQml/qqml.h",
|
||||
"QtQml/qqmlengine.h"};
|
||||
"QtQml/qqmlengine.h",
|
||||
"QtProtobuf/qtprotobuftypes.h"};
|
||||
for (const auto &header : qmlHeaders) {
|
||||
printer->Print({{"include", header}},
|
||||
CommonTemplates::ExternalIncludeTemplate());
|
||||
|
|
|
|||
|
|
@ -947,6 +947,11 @@ const char *CommonTemplates::QmlRegisterMessageTypeTemplate()
|
|||
"but not create its instances in QML scope.\");\n";
|
||||
}
|
||||
|
||||
const char *CommonTemplates::QmlRegisterProtobufTypes()
|
||||
{
|
||||
return " qRegisterProtobufTypes();\n";
|
||||
}
|
||||
|
||||
const char *CommonTemplates::RepeatedSuffix()
|
||||
{
|
||||
return "Repeated";
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ public:
|
|||
static const char *QmlRegisterTypeTemplate();
|
||||
static const char *QmlRegisterGlobalEnumTypeTemplate();
|
||||
static const char *QmlRegisterMessageTypeTemplate();
|
||||
static const char *QmlRegisterProtobufTypes();
|
||||
|
||||
static const char *RepeatedSuffix();
|
||||
static const char *ProtoFileSuffix();
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <QtQml/qqmlextensionplugin.h>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QtQml/qqmlengine.h>
|
||||
#include <QtProtobuf/qtprotobuftypes.h>
|
||||
#include "nopackage.qpb.h"
|
||||
#include "nopackageexternal.qpb.h"
|
||||
|
||||
|
|
@ -21,6 +22,7 @@ public:
|
|||
qmlRegisterUncreatableMetaObject(
|
||||
::TestEnumGadget::staticMetaObject,
|
||||
uri, 1, 0, "TestEnum", "You can only use the nested enums of TestEnum, but not create its instances in QML scope.");
|
||||
qRegisterProtobufTypes();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include <QtQml/qqmlextensionplugin.h>
|
||||
#include <QtQml/qqml.h>
|
||||
#include <QtQml/qqmlengine.h>
|
||||
#include <QtProtobuf/qtprotobuftypes.h>
|
||||
#include "basicmessages.qpb.h"
|
||||
#include "enummessages.qpb.h"
|
||||
|
||||
|
|
@ -33,6 +34,7 @@ public:
|
|||
qmlRegisterUncreatableMetaObject(
|
||||
qtprotobufnamespace::tests::TestEnumSecondInFileGadget::staticMetaObject,
|
||||
uri, 1, 0, "TestEnumSecondInFile", "You can only use the nested enums of TestEnumSecondInFile, but not create its instances in QML scope.");
|
||||
qRegisterProtobufTypes();
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue