Rename "alterl" to "erl".

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@666481 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
David Reiss 2008-06-11 01:15:45 +00:00
parent f2e66c1cb7
commit 9f2a5d7799
46 changed files with 56 additions and 56 deletions

2
.gitignore vendored
View File

@ -21,7 +21,7 @@ if/Makefile.in
install-sh install-sh
lib/Makefile lib/Makefile
lib/Makefile.in lib/Makefile.in
lib/alterl/ebin lib/erl/ebin
lib/cpp/.deps lib/cpp/.deps
lib/cpp/.libs lib/cpp/.libs
lib/cpp/Makefile lib/cpp/Makefile

View File

@ -11,7 +11,7 @@ thrift_SOURCES = src/thrifty.yy \
src/generate/t_generator.cc \ src/generate/t_generator.cc \
src/generate/t_php_generator.cc \ src/generate/t_php_generator.cc \
src/generate/t_xsd_generator.cc \ src/generate/t_xsd_generator.cc \
src/generate/t_alterl_generator.cc \ src/generate/t_erl_generator.cc \
src/globals.h \ src/globals.h \
src/main.h \ src/main.h \
src/platform.h \ src/platform.h \
@ -38,7 +38,7 @@ thrift_SOURCES = src/thrifty.yy \
src/generate/t_oop_generator.h \ src/generate/t_oop_generator.h \
src/generate/t_php_generator.h \ src/generate/t_php_generator.h \
src/generate/t_xsd_generator.h \ src/generate/t_xsd_generator.h \
src/generate/t_alterl_generator.h src/generate/t_erl_generator.h
if THRIFT_GEN_cpp if THRIFT_GEN_cpp
thrift_SOURCES += src/generate/t_cpp_generator.cc thrift_SOURCES += src/generate/t_cpp_generator.cc

View File

@ -8,7 +8,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/types.h> #include <sys/types.h>
#include <sstream> #include <sstream>
#include "t_alterl_generator.h" #include "t_erl_generator.h"
using namespace std; using namespace std;
@ -18,7 +18,7 @@ using namespace std;
* *
* @param tprogram The program to generate * @param tprogram The program to generate
*/ */
void t_alterl_generator::init_generator() { void t_erl_generator::init_generator() {
// Make output directory // Make output directory
mkdir(get_out_dir().c_str(), S_IRWXU | S_IRWXG | S_IRWXO); mkdir(get_out_dir().c_str(), S_IRWXU | S_IRWXG | S_IRWXO);
@ -60,19 +60,19 @@ void t_alterl_generator::init_generator() {
/** /**
* Boilerplate at beginning and end of header files * Boilerplate at beginning and end of header files
*/ */
void t_alterl_generator::hrl_header(ostream& out, string name) { void t_erl_generator::hrl_header(ostream& out, string name) {
out << "-ifndef(_" << name << "_included)." << endl << out << "-ifndef(_" << name << "_included)." << endl <<
"-define(_" << name << "_included, yeah)." << endl; "-define(_" << name << "_included, yeah)." << endl;
} }
void t_alterl_generator::hrl_footer(ostream& out, string name) { void t_erl_generator::hrl_footer(ostream& out, string name) {
out << "-endif." << endl; out << "-endif." << endl;
} }
/** /**
* Renders all the imports necessary for including another Thrift program * Renders all the imports necessary for including another Thrift program
*/ */
string t_alterl_generator::render_includes() { string t_erl_generator::render_includes() {
const vector<t_program*>& includes = program_->get_includes(); const vector<t_program*>& includes = program_->get_includes();
string result = ""; string result = "";
for (size_t i = 0; i < includes.size(); ++i) { for (size_t i = 0; i < includes.size(); ++i) {
@ -87,7 +87,7 @@ string t_alterl_generator::render_includes() {
/** /**
* Autogen'd comment * Autogen'd comment
*/ */
string t_alterl_generator::erl_autogen_comment() { string t_erl_generator::erl_autogen_comment() {
return return
std::string("%%\n") + std::string("%%\n") +
"%% Autogenerated by Thrift\n" + "%% Autogenerated by Thrift\n" +
@ -99,14 +99,14 @@ string t_alterl_generator::erl_autogen_comment() {
/** /**
* Prints standard thrift imports * Prints standard thrift imports
*/ */
string t_alterl_generator::erl_imports() { string t_erl_generator::erl_imports() {
return ""; return "";
} }
/** /**
* Closes the type files * Closes the type files
*/ */
void t_alterl_generator::close_generator() { void t_erl_generator::close_generator() {
// Close types file // Close types file
export_types_string("struct_info", 1); export_types_string("struct_info", 1);
@ -126,7 +126,7 @@ void t_alterl_generator::close_generator() {
* *
* @param ttypedef The type definition * @param ttypedef The type definition
*/ */
void t_alterl_generator::generate_typedef(t_typedef* ttypedef) { void t_erl_generator::generate_typedef(t_typedef* ttypedef) {
} }
/** /**
@ -135,7 +135,7 @@ void t_alterl_generator::generate_typedef(t_typedef* ttypedef) {
* *
* @param tenum The enumeration * @param tenum The enumeration
*/ */
void t_alterl_generator::generate_enum(t_enum* tenum) { void t_erl_generator::generate_enum(t_enum* tenum) {
vector<t_enum_value*> constants = tenum->get_constants(); vector<t_enum_value*> constants = tenum->get_constants();
vector<t_enum_value*>::iterator c_iter; vector<t_enum_value*>::iterator c_iter;
@ -160,7 +160,7 @@ void t_alterl_generator::generate_enum(t_enum* tenum) {
/** /**
* Generate a constant value * Generate a constant value
*/ */
void t_alterl_generator::generate_const(t_const* tconst) { void t_erl_generator::generate_const(t_const* tconst) {
t_type* type = tconst->get_type(); t_type* type = tconst->get_type();
string name = capitalize(tconst->get_name()); string name = capitalize(tconst->get_name());
t_const_value* value = tconst->get_value(); t_const_value* value = tconst->get_value();
@ -173,7 +173,7 @@ void t_alterl_generator::generate_const(t_const* tconst) {
* is NOT performed in this function as it is always run beforehand using the * is NOT performed in this function as it is always run beforehand using the
* validate_types method in main.cc * validate_types method in main.cc
*/ */
string t_alterl_generator::render_const_value(t_type* type, t_const_value* value) { string t_erl_generator::render_const_value(t_type* type, t_const_value* value) {
std::ostringstream out; std::ostringstream out;
if (type->is_base_type()) { if (type->is_base_type()) {
@ -297,7 +297,7 @@ string t_alterl_generator::render_const_value(t_type* type, t_const_value* value
/** /**
* Generates a struct * Generates a struct
*/ */
void t_alterl_generator::generate_struct(t_struct* tstruct) { void t_erl_generator::generate_struct(t_struct* tstruct) {
generate_erl_struct(tstruct, false); generate_erl_struct(tstruct, false);
} }
@ -307,14 +307,14 @@ void t_alterl_generator::generate_struct(t_struct* tstruct) {
* *
* @param txception The struct definition * @param txception The struct definition
*/ */
void t_alterl_generator::generate_xception(t_struct* txception) { void t_erl_generator::generate_xception(t_struct* txception) {
generate_erl_struct(txception, true); generate_erl_struct(txception, true);
} }
/** /**
* Generates a struct * Generates a struct
*/ */
void t_alterl_generator::generate_erl_struct(t_struct* tstruct, void t_erl_generator::generate_erl_struct(t_struct* tstruct,
bool is_exception) { bool is_exception) {
generate_erl_struct_definition(f_types_, f_types_hrl_file_, tstruct, is_exception); generate_erl_struct_definition(f_types_, f_types_hrl_file_, tstruct, is_exception);
} }
@ -324,7 +324,7 @@ void t_alterl_generator::generate_erl_struct(t_struct* tstruct,
* *
* @param tstruct The struct definition * @param tstruct The struct definition
*/ */
void t_alterl_generator::generate_erl_struct_definition(ostream& out, void t_erl_generator::generate_erl_struct_definition(ostream& out,
ostream& hrl_out, ostream& hrl_out,
t_struct* tstruct, t_struct* tstruct,
bool is_exception, bool is_exception,
@ -372,7 +372,7 @@ void t_alterl_generator::generate_erl_struct_definition(ostream& out,
/** /**
* Generates the read method for a struct * Generates the read method for a struct
*/ */
void t_alterl_generator::generate_erl_struct_info(ostream& out, void t_erl_generator::generate_erl_struct_info(ostream& out,
t_struct* tstruct) { t_struct* tstruct) {
string name = type_name(tstruct); string name = type_name(tstruct);
@ -391,7 +391,7 @@ void t_alterl_generator::generate_erl_struct_info(ostream& out,
* *
* @param tservice The service definition * @param tservice The service definition
*/ */
void t_alterl_generator::generate_service(t_service* tservice) { void t_erl_generator::generate_service(t_service* tservice) {
// somehow this point is reached before the constructor and it's not downcased yet // somehow this point is reached before the constructor and it's not downcased yet
// ...awesome // ...awesome
service_name_[0] = tolower(service_name_[0]); service_name_[0] = tolower(service_name_[0]);
@ -448,7 +448,7 @@ void t_alterl_generator::generate_service(t_service* tservice) {
* *
* @param tservice The service to generate a header definition for * @param tservice The service to generate a header definition for
*/ */
void t_alterl_generator::generate_service_helpers(t_service* tservice) { void t_erl_generator::generate_service_helpers(t_service* tservice) {
vector<t_function*> functions = tservice->get_functions(); vector<t_function*> functions = tservice->get_functions();
vector<t_function*>::iterator f_iter; vector<t_function*>::iterator f_iter;
@ -468,7 +468,7 @@ void t_alterl_generator::generate_service_helpers(t_service* tservice) {
* *
* @param tfunction The function * @param tfunction The function
*/ */
void t_alterl_generator::generate_erl_function_helpers(t_function* tfunction) { void t_erl_generator::generate_erl_function_helpers(t_function* tfunction) {
} }
/** /**
@ -476,7 +476,7 @@ void t_alterl_generator::generate_erl_function_helpers(t_function* tfunction) {
* *
* @param tservice The service to generate a header definition for * @param tservice The service to generate a header definition for
*/ */
void t_alterl_generator::generate_service_interface(t_service* tservice) { void t_erl_generator::generate_service_interface(t_service* tservice) {
export_string("function_info", 2); export_string("function_info", 2);
@ -510,7 +510,7 @@ void t_alterl_generator::generate_service_interface(t_service* tservice) {
* Generates a function_info(FunctionName, params_type) and * Generates a function_info(FunctionName, params_type) and
* function_info(FunctionName, reply_type) * function_info(FunctionName, reply_type)
*/ */
void t_alterl_generator::generate_function_info(t_service* tservice, void t_erl_generator::generate_function_info(t_service* tservice,
t_function* tfunction) { t_function* tfunction) {
string name_atom = "'" + tfunction->get_name() + "'"; string name_atom = "'" + tfunction->get_name() + "'";
@ -556,7 +556,7 @@ void t_alterl_generator::generate_function_info(t_service* tservice,
* *
* @param ttype The type * @param ttype The type
*/ */
string t_alterl_generator::declare_field(t_field* tfield) { // TODO string t_erl_generator::declare_field(t_field* tfield) { // TODO
string result = "@" + tfield->get_name(); string result = "@" + tfield->get_name();
t_type* type = get_true_type(tfield->get_type()); t_type* type = get_true_type(tfield->get_type());
if (tfield->get_value() != NULL) { if (tfield->get_value() != NULL) {
@ -573,7 +573,7 @@ string t_alterl_generator::declare_field(t_field* tfield) { // TODO
* @param tfunction Function definition * @param tfunction Function definition
* @return String of rendered function definition * @return String of rendered function definition
*/ */
string t_alterl_generator::function_signature(t_function* tfunction, string t_erl_generator::function_signature(t_function* tfunction,
string prefix) { string prefix) {
return return
prefix + tfunction->get_name() + prefix + tfunction->get_name() +
@ -583,7 +583,7 @@ string t_alterl_generator::function_signature(t_function* tfunction,
/** /**
* Add a function to the exports list * Add a function to the exports list
*/ */
void t_alterl_generator::export_string(string name, int num) { void t_erl_generator::export_string(string name, int num) {
if (export_lines_first_) { if (export_lines_first_) {
export_lines_first_ = false; export_lines_first_ = false;
} else { } else {
@ -592,7 +592,7 @@ void t_alterl_generator::export_string(string name, int num) {
export_lines_ << name << "/" << num; export_lines_ << name << "/" << num;
} }
void t_alterl_generator::export_types_function(t_function* tfunction, void t_erl_generator::export_types_function(t_function* tfunction,
string prefix) { string prefix) {
export_types_string(prefix + tfunction->get_name(), export_types_string(prefix + tfunction->get_name(),
@ -601,7 +601,7 @@ void t_alterl_generator::export_types_function(t_function* tfunction,
); );
} }
void t_alterl_generator::export_types_string(string name, int num) { void t_erl_generator::export_types_string(string name, int num) {
if (export_types_lines_first_) { if (export_types_lines_first_) {
export_types_lines_first_ = false; export_types_lines_first_ = false;
} else { } else {
@ -610,7 +610,7 @@ void t_alterl_generator::export_types_string(string name, int num) {
export_types_lines_ << name << "/" << num; export_types_lines_ << name << "/" << num;
} }
void t_alterl_generator::export_function(t_function* tfunction, void t_erl_generator::export_function(t_function* tfunction,
string prefix) { string prefix) {
export_string(prefix + tfunction->get_name(), export_string(prefix + tfunction->get_name(),
@ -623,7 +623,7 @@ void t_alterl_generator::export_function(t_function* tfunction,
/** /**
* Renders a field list * Renders a field list
*/ */
string t_alterl_generator::argument_list(t_struct* tstruct) { string t_erl_generator::argument_list(t_struct* tstruct) {
string result = ""; string result = "";
const vector<t_field*>& fields = tstruct->get_members(); const vector<t_field*>& fields = tstruct->get_members();
@ -641,7 +641,7 @@ string t_alterl_generator::argument_list(t_struct* tstruct) {
return result; return result;
} }
string t_alterl_generator::type_name(t_type* ttype) { string t_erl_generator::type_name(t_type* ttype) {
string prefix = ""; string prefix = "";
string name = ttype->get_name(); string name = ttype->get_name();
@ -655,7 +655,7 @@ string t_alterl_generator::type_name(t_type* ttype) {
/** /**
* Converts the parse type to a Erlang "type" (macro for int constants) * Converts the parse type to a Erlang "type" (macro for int constants)
*/ */
string t_alterl_generator::type_to_enum(t_type* type) { string t_erl_generator::type_to_enum(t_type* type) {
type = get_true_type(type); type = get_true_type(type);
if (type->is_base_type()) { if (type->is_base_type()) {
@ -697,7 +697,7 @@ string t_alterl_generator::type_to_enum(t_type* type) {
/** /**
* Generate an Erlang term which represents a thrift type * Generate an Erlang term which represents a thrift type
*/ */
std::string t_alterl_generator::generate_type_term(t_type* type, std::string t_erl_generator::generate_type_term(t_type* type,
bool expand_structs) { bool expand_structs) {
type = get_true_type(type); type = get_true_type(type);
@ -773,6 +773,6 @@ std::string t_alterl_generator::generate_type_term(t_type* type,
throw "INVALID TYPE IN type_to_enum: " + type->get_name(); throw "INVALID TYPE IN type_to_enum: " + type->get_name();
} }
std::string t_alterl_generator::type_module(t_type* ttype) { std::string t_erl_generator::type_module(t_type* ttype) {
return uncapitalize(ttype->get_program()->get_name()) + "_types"; return uncapitalize(ttype->get_program()->get_name()) + "_types";
} }

View File

@ -1,5 +1,5 @@
#ifndef T_ALTERL_GENERATOR_H #ifndef T_ERL_GENERATOR_H
#define T_ALTERL_GENERATOR_H #define T_ERL_GENERATOR_H
#include <string> #include <string>
#include <fstream> #include <fstream>
@ -13,9 +13,9 @@
* *
* @author * @author
*/ */
class t_alterl_generator : public t_generator { class t_erl_generator : public t_generator {
public: public:
t_alterl_generator(t_program* program) : t_erl_generator(t_program* program) :
t_generator(program) t_generator(program)
{ {
program_name_[0] = tolower(program_name_[0]); program_name_[0] = tolower(program_name_[0]);

View File

@ -38,7 +38,7 @@
#include "parse/t_scope.h" #include "parse/t_scope.h"
#include "generate/t_php_generator.h" #include "generate/t_php_generator.h"
#include "generate/t_xsd_generator.h" #include "generate/t_xsd_generator.h"
#include "generate/t_alterl_generator.h" #include "generate/t_erl_generator.h"
using namespace std; using namespace std;
@ -151,7 +151,7 @@ bool gen_phpa = false;
bool gen_phpo = false; bool gen_phpo = false;
bool gen_rest = false; bool gen_rest = false;
bool gen_perl = false; bool gen_perl = false;
bool gen_alterl = false; bool gen_erl = false;
bool gen_ocaml = false; bool gen_ocaml = false;
bool gen_hs = false; bool gen_hs = false;
bool gen_cocoa = false; bool gen_cocoa = false;
@ -601,7 +601,7 @@ void usage() {
fprintf(stderr, " -phpa Generate PHP with autoload (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, " -phpo Generate PHP with object oriented subclasses (with -php)\n");
fprintf(stderr, " -xsd Generate XSD output files\n"); fprintf(stderr, " -xsd Generate XSD output files\n");
fprintf(stderr, " -alterl Generate Alternative Erlang output files\n"); fprintf(stderr, " -erl Generate Erlang output files\n");
fprintf(stderr, " -o dir Set the output directory for gen-* packages\n"); fprintf(stderr, " -o dir Set the output directory for gen-* packages\n");
fprintf(stderr, " (default: current directory)\n"); fprintf(stderr, " (default: current directory)\n");
fprintf(stderr, " -I dir Add a directory to the list of directories\n"); fprintf(stderr, " -I dir Add a directory to the list of directories\n");
@ -871,11 +871,11 @@ void generate(t_program* program, const vector<string>& generator_strings) {
delete xsd; delete xsd;
} }
if (gen_alterl) { if (gen_erl) {
pverbose("Generating Alternative Erlang\n"); pverbose("Generating Erlang\n");
t_alterl_generator* alterl = new t_alterl_generator(program); t_erl_generator* erl = new t_erl_generator(program);
alterl->generate_program(); erl->generate_program();
delete alterl; delete erl;
} }
if (dump_docs) { if (dump_docs) {
@ -992,8 +992,8 @@ int main(int argc, char** argv) {
gen_xsd = true; gen_xsd = true;
} else if (strcmp(arg, "-perl") == 0) { } else if (strcmp(arg, "-perl") == 0) {
gen_perl = true; gen_perl = true;
} else if (strcmp(arg, "-alterl") == 0) { } else if (strcmp(arg, "-erl") == 0) {
gen_alterl = true; gen_erl = true;
} else if (strcmp(arg, "-ocaml") == 0) { } else if (strcmp(arg, "-ocaml") == 0) {
gen_ocaml = true; gen_ocaml = true;
} else if (strcmp(arg, "-hs") == 0) { } else if (strcmp(arg, "-hs") == 0) {
@ -1105,7 +1105,7 @@ int main(int argc, char** argv) {
} }
// You gotta generate something! // You gotta generate something!
if (!gen_php && !gen_phpi && !gen_xsd && !gen_alterl && generator_strings.empty()) { if (!gen_php && !gen_phpi && !gen_xsd && !gen_erl && generator_strings.empty()) {
fprintf(stderr, "!!! No output language(s) specified\n\n"); fprintf(stderr, "!!! No output language(s) specified\n\n");
usage(); usage();
} }

View File

@ -11,7 +11,7 @@ SUBDIRS += java
endif endif
if ENABLE_ERLANG if ENABLE_ERLANG
SUBDIRS += alterl SUBDIRS += erl
endif endif
EXTRA_DIST = \ EXTRA_DIST = \

View File

@ -7,7 +7,7 @@ INCLUDEDIR=include
TARGETDIR=ebin TARGETDIR=ebin
SRCDIR=src SRCDIR=src
ALL_INCLUDEDIR=$(GEN_INCLUDEDIR) $(INCLUDEDIR) ../../lib/alterl/include ALL_INCLUDEDIR=$(GEN_INCLUDEDIR) $(INCLUDEDIR) ../../lib/erl/include
INCLUDEFLAGS=$(patsubst %,-I%, ${ALL_INCLUDEDIR}) INCLUDEFLAGS=$(patsubst %,-I%, ${ALL_INCLUDEDIR})
MODULES = stress_server test_server test_disklog MODULES = stress_server test_server test_disklog
@ -24,8 +24,8 @@ THRIFT = ../../compiler/cpp/thrift
${GENDIR}/: ${RPCFILE} ${GENDIR}/: ${RPCFILE}
rm -rf ${GENDIR} rm -rf ${GENDIR}
${THRIFT} -alterl ${TEST_RPCFILE} ${THRIFT} -erl ${TEST_RPCFILE}
${THRIFT} -alterl ${STRESS_RPCFILE} ${THRIFT} -erl ${STRESS_RPCFILE}
mkdir -p ${GEN_INCLUDEDIR} mkdir -p ${GEN_INCLUDEDIR}
mkdir -p ${GEN_SRCDIR} mkdir -p ${GEN_SRCDIR}
mkdir -p ${GEN_TARGETDIR} mkdir -p ${GEN_TARGETDIR}

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
ERL_THRIFT=../../lib/alterl ERL_THRIFT=../../lib/erl
if ! [ -d ${ERL_THRIFT}/ebin ]; then if ! [ -d ${ERL_THRIFT}/ebin ]; then
echo "Please build the Thrift library by running \`make' in ${ERL_THRIFT}" echo "Please build the Thrift library by running \`make' in ${ERL_THRIFT}"