Parcourir la source

Remove useless records from generated header files

- Remove nested namespaces for classes that have no nested classes.
- Remove duplicated declaration of repeated messages after the
  class declaration. It's not necessary since they are already
  declared in forward declaration section.
Alexey Edelev il y a 2 ans
Parent
commit
3693758034

+ 8 - 13
tools/generator/messagedeclarationprinter.cpp

@@ -75,18 +75,18 @@ void MessageDeclarationPrinter::printClassDeclaration()
 
 void MessageDeclarationPrinter::printClassDeclarationPrivate()
 {
-    mPrinter->Print({{"namespace", mTypeMap["classname"] + Templates::QtProtobufNestedNamespace}}, Templates::NamespaceTemplate);
-    common::iterateNestedMessages(mDescriptor, [this](const ::google::protobuf::Descriptor *nestedMessage) {
-        MessageDeclarationPrinter nesterPrinter(nestedMessage, mPrinter);
-        nesterPrinter.printClassDeclarationPrivate();
-    });
-    mPrinter->Print(Templates::SimpleBlockEnclosureTemplate);
-
+    if (common::hasNestedMessages(mDescriptor)) {
+        mPrinter->Print({{"namespace", mTypeMap["classname"] + Templates::QtProtobufNestedNamespace}}, Templates::NamespaceTemplate);
+        common::iterateNestedMessages(mDescriptor, [this](const ::google::protobuf::Descriptor *nestedMessage) {
+            MessageDeclarationPrinter nesterPrinter(nestedMessage, mPrinter);
+            nesterPrinter.printClassDeclarationPrivate();
+        });
+        mPrinter->Print(Templates::SimpleBlockEnclosureTemplate);
+    }
     printComments(mDescriptor);
     printClassDeclarationBegin();
     printClassBody();
     encloseClass();
-    printListType();
 }
 
 void MessageDeclarationPrinter::printCopyFunctionality()
@@ -418,11 +418,6 @@ void MessageDeclarationPrinter::printClassBody()
     printClassMembers();
 }
 
-void MessageDeclarationPrinter::printListType()
-{
-    mPrinter->Print(mTypeMap, Templates::ComplexListTypeUsingTemplate);
-}
-
 void MessageDeclarationPrinter::printClassMembers()
 {
     Indent();

+ 0 - 1
tools/generator/messagedeclarationprinter.h

@@ -61,7 +61,6 @@ private:
     void printConstructor(int fieldCount);
     void printConstructors();
     void printDestructor();
-    void printListType();
     void printMaps();
     void printNested();
     void printMetaTypesDeclaration();