Remove t_rb_generator.h.
t_rb_generator.h is no longer included anywhere, because
the Ruby generator uses the new dynamic generator framework.
Therefore, we can collapse the class definition into the .cc file.
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665618 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am
index 713ac21..6f618ea 100644
--- a/compiler/cpp/Makefile.am
+++ b/compiler/cpp/Makefile.am
@@ -39,7 +39,6 @@
src/generate/t_generator.h \
src/generate/t_oop_generator.h \
src/generate/t_php_generator.h \
- src/generate/t_rb_generator.h \
src/generate/t_xsd_generator.h \
src/generate/t_perl_generator.h \
src/generate/t_erl_generator.h
diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc
index b2bc8ce..833dfd3 100644
--- a/compiler/cpp/src/generate/t_rb_generator.cc
+++ b/compiler/cpp/src/generate/t_rb_generator.cc
@@ -4,14 +4,180 @@
// See accompanying file LICENSE or visit the Thrift site at:
// http://developers.facebook.com/thrift/
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sstream>
-#include "t_rb_generator.h"
+
+#include <boost/tokenizer.hpp>
+
+#include "t_oop_generator.h"
#include "platform.h"
using namespace std;
+
+/**
+ * Ruby code generator.
+ *
+ * @author Mark Slee <mcslee@facebook.com>
+ */
+class t_rb_generator : public t_oop_generator {
+ public:
+ 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";
+ }
+
+ /**
+ * Init and close methods
+ */
+
+ void init_generator();
+ void close_generator();
+
+ /**
+ * Program-level generation functions
+ */
+
+ void generate_typedef (t_typedef* ttypedef);
+ void generate_enum (t_enum* tenum);
+ void generate_const (t_const* tconst);
+ void generate_struct (t_struct* tstruct);
+ void generate_xception (t_struct* txception);
+ void generate_service (t_service* tservice);
+
+ std::string render_const_value(t_type* type, t_const_value* value);
+
+ /**
+ * Struct generation code
+ */
+
+ void generate_rb_struct(std::ofstream& out, t_struct* tstruct, bool is_exception);
+ void generate_rb_struct_reader(std::ofstream& out, t_struct* tstruct);
+ void generate_rb_struct_writer(std::ofstream& out, t_struct* tstruct);
+ void generate_rb_function_helpers(t_function* tfunction);
+ void generate_rb_simple_constructor(std::ofstream& out, t_struct* tstruct);
+ void generate_rb_simple_exception_constructor(std::ofstream& out, t_struct* tstruct);
+ void generate_accessors (std::ofstream& out, t_struct* tstruct);
+ void generate_field_defns (std::ofstream& out, t_struct* tstruct);
+ void generate_field_data (std::ofstream& out, t_type* field_type, const std::string& field_name, t_const_value* field_value);
+
+ /**
+ * Service-level generation functions
+ */
+
+ void generate_service_helpers (t_service* tservice);
+ void generate_service_interface (t_service* tservice);
+ void generate_service_client (t_service* tservice);
+ void generate_service_server (t_service* tservice);
+ void generate_process_function (t_service* tservice, t_function* tfunction);
+
+ /**
+ * Serialization constructs
+ */
+
+ void generate_deserialize_field (std::ofstream &out,
+ t_field* tfield,
+ std::string prefix="",
+ bool inclass=false);
+
+ void generate_deserialize_struct (std::ofstream &out,
+ t_struct* tstruct,
+ std::string prefix="");
+
+ void generate_deserialize_container (std::ofstream &out,
+ t_type* ttype,
+ std::string prefix="");
+
+ void generate_deserialize_set_element (std::ofstream &out,
+ t_set* tset,
+ std::string prefix="");
+
+ void generate_deserialize_map_element (std::ofstream &out,
+ t_map* tmap,
+ std::string prefix="");
+
+ void generate_deserialize_list_element (std::ofstream &out,
+ t_list* tlist,
+ std::string prefix="");
+
+ void generate_serialize_field (std::ofstream &out,
+ t_field* tfield,
+ std::string prefix="");
+
+ void generate_serialize_struct (std::ofstream &out,
+ t_struct* tstruct,
+ std::string prefix="");
+
+ void generate_serialize_container (std::ofstream &out,
+ t_type* ttype,
+ std::string prefix="");
+
+ void generate_serialize_map_element (std::ofstream &out,
+ t_map* tmap,
+ std::string kiter,
+ std::string viter);
+
+ void generate_serialize_set_element (std::ofstream &out,
+ t_set* tmap,
+ std::string iter);
+
+ void generate_serialize_list_element (std::ofstream &out,
+ t_list* tlist,
+ std::string iter);
+
+ /**
+ * Helper rendering functions
+ */
+
+ std::string rb_autogen_comment();
+ std::string rb_imports();
+ std::string render_includes();
+ std::string declare_field(t_field* tfield);
+ std::string type_name(t_type* ttype);
+ std::string function_signature(t_function* tfunction, std::string prefix="");
+ std::string argument_list(t_struct* tstruct);
+ std::string type_to_enum(t_type* ttype);
+
+
+
+ std::vector<std::string> ruby_modules(t_program* p) {
+ std::string ns = p->get_ruby_namespace();
+ boost::tokenizer<> tok(ns);
+ std::vector<std::string> modules;
+
+ for(boost::tokenizer<>::iterator beg=tok.begin(); beg != tok.end(); ++beg) {
+ modules.push_back(*beg);
+ }
+
+ return modules;
+ }
+
+ void begin_namespace(std::ofstream&, std::vector<std::string>);
+ void end_namespace(std::ofstream&, std::vector<std::string>);
+
+ private:
+
+ /**
+ * File streams
+ */
+
+ std::ofstream f_types_;
+ std::ofstream f_consts_;
+ std::ofstream f_service_;
+
+};
+
+
/**
* Prepares for file generation by opening up the necessary file output
* streams.
diff --git a/compiler/cpp/src/generate/t_rb_generator.h b/compiler/cpp/src/generate/t_rb_generator.h
deleted file mode 100644
index 0b1fb25..0000000
--- a/compiler/cpp/src/generate/t_rb_generator.h
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (c) 2006- Facebook
-// Distributed under the Thrift Software License
-//
-// See accompanying file LICENSE or visit the Thrift site at:
-// http://developers.facebook.com/thrift/
-
-#ifndef T_RB_GENERATOR_H
-#define T_RB_GENERATOR_H
-
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <vector>
-#include <boost/tokenizer.hpp>
-
-#include "t_oop_generator.h"
-
-/**
- * Ruby code generator.
- *
- * @author Mark Slee <mcslee@facebook.com>
- */
-class t_rb_generator : public t_oop_generator {
- public:
- 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";
- }
-
- /**
- * Init and close methods
- */
-
- void init_generator();
- void close_generator();
-
- /**
- * Program-level generation functions
- */
-
- void generate_typedef (t_typedef* ttypedef);
- void generate_enum (t_enum* tenum);
- void generate_const (t_const* tconst);
- void generate_struct (t_struct* tstruct);
- void generate_xception (t_struct* txception);
- void generate_service (t_service* tservice);
-
- std::string render_const_value(t_type* type, t_const_value* value);
-
- /**
- * Struct generation code
- */
-
- void generate_rb_struct(std::ofstream& out, t_struct* tstruct, bool is_exception);
- void generate_rb_struct_reader(std::ofstream& out, t_struct* tstruct);
- void generate_rb_struct_writer(std::ofstream& out, t_struct* tstruct);
- void generate_rb_function_helpers(t_function* tfunction);
- void generate_rb_simple_constructor(std::ofstream& out, t_struct* tstruct);
- void generate_rb_simple_exception_constructor(std::ofstream& out, t_struct* tstruct);
- void generate_accessors (std::ofstream& out, t_struct* tstruct);
- void generate_field_defns (std::ofstream& out, t_struct* tstruct);
- void generate_field_data (std::ofstream& out, t_type* field_type, const std::string& field_name, t_const_value* field_value);
-
- /**
- * Service-level generation functions
- */
-
- void generate_service_helpers (t_service* tservice);
- void generate_service_interface (t_service* tservice);
- void generate_service_client (t_service* tservice);
- void generate_service_server (t_service* tservice);
- void generate_process_function (t_service* tservice, t_function* tfunction);
-
- /**
- * Serialization constructs
- */
-
- void generate_deserialize_field (std::ofstream &out,
- t_field* tfield,
- std::string prefix="",
- bool inclass=false);
-
- void generate_deserialize_struct (std::ofstream &out,
- t_struct* tstruct,
- std::string prefix="");
-
- void generate_deserialize_container (std::ofstream &out,
- t_type* ttype,
- std::string prefix="");
-
- void generate_deserialize_set_element (std::ofstream &out,
- t_set* tset,
- std::string prefix="");
-
- void generate_deserialize_map_element (std::ofstream &out,
- t_map* tmap,
- std::string prefix="");
-
- void generate_deserialize_list_element (std::ofstream &out,
- t_list* tlist,
- std::string prefix="");
-
- void generate_serialize_field (std::ofstream &out,
- t_field* tfield,
- std::string prefix="");
-
- void generate_serialize_struct (std::ofstream &out,
- t_struct* tstruct,
- std::string prefix="");
-
- void generate_serialize_container (std::ofstream &out,
- t_type* ttype,
- std::string prefix="");
-
- void generate_serialize_map_element (std::ofstream &out,
- t_map* tmap,
- std::string kiter,
- std::string viter);
-
- void generate_serialize_set_element (std::ofstream &out,
- t_set* tmap,
- std::string iter);
-
- void generate_serialize_list_element (std::ofstream &out,
- t_list* tlist,
- std::string iter);
-
- /**
- * Helper rendering functions
- */
-
- std::string rb_autogen_comment();
- std::string rb_imports();
- std::string render_includes();
- std::string declare_field(t_field* tfield);
- std::string type_name(t_type* ttype);
- std::string function_signature(t_function* tfunction, std::string prefix="");
- std::string argument_list(t_struct* tstruct);
- std::string type_to_enum(t_type* ttype);
-
-
-
- std::vector<std::string> ruby_modules(t_program* p) {
- std::string ns = p->get_ruby_namespace();
- boost::tokenizer<> tok(ns);
- std::vector<std::string> modules;
-
- for(boost::tokenizer<>::iterator beg=tok.begin(); beg != tok.end(); ++beg) {
- modules.push_back(*beg);
- }
-
- return modules;
- }
-
- void begin_namespace(std::ofstream&, std::vector<std::string>);
- void end_namespace(std::ofstream&, std::vector<std::string>);
-
- private:
-
- /**
- * File streams
- */
-
- std::ofstream f_types_;
- std::ofstream f_consts_;
- std::ofstream f_service_;
-
-};
-
-#endif