|
@@ -34,6 +34,7 @@ const std::vector<std::string> Templates::ListOfQmlExeptions{"id", "property", "
|
|
|
const char *Templates::DefaultProtobufIncludesTemplate = "#include <QMetaType>\n"
|
|
|
"#include <QList>\n"
|
|
|
"#include <QProtobufObject>\n"
|
|
|
+ "#include <QProtobufLazyMessagePointer>\n"
|
|
|
"#include <QSharedPointer>\n"
|
|
|
"\n"
|
|
|
"#include <memory>\n"
|
|
@@ -48,7 +49,7 @@ const char *Templates::GlobalEnumClassNameTemplate = "GlobalEnums";
|
|
|
const char *Templates::DisclaimerTemplate = "/* This file is autogenerated. DO NOT CHANGE. All changes will be lost */\n\n";
|
|
|
|
|
|
const char *Templates::PreambleTemplate = "#pragma once\n\n"
|
|
|
- "#include <QObject>\n";
|
|
|
+ "#include <QObject>\n";
|
|
|
|
|
|
const char *Templates::InternalIncludeTemplate = "#include \"$include$.h\"\n";
|
|
|
const char *Templates::ExternalIncludeTemplate = "#include <$include$>\n";
|
|
@@ -59,30 +60,30 @@ const char *Templates::ManualRegistrationDeclaration = "static void registerType
|
|
|
const char *Templates::ManualRegistrationComplexTypeDefinition = "void $type$::registerTypes()\n{\n"
|
|
|
" qRegisterMetaType<$type$>(\"$full_type$\");\n"
|
|
|
" qRegisterMetaType<$type$*>(\"$full_type$*\");\n" //Somehow for aliastypes qRegisterMetaType logic doesn't work for pointer type registration
|
|
|
- " qRegisterMetaType<$list_type$>(\"$full_list_type$\");\n"
|
|
|
- "";
|
|
|
+ " qRegisterMetaType<$list_type$>(\"$full_list_type$\");\n"
|
|
|
+ "";
|
|
|
const char *Templates::ManualRegistrationGlobalEnumDefinition = "void $enum_gadget$::registerTypes()\n{\n"
|
|
|
- "";
|
|
|
+ "";
|
|
|
const char *Templates::ComplexGlobalEnumFieldRegistrationTemplate = "qRegisterMetaType<$type$>(\"$full_type$\");\n";
|
|
|
const char *Templates::ComplexListTypeUsingTemplate = "using $classname$Repeated = QList<QSharedPointer<$classname$>>;\n";
|
|
|
const char *Templates::MapTypeUsingTemplate = "using $type$ = QMap<$key_type$, $value_type$>;\n";
|
|
|
const char *Templates::MessageMapTypeUsingTemplate = "using $type$ = QMap<$key_type$, QSharedPointer<$value_type$>>;\n";
|
|
|
-const char *Templates::NestedMessageUsingTemplate = "using $type$ = $scope_namespaces$_QtProtobufNested::$type$;\n"
|
|
|
- "using $list_type$ = $scope_namespaces$_QtProtobufNested::$list_type$;\n";
|
|
|
+const char *Templates::NestedMessageUsingTemplate = "using $type$ = $scope_namespaces$::$type$;\n"
|
|
|
+ "using $list_type$ = $scope_namespaces$::$list_type$;\n";
|
|
|
|
|
|
const char *Templates::EnumTypeRepeatedTemplate = "using $list_type$ = QList<$type$>;\n";
|
|
|
|
|
|
const char *Templates::NamespaceTemplate = "namespace $namespace$ {\n";
|
|
|
const char *Templates::UsingNamespaceTemplate = "using namespace $namespace$;\n";
|
|
|
const char *Templates::ClassDeclarationTemplate = "\nclass $classname$ : public QObject\n"
|
|
|
- "{\n"
|
|
|
- " Q_OBJECT\n";
|
|
|
+ "{\n"
|
|
|
+ " Q_OBJECT\n";
|
|
|
const char *Templates::ProtoClassForwardDeclarationTemplate = "class $classname$;\n";
|
|
|
const char *Templates::ProtoClassDeclarationBeginTemplate = "\nclass $classname$ : public QObject\n"
|
|
|
- "{\n"
|
|
|
- " Q_OBJECT\n"
|
|
|
- " Q_PROTOBUF_OBJECT\n"
|
|
|
- " Q_DECLARE_PROTOBUF_SERIALIZERS($classname$)\n";
|
|
|
+ "{\n"
|
|
|
+ " Q_OBJECT\n"
|
|
|
+ " Q_PROTOBUF_OBJECT\n"
|
|
|
+ " Q_DECLARE_PROTOBUF_SERIALIZERS($classname$)\n";
|
|
|
|
|
|
const char *Templates::PropertyTemplate = "Q_PROPERTY($property_type$ $property_name$ READ $property_name$ WRITE set$property_name_cap$ NOTIFY $property_name$Changed SCRIPTABLE $scriptable$)\n";
|
|
|
const char *Templates::RepeatedPropertyTemplate = "Q_PROPERTY($property_list_type$ $property_name$ READ $property_name$ WRITE set$property_name_cap$ NOTIFY $property_name$Changed SCRIPTABLE $scriptable$)\n";
|
|
@@ -99,7 +100,7 @@ const char *Templates::ProtoConstructorEndTemplate = "QObject *parent = nullptr)
|
|
|
|
|
|
const char *Templates::MemberTemplate = "$scope_type$ m_$property_name$;\n";
|
|
|
const char *Templates::ListMemberTemplate = "$scope_list_type$ m_$property_name$;\n";
|
|
|
-const char *Templates::ComplexMemberTemplate = "std::unique_ptr<$scope_type$> m_$property_name$;\n";
|
|
|
+const char *Templates::ComplexMemberTemplate = "QProtobufLazyMessagePointer<$scope_type$> m_$property_name$;\n";
|
|
|
const char *Templates::PublicBlockTemplate = "\npublic:\n";
|
|
|
const char *Templates::PrivateBlockTemplate = "\nprivate:\n";
|
|
|
const char *Templates::EnumDefinitionTemplate = "enum $type$ {\n";
|
|
@@ -121,16 +122,26 @@ const char *Templates::EmptyMoveConstructorDefinitionTemplate = "$classname$::$c
|
|
|
const char *Templates::DeletedCopyConstructorTemplate = "$classname$(const $classname$ &) = delete;\n";
|
|
|
const char *Templates::DeletedMoveConstructorTemplate = "$classname$($classname$ &&) = delete;\n";
|
|
|
const char *Templates::CopyFieldTemplate = "set$property_name_cap$(other.m_$property_name$);\n";
|
|
|
-const char *Templates::CopyComplexFieldTemplate = "set$property_name_cap$(*other.m_$property_name$);\n";
|
|
|
-const char *Templates::MoveMessageFieldTemplate = "*m_$property_name$ = std::move(*other.m_$property_name$);\n";
|
|
|
+const char *Templates::CopyComplexFieldTemplate = "if (m_$property_name$ != other.m_$property_name$) {\n"
|
|
|
+ " *m_$property_name$ = *other.m_$property_name$;\n"
|
|
|
+ "}\n";
|
|
|
+const char *Templates::AssignComplexFieldTemplate = "if (m_$property_name$ != other.m_$property_name$) {\n"
|
|
|
+ " *m_$property_name$ = *other.m_$property_name$;\n"
|
|
|
+ " $property_name$Changed();\n"
|
|
|
+ "}\n";
|
|
|
+const char *Templates::MoveMessageFieldTemplate = "if (m_$property_name$ != other.m_$property_name$) {\n"
|
|
|
+ " *m_$property_name$ = std::move(*other.m_$property_name$);\n"
|
|
|
+ "}\n";
|
|
|
+const char *Templates::MoveAssignMessageFieldTemplate = "if (m_$property_name$ != other.m_$property_name$) {\n"
|
|
|
+ " *m_$property_name$ = std::move(*other.m_$property_name$);\n"
|
|
|
+ " $property_name$Changed();\n"
|
|
|
+ " other.$property_name$Changed();\n"
|
|
|
+ "}\n";
|
|
|
const char *Templates::MoveComplexFieldTemplate = "if (m_$property_name$ != other.m_$property_name$) {\n"
|
|
|
" m_$property_name$ = std::move(other.m_$property_name$);\n"
|
|
|
" $property_name$Changed();\n"
|
|
|
" other.$property_name$Changed();\n"
|
|
|
- "} else {\n"
|
|
|
- " m_$property_name$ = std::move(other.m_$property_name$);\n"
|
|
|
- " other.$property_name$Changed();\n"
|
|
|
- "}\n";
|
|
|
+ "}";
|
|
|
|
|
|
const char *Templates::MoveComplexFieldConstructorTemplate = "m_$property_name$ = std::move(other.m_$property_name$);\n"
|
|
|
"other.$property_name$Changed();\n";
|
|
@@ -155,82 +166,76 @@ const char *Templates::EmptyEqualOperatorDefinitionTemplate = "bool $classname$:
|
|
|
" return true;\n"
|
|
|
"}\n\n";
|
|
|
const char *Templates::EqualOperatorPropertyTemplate = "m_$property_name$ == other.m_$property_name$";
|
|
|
-const char *Templates::EqualOperatorMessagePropertyTemplate = "*m_$property_name$ == *other.m_$property_name$";
|
|
|
+const char *Templates::EqualOperatorMessagePropertyTemplate = "m_$property_name$ == other.m_$property_name$\n";
|
|
|
|
|
|
const char *Templates::NotEqualOperatorDeclarationTemplate = "bool operator !=(const $classname$ &other) const;\n";
|
|
|
const char *Templates::NotEqualOperatorDefinitionTemplate = "bool $classname$::operator !=(const $classname$ &other) const\n{\n"
|
|
|
- " return !this->operator ==(other);\n"
|
|
|
- "}\n\n";
|
|
|
+ " return !this->operator ==(other);\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::GetterPrivateMessageDeclarationTemplate = "$getter_type$ *$property_name$_p() const;\n";
|
|
|
const char *Templates::GetterPrivateMessageDefinitionTemplate = "$getter_type$ *$classname$::$property_name$_p() const\n{\n"
|
|
|
- " return m_$property_name$.get();\n"
|
|
|
- "}\n\n";
|
|
|
+ " return m_$property_name$.get();\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::GetterMessageDeclarationTemplate = "const $getter_type$ &$property_name$() const;\n";
|
|
|
const char *Templates::GetterMessageDefinitionTemplate = "const $getter_type$ &$classname$::$property_name$() const\n{\n"
|
|
|
- " return *m_$property_name$;\n"
|
|
|
- "}\n\n";
|
|
|
+ " return *m_$property_name$;\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::GetterTemplate = "$getter_type$ $property_name$() const {\n"
|
|
|
" return m_$property_name$;\n"
|
|
|
"}\n\n";
|
|
|
|
|
|
const char *Templates::NonScriptableGetterTemplate = "$qml_alias_type$ $property_name$_p() const {\n"
|
|
|
- " return m_$property_name$;\n"
|
|
|
- "}\n\n";
|
|
|
+ " return m_$property_name$;\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::GetterContainerExtraTemplate = "$getter_type$ &$property_name$() {\n"
|
|
|
- " return m_$property_name$;\n"
|
|
|
- "}\n\n";
|
|
|
+ " return m_$property_name$;\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::GetterQmlListDeclarationTemplate = "QQmlListProperty<$scope_type$> $property_name$_l();\n";
|
|
|
const char *Templates::GetterQmlListDefinitionTemplate = "QQmlListProperty<$full_type$> $classname$::$property_name$_l()\n{\n"
|
|
|
- " return QtProtobuf::constructQmlListProperty<$scope_type$>(this, &m_$property_name$);\n"
|
|
|
- "}\n\n";
|
|
|
+ " return QtProtobuf::constructQmlListProperty<$scope_type$>(this, &m_$property_name$);\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::SetterPrivateTemplateDeclarationMessageType = "void set$property_name_cap$_p($setter_type$ *$property_name$);\n";
|
|
|
const char *Templates::SetterPrivateTemplateDefinitionMessageType = "void $classname$::set$property_name_cap$_p($setter_type$ *$property_name$)\n{\n"
|
|
|
- " if ($property_name$ == nullptr) {\n"
|
|
|
- " *m_$property_name$ = {};\n"
|
|
|
- " return;\n"
|
|
|
- " }\n"
|
|
|
- " if (*m_$property_name$ != *$property_name$) {\n"
|
|
|
- " *m_$property_name$ = *$property_name$;\n"
|
|
|
- " $property_name$Changed();\n"
|
|
|
- " }\n"
|
|
|
- " //NOTE: take ownership of value\n"
|
|
|
- " delete $property_name$;\n"
|
|
|
- "}\n\n";
|
|
|
+ " if (m_$property_name$.get() != $property_name$) {\n"
|
|
|
+ " m_$property_name$.reset($property_name$);\n"
|
|
|
+ " $property_name$Changed();\n"
|
|
|
+ " }\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::SetterTemplateDeclarationMessageType = "void set$property_name_cap$(const $setter_type$ &$property_name$);\n";
|
|
|
const char *Templates::SetterTemplateDefinitionMessageType = "void $classname$::set$property_name_cap$(const $setter_type$ &$property_name$)\n{\n"
|
|
|
- " if (*m_$property_name$ != $property_name$) {\n"
|
|
|
- " *m_$property_name$ = $property_name$;\n"
|
|
|
- " $property_name$Changed();\n"
|
|
|
- " }\n"
|
|
|
- "}\n\n";
|
|
|
+ " if (*m_$property_name$ != $property_name$) {\n"
|
|
|
+ " *m_$property_name$ = $property_name$;\n"
|
|
|
+ " $property_name$Changed();\n"
|
|
|
+ " }\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::SetterTemplateDeclarationComplexType = "void set$property_name_cap$(const $setter_type$ &$property_name$);\n";
|
|
|
const char *Templates::SetterTemplateDefinitionComplexType = "void $classname$::set$property_name_cap$(const $setter_type$ &$property_name$)\n{\n"
|
|
|
- " if (m_$property_name$ != $property_name$) {\n"
|
|
|
- " m_$property_name$ = $property_name$;\n"
|
|
|
- " $property_name$Changed();\n"
|
|
|
- " }\n"
|
|
|
- "}\n\n";
|
|
|
+ " if (m_$property_name$ != $property_name$) {\n"
|
|
|
+ " m_$property_name$ = $property_name$;\n"
|
|
|
+ " $property_name$Changed();\n"
|
|
|
+ " }\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::SetterTemplate = "void set$property_name_cap$(const $setter_type$ &$property_name$) {\n"
|
|
|
- " if (m_$property_name$ != $property_name$) {\n"
|
|
|
- " m_$property_name$ = $property_name$;\n"
|
|
|
- " $property_name$Changed();\n"
|
|
|
- " }\n"
|
|
|
- "}\n\n";
|
|
|
+ " if (m_$property_name$ != $property_name$) {\n"
|
|
|
+ " m_$property_name$ = $property_name$;\n"
|
|
|
+ " $property_name$Changed();\n"
|
|
|
+ " }\n"
|
|
|
+ "}\n\n";
|
|
|
const char *Templates::NonScriptableSetterTemplate = "void set$property_name_cap$_p(const $qml_alias_type$ &$property_name$) {\n"
|
|
|
- " if (m_$property_name$ != $property_name$) {\n"
|
|
|
- " m_$property_name$ = $property_name$;\n"
|
|
|
- " $property_name$Changed();\n"
|
|
|
- " }\n"
|
|
|
- "}\n\n";
|
|
|
+ " if (m_$property_name$ != $property_name$) {\n"
|
|
|
+ " m_$property_name$ = $property_name$;\n"
|
|
|
+ " $property_name$Changed();\n"
|
|
|
+ " }\n"
|
|
|
+ "}\n\n";
|
|
|
|
|
|
const char *Templates::SignalsBlockTemplate = "\nsignals:\n";
|
|
|
const char *Templates::SignalTemplate = "void $property_name$Changed();\n";
|
|
@@ -247,7 +252,7 @@ const char *Templates::EmptyBlockTemplate = "{}\n\n";
|
|
|
const char *Templates::PropertyInitializerTemplate = "\n , m_$property_name$($property_name$)";
|
|
|
const char *Templates::PropertyDefaultInitializerTemplate = "\n , m_$property_name$($initializer$)";
|
|
|
const char *Templates::MessagePropertyInitializerTemplate = "\n , m_$property_name$(new $scope_type$($property_name$))";
|
|
|
-const char *Templates::MessagePropertyDefaultInitializerTemplate = "\n , m_$property_name$(new $scope_type$)";
|
|
|
+const char *Templates::MessagePropertyDefaultInitializerTemplate = "\n , m_$property_name$(nullptr)";
|
|
|
const char *Templates::ConstructorContentTemplate = "\n{\n}\n";
|
|
|
|
|
|
const char *Templates::DeclareMetaTypeTemplate = "Q_DECLARE_METATYPE($full_type$)\n";
|
|
@@ -292,8 +297,8 @@ const char *Templates::ServerMethodDeclarationTemplate = "Q_INVOKABLE virtual $r
|
|
|
|
|
|
|
|
|
const char *Templates::ClientConstructorDefinitionTemplate = "\n$classname$::$classname$(QObject *parent) : $parent_class$(\"$service_name$\", parent)\n"
|
|
|
- "{\n"
|
|
|
- "}\n";
|
|
|
+ "{\n"
|
|
|
+ "}\n";
|
|
|
const char *Templates::ClientMethodDefinitionSyncTemplate = "\nQtProtobuf::QGrpcStatus $classname$::$method_name$(const $param_type$ &$param_name$, const QPointer<$return_type$> &$return_name$)\n"
|
|
|
"{\n"
|
|
|
" return call(\"$method_name$\", $param_name$, $return_name$);\n"
|
|
@@ -338,8 +343,7 @@ const char *Templates::RegisterSerializersTemplate = "qRegisterProtobufType<$cla
|
|
|
const char *Templates::RegisterEnumSerializersTemplate = "qRegisterProtobufEnumType<$full_type$>();\n";
|
|
|
const char *Templates::RegistrarTemplate = "static QtProtobuf::ProtoTypeRegistrar<$classname$> ProtoTypeRegistrar$classname$(qRegisterProtobufType<$classname$>);\n";
|
|
|
const char *Templates::EnumRegistrarTemplate = "static QtProtobuf::ProtoTypeRegistrar<$enum_gadget$> ProtoTypeRegistrar$enum_gadget$($enum_gadget$::registerTypes);\n";
|
|
|
-const char *Templates::QmlRegisterTypeTemplate = "qmlRegisterType<$full_type$>(\"$qml_package$\", 1, 0, \"$type$\");\n";
|
|
|
-const char *Templates::QmlRegisterTypeUncreatableTemplate = "qmlRegisterUncreatableType<$full_name$>(\"$qml_package$\", 1, 0, \"$type$\", \"$full_type$ Could not be created from qml context\");\n";
|
|
|
+const char *Templates::QmlRegisterTypeTemplate = "qmlRegisterType<$scope_type$>(\"$qml_package$\", 1, 0, \"$type$\");\n";
|
|
|
const char *Templates::QmlRegisterEnumTypeTemplate = "qmlRegisterUncreatableType<$enum_gadget$>(\"$qml_package$\", 1, 0, \"$type$\", \"$full_type$ Could not be created from qml context\");\n";
|
|
|
|
|
|
|