THRIFT-3426 Align autogen comment in XSD
Client: XSD
Patch: Jens Geyer

Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/eeb51962
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/eeb51962
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/eeb51962

Branch: refs/heads/master
Commit: eeb51962fa47c4d48ab374ffa95c088b29108396
Parents: cc193c1
Author: Jens Geyer <[email protected]>
Authored: Sat Nov 14 14:03:33 2015 +0100
Committer: Jens Geyer <[email protected]>
Committed: Sat Nov 14 14:28:10 2015 +0100

----------------------------------------------------------------------
 compiler/cpp/src/generate/t_generator.h      | 17 +++++++++++++++++
 compiler/cpp/src/generate/t_oop_generator.h  | 17 -----------------
 compiler/cpp/src/generate/t_xsd_generator.cc | 14 ++++++++++++--
 3 files changed, 29 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/eeb51962/compiler/cpp/src/generate/t_generator.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_generator.h 
b/compiler/cpp/src/generate/t_generator.h
index 99d878a..da32757 100644
--- a/compiler/cpp/src/generate/t_generator.h
+++ b/compiler/cpp/src/generate/t_generator.h
@@ -27,6 +27,7 @@
 #include "parse/t_program.h"
 #include "globals.h"
 #include "t_generator_registry.h"
+#include "version.h"
 
 /**
  * Base class for a thrift code generator. This class defines the basic
@@ -145,6 +146,22 @@ protected:
   }
 
   /**
+   * Generates a comment about this code being autogenerated, using C++ style
+   * comments, which are also fair game in Java / PHP, yay!
+   *
+   * @return C-style comment mentioning that this file is autogenerated.
+   */
+  virtual std::string autogen_comment() {
+    return std::string("/**\n") + " * " + autogen_summary() + "\n" + " *\n"
+           + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE 
DOING\n"
+           + " *  @generated\n" + " */\n";
+  }
+
+  virtual std::string autogen_summary() {
+    return std::string("Autogenerated by Thrift Compiler (") + THRIFT_VERSION 
+ ")";
+  }
+
+  /**
    * Indentation level modifiers
    */
 

http://git-wip-us.apache.org/repos/asf/thrift/blob/eeb51962/compiler/cpp/src/generate/t_oop_generator.h
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_oop_generator.h 
b/compiler/cpp/src/generate/t_oop_generator.h
index 925d108..07c9d85 100644
--- a/compiler/cpp/src/generate/t_oop_generator.h
+++ b/compiler/cpp/src/generate/t_oop_generator.h
@@ -25,7 +25,6 @@
 
 #include "globals.h"
 #include "t_generator.h"
-#include "version.h"
 
 #include <algorithm>
 
@@ -57,22 +56,6 @@ public:
     return original;
   }
 
-  /**
-   * Generates a comment about this code being autogenerated, using C++ style
-   * comments, which are also fair game in Java / PHP, yay!
-   *
-   * @return C-style comment mentioning that this file is autogenerated.
-   */
-  virtual std::string autogen_comment() {
-    return std::string("/**\n") + " * " + autogen_summary() + "\n" + " *\n"
-           + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE 
DOING\n"
-           + " *  @generated\n" + " */\n";
-  }
-
-  virtual std::string autogen_summary() {
-    return std::string("Autogenerated by Thrift Compiler (") + THRIFT_VERSION 
+ ")";
-  }
-
   virtual std::string get_enum_class_name(t_type* type) {
     std::string package = "";
     t_program* program = type->get_program();

http://git-wip-us.apache.org/repos/asf/thrift/blob/eeb51962/compiler/cpp/src/generate/t_xsd_generator.cc
----------------------------------------------------------------------
diff --git a/compiler/cpp/src/generate/t_xsd_generator.cc 
b/compiler/cpp/src/generate/t_xsd_generator.cc
index 1301656..cf7937a 100644
--- a/compiler/cpp/src/generate/t_xsd_generator.cc
+++ b/compiler/cpp/src/generate/t_xsd_generator.cc
@@ -25,6 +25,7 @@
 #include <sys/stat.h>
 #include <sstream>
 #include "t_generator.h"
+#include "version.h"
 #include "platform.h"
 
 using std::map;
@@ -87,6 +88,12 @@ private:
   std::string type_name(t_type* ttype);
   std::string base_type_name(t_base_type::t_base tbase);
 
+  virtual std::string xml_autogen_comment() {
+    return std::string("<!--\n") + " * Autogenerated by Thrift Compiler (" + 
THRIFT_VERSION + ")\n"
+           + " *\n" + " * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT 
YOU ARE DOING\n"
+           + " -->\n";
+  }
+
   /**
    * Output xsd/php file
    */
@@ -107,7 +114,8 @@ void t_xsd_generator::init_generator() {
   string f_php_name = get_out_dir() + program_->get_name() + "_xsd.php";
   f_php_.open(f_php_name.c_str());
 
-  f_php_ << "<?php" << endl;
+  f_php_ << "<?php" << endl
+         << autogen_comment() << endl;
 }
 
 void t_xsd_generator::close_generator() {
@@ -254,6 +262,7 @@ void t_xsd_generator::generate_element(ostream& out,
   }
 }
 
+
 void t_xsd_generator::generate_service(t_service* tservice) {
   // Make output file
   string f_xsd_name = get_out_dir() + tservice->get_name() + ".xsd";
@@ -273,7 +282,8 @@ void t_xsd_generator::generate_service(t_service* tservice) 
{
   // Print the XSD header
   f_xsd_ << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" << endl
          << "<xsd:schema xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\""; << ns 
<< ">" << endl
-         << endl << "<!-- Yo yo yo, this XSD woz be generated by Thrift. -->" 
<< endl << endl;
+         << xml_autogen_comment()
+         << endl;
 
   // Print out the type definitions
   indent(f_xsd_) << s_xsd_types_.str();

Reply via email to