You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by ro...@apache.org on 2013/05/06 00:00:29 UTC

git commit: THRIFT-1760 [Ruby] Remove unnecessary native protocol code Patch: Nathan Beyer

Updated Branches:
  refs/heads/master 7f1df9924 -> 4f623260b


THRIFT-1760 [Ruby] Remove unnecessary native protocol code
Patch: Nathan Beyer


Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/4f623260
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/4f623260
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/4f623260

Branch: refs/heads/master
Commit: 4f623260b5c22c7719f5730c94f999f3d53eb425
Parents: 7f1df99
Author: Roger Meier <ro...@apache.org>
Authored: Sun May 5 23:59:25 2013 +0200
Committer: Roger Meier <ro...@apache.org>
Committed: Sun May 5 23:59:25 2013 +0200

----------------------------------------------------------------------
 lib/rb/ext/constants.h     |    6 +-
 lib/rb/ext/protocol.c      |  185 ---------------------------------------
 lib/rb/ext/protocol.h      |   20 ----
 lib/rb/ext/thrift_native.c |   12 +---
 4 files changed, 2 insertions(+), 221 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/thrift/blob/4f623260/lib/rb/ext/constants.h
----------------------------------------------------------------------
diff --git a/lib/rb/ext/constants.h b/lib/rb/ext/constants.h
index 3bfac88..76947e5 100644
--- a/lib/rb/ext/constants.h
+++ b/lib/rb/ext/constants.h
@@ -48,7 +48,6 @@ extern ID write_list_begin_method_id;
 extern ID write_list_end_method_id;
 extern ID write_set_begin_method_id;
 extern ID write_set_end_method_id;
-extern ID size_method_id;
 extern ID read_bool_method_id;
 extern ID read_byte_method_id;
 extern ID read_i16_method_id;
@@ -67,15 +66,12 @@ extern ID read_struct_end_method_id;
 extern ID read_field_begin_method_id;
 extern ID read_field_end_method_id;
 extern ID keys_method_id;
-extern ID entries_method_id; 
-extern ID name_method_id; 
-extern ID sort_method_id;
+extern ID entries_method_id;
 extern ID write_field_stop_method_id;
 extern ID skip_method_id;
 extern ID write_method_id;
 extern ID read_all_method_id;
 extern ID read_into_buffer_method_id;
-extern ID native_qmark_method_id;
 extern ID force_binary_encoding_id;
 extern ID convert_to_utf8_byte_buffer_id;
 extern ID convert_to_string_id;

http://git-wip-us.apache.org/repos/asf/thrift/blob/4f623260/lib/rb/ext/protocol.c
----------------------------------------------------------------------
diff --git a/lib/rb/ext/protocol.c b/lib/rb/ext/protocol.c
index c187654..e69de29 100644
--- a/lib/rb/ext/protocol.c
+++ b/lib/rb/ext/protocol.c
@@ -1,185 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-#include <ruby.h>
-#include <protocol.h>
-#include <stdbool.h>
-#include <constants.h>
-#include <struct.h>
-
-static VALUE skip(VALUE self, int ttype) {
-  if (ttype == TTYPE_STOP) {
-    return Qnil;
-  } else if (ttype == TTYPE_BOOL) {
-    rb_funcall(self, read_bool_method_id, 0);
-  } else if (ttype == TTYPE_BYTE) {
-    rb_funcall(self, read_byte_method_id, 0);
-  } else if (ttype == TTYPE_I16) {
-    rb_funcall(self, read_i16_method_id, 0);
-  } else if (ttype == TTYPE_I32) {
-    rb_funcall(self, read_i32_method_id, 0);
-  } else if (ttype == TTYPE_I64) {
-    rb_funcall(self, read_i64_method_id, 0);
-  } else if (ttype == TTYPE_DOUBLE) {
-    rb_funcall(self, read_double_method_id, 0);
-  } else if (ttype == TTYPE_STRING) {
-    rb_funcall(self, read_string_method_id, 0);
-  } else if (ttype == TTYPE_STRUCT) {
-    rb_funcall(self, read_struct_begin_method_id, 0);
-    while (true) {
-      VALUE field_header = rb_funcall(self, read_field_begin_method_id, 0);
-      if (NIL_P(field_header) || FIX2INT(rb_ary_entry(field_header, 1)) == TTYPE_STOP ) {
-        break;
-      } 
-      skip(self, FIX2INT(rb_ary_entry(field_header, 1)));
-      rb_funcall(self, read_field_end_method_id, 0);
-    }
-    rb_funcall(self, read_struct_end_method_id, 0);
-  } else if (ttype == TTYPE_MAP) {
-    int i;
-    VALUE map_header = rb_funcall(self, read_map_begin_method_id, 0);
-    int ktype = FIX2INT(rb_ary_entry(map_header, 0));
-    int vtype = FIX2INT(rb_ary_entry(map_header, 1));
-    int size = FIX2INT(rb_ary_entry(map_header, 2));
-    
-    for (i = 0; i < size; i++) {
-      skip(self, ktype);
-      skip(self, vtype);
-    }
-    rb_funcall(self, read_map_end_method_id, 0);
-  } else if (ttype == TTYPE_LIST || ttype == TTYPE_SET) {
-    int i;
-    VALUE collection_header = rb_funcall(self, ttype == TTYPE_LIST ? read_list_begin_method_id : read_set_begin_method_id, 0);
-    int etype = FIX2INT(rb_ary_entry(collection_header, 0));
-    int size = FIX2INT(rb_ary_entry(collection_header, 1));
-    for (i = 0; i < size; i++) {
-      skip(self, etype);
-    }
-    rb_funcall(self, ttype == TTYPE_LIST ? read_list_end_method_id : read_set_end_method_id, 0);
-  } else {
-    rb_raise(rb_eNotImpError, "don't know how to skip type %d", ttype);
-  }
-
-  return Qnil;
-}
-
-VALUE rb_thrift_protocol_native_qmark(VALUE self) {
-  return Qfalse;
-}
-
-VALUE rb_thrift_protocol_skip(VALUE protocol, VALUE ttype) {
-  return skip(protocol, FIX2INT(ttype));
-}
-
-VALUE rb_thrift_write_message_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thrift_write_struct_begin(VALUE self, VALUE name) {
-  return Qnil;
-}
-
-VALUE rb_thrift_write_struct_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thrift_write_field_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thrift_write_map_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thrift_write_list_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thrift_write_set_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thrift_read_message_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thift_read_struct_begin(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thift_read_struct_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thift_read_field_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thift_read_map_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thift_read_list_end(VALUE self) {
-  return Qnil;
-}
-
-VALUE rb_thift_read_set_end(VALUE self) {
-  return Qnil;
-}
-
-void Init_protocol() {
-  VALUE c_protocol = rb_const_get(thrift_module, rb_intern("BaseProtocol"));
-  
-  rb_define_method(c_protocol, "skip", rb_thrift_protocol_skip, 1);
-  rb_define_method(c_protocol, "write_message_end", rb_thrift_write_message_end, 0);
-  rb_define_method(c_protocol, "write_struct_begin", rb_thrift_write_struct_begin, 1);
-  rb_define_method(c_protocol, "write_struct_end", rb_thrift_write_struct_end, 0);
-  rb_define_method(c_protocol, "write_field_end", rb_thrift_write_field_end, 0);
-  rb_define_method(c_protocol, "write_map_end", rb_thrift_write_map_end, 0);
-  rb_define_method(c_protocol, "write_list_end", rb_thrift_write_list_end, 0);
-  rb_define_method(c_protocol, "write_set_end", rb_thrift_write_set_end, 0);
-  rb_define_method(c_protocol, "read_message_end", rb_thrift_read_message_end, 0);
-  rb_define_method(c_protocol, "read_struct_begin", rb_thift_read_struct_begin, 0);
-  rb_define_method(c_protocol, "read_struct_end", rb_thift_read_struct_end, 0);
-  rb_define_method(c_protocol, "read_field_end", rb_thift_read_field_end, 0);
-  rb_define_method(c_protocol, "read_map_end", rb_thift_read_map_end, 0);
-  rb_define_method(c_protocol, "read_list_end", rb_thift_read_list_end, 0);
-  rb_define_method(c_protocol, "read_set_end", rb_thift_read_set_end, 0);
-  rb_define_method(c_protocol, "native?", rb_thrift_protocol_native_qmark, 0);
-  
-  // native_proto_method_table *npmt;
-  // npmt = ALLOC(native_proto_method_table);
-  // npmt->write_message_end = rb_thrift_write_message_end;
-  // npmt->write_struct_begin = rb_thrift_write_struct_begin;
-  // npmt->write_struct_end = rb_thrift_write_struct_end;
-  // npmt->write_field_end = rb_thrift_write_field_end;
-  // npmt->write_map_end = rb_thrift_write_map_end;
-  // npmt->write_list_end = rb_thrift_write_list_end;
-  // npmt->write_set_end = rb_thrift_write_set_end;
-  // npmt->read_message_end = rb_thrift_read_message_end;
-  // npmt->read_struct_begin = rb_thift_read_struct_begin;
-  // npmt->read_struct_end = rb_thift_read_struct_end;
-  // npmt->read_field_end = rb_thift_read_field_end;
-  // npmt->read_map_end = rb_thift_read_map_end;
-  // npmt->read_list_end = rb_thift_read_list_end;
-  // npmt->read_set_end = rb_thift_read_set_end;
-  // 
-  // VALUE method_table_object = Data_Wrap_Struct(rb_cObject, 0, free, npmt);
-  // rb_const_set(c_protocol, rb_intern("@native_method_table"), method_table_object);
-}

http://git-wip-us.apache.org/repos/asf/thrift/blob/4f623260/lib/rb/ext/protocol.h
----------------------------------------------------------------------
diff --git a/lib/rb/ext/protocol.h b/lib/rb/ext/protocol.h
index 5369530..e69de29 100644
--- a/lib/rb/ext/protocol.h
+++ b/lib/rb/ext/protocol.h
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-void Init_protocol();

http://git-wip-us.apache.org/repos/asf/thrift/blob/4f623260/lib/rb/ext/thrift_native.c
----------------------------------------------------------------------
diff --git a/lib/rb/ext/thrift_native.c b/lib/rb/ext/thrift_native.c
index f066d6c..614f2dd 100644
--- a/lib/rb/ext/thrift_native.c
+++ b/lib/rb/ext/thrift_native.c
@@ -22,7 +22,6 @@
 #include <struct.h>
 #include <binary_protocol_accelerated.h>
 #include <compact_protocol.h>
-#include <protocol.h>
 #include <memory_buffer.h>
 
 // cached classes/modules
@@ -64,7 +63,6 @@ ID write_list_begin_method_id;
 ID write_list_end_method_id;
 ID write_set_begin_method_id;
 ID write_set_end_method_id;
-ID size_method_id;
 ID read_bool_method_id;
 ID read_byte_method_id;
 ID read_i16_method_id;
@@ -83,15 +81,12 @@ ID read_struct_end_method_id;
 ID read_field_begin_method_id;
 ID read_field_end_method_id;
 ID keys_method_id;
-ID entries_method_id; 
-ID name_method_id; 
-ID sort_method_id;
+ID entries_method_id;
 ID write_field_stop_method_id;
 ID skip_method_id;
 ID write_method_id;
 ID read_all_method_id;
 ID read_into_buffer_method_id;
-ID native_qmark_method_id;
 ID force_binary_encoding_id;
 ID convert_to_utf8_byte_buffer_id;
 ID convert_to_string_id;
@@ -151,7 +146,6 @@ void Init_thrift_native() {
   write_list_end_method_id = rb_intern("write_list_end");
   write_set_begin_method_id = rb_intern("write_set_begin");
   write_set_end_method_id = rb_intern("write_set_end");
-  size_method_id = rb_intern("size");
   read_bool_method_id = rb_intern("read_bool");
   read_byte_method_id = rb_intern("read_byte");
   read_i16_method_id = rb_intern("read_i16");
@@ -171,14 +165,11 @@ void Init_thrift_native() {
   read_field_end_method_id = rb_intern("read_field_end");
   keys_method_id = rb_intern("keys");
   entries_method_id = rb_intern("entries");
-  name_method_id = rb_intern("name");
-  sort_method_id = rb_intern("sort");
   write_field_stop_method_id = rb_intern("write_field_stop");
   skip_method_id = rb_intern("skip");
   write_method_id = rb_intern("write");
   read_all_method_id = rb_intern("read_all");
   read_into_buffer_method_id = rb_intern("read_into_buffer");
-  native_qmark_method_id = rb_intern("native?");
   force_binary_encoding_id = rb_intern("force_binary_encoding");
   convert_to_utf8_byte_buffer_id = rb_intern("convert_to_utf8_byte_buffer");
   convert_to_string_id = rb_intern("convert_to_string");
@@ -197,7 +188,6 @@ void Init_thrift_native() {
   element_sym = ID2SYM(rb_intern("element"));
   class_sym = ID2SYM(rb_intern("class"));
 
-  Init_protocol();
   Init_struct();
   Init_binary_protocol_accelerated();
   Init_compact_protocol();