THRIFT-3426 Align autogen comment in XSD

Client: XSD
Patch: Jens Geyer
This commit is contained in:
Jens Geyer 2015-11-14 14:03:33 +01:00
parent cc193c1bec
commit eeb51962fa
3 changed files with 29 additions and 19 deletions

View File

@ -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
@ -144,6 +145,22 @@ protected:
return out.str();
}
/**
* 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
*/

View File

@ -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();

View File

@ -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();