extern ID write_i64_method_id;
extern ID write_double_method_id;
extern ID write_string_method_id;
+extern ID write_binary_method_id;
extern ID write_map_begin_method_id;
extern ID write_map_end_method_id;
extern ID write_list_begin_method_id;
extern ID read_i32_method_id;
extern ID read_i64_method_id;
extern ID read_string_method_id;
+extern ID read_binary_method_id;
extern ID read_double_method_id;
extern ID read_map_begin_method_id;
extern ID read_map_end_method_id;
extern VALUE value_sym;
extern VALUE element_sym;
extern VALUE class_sym;
+extern VALUE binary_sym;
extern VALUE rb_cSet;
extern VALUE thrift_module;
return Qnil;
}
+VALUE default_write_binary(VALUE protocol, VALUE value) {
+ rb_funcall(protocol, write_binary_method_id, 1, value);
+ return Qnil;
+}
+
VALUE default_write_list_begin(VALUE protocol, VALUE etype, VALUE length) {
rb_funcall(protocol, write_list_begin_method_id, 2, etype, length);
return Qnil;
return rb_funcall(protocol, read_string_method_id, 0);
}
+VALUE default_read_binary(VALUE protocol) {
+ return rb_funcall(protocol, read_binary_method_id, 0);
+}
+
VALUE default_read_struct_begin(VALUE protocol) {
return rb_funcall(protocol, read_struct_begin_method_id, 0);
}
} else if (ttype == TTYPE_DOUBLE) {
default_write_double(protocol, value);
} else if (ttype == TTYPE_STRING) {
- default_write_string(protocol, value);
+ VALUE is_binary = rb_hash_aref(field_info, binary_sym);
+ if (is_binary != Qtrue) {
+ default_write_string(protocol, value);
+ } else {
+ default_write_binary(protocol, value);
+ }
} else if (IS_CONTAINER(ttype)) {
write_container(ttype, field_info, value, protocol);
} else if (ttype == TTYPE_STRUCT) {
} else if (ttype == TTYPE_I64) {
result = default_read_i64(protocol);
} else if (ttype == TTYPE_STRING) {
- result = default_read_string(protocol);
+ VALUE is_binary = rb_hash_aref(field_info, binary_sym);
+ if (is_binary != Qtrue) {
+ result = default_read_string(protocol);
+ } else {
+ result = default_read_binary(protocol);
+ }
} else if (ttype == TTYPE_DOUBLE) {
result = default_read_double(protocol);
} else if (ttype == TTYPE_STRUCT) {
ID write_i64_method_id;
ID write_double_method_id;
ID write_string_method_id;
+ID write_binary_method_id;
ID write_map_begin_method_id;
ID write_map_end_method_id;
ID write_list_begin_method_id;
ID read_i32_method_id;
ID read_i64_method_id;
ID read_string_method_id;
+ID read_binary_method_id;
ID read_double_method_id;
ID read_map_begin_method_id;
ID read_map_end_method_id;
VALUE value_sym;
VALUE element_sym;
VALUE class_sym;
+VALUE binary_sym;
VALUE protocol_exception_class;
void Init_thrift_native() {
write_i64_method_id = rb_intern("write_i64");
write_double_method_id = rb_intern("write_double");
write_string_method_id = rb_intern("write_string");
+ write_binary_method_id = rb_intern("write_binary");
write_map_begin_method_id = rb_intern("write_map_begin");
write_map_end_method_id = rb_intern("write_map_end");
write_list_begin_method_id = rb_intern("write_list_begin");
read_i32_method_id = rb_intern("read_i32");
read_i64_method_id = rb_intern("read_i64");
read_string_method_id = rb_intern("read_string");
+ read_binary_method_id = rb_intern("read_binary");
read_double_method_id = rb_intern("read_double");
read_map_begin_method_id = rb_intern("read_map_begin");
read_map_end_method_id = rb_intern("read_map_end");
value_sym = ID2SYM(rb_intern("value"));
element_sym = ID2SYM(rb_intern("element"));
class_sym = ID2SYM(rb_intern("class"));
+ binary_sym = ID2SYM(rb_intern("binary"));
Init_struct();
Init_binary_protocol_accelerated();