From 227ac2c50e11f3d70ca13d811b044fb9e2a528cc Mon Sep 17 00:00:00 2001 From: Mark Slee Date: Wed, 7 Mar 2007 05:46:50 +0000 Subject: [PATCH] Ruby code gen fixes and some README improvements git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665053 13f79535-47bb-0310-9956-ffa450edef68 --- README | 20 +++++++++++++---- compiler/cpp/README | 25 +++++++++++++++++++++ compiler/cpp/cleanup.sh | 1 - compiler/cpp/src/generate/t_rb_generator.cc | 14 ++++++++---- compiler/cpp/src/main.cc | 4 ++-- 5 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 compiler/cpp/README diff --git a/README b/README index 4475e636..647df05e 100644 --- a/README +++ b/README @@ -4,6 +4,8 @@ Mark Slee (mcslee@facebook.com) Marc Kwiatkowski (marc@facebook.com) Aditya Agarwal (aditya@facebook.com) +Last Modified: 2007-Mar-06 + Thrift is distributed under the Thrift open source software license. Please see the included LICENSE file. @@ -17,9 +19,12 @@ level processing. The code generation system takes a simple definition language as its input and generates code across programming languages that uses the abstracted stack to build interoperable RPC clients and servers. +Thrift is specifically designed to support non-atomic version changes +across client and server code. + For more details on Thrift's design and implementation, take a gander at the Thrift whitepaper included in this distribution or at the README files -in a particular subdirectory of interest. +in your particular subdirectory of interest. Heirarchy ========= @@ -37,13 +42,17 @@ thrift/ java/ php/ py/ - ruby/ + rb/ test/ Contains sample Thrift files and test code across the target programming languages. + tutorial/ + + Contains a basic tutorial that will teach you how to develop software + using Thrift. Requirements ============ @@ -97,7 +106,7 @@ CXXFLAGS option in configure, as such: Run ./configure --help to see other configuration options -Make thrift +Make thrift: make @@ -105,6 +114,9 @@ From the top directory, become superuser and do: make install -Note that some language packages must be installed manually (i.e. Java, Ruby). +Note that some language packages must be installed manually using build tools +better suited to those languages (at the time of this writing, this applies +to Java, Ruby, PHP). + Look for the README file in the lib// folder for more details on the installation of each language library package. diff --git a/compiler/cpp/README b/compiler/cpp/README new file mode 100644 index 00000000..a2efb4f0 --- /dev/null +++ b/compiler/cpp/README @@ -0,0 +1,25 @@ +Thrift Code Compiler + +Author: Mark Slee (mcslee@facebook.com) +Last Modified: 2007-Mar-06 + +Thrift is distributed under the Thrift open source software license. +Please see the included LICENSE file. + +Thrift Code Compiler +==================== + +This compiler takes thrift files as input and generates output code across +various programming languages. To build and install it, do this: + + ./bootstrap.sh + ./configure + make + sudo make install + +It requires some form of LEX and YACC to be installed, which should be +picked up by autoconf. + +Not much else to report here. You'll have to look at the code to get your +questions answered. Or just run the executable after you build and take +a look at the usage message. diff --git a/compiler/cpp/cleanup.sh b/compiler/cpp/cleanup.sh index 7415fd8a..7dea388e 100755 --- a/compiler/cpp/cleanup.sh +++ b/compiler/cpp/cleanup.sh @@ -8,7 +8,6 @@ Makefile \ Makefile.in \ Makefile.orig \ NEWS \ -README \ aclocal.m4 \ autom4te.cache \ autoscan.log \ diff --git a/compiler/cpp/src/generate/t_rb_generator.cc b/compiler/cpp/src/generate/t_rb_generator.cc index 7433104a..7672030f 100644 --- a/compiler/cpp/src/generate/t_rb_generator.cc +++ b/compiler/cpp/src/generate/t_rb_generator.cc @@ -576,7 +576,7 @@ void t_rb_generator::generate_service_interface(t_service* tservice) { if (tservice->get_extends() != NULL) { string extends = type_name(tservice->get_extends()); - indent(f_service_) << "include " << extends << ".Iface" << endl; + indent(f_service_) << "include " << extends << "::Iface" << endl; } vector functions = tservice->get_functions(); @@ -600,7 +600,7 @@ void t_rb_generator::generate_service_client(t_service* tservice) { string extends_client = ""; if (tservice->get_extends() != NULL) { extends = type_name(tservice->get_extends()); - extends_client = " < " + extends + ".Client, "; + extends_client = " < " + extends + "::Client "; } indent(f_service_) << @@ -620,6 +620,9 @@ void t_rb_generator::generate_service_client(t_service* tservice) { indent() << " @oprot = oprot" << endl << indent() << " end" << endl << indent() << " @seqid = 0" << endl; + } else { + f_service_ << + indent() << " super(iprot, oprot)" << endl; } indent(f_service_) << "end" << endl << endl; @@ -763,7 +766,7 @@ void t_rb_generator::generate_service_server(t_service* tservice) { string extends_processor = ""; if (tservice->get_extends() != NULL) { extends = type_name(tservice->get_extends()); - extends_processor = " < " + extends + ".Processor, "; + extends_processor = " < " + extends + "::Processor "; } // Generate the header portion @@ -783,6 +786,9 @@ void t_rb_generator::generate_service_server(t_service* tservice) { f_service_ << indent() << "@handler = handler" << endl << indent() << "@processMap = {}" << endl; + } else { + f_service_ << + indent() << "super(handler)" << endl; } for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { f_service_ << @@ -998,7 +1004,7 @@ void t_rb_generator::generate_deserialize_struct(ofstream &out, t_struct* tstruct, string prefix) { out << - indent() << prefix << " = " << type_name(tstruct) << "()" << endl << + indent() << prefix << " = " << type_name(tstruct) << ".new()" << endl << indent() << prefix << ".read(iprot)" << endl; } diff --git a/compiler/cpp/src/main.cc b/compiler/cpp/src/main.cc index 621116d4..eb48cd00 100644 --- a/compiler/cpp/src/main.cc +++ b/compiler/cpp/src/main.cc @@ -291,8 +291,8 @@ void usage() { fprintf(stderr, " -py Generate Python output files\n"); fprintf(stderr, " -rb Generate Ruby output files\n"); fprintf(stderr, " -xsd Generate XSD output files\n"); - fprintf(stderr, " -I dir Add a directory to the list of directories \n"); - fprintf(stderr, " searched for include directives\n"); + fprintf(stderr, " -I dir Add a directory to the list of directories \n"); + fprintf(stderr, " searched for include directives\n"); fprintf(stderr, " -nowarn Suppress all compiler warnings (BAD!)\n"); fprintf(stderr, " -strict Strict compiler warnings on\n"); fprintf(stderr, " -v[erbose] Verbose mode\n"); -- 2.17.1