THRIFT-782. perl: Perl code for writing containers doesn't count length of write*Begin or write*End
This patch adds appropriate accounting of the start and end bytes when writing out container types.
Patch: Conrad Hughes
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@982812 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/compiler/cpp/src/generate/t_perl_generator.cc b/compiler/cpp/src/generate/t_perl_generator.cc
index e08ade2..cbfc786 100644
--- a/compiler/cpp/src/generate/t_perl_generator.cc
+++ b/compiler/cpp/src/generate/t_perl_generator.cc
@@ -1576,20 +1576,20 @@
if (ttype->is_map()) {
indent(out) <<
- "$output->writeMapBegin(" <<
+ "$xfer += $output->writeMapBegin(" <<
type_to_enum(((t_map*)ttype)->get_key_type()) << ", " <<
type_to_enum(((t_map*)ttype)->get_val_type()) << ", " <<
"scalar(keys %{$" << prefix << "}));" << endl;
} else if (ttype->is_set()) {
indent(out) <<
- "$output->writeSetBegin(" <<
+ "$xfer += $output->writeSetBegin(" <<
type_to_enum(((t_set*)ttype)->get_elem_type()) << ", " <<
"scalar(@{$" << prefix << "}));" << endl;
} else if (ttype->is_list()) {
indent(out) <<
- "$output->writeListBegin(" <<
+ "$xfer += $output->writeListBegin(" <<
type_to_enum(((t_list*)ttype)->get_elem_type()) << ", " <<
"scalar(@{$" << prefix << "}));" << endl;
@@ -1629,13 +1629,13 @@
if (ttype->is_map()) {
indent(out) <<
- "$output->writeMapEnd();" << endl;
+ "$xfer += $output->writeMapEnd();" << endl;
} else if (ttype->is_set()) {
indent(out) <<
- "$output->writeSetEnd();" << endl;
+ "$xfer += $output->writeSetEnd();" << endl;
} else if (ttype->is_list()) {
indent(out) <<
- "$output->writeListEnd();" << endl;
+ "$xfer += $output->writeListEnd();" << endl;
}
scope_down(out);