File Coverage

XS.c
Criterion Covered Total %
statement 627 768 81.6
branch 264 552 47.8
condition n/a
subroutine n/a
pod n/a
total 891 1320 67.5


line stmt bran cond sub pod time code
1             /*
2             * This file was generated automatically by ExtUtils::ParseXS version 3.57 from the
3             * contents of XS.xs. Do not edit this file, edit XS.xs instead.
4             *
5             * ANY CHANGES MADE HERE WILL BE LOST!
6             *
7             */
8              
9             #line 1 "XS.xs"
10             #include "EXTERN.h"
11             #include "perl.h"
12             #include "XSUB.h"
13              
14             #include "ppport.h"
15              
16             #include <stdlib.h>
17             #include <stdint.h>
18             #include <inttypes.h>
19              
20             #include "xs_object_magic.h"
21             #include "common.h"
22             #include "buffer.c"
23             #include "memory_buffer.h"
24             #include "binary_protocol.h"
25              
26             // Include the XS::Object::Magic code inline to simplify things
27             #include "Magic.c"
28              
29             /* Detect Endianness using Perl's configuration */
30             #undef __LITTLE_ENDIAN
31             #undef __BIG_ENDIAN
32             #undef __BYTE_ORDER
33              
34             #define __LITTLE_ENDIAN 1234
35             #define __BIG_ENDIAN 4321
36              
37             #ifdef BYTEORDER
38             # if (BYTEORDER == 0x1234 || BYTEORDER == 0x12345678)
39             # define __BYTE_ORDER __LITTLE_ENDIAN
40             # elif (BYTEORDER == 0x4321 || BYTEORDER == 0x87654321)
41             # define __BYTE_ORDER __BIG_ENDIAN
42             # endif
43             #endif
44              
45             /* Fallback for common platforms if BYTEORDER is missing */
46             #ifndef __BYTE_ORDER
47             # if defined(_WIN32) || defined(__i386__) || defined(__x86_64__) || defined(__alpha__)
48             # define __BYTE_ORDER __LITTLE_ENDIAN
49             # else
50             # error "Cannot determine endianness. Please check your Perl configuration."
51             # endif
52             #endif
53              
54             /* Define a high-performance 64-bit byte swapper */
55             #ifndef bswap_64
56             # if defined(_MSC_VER)
57             # include <stdlib.h>
58             # define bswap_64(n) _byteswap_uint64(n)
59             # elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
60             # define bswap_64(n) __builtin_bswap64(n)
61             # else
62             # define bswap_64(n) \
63             ( (((n) & 0xff00000000000000ull) >> 56) \
64             | (((n) & 0x00ff000000000000ull) >> 40) \
65             | (((n) & 0x0000ff0000000000ull) >> 24) \
66             | (((n) & 0x000000ff00000000ull) >> 8) \
67             | (((n) & 0x00000000ff000000ull) << 8) \
68             | (((n) & 0x0000000000ff0000ull) << 24) \
69             | (((n) & 0x000000000000ff00ull) << 40) \
70             | (((n) & 0x00000000000000ffull) << 56) )
71             # endif
72             #endif
73              
74             /* Define Host/Network macros */
75             #if __BYTE_ORDER == __BIG_ENDIAN
76             # define ntohll(n) (n)
77             # define htonll(n) (n)
78             # define htolell(n) bswap_64(n)
79             # define letohll(n) bswap_64(n)
80             #else
81             # define ntohll(n) bswap_64(n)
82             # define htonll(n) bswap_64(n)
83             # define htolell(n) (n)
84             # define letohll(n) (n)
85             #endif
86              
87             #line 88 "XS.c"
88             #ifndef PERL_UNUSED_VAR
89             # define PERL_UNUSED_VAR(var) if (0) var = var
90             #endif
91              
92             #ifndef dVAR
93             # define dVAR dNOOP
94             #endif
95              
96              
97             /* This stuff is not part of the API! You have been warned. */
98             #ifndef PERL_VERSION_DECIMAL
99             # define PERL_VERSION_DECIMAL(r,v,s) (r*1000000 + v*1000 + s)
100             #endif
101             #ifndef PERL_DECIMAL_VERSION
102             # define PERL_DECIMAL_VERSION \
103             PERL_VERSION_DECIMAL(PERL_REVISION,PERL_VERSION,PERL_SUBVERSION)
104             #endif
105             #ifndef PERL_VERSION_GE
106             # define PERL_VERSION_GE(r,v,s) \
107             (PERL_DECIMAL_VERSION >= PERL_VERSION_DECIMAL(r,v,s))
108             #endif
109             #ifndef PERL_VERSION_LE
110             # define PERL_VERSION_LE(r,v,s) \
111             (PERL_DECIMAL_VERSION <= PERL_VERSION_DECIMAL(r,v,s))
112             #endif
113              
114             /* XS_INTERNAL is the explicit static-linkage variant of the default
115             * XS macro.
116             *
117             * XS_EXTERNAL is the same as XS_INTERNAL except it does not include
118             * "STATIC", ie. it exports XSUB symbols. You probably don't want that
119             * for anything but the BOOT XSUB.
120             *
121             * See XSUB.h in core!
122             */
123              
124              
125             /* TODO: This might be compatible further back than 5.10.0. */
126             #if PERL_VERSION_GE(5, 10, 0) && PERL_VERSION_LE(5, 15, 1)
127             # undef XS_EXTERNAL
128             # undef XS_INTERNAL
129             # if defined(__CYGWIN__) && defined(USE_DYNAMIC_LOADING)
130             # define XS_EXTERNAL(name) __declspec(dllexport) XSPROTO(name)
131             # define XS_INTERNAL(name) STATIC XSPROTO(name)
132             # endif
133             # if defined(__SYMBIAN32__)
134             # define XS_EXTERNAL(name) EXPORT_C XSPROTO(name)
135             # define XS_INTERNAL(name) EXPORT_C STATIC XSPROTO(name)
136             # endif
137             # ifndef XS_EXTERNAL
138             # if defined(HASATTRIBUTE_UNUSED) && !defined(__cplusplus)
139             # define XS_EXTERNAL(name) void name(pTHX_ CV* cv __attribute__unused__)
140             # define XS_INTERNAL(name) STATIC void name(pTHX_ CV* cv __attribute__unused__)
141             # else
142             # ifdef __cplusplus
143             # define XS_EXTERNAL(name) extern "C" XSPROTO(name)
144             # define XS_INTERNAL(name) static XSPROTO(name)
145             # else
146             # define XS_EXTERNAL(name) XSPROTO(name)
147             # define XS_INTERNAL(name) STATIC XSPROTO(name)
148             # endif
149             # endif
150             # endif
151             #endif
152              
153             /* perl >= 5.10.0 && perl <= 5.15.1 */
154              
155              
156             /* The XS_EXTERNAL macro is used for functions that must not be static
157             * like the boot XSUB of a module. If perl didn't have an XS_EXTERNAL
158             * macro defined, the best we can do is assume XS is the same.
159             * Dito for XS_INTERNAL.
160             */
161             #ifndef XS_EXTERNAL
162             # define XS_EXTERNAL(name) XS(name)
163             #endif
164             #ifndef XS_INTERNAL
165             # define XS_INTERNAL(name) XS(name)
166             #endif
167              
168             /* Now, finally, after all this mess, we want an ExtUtils::ParseXS
169             * internal macro that we're free to redefine for varying linkage due
170             * to the EXPORT_XSUB_SYMBOLS XS keyword. This is internal, use
171             * XS_EXTERNAL(name) or XS_INTERNAL(name) in your code if you need to!
172             */
173              
174             #undef XS_EUPXS
175             #if defined(PERL_EUPXS_ALWAYS_EXPORT)
176             # define XS_EUPXS(name) XS_EXTERNAL(name)
177             #else
178             /* default to internal */
179             # define XS_EUPXS(name) XS_INTERNAL(name)
180             #endif
181              
182             #ifndef PERL_ARGS_ASSERT_CROAK_XS_USAGE
183             #define PERL_ARGS_ASSERT_CROAK_XS_USAGE assert(cv); assert(params)
184              
185             /* prototype to pass -Wmissing-prototypes */
186             STATIC void
187             S_croak_xs_usage(const CV *const cv, const char *const params);
188              
189             STATIC void
190             S_croak_xs_usage(const CV *const cv, const char *const params)
191             {
192             const GV *const gv = CvGV(cv);
193              
194             PERL_ARGS_ASSERT_CROAK_XS_USAGE;
195              
196             if (gv) {
197             const char *const gvname = GvNAME(gv);
198             const HV *const stash = GvSTASH(gv);
199             const char *const hvname = stash ? HvNAME(stash) : NULL;
200              
201             if (hvname)
202             Perl_croak_nocontext("Usage: %s::%s(%s)", hvname, gvname, params);
203             else
204             Perl_croak_nocontext("Usage: %s(%s)", gvname, params);
205             } else {
206             /* Pants. I don't think that it should be possible to get here. */
207             Perl_croak_nocontext("Usage: CODE(0x%" UVxf ")(%s)", PTR2UV(cv), params);
208             }
209             }
210             #undef PERL_ARGS_ASSERT_CROAK_XS_USAGE
211              
212             #define croak_xs_usage S_croak_xs_usage
213              
214             #endif
215              
216             /* NOTE: the prototype of newXSproto() is different in versions of perls,
217             * so we define a portable version of newXSproto()
218             */
219             #ifdef newXS_flags
220             #define newXSproto_portable(name, c_impl, file, proto) newXS_flags(name, c_impl, file, proto, 0)
221             #else
222             #define newXSproto_portable(name, c_impl, file, proto) (PL_Sv=(SV*)newXS(name, c_impl, file), sv_setpv(PL_Sv, proto), (CV*)PL_Sv)
223             #endif /* !defined(newXS_flags) */
224              
225             #if PERL_VERSION_LE(5, 21, 5)
226             # define newXS_deffile(a,b) Perl_newXS(aTHX_ a,b,file)
227             #else
228             # define newXS_deffile(a,b) Perl_newXS_deffile(aTHX_ a,b)
229             #endif
230              
231             /* simple backcompat versions of the TARGx() macros with no optimisation */
232             #ifndef TARGi
233             # define TARGi(iv, do_taint) sv_setiv_mg(TARG, iv)
234             # define TARGu(uv, do_taint) sv_setuv_mg(TARG, uv)
235             # define TARGn(nv, do_taint) sv_setnv_mg(TARG, nv)
236             #endif
237              
238             #line 239 "XS.c"
239              
240             /* INCLUDE: Including 'MemoryBuffer.xs' from 'XS.xs' */
241              
242              
243             /* INCLUDE: Including 'BinaryProtocol.xs' from 'MemoryBuffer.xs' */
244              
245              
246             /* INCLUDE: Including 'CompactProtocol.xs' from 'BinaryProtocol.xs' */
247              
248              
249             XS_EUPXS(XS_Thrift__XS__CompactProtocol_resetState); /* prototype to pass -Wmissing-prototypes */
250 3           XS_EUPXS(XS_Thrift__XS__CompactProtocol_resetState)
251             {
252 3 50         dVAR; dXSARGS;
253 3 50         if (items != 1)
254 0           croak_xs_usage(cv, "p");
255             {
256 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
257             ;
258             #line 9 "./CompactProtocol.xs"
259             {
260             DEBUG_TRACE("resetState()\n");
261              
262             p->bool_type = -1;
263             p->bool_id = -1;
264             p->bool_value_id = -1;
265             p->last_field_id = 0;
266              
267             // clear field queue
268             struct field_entry *entry;
269             while (!SIMPLEQ_EMPTY(p->last_fields)) {
270             entry = SIMPLEQ_FIRST(p->last_fields);
271             SIMPLEQ_REMOVE_HEAD(p->last_fields, entries);
272             MEM_TRACE("free entry @ %p\n", entry);
273             Safefree(entry);
274             }
275             }
276             #line 277 "XS.c"
277             }
278 3           XSRETURN_EMPTY;
279             }
280              
281              
282             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeMessageBegin); /* prototype to pass -Wmissing-prototypes */
283 3           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeMessageBegin)
284             {
285 3 50         dVAR; dXSARGS;
286 3 50         if (items != 4)
287 0           croak_xs_usage(cv, "p, name, type, seqid");
288             {
289 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
290             ;
291 3           SV * name = ST(1)
292             ;
293 3           int type = (int)SvIV(ST(2))
294             ;
295 3           uint32_t seqid = (uint32_t)SvUV(ST(3))
296             ;
297             #line 30 "./CompactProtocol.xs"
298             {
299             DEBUG_TRACE("writeMessageBegin()\n");
300              
301             SV *namecopy = sv_mortalcopy(name); // because we can't modify the original name
302             sv_utf8_encode(namecopy);
303             uint32_t namelen = sv_len(namecopy);
304             SV *data = sv_2mortal(newSV(16 + namelen));
305             char tmp[5]; // 5 required for varint32
306              
307             // byte protocol ID
308             tmp[0] = PROTOCOL_ID;
309              
310             // byte version/type
311             tmp[1] = (VERSION_N & VERSION_MASK_COMPACT) | ((type << TYPE_SHIFT_AMOUNT) & TYPE_MASK);
312              
313             sv_setpvn(data, tmp, 2);
314              
315             // varint32 seqid
316             int varlen;
317             UINT_TO_VARINT(varlen, tmp, seqid, 0);
318             sv_catpvn(data, tmp, varlen);
319              
320             // varint32 len + string
321             UINT_TO_VARINT(varlen, tmp, namelen, 0);
322             sv_catpvn(data, tmp, varlen);
323             sv_catsv(data, namecopy);
324              
325             WRITE_SV(p, data);
326             }
327             #line 328 "XS.c"
328             }
329 3           XSRETURN_EMPTY;
330             }
331              
332              
333             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeStructBegin); /* prototype to pass -Wmissing-prototypes */
334 5           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeStructBegin)
335             {
336 5 50         dVAR; dXSARGS;
337 5 50         if (items != 2)
338 0           croak_xs_usage(cv, "p, SV *");
339             {
340 5           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
341             ;
342             #line 65 "./CompactProtocol.xs"
343             {
344             DEBUG_TRACE("writeStructBegin()\n");
345              
346             // No writing here, but we push last_field_id onto the fields stack
347             // and reset last_field_id to 0
348             struct field_entry *entry;
349             New(0, entry, sizeof(struct field_entry), struct field_entry);
350             MEM_TRACE("New entry @ %p\n", entry);
351             entry->field_id = p->last_field_id;
352             SIMPLEQ_INSERT_HEAD(p->last_fields, entry, entries);
353              
354             DEBUG_TRACE("writeStructBegin(), insert_head %d\n", entry->field_id);
355              
356             p->last_field_id = 0;
357             }
358             #line 359 "XS.c"
359             }
360 5           XSRETURN_EMPTY;
361             }
362              
363              
364             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeStructEnd); /* prototype to pass -Wmissing-prototypes */
365 4           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeStructEnd)
366             {
367 4 50         dVAR; dXSARGS;
368 4 50         if (items != 1)
369 0           croak_xs_usage(cv, "p");
370             {
371 4           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
372             ;
373             #line 84 "./CompactProtocol.xs"
374             {
375             DEBUG_TRACE("writeStructEnd()\n");
376              
377             // pop last field off the stack and save it in
378             // last_field_id
379             struct field_entry *entry = SIMPLEQ_FIRST(p->last_fields);
380             p->last_field_id = entry->field_id;
381             SIMPLEQ_REMOVE_HEAD(p->last_fields, entries);
382              
383             DEBUG_TRACE("writeStructEnd(), remove_head %d\n", entry->field_id);
384              
385             MEM_TRACE("free entry @ %p\n", entry);
386             Safefree(entry);
387             }
388             #line 389 "XS.c"
389             }
390 4           XSRETURN_EMPTY;
391             }
392              
393              
394             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeFieldBegin); /* prototype to pass -Wmissing-prototypes */
395 10           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeFieldBegin)
396             {
397 10 50         dVAR; dXSARGS;
398 10 50         if (items != 4)
399 0           croak_xs_usage(cv, "p, name, type, id");
400             {
401 10           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
402             ;
403 10           SV * name = ST(1)
404             ;
405 10           int type = (int)SvIV(ST(2))
406             ;
407 10 100         int id = (int)SvIV(ST(3))
408             ;
409             #line 102 "./CompactProtocol.xs"
410             {
411             DEBUG_TRACE("writeFieldBegin()\n");
412              
413             PERL_UNUSED_VAR(name);
414             if (unlikely(type == T_BOOL)) {
415             // Special case, save type/id for use later
416             p->bool_type = type;
417             p->bool_id = id;
418             }
419             else {
420             write_field_begin_internal(p, type, id, -1);
421             }
422             }
423             #line 424 "XS.c"
424             }
425 10           XSRETURN_EMPTY;
426             }
427              
428              
429             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeMapBegin); /* prototype to pass -Wmissing-prototypes */
430 5           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeMapBegin)
431             {
432 5 50         dVAR; dXSARGS;
433 5 50         if (items != 4)
434 0           croak_xs_usage(cv, "p, keytype, valtype, size");
435             {
436 5           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
437             ;
438 5           int keytype = (int)SvIV(ST(1))
439             ;
440 5           int valtype = (int)SvIV(ST(2))
441             ;
442 5 100         uint32_t size = (uint32_t)SvUV(ST(3))
443             ;
444             #line 123 "./CompactProtocol.xs"
445             {
446             DEBUG_TRACE("writeMapBegin()\n");
447              
448             char data[6];
449              
450             if (size == 0) {
451             data[0] = 0;
452             WRITE(p, data, 1);
453             }
454             else {
455             int varlen;
456             UINT_TO_VARINT(varlen, data, size, 0);
457             data[varlen] = (get_compact_type(keytype) << 4) | get_compact_type(valtype);
458             WRITE(p, data, varlen + 1);
459             }
460             }
461             #line 462 "XS.c"
462             }
463 5           XSRETURN_EMPTY;
464             }
465              
466              
467             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeListBegin); /* prototype to pass -Wmissing-prototypes */
468 5           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeListBegin)
469             {
470 5 50         dVAR; dXSARGS;
471 5 50         if (items != 3)
472 0           croak_xs_usage(cv, "p, elemtype, size");
473             {
474 5           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
475             ;
476 5           int elemtype = (int)SvIV(ST(1))
477             ;
478 5           int size = (int)SvIV(ST(2))
479             ;
480             #line 145 "./CompactProtocol.xs"
481             {
482             DEBUG_TRACE("writeListBegin()\n");
483              
484             write_collection_begin_internal(p, elemtype, size);
485             }
486             #line 487 "XS.c"
487             }
488 5           XSRETURN_EMPTY;
489             }
490              
491              
492             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeSetBegin); /* prototype to pass -Wmissing-prototypes */
493 2           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeSetBegin)
494             {
495 2 50         dVAR; dXSARGS;
496 2 50         if (items != 3)
497 0           croak_xs_usage(cv, "p, elemtype, size");
498             {
499 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
500             ;
501 2           int elemtype = (int)SvIV(ST(1))
502             ;
503 2           int size = (int)SvIV(ST(2))
504             ;
505             #line 156 "./CompactProtocol.xs"
506             {
507             DEBUG_TRACE("writeSetBegin()\n");
508              
509             write_collection_begin_internal(p, elemtype, size);
510             }
511             #line 512 "XS.c"
512             }
513 2           XSRETURN_EMPTY;
514             }
515              
516              
517             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeBool); /* prototype to pass -Wmissing-prototypes */
518 5           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeBool)
519             {
520 5 50         dVAR; dXSARGS;
521 5 50         if (items != 2)
522 0           croak_xs_usage(cv, "p, value");
523             {
524 5           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
525             ;
526 5 100         SV * value = ST(1)
527             ;
528             #line 167 "./CompactProtocol.xs"
529             {
530             DEBUG_TRACE("writeBool()\n");
531              
532             if (unlikely(p->bool_type != -1)) {
533             // we haven't written the field header yet
534             write_field_begin_internal(p, p->bool_type, p->bool_id, SvTRUE(value) ? CTYPE_BOOLEAN_TRUE: CTYPE_BOOLEAN_FALSE);
535             p->bool_type = -1;
536             p->bool_id = -1;
537             }
538             else {
539             // we're not part of a field, so just write the value.
540             char data[1];
541             data[0] = SvTRUE(value) ? 1 : 0;
542              
543             WRITE(p, data, 1);
544             }
545             }
546             #line 547 "XS.c"
547             }
548 5           XSRETURN_EMPTY;
549             }
550              
551              
552             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeI16); /* prototype to pass -Wmissing-prototypes */
553 3           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeI16)
554             {
555 3 50         dVAR; dXSARGS;
556 3 50         if (items != 2)
557 0           croak_xs_usage(cv, "p, value");
558             {
559 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
560             ;
561 3           int value = (int)SvIV(ST(1))
562             ;
563             #line 190 "./CompactProtocol.xs"
564             {
565             DEBUG_TRACE("writeI16()\n");
566              
567             char data[3];
568             int varlen;
569              
570             uint32_t uvalue = int_to_zigzag(value);
571             UINT_TO_VARINT(varlen, data, uvalue, 0);
572             WRITE(p, data, varlen);
573             }
574             #line 575 "XS.c"
575             }
576 3           XSRETURN_EMPTY;
577             }
578              
579              
580             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeI32); /* prototype to pass -Wmissing-prototypes */
581 4           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeI32)
582             {
583 4 50         dVAR; dXSARGS;
584 4 50         if (items != 2)
585 0           croak_xs_usage(cv, "p, value");
586             {
587 4           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
588             ;
589 4           int value = (int)SvIV(ST(1))
590             ;
591             #line 204 "./CompactProtocol.xs"
592             {
593             DEBUG_TRACE("writeI32()\n");
594              
595             char data[5];
596             int varlen;
597              
598             uint32_t uvalue = int_to_zigzag(value);
599             UINT_TO_VARINT(varlen, data, uvalue, 0);
600             WRITE(p, data, varlen);
601             }
602             #line 603 "XS.c"
603             }
604 4           XSRETURN_EMPTY;
605             }
606              
607              
608             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeI64); /* prototype to pass -Wmissing-prototypes */
609 5           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeI64)
610             {
611 5 50         dVAR; dXSARGS;
612 5 50         if (items != 2)
613 0           croak_xs_usage(cv, "p, value");
614             {
615 5           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
616             ;
617 5 100         SV * value = ST(1)
618             ;
619             #line 218 "./CompactProtocol.xs"
620             {
621             char data[10];
622             int varlen = 0;
623              
624             // Stringify the value, then convert to an int64_t
625             const char *str = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
626             int64_t i64 = (int64_t)strtoll(str, NULL, 10);
627              
628             DEBUG_TRACE("writeI64(%" PRId64 ")\n", i64);
629              
630             uint64_t uvalue = ll_to_zigzag(i64);
631             UINT_TO_VARINT(varlen, data, uvalue, 0);
632             WRITE(p, data, varlen);
633             }
634             #line 635 "XS.c"
635             }
636 5           XSRETURN_EMPTY;
637             }
638              
639              
640             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeDouble); /* prototype to pass -Wmissing-prototypes */
641 2           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeDouble)
642             {
643 2 50         dVAR; dXSARGS;
644 2 50         if (items != 2)
645 0           croak_xs_usage(cv, "p, value");
646             {
647 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
648             ;
649 2           SV * value = ST(1)
650             ;
651             #line 236 "./CompactProtocol.xs"
652             {
653             DEBUG_TRACE("writeDouble()\n");
654              
655             char data[8];
656             union {
657             double d;
658             int64_t i;
659             } u;
660              
661             u.d = (double)SvNV(value);
662              
663             data[0] = u.i & 0xff;
664             data[1] = (u.i >> 8) & 0xff;
665             data[2] = (u.i >> 16) & 0xff;
666             data[3] = (u.i >> 24) & 0xff;
667             data[4] = (u.i >> 32) & 0xff;
668             data[5] = (u.i >> 40) & 0xff;
669             data[6] = (u.i >> 48) & 0xff;
670             data[7] = (u.i >> 56) & 0xff;
671              
672             WRITE(p, data, 8);
673             }
674             #line 675 "XS.c"
675             }
676 2           XSRETURN_EMPTY;
677             }
678              
679              
680             XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeString); /* prototype to pass -Wmissing-prototypes */
681 19           XS_EUPXS(XS_Thrift__XS__CompactProtocol_writeString)
682             {
683 19 50         dVAR; dXSARGS;
684 19 50         if (items != 2)
685 0           croak_xs_usage(cv, "p, value");
686             {
687 19           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
688             ;
689 19           SV * value = ST(1)
690             ;
691             #line 262 "./CompactProtocol.xs"
692             {
693             DEBUG_TRACE("writeString()\n");
694              
695             SV *valuecopy = sv_mortalcopy(value);
696             if (SvUTF8(value) != 0) {
697             sv_utf8_encode(valuecopy);
698             }
699             int len = sv_len(valuecopy);
700             SV *data = sv_2mortal(newSV(5 + len));
701             char tmp[5];
702              
703             int varlen;
704             UINT_TO_VARINT(varlen, tmp, len, 0);
705             sv_setpvn(data, tmp, varlen);
706             sv_catsv(data, valuecopy);
707              
708             WRITE_SV(p, data);
709             }
710             #line 711 "XS.c"
711             }
712 19           XSRETURN_EMPTY;
713             }
714              
715              
716             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readMessageBegin); /* prototype to pass -Wmissing-prototypes */
717 1           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readMessageBegin)
718             {
719 1 50         dVAR; dXSARGS;
720 1 50         if (items != 4)
721 0           croak_xs_usage(cv, "p, name, type, seqid");
722             {
723 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
724             ;
725 1           SV * name = ST(1)
726             ;
727 1           SV * type = ST(2)
728             ;
729 1 50         SV * seqid = ST(3)
730             ;
731             #line 284 "./CompactProtocol.xs"
732             {
733             DEBUG_TRACE("readMessageBegin()\n");
734              
735             SV *tmp;
736             char *tmps;
737             uint32_t tmpui;
738              
739             // read protocol id, version, type
740             READ_SV(p, tmp, 2);
741             tmps = SvPVX(tmp);
742              
743             uint8_t protocol_id = (uint8_t) tmps[0];
744             if (protocol_id != (uint8_t) PROTOCOL_ID) {
745             THROW_SV("Thrift::TException", newSVpvf("Expected protocol id %d but got %d", PROTOCOL_ID, protocol_id));
746             }
747              
748             uint8_t version_and_type = (uint8_t) tmps[1];
749             uint8_t version = version_and_type & VERSION_MASK_COMPACT;
750             if (version != VERSION_N) {
751             THROW_SV("Thrift::TException", newSVpvf("Expected version id %d but got %d", VERSION_N, version));
752             }
753              
754             // set type
755             if (SvROK(type))
756             sv_setiv(SvRV(type), (version_and_type >> TYPE_SHIFT_AMOUNT) & 0x03);
757              
758             // read/set seqid
759             READ_VARINT(p, tmpui);
760             if (SvROK(seqid))
761             sv_setiv(SvRV(seqid), tmpui);
762              
763             // read/set name
764             READ_VARINT(p, tmpui);
765             if (tmpui) {
766             READ_SV(p, tmp, tmpui);
767             sv_utf8_decode(tmp);
768             if (SvROK(name))
769             sv_setsv(SvRV(name), tmp);
770             }
771             else {
772             if (SvROK(name))
773             sv_setpv(SvRV(name), "");
774             }
775             }
776             #line 777 "XS.c"
777             }
778 1           XSRETURN_EMPTY;
779             }
780              
781              
782             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readStructBegin); /* prototype to pass -Wmissing-prototypes */
783 4           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readStructBegin)
784             {
785 4 50         dVAR; dXSARGS;
786 4 50         if (items != 2)
787 0           croak_xs_usage(cv, "p, name");
788             {
789 4           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
790             ;
791 4           SV * name = ST(1)
792             ;
793             #line 334 "./CompactProtocol.xs"
794             {
795             DEBUG_TRACE("readStructBegin()\n");
796              
797             // No reading here, but we push last_field_id onto the fields stack
798             struct field_entry *entry;
799             New(0, entry, sizeof(struct field_entry), struct field_entry);
800             MEM_TRACE("New entry @ %p\n", entry);
801             entry->field_id = p->last_field_id;
802             SIMPLEQ_INSERT_HEAD(p->last_fields, entry, entries);
803              
804             p->last_field_id = 0;
805              
806             if (SvROK(name))
807             sv_setpv(SvRV(name), "");
808             }
809             #line 810 "XS.c"
810             }
811 4           XSRETURN_EMPTY;
812             }
813              
814              
815             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readStructEnd); /* prototype to pass -Wmissing-prototypes */
816 3           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readStructEnd)
817             {
818 3 50         dVAR; dXSARGS;
819 3 50         if (items != 1)
820 0           croak_xs_usage(cv, "p");
821             {
822 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
823             ;
824             #line 353 "./CompactProtocol.xs"
825             {
826             DEBUG_TRACE("readStructEnd()\n");
827              
828             // pop last field off the stack
829             struct field_entry *entry = SIMPLEQ_FIRST(p->last_fields);
830             SIMPLEQ_REMOVE_HEAD(p->last_fields, entries);
831             p->last_field_id = entry->field_id;
832              
833             MEM_TRACE("free entry @ %p\n", entry);
834             Safefree(entry);
835             }
836             #line 837 "XS.c"
837             }
838 3           XSRETURN_EMPTY;
839             }
840              
841              
842             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readFieldBegin); /* prototype to pass -Wmissing-prototypes */
843 10           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readFieldBegin)
844             {
845 10 50         dVAR; dXSARGS;
846 10 50         if (items != 4)
847 0           croak_xs_usage(cv, "p, name, fieldtype, fieldid");
848             {
849 10           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
850             ;
851 10           SV * name = ST(1)
852             ;
853 10           SV * fieldtype = ST(2)
854             ;
855 10 50         SV * fieldid = ST(3)
856             ;
857             #line 368 "./CompactProtocol.xs"
858             {
859             DEBUG_TRACE("readFieldBegin()\n");
860              
861             SV *tmp;
862             char *tmps;
863              
864             PERL_UNUSED_VAR(name);
865             // fieldtype byte
866             READ_SV(p, tmp, 1);
867             tmps = SvPVX(tmp);
868             int type = tmps[0];
869              
870             if (SvROK(fieldtype))
871             sv_setiv(SvRV(fieldtype), get_ttype(type & 0x0f));
872              
873             if (type == T_STOP) {
874             if (SvROK(fieldid))
875             sv_setiv(SvRV(fieldid), 0);
876             XSRETURN_EMPTY;
877             }
878              
879             // fieldid i16 varint
880             int fid;
881              
882             // mask off the 4 MSB of the type header. it could contain a field id delta.
883             uint8_t modifier = ((type & 0xf0) >> 4);
884             if (modifier == 0) {
885             // pop field
886             struct field_entry *entry = SIMPLEQ_FIRST(p->last_fields);
887             SIMPLEQ_REMOVE_HEAD(p->last_fields, entries);
888             MEM_TRACE("free entry @ %p\n", entry);
889             Safefree(entry);
890              
891             // not a delta. look ahead for the zigzag varint field id.
892             READ_VARINT(p, fid);
893             fid = zigzag_to_int(fid);
894             }
895             else {
896             // has a delta. add the delta to the last read field id.
897             // pop field
898             struct field_entry *entry = SIMPLEQ_FIRST(p->last_fields);
899             SIMPLEQ_REMOVE_HEAD(p->last_fields, entries);
900             int last = entry->field_id;
901             MEM_TRACE("free entry @ %p\n", entry);
902             Safefree(entry);
903              
904             fid = last + modifier;
905             }
906              
907             // if this happens to be a boolean field, the value is encoded in the type
908             if (is_bool_type(type)) {
909             // save the boolean value in a special instance variable.
910             p->bool_value_id = (type & 0x0f) == CTYPE_BOOLEAN_TRUE ? 1 : 0;
911             }
912              
913             // push the new field onto the field stack so we can keep the deltas going.
914             struct field_entry *entry;
915             New(0, entry, sizeof(struct field_entry), struct field_entry);
916             MEM_TRACE("New entry @ %p\n", entry);
917             entry->field_id = fid;
918             SIMPLEQ_INSERT_HEAD(p->last_fields, entry, entries);
919              
920             if (SvROK(fieldid))
921             sv_setiv(SvRV(fieldid), fid);
922             }
923             #line 924 "XS.c"
924             }
925 7           XSRETURN_EMPTY;
926             }
927              
928              
929             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readMapBegin); /* prototype to pass -Wmissing-prototypes */
930 3           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readMapBegin)
931             {
932 3 50         dVAR; dXSARGS;
933 3 50         if (items != 4)
934 0           croak_xs_usage(cv, "p, keytype, valtype, size");
935             {
936 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
937             ;
938 3           SV * keytype = ST(1)
939             ;
940 3           SV * valtype = ST(2)
941             ;
942 3           SV * size = ST(3)
943             ;
944             #line 439 "./CompactProtocol.xs"
945             {
946             DEBUG_TRACE("readMapBegin()\n");
947              
948             SV *tmp;
949             char *tmps;
950              
951             // size
952             uint32_t isize;
953             READ_VARINT(p, isize);
954             if (SvROK(size))
955             sv_setiv(SvRV(size), isize);
956              
957             // key and value type
958             READ_SV(p, tmp, 1);
959             tmps = SvPVX(tmp);
960              
961             // keytype byte
962             if (SvROK(keytype))
963             sv_setiv(SvRV(keytype), get_ttype((tmps[0] >> 4) & 0xf));
964              
965             // valtype byte
966             if (SvROK(valtype))
967             sv_setiv(SvRV(valtype), get_ttype(tmps[0] & 0xf));
968             }
969             #line 970 "XS.c"
970             }
971 3           XSRETURN_EMPTY;
972             }
973              
974              
975             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readListBegin); /* prototype to pass -Wmissing-prototypes */
976 3           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readListBegin)
977             {
978 3 50         dVAR; dXSARGS;
979 3 50         if (items != 3)
980 0           croak_xs_usage(cv, "p, elemtype, size");
981             {
982 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
983             ;
984 3           SV * elemtype = ST(1)
985             ;
986 3 50         SV * size = ST(2)
987             ;
988             #line 469 "./CompactProtocol.xs"
989             {
990             DEBUG_TRACE("readListBegin()\n");
991              
992             SV *tmp;
993             char *tmps;
994              
995             // size and type may be in the same byte
996             READ_SV(p, tmp, 1);
997             tmps = SvPVX(tmp);
998             int isize = (tmps[0] >> 4) & 0x0f;
999             if (isize == 15) {
1000             // size is in a varint
1001             READ_VARINT(p, isize);
1002             }
1003             int type = get_ttype(tmps[0] & 0x0f);
1004              
1005             // elemtype byte
1006             if (SvROK(elemtype))
1007             sv_setiv(SvRV(elemtype), type);
1008              
1009             // size
1010             if (SvROK(size))
1011             sv_setiv(SvRV(size), isize);
1012             }
1013             #line 1014 "XS.c"
1014             }
1015 3           XSRETURN_EMPTY;
1016             }
1017              
1018              
1019             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readSetBegin); /* prototype to pass -Wmissing-prototypes */
1020 1           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readSetBegin)
1021             {
1022 1 50         dVAR; dXSARGS;
1023 1 50         if (items != 3)
1024 0           croak_xs_usage(cv, "p, elemtype, size");
1025             {
1026 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1027             ;
1028 1           SV * elemtype = ST(1)
1029             ;
1030 1 50         SV * size = ST(2)
1031             ;
1032             #line 499 "./CompactProtocol.xs"
1033             {
1034             DEBUG_TRACE("readSetBegin()\n");
1035              
1036             SV *tmp;
1037             char *tmps;
1038              
1039             // size and type may be in the same byte
1040             READ_SV(p, tmp, 1);
1041             tmps = SvPVX(tmp);
1042             int isize = (tmps[0] >> 4) & 0x0f;
1043             if (isize == 15) {
1044             // size is in a varint
1045             READ_VARINT(p, isize);
1046             }
1047             int type = get_ttype(tmps[0] & 0x0f);
1048              
1049             // elemtype byte
1050             if (SvROK(elemtype))
1051             sv_setiv(SvRV(elemtype), type);
1052              
1053             // size
1054             if (SvROK(size))
1055             sv_setiv(SvRV(size), isize);
1056             }
1057             #line 1058 "XS.c"
1058             }
1059 1           XSRETURN_EMPTY;
1060             }
1061              
1062              
1063             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readBool); /* prototype to pass -Wmissing-prototypes */
1064 3           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readBool)
1065             {
1066 3 50         dVAR; dXSARGS;
1067 3 50         if (items != 2)
1068 0           croak_xs_usage(cv, "p, value");
1069             {
1070 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1071             ;
1072 3 100         SV * value = ST(1)
1073             ;
1074             #line 529 "./CompactProtocol.xs"
1075             {
1076             DEBUG_TRACE("readBool()\n");
1077              
1078             SV *tmp;
1079             char *tmps;
1080              
1081             // Check for bool_value encoded in the fieldBegin type
1082             if (p->bool_value_id != -1) {
1083             if (SvROK(value))
1084             sv_setiv(SvRV(value), p->bool_value_id);
1085             p->bool_value_id = -1;
1086             }
1087             else {
1088             READ_SV(p, tmp, 1);
1089             tmps = SvPVX(tmp);
1090              
1091             if (SvROK(value))
1092             sv_setiv(SvRV(value), tmps[0] ? 1 : 0);
1093             }
1094             }
1095             #line 1096 "XS.c"
1096             }
1097 3           XSRETURN_EMPTY;
1098             }
1099              
1100              
1101             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readI16); /* prototype to pass -Wmissing-prototypes */
1102 1           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readI16)
1103             {
1104 1 50         dVAR; dXSARGS;
1105 1 50         if (items != 2)
1106 0           croak_xs_usage(cv, "p, value");
1107             {
1108 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1109             ;
1110 1           SV * value = ST(1)
1111             ;
1112             #line 555 "./CompactProtocol.xs"
1113             {
1114             DEBUG_TRACE("readI16()\n");
1115              
1116             uint32_t varint;
1117             READ_VARINT(p, varint);
1118              
1119             if (SvROK(value))
1120             sv_setiv(SvRV(value), zigzag_to_int(varint));
1121             }
1122             #line 1123 "XS.c"
1123             }
1124 1           XSRETURN_EMPTY;
1125             }
1126              
1127              
1128             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readI32); /* prototype to pass -Wmissing-prototypes */
1129 2           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readI32)
1130             {
1131 2 50         dVAR; dXSARGS;
1132 2 50         if (items != 2)
1133 0           croak_xs_usage(cv, "p, value");
1134             {
1135 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1136             ;
1137 2           SV * value = ST(1)
1138             ;
1139             #line 568 "./CompactProtocol.xs"
1140             {
1141             DEBUG_TRACE("readI32()\n");
1142              
1143             uint32_t varint;
1144             READ_VARINT(p, varint);
1145              
1146             if (SvROK(value))
1147             sv_setiv(SvRV(value), zigzag_to_int(varint));
1148             }
1149             #line 1150 "XS.c"
1150             }
1151 2           XSRETURN_EMPTY;
1152             }
1153              
1154              
1155             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readI64); /* prototype to pass -Wmissing-prototypes */
1156 1           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readI64)
1157             {
1158 1 50         dVAR; dXSARGS;
1159 1 50         if (items != 2)
1160 0           croak_xs_usage(cv, "p, value");
1161             {
1162 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1163             ;
1164 1           SV * value = ST(1)
1165             ;
1166             #line 581 "./CompactProtocol.xs"
1167             {
1168             uint64_t varint;
1169             READ_VARINT(p, varint);
1170              
1171             DEBUG_TRACE("readI64(%" PRId64 ") (from varint %" PRIu64 ")\n", zigzag_to_ll(varint), varint);
1172              
1173             // Store as a string so it works on 32-bit platforms
1174             if (SvROK(value)) {
1175             char string[25];
1176             STRLEN length;
1177             length = sprintf(string, "%" PRId64, zigzag_to_ll(varint));
1178             sv_setpvn(SvRV(value), string, length);
1179             }
1180             }
1181             #line 1182 "XS.c"
1182             }
1183 1           XSRETURN_EMPTY;
1184             }
1185              
1186              
1187             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readDouble); /* prototype to pass -Wmissing-prototypes */
1188 1           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readDouble)
1189             {
1190 1 50         dVAR; dXSARGS;
1191 1 50         if (items != 2)
1192 0           croak_xs_usage(cv, "p, value");
1193             {
1194 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1195             ;
1196 1 50         SV * value = ST(1)
1197             ;
1198             #line 599 "./CompactProtocol.xs"
1199             {
1200             DEBUG_TRACE("readDouble()\n");
1201              
1202             SV *tmp;
1203             char *tmps;
1204              
1205             READ_SV(p, tmp, 8);
1206             tmps = SvPVX(tmp);
1207              
1208             uint32_t lo = (uint8_t)tmps[0] |
1209             ((uint8_t)tmps[1] << 8) |
1210             ((uint8_t)tmps[2] << 16) |
1211             ((uint8_t)tmps[3] << 24);
1212             uint64_t hi = (uint8_t)tmps[4] |
1213             ((uint8_t)tmps[5] << 8) |
1214             ((uint8_t)tmps[6] << 16) |
1215             ((uint8_t)tmps[7] << 24);
1216              
1217             union {
1218             double d;
1219             int64_t i;
1220             } u;
1221             u.i = (hi << 32) | lo;
1222              
1223             if (SvROK(value))
1224             sv_setnv(SvRV(value), u.d);
1225             }
1226             #line 1227 "XS.c"
1227             }
1228 1           XSRETURN_EMPTY;
1229             }
1230              
1231              
1232             XS_EUPXS(XS_Thrift__XS__CompactProtocol_readString); /* prototype to pass -Wmissing-prototypes */
1233 15           XS_EUPXS(XS_Thrift__XS__CompactProtocol_readString)
1234             {
1235 15 50         dVAR; dXSARGS;
1236 15 50         if (items != 2)
1237 0           croak_xs_usage(cv, "p, value");
1238             {
1239 15           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1240             ;
1241 15           SV * value = ST(1)
1242             ;
1243             #line 630 "./CompactProtocol.xs"
1244             {
1245             DEBUG_TRACE("readString()\n");
1246              
1247             SV *tmp;
1248              
1249             uint64_t len;
1250             READ_VARINT(p, len);
1251             if (len) {
1252             READ_SV(p, tmp, len);
1253             sv_utf8_decode(tmp);
1254             if (SvROK(value))
1255             sv_setsv(SvRV(value), tmp);
1256             }
1257             else {
1258             if (SvROK(value))
1259             sv_setpv(SvRV(value), "");
1260             }
1261             }
1262             #line 1263 "XS.c"
1263             }
1264 15           XSRETURN_EMPTY;
1265             }
1266              
1267              
1268             /* INCLUDE: Returning to 'BinaryProtocol.xs' from 'CompactProtocol.xs' */
1269              
1270              
1271             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_new); /* prototype to pass -Wmissing-prototypes */
1272 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_new)
1273             {
1274 2 50         dVAR; dXSARGS;
1275 2 50         if (items != 2)
1276 0           croak_xs_usage(cv, "klass, transport");
1277             {
1278             SV * RETVAL;
1279 2           char * klass = (char *)SvPV_nolen(ST(0))
1280             ;
1281 2           SV * transport = ST(1)
1282             ;
1283             #line 6 "./BinaryProtocol.xs"
1284             {
1285             TBinaryProtocol *p;
1286             New(0, p, sizeof(TBinaryProtocol), TBinaryProtocol);
1287             New(0, p->last_fields, sizeof(struct fieldq), struct fieldq);
1288              
1289             MEM_TRACE("new()\n");
1290             MEM_TRACE(" New p @ %p\n", p);
1291             MEM_TRACE(" New last_fields @ %p\n", p->last_fields);
1292              
1293             if (sv_isa(transport, "Thrift::XS::MemoryBuffer"))
1294             p->mbuf = (TMemoryBuffer *)xs_object_magic_get_struct_rv_pretty(aTHX_ transport, "mbuf");
1295             else
1296             p->mbuf = NULL;
1297              
1298             p->transport = transport;
1299              
1300             p->bool_type = -1;
1301             p->bool_id = -1;
1302             p->bool_value_id = -1;
1303             p->last_field_id = 0;
1304              
1305             SIMPLEQ_INIT(p->last_fields);
1306              
1307             RETVAL = xs_object_magic_create(
1308             aTHX_
1309             (void *)p,
1310             gv_stashpv(klass, 0)
1311             );
1312             }
1313             #line 1314 "XS.c"
1314 2           RETVAL = sv_2mortal(RETVAL);
1315 2           ST(0) = RETVAL;
1316             }
1317 2           XSRETURN(1);
1318             }
1319              
1320              
1321             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_DESTROY); /* prototype to pass -Wmissing-prototypes */
1322 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_DESTROY)
1323             {
1324 2 50         dVAR; dXSARGS;
1325 2 50         if (items != 1)
1326 0           croak_xs_usage(cv, "p");
1327             {
1328 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1329             ;
1330             #line 41 "./BinaryProtocol.xs"
1331             {
1332             MEM_TRACE("DESTROY()\n");
1333              
1334             // clear field queue
1335             struct field_entry *entry;
1336             while (!SIMPLEQ_EMPTY(p->last_fields)) {
1337             entry = SIMPLEQ_FIRST(p->last_fields);
1338             SIMPLEQ_REMOVE_HEAD(p->last_fields, entries);
1339             MEM_TRACE(" free entry @ %p\n", entry);
1340             Safefree(entry);
1341             }
1342              
1343             MEM_TRACE(" free last_fields @ %p\n", p->last_fields);
1344             Safefree(p->last_fields);
1345             MEM_TRACE(" free p @ %p\n", p);
1346             Safefree(p);
1347             }
1348             #line 1349 "XS.c"
1349             }
1350 2           XSRETURN_EMPTY;
1351             }
1352              
1353              
1354             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_getTransport); /* prototype to pass -Wmissing-prototypes */
1355 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_getTransport)
1356             {
1357 2 50         dVAR; dXSARGS;
1358 2 50         if (items != 1)
1359 0           croak_xs_usage(cv, "p");
1360             {
1361             SV * RETVAL;
1362 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1363             ;
1364             #line 62 "./BinaryProtocol.xs"
1365             {
1366             SvREFCNT_inc(p->transport);
1367             RETVAL = p->transport;
1368             }
1369             #line 1370 "XS.c"
1370 2           RETVAL = sv_2mortal(RETVAL);
1371 2           ST(0) = RETVAL;
1372             }
1373 2           XSRETURN(1);
1374             }
1375              
1376              
1377             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMessageBegin); /* prototype to pass -Wmissing-prototypes */
1378 3           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMessageBegin)
1379             {
1380 3 50         dVAR; dXSARGS;
1381 3 50         if (items != 4)
1382 0           croak_xs_usage(cv, "p, name, type, seqid");
1383             {
1384             int RETVAL;
1385 3 50         dXSTARG;
1386 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1387             ;
1388 3           SV * name = ST(1)
1389             ;
1390 3           int type = (int)SvIV(ST(2))
1391             ;
1392 3           int seqid = (int)SvIV(ST(3))
1393             ;
1394             #line 72 "./BinaryProtocol.xs"
1395             {
1396             DEBUG_TRACE("writeMessageBegin()\n");
1397             RETVAL = 0;
1398              
1399             SV *namecopy = sv_mortalcopy(name); // because we can't modify the original name
1400             sv_utf8_encode(namecopy);
1401             int namelen = sv_len(namecopy);
1402             SV *data = sv_2mortal(newSV(8 + 4+namelen));
1403             char i32[4];
1404              
1405             // i32 type
1406             type = VERSION_1 | type;
1407             INT_TO_I32(i32, type, 0);
1408             sv_setpvn(data, i32, 4);
1409             RETVAL += 4;
1410              
1411             // i32 len + string
1412             INT_TO_I32(i32, namelen, 0);
1413             sv_catpvn(data, i32, 4);
1414             sv_catsv(data, namecopy);
1415             RETVAL += 4 + namelen;
1416              
1417             // i32 seqid
1418             INT_TO_I32(i32, seqid, 0);
1419             sv_catpvn(data, i32, 4);
1420             RETVAL += 4;
1421              
1422             WRITE_SV(p, data);
1423             }
1424             #line 1425 "XS.c"
1425 3 100         TARGi((IV)RETVAL, 1);
1426 3           ST(0) = TARG;
1427             }
1428 3           XSRETURN(1);
1429             }
1430              
1431              
1432             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMessageEnd); /* prototype to pass -Wmissing-prototypes */
1433 0           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMessageEnd)
1434             {
1435 0 0         dVAR; dXSARGS;
1436 0 0         if (items != 1)
1437 0           croak_xs_usage(cv, "SV *");
1438             {
1439             int RETVAL;
1440 0 0         dXSTARG;
1441             #line 107 "./BinaryProtocol.xs"
1442             {
1443             RETVAL = 0;
1444             }
1445             #line 1446 "XS.c"
1446 0 0         TARGi((IV)RETVAL, 1);
1447 0           ST(0) = TARG;
1448             }
1449 0           XSRETURN(1);
1450             }
1451              
1452              
1453             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeStructBegin); /* prototype to pass -Wmissing-prototypes */
1454 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeStructBegin)
1455             {
1456 1 50         dVAR; dXSARGS;
1457 1 50         if (items != 2)
1458 0           croak_xs_usage(cv, "SV *, SV *");
1459             {
1460             int RETVAL;
1461 1 50         dXSTARG;
1462             #line 116 "./BinaryProtocol.xs"
1463             {
1464             RETVAL = 0;
1465             }
1466             #line 1467 "XS.c"
1467 1 50         TARGi((IV)RETVAL, 1);
1468 1           ST(0) = TARG;
1469             }
1470 1           XSRETURN(1);
1471             }
1472              
1473              
1474             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeStructEnd); /* prototype to pass -Wmissing-prototypes */
1475 0           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeStructEnd)
1476             {
1477 0 0         dVAR; dXSARGS;
1478 0 0         if (items != 1)
1479 0           croak_xs_usage(cv, "SV *");
1480             {
1481             int RETVAL;
1482 0 0         dXSTARG;
1483             #line 125 "./BinaryProtocol.xs"
1484             {
1485             RETVAL = 0;
1486             }
1487             #line 1488 "XS.c"
1488 0 0         TARGi((IV)RETVAL, 1);
1489 0           ST(0) = TARG;
1490             }
1491 0           XSRETURN(1);
1492             }
1493              
1494              
1495             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeFieldBegin); /* prototype to pass -Wmissing-prototypes */
1496 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeFieldBegin)
1497             {
1498 2 50         dVAR; dXSARGS;
1499 2 50         if (items != 4)
1500 0           croak_xs_usage(cv, "p, name, type, id");
1501             {
1502             int RETVAL;
1503 2 50         dXSTARG;
1504 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1505             ;
1506 2           SV * name = ST(1)
1507             ;
1508 2           int type = (int)SvIV(ST(2))
1509             ;
1510 2 50         int id = (int)SvIV(ST(3))
1511             ;
1512             #line 134 "./BinaryProtocol.xs"
1513             {
1514             DEBUG_TRACE("writeFieldBegin(type %d, id %d)\n", type, id);
1515             char data[3];
1516             RETVAL = 0;
1517              
1518             PERL_UNUSED_VAR(name);
1519             data[0] = type & 0xff; // byte
1520             data[1] = (id >> 8) & 0xff; // i16
1521             data[2] = id & 0xff;
1522              
1523             WRITE(p, data, 3);
1524             RETVAL += 3;
1525             }
1526             #line 1527 "XS.c"
1527 2 100         TARGi((IV)RETVAL, 1);
1528 2           ST(0) = TARG;
1529             }
1530 2           XSRETURN(1);
1531             }
1532              
1533              
1534             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeFieldEnd); /* prototype to pass -Wmissing-prototypes */
1535 9           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeFieldEnd)
1536             {
1537 9 50         dVAR; dXSARGS;
1538 9 50         if (items != 1)
1539 0           croak_xs_usage(cv, "SV *");
1540             {
1541             int RETVAL;
1542 9 50         dXSTARG;
1543             #line 153 "./BinaryProtocol.xs"
1544             {
1545             RETVAL = 0;
1546             }
1547             #line 1548 "XS.c"
1548 9 100         TARGi((IV)RETVAL, 1);
1549 9           ST(0) = TARG;
1550             }
1551 9           XSRETURN(1);
1552             }
1553              
1554              
1555             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeFieldStop); /* prototype to pass -Wmissing-prototypes */
1556 5           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeFieldStop)
1557             {
1558 5 50         dVAR; dXSARGS;
1559 5 50         if (items != 1)
1560 0           croak_xs_usage(cv, "p");
1561             {
1562             int RETVAL;
1563 5 50         dXSTARG;
1564 5           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1565             ;
1566             #line 162 "./BinaryProtocol.xs"
1567             {
1568             DEBUG_TRACE("writeFieldStop()\n");
1569             RETVAL = 0;
1570              
1571             char data[1];
1572             data[0] = T_STOP;
1573              
1574             WRITE(p, data, 1);
1575             RETVAL += 1;
1576             }
1577             #line 1578 "XS.c"
1578 5 100         TARGi((IV)RETVAL, 1);
1579 5           ST(0) = TARG;
1580             }
1581 5           XSRETURN(1);
1582             }
1583              
1584              
1585             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMapBegin); /* prototype to pass -Wmissing-prototypes */
1586 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMapBegin)
1587             {
1588 2 50         dVAR; dXSARGS;
1589 2 50         if (items != 4)
1590 0           croak_xs_usage(cv, "p, keytype, valtype, size");
1591             {
1592             int RETVAL;
1593 2 50         dXSTARG;
1594 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1595             ;
1596 2           int keytype = (int)SvIV(ST(1))
1597             ;
1598 2           int valtype = (int)SvIV(ST(2))
1599             ;
1600 2 50         int size = (int)SvIV(ST(3))
1601             ;
1602             #line 178 "./BinaryProtocol.xs"
1603             {
1604             DEBUG_TRACE("writeMapBegin(keytype %d, valtype %d, size %d)\n", keytype, valtype, size);
1605             char data[6];
1606             RETVAL = 0;
1607              
1608             data[0] = keytype & 0xff;
1609             data[1] = valtype & 0xff;
1610             INT_TO_I32(data, size, 2);
1611              
1612             WRITE(p, data, 6);
1613             RETVAL += 6;
1614             }
1615             #line 1616 "XS.c"
1616 2 100         TARGi((IV)RETVAL, 1);
1617 2           ST(0) = TARG;
1618             }
1619 2           XSRETURN(1);
1620             }
1621              
1622              
1623             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMapEnd); /* prototype to pass -Wmissing-prototypes */
1624 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeMapEnd)
1625             {
1626 2 50         dVAR; dXSARGS;
1627 2 50         if (items != 1)
1628 0           croak_xs_usage(cv, "SV *");
1629             {
1630             int RETVAL;
1631 2 50         dXSTARG;
1632             #line 196 "./BinaryProtocol.xs"
1633             {
1634             RETVAL = 0;
1635             }
1636             #line 1637 "XS.c"
1637 2 50         TARGi((IV)RETVAL, 1);
1638 2           ST(0) = TARG;
1639             }
1640 2           XSRETURN(1);
1641             }
1642              
1643              
1644             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeListBegin); /* prototype to pass -Wmissing-prototypes */
1645 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeListBegin)
1646             {
1647 2 50         dVAR; dXSARGS;
1648 2 50         if (items != 3)
1649 0           croak_xs_usage(cv, "p, elemtype, size");
1650             {
1651             int RETVAL;
1652 2 50         dXSTARG;
1653 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1654             ;
1655 2           int elemtype = (int)SvIV(ST(1))
1656             ;
1657 2 50         int size = (int)SvIV(ST(2))
1658             ;
1659             #line 205 "./BinaryProtocol.xs"
1660             {
1661             DEBUG_TRACE("writeListBegin(elemtype %d, size %d)\n", elemtype, size);
1662             char data[5];
1663             RETVAL = 0;
1664              
1665             data[0] = elemtype & 0xff;
1666             INT_TO_I32(data, size, 1);
1667              
1668             WRITE(p, data, 5);
1669             RETVAL += 5;
1670             }
1671             #line 1672 "XS.c"
1672 2 100         TARGi((IV)RETVAL, 1);
1673 2           ST(0) = TARG;
1674             }
1675 2           XSRETURN(1);
1676             }
1677              
1678              
1679             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeListEnd); /* prototype to pass -Wmissing-prototypes */
1680 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeListEnd)
1681             {
1682 2 50         dVAR; dXSARGS;
1683 2 50         if (items != 1)
1684 0           croak_xs_usage(cv, "SV *");
1685             {
1686             int RETVAL;
1687 2 50         dXSTARG;
1688             #line 222 "./BinaryProtocol.xs"
1689             {
1690             RETVAL = 0;
1691             }
1692             #line 1693 "XS.c"
1693 2 100         TARGi((IV)RETVAL, 1);
1694 2           ST(0) = TARG;
1695             }
1696 2           XSRETURN(1);
1697             }
1698              
1699              
1700             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeSetBegin); /* prototype to pass -Wmissing-prototypes */
1701 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeSetBegin)
1702             {
1703 2 50         dVAR; dXSARGS;
1704 2 50         if (items != 3)
1705 0           croak_xs_usage(cv, "p, elemtype, size");
1706             {
1707             int RETVAL;
1708 2 50         dXSTARG;
1709 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1710             ;
1711 2           int elemtype = (int)SvIV(ST(1))
1712             ;
1713 2 50         int size = (int)SvIV(ST(2))
1714             ;
1715             #line 231 "./BinaryProtocol.xs"
1716             {
1717             DEBUG_TRACE("writeSetBegin(elemtype %d, size %d)\n", elemtype, size);
1718             char data[5];
1719             RETVAL = 0;
1720              
1721             data[0] = elemtype & 0xff;
1722             INT_TO_I32(data, size, 1);
1723              
1724             WRITE(p, data, 5);
1725             RETVAL += 5;
1726             }
1727             #line 1728 "XS.c"
1728 2 100         TARGi((IV)RETVAL, 1);
1729 2           ST(0) = TARG;
1730             }
1731 2           XSRETURN(1);
1732             }
1733              
1734              
1735             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeSetEnd); /* prototype to pass -Wmissing-prototypes */
1736 0           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeSetEnd)
1737             {
1738 0 0         dVAR; dXSARGS;
1739 0 0         if (items != 1)
1740 0           croak_xs_usage(cv, "SV *");
1741             {
1742             int RETVAL;
1743 0 0         dXSTARG;
1744             #line 248 "./BinaryProtocol.xs"
1745             {
1746             RETVAL = 0;
1747             }
1748             #line 1749 "XS.c"
1749 0 0         TARGi((IV)RETVAL, 1);
1750 0           ST(0) = TARG;
1751             }
1752 0           XSRETURN(1);
1753             }
1754              
1755              
1756             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeBool); /* prototype to pass -Wmissing-prototypes */
1757 4           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeBool)
1758             {
1759 4 50         dVAR; dXSARGS;
1760 4 50         if (items != 2)
1761 0           croak_xs_usage(cv, "p, value");
1762             {
1763             int RETVAL;
1764 4 50         dXSTARG;
1765 4           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1766             ;
1767 4           SV * value = ST(1)
1768             ;
1769             #line 257 "./BinaryProtocol.xs"
1770             {
1771             DEBUG_TRACE("writeBool(%d)\n", SvTRUE(value) ? 1 : 0);
1772             char data[1];
1773             RETVAL = 0;
1774              
1775             data[0] = SvTRUE(value) ? 1 : 0;
1776              
1777             WRITE(p, data, 1);
1778             RETVAL += 1;
1779             }
1780             #line 1781 "XS.c"
1781 4 100         TARGi((IV)RETVAL, 1);
1782 4           ST(0) = TARG;
1783             }
1784 4           XSRETURN(1);
1785             }
1786              
1787              
1788             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeByte); /* prototype to pass -Wmissing-prototypes */
1789 4           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeByte)
1790             {
1791 4 50         dVAR; dXSARGS;
1792 4 50         if (items != 2)
1793 0           croak_xs_usage(cv, "p, value");
1794             {
1795             int RETVAL;
1796 4 50         dXSTARG;
1797 4           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1798             ;
1799 4           SV * value = ST(1)
1800             ;
1801             #line 273 "./BinaryProtocol.xs"
1802             {
1803             DEBUG_TRACE("writeByte(%ld)\n", SvIV(value) & 0xff);
1804             char data[1];
1805             RETVAL = 0;
1806              
1807             data[0] = SvIV(value) & 0xff;
1808              
1809             WRITE(p, data, 1);
1810             RETVAL += 1;
1811             }
1812             #line 1813 "XS.c"
1813 4 100         TARGi((IV)RETVAL, 1);
1814 4           ST(0) = TARG;
1815             }
1816 4           XSRETURN(1);
1817             }
1818              
1819              
1820             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeI16); /* prototype to pass -Wmissing-prototypes */
1821 3           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeI16)
1822             {
1823 3 50         dVAR; dXSARGS;
1824 3 50         if (items != 2)
1825 0           croak_xs_usage(cv, "p, value");
1826             {
1827             int RETVAL;
1828 3 50         dXSTARG;
1829 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1830             ;
1831 3 50         int value = (int)SvIV(ST(1))
1832             ;
1833             #line 289 "./BinaryProtocol.xs"
1834             {
1835             DEBUG_TRACE("writeI16(%d)\n", value);
1836             char data[2];
1837             RETVAL = 0;
1838              
1839             INT_TO_I16(data, value, 0);
1840              
1841             WRITE(p, data, 2);
1842             RETVAL += 2;
1843             }
1844             #line 1845 "XS.c"
1845 3 100         TARGi((IV)RETVAL, 1);
1846 3           ST(0) = TARG;
1847             }
1848 3           XSRETURN(1);
1849             }
1850              
1851              
1852             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeI32); /* prototype to pass -Wmissing-prototypes */
1853 3           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeI32)
1854             {
1855 3 50         dVAR; dXSARGS;
1856 3 50         if (items != 2)
1857 0           croak_xs_usage(cv, "p, value");
1858             {
1859             int RETVAL;
1860 3 50         dXSTARG;
1861 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1862             ;
1863 3 50         int value = (int)SvIV(ST(1))
1864             ;
1865             #line 305 "./BinaryProtocol.xs"
1866             {
1867             DEBUG_TRACE("writeI32(%d)\n", value);
1868             char data[4];
1869             RETVAL = 0;
1870              
1871             INT_TO_I32(data, value, 0);
1872              
1873             WRITE(p, data, 4);
1874             RETVAL += 4;
1875             }
1876             #line 1877 "XS.c"
1877 3 100         TARGi((IV)RETVAL, 1);
1878 3           ST(0) = TARG;
1879             }
1880 3           XSRETURN(1);
1881             }
1882              
1883              
1884             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeI64); /* prototype to pass -Wmissing-prototypes */
1885 3           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeI64)
1886             {
1887 3 50         dVAR; dXSARGS;
1888 3 50         if (items != 2)
1889 0           croak_xs_usage(cv, "p, value");
1890             {
1891             int RETVAL;
1892 3 50         dXSTARG;
1893 3           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1894             ;
1895 3 50         SV * value = ST(1)
1896             ;
1897             #line 321 "./BinaryProtocol.xs"
1898             {
1899             char data[8];
1900             RETVAL = 0;
1901              
1902             // Stringify the value, then convert to an int64_t
1903             const char *str = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
1904             int64_t i64 = (int64_t)strtoll(str, NULL, 10);
1905              
1906             DEBUG_TRACE("writeI64(%" PRId64 ") (from string %s)\n", i64, str);
1907              
1908             data[7] = i64 & 0xff;
1909             data[6] = (i64 >> 8) & 0xff;
1910             data[5] = (i64 >> 16) & 0xff;
1911             data[4] = (i64 >> 24) & 0xff;
1912             data[3] = (i64 >> 32) & 0xff;
1913             data[2] = (i64 >> 40) & 0xff;
1914             data[1] = (i64 >> 48) & 0xff;
1915             data[0] = (i64 >> 56) & 0xff;
1916              
1917             WRITE(p, data, 8);
1918             RETVAL += 8;
1919             }
1920             #line 1921 "XS.c"
1921 3 100         TARGi((IV)RETVAL, 1);
1922 3           ST(0) = TARG;
1923             }
1924 3           XSRETURN(1);
1925             }
1926              
1927              
1928             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeDouble); /* prototype to pass -Wmissing-prototypes */
1929 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeDouble)
1930             {
1931 2 50         dVAR; dXSARGS;
1932 2 50         if (items != 2)
1933 0           croak_xs_usage(cv, "p, value");
1934             {
1935             int RETVAL;
1936 2 50         dXSTARG;
1937 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1938             ;
1939 2           SV * value = ST(1)
1940             ;
1941             #line 349 "./BinaryProtocol.xs"
1942             {
1943             DEBUG_TRACE("writeDouble(%f)\n", (double)SvNV(value));
1944             char data[8];
1945             union {
1946             double from;
1947             uint64_t to;
1948             } u;
1949             RETVAL = 0;
1950              
1951             u.from = (double)SvNV(value);
1952             uint64_t bits = u.to;
1953             bits = htonll(bits);
1954              
1955             memcpy(&data, (uint8_t *)&bits, 8);
1956              
1957             WRITE(p, data, 8);
1958             RETVAL += 8;
1959             }
1960             #line 1961 "XS.c"
1961 2 100         TARGi((IV)RETVAL, 1);
1962 2           ST(0) = TARG;
1963             }
1964 2           XSRETURN(1);
1965             }
1966              
1967              
1968             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeString); /* prototype to pass -Wmissing-prototypes */
1969 6           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_writeString)
1970             {
1971 6 50         dVAR; dXSARGS;
1972 6 50         if (items != 2)
1973 0           croak_xs_usage(cv, "p, value");
1974             {
1975             int RETVAL;
1976 6 50         dXSTARG;
1977 6           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
1978             ;
1979 6           SV * value = ST(1)
1980             ;
1981             #line 373 "./BinaryProtocol.xs"
1982             {
1983             DEBUG_TRACE("writeString(%s)\n", SvPVX(value));
1984             RETVAL = 0;
1985              
1986             SV *valuecopy = sv_mortalcopy(value);
1987             if (SvUTF8(value) != 0) {
1988             sv_utf8_encode(valuecopy);
1989             }
1990             int len = sv_len(valuecopy);
1991             SV *data = sv_2mortal(newSV(4 + len));
1992             char i32[4];
1993              
1994             INT_TO_I32(i32, len, 0);
1995             sv_setpvn(data, i32, 4);
1996             RETVAL += 4;
1997             sv_catsv(data, valuecopy);
1998             RETVAL += len;
1999              
2000             WRITE_SV(p, data);
2001             }
2002             #line 2003 "XS.c"
2003 6 100         TARGi((IV)RETVAL, 1);
2004 6           ST(0) = TARG;
2005             }
2006 6           XSRETURN(1);
2007             }
2008              
2009              
2010             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMessageBegin); /* prototype to pass -Wmissing-prototypes */
2011 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMessageBegin)
2012             {
2013 1 50         dVAR; dXSARGS;
2014 1 50         if (items != 4)
2015 0           croak_xs_usage(cv, "p, name, type, seqid");
2016             {
2017             int RETVAL;
2018 1 50         dXSTARG;
2019 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2020             ;
2021 1           SV * name = ST(1)
2022             ;
2023 1           SV * type = ST(2)
2024             ;
2025 1 50         SV * seqid = ST(3)
2026             ;
2027             #line 399 "./BinaryProtocol.xs"
2028             {
2029             DEBUG_TRACE("readMessageBegin()\n");
2030             RETVAL = 0;
2031              
2032             SV *tmp;
2033             int version;
2034             char *tmps;
2035              
2036             // read version + type
2037             READ_SV(p, tmp, 4);
2038             tmps = SvPVX(tmp);
2039             I32_TO_INT(version, tmps, 0);
2040             RETVAL += 4;
2041              
2042             if (version < 0) {
2043             if ((version & VERSION_MASK) != VERSION_1) {
2044             THROW("Thrift::TException", "Missing version identifier");
2045             }
2046             // set type
2047             if (SvROK(type))
2048             sv_setiv(SvRV(type), version & 0x000000ff);
2049              
2050             // read string
2051             {
2052             uint32_t len;
2053             READ_SV(p, tmp, 4);
2054             tmps = SvPVX(tmp);
2055             I32_TO_INT(len, tmps, 0);
2056             RETVAL += 4;
2057             if (len) {
2058             READ_SV(p, tmp, len);
2059             sv_utf8_decode(tmp);
2060             RETVAL += len;
2061             if (SvROK(name))
2062             sv_setsv(SvRV(name), tmp);
2063             }
2064             else {
2065             if (SvROK(name))
2066             sv_setpv(SvRV(name), "");
2067             }
2068             }
2069              
2070             // read seqid
2071             {
2072             int s;
2073             READ_SV(p, tmp, 4);
2074             tmps = SvPVX(tmp);
2075             I32_TO_INT(s, tmps, 0);
2076             RETVAL += 4;
2077             if (SvROK(seqid))
2078             sv_setiv(SvRV(seqid), s);
2079             }
2080             }
2081             else {
2082             THROW("Thrift::TException", "Missing version identifier");
2083             }
2084             }
2085             #line 2086 "XS.c"
2086 1 50         TARGi((IV)RETVAL, 1);
2087 1           ST(0) = TARG;
2088             }
2089 1           XSRETURN(1);
2090             }
2091              
2092              
2093             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMessageEnd); /* prototype to pass -Wmissing-prototypes */
2094 0           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMessageEnd)
2095             {
2096 0 0         dVAR; dXSARGS;
2097 0 0         if (items != 1)
2098 0           croak_xs_usage(cv, "SV *");
2099             {
2100             int RETVAL;
2101 0 0         dXSTARG;
2102             #line 462 "./BinaryProtocol.xs"
2103             {
2104             RETVAL = 0;
2105             }
2106             #line 2107 "XS.c"
2107 0 0         TARGi((IV)RETVAL, 1);
2108 0           ST(0) = TARG;
2109             }
2110 0           XSRETURN(1);
2111             }
2112              
2113              
2114             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readStructBegin); /* prototype to pass -Wmissing-prototypes */
2115 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readStructBegin)
2116             {
2117 1 50         dVAR; dXSARGS;
2118 1 50         if (items != 2)
2119 0           croak_xs_usage(cv, "SV *, name");
2120             {
2121             int RETVAL;
2122 1 50         dXSTARG;
2123 1 50         SV * name = ST(1)
2124             ;
2125             #line 471 "./BinaryProtocol.xs"
2126             {
2127             DEBUG_TRACE("readStructBegin()\n");
2128             RETVAL = 0;
2129              
2130             if (SvROK(name))
2131             sv_setpv(SvRV(name), "");
2132             }
2133             #line 2134 "XS.c"
2134 1 50         TARGi((IV)RETVAL, 1);
2135 1           ST(0) = TARG;
2136             }
2137 1           XSRETURN(1);
2138             }
2139              
2140              
2141             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readStructEnd); /* prototype to pass -Wmissing-prototypes */
2142 0           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readStructEnd)
2143             {
2144 0 0         dVAR; dXSARGS;
2145 0 0         if (items != 1)
2146 0           croak_xs_usage(cv, "SV *");
2147             {
2148             int RETVAL;
2149 0 0         dXSTARG;
2150             #line 484 "./BinaryProtocol.xs"
2151             {
2152             RETVAL = 0;
2153             }
2154             #line 2155 "XS.c"
2155 0 0         TARGi((IV)RETVAL, 1);
2156 0           ST(0) = TARG;
2157             }
2158 0           XSRETURN(1);
2159             }
2160              
2161              
2162             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readFieldBegin); /* prototype to pass -Wmissing-prototypes */
2163 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readFieldBegin)
2164             {
2165 1 50         dVAR; dXSARGS;
2166 1 50         if (items != 4)
2167 0           croak_xs_usage(cv, "p, name, fieldtype, fieldid");
2168             {
2169             int RETVAL;
2170 1 50         dXSTARG;
2171 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2172             ;
2173 1           SV * name = ST(1)
2174             ;
2175 1           SV * fieldtype = ST(2)
2176             ;
2177 1 50         SV * fieldid = ST(3)
2178             ;
2179             #line 493 "./BinaryProtocol.xs"
2180             {
2181             DEBUG_TRACE("readFieldBegin()\n");
2182             SV *tmp;
2183             char *tmps;
2184             RETVAL = 0;
2185              
2186             PERL_UNUSED_VAR(name);
2187             READ_SV(p, tmp, 1);
2188             tmps = SvPVX(tmp);
2189             RETVAL += 1;
2190              
2191             // fieldtype byte
2192             if (SvROK(fieldtype))
2193             sv_setiv(SvRV(fieldtype), tmps[0]);
2194              
2195             if (tmps[0] == T_STOP) {
2196             if (SvROK(fieldid))
2197             sv_setiv(SvRV(fieldid), 0);
2198             }
2199             else {
2200             // fieldid i16
2201             READ_SV(p, tmp, 2);
2202             tmps = SvPVX(tmp);
2203             int fid;
2204             I16_TO_INT(fid, tmps, 0);
2205             RETVAL += 2;
2206             if (SvROK(fieldid))
2207             sv_setiv(SvRV(fieldid), fid);
2208             }
2209             }
2210             #line 2211 "XS.c"
2211 1 50         TARGi((IV)RETVAL, 1);
2212 1           ST(0) = TARG;
2213             }
2214 1           XSRETURN(1);
2215             }
2216              
2217              
2218             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readFieldEnd); /* prototype to pass -Wmissing-prototypes */
2219 6           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readFieldEnd)
2220             {
2221 6 50         dVAR; dXSARGS;
2222 6 50         if (items != 1)
2223 0           croak_xs_usage(cv, "SV *");
2224             {
2225             int RETVAL;
2226 6 50         dXSTARG;
2227             #line 529 "./BinaryProtocol.xs"
2228             {
2229             RETVAL = 0;
2230             }
2231             #line 2232 "XS.c"
2232 6 100         TARGi((IV)RETVAL, 1);
2233 6           ST(0) = TARG;
2234             }
2235 6           XSRETURN(1);
2236             }
2237              
2238              
2239             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMapBegin); /* prototype to pass -Wmissing-prototypes */
2240 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMapBegin)
2241             {
2242 1 50         dVAR; dXSARGS;
2243 1 50         if (items != 4)
2244 0           croak_xs_usage(cv, "p, keytype, valtype, size");
2245             {
2246             int RETVAL;
2247 1 50         dXSTARG;
2248 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2249             ;
2250 1           SV * keytype = ST(1)
2251             ;
2252 1           SV * valtype = ST(2)
2253             ;
2254 1 50         SV * size = ST(3)
2255             ;
2256             #line 538 "./BinaryProtocol.xs"
2257             {
2258             DEBUG_TRACE("readMapBegin()\n");
2259             SV *tmp;
2260             char *tmps;
2261             RETVAL = 0;
2262              
2263             READ_SV(p, tmp, 6);
2264             tmps = SvPVX(tmp);
2265             RETVAL += 6;
2266              
2267             // keytype byte
2268             if (SvROK(keytype))
2269             sv_setiv(SvRV(keytype), tmps[0]);
2270              
2271             // valtype byte
2272             if (SvROK(valtype))
2273             sv_setiv(SvRV(valtype), tmps[1]);
2274              
2275             // size i32
2276             int isize;
2277             I32_TO_INT(isize, tmps, 2);
2278             if (SvROK(size))
2279             sv_setiv(SvRV(size), isize);
2280             }
2281             #line 2282 "XS.c"
2282 1 50         TARGi((IV)RETVAL, 1);
2283 1           ST(0) = TARG;
2284             }
2285 1           XSRETURN(1);
2286             }
2287              
2288              
2289             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMapEnd); /* prototype to pass -Wmissing-prototypes */
2290 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readMapEnd)
2291             {
2292 2 50         dVAR; dXSARGS;
2293 2 50         if (items != 1)
2294 0           croak_xs_usage(cv, "SV *");
2295             {
2296             int RETVAL;
2297 2 50         dXSTARG;
2298             #line 568 "./BinaryProtocol.xs"
2299             {
2300             RETVAL = 0;
2301             }
2302             #line 2303 "XS.c"
2303 2 50         TARGi((IV)RETVAL, 1);
2304 2           ST(0) = TARG;
2305             }
2306 2           XSRETURN(1);
2307             }
2308              
2309              
2310             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readListBegin); /* prototype to pass -Wmissing-prototypes */
2311 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readListBegin)
2312             {
2313 1 50         dVAR; dXSARGS;
2314 1 50         if (items != 3)
2315 0           croak_xs_usage(cv, "p, elemtype, size");
2316             {
2317             int RETVAL;
2318 1 50         dXSTARG;
2319 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2320             ;
2321 1           SV * elemtype = ST(1)
2322             ;
2323 1 50         SV * size = ST(2)
2324             ;
2325             #line 577 "./BinaryProtocol.xs"
2326             {
2327             DEBUG_TRACE("readListBegin()\n");
2328             SV *tmp;
2329             char *tmps;
2330             RETVAL = 0;
2331              
2332             READ_SV(p, tmp, 5);
2333             tmps = SvPVX(tmp);
2334             RETVAL += 5;
2335              
2336             // elemtype byte
2337             if (SvROK(elemtype))
2338             sv_setiv(SvRV(elemtype), tmps[0]);
2339              
2340             // size i32
2341             int isize;
2342             I32_TO_INT(isize, tmps, 1);
2343             if (SvROK(size))
2344             sv_setiv(SvRV(size), isize);
2345             }
2346             #line 2347 "XS.c"
2347 1 50         TARGi((IV)RETVAL, 1);
2348 1           ST(0) = TARG;
2349             }
2350 1           XSRETURN(1);
2351             }
2352              
2353              
2354             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readListEnd); /* prototype to pass -Wmissing-prototypes */
2355 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readListEnd)
2356             {
2357 2 50         dVAR; dXSARGS;
2358 2 50         if (items != 1)
2359 0           croak_xs_usage(cv, "SV *");
2360             {
2361             int RETVAL;
2362 2 50         dXSTARG;
2363             #line 603 "./BinaryProtocol.xs"
2364             {
2365             RETVAL = 0;
2366             }
2367             #line 2368 "XS.c"
2368 2 100         TARGi((IV)RETVAL, 1);
2369 2           ST(0) = TARG;
2370             }
2371 2           XSRETURN(1);
2372             }
2373              
2374              
2375             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readSetBegin); /* prototype to pass -Wmissing-prototypes */
2376 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readSetBegin)
2377             {
2378 1 50         dVAR; dXSARGS;
2379 1 50         if (items != 3)
2380 0           croak_xs_usage(cv, "p, elemtype, size");
2381             {
2382             int RETVAL;
2383 1 50         dXSTARG;
2384 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2385             ;
2386 1           SV * elemtype = ST(1)
2387             ;
2388 1 50         SV * size = ST(2)
2389             ;
2390             #line 612 "./BinaryProtocol.xs"
2391             {
2392             DEBUG_TRACE("readSetBegin()\n");
2393             SV *tmp;
2394             char *tmps;
2395             RETVAL = 0;
2396              
2397             READ_SV(p, tmp, 5);
2398             tmps = SvPVX(tmp);
2399             RETVAL += 5;
2400              
2401             // elemtype byte
2402             if (SvROK(elemtype))
2403             sv_setiv(SvRV(elemtype), tmps[0]);
2404              
2405             // size i32
2406             int isize;
2407             I32_TO_INT(isize, tmps, 1);
2408             if (SvROK(size))
2409             sv_setiv(SvRV(size), isize);
2410             }
2411             #line 2412 "XS.c"
2412 1 50         TARGi((IV)RETVAL, 1);
2413 1           ST(0) = TARG;
2414             }
2415 1           XSRETURN(1);
2416             }
2417              
2418              
2419             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readSetEnd); /* prototype to pass -Wmissing-prototypes */
2420 0           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readSetEnd)
2421             {
2422 0 0         dVAR; dXSARGS;
2423 0 0         if (items != 1)
2424 0           croak_xs_usage(cv, "SV *");
2425             {
2426             int RETVAL;
2427 0 0         dXSTARG;
2428             #line 638 "./BinaryProtocol.xs"
2429             {
2430             RETVAL = 0;
2431             }
2432             #line 2433 "XS.c"
2433 0 0         TARGi((IV)RETVAL, 1);
2434 0           ST(0) = TARG;
2435             }
2436 0           XSRETURN(1);
2437             }
2438              
2439              
2440             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readBool); /* prototype to pass -Wmissing-prototypes */
2441 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readBool)
2442             {
2443 2 50         dVAR; dXSARGS;
2444 2 50         if (items != 2)
2445 0           croak_xs_usage(cv, "p, value");
2446             {
2447             int RETVAL;
2448 2 50         dXSTARG;
2449 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2450             ;
2451 2 50         SV * value = ST(1)
2452             ;
2453             #line 647 "./BinaryProtocol.xs"
2454             {
2455             DEBUG_TRACE("readBool()\n");
2456             SV *tmp;
2457             char *tmps;
2458             RETVAL = 0;
2459              
2460             READ_SV(p, tmp, 1);
2461             tmps = SvPVX(tmp);
2462             RETVAL += 1;
2463              
2464             if (SvROK(value))
2465             sv_setiv(SvRV(value), tmps[0] ? 1 : 0);
2466             }
2467             #line 2468 "XS.c"
2468 2 50         TARGi((IV)RETVAL, 1);
2469 2           ST(0) = TARG;
2470             }
2471 2           XSRETURN(1);
2472             }
2473              
2474              
2475             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readByte); /* prototype to pass -Wmissing-prototypes */
2476 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readByte)
2477             {
2478 2 50         dVAR; dXSARGS;
2479 2 50         if (items != 2)
2480 0           croak_xs_usage(cv, "p, value");
2481             {
2482             int RETVAL;
2483 2 50         dXSTARG;
2484 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2485             ;
2486 2 50         SV * value = ST(1)
2487             ;
2488             #line 666 "./BinaryProtocol.xs"
2489             {
2490             DEBUG_TRACE("readByte()\n");
2491             SV *tmp;
2492             char *tmps;
2493             RETVAL = 0;
2494              
2495             READ_SV(p, tmp, 1);
2496             tmps = SvPVX(tmp);
2497             RETVAL += 1;
2498              
2499             if (SvROK(value))
2500             sv_setiv(SvRV(value), tmps[0]);
2501             }
2502             #line 2503 "XS.c"
2503 2 50         TARGi((IV)RETVAL, 1);
2504 2           ST(0) = TARG;
2505             }
2506 2           XSRETURN(1);
2507             }
2508              
2509              
2510             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readI16); /* prototype to pass -Wmissing-prototypes */
2511 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readI16)
2512             {
2513 1 50         dVAR; dXSARGS;
2514 1 50         if (items != 2)
2515 0           croak_xs_usage(cv, "p, value");
2516             {
2517             int RETVAL;
2518 1 50         dXSTARG;
2519 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2520             ;
2521 1 50         SV * value = ST(1)
2522             ;
2523             #line 685 "./BinaryProtocol.xs"
2524             {
2525             DEBUG_TRACE("readI16()\n");
2526             SV *tmp;
2527             char *tmps;
2528             RETVAL = 0;
2529              
2530             READ_SV(p, tmp, 2);
2531             tmps = SvPVX(tmp);
2532             RETVAL += 2;
2533              
2534             int v;
2535             I16_TO_INT(v, tmps, 0);
2536             if (SvROK(value))
2537             sv_setiv(SvRV(value), v);
2538             }
2539             #line 2540 "XS.c"
2540 1 50         TARGi((IV)RETVAL, 1);
2541 1           ST(0) = TARG;
2542             }
2543 1           XSRETURN(1);
2544             }
2545              
2546              
2547             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readI32); /* prototype to pass -Wmissing-prototypes */
2548 2           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readI32)
2549             {
2550 2 50         dVAR; dXSARGS;
2551 2 50         if (items != 2)
2552 0           croak_xs_usage(cv, "p, value");
2553             {
2554             int RETVAL;
2555 2 50         dXSTARG;
2556 2           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2557             ;
2558 2 50         SV * value = ST(1)
2559             ;
2560             #line 706 "./BinaryProtocol.xs"
2561             {
2562             DEBUG_TRACE("readI32()\n");
2563             SV *tmp;
2564             char *tmps;
2565             RETVAL = 0;
2566              
2567             READ_SV(p, tmp, 4);
2568             tmps = SvPVX(tmp);
2569             RETVAL += 4;
2570              
2571             int v;
2572             I32_TO_INT(v, tmps, 0);
2573             if (SvROK(value))
2574             sv_setiv(SvRV(value), v);
2575             }
2576             #line 2577 "XS.c"
2577 2 50         TARGi((IV)RETVAL, 1);
2578 2           ST(0) = TARG;
2579             }
2580 2           XSRETURN(1);
2581             }
2582              
2583              
2584             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readI64); /* prototype to pass -Wmissing-prototypes */
2585 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readI64)
2586             {
2587 1 50         dVAR; dXSARGS;
2588 1 50         if (items != 2)
2589 0           croak_xs_usage(cv, "p, value");
2590             {
2591             int RETVAL;
2592 1 50         dXSTARG;
2593 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2594             ;
2595 1 50         SV * value = ST(1)
2596             ;
2597             #line 727 "./BinaryProtocol.xs"
2598             {
2599             DEBUG_TRACE("readI64()\n");
2600             SV *tmp;
2601             char *tmps;
2602             RETVAL = 0;
2603              
2604             READ_SV(p, tmp, 8);
2605             tmps = SvPVX(tmp);
2606             RETVAL += 8;
2607              
2608             int64_t hi;
2609             uint32_t lo;
2610             I32_TO_INT(hi, tmps, 0);
2611             I32_TO_INT(lo, tmps, 4);
2612              
2613             if (SvROK(value)) {
2614             char string[25];
2615             STRLEN length;
2616             length = sprintf(string, "%" PRId64, (int64_t)(hi << 32) | lo);
2617             sv_setpvn(SvRV(value), string, length);
2618             }
2619             }
2620             #line 2621 "XS.c"
2621 1 50         TARGi((IV)RETVAL, 1);
2622 1           ST(0) = TARG;
2623             }
2624 1           XSRETURN(1);
2625             }
2626              
2627              
2628             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readDouble); /* prototype to pass -Wmissing-prototypes */
2629 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readDouble)
2630             {
2631 1 50         dVAR; dXSARGS;
2632 1 50         if (items != 2)
2633 0           croak_xs_usage(cv, "p, value");
2634             {
2635             int RETVAL;
2636 1 50         dXSTARG;
2637 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2638             ;
2639 1 50         SV * value = ST(1)
2640             ;
2641             #line 755 "./BinaryProtocol.xs"
2642             {
2643             DEBUG_TRACE("readDouble()\n");
2644             SV *tmp;
2645             char *tmps;
2646             uint64_t bits;
2647             RETVAL = 0;
2648              
2649             READ_SV(p, tmp, 8);
2650             tmps = SvPVX(tmp);
2651             RETVAL += 8;
2652              
2653             bits = *(uint64_t *)tmps;
2654             bits = ntohll(bits);
2655              
2656             union {
2657             uint64_t from;
2658             double to;
2659             } u;
2660             u.from = bits;
2661              
2662             if (SvROK(value))
2663             sv_setnv(SvRV(value), u.to);
2664             }
2665             #line 2666 "XS.c"
2666 1 50         TARGi((IV)RETVAL, 1);
2667 1           ST(0) = TARG;
2668             }
2669 1           XSRETURN(1);
2670             }
2671              
2672              
2673             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readString); /* prototype to pass -Wmissing-prototypes */
2674 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readString)
2675             {
2676 1 50         dVAR; dXSARGS;
2677 1 50         if (items != 2)
2678 0           croak_xs_usage(cv, "p, value");
2679             {
2680             int RETVAL;
2681 1 50         dXSTARG;
2682 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2683             ;
2684 1 50         SV * value = ST(1)
2685             ;
2686             #line 784 "./BinaryProtocol.xs"
2687             {
2688             DEBUG_TRACE("readString()\n");
2689             SV *tmp;
2690             char *tmps;
2691             RETVAL = 0;
2692              
2693             uint32_t len;
2694             READ_SV(p, tmp, 4);
2695             tmps = SvPVX(tmp);
2696             I32_TO_INT(len, tmps, 0);
2697             RETVAL += 4;
2698             if (len) {
2699             READ_SV(p, tmp, len);
2700             sv_utf8_decode(tmp);
2701             RETVAL += len;
2702             if (SvROK(value))
2703             sv_setsv(SvRV(value), tmp);
2704             }
2705             else {
2706             if (SvROK(value))
2707             sv_setpv(SvRV(value), "");
2708             }
2709             }
2710             #line 2711 "XS.c"
2711 1 50         TARGi((IV)RETVAL, 1);
2712 1           ST(0) = TARG;
2713             }
2714 1           XSRETURN(1);
2715             }
2716              
2717              
2718             XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readStringBody); /* prototype to pass -Wmissing-prototypes */
2719 1           XS_EUPXS(XS_Thrift__XS__BinaryProtocol_readStringBody)
2720             {
2721 1 50         dVAR; dXSARGS;
2722 1 50         if (items != 3)
2723 0           croak_xs_usage(cv, "p, value, len");
2724             {
2725             int RETVAL;
2726 1 50         dXSTARG;
2727 1           TBinaryProtocol * p = (TBinaryProtocol *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "p")
2728             ;
2729 1           SV * value = ST(1)
2730             ;
2731 1 50         uint32_t len = (uint32_t)SvUV(ST(2))
2732             ;
2733             #line 813 "./BinaryProtocol.xs"
2734             {
2735             // This method is never used but is here for compat
2736             SV *tmp;
2737             RETVAL = 0;
2738              
2739             if (len) {
2740             READ_SV(p, tmp, len);
2741             sv_utf8_decode(tmp);
2742             RETVAL += len;
2743             if (SvROK(value))
2744             sv_setsv(SvRV(value), tmp);
2745             }
2746             else {
2747             if (SvROK(value))
2748             sv_setpv(SvRV(value), "");
2749             }
2750             }
2751             #line 2752 "XS.c"
2752 1 50         TARGi((IV)RETVAL, 1);
2753 1           ST(0) = TARG;
2754             }
2755 1           XSRETURN(1);
2756             }
2757              
2758              
2759             /* INCLUDE: Returning to 'MemoryBuffer.xs' from 'BinaryProtocol.xs' */
2760              
2761              
2762             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_new); /* prototype to pass -Wmissing-prototypes */
2763 3           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_new)
2764             {
2765 3 50         dVAR; dXSARGS;
2766 3 50         if (items < 1)
2767 0           croak_xs_usage(cv, "klass, ...");
2768             {
2769             SV * RETVAL;
2770 3           char * klass = (char *)SvPV_nolen(ST(0))
2771             ;
2772             #line 6 "./MemoryBuffer.xs"
2773             {
2774             int bufsize = 8192;
2775             TMemoryBuffer *mbuf;
2776             New(0, mbuf, sizeof(TMemoryBuffer), TMemoryBuffer);
2777             New(0, mbuf->buffer, sizeof(Buffer), Buffer);
2778              
2779             MEM_TRACE("new()\n");
2780             MEM_TRACE(" New mbuf @ %p\n", mbuf);
2781             MEM_TRACE(" New buffer @ %p\n", mbuf->buffer);
2782              
2783             if (items > 1 && SvIOK_UV(ST(1)))
2784             bufsize = SvIV(ST(1));
2785              
2786             buffer_init(mbuf->buffer, bufsize);
2787              
2788             RETVAL = xs_object_magic_create(
2789             aTHX_
2790             (void *)mbuf,
2791             gv_stashpv(klass, 0)
2792             );
2793             }
2794             #line 2795 "XS.c"
2795 3           RETVAL = sv_2mortal(RETVAL);
2796 3           ST(0) = RETVAL;
2797             }
2798 3           XSRETURN(1);
2799             }
2800              
2801              
2802             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_isOpen); /* prototype to pass -Wmissing-prototypes */
2803 0           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_isOpen)
2804             {
2805 0 0         dVAR; dXSARGS;
2806 0 0         if (items != 1)
2807 0           croak_xs_usage(cv, "SV *");
2808             {
2809             int RETVAL;
2810 0 0         dXSTARG;
2811             #line 33 "./MemoryBuffer.xs"
2812             {
2813             RETVAL = 1;
2814             }
2815             #line 2816 "XS.c"
2816 0 0         TARGi((IV)RETVAL, 1);
2817 0           ST(0) = TARG;
2818             }
2819 0           XSRETURN(1);
2820             }
2821              
2822              
2823             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_open); /* prototype to pass -Wmissing-prototypes */
2824 0           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_open)
2825             {
2826 0 0         dVAR; dXSARGS;
2827 0 0         if (items != 1)
2828 0           croak_xs_usage(cv, "SV *");
2829             {
2830             #line 42 "./MemoryBuffer.xs"
2831             { }
2832             #line 2833 "XS.c"
2833             }
2834 0           XSRETURN_EMPTY;
2835             }
2836              
2837              
2838             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_close); /* prototype to pass -Wmissing-prototypes */
2839 0           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_close)
2840             {
2841 0 0         dVAR; dXSARGS;
2842 0 0         if (items != 1)
2843 0           croak_xs_usage(cv, "SV *");
2844             {
2845             #line 47 "./MemoryBuffer.xs"
2846             { }
2847             #line 2848 "XS.c"
2848             }
2849 0           XSRETURN_EMPTY;
2850             }
2851              
2852              
2853             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_flush); /* prototype to pass -Wmissing-prototypes */
2854 0           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_flush)
2855             {
2856 0 0         dVAR; dXSARGS;
2857 0 0         if (items != 1)
2858 0           croak_xs_usage(cv, "SV *");
2859             {
2860             #line 52 "./MemoryBuffer.xs"
2861             { }
2862             #line 2863 "XS.c"
2863             }
2864 0           XSRETURN_EMPTY;
2865             }
2866              
2867              
2868             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_available); /* prototype to pass -Wmissing-prototypes */
2869 1           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_available)
2870             {
2871 1 50         dVAR; dXSARGS;
2872 1 50         if (items != 1)
2873 0           croak_xs_usage(cv, "mbuf");
2874             {
2875             int RETVAL;
2876 1 50         dXSTARG;
2877 1           TMemoryBuffer * mbuf = (TMemoryBuffer *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "mbuf")
2878             ;
2879             #line 57 "./MemoryBuffer.xs"
2880             {
2881             RETVAL = buffer_len(mbuf->buffer);
2882             }
2883             #line 2884 "XS.c"
2884 1 50         TARGi((IV)RETVAL, 1);
2885 1           ST(0) = TARG;
2886             }
2887 1           XSRETURN(1);
2888             }
2889              
2890              
2891             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_read); /* prototype to pass -Wmissing-prototypes */
2892 56           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_read)
2893             {
2894 56 50         dVAR; dXSARGS;
2895 56 50         if (items != 2)
2896 0           croak_xs_usage(cv, "mbuf, len");
2897             {
2898             SV * RETVAL;
2899 56           TMemoryBuffer * mbuf = (TMemoryBuffer *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "mbuf")
2900             ;
2901 56           int len = (int)SvIV(ST(1))
2902             ;
2903             #line 66 "./MemoryBuffer.xs"
2904             {
2905             int avail = buffer_len(mbuf->buffer);
2906              
2907             if (avail == 0) {
2908             RETVAL = newSVpvn("", 0);
2909             }
2910             else {
2911             if (avail < len)
2912             len = avail;
2913              
2914             DEBUG_TRACE("read(%d)\n", len);
2915             RETVAL = newSVpvn( buffer_ptr(mbuf->buffer), len );
2916             buffer_consume(mbuf->buffer, len);
2917             }
2918             }
2919             #line 2920 "XS.c"
2920 56           RETVAL = sv_2mortal(RETVAL);
2921 56           ST(0) = RETVAL;
2922             }
2923 56           XSRETURN(1);
2924             }
2925              
2926              
2927             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_readAll); /* prototype to pass -Wmissing-prototypes */
2928 2           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_readAll)
2929             {
2930 2 50         dVAR; dXSARGS;
2931 2 50         if (items != 2)
2932 0           croak_xs_usage(cv, "mbuf, len");
2933             {
2934             SV * RETVAL;
2935 2           TMemoryBuffer * mbuf = (TMemoryBuffer *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "mbuf")
2936             ;
2937 2           int len = (int)SvIV(ST(1))
2938             ;
2939             #line 87 "./MemoryBuffer.xs"
2940             {
2941             int avail = buffer_len(mbuf->buffer);
2942              
2943             if (avail < len) {
2944             THROW_SV("Thrift::TTransportException", newSVpvf("Attempt to readAll(%d) found only %d available", len, avail));
2945             }
2946              
2947             DEBUG_TRACE("readAll(%d)\n", len);
2948             #ifdef XS_DEBUG
2949             //buffer_dump(mbuf->buffer, len);
2950             #endif
2951              
2952             RETVAL = newSVpvn( buffer_ptr(mbuf->buffer), len );
2953             buffer_consume(mbuf->buffer, len);
2954             }
2955             #line 2956 "XS.c"
2956 1           RETVAL = sv_2mortal(RETVAL);
2957 1           ST(0) = RETVAL;
2958             }
2959 1           XSRETURN(1);
2960             }
2961              
2962              
2963             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_write); /* prototype to pass -Wmissing-prototypes */
2964 3           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_write)
2965             {
2966 3 50         dVAR; dXSARGS;
2967 3 50         if (items < 2)
2968 0           croak_xs_usage(cv, "mbuf, buf, ...");
2969             {
2970 3           TMemoryBuffer * mbuf = (TMemoryBuffer *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "mbuf")
2971             ;
2972 3 50         SV * buf = ST(1)
2973             ;
2974             #line 108 "./MemoryBuffer.xs"
2975             {
2976             int len;
2977              
2978             if (items > 2)
2979             len = SvIV(ST(2));
2980             else
2981             len = sv_len(buf);
2982              
2983             buffer_append(mbuf->buffer, (void *)SvPVX(buf), len);
2984              
2985             DEBUG_TRACE("write(%d)\n", len);
2986             #ifdef XS_DEBUG
2987             //buffer_dump(mbuf->buffer, 0);
2988             #endif
2989             }
2990             #line 2991 "XS.c"
2991             }
2992 3           XSRETURN_EMPTY;
2993             }
2994              
2995              
2996             XS_EUPXS(XS_Thrift__XS__MemoryBuffer_DESTROY); /* prototype to pass -Wmissing-prototypes */
2997 3           XS_EUPXS(XS_Thrift__XS__MemoryBuffer_DESTROY)
2998             {
2999 3 50         dVAR; dXSARGS;
3000 3 50         if (items != 1)
3001 0           croak_xs_usage(cv, "mbuf");
3002             {
3003 3           TMemoryBuffer * mbuf = (TMemoryBuffer *)xs_object_magic_get_struct_rv_pretty(aTHX_ ST(0), "mbuf")
3004             ;
3005             #line 127 "./MemoryBuffer.xs"
3006             {
3007             MEM_TRACE("DESTROY()\n");
3008             MEM_TRACE(" free buffer @ %p\n", mbuf->buffer);
3009             MEM_TRACE(" free mbuf @ %p\n", mbuf);
3010              
3011             buffer_free(mbuf->buffer);
3012             Safefree(mbuf->buffer);
3013             Safefree(mbuf);
3014             }
3015             #line 3016 "XS.c"
3016             }
3017 3           XSRETURN_EMPTY;
3018             }
3019              
3020              
3021             /* INCLUDE: Returning to 'XS.xs' from 'MemoryBuffer.xs' */
3022              
3023             #ifdef __cplusplus
3024             extern "C" {
3025             #endif
3026             XS_EXTERNAL(boot_Thrift__XS); /* prototype to pass -Wmissing-prototypes */
3027 4           XS_EXTERNAL(boot_Thrift__XS)
3028             {
3029             #if PERL_VERSION_LE(5, 21, 5)
3030             dVAR; dXSARGS;
3031             #else
3032 4           dVAR; dXSBOOTARGSXSAPIVERCHK;
3033             #endif
3034             #if PERL_VERSION_LE(5, 8, 999) /* PERL_VERSION_LT is 5.33+ */
3035             char* file = __FILE__;
3036             #else
3037             const char* file = __FILE__;
3038             #endif
3039              
3040             PERL_UNUSED_VAR(file);
3041              
3042             PERL_UNUSED_VAR(cv); /* -W */
3043             PERL_UNUSED_VAR(items); /* -W */
3044             #if PERL_VERSION_LE(5, 21, 5)
3045             XS_VERSION_BOOTCHECK;
3046             # ifdef XS_APIVERSION_BOOTCHECK
3047             XS_APIVERSION_BOOTCHECK;
3048             # endif
3049             #endif
3050              
3051 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::resetState", XS_Thrift__XS__CompactProtocol_resetState, file, "$");
3052 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeMessageBegin", XS_Thrift__XS__CompactProtocol_writeMessageBegin, file, "$$$$");
3053 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeStructBegin", XS_Thrift__XS__CompactProtocol_writeStructBegin, file, "$$");
3054 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeStructEnd", XS_Thrift__XS__CompactProtocol_writeStructEnd, file, "$");
3055 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeFieldBegin", XS_Thrift__XS__CompactProtocol_writeFieldBegin, file, "$$$$");
3056 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeMapBegin", XS_Thrift__XS__CompactProtocol_writeMapBegin, file, "$$$$");
3057 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeListBegin", XS_Thrift__XS__CompactProtocol_writeListBegin, file, "$$$");
3058 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeSetBegin", XS_Thrift__XS__CompactProtocol_writeSetBegin, file, "$$$");
3059 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeBool", XS_Thrift__XS__CompactProtocol_writeBool, file, "$$");
3060 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeI16", XS_Thrift__XS__CompactProtocol_writeI16, file, "$$");
3061 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeI32", XS_Thrift__XS__CompactProtocol_writeI32, file, "$$");
3062 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeI64", XS_Thrift__XS__CompactProtocol_writeI64, file, "$$");
3063 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeDouble", XS_Thrift__XS__CompactProtocol_writeDouble, file, "$$");
3064 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::writeString", XS_Thrift__XS__CompactProtocol_writeString, file, "$$");
3065 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readMessageBegin", XS_Thrift__XS__CompactProtocol_readMessageBegin, file, "$$$$");
3066 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readStructBegin", XS_Thrift__XS__CompactProtocol_readStructBegin, file, "$$");
3067 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readStructEnd", XS_Thrift__XS__CompactProtocol_readStructEnd, file, "$");
3068 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readFieldBegin", XS_Thrift__XS__CompactProtocol_readFieldBegin, file, "$$$$");
3069 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readMapBegin", XS_Thrift__XS__CompactProtocol_readMapBegin, file, "$$$$");
3070 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readListBegin", XS_Thrift__XS__CompactProtocol_readListBegin, file, "$$$");
3071 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readSetBegin", XS_Thrift__XS__CompactProtocol_readSetBegin, file, "$$$");
3072 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readBool", XS_Thrift__XS__CompactProtocol_readBool, file, "$$");
3073 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readI16", XS_Thrift__XS__CompactProtocol_readI16, file, "$$");
3074 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readI32", XS_Thrift__XS__CompactProtocol_readI32, file, "$$");
3075 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readI64", XS_Thrift__XS__CompactProtocol_readI64, file, "$$");
3076 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readDouble", XS_Thrift__XS__CompactProtocol_readDouble, file, "$$");
3077 4           (void)newXSproto_portable("Thrift::XS::CompactProtocol::readString", XS_Thrift__XS__CompactProtocol_readString, file, "$$");
3078 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::new", XS_Thrift__XS__BinaryProtocol_new, file, "$$");
3079 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::DESTROY", XS_Thrift__XS__BinaryProtocol_DESTROY, file, "$");
3080 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::getTransport", XS_Thrift__XS__BinaryProtocol_getTransport, file, "$");
3081 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeMessageBegin", XS_Thrift__XS__BinaryProtocol_writeMessageBegin, file, "$$$$");
3082 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeMessageEnd", XS_Thrift__XS__BinaryProtocol_writeMessageEnd, file, "$");
3083 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeStructBegin", XS_Thrift__XS__BinaryProtocol_writeStructBegin, file, "$$");
3084 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeStructEnd", XS_Thrift__XS__BinaryProtocol_writeStructEnd, file, "$");
3085 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeFieldBegin", XS_Thrift__XS__BinaryProtocol_writeFieldBegin, file, "$$$$");
3086 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeFieldEnd", XS_Thrift__XS__BinaryProtocol_writeFieldEnd, file, "$");
3087 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeFieldStop", XS_Thrift__XS__BinaryProtocol_writeFieldStop, file, "$");
3088 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeMapBegin", XS_Thrift__XS__BinaryProtocol_writeMapBegin, file, "$$$$");
3089 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeMapEnd", XS_Thrift__XS__BinaryProtocol_writeMapEnd, file, "$");
3090 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeListBegin", XS_Thrift__XS__BinaryProtocol_writeListBegin, file, "$$$");
3091 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeListEnd", XS_Thrift__XS__BinaryProtocol_writeListEnd, file, "$");
3092 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeSetBegin", XS_Thrift__XS__BinaryProtocol_writeSetBegin, file, "$$$");
3093 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeSetEnd", XS_Thrift__XS__BinaryProtocol_writeSetEnd, file, "$");
3094 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeBool", XS_Thrift__XS__BinaryProtocol_writeBool, file, "$$");
3095 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeByte", XS_Thrift__XS__BinaryProtocol_writeByte, file, "$$");
3096 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeI16", XS_Thrift__XS__BinaryProtocol_writeI16, file, "$$");
3097 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeI32", XS_Thrift__XS__BinaryProtocol_writeI32, file, "$$");
3098 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeI64", XS_Thrift__XS__BinaryProtocol_writeI64, file, "$$");
3099 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeDouble", XS_Thrift__XS__BinaryProtocol_writeDouble, file, "$$");
3100 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::writeString", XS_Thrift__XS__BinaryProtocol_writeString, file, "$$");
3101 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readMessageBegin", XS_Thrift__XS__BinaryProtocol_readMessageBegin, file, "$$$$");
3102 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readMessageEnd", XS_Thrift__XS__BinaryProtocol_readMessageEnd, file, "$");
3103 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readStructBegin", XS_Thrift__XS__BinaryProtocol_readStructBegin, file, "$$");
3104 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readStructEnd", XS_Thrift__XS__BinaryProtocol_readStructEnd, file, "$");
3105 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readFieldBegin", XS_Thrift__XS__BinaryProtocol_readFieldBegin, file, "$$$$");
3106 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readFieldEnd", XS_Thrift__XS__BinaryProtocol_readFieldEnd, file, "$");
3107 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readMapBegin", XS_Thrift__XS__BinaryProtocol_readMapBegin, file, "$$$$");
3108 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readMapEnd", XS_Thrift__XS__BinaryProtocol_readMapEnd, file, "$");
3109 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readListBegin", XS_Thrift__XS__BinaryProtocol_readListBegin, file, "$$$");
3110 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readListEnd", XS_Thrift__XS__BinaryProtocol_readListEnd, file, "$");
3111 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readSetBegin", XS_Thrift__XS__BinaryProtocol_readSetBegin, file, "$$$");
3112 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readSetEnd", XS_Thrift__XS__BinaryProtocol_readSetEnd, file, "$");
3113 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readBool", XS_Thrift__XS__BinaryProtocol_readBool, file, "$$");
3114 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readByte", XS_Thrift__XS__BinaryProtocol_readByte, file, "$$");
3115 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readI16", XS_Thrift__XS__BinaryProtocol_readI16, file, "$$");
3116 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readI32", XS_Thrift__XS__BinaryProtocol_readI32, file, "$$");
3117 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readI64", XS_Thrift__XS__BinaryProtocol_readI64, file, "$$");
3118 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readDouble", XS_Thrift__XS__BinaryProtocol_readDouble, file, "$$");
3119 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readString", XS_Thrift__XS__BinaryProtocol_readString, file, "$$");
3120 4           (void)newXSproto_portable("Thrift::XS::BinaryProtocol::readStringBody", XS_Thrift__XS__BinaryProtocol_readStringBody, file, "$$$");
3121 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::new", XS_Thrift__XS__MemoryBuffer_new, file, "$;@");
3122 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::isOpen", XS_Thrift__XS__MemoryBuffer_isOpen, file, "$");
3123 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::open", XS_Thrift__XS__MemoryBuffer_open, file, "$");
3124 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::close", XS_Thrift__XS__MemoryBuffer_close, file, "$");
3125 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::flush", XS_Thrift__XS__MemoryBuffer_flush, file, "$");
3126 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::available", XS_Thrift__XS__MemoryBuffer_available, file, "$");
3127 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::read", XS_Thrift__XS__MemoryBuffer_read, file, "$$");
3128 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::readAll", XS_Thrift__XS__MemoryBuffer_readAll, file, "$$");
3129 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::write", XS_Thrift__XS__MemoryBuffer_write, file, "$$;@");
3130 4           (void)newXSproto_portable("Thrift::XS::MemoryBuffer::DESTROY", XS_Thrift__XS__MemoryBuffer_DESTROY, file, "$");
3131             #if PERL_VERSION_LE(5, 21, 5)
3132             # if PERL_VERSION_GE(5, 9, 0)
3133             if (PL_unitcheckav)
3134             call_list(PL_scopestack_ix, PL_unitcheckav);
3135             # endif
3136             XSRETURN_YES;
3137             #else
3138 4           Perl_xs_boot_epilog(aTHX_ ax);
3139             #endif
3140 4           }
3141              
3142             #ifdef __cplusplus
3143             }
3144             #endif