mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 18:58:51 +00:00
Remove t_perl_generator.h.
t_perl_generator.h is no longer included anywhere, because the Perl 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@665622 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2b386c50d7
commit
fb63533c78
@ -39,7 +39,6 @@ thrift_SOURCES = src/thrifty.yy \
|
||||
src/generate/t_oop_generator.h \
|
||||
src/generate/t_php_generator.h \
|
||||
src/generate/t_xsd_generator.h \
|
||||
src/generate/t_perl_generator.h \
|
||||
src/generate/t_erl_generator.h
|
||||
|
||||
if THRIFT_GEN_cpp
|
||||
|
@ -4,13 +4,199 @@
|
||||
// See accompanying file LICENSE or visit the Thrift site at:
|
||||
// http://developers.facebook.com/thrift/
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sstream>
|
||||
#include "t_perl_generator.h"
|
||||
#include "t_oop_generator.h"
|
||||
#include "platform.h"
|
||||
using namespace std;
|
||||
|
||||
|
||||
/**
|
||||
* PERL code generator.
|
||||
*
|
||||
* @author Jake Luciani <jakers@gmail.com>
|
||||
*/
|
||||
class t_perl_generator : public t_oop_generator {
|
||||
public:
|
||||
t_perl_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-perl";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Structs!
|
||||
*/
|
||||
|
||||
void generate_perl_struct(t_struct* tstruct, bool is_exception);
|
||||
void generate_perl_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false);
|
||||
void generate_perl_struct_reader(std::ofstream& out, t_struct* tstruct);
|
||||
void generate_perl_struct_writer(std::ofstream& out, t_struct* tstruct);
|
||||
void generate_perl_function_helpers(t_function* tfunction);
|
||||
|
||||
/**
|
||||
* Service-level generation functions
|
||||
*/
|
||||
|
||||
void generate_service_helpers (t_service* tservice);
|
||||
void generate_service_interface (t_service* tservice);
|
||||
void generate_service_rest (t_service* tservice);
|
||||
void generate_service_client (t_service* tservice);
|
||||
void generate_service_processor (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 perl_includes();
|
||||
std::string declare_field(t_field* tfield, bool init=false, bool obj=false);
|
||||
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::string autogen_comment() {
|
||||
return
|
||||
std::string("#\n") +
|
||||
"# Autogenerated by Thrift\n" +
|
||||
"#\n" +
|
||||
"# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
|
||||
"#\n";
|
||||
}
|
||||
|
||||
void perl_namespace_dirs(t_program* p, std::list<std::string>& dirs) {
|
||||
std::string ns = p->get_perl_package();
|
||||
std::string::size_type loc;
|
||||
|
||||
if (ns.size() > 0) {
|
||||
while ((loc = ns.find(".")) != std::string::npos) {
|
||||
dirs.push_back(ns.substr(0, loc));
|
||||
ns = ns.substr(loc+1);
|
||||
}
|
||||
}
|
||||
|
||||
if (ns.size() > 0) {
|
||||
dirs.push_back(ns);
|
||||
}
|
||||
}
|
||||
|
||||
std::string perl_namespace(t_program* p) {
|
||||
std::string ns = p->get_perl_package();
|
||||
std::string result = "";
|
||||
std::string::size_type loc;
|
||||
|
||||
if (ns.size() > 0) {
|
||||
while ((loc = ns.find(".")) != std::string::npos) {
|
||||
result += ns.substr(0, loc);
|
||||
result += "::";
|
||||
ns = ns.substr(loc+1);
|
||||
}
|
||||
|
||||
if (ns.size() > 0) {
|
||||
result += ns + "::";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* File streams
|
||||
*/
|
||||
std::ofstream f_types_;
|
||||
std::ofstream f_consts_;
|
||||
std::ofstream f_helpers_;
|
||||
std::ofstream f_service_;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Prepares for file generation by opening up the necessary file output
|
||||
* streams.
|
||||
|
@ -1,196 +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_PERL_GENERATOR_H
|
||||
#define T_PERL_GENERATOR_H
|
||||
|
||||
#include <string>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
|
||||
#include "t_oop_generator.h"
|
||||
|
||||
/**
|
||||
* PERL code generator.
|
||||
*
|
||||
* @author Jake Luciani <jakers@gmail.com>
|
||||
*/
|
||||
class t_perl_generator : public t_oop_generator {
|
||||
public:
|
||||
t_perl_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-perl";
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Structs!
|
||||
*/
|
||||
|
||||
void generate_perl_struct(t_struct* tstruct, bool is_exception);
|
||||
void generate_perl_struct_definition(std::ofstream& out, t_struct* tstruct, bool is_xception=false);
|
||||
void generate_perl_struct_reader(std::ofstream& out, t_struct* tstruct);
|
||||
void generate_perl_struct_writer(std::ofstream& out, t_struct* tstruct);
|
||||
void generate_perl_function_helpers(t_function* tfunction);
|
||||
|
||||
/**
|
||||
* Service-level generation functions
|
||||
*/
|
||||
|
||||
void generate_service_helpers (t_service* tservice);
|
||||
void generate_service_interface (t_service* tservice);
|
||||
void generate_service_rest (t_service* tservice);
|
||||
void generate_service_client (t_service* tservice);
|
||||
void generate_service_processor (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 perl_includes();
|
||||
std::string declare_field(t_field* tfield, bool init=false, bool obj=false);
|
||||
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::string autogen_comment() {
|
||||
return
|
||||
std::string("#\n") +
|
||||
"# Autogenerated by Thrift\n" +
|
||||
"#\n" +
|
||||
"# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING\n" +
|
||||
"#\n";
|
||||
}
|
||||
|
||||
void perl_namespace_dirs(t_program* p, std::list<std::string>& dirs) {
|
||||
std::string ns = p->get_perl_package();
|
||||
std::string::size_type loc;
|
||||
|
||||
if (ns.size() > 0) {
|
||||
while ((loc = ns.find(".")) != std::string::npos) {
|
||||
dirs.push_back(ns.substr(0, loc));
|
||||
ns = ns.substr(loc+1);
|
||||
}
|
||||
}
|
||||
|
||||
if (ns.size() > 0) {
|
||||
dirs.push_back(ns);
|
||||
}
|
||||
}
|
||||
|
||||
std::string perl_namespace(t_program* p) {
|
||||
std::string ns = p->get_perl_package();
|
||||
std::string result = "";
|
||||
std::string::size_type loc;
|
||||
|
||||
if (ns.size() > 0) {
|
||||
while ((loc = ns.find(".")) != std::string::npos) {
|
||||
result += ns.substr(0, loc);
|
||||
result += "::";
|
||||
ns = ns.substr(loc+1);
|
||||
}
|
||||
|
||||
if (ns.size() > 0) {
|
||||
result += ns + "::";
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* File streams
|
||||
*/
|
||||
std::ofstream f_types_;
|
||||
std::ofstream f_consts_;
|
||||
std::ofstream f_helpers_;
|
||||
std::ofstream f_service_;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user