fl-thrift 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/CHANGELOG +4 -0
  2. data/Manifest +81 -0
  3. data/README +43 -0
  4. data/Rakefile +102 -0
  5. data/benchmark/Benchmark.thrift +24 -0
  6. data/benchmark/benchmark.rb +271 -0
  7. data/benchmark/client.rb +74 -0
  8. data/benchmark/server.rb +82 -0
  9. data/benchmark/thin_server.rb +44 -0
  10. data/ext/binary_protocol_accelerated.c +474 -0
  11. data/ext/binary_protocol_accelerated.h +20 -0
  12. data/ext/compact_protocol.c +665 -0
  13. data/ext/compact_protocol.h +20 -0
  14. data/ext/constants.h +95 -0
  15. data/ext/extconf.rb +26 -0
  16. data/ext/macros.h +41 -0
  17. data/ext/memory_buffer.c +76 -0
  18. data/ext/memory_buffer.h +20 -0
  19. data/ext/protocol.c +185 -0
  20. data/ext/protocol.h +20 -0
  21. data/ext/struct.c +606 -0
  22. data/ext/struct.h +67 -0
  23. data/ext/thrift_native.c +194 -0
  24. data/lib/thrift.rb +59 -0
  25. data/lib/thrift/client.rb +62 -0
  26. data/lib/thrift/core_ext.rb +23 -0
  27. data/lib/thrift/core_ext/fixnum.rb +29 -0
  28. data/lib/thrift/exceptions.rb +82 -0
  29. data/lib/thrift/processor.rb +57 -0
  30. data/lib/thrift/protocol/base_protocol.rb +290 -0
  31. data/lib/thrift/protocol/binary_protocol.rb +225 -0
  32. data/lib/thrift/protocol/binary_protocol_accelerated.rb +35 -0
  33. data/lib/thrift/protocol/compact_protocol.rb +422 -0
  34. data/lib/thrift/serializer/deserializer.rb +33 -0
  35. data/lib/thrift/serializer/serializer.rb +34 -0
  36. data/lib/thrift/server/base_server.rb +31 -0
  37. data/lib/thrift/server/mongrel_http_server.rb +58 -0
  38. data/lib/thrift/server/nonblocking_server.rb +296 -0
  39. data/lib/thrift/server/simple_server.rb +43 -0
  40. data/lib/thrift/server/thread_pool_server.rb +75 -0
  41. data/lib/thrift/server/threaded_server.rb +47 -0
  42. data/lib/thrift/struct.rb +298 -0
  43. data/lib/thrift/thrift_native.rb +24 -0
  44. data/lib/thrift/transport/base_server_transport.rb +37 -0
  45. data/lib/thrift/transport/base_transport.rb +70 -0
  46. data/lib/thrift/transport/buffered_transport.rb +77 -0
  47. data/lib/thrift/transport/framed_transport.rb +90 -0
  48. data/lib/thrift/transport/http_client_transport.rb +45 -0
  49. data/lib/thrift/transport/io_stream_transport.rb +39 -0
  50. data/lib/thrift/transport/memory_buffer_transport.rb +96 -0
  51. data/lib/thrift/transport/server_socket.rb +63 -0
  52. data/lib/thrift/transport/socket.rb +136 -0
  53. data/lib/thrift/transport/unix_server_socket.rb +60 -0
  54. data/lib/thrift/transport/unix_socket.rb +40 -0
  55. data/lib/thrift/types.rb +101 -0
  56. data/script/proto_benchmark.rb +121 -0
  57. data/script/read_struct.rb +43 -0
  58. data/script/write_struct.rb +30 -0
  59. data/setup.rb +1585 -0
  60. data/spec/ThriftSpec.thrift +84 -0
  61. data/spec/base_protocol_spec.rb +160 -0
  62. data/spec/base_transport_spec.rb +351 -0
  63. data/spec/binary_protocol_accelerated_spec.rb +41 -0
  64. data/spec/binary_protocol_spec.rb +63 -0
  65. data/spec/binary_protocol_spec_shared.rb +375 -0
  66. data/spec/client_spec.rb +100 -0
  67. data/spec/compact_protocol_spec.rb +117 -0
  68. data/spec/exception_spec.rb +142 -0
  69. data/spec/http_client_spec.rb +49 -0
  70. data/spec/mongrel_http_server_spec.rb +117 -0
  71. data/spec/nonblocking_server_spec.rb +265 -0
  72. data/spec/processor_spec.rb +83 -0
  73. data/spec/serializer_spec.rb +69 -0
  74. data/spec/server_socket_spec.rb +80 -0
  75. data/spec/server_spec.rb +160 -0
  76. data/spec/socket_spec.rb +61 -0
  77. data/spec/socket_spec_shared.rb +104 -0
  78. data/spec/spec_helper.rb +60 -0
  79. data/spec/struct_spec.rb +252 -0
  80. data/spec/types_spec.rb +116 -0
  81. data/spec/unix_socket_spec.rb +108 -0
  82. data/thrift.gemspec +32 -0
  83. metadata +202 -0
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ void Init_compact_protocol();
@@ -0,0 +1,95 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ extern int TTYPE_STOP;
21
+ extern int TTYPE_BOOL;
22
+ extern int TTYPE_BYTE;
23
+ extern int TTYPE_I16;
24
+ extern int TTYPE_I32;
25
+ extern int TTYPE_I64;
26
+ extern int TTYPE_DOUBLE;
27
+ extern int TTYPE_STRING;
28
+ extern int TTYPE_MAP;
29
+ extern int TTYPE_SET;
30
+ extern int TTYPE_LIST;
31
+ extern int TTYPE_STRUCT;
32
+
33
+ extern ID validate_method_id;
34
+ extern ID write_struct_begin_method_id;
35
+ extern ID write_struct_end_method_id;
36
+ extern ID write_field_begin_method_id;
37
+ extern ID write_field_end_method_id;
38
+ extern ID write_boolean_method_id;
39
+ extern ID write_byte_method_id;
40
+ extern ID write_i16_method_id;
41
+ extern ID write_i32_method_id;
42
+ extern ID write_i64_method_id;
43
+ extern ID write_double_method_id;
44
+ extern ID write_string_method_id;
45
+ extern ID write_map_begin_method_id;
46
+ extern ID write_map_end_method_id;
47
+ extern ID write_list_begin_method_id;
48
+ extern ID write_list_end_method_id;
49
+ extern ID write_set_begin_method_id;
50
+ extern ID write_set_end_method_id;
51
+ extern ID size_method_id;
52
+ extern ID read_bool_method_id;
53
+ extern ID read_byte_method_id;
54
+ extern ID read_i16_method_id;
55
+ extern ID read_i32_method_id;
56
+ extern ID read_i64_method_id;
57
+ extern ID read_string_method_id;
58
+ extern ID read_double_method_id;
59
+ extern ID read_map_begin_method_id;
60
+ extern ID read_map_end_method_id;
61
+ extern ID read_list_begin_method_id;
62
+ extern ID read_list_end_method_id;
63
+ extern ID read_set_begin_method_id;
64
+ extern ID read_set_end_method_id;
65
+ extern ID read_struct_begin_method_id;
66
+ extern ID read_struct_end_method_id;
67
+ extern ID read_field_begin_method_id;
68
+ extern ID read_field_end_method_id;
69
+ extern ID keys_method_id;
70
+ extern ID entries_method_id;
71
+ extern ID name_method_id;
72
+ extern ID sort_method_id;
73
+ extern ID write_field_stop_method_id;
74
+ extern ID skip_method_id;
75
+ extern ID write_method_id;
76
+ extern ID read_all_method_id;
77
+ extern ID native_qmark_method_id;
78
+
79
+ extern ID fields_const_id;
80
+ extern ID transport_ivar_id;
81
+ extern ID strict_read_ivar_id;
82
+ extern ID strict_write_ivar_id;
83
+
84
+ extern VALUE type_sym;
85
+ extern VALUE name_sym;
86
+ extern VALUE key_sym;
87
+ extern VALUE value_sym;
88
+ extern VALUE element_sym;
89
+ extern VALUE class_sym;
90
+
91
+ extern VALUE rb_cSet;
92
+ extern VALUE thrift_module;
93
+ extern VALUE thrift_types_module;
94
+ extern VALUE class_thrift_protocol;
95
+ extern VALUE protocol_exception_class;
@@ -0,0 +1,26 @@
1
+ #
2
+ # Licensed to the Apache Software Foundation (ASF) under one
3
+ # or more contributor license agreements. See the NOTICE file
4
+ # distributed with this work for additional information
5
+ # regarding copyright ownership. The ASF licenses this file
6
+ # to you under the Apache License, Version 2.0 (the
7
+ # "License"); you may not use this file except in compliance
8
+ # with the License. You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing,
13
+ # software distributed under the License is distributed on an
14
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ # KIND, either express or implied. See the License for the
16
+ # specific language governing permissions and limitations
17
+ # under the License.
18
+ #
19
+
20
+ require 'mkmf'
21
+
22
+ $CFLAGS = "-g -O2 -Wall"
23
+
24
+ have_func("strlcpy", "string.h")
25
+
26
+ create_makefile 'thrift_native'
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ #define GET_TRANSPORT(obj) rb_ivar_get(obj, transport_ivar_id)
21
+ #define GET_STRICT_READ(obj) rb_ivar_get(obj, strict_read_ivar_id)
22
+ #define GET_STRICT_WRITE(obj) rb_ivar_get(obj, strict_write_ivar_id)
23
+ #define WRITE(obj, data, length) rb_funcall(obj, write_method_id, 1, rb_str_new(data, length))
24
+ #define CHECK_NIL(obj) if (NIL_P(obj)) { rb_raise(rb_eStandardError, "nil argument not allowed!");}
25
+ #define READ(obj, length) rb_funcall(GET_TRANSPORT(obj), read_all_method_id, 1, INT2FIX(length))
26
+
27
+ #ifndef RFLOAT_VALUE
28
+ # define RFLOAT_VALUE(v) RFLOAT(rb_Float(v))->value
29
+ #endif
30
+
31
+ #ifndef RSTRING_LEN
32
+ # define RSTRING_LEN(v) RSTRING(rb_String(v))->len
33
+ #endif
34
+
35
+ #ifndef RSTRING_PTR
36
+ # define RSTRING_PTR(v) RSTRING(rb_String(v))->ptr
37
+ #endif
38
+
39
+ #ifndef RARRAY_LEN
40
+ # define RARRAY_LEN(v) RARRAY(rb_Array(v))->len
41
+ #endif
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ #include <ruby.h>
21
+ #include <constants.h>
22
+ #include "macros.h"
23
+
24
+ ID buf_ivar_id;
25
+ ID index_ivar_id;
26
+
27
+ ID slice_method_id;
28
+
29
+ int GARBAGE_BUFFER_SIZE;
30
+
31
+ #define GET_BUF(self) rb_ivar_get(self, buf_ivar_id)
32
+
33
+ VALUE rb_thrift_memory_buffer_write(VALUE self, VALUE str) {
34
+ VALUE buf = GET_BUF(self);
35
+ rb_str_buf_cat(buf, RSTRING_PTR(str), RSTRING_LEN(str));
36
+ return Qnil;
37
+ }
38
+
39
+ VALUE rb_thrift_memory_buffer_read(VALUE self, VALUE length_value) {
40
+ int length = FIX2INT(length_value);
41
+
42
+ VALUE index_value = rb_ivar_get(self, index_ivar_id);
43
+ int index = FIX2INT(index_value);
44
+
45
+ VALUE buf = GET_BUF(self);
46
+ VALUE data = rb_funcall(buf, slice_method_id, 2, index_value, length_value);
47
+
48
+ index += length;
49
+ if (index > RSTRING_LEN(buf)) {
50
+ index = RSTRING_LEN(buf);
51
+ }
52
+ if (index >= GARBAGE_BUFFER_SIZE) {
53
+ rb_ivar_set(self, buf_ivar_id, rb_funcall(buf, slice_method_id, 2, INT2FIX(index), INT2FIX(RSTRING_LEN(buf) - 1)));
54
+ index = 0;
55
+ }
56
+
57
+ if (RSTRING_LEN(data) < length) {
58
+ rb_raise(rb_eEOFError, "Not enough bytes remain in memory buffer");
59
+ }
60
+
61
+ rb_ivar_set(self, index_ivar_id, INT2FIX(index));
62
+ return data;
63
+ }
64
+
65
+ void Init_memory_buffer() {
66
+ VALUE thrift_memory_buffer_class = rb_const_get(thrift_module, rb_intern("MemoryBufferTransport"));
67
+ rb_define_method(thrift_memory_buffer_class, "write", rb_thrift_memory_buffer_write, 1);
68
+ rb_define_method(thrift_memory_buffer_class, "read", rb_thrift_memory_buffer_read, 1);
69
+
70
+ buf_ivar_id = rb_intern("@buf");
71
+ index_ivar_id = rb_intern("@index");
72
+
73
+ slice_method_id = rb_intern("slice");
74
+
75
+ GARBAGE_BUFFER_SIZE = FIX2INT(rb_const_get(thrift_memory_buffer_class, rb_intern("GARBAGE_BUFFER_SIZE")));
76
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ void Init_memory_buffer();
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Licensed to the Apache Software Foundation (ASF) under one
3
+ * or more contributor license agreements. See the NOTICE file
4
+ * distributed with this work for additional information
5
+ * regarding copyright ownership. The ASF licenses this file
6
+ * to you under the Apache License, Version 2.0 (the
7
+ * "License"); you may not use this file except in compliance
8
+ * with the License. You may obtain a copy of the License at
9
+ *
10
+ * http://www.apache.org/licenses/LICENSE-2.0
11
+ *
12
+ * Unless required by applicable law or agreed to in writing,
13
+ * software distributed under the License is distributed on an
14
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ * KIND, either express or implied. See the License for the
16
+ * specific language governing permissions and limitations
17
+ * under the License.
18
+ */
19
+
20
+ #include <ruby.h>
21
+ #include <protocol.h>
22
+ #include <stdbool.h>
23
+ #include <constants.h>
24
+ #include <struct.h>
25
+
26
+ static VALUE skip(VALUE self, int ttype) {
27
+ if (ttype == TTYPE_STOP) {
28
+ return Qnil;
29
+ } else if (ttype == TTYPE_BOOL) {
30
+ rb_funcall(self, read_bool_method_id, 0);
31
+ } else if (ttype == TTYPE_BYTE) {
32
+ rb_funcall(self, read_byte_method_id, 0);
33
+ } else if (ttype == TTYPE_I16) {
34
+ rb_funcall(self, read_i16_method_id, 0);
35
+ } else if (ttype == TTYPE_I32) {
36
+ rb_funcall(self, read_i32_method_id, 0);
37
+ } else if (ttype == TTYPE_I64) {
38
+ rb_funcall(self, read_i64_method_id, 0);
39
+ } else if (ttype == TTYPE_DOUBLE) {
40
+ rb_funcall(self, read_double_method_id, 0);
41
+ } else if (ttype == TTYPE_STRING) {
42
+ rb_funcall(self, read_string_method_id, 0);
43
+ } else if (ttype == TTYPE_STRUCT) {
44
+ rb_funcall(self, read_struct_begin_method_id, 0);
45
+ while (true) {
46
+ VALUE field_header = rb_funcall(self, read_field_begin_method_id, 0);
47
+ if (NIL_P(field_header) || FIX2INT(rb_ary_entry(field_header, 1)) == TTYPE_STOP ) {
48
+ break;
49
+ }
50
+ skip(self, FIX2INT(rb_ary_entry(field_header, 1)));
51
+ rb_funcall(self, read_field_end_method_id, 0);
52
+ }
53
+ rb_funcall(self, read_struct_end_method_id, 0);
54
+ } else if (ttype == TTYPE_MAP) {
55
+ int i;
56
+ VALUE map_header = rb_funcall(self, read_map_begin_method_id, 0);
57
+ int ktype = FIX2INT(rb_ary_entry(map_header, 0));
58
+ int vtype = FIX2INT(rb_ary_entry(map_header, 1));
59
+ int size = FIX2INT(rb_ary_entry(map_header, 2));
60
+
61
+ for (i = 0; i < size; i++) {
62
+ skip(self, ktype);
63
+ skip(self, vtype);
64
+ }
65
+ rb_funcall(self, read_map_end_method_id, 0);
66
+ } else if (ttype == TTYPE_LIST || ttype == TTYPE_SET) {
67
+ int i;
68
+ VALUE collection_header = rb_funcall(self, ttype == TTYPE_LIST ? read_list_begin_method_id : read_set_begin_method_id, 0);
69
+ int etype = FIX2INT(rb_ary_entry(collection_header, 0));
70
+ int size = FIX2INT(rb_ary_entry(collection_header, 1));
71
+ for (i = 0; i < size; i++) {
72
+ skip(self, etype);
73
+ }
74
+ rb_funcall(self, ttype == TTYPE_LIST ? read_list_end_method_id : read_set_end_method_id, 0);
75
+ } else {
76
+ rb_raise(rb_eNotImpError, "don't know how to skip type %d", ttype);
77
+ }
78
+
79
+ return Qnil;
80
+ }
81
+
82
+ VALUE rb_thrift_protocol_native_qmark(VALUE self) {
83
+ return Qfalse;
84
+ }
85
+
86
+ VALUE rb_thrift_protocol_skip(VALUE protocol, VALUE ttype) {
87
+ return skip(protocol, FIX2INT(ttype));
88
+ }
89
+
90
+ VALUE rb_thrift_write_message_end(VALUE self) {
91
+ return Qnil;
92
+ }
93
+
94
+ VALUE rb_thrift_write_struct_begin(VALUE self, VALUE name) {
95
+ return Qnil;
96
+ }
97
+
98
+ VALUE rb_thrift_write_struct_end(VALUE self) {
99
+ return Qnil;
100
+ }
101
+
102
+ VALUE rb_thrift_write_field_end(VALUE self) {
103
+ return Qnil;
104
+ }
105
+
106
+ VALUE rb_thrift_write_map_end(VALUE self) {
107
+ return Qnil;
108
+ }
109
+
110
+ VALUE rb_thrift_write_list_end(VALUE self) {
111
+ return Qnil;
112
+ }
113
+
114
+ VALUE rb_thrift_write_set_end(VALUE self) {
115
+ return Qnil;
116
+ }
117
+
118
+ VALUE rb_thrift_read_message_end(VALUE self) {
119
+ return Qnil;
120
+ }
121
+
122
+ VALUE rb_thift_read_struct_begin(VALUE self) {
123
+ return Qnil;
124
+ }
125
+
126
+ VALUE rb_thift_read_struct_end(VALUE self) {
127
+ return Qnil;
128
+ }
129
+
130
+ VALUE rb_thift_read_field_end(VALUE self) {
131
+ return Qnil;
132
+ }
133
+
134
+ VALUE rb_thift_read_map_end(VALUE self) {
135
+ return Qnil;
136
+ }
137
+
138
+ VALUE rb_thift_read_list_end(VALUE self) {
139
+ return Qnil;
140
+ }
141
+
142
+ VALUE rb_thift_read_set_end(VALUE self) {
143
+ return Qnil;
144
+ }
145
+
146
+ void Init_protocol() {
147
+ VALUE c_protocol = rb_const_get(thrift_module, rb_intern("BaseProtocol"));
148
+
149
+ rb_define_method(c_protocol, "skip", rb_thrift_protocol_skip, 1);
150
+ rb_define_method(c_protocol, "write_message_end", rb_thrift_write_message_end, 0);
151
+ rb_define_method(c_protocol, "write_struct_begin", rb_thrift_write_struct_begin, 1);
152
+ rb_define_method(c_protocol, "write_struct_end", rb_thrift_write_struct_end, 0);
153
+ rb_define_method(c_protocol, "write_field_end", rb_thrift_write_field_end, 0);
154
+ rb_define_method(c_protocol, "write_map_end", rb_thrift_write_map_end, 0);
155
+ rb_define_method(c_protocol, "write_list_end", rb_thrift_write_list_end, 0);
156
+ rb_define_method(c_protocol, "write_set_end", rb_thrift_write_set_end, 0);
157
+ rb_define_method(c_protocol, "read_message_end", rb_thrift_read_message_end, 0);
158
+ rb_define_method(c_protocol, "read_struct_begin", rb_thift_read_struct_begin, 0);
159
+ rb_define_method(c_protocol, "read_struct_end", rb_thift_read_struct_end, 0);
160
+ rb_define_method(c_protocol, "read_field_end", rb_thift_read_field_end, 0);
161
+ rb_define_method(c_protocol, "read_map_end", rb_thift_read_map_end, 0);
162
+ rb_define_method(c_protocol, "read_list_end", rb_thift_read_list_end, 0);
163
+ rb_define_method(c_protocol, "read_set_end", rb_thift_read_set_end, 0);
164
+ rb_define_method(c_protocol, "native?", rb_thrift_protocol_native_qmark, 0);
165
+
166
+ // native_proto_method_table *npmt;
167
+ // npmt = ALLOC(native_proto_method_table);
168
+ // npmt->write_message_end = rb_thrift_write_message_end;
169
+ // npmt->write_struct_begin = rb_thrift_write_struct_begin;
170
+ // npmt->write_struct_end = rb_thrift_write_struct_end;
171
+ // npmt->write_field_end = rb_thrift_write_field_end;
172
+ // npmt->write_map_end = rb_thrift_write_map_end;
173
+ // npmt->write_list_end = rb_thrift_write_list_end;
174
+ // npmt->write_set_end = rb_thrift_write_set_end;
175
+ // npmt->read_message_end = rb_thrift_read_message_end;
176
+ // npmt->read_struct_begin = rb_thift_read_struct_begin;
177
+ // npmt->read_struct_end = rb_thift_read_struct_end;
178
+ // npmt->read_field_end = rb_thift_read_field_end;
179
+ // npmt->read_map_end = rb_thift_read_map_end;
180
+ // npmt->read_list_end = rb_thift_read_list_end;
181
+ // npmt->read_set_end = rb_thift_read_set_end;
182
+ //
183
+ // VALUE method_table_object = Data_Wrap_Struct(rb_cObject, 0, free, npmt);
184
+ // rb_const_set(c_protocol, rb_intern("@native_method_table"), method_table_object);
185
+ }