blob: 65cbe5ffecddd8b37ab1a122501eed5192a3411c [file] [log] [blame]
Kevin Clark916f3532009-03-20 04:21:39 +00001/**
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
Bryan Duxburyc0166282009-02-02 00:48:17 +000020#include <ruby.h>
21#include <stdbool.h>
Bryan Duxbury1e80d442009-02-03 18:16:54 +000022#include <stdint.h>
Bryan Duxburyc0166282009-02-02 00:48:17 +000023#include <constants.h>
24#include <struct.h>
Jake Farrellb5a18a12012-10-09 01:10:43 +000025#include <macros.h>
26#include <bytes.h>
Bryan Duxburyc0166282009-02-02 00:48:17 +000027
28VALUE rb_thrift_binary_proto_native_qmark(VALUE self) {
29 return Qtrue;
30}
31
32
33
34static int VERSION_1;
35static int VERSION_MASK;
Kevin Clarkead33822009-02-04 22:43:59 +000036static int TYPE_MASK;
Bryan Duxburyc0166282009-02-02 00:48:17 +000037static int BAD_VERSION;
Bryan Duxburyad0ad822011-06-28 18:46:03 +000038static ID rbuf_ivar_id;
Bryan Duxburyc0166282009-02-02 00:48:17 +000039
40static void write_byte_direct(VALUE trans, int8_t b) {
41 WRITE(trans, (char*)&b, 1);
42}
43
44static void write_i16_direct(VALUE trans, int16_t value) {
45 char data[2];
46
47 data[1] = value;
48 data[0] = (value >> 8);
49
50 WRITE(trans, data, 2);
51}
52
53static void write_i32_direct(VALUE trans, int32_t value) {
54 char data[4];
55
56 data[3] = value;
57 data[2] = (value >> 8);
58 data[1] = (value >> 16);
59 data[0] = (value >> 24);
60
61 WRITE(trans, data, 4);
62}
63
64
65static void write_i64_direct(VALUE trans, int64_t value) {
66 char data[8];
67
68 data[7] = value;
69 data[6] = (value >> 8);
70 data[5] = (value >> 16);
71 data[4] = (value >> 24);
72 data[3] = (value >> 32);
73 data[2] = (value >> 40);
74 data[1] = (value >> 48);
75 data[0] = (value >> 56);
76
77 WRITE(trans, data, 8);
78}
79
80static void write_string_direct(VALUE trans, VALUE str) {
Bryan Duxbury3647fc62009-09-02 20:05:07 +000081 if (TYPE(str) != T_STRING) {
Roger Meier19dbbef2012-12-27 01:24:20 +010082 rb_raise(rb_eStandardError, "Value should be a string");
Bryan Duxbury3647fc62009-09-02 20:05:07 +000083 }
Jake Farrellb5a18a12012-10-09 01:10:43 +000084 str = convert_to_utf8_byte_buffer(str);
Bryan Duxburye3ab50d2009-03-25 21:06:53 +000085 write_i32_direct(trans, RSTRING_LEN(str));
Bryan Duxburyc0166282009-02-02 00:48:17 +000086 rb_funcall(trans, write_method_id, 1, str);
87}
88
89//--------------------------------
90// interface writing methods
91//--------------------------------
92
93VALUE rb_thrift_binary_proto_write_message_end(VALUE self) {
94 return Qnil;
95}
96
97VALUE rb_thrift_binary_proto_write_struct_begin(VALUE self, VALUE name) {
98 return Qnil;
99}
100
101VALUE rb_thrift_binary_proto_write_struct_end(VALUE self) {
102 return Qnil;
103}
104
105VALUE rb_thrift_binary_proto_write_field_end(VALUE self) {
106 return Qnil;
107}
108
109VALUE rb_thrift_binary_proto_write_map_end(VALUE self) {
110 return Qnil;
111}
112
113VALUE rb_thrift_binary_proto_write_list_end(VALUE self) {
114 return Qnil;
115}
116
117VALUE rb_thrift_binary_proto_write_set_end(VALUE self) {
118 return Qnil;
119}
120
121VALUE rb_thrift_binary_proto_write_message_begin(VALUE self, VALUE name, VALUE type, VALUE seqid) {
122 VALUE trans = GET_TRANSPORT(self);
Kevin Clarkead33822009-02-04 22:43:59 +0000123 VALUE strict_write = GET_STRICT_WRITE(self);
124
125 if (strict_write == Qtrue) {
126 write_i32_direct(trans, VERSION_1 | FIX2INT(type));
127 write_string_direct(trans, name);
128 write_i32_direct(trans, FIX2INT(seqid));
129 } else {
130 write_string_direct(trans, name);
Bryan Duxburyd40731e2009-03-20 02:21:05 +0000131 write_byte_direct(trans, FIX2INT(type));
Kevin Clarkead33822009-02-04 22:43:59 +0000132 write_i32_direct(trans, FIX2INT(seqid));
133 }
Bryan Duxburyc0166282009-02-02 00:48:17 +0000134
135 return Qnil;
136}
137
138VALUE rb_thrift_binary_proto_write_field_begin(VALUE self, VALUE name, VALUE type, VALUE id) {
139 VALUE trans = GET_TRANSPORT(self);
140 write_byte_direct(trans, FIX2INT(type));
141 write_i16_direct(trans, FIX2INT(id));
142
143 return Qnil;
144}
145
146VALUE rb_thrift_binary_proto_write_field_stop(VALUE self) {
147 write_byte_direct(GET_TRANSPORT(self), TTYPE_STOP);
148 return Qnil;
149}
150
151VALUE rb_thrift_binary_proto_write_map_begin(VALUE self, VALUE ktype, VALUE vtype, VALUE size) {
152 VALUE trans = GET_TRANSPORT(self);
153 write_byte_direct(trans, FIX2INT(ktype));
154 write_byte_direct(trans, FIX2INT(vtype));
155 write_i32_direct(trans, FIX2INT(size));
156
157 return Qnil;
158}
159
160VALUE rb_thrift_binary_proto_write_list_begin(VALUE self, VALUE etype, VALUE size) {
161 VALUE trans = GET_TRANSPORT(self);
162 write_byte_direct(trans, FIX2INT(etype));
163 write_i32_direct(trans, FIX2INT(size));
164
165 return Qnil;
166}
167
168VALUE rb_thrift_binary_proto_write_set_begin(VALUE self, VALUE etype, VALUE size) {
169 rb_thrift_binary_proto_write_list_begin(self, etype, size);
170 return Qnil;
171}
172
173VALUE rb_thrift_binary_proto_write_bool(VALUE self, VALUE b) {
174 write_byte_direct(GET_TRANSPORT(self), RTEST(b) ? 1 : 0);
175 return Qnil;
176}
177
178VALUE rb_thrift_binary_proto_write_byte(VALUE self, VALUE byte) {
179 CHECK_NIL(byte);
180 write_byte_direct(GET_TRANSPORT(self), NUM2INT(byte));
181 return Qnil;
182}
183
184VALUE rb_thrift_binary_proto_write_i16(VALUE self, VALUE i16) {
185 CHECK_NIL(i16);
186 write_i16_direct(GET_TRANSPORT(self), FIX2INT(i16));
187 return Qnil;
188}
189
190VALUE rb_thrift_binary_proto_write_i32(VALUE self, VALUE i32) {
191 CHECK_NIL(i32);
192 write_i32_direct(GET_TRANSPORT(self), NUM2INT(i32));
193 return Qnil;
194}
195
196VALUE rb_thrift_binary_proto_write_i64(VALUE self, VALUE i64) {
197 CHECK_NIL(i64);
198 write_i64_direct(GET_TRANSPORT(self), NUM2LL(i64));
199 return Qnil;
200}
201
202VALUE rb_thrift_binary_proto_write_double(VALUE self, VALUE dub) {
203 CHECK_NIL(dub);
204 // Unfortunately, bitwise_cast doesn't work in C. Bad C!
205 union {
206 double f;
207 int64_t t;
208 } transfer;
Bryan Duxburye3ab50d2009-03-25 21:06:53 +0000209 transfer.f = RFLOAT_VALUE(rb_Float(dub));
Bryan Duxburyc0166282009-02-02 00:48:17 +0000210 write_i64_direct(GET_TRANSPORT(self), transfer.t);
211
212 return Qnil;
213}
214
215VALUE rb_thrift_binary_proto_write_string(VALUE self, VALUE str) {
216 CHECK_NIL(str);
217 VALUE trans = GET_TRANSPORT(self);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000218 write_string_direct(trans, str);
219 return Qnil;
220}
221
Roger Meier19dbbef2012-12-27 01:24:20 +0100222VALUE rb_thrift_binary_proto_write_binary(VALUE self, VALUE buf) {
223 CHECK_NIL(buf);
224 VALUE trans = GET_TRANSPORT(self);
225 buf = force_binary_encoding(buf);
226 write_i32_direct(trans, RSTRING_LEN(buf));
227 rb_funcall(trans, write_method_id, 1, buf);
228 return Qnil;
229}
230
Bryan Duxburyc0166282009-02-02 00:48:17 +0000231//---------------------------------------
232// interface reading methods
233//---------------------------------------
234
Bryan Duxburyc0166282009-02-02 00:48:17 +0000235VALUE rb_thrift_binary_proto_read_string(VALUE self);
Roger Meier19dbbef2012-12-27 01:24:20 +0100236VALUE rb_thrift_binary_proto_read_binary(VALUE self);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000237VALUE rb_thrift_binary_proto_read_byte(VALUE self);
238VALUE rb_thrift_binary_proto_read_i32(VALUE self);
239VALUE rb_thrift_binary_proto_read_i16(VALUE self);
240
241static char read_byte_direct(VALUE self) {
Bryan Duxburyad0ad822011-06-28 18:46:03 +0000242 VALUE byte = rb_funcall(GET_TRANSPORT(self), read_byte_method_id, 0);
243 return (char)(FIX2INT(byte));
Bryan Duxburyc0166282009-02-02 00:48:17 +0000244}
245
246static int16_t read_i16_direct(VALUE self) {
Bryan Duxburyad0ad822011-06-28 18:46:03 +0000247 VALUE rbuf = rb_ivar_get(self, rbuf_ivar_id);
248 rb_funcall(GET_TRANSPORT(self), read_into_buffer_method_id, 2, rbuf, INT2FIX(2));
249 return (int16_t)(((uint8_t)(RSTRING_PTR(rbuf)[1])) | ((uint16_t)((RSTRING_PTR(rbuf)[0]) << 8)));
Bryan Duxburyc0166282009-02-02 00:48:17 +0000250}
251
252static int32_t read_i32_direct(VALUE self) {
Bryan Duxburyad0ad822011-06-28 18:46:03 +0000253 VALUE rbuf = rb_ivar_get(self, rbuf_ivar_id);
254 rb_funcall(GET_TRANSPORT(self), read_into_buffer_method_id, 2, rbuf, INT2FIX(4));
255 return ((uint8_t)(RSTRING_PTR(rbuf)[3])) |
256 (((uint8_t)(RSTRING_PTR(rbuf)[2])) << 8) |
257 (((uint8_t)(RSTRING_PTR(rbuf)[1])) << 16) |
258 (((uint8_t)(RSTRING_PTR(rbuf)[0])) << 24);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000259}
260
261static int64_t read_i64_direct(VALUE self) {
Bryan Duxburyad0ad822011-06-28 18:46:03 +0000262 VALUE rbuf = rb_ivar_get(self, rbuf_ivar_id);
263 rb_funcall(GET_TRANSPORT(self), read_into_buffer_method_id, 2, rbuf, INT2FIX(8));
264 uint64_t hi = ((uint8_t)(RSTRING_PTR(rbuf)[3])) |
265 (((uint8_t)(RSTRING_PTR(rbuf)[2])) << 8) |
266 (((uint8_t)(RSTRING_PTR(rbuf)[1])) << 16) |
267 (((uint8_t)(RSTRING_PTR(rbuf)[0])) << 24);
268 uint32_t lo = ((uint8_t)(RSTRING_PTR(rbuf)[7])) |
269 (((uint8_t)(RSTRING_PTR(rbuf)[6])) << 8) |
270 (((uint8_t)(RSTRING_PTR(rbuf)[5])) << 16) |
271 (((uint8_t)(RSTRING_PTR(rbuf)[4])) << 24);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000272 return (hi << 32) | lo;
273}
274
275static VALUE get_protocol_exception(VALUE code, VALUE message) {
276 VALUE args[2];
277 args[0] = code;
278 args[1] = message;
279 return rb_class_new_instance(2, (VALUE*)&args, protocol_exception_class);
280}
281
282VALUE rb_thrift_binary_proto_read_message_end(VALUE self) {
283 return Qnil;
284}
285
Roger Meiera2d12b62015-03-24 21:15:06 +0100286VALUE rb_thrift_binary_proto_read_struct_begin(VALUE self) {
Bryan Duxburyc0166282009-02-02 00:48:17 +0000287 return Qnil;
288}
289
Roger Meiera2d12b62015-03-24 21:15:06 +0100290VALUE rb_thrift_binary_proto_read_struct_end(VALUE self) {
Bryan Duxburyc0166282009-02-02 00:48:17 +0000291 return Qnil;
292}
293
Roger Meiera2d12b62015-03-24 21:15:06 +0100294VALUE rb_thrift_binary_proto_read_field_end(VALUE self) {
Bryan Duxburyc0166282009-02-02 00:48:17 +0000295 return Qnil;
296}
297
Roger Meiera2d12b62015-03-24 21:15:06 +0100298VALUE rb_thrift_binary_proto_read_map_end(VALUE self) {
Bryan Duxburyc0166282009-02-02 00:48:17 +0000299 return Qnil;
300}
301
Roger Meiera2d12b62015-03-24 21:15:06 +0100302VALUE rb_thrift_binary_proto_read_list_end(VALUE self) {
Bryan Duxburyc0166282009-02-02 00:48:17 +0000303 return Qnil;
304}
305
Roger Meiera2d12b62015-03-24 21:15:06 +0100306VALUE rb_thrift_binary_proto_read_set_end(VALUE self) {
Bryan Duxburyc0166282009-02-02 00:48:17 +0000307 return Qnil;
308}
309
310VALUE rb_thrift_binary_proto_read_message_begin(VALUE self) {
Kevin Clarkead33822009-02-04 22:43:59 +0000311 VALUE strict_read = GET_STRICT_READ(self);
312 VALUE name, seqid;
313 int type;
Bryan Duxburyc0166282009-02-02 00:48:17 +0000314
Kevin Clarkead33822009-02-04 22:43:59 +0000315 int version = read_i32_direct(self);
316
317 if (version < 0) {
318 if ((version & VERSION_MASK) != VERSION_1) {
319 rb_exc_raise(get_protocol_exception(INT2FIX(BAD_VERSION), rb_str_new2("Missing version identifier")));
320 }
321 type = version & TYPE_MASK;
322 name = rb_thrift_binary_proto_read_string(self);
323 seqid = rb_thrift_binary_proto_read_i32(self);
324 } else {
325 if (strict_read == Qtrue) {
326 rb_exc_raise(get_protocol_exception(INT2FIX(BAD_VERSION), rb_str_new2("No version identifier, old protocol client?")));
327 }
328 name = READ(self, version);
Bryan Duxburyac002d32009-03-31 23:48:36 +0000329 type = read_byte_direct(self);
Kevin Clarkead33822009-02-04 22:43:59 +0000330 seqid = rb_thrift_binary_proto_read_i32(self);
331 }
Bryan Duxburyc0166282009-02-02 00:48:17 +0000332
333 return rb_ary_new3(3, name, INT2FIX(type), seqid);
334}
335
336VALUE rb_thrift_binary_proto_read_field_begin(VALUE self) {
337 int type = read_byte_direct(self);
338 if (type == TTYPE_STOP) {
339 return rb_ary_new3(3, Qnil, INT2FIX(type), INT2FIX(0));
340 } else {
341 VALUE id = rb_thrift_binary_proto_read_i16(self);
342 return rb_ary_new3(3, Qnil, INT2FIX(type), id);
343 }
344}
345
346VALUE rb_thrift_binary_proto_read_map_begin(VALUE self) {
347 VALUE ktype = rb_thrift_binary_proto_read_byte(self);
348 VALUE vtype = rb_thrift_binary_proto_read_byte(self);
349 VALUE size = rb_thrift_binary_proto_read_i32(self);
350 return rb_ary_new3(3, ktype, vtype, size);
351}
352
353VALUE rb_thrift_binary_proto_read_list_begin(VALUE self) {
354 VALUE etype = rb_thrift_binary_proto_read_byte(self);
355 VALUE size = rb_thrift_binary_proto_read_i32(self);
356 return rb_ary_new3(2, etype, size);
357}
358
359VALUE rb_thrift_binary_proto_read_set_begin(VALUE self) {
360 return rb_thrift_binary_proto_read_list_begin(self);
361}
362
363VALUE rb_thrift_binary_proto_read_bool(VALUE self) {
364 char byte = read_byte_direct(self);
Bryan Duxbury5b8b4842009-04-01 20:10:15 +0000365 return byte != 0 ? Qtrue : Qfalse;
Bryan Duxburyc0166282009-02-02 00:48:17 +0000366}
367
368VALUE rb_thrift_binary_proto_read_byte(VALUE self) {
369 return INT2FIX(read_byte_direct(self));
370}
371
372VALUE rb_thrift_binary_proto_read_i16(VALUE self) {
373 return INT2FIX(read_i16_direct(self));
374}
375
376VALUE rb_thrift_binary_proto_read_i32(VALUE self) {
377 return INT2NUM(read_i32_direct(self));
378}
379
380VALUE rb_thrift_binary_proto_read_i64(VALUE self) {
381 return LL2NUM(read_i64_direct(self));
382}
383
384VALUE rb_thrift_binary_proto_read_double(VALUE self) {
385 union {
386 double f;
387 int64_t t;
388 } transfer;
389 transfer.t = read_i64_direct(self);
390 return rb_float_new(transfer.f);
391}
392
393VALUE rb_thrift_binary_proto_read_string(VALUE self) {
Roger Meier19dbbef2012-12-27 01:24:20 +0100394 VALUE buffer = rb_thrift_binary_proto_read_binary(self);
Jake Farrellb5a18a12012-10-09 01:10:43 +0000395 return convert_to_string(buffer);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000396}
397
Roger Meier19dbbef2012-12-27 01:24:20 +0100398VALUE rb_thrift_binary_proto_read_binary(VALUE self) {
399 int size = read_i32_direct(self);
400 return READ(self, size);
401}
402
Bryan Duxburyc0166282009-02-02 00:48:17 +0000403void Init_binary_protocol_accelerated() {
404 VALUE thrift_binary_protocol_class = rb_const_get(thrift_module, rb_intern("BinaryProtocol"));
Bryan Duxburyd2cc5bb2010-07-28 21:00:06 +0000405
Bryan Duxburyc0166282009-02-02 00:48:17 +0000406 VERSION_1 = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_1")));
407 VERSION_MASK = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("VERSION_MASK")));
Kevin Clarkead33822009-02-04 22:43:59 +0000408 TYPE_MASK = rb_num2ll(rb_const_get(thrift_binary_protocol_class, rb_intern("TYPE_MASK")));
Bryan Duxburyd2cc5bb2010-07-28 21:00:06 +0000409
Bryan Duxburyc0166282009-02-02 00:48:17 +0000410 VALUE bpa_class = rb_define_class_under(thrift_module, "BinaryProtocolAccelerated", thrift_binary_protocol_class);
Bryan Duxburyd2cc5bb2010-07-28 21:00:06 +0000411
Bryan Duxburyc0166282009-02-02 00:48:17 +0000412 rb_define_method(bpa_class, "native?", rb_thrift_binary_proto_native_qmark, 0);
Bryan Duxburyd2cc5bb2010-07-28 21:00:06 +0000413
Bryan Duxburyc0166282009-02-02 00:48:17 +0000414 rb_define_method(bpa_class, "write_message_begin", rb_thrift_binary_proto_write_message_begin, 3);
415 rb_define_method(bpa_class, "write_field_begin", rb_thrift_binary_proto_write_field_begin, 3);
416 rb_define_method(bpa_class, "write_field_stop", rb_thrift_binary_proto_write_field_stop, 0);
417 rb_define_method(bpa_class, "write_map_begin", rb_thrift_binary_proto_write_map_begin, 3);
418 rb_define_method(bpa_class, "write_list_begin", rb_thrift_binary_proto_write_list_begin, 2);
419 rb_define_method(bpa_class, "write_set_begin", rb_thrift_binary_proto_write_set_begin, 2);
420 rb_define_method(bpa_class, "write_byte", rb_thrift_binary_proto_write_byte, 1);
421 rb_define_method(bpa_class, "write_bool", rb_thrift_binary_proto_write_bool, 1);
422 rb_define_method(bpa_class, "write_i16", rb_thrift_binary_proto_write_i16, 1);
423 rb_define_method(bpa_class, "write_i32", rb_thrift_binary_proto_write_i32, 1);
424 rb_define_method(bpa_class, "write_i64", rb_thrift_binary_proto_write_i64, 1);
425 rb_define_method(bpa_class, "write_double", rb_thrift_binary_proto_write_double, 1);
426 rb_define_method(bpa_class, "write_string", rb_thrift_binary_proto_write_string, 1);
Roger Meier19dbbef2012-12-27 01:24:20 +0100427 rb_define_method(bpa_class, "write_binary", rb_thrift_binary_proto_write_binary, 1);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000428 // unused methods
429 rb_define_method(bpa_class, "write_message_end", rb_thrift_binary_proto_write_message_end, 0);
430 rb_define_method(bpa_class, "write_struct_begin", rb_thrift_binary_proto_write_struct_begin, 1);
431 rb_define_method(bpa_class, "write_struct_end", rb_thrift_binary_proto_write_struct_end, 0);
432 rb_define_method(bpa_class, "write_field_end", rb_thrift_binary_proto_write_field_end, 0);
433 rb_define_method(bpa_class, "write_map_end", rb_thrift_binary_proto_write_map_end, 0);
434 rb_define_method(bpa_class, "write_list_end", rb_thrift_binary_proto_write_list_end, 0);
435 rb_define_method(bpa_class, "write_set_end", rb_thrift_binary_proto_write_set_end, 0);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000436
437 rb_define_method(bpa_class, "read_message_begin", rb_thrift_binary_proto_read_message_begin, 0);
438 rb_define_method(bpa_class, "read_field_begin", rb_thrift_binary_proto_read_field_begin, 0);
439 rb_define_method(bpa_class, "read_map_begin", rb_thrift_binary_proto_read_map_begin, 0);
440 rb_define_method(bpa_class, "read_list_begin", rb_thrift_binary_proto_read_list_begin, 0);
441 rb_define_method(bpa_class, "read_set_begin", rb_thrift_binary_proto_read_set_begin, 0);
442 rb_define_method(bpa_class, "read_byte", rb_thrift_binary_proto_read_byte, 0);
443 rb_define_method(bpa_class, "read_bool", rb_thrift_binary_proto_read_bool, 0);
444 rb_define_method(bpa_class, "read_i16", rb_thrift_binary_proto_read_i16, 0);
445 rb_define_method(bpa_class, "read_i32", rb_thrift_binary_proto_read_i32, 0);
446 rb_define_method(bpa_class, "read_i64", rb_thrift_binary_proto_read_i64, 0);
447 rb_define_method(bpa_class, "read_double", rb_thrift_binary_proto_read_double, 0);
448 rb_define_method(bpa_class, "read_string", rb_thrift_binary_proto_read_string, 0);
Roger Meier19dbbef2012-12-27 01:24:20 +0100449 rb_define_method(bpa_class, "read_binary", rb_thrift_binary_proto_read_binary, 0);
Bryan Duxburyc0166282009-02-02 00:48:17 +0000450 // unused methods
451 rb_define_method(bpa_class, "read_message_end", rb_thrift_binary_proto_read_message_end, 0);
Roger Meiera2d12b62015-03-24 21:15:06 +0100452 rb_define_method(bpa_class, "read_struct_begin", rb_thrift_binary_proto_read_struct_begin, 0);
453 rb_define_method(bpa_class, "read_struct_end", rb_thrift_binary_proto_read_struct_end, 0);
454 rb_define_method(bpa_class, "read_field_end", rb_thrift_binary_proto_read_field_end, 0);
455 rb_define_method(bpa_class, "read_map_end", rb_thrift_binary_proto_read_map_end, 0);
456 rb_define_method(bpa_class, "read_list_end", rb_thrift_binary_proto_read_list_end, 0);
457 rb_define_method(bpa_class, "read_set_end", rb_thrift_binary_proto_read_set_end, 0);
Bryan Duxburyad0ad822011-06-28 18:46:03 +0000458
459 rbuf_ivar_id = rb_intern("@rbuf");
Bryan Duxbury1e80d442009-02-03 18:16:54 +0000460}