thrift-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kcl...@apache.org
Subject svn commit: r762907 - in /incubator/thrift/trunk: compiler/cpp/src/generate/ lib/rb/spec/
Date Tue, 07 Apr 2009 19:09:29 GMT
Author: kclark
Date: Tue Apr  7 19:09:28 2009
New Revision: 762907

URL: http://svn.apache.org/viewvc?rev=762907&view=rev
Log:
Thrift-421. rb: Underscore output file names and require file statments

Breaks compatiblity

Author: Michael Stockton

Modified:
    incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h
    incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
    incubator/thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb
    incubator/thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb
    incubator/thrift/trunk/lib/rb/spec/serializer_spec.rb
    incubator/thrift/trunk/lib/rb/spec/struct_spec.rb
    incubator/thrift/trunk/lib/rb/spec/types_spec.rb

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h?rev=762907&r1=762906&r2=762907&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_generator.h Tue Apr  7 19:09:28 2009
@@ -178,6 +178,16 @@
     }
     return in;
   }
+  std::string underscore(std::string in) {
+    in[0] = tolower(in[0]);
+    for (size_t i = 1; i < in.size(); ++i) {
+      if (isupper(in[i])) {
+        in[i] = tolower(in[i]);
+        in.insert(i, "_");
+      }
+    }
+    return in;
+  }
 
   /**
    * Get the true type behind a series of typedefs.

Modified: incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc?rev=762907&r1=762906&r2=762907&view=diff
==============================================================================
--- incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc (original)
+++ incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc Tue Apr  7 19:09:28
2009
@@ -204,10 +204,10 @@
   MKDIR(get_out_dir().c_str());
 
   // Make output file
-  string f_types_name = get_out_dir()+program_name_+"_types.rb";
+  string f_types_name = get_out_dir()+underscore(program_name_)+"_types.rb";
   f_types_.open(f_types_name.c_str());
 
-  string f_consts_name = get_out_dir()+program_name_+"_constants.rb";
+  string f_consts_name = get_out_dir()+underscore(program_name_)+"_constants.rb";
   f_consts_.open(f_consts_name.c_str());
 
   // Print header
@@ -218,7 +218,7 @@
 
   f_consts_ <<
     rb_autogen_comment() << endl <<
-    "require File.dirname(__FILE__) + '/" << program_name_ << "_types'" <<
endl <<
+    "require File.dirname(__FILE__) + '/" << underscore(program_name_) << "_types'"
<< endl <<
     endl;
     begin_namespace(f_consts_, ruby_modules(program_));
 
@@ -231,7 +231,7 @@
   const vector<t_program*>& includes = program_->get_includes();
   string result = "";
   for (size_t i = 0; i < includes.size(); ++i) {
-    result += "require '" + includes[i]->get_name() + "_types'\n";
+    result += "require '" + underscore(includes[i]->get_name()) + "_types'\n";
   }
   if (includes.size() > 0) {
     result += "\n";
@@ -622,7 +622,7 @@
  * @param tservice The service definition
  */
 void t_rb_generator::generate_service(t_service* tservice) {
-  string f_service_name = get_out_dir()+service_name_+".rb";
+  string f_service_name = get_out_dir()+underscore(service_name_)+".rb";
   f_service_.open(f_service_name.c_str());
 
   f_service_ <<
@@ -631,11 +631,11 @@
 
   if (tservice->get_extends() != NULL) {
     f_service_ <<
-      "require '" << tservice->get_extends()->get_name() << "'" <<
endl;
+      "require '" << underscore(tservice->get_extends()->get_name()) <<
"'" << endl;
   }
 
   f_service_ <<
-    "require File.dirname(__FILE__) + '/" << program_name_ << "_types'" <<
endl <<
+    "require File.dirname(__FILE__) + '/" << underscore(program_name_) << "_types'"
<< endl <<
     endl;
 
   begin_namespace(f_service_, ruby_modules(tservice->get_program()));

Modified: incubator/thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb?rev=762907&r1=762906&r2=762907&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/binary_protocol_accelerated_spec.rb Tue Apr  7 19:09:28
2009
@@ -19,7 +19,7 @@
 
 require File.dirname(__FILE__) + '/spec_helper'
 require File.dirname(__FILE__) + '/binary_protocol_spec_shared'
-require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
+require File.dirname(__FILE__) + '/gen-rb/thrift_spec_types'
 
 class ThriftBinaryProtocolAcceleratedSpec < Spec::ExampleGroup
   include Thrift

Modified: incubator/thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb?rev=762907&r1=762906&r2=762907&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/nonblocking_server_spec.rb Tue Apr  7 19:09:28 2009
@@ -18,7 +18,7 @@
 #
 
 require File.dirname(__FILE__) + '/spec_helper'
-require File.dirname(__FILE__) + '/gen-rb/NonblockingService'
+require File.dirname(__FILE__) + '/gen-rb/nonblocking_service'
 
 class ThriftNonblockingServerSpec < Spec::ExampleGroup
   include Thrift

Modified: incubator/thrift/trunk/lib/rb/spec/serializer_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/serializer_spec.rb?rev=762907&r1=762906&r2=762907&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/serializer_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/serializer_spec.rb Tue Apr  7 19:09:28 2009
@@ -18,7 +18,7 @@
 #
 
 require File.dirname(__FILE__) + '/spec_helper'
-require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
+require File.dirname(__FILE__) + '/gen-rb/thrift_spec_types'
 
 class ThriftSerializerSpec < Spec::ExampleGroup
   include Thrift

Modified: incubator/thrift/trunk/lib/rb/spec/struct_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/struct_spec.rb?rev=762907&r1=762906&r2=762907&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/struct_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/struct_spec.rb Tue Apr  7 19:09:28 2009
@@ -18,7 +18,7 @@
 #
 
 require File.dirname(__FILE__) + '/spec_helper'
-require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
+require File.dirname(__FILE__) + '/gen-rb/thrift_spec_types'
 
 class ThriftStructSpec < Spec::ExampleGroup
   include Thrift

Modified: incubator/thrift/trunk/lib/rb/spec/types_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/types_spec.rb?rev=762907&r1=762906&r2=762907&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/types_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/types_spec.rb Tue Apr  7 19:09:28 2009
@@ -18,7 +18,7 @@
 #
 
 require File.dirname(__FILE__) + '/spec_helper'
-require File.dirname(__FILE__) + '/gen-rb/ThriftSpec_types'
+require File.dirname(__FILE__) + '/gen-rb/thrift_spec_types'
 
 class ThriftTypesSpec < Spec::ExampleGroup
   include Thrift



Mime
View raw message