THRIFT-417. rb: BufferedTransport can enter an infinite loop

Switch native proto implementations to use read_all instead of read. Add a bunch of tests to verify. 

Also:
- removed some commented code in binary_protocol_accelerated.c
- struct.c was missing one of the possible native method calls
- updates gem manifest (included files that didn't exist)
- fixed svn:ignores of test/rb/gen-rb and lib/java/gen-java

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@761037 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/rb/ext/binary_protocol_accelerated.c b/lib/rb/ext/binary_protocol_accelerated.c
index 751281e..728a057 100644
--- a/lib/rb/ext/binary_protocol_accelerated.c
+++ b/lib/rb/ext/binary_protocol_accelerated.c
@@ -336,7 +336,7 @@
 
 VALUE rb_thrift_binary_proto_read_bool(VALUE self) {
   char byte = read_byte_direct(self);
-  return byte == 1 ? Qtrue : Qfalse;
+  return byte != 0 ? Qtrue : Qfalse;
 }
 
 VALUE rb_thrift_binary_proto_read_byte(VALUE self) {
diff --git a/lib/rb/ext/constants.h b/lib/rb/ext/constants.h
index 2b18081..57df544 100644
--- a/lib/rb/ext/constants.h
+++ b/lib/rb/ext/constants.h
@@ -73,7 +73,7 @@
 extern ID write_field_stop_method_id;
 extern ID skip_method_id;
 extern ID write_method_id;
-extern ID read_method_id;
+extern ID read_all_method_id;
 extern ID native_qmark_method_id;
 
 extern ID fields_const_id;
diff --git a/lib/rb/ext/macros.h b/lib/rb/ext/macros.h
index 300b1cc..265f693 100644
--- a/lib/rb/ext/macros.h
+++ b/lib/rb/ext/macros.h
@@ -22,7 +22,7 @@
 #define GET_STRICT_WRITE(obj) rb_ivar_get(obj, strict_write_ivar_id)
 #define WRITE(obj, data, length) rb_funcall(obj, write_method_id, 1, rb_str_new(data, length))
 #define CHECK_NIL(obj) if (NIL_P(obj)) { rb_raise(rb_eStandardError, "nil argument not allowed!");}
-#define READ(obj, length) rb_funcall(GET_TRANSPORT(obj), read_method_id, 1, INT2FIX(length))
+#define READ(obj, length) rb_funcall(GET_TRANSPORT(obj), read_all_method_id, 1, INT2FIX(length))
 
 #ifndef RFLOAT_VALUE
 #  define RFLOAT_VALUE(v) RFLOAT(rb_Float(v))->value
diff --git a/lib/rb/ext/struct.c b/lib/rb/ext/struct.c
index 8dd5c3e..fee285e 100644
--- a/lib/rb/ext/struct.c
+++ b/lib/rb/ext/struct.c
@@ -416,11 +416,6 @@
   // call validate
   rb_funcall(self, validate_method_id, 0);
 
-  // if (rb_funcall(protocol, native_qmark_method_id, 0) == Qtrue) {
-  //   set_native_proto_function_pointers(protocol);
-  // } else {
-  //   set_default_proto_function_pointers();
-  // }
   check_native_proto_method_table(protocol);
   
   // write struct begin
@@ -565,7 +560,7 @@
   
   // read each field
   while (true) {
-    VALUE field_header = rb_funcall(protocol, read_field_begin_method_id, 0);
+    VALUE field_header = mt->read_field_begin(protocol);
     VALUE field_type_value = rb_ary_entry(field_header, 1);
     int field_type = FIX2INT(field_type_value);
     
diff --git a/lib/rb/ext/thrift_native.c b/lib/rb/ext/thrift_native.c
index 7e71ad3..effa202 100644
--- a/lib/rb/ext/thrift_native.c
+++ b/lib/rb/ext/thrift_native.c
@@ -87,7 +87,7 @@
 ID write_field_stop_method_id;
 ID skip_method_id;
 ID write_method_id;
-ID read_method_id;
+ID read_all_method_id;
 ID native_qmark_method_id;
 
 // constant ids
@@ -169,7 +169,7 @@
   write_field_stop_method_id = rb_intern("write_field_stop");
   skip_method_id = rb_intern("skip");
   write_method_id = rb_intern("write");
-  read_method_id = rb_intern("read");
+  read_all_method_id = rb_intern("read_all");
   native_qmark_method_id = rb_intern("native?");
   
   // constant ids