THRIFT-248. ruby: Factor BinaryProtocolAccelerated into separate protocol and struct components

This patch replaces the "binaryprotocolaccelerated" c extension with the "thrift_native" c extension. This new extension creates native implementations for the struct.rb #write and #read methods, Thrift::BinaryProtocol, and Thrift::MemoryBuffer, but keeps ruby-level interfaces, allowing all protocols to benefit from the struct code and the memory buffer. There is however an additional cost associated with going through this ruby layer, but the increased interoperability seems to be well worth it.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@739895 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/spec/protocol_spec.rb b/lib/rb/spec/protocol_spec.rb
index 917ca45..a681cd8 100644
--- a/lib/rb/spec/protocol_spec.rb
+++ b/lib/rb/spec/protocol_spec.rb
@@ -1,4 +1,5 @@
 require File.dirname(__FILE__) + '/spec_helper'
+require "thrift_native"
 
 class ThriftProtocolSpec < Spec::ExampleGroup
   include Thrift
@@ -94,18 +95,23 @@
         ['field 3', Types::MAP, 3],
         [nil, Types::STOP, 0]
       )
-      @prot.should_receive(:skip).with(Types::STRING).ordered
-      @prot.should_receive(:skip).with(Types::I32).ordered
-      @prot.should_receive(:skip).with(Types::MAP).ordered
       @prot.should_receive(:read_field_end).exactly(3).times
+      @prot.should_receive(:read_string).exactly(3).times
+      @prot.should_receive(:read_i32).ordered
+      @prot.should_receive(:read_map_begin).ordered.and_return([Types::STRING, Types::STRING, 1])
+      # @prot.should_receive(:read_string).exactly(2).times
+      @prot.should_receive(:read_map_end).ordered
       @prot.should_receive(:read_struct_end).ordered
       real_skip.call(Types::STRUCT)
     end
 
     it "should skip maps" do
       real_skip = @prot.method(:skip)
-      @prot.should_receive(:read_map_begin).ordered.and_return([Types::STRING, Types::STRUCT, 7])
-      @prot.should_receive(:skip).ordered.exactly(14).times # once per key and once per value
+      @prot.should_receive(:read_map_begin).ordered.and_return([Types::STRING, Types::STRUCT, 1])
+      @prot.should_receive(:read_string).ordered
+      @prot.should_receive(:read_struct_begin).ordered.and_return(["some_struct"])
+      @prot.should_receive(:read_field_begin).ordered.and_return([nil, Types::STOP, nil]);
+      @prot.should_receive(:read_struct_end).ordered
       @prot.should_receive(:read_map_end).ordered
       real_skip.call(Types::MAP)
     end
@@ -113,7 +119,7 @@
     it "should skip sets" do
       real_skip = @prot.method(:skip)
       @prot.should_receive(:read_set_begin).ordered.and_return([Types::I64, 9])
-      @prot.should_receive(:skip).with(Types::I64).ordered.exactly(9).times
+      @prot.should_receive(:read_i64).ordered.exactly(9).times
       @prot.should_receive(:read_set_end)
       real_skip.call(Types::SET)
     end
@@ -121,7 +127,7 @@
     it "should skip lists" do
       real_skip = @prot.method(:skip)
       @prot.should_receive(:read_list_begin).ordered.and_return([Types::DOUBLE, 11])
-      @prot.should_receive(:skip).with(Types::DOUBLE).ordered.exactly(11).times
+      @prot.should_receive(:read_double).ordered.exactly(11).times
       @prot.should_receive(:read_list_end)
       real_skip.call(Types::LIST)
     end