Browse Source

Remove unused argument parsing in QtGenerator::Generate method

- Make qtproto generation procedure generator-dependent
Viktor Kopp 5 years ago
parent
commit
ba0222b03f
3 changed files with 5 additions and 18 deletions
  1. 2 17
      src/generator/generator.cpp
  2. 2 0
      src/generator/utils.h
  3. 1 1
      src/protobuf/QtProtobufGen.cmake.in

+ 2 - 17
src/generator/generator.cpp

@@ -45,28 +45,13 @@ using namespace ::qtprotobuf::generator;
 using namespace ::google::protobuf;
 using namespace ::google::protobuf::compiler;
 
-namespace {
-#ifdef _WIN32
-    const char separator = '\\';
-#else
-    const char separator = '/';
-#endif
-}
-
 bool QtGenerator::Generate(const FileDescriptor *file,
                            const std::string &parameter,
                            GeneratorContext *generatorContext,
                            std::string *error) const
 {
-    std::vector<std::pair<std::string, std::string> > parammap;
-    ParseGeneratorParameter(parameter, &parammap);
-    std::string outDir;
-
-    for(auto param : parammap) {
-        if (param.first == "out") {
-            outDir = param.second + separator;
-        }
-    }
+    // the variable contains only the relative path to ouput dir which is unused in this method
+    UNUSED(parameter);
 
     if (file->syntax() != FileDescriptor::SYNTAX_PROTO3) {
         *error = "Invalid proto used. This plugin only supports 'proto3' syntax";

+ 2 - 0
src/generator/utils.h

@@ -64,6 +64,8 @@ static void tolower(std::string& str) {
 
 };
 
+#define UNUSED(expr) do { (void)(expr); } while (0)
+
 using PackagesList = std::unordered_map<std::string/*package*/, std::list<const ::google::protobuf::FileDescriptor *>>;
 
 } //namespace generator

+ 1 - 1
src/protobuf/QtProtobufGen.cmake.in

@@ -44,7 +44,7 @@ function(generate_qtprotobuf)
                 ${PROTO_INCLUDES}
                 ${PROTO_FILES}
             WORKING_DIRECTORY ${OUT_DIR}
-            DEPENDS ${PROTO_FILES}
+            DEPENDS ${PROTO_FILES} ${QTPROTOBUF_EXECUTABLE}
             COMMENT "Generating test headers"
     )