File Coverage

BinaryProtocol.xs
Criterion Covered Total %
statement 179 192 93.2
branch 83 422 19.6
condition n/a
subroutine n/a
pod n/a
total 262 614 42.6


line stmt bran cond sub pod time code
1             MODULE = Thrift::XS PACKAGE = Thrift::XS::BinaryProtocol
2              
3             SV *
4             new(char *klass, SV *transport)
5             CODE:
6             {
7             TBinaryProtocol *p;
8 2           New(0, p, sizeof(TBinaryProtocol), TBinaryProtocol);
9 2           New(0, p->last_fields, sizeof(struct fieldq), struct fieldq);
10              
11             MEM_TRACE("new()\n");
12             MEM_TRACE(" New p @ %p\n", p);
13             MEM_TRACE(" New last_fields @ %p\n", p->last_fields);
14              
15 2 50         if (sv_isa(transport, "Thrift::XS::MemoryBuffer"))
16 2           p->mbuf = (TMemoryBuffer *)xs_object_magic_get_struct_rv_pretty(aTHX_ transport, "mbuf");
17             else
18 0           p->mbuf = NULL;
19              
20 2           p->transport = transport;
21              
22 2           p->bool_type = -1;
23 2           p->bool_id = -1;
24 2           p->bool_value_id = -1;
25 2           p->last_field_id = 0;
26              
27 2           SIMPLEQ_INIT(p->last_fields);
28              
29 2           RETVAL = xs_object_magic_create(
30             aTHX_
31             (void *)p,
32             gv_stashpv(klass, 0)
33             );
34             }
35             OUTPUT:
36             RETVAL
37              
38             void
39             DESTROY(TBinaryProtocol *p)
40             CODE:
41             {
42             MEM_TRACE("DESTROY()\n");
43              
44             // clear field queue
45             struct field_entry *entry;
46 2 50         while (!SIMPLEQ_EMPTY(p->last_fields)) {
47             entry = SIMPLEQ_FIRST(p->last_fields);
48 0 0         SIMPLEQ_REMOVE_HEAD(p->last_fields, entries);
49             MEM_TRACE(" free entry @ %p\n", entry);
50 0           Safefree(entry);
51             }
52              
53             MEM_TRACE(" free last_fields @ %p\n", p->last_fields);
54 2           Safefree(p->last_fields);
55             MEM_TRACE(" free p @ %p\n", p);
56 2           Safefree(p);
57             }
58              
59             SV *
60             getTransport(TBinaryProtocol *p)
61             CODE:
62             {
63 2 50         SvREFCNT_inc(p->transport);
64 2           RETVAL = p->transport;
65             }
66             OUTPUT:
67             RETVAL
68              
69             int
70             writeMessageBegin(TBinaryProtocol *p, SV *name, int type, int seqid)
71             CODE:
72             {
73             DEBUG_TRACE("writeMessageBegin()\n");
74             RETVAL = 0;
75              
76 3           SV *namecopy = sv_mortalcopy(name); // because we can't modify the original name
77 3           sv_utf8_encode(namecopy);
78 3           int namelen = sv_len(namecopy);
79 3           SV *data = sv_2mortal(newSV(8 + 4+namelen));
80             char i32[4];
81              
82             // i32 type
83 3           type = VERSION_1 | type;
84 3           INT_TO_I32(i32, type, 0);
85 3           sv_setpvn(data, i32, 4);
86             RETVAL += 4;
87              
88             // i32 len + string
89 3           INT_TO_I32(i32, namelen, 0);
90 3           sv_catpvn(data, i32, 4);
91 3           sv_catsv(data, namecopy);
92             RETVAL += 4 + namelen;
93              
94             // i32 seqid
95 3           INT_TO_I32(i32, seqid, 0);
96 3           sv_catpvn(data, i32, 4);
97             RETVAL += 4;
98              
99 3 50         WRITE_SV(p, data);
    0          
    0          
    0          
    0          
100             }
101             OUTPUT:
102             RETVAL
103              
104             int
105             writeMessageEnd(SV *)
106             CODE:
107             {
108             RETVAL = 0;
109             }
110             OUTPUT:
111             RETVAL
112              
113             int
114             writeStructBegin(SV *, SV *)
115             CODE:
116             {
117             RETVAL = 0;
118             }
119             OUTPUT:
120             RETVAL
121              
122             int
123             writeStructEnd(SV *)
124             CODE:
125             {
126             RETVAL = 0;
127             }
128             OUTPUT:
129             RETVAL
130              
131             int
132             writeFieldBegin(TBinaryProtocol *p, SV *name, int type, int id)
133             CODE:
134             {
135             DEBUG_TRACE("writeFieldBegin(type %d, id %d)\n", type, id);
136             char data[3];
137             RETVAL = 0;
138              
139             PERL_UNUSED_VAR(name);
140 2           data[0] = type & 0xff; // byte
141 2           data[1] = (id >> 8) & 0xff; // i16
142 2           data[2] = id & 0xff;
143              
144 2 50         WRITE(p, data, 3);
    0          
    0          
    0          
    0          
145             RETVAL += 3;
146             }
147             OUTPUT:
148             RETVAL
149              
150             int
151             writeFieldEnd(SV *)
152             CODE:
153             {
154             RETVAL = 0;
155             }
156             OUTPUT:
157             RETVAL
158              
159             int
160             writeFieldStop(TBinaryProtocol *p)
161             CODE:
162             {
163             DEBUG_TRACE("writeFieldStop()\n");
164             RETVAL = 0;
165              
166             char data[1];
167 5           data[0] = T_STOP;
168              
169 5 50         WRITE(p, data, 1);
    0          
    0          
    0          
    0          
170             RETVAL += 1;
171             }
172             OUTPUT:
173             RETVAL
174              
175             int
176             writeMapBegin(TBinaryProtocol *p, int keytype, int valtype, int size)
177             CODE:
178             {
179             DEBUG_TRACE("writeMapBegin(keytype %d, valtype %d, size %d)\n", keytype, valtype, size);
180             char data[6];
181             RETVAL = 0;
182              
183 2           data[0] = keytype & 0xff;
184 2           data[1] = valtype & 0xff;
185 2           INT_TO_I32(data, size, 2);
186              
187 2 50         WRITE(p, data, 6);
    0          
    0          
    0          
    0          
188             RETVAL += 6;
189             }
190             OUTPUT:
191             RETVAL
192              
193             int
194             writeMapEnd(SV *)
195             CODE:
196             {
197             RETVAL = 0;
198             }
199             OUTPUT:
200             RETVAL
201              
202             int
203             writeListBegin(TBinaryProtocol *p, int elemtype, int size)
204             CODE:
205             {
206             DEBUG_TRACE("writeListBegin(elemtype %d, size %d)\n", elemtype, size);
207             char data[5];
208             RETVAL = 0;
209              
210 2           data[0] = elemtype & 0xff;
211 2           INT_TO_I32(data, size, 1);
212              
213 2 50         WRITE(p, data, 5);
    0          
    0          
    0          
    0          
214             RETVAL += 5;
215             }
216             OUTPUT:
217             RETVAL
218              
219             int
220             writeListEnd(SV *)
221             CODE:
222             {
223             RETVAL = 0;
224             }
225             OUTPUT:
226             RETVAL
227              
228             int
229             writeSetBegin(TBinaryProtocol *p, int elemtype, int size)
230             CODE:
231             {
232             DEBUG_TRACE("writeSetBegin(elemtype %d, size %d)\n", elemtype, size);
233             char data[5];
234             RETVAL = 0;
235              
236 2           data[0] = elemtype & 0xff;
237 2           INT_TO_I32(data, size, 1);
238              
239 2 50         WRITE(p, data, 5);
    0          
    0          
    0          
    0          
240             RETVAL += 5;
241             }
242             OUTPUT:
243             RETVAL
244              
245             int
246             writeSetEnd(SV *)
247             CODE:
248             {
249             RETVAL = 0;
250             }
251             OUTPUT:
252             RETVAL
253              
254             int
255             writeBool(TBinaryProtocol *p, SV *value)
256             CODE:
257             {
258             DEBUG_TRACE("writeBool(%d)\n", SvTRUE(value) ? 1 : 0);
259             char data[1];
260             RETVAL = 0;
261              
262 4           data[0] = SvTRUE(value) ? 1 : 0;
263              
264 4 50         WRITE(p, data, 1);
    0          
    0          
    0          
    0          
265             RETVAL += 1;
266             }
267             OUTPUT:
268             RETVAL
269              
270             int
271             writeByte(TBinaryProtocol *p, SV *value)
272             CODE:
273             {
274             DEBUG_TRACE("writeByte(%ld)\n", SvIV(value) & 0xff);
275             char data[1];
276             RETVAL = 0;
277              
278 4           data[0] = SvIV(value) & 0xff;
279              
280 4 50         WRITE(p, data, 1);
    0          
    0          
    0          
    0          
281             RETVAL += 1;
282             }
283             OUTPUT:
284             RETVAL
285              
286             int
287             writeI16(TBinaryProtocol *p, int value)
288             CODE:
289             {
290             DEBUG_TRACE("writeI16(%d)\n", value);
291             char data[2];
292             RETVAL = 0;
293              
294 3           INT_TO_I16(data, value, 0);
295              
296 3 50         WRITE(p, data, 2);
    0          
    0          
    0          
    0          
297             RETVAL += 2;
298             }
299             OUTPUT:
300             RETVAL
301              
302             int
303             writeI32(TBinaryProtocol *p, int value)
304             CODE:
305             {
306             DEBUG_TRACE("writeI32(%d)\n", value);
307             char data[4];
308             RETVAL = 0;
309              
310 3           INT_TO_I32(data, value, 0);
311              
312 3 50         WRITE(p, data, 4);
    0          
    0          
    0          
    0          
313             RETVAL += 4;
314             }
315             OUTPUT:
316             RETVAL
317              
318             int
319             writeI64(TBinaryProtocol *p, SV *value)
320             CODE:
321             {
322             char data[8];
323             RETVAL = 0;
324              
325             // Stringify the value, then convert to an int64_t
326 3 50         const char *str = SvPOK(value) ? SvPVX(value) : SvPV_nolen(value);
327 3           int64_t i64 = (int64_t)strtoll(str, NULL, 10);
328              
329             DEBUG_TRACE("writeI64(%" PRId64 ") (from string %s)\n", i64, str);
330              
331 3           data[7] = i64 & 0xff;
332 3           data[6] = (i64 >> 8) & 0xff;
333 3           data[5] = (i64 >> 16) & 0xff;
334 3           data[4] = (i64 >> 24) & 0xff;
335 3           data[3] = (i64 >> 32) & 0xff;
336 3           data[2] = (i64 >> 40) & 0xff;
337 3           data[1] = (i64 >> 48) & 0xff;
338 3           data[0] = (i64 >> 56) & 0xff;
339              
340 3 50         WRITE(p, data, 8);
    0          
    0          
    0          
    0          
341             RETVAL += 8;
342             }
343             OUTPUT:
344             RETVAL
345              
346             int
347             writeDouble(TBinaryProtocol *p, SV *value)
348             CODE:
349             {
350             DEBUG_TRACE("writeDouble(%f)\n", (double)SvNV(value));
351             char data[8];
352             union {
353             double from;
354             uint64_t to;
355             } u;
356             RETVAL = 0;
357              
358 2           u.from = (double)SvNV(value);
359             uint64_t bits = u.to;
360 2 50         bits = htonll(bits);
361              
362             memcpy(&data, (uint8_t *)&bits, 8);
363              
364 2 50         WRITE(p, data, 8);
    0          
    0          
    0          
    0          
365             RETVAL += 8;
366             }
367             OUTPUT:
368             RETVAL
369              
370             int
371             writeString(TBinaryProtocol *p, SV *value)
372             CODE:
373             {
374             DEBUG_TRACE("writeString(%s)\n", SvPVX(value));
375             RETVAL = 0;
376              
377 6           SV *valuecopy = sv_mortalcopy(value);
378 6 100         if (SvUTF8(value) != 0) {
379 3           sv_utf8_encode(valuecopy);
380             }
381 6           int len = sv_len(valuecopy);
382 6           SV *data = sv_2mortal(newSV(4 + len));
383             char i32[4];
384              
385 6           INT_TO_I32(i32, len, 0);
386 6           sv_setpvn(data, i32, 4);
387             RETVAL += 4;
388 6           sv_catsv(data, valuecopy);
389             RETVAL += len;
390              
391 6 50         WRITE_SV(p, data);
    0          
    0          
    0          
    0          
392             }
393             OUTPUT:
394             RETVAL
395              
396             int
397             readMessageBegin(TBinaryProtocol *p, SV *name, SV *type, SV *seqid)
398             CODE:
399             {
400             DEBUG_TRACE("readMessageBegin()\n");
401             RETVAL = 0;
402              
403             SV *tmp;
404             int version;
405             char *tmps;
406              
407             // read version + type
408 1 50         READ_SV(p, tmp, 4);
    50          
    0          
    0          
    0          
    0          
409 1           tmps = SvPVX(tmp);
410 1           I32_TO_INT(version, tmps, 0);
411             RETVAL += 4;
412              
413 1 50         if (version < 0) {
414 1 50         if ((version & VERSION_MASK) != VERSION_1) {
415 0           THROW("Thrift::TException", "Missing version identifier");
416             }
417             // set type
418 1 50         if (SvROK(type))
419 1           sv_setiv(SvRV(type), version & 0x000000ff);
420              
421             // read string
422             {
423             uint32_t len;
424 1 50         READ_SV(p, tmp, 4);
    50          
    0          
    0          
    0          
    0          
425 1           tmps = SvPVX(tmp);
426 1           I32_TO_INT(len, tmps, 0);
427             RETVAL += 4;
428 1 50         if (len) {
429 1 50         READ_SV(p, tmp, len);
    50          
    0          
    0          
    0          
    0          
430 1           sv_utf8_decode(tmp);
431 1           RETVAL += len;
432 1 50         if (SvROK(name))
433 1           sv_setsv(SvRV(name), tmp);
434             }
435             else {
436 0 0         if (SvROK(name))
437 0           sv_setpv(SvRV(name), "");
438             }
439             }
440              
441             // read seqid
442             {
443             int s;
444 1 50         READ_SV(p, tmp, 4);
    50          
    0          
    0          
    0          
    0          
445 1           tmps = SvPVX(tmp);
446 1           I32_TO_INT(s, tmps, 0);
447 1           RETVAL += 4;
448 1 50         if (SvROK(seqid))
449 1           sv_setiv(SvRV(seqid), s);
450             }
451             }
452             else {
453 0           THROW("Thrift::TException", "Missing version identifier");
454             }
455             }
456             OUTPUT:
457             RETVAL
458              
459             int
460             readMessageEnd(SV *)
461             CODE:
462             {
463             RETVAL = 0;
464             }
465             OUTPUT:
466             RETVAL
467              
468             int
469             readStructBegin(SV *, SV *name)
470             CODE:
471             {
472             DEBUG_TRACE("readStructBegin()\n");
473             RETVAL = 0;
474              
475 1 50         if (SvROK(name))
476 1           sv_setpv(SvRV(name), "");
477             }
478             OUTPUT:
479             RETVAL
480              
481             int
482             readStructEnd(SV *)
483             CODE:
484             {
485             RETVAL = 0;
486             }
487             OUTPUT:
488             RETVAL
489              
490             int
491             readFieldBegin(TBinaryProtocol *p, SV *name, SV *fieldtype, SV *fieldid)
492             CODE:
493             {
494             DEBUG_TRACE("readFieldBegin()\n");
495             SV *tmp;
496             char *tmps;
497             RETVAL = 0;
498              
499             PERL_UNUSED_VAR(name);
500 1 50         READ_SV(p, tmp, 1);
    50          
    0          
    0          
    0          
    0          
501 1           tmps = SvPVX(tmp);
502             RETVAL += 1;
503              
504             // fieldtype byte
505 1 50         if (SvROK(fieldtype))
506 1           sv_setiv(SvRV(fieldtype), tmps[0]);
507              
508 1 50         if (tmps[0] == T_STOP) {
509 0 0         if (SvROK(fieldid))
510 0           sv_setiv(SvRV(fieldid), 0);
511             }
512             else {
513             // fieldid i16
514 1 50         READ_SV(p, tmp, 2);
    50          
    0          
    0          
    0          
    0          
515 1           tmps = SvPVX(tmp);
516             int fid;
517 1           I16_TO_INT(fid, tmps, 0);
518             RETVAL += 2;
519 1 50         if (SvROK(fieldid))
520 1           sv_setiv(SvRV(fieldid), fid);
521             }
522             }
523             OUTPUT:
524             RETVAL
525              
526             int
527             readFieldEnd(SV *)
528             CODE:
529             {
530             RETVAL = 0;
531             }
532             OUTPUT:
533             RETVAL
534              
535             int
536             readMapBegin(TBinaryProtocol *p, SV *keytype, SV *valtype, SV *size)
537             CODE:
538             {
539             DEBUG_TRACE("readMapBegin()\n");
540             SV *tmp;
541             char *tmps;
542             RETVAL = 0;
543              
544 1 50         READ_SV(p, tmp, 6);
    50          
    0          
    0          
    0          
    0          
545 1           tmps = SvPVX(tmp);
546             RETVAL += 6;
547              
548             // keytype byte
549 1 50         if (SvROK(keytype))
550 1           sv_setiv(SvRV(keytype), tmps[0]);
551              
552             // valtype byte
553 1 50         if (SvROK(valtype))
554 1           sv_setiv(SvRV(valtype), tmps[1]);
555              
556             // size i32
557             int isize;
558 1           I32_TO_INT(isize, tmps, 2);
559 1 50         if (SvROK(size))
560 1           sv_setiv(SvRV(size), isize);
561             }
562             OUTPUT:
563             RETVAL
564              
565             int
566             readMapEnd(SV *)
567             CODE:
568             {
569             RETVAL = 0;
570             }
571             OUTPUT:
572             RETVAL
573              
574             int
575             readListBegin(TBinaryProtocol *p, SV *elemtype, SV *size)
576             CODE:
577             {
578             DEBUG_TRACE("readListBegin()\n");
579             SV *tmp;
580             char *tmps;
581             RETVAL = 0;
582              
583 1 50         READ_SV(p, tmp, 5);
    50          
    0          
    0          
    0          
    0          
584 1           tmps = SvPVX(tmp);
585             RETVAL += 5;
586              
587             // elemtype byte
588 1 50         if (SvROK(elemtype))
589 1           sv_setiv(SvRV(elemtype), tmps[0]);
590              
591             // size i32
592             int isize;
593 1           I32_TO_INT(isize, tmps, 1);
594 1 50         if (SvROK(size))
595 1           sv_setiv(SvRV(size), isize);
596             }
597             OUTPUT:
598             RETVAL
599              
600             int
601             readListEnd(SV *)
602             CODE:
603             {
604             RETVAL = 0;
605             }
606             OUTPUT:
607             RETVAL
608              
609             int
610             readSetBegin(TBinaryProtocol *p, SV *elemtype, SV *size)
611             CODE:
612             {
613             DEBUG_TRACE("readSetBegin()\n");
614             SV *tmp;
615             char *tmps;
616             RETVAL = 0;
617              
618 1 50         READ_SV(p, tmp, 5);
    50          
    0          
    0          
    0          
    0          
619 1           tmps = SvPVX(tmp);
620             RETVAL += 5;
621              
622             // elemtype byte
623 1 50         if (SvROK(elemtype))
624 1           sv_setiv(SvRV(elemtype), tmps[0]);
625              
626             // size i32
627             int isize;
628 1           I32_TO_INT(isize, tmps, 1);
629 1 50         if (SvROK(size))
630 1           sv_setiv(SvRV(size), isize);
631             }
632             OUTPUT:
633             RETVAL
634              
635             int
636             readSetEnd(SV *)
637             CODE:
638             {
639             RETVAL = 0;
640             }
641             OUTPUT:
642             RETVAL
643              
644             int
645             readBool(TBinaryProtocol *p, SV *value)
646             CODE:
647             {
648             DEBUG_TRACE("readBool()\n");
649             SV *tmp;
650             char *tmps;
651             RETVAL = 0;
652              
653 2 50         READ_SV(p, tmp, 1);
    50          
    0          
    0          
    0          
    0          
654 2           tmps = SvPVX(tmp);
655             RETVAL += 1;
656              
657 2 50         if (SvROK(value))
658 2           sv_setiv(SvRV(value), tmps[0] ? 1 : 0);
659             }
660             OUTPUT:
661             RETVAL
662              
663             int
664             readByte(TBinaryProtocol *p, SV *value)
665             CODE:
666             {
667             DEBUG_TRACE("readByte()\n");
668             SV *tmp;
669             char *tmps;
670             RETVAL = 0;
671              
672 2 50         READ_SV(p, tmp, 1);
    50          
    0          
    0          
    0          
    0          
673 2           tmps = SvPVX(tmp);
674             RETVAL += 1;
675              
676 2 50         if (SvROK(value))
677 2           sv_setiv(SvRV(value), tmps[0]);
678             }
679             OUTPUT:
680             RETVAL
681              
682             int
683             readI16(TBinaryProtocol *p, SV *value)
684             CODE:
685             {
686             DEBUG_TRACE("readI16()\n");
687             SV *tmp;
688             char *tmps;
689             RETVAL = 0;
690              
691 1 50         READ_SV(p, tmp, 2);
    50          
    0          
    0          
    0          
    0          
692 1           tmps = SvPVX(tmp);
693             RETVAL += 2;
694              
695             int v;
696 1           I16_TO_INT(v, tmps, 0);
697 1 50         if (SvROK(value))
698 1           sv_setiv(SvRV(value), v);
699             }
700             OUTPUT:
701             RETVAL
702              
703             int
704             readI32(TBinaryProtocol *p, SV *value)
705             CODE:
706             {
707             DEBUG_TRACE("readI32()\n");
708             SV *tmp;
709             char *tmps;
710             RETVAL = 0;
711              
712 2 50         READ_SV(p, tmp, 4);
    50          
    0          
    0          
    0          
    0          
713 2           tmps = SvPVX(tmp);
714             RETVAL += 4;
715              
716             int v;
717 2           I32_TO_INT(v, tmps, 0);
718 2 50         if (SvROK(value))
719 2           sv_setiv(SvRV(value), v);
720             }
721             OUTPUT:
722             RETVAL
723              
724             int
725             readI64(TBinaryProtocol *p, SV *value)
726             CODE:
727             {
728             DEBUG_TRACE("readI64()\n");
729             SV *tmp;
730             char *tmps;
731             RETVAL = 0;
732              
733 1 50         READ_SV(p, tmp, 8);
    50          
    0          
    0          
    0          
    0          
734 1           tmps = SvPVX(tmp);
735             RETVAL += 8;
736              
737             int64_t hi;
738             uint32_t lo;
739 1           I32_TO_INT(hi, tmps, 0);
740 1           I32_TO_INT(lo, tmps, 4);
741              
742 1 50         if (SvROK(value)) {
743             char string[25];
744             STRLEN length;
745 1           length = sprintf(string, "%" PRId64, (int64_t)(hi << 32) | lo);
746 1           sv_setpvn(SvRV(value), string, length);
747             }
748             }
749             OUTPUT:
750             RETVAL
751              
752             int
753             readDouble(TBinaryProtocol *p, SV *value)
754             CODE:
755             {
756             DEBUG_TRACE("readDouble()\n");
757             SV *tmp;
758             char *tmps;
759             uint64_t bits;
760             RETVAL = 0;
761              
762 1 50         READ_SV(p, tmp, 8);
    50          
    0          
    0          
    0          
    0          
763 1           tmps = SvPVX(tmp);
764             RETVAL += 8;
765              
766 1           bits = *(uint64_t *)tmps;
767 1           bits = ntohll(bits);
768              
769             union {
770             uint64_t from;
771             double to;
772             } u;
773             u.from = bits;
774              
775 1 50         if (SvROK(value))
776 1           sv_setnv(SvRV(value), u.to);
777             }
778             OUTPUT:
779             RETVAL
780              
781             int
782             readString(TBinaryProtocol *p, SV *value)
783             CODE:
784             {
785             DEBUG_TRACE("readString()\n");
786             SV *tmp;
787             char *tmps;
788             RETVAL = 0;
789              
790             uint32_t len;
791 1 50         READ_SV(p, tmp, 4);
    50          
    0          
    0          
    0          
    0          
792 1           tmps = SvPVX(tmp);
793 1           I32_TO_INT(len, tmps, 0);
794             RETVAL += 4;
795 1 50         if (len) {
796 1 50         READ_SV(p, tmp, len);
    50          
    0          
    0          
    0          
    0          
797 1           sv_utf8_decode(tmp);
798 1           RETVAL += len;
799 1 50         if (SvROK(value))
800 1           sv_setsv(SvRV(value), tmp);
801             }
802             else {
803 0 0         if (SvROK(value))
804 0           sv_setpv(SvRV(value), "");
805             }
806             }
807             OUTPUT:
808             RETVAL
809              
810             int
811             readStringBody(TBinaryProtocol *p, SV *value, uint32_t len)
812             CODE:
813             {
814             // This method is never used but is here for compat
815             SV *tmp;
816             RETVAL = 0;
817              
818 1 50         if (len) {
819 1 50         READ_SV(p, tmp, len);
    50          
    0          
    0          
    0          
    0          
820 1           sv_utf8_decode(tmp);
821 1           RETVAL += len;
822 1 50         if (SvROK(value))
823 1           sv_setsv(SvRV(value), tmp);
824             }
825             else {
826 0 0         if (SvROK(value))
827 0           sv_setpv(SvRV(value), "");
828             }
829             }
830             OUTPUT:
831             RETVAL