Make the Ruby generator dynamic.
authorDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 21:42:01 +0000 (21:42 +0000)
committerDavid Reiss <dreiss@apache.org>
Thu, 27 Mar 2008 21:42:01 +0000 (21:42 +0000)
- Modify the Ruby generator constructor to fit the new generic interface.
- Register the Ruby genrator with the central registry.
- Deprecate the old way of invoking the Ruby generator.
- main.cc no longer includes t_rb_generator.h.

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

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

index bb9c4d1..b2bc8ce 100644 (file)
@@ -828,3 +828,6 @@ string t_rb_generator::type_to_enum(t_type* type) {
 
   throw "INVALID TYPE IN type_to_enum: " + type->get_name();
 }
+
+
+THRIFT_REGISTER_GENERATOR(rb, "Ruby", "");
index f5e07bd..0b1fb25 100644 (file)
  */
 class t_rb_generator : public t_oop_generator {
  public:
-  t_rb_generator(t_program* program) :
-    t_oop_generator(program) {
-
+  t_rb_generator(
+      t_program* program,
+      const std::map<std::string, std::string>& parsed_options,
+      const std::string& option_string)
+    : t_oop_generator(program)
+  {
     out_dir_base_ = "gen-rb";
   }
 
index 7181d26..9e94482 100644 (file)
@@ -36,7 +36,6 @@
 #include "parse/t_program.h"
 #include "parse/t_scope.h"
 #include "generate/t_php_generator.h"
-#include "generate/t_rb_generator.h"
 #include "generate/t_xsd_generator.h"
 #include "generate/t_perl_generator.h"
 #include "generate/t_erl_generator.h"
@@ -601,7 +600,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, "  -rb         Generate Ruby output files\n");
   fprintf(stderr, "  -xsd        Generate XSD output files\n");
   fprintf(stderr, "  -perl       Generate Perl output files\n");
   fprintf(stderr, "  -erl        Generate Erlang output files\n");
@@ -867,13 +865,6 @@ void generate(t_program* program, const vector<string>& generator_strings) {
       delete phpi;
     }
 
-    if (gen_rb) {
-      pverbose("Generating Ruby\n");
-      t_rb_generator* rb = new t_rb_generator(program);
-      rb->generate_program();
-      delete rb;
-    }
-
     if (gen_xsd) {
       pverbose("Generating XSD\n");
       t_xsd_generator* xsd = new t_xsd_generator(program);
@@ -1096,6 +1087,10 @@ int main(int argc, char** argv) {
     pwarning(1, "-py is deprecated.  Use --gen py");
     generator_strings.push_back("py");
   }
+  if (gen_rb) {
+    pwarning(1, "-rb is deprecated.  Use --gen rb");
+    generator_strings.push_back("rb");
+  }
   if (gen_cocoa) {
     pwarning(1, "-cocoa is deprecated.  Use --gen cocoa");
     generator_strings.push_back("cocoa");
@@ -1114,7 +1109,7 @@ int main(int argc, char** argv) {
   }
 
   // You gotta generate something!
-  if (!gen_php && !gen_phpi && !gen_rb && !gen_xsd && !gen_perl && !gen_erl && generator_strings.empty()) {
+  if (!gen_php && !gen_phpi && !gen_xsd && !gen_perl && !gen_erl && generator_strings.empty()) {
     fprintf(stderr, "!!! No output language(s) specified\n\n");
     usage();
   }