From 2b6ba090dc895152efe2d9da4b15497e92429d18 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Thu, 27 Mar 2008 21:40:38 +0000 Subject: [PATCH] Remove t_st_generator.h. t_st_generator.h is no longer included anywhere, because the Smalltalk 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@665599 13f79535-47bb-0310-9956-ffa450edef68 --- compiler/cpp/Makefile.am | 1 - compiler/cpp/src/generate/t_st_generator.cc | 122 +++++++++++++++++- compiler/cpp/src/generate/t_st_generator.h | 131 -------------------- 3 files changed, 121 insertions(+), 133 deletions(-) delete mode 100644 compiler/cpp/src/generate/t_st_generator.h diff --git a/compiler/cpp/Makefile.am b/compiler/cpp/Makefile.am index 90639436..c3bf82e3 100644 --- a/compiler/cpp/Makefile.am +++ b/compiler/cpp/Makefile.am @@ -49,7 +49,6 @@ thrift_SOURCES = src/thrifty.yy \ src/generate/t_perl_generator.h \ src/generate/t_erl_generator.h \ src/generate/t_cocoa_generator.h \ - src/generate/t_st_generator.h \ src/generate/t_csharp_generator.h if THRIFT_GEN_cpp diff --git a/compiler/cpp/src/generate/t_st_generator.cc b/compiler/cpp/src/generate/t_st_generator.cc index cf174160..312e2ba4 100644 --- a/compiler/cpp/src/generate/t_st_generator.cc +++ b/compiler/cpp/src/generate/t_st_generator.cc @@ -6,14 +6,134 @@ // See accompanying file LICENSE or visit the Thrift site at: // http://developers.facebook.com/thrift/ +#include +#include +#include +#include + #include +#include #include #include #include -#include "t_st_generator.h" + #include "platform.h" +#include "t_oop_generator.h" using namespace std; + +/** + * Smalltalk code generator. + * + * @author Patrick Collison + */ +class t_st_generator : public t_oop_generator { + public: + t_st_generator( + t_program* program, + const std::map& parsed_options, + const std::string& option_string) + : t_oop_generator(program) + { + out_dir_base_ = "gen-st"; + } + + /** + * 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); + void generate_class_side_definition (); + void generate_force_consts (); + + + std::string render_const_value(t_type* type, t_const_value* value); + + /** + * Struct generation code + */ + + void generate_st_struct (std::ofstream& out, t_struct* tstruct, bool is_exception); + void generate_accessors (std::ofstream& out, t_struct* tstruct); + + /** + * Service-level generation functions + */ + + void generate_service_client (t_service* tservice); + + void generate_send_method (t_function* tfunction); + void generate_recv_method (t_function* tfunction); + + std::string map_reader (t_map *tmap); + std::string list_reader (t_list *tlist); + std::string set_reader (t_set *tset); + std::string struct_reader (t_struct *tstruct, std::string clsName); + + std::string map_writer (t_map *tmap, std::string name); + std::string list_writer (t_list *tlist, std::string name); + std::string set_writer (t_set *tset, std::string name); + std::string struct_writer (t_struct *tstruct, std::string fname); + + std::string write_val (t_type *t, std::string fname); + std::string read_val (t_type *t); + + /** + * Helper rendering functions + */ + + std::string st_autogen_comment(); + + void st_class_def(std::ofstream &out, std::string name); + void st_method(std::ofstream &out, std::string cls, std::string name); + void st_method(std::ofstream &out, std::string cls, std::string name, std::string category); + void st_close_method(std::ofstream &out); + void st_class_method(std::ofstream &out, std::string cls, std::string name); + void st_class_method(std::ofstream &out, std::string cls, std::string name, std::string category); + void st_setter(std::ofstream &out, std::string cls, std::string name, std::string type); + void st_getter(std::ofstream &out, std::string cls, std::string name); + void st_accessors(std::ofstream &out, std::string cls, std::string name, std::string type); + + std::string class_name(); + std::string client_class_name(); + std::string prefix(std::string name); + std::string declare_field(t_field* tfield); + std::string sanitize(std::string s); + std::string type_name(t_type* ttype); + + std::string function_signature(t_function* tfunction); + std::string argument_list(t_struct* tstruct); + std::string function_types_comment(t_function* fn); + + std::string type_to_enum(t_type* ttype); + std::string a_type(t_type* type); + bool is_vowel(char c); + std::string temp_name(); + std::string generated_category(); + + private: + + /** + * File streams + */ + int temporary_var; + std::ofstream f_; + +}; + + /** * Prepares for file generation by opening up the necessary file output * streams. diff --git a/compiler/cpp/src/generate/t_st_generator.h b/compiler/cpp/src/generate/t_st_generator.h deleted file mode 100644 index ae8f3239..00000000 --- a/compiler/cpp/src/generate/t_st_generator.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (c) 2007- Patrick Collison -// 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_ST_GENERATOR_H -#define T_ST_GENERATOR_H - -#include -#include -#include -#include -#include - -#include "t_oop_generator.h" - -/** - * Smalltalk code generator. - * - * @author Patrick Collison - */ -class t_st_generator : public t_oop_generator { - public: - t_st_generator( - t_program* program, - const std::map& parsed_options, - const std::string& option_string) - : t_oop_generator(program) - { - out_dir_base_ = "gen-st"; - } - - /** - * 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); - void generate_class_side_definition (); - void generate_force_consts (); - - - std::string render_const_value(t_type* type, t_const_value* value); - - /** - * Struct generation code - */ - - void generate_st_struct (std::ofstream& out, t_struct* tstruct, bool is_exception); - void generate_accessors (std::ofstream& out, t_struct* tstruct); - - /** - * Service-level generation functions - */ - - void generate_service_client (t_service* tservice); - - void generate_send_method (t_function* tfunction); - void generate_recv_method (t_function* tfunction); - - std::string map_reader (t_map *tmap); - std::string list_reader (t_list *tlist); - std::string set_reader (t_set *tset); - std::string struct_reader (t_struct *tstruct, std::string clsName); - - std::string map_writer (t_map *tmap, std::string name); - std::string list_writer (t_list *tlist, std::string name); - std::string set_writer (t_set *tset, std::string name); - std::string struct_writer (t_struct *tstruct, std::string fname); - - std::string write_val (t_type *t, std::string fname); - std::string read_val (t_type *t); - - /** - * Helper rendering functions - */ - - std::string st_autogen_comment(); - - void st_class_def(std::ofstream &out, std::string name); - void st_method(std::ofstream &out, std::string cls, std::string name); - void st_method(std::ofstream &out, std::string cls, std::string name, std::string category); - void st_close_method(std::ofstream &out); - void st_class_method(std::ofstream &out, std::string cls, std::string name); - void st_class_method(std::ofstream &out, std::string cls, std::string name, std::string category); - void st_setter(std::ofstream &out, std::string cls, std::string name, std::string type); - void st_getter(std::ofstream &out, std::string cls, std::string name); - void st_accessors(std::ofstream &out, std::string cls, std::string name, std::string type); - - std::string class_name(); - std::string client_class_name(); - std::string prefix(std::string name); - std::string declare_field(t_field* tfield); - std::string sanitize(std::string s); - std::string type_name(t_type* ttype); - - std::string function_signature(t_function* tfunction); - std::string argument_list(t_struct* tstruct); - std::string function_types_comment(t_function* fn); - - std::string type_to_enum(t_type* ttype); - std::string a_type(t_type* type); - bool is_vowel(char c); - std::string temp_name(); - std::string generated_category(); - - private: - - /** - * File streams - */ - int temporary_var; - std::ofstream f_; - -}; - -#endif -- 2.17.1