You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/11/14 18:11:40 UTC
svn commit: r714070 - in /incubator/thrift/trunk:
compiler/cpp/src/generate/t_rb_generator.cc lib/rb/Rakefile
lib/rb/lib/thrift/struct.rb lib/rb/spec/ThriftSpec.thrift
lib/rb/spec/gen-rb/ThriftSpec_types.rb lib/rb/spec/struct_spec.rb
Author: kclark
Date: Fri Nov 14 09:11:39 2008
New Revision: 714070
URL: http://svn.apache.org/viewvc?rev=714070&view=rev
Log:
Merge branch 'THRIFT-143'
Modified:
incubator/thrift/trunk/compiler/cpp/src/generate/t_rb_generator.cc
incubator/thrift/trunk/lib/rb/Rakefile
incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
incubator/thrift/trunk/lib/rb/spec/ThriftSpec.thrift
incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb
incubator/thrift/trunk/lib/rb/spec/struct_spec.rb
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=714070&r1=714069&r2=714070&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 Fri Nov 14 09:11:39 2008
@@ -448,7 +448,7 @@
generate_rdoc(out, tstruct);
indent(out) << "class " << type_name(tstruct);
if (is_exception) {
- out << " < StandardError";
+ out << " < Thrift::Exception";
}
out << endl;
Modified: incubator/thrift/trunk/lib/rb/Rakefile
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/Rakefile?rev=714070&r1=714069&r2=714070&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/Rakefile (original)
+++ incubator/thrift/trunk/lib/rb/Rakefile Fri Nov 14 09:11:39 2008
@@ -4,7 +4,7 @@
THRIFT = '../../compiler/cpp/thrift'
-task :default => [:spec, :test]
+task :default => [:'gen-rb', :spec, :test]
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
Modified: incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb?rev=714070&r1=714069&r2=714070&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/struct.rb Fri Nov 14 09:11:39 2008
@@ -82,6 +82,7 @@
end
def read(iprot)
+ validate
# TODO(kevinclark): Make sure transport is C readable
if iprot.respond_to?(:decode_binary)
iprot.decode_binary(self, iprot.trans)
Modified: incubator/thrift/trunk/lib/rb/spec/ThriftSpec.thrift
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/ThriftSpec.thrift?rev=714070&r1=714069&r2=714070&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/ThriftSpec.thrift (original)
+++ incubator/thrift/trunk/lib/rb/spec/ThriftSpec.thrift Fri Nov 14 09:11:39 2008
@@ -32,6 +32,11 @@
11: list<Hello> hellos
}
+exception Xception {
+ 1: string message,
+ 2: i32 code = 1
+}
+
service NonblockingService {
Hello greeting(1:bool english)
bool block()
Modified: incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb?rev=714070&r1=714069&r2=714070&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/gen-rb/ThriftSpec_types.rb Fri Nov 14 09:11:39 2008
@@ -96,6 +96,24 @@
SETS => {:type => Thrift::Types::LIST, :name => 'sets', :element => {:type => Thrift::Types::SET, :element => {:type => Thrift::Types::I16}}},
HELLOS => {:type => Thrift::Types::LIST, :name => 'hellos', :element => {:type => Thrift::Types::STRUCT, :class => Hello}}
}
+ def validate
+ end
+
+ end
+
+ class Xception < Thrift::Exception
+ include Thrift::Struct
+ MESSAGE = 1
+ CODE = 2
+
+ Thrift::Struct.field_accessor self, :message, :code
+ FIELDS = {
+ MESSAGE => {:type => Thrift::Types::STRING, :name => 'message'},
+ CODE => {:type => Thrift::Types::I32, :name => 'code', :default => 1}
+ }
+ def validate
+ end
+
end
end
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=714070&r1=714069&r2=714070&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/struct_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/struct_spec.rb Fri Nov 14 09:11:39 2008
@@ -5,15 +5,6 @@
include Thrift
include SpecNamespace
- class Xception < Thrift::Exception
- include Thrift::Struct
- attr_accessor :message, :code
- FIELDS = {
- 1 => {:type => Thrift::Types::STRING, :name => 'message'},
- 2 => {:type => Thrift::Types::I32, :name => 'code', :default => 1}
- }
- end
-
describe Struct do
it "should iterate over all fields properly" do
fields = {}
@@ -209,7 +200,7 @@
e.code.should == 1
# ensure it gets serialized properly, this is the really important part
prot = mock("Protocol")
- prot.should_receive(:write_struct_begin).with("ThriftStructSpec::Xception")
+ prot.should_receive(:write_struct_begin).with("SpecNamespace::Xception")
prot.should_receive(:write_struct_end)
prot.should_receive(:write_field).with('message', Types::STRING, 1, "something happened")
prot.should_receive(:write_field).with('code', Types::I32, 2, 1)
@@ -226,7 +217,7 @@
e.message.should == "something happened"
e.code.should == 5
prot = mock("Protocol")
- prot.should_receive(:write_struct_begin).with("ThriftStructSpec::Xception")
+ prot.should_receive(:write_struct_begin).with("SpecNamespace::Xception")
prot.should_receive(:write_struct_end)
prot.should_receive(:write_field).with('message', Types::STRING, 1, "something happened")
prot.should_receive(:write_field).with('code', Types::I32, 2, 5)