Make the XSD generator dynamic.
authorDavid Reiss <dreiss@apache.org>
Tue, 17 Feb 2009 20:28:06 +0000 (20:28 +0000)
committerDavid Reiss <dreiss@apache.org>
Tue, 17 Feb 2009 20:28:06 +0000 (20:28 +0000)
- Modify the XSD generator constructor to fit the new generic interface.
- Register the XSD genrator with the central registry.
- Deprecate the old way of invoking the XSD generator.
- main.cc no longer includes t_xsd_generator.h.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@745234 13f79535-47bb-0310-9956-ffa450edef68

compiler/cpp/src/generate/t_xsd_generator.cc
compiler/cpp/src/generate/t_xsd_generator.h
compiler/cpp/src/main.cc

index 3b67f1a..6b02038 100644 (file)
@@ -269,3 +269,5 @@ string t_xsd_generator::base_type_name(t_base_type::t_base tbase) {
     throw "compiler error: no C++ base type name for base type " + t_base_type::t_base_name(tbase);
   }
 }
+
+THRIFT_REGISTER_GENERATOR(xsd, "XSD", "");
index 31d9f60..d2e4e4b 100644 (file)
  */
 class t_xsd_generator : public t_generator {
  public:
-  t_xsd_generator(t_program* program) :
-    t_generator(program) {
+  t_xsd_generator(
+      t_program* program,
+      const std::map<std::string, std::string>& parsed_options,
+      const std::string& option_string)
+    : t_generator(program)
+  {
     out_dir_base_ = "gen-xsd";
   }
 
index 5ac9627..88d9bc4 100644 (file)
@@ -38,7 +38,6 @@
 #include "parse/t_scope.h"
 #include "generate/t_generator.h"
 #include "generate/t_php_generator.h"
-#include "generate/t_xsd_generator.h"
 
 #include "version.h"
 
@@ -610,7 +609,6 @@ void usage() {
   fprintf(stderr, "  -phpl       Generate PHP-lite (with -php)\n");
   fprintf(stderr, "  -phpa       Generate PHP with autoload (with -php)\n");
   fprintf(stderr, "  -phpo       Generate PHP with object oriented subclasses (with -php)\n");
-  fprintf(stderr, "  -xsd        Generate XSD output files\n");
   fprintf(stderr, "  -o dir      Set the output directory for gen-* packages\n");
   fprintf(stderr, "               (default: current directory)\n");
   fprintf(stderr, "  -I dir      Add a directory to the list of directories\n");
@@ -873,13 +871,6 @@ void generate(t_program* program, const vector<string>& generator_strings) {
       delete phpi;
     }
 
-    if (gen_xsd) {
-      pverbose("Generating XSD\n");
-      t_xsd_generator* xsd = new t_xsd_generator(program);
-      xsd->generate_program();
-      delete xsd;
-    }
-
     if (dump_docs) {
       dump_docstrings(program);
     }
@@ -1118,9 +1109,13 @@ int main(int argc, char** argv) {
     pwarning(1, "-hs is deprecated.  Use --gen hs");
     generator_strings.push_back("hs");
   }
+  if (gen_xsd) {
+    pwarning(1, "-xsd is deprecated.  Use --gen xsd");
+    generator_strings.push_back("xsd");
+  }
 
   // You gotta generate something!
-  if (!gen_php && !gen_phpi && !gen_xsd && generator_strings.empty()) {
+  if (!gen_php && !gen_phpi && generator_strings.empty()) {
     fprintf(stderr, "!!! No output language(s) specified\n\n");
     usage();
   }