mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
THRIFT-342. php: PHP: can't have sets of complex types
This patch implements a dual approach for scalars vs objects. Patch: Jake Farrell git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1091580 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f3a51e6b03
commit
b891145894
@ -1870,8 +1870,11 @@ void t_php_generator::generate_deserialize_set_element(ofstream &out,
|
||||
|
||||
generate_deserialize_field(out, &felem);
|
||||
|
||||
indent(out) <<
|
||||
"$" << prefix << "[$" << elem << "] = true;" << endl;
|
||||
indent(out) << "if (is_scalar($" << elem << ")) {" << endl;
|
||||
indent(out) << " $" << prefix << "[$" << elem << "] = true;" << endl;
|
||||
indent(out) << "} else {" << endl;
|
||||
indent(out) << " $" << prefix << " []= $" << elem << ";" << endl;
|
||||
indent(out) << "}" << endl;
|
||||
}
|
||||
|
||||
void t_php_generator::generate_deserialize_list_element(ofstream &out,
|
||||
@ -2087,8 +2090,11 @@ void t_php_generator::generate_serialize_container(ofstream &out,
|
||||
} else if (ttype->is_set()) {
|
||||
string iter = tmp("iter");
|
||||
indent(out) <<
|
||||
"foreach ($" << prefix << " as $" << iter << " => $true)" << endl;
|
||||
"foreach ($" << prefix << " as $" << iter << ")" << endl;
|
||||
scope_up(out);
|
||||
indent(out) << "if (is_scalar($" << iter << ")) {" << endl <<
|
||||
indent() << " $" << prefix << "[$" << iter << "] = true;" << endl <<
|
||||
indent() << "}" << endl;
|
||||
generate_serialize_set_element(out, (t_set*)ttype, iter);
|
||||
scope_down(out);
|
||||
} else if (ttype->is_list()) {
|
||||
|
Loading…
Reference in New Issue
Block a user