You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jf...@apache.org on 2011/09/06 17:19:18 UTC

svn commit: r1165703 - /thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc

Author: jfarrell
Date: Tue Sep  6 15:19:18 2011
New Revision: 1165703

URL: http://svn.apache.org/viewvc?rev=1165703&view=rev
Log:
Thrift-1279: type set is handled incorrectly when writing object
Client: php
Patch: Darius Staisiunas

Fixes issue to iIterate through scalar types correctly.


Modified:
    thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc

Modified: thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc
URL: http://svn.apache.org/viewvc/thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc?rev=1165703&r1=1165702&r2=1165703&view=diff
==============================================================================
--- thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc (original)
+++ thrift/trunk/compiler/cpp/src/generate/t_php_generator.cc Tue Sep  6 15:19:18 2011
@@ -2136,13 +2136,15 @@ void t_php_generator::generate_serialize
     scope_down(out);
   } else if (ttype->is_set()) {
     string iter = tmp("iter");
+    string iter_val = tmp("iter");
     indent(out) <<
-      "foreach ($" << prefix << " as $" << iter << ")" << endl;
+      "foreach ($" << prefix << " as $" << iter << " => $" << iter_val << ")" << endl;
     scope_up(out);
-    indent(out) << "if (is_scalar($" << iter << ")) {" << endl <<
-      indent() << "  $" << prefix << "[$" << iter << "] = true;" << endl <<
-      indent() << "}" << endl;
+    indent(out) << "if (is_scalar($" << iter_val << ")) {" << endl;
     generate_serialize_set_element(out, (t_set*)ttype, iter);
+    indent(out) << "} else {" << endl;
+    generate_serialize_set_element(out, (t_set*)ttype, iter_val);
+    indent(out) << "}" << endl;
     scope_down(out);
   } else if (ttype->is_list()) {
     string iter = tmp("iter");