THRIFT-3426 Align autogen comment in XSD
Client: XSD
Patch: Jens Geyer
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 @@
}
/**
+ * 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
*/
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 @@
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();
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 @@
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 @@
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_service(t_service* tservice) {
// Make output file
string f_xsd_name = get_out_dir() + tservice->get_name() + ".xsd";
@@ -273,7 +282,8 @@
// 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();