mirror of
https://github.com/valitydev/thrift.git
synced 2024-11-07 10:48:51 +00:00
THRIFT-1532 - slightly better fix, take into account requiredness when adding default values
git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1303666 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
31835148b2
commit
3bba214c13
@ -588,9 +588,13 @@ void t_erl_generator::generate_erl_struct_member(ostream & out, t_field * tmembe
|
|||||||
bool t_erl_generator::has_default_value(t_field * field) {
|
bool t_erl_generator::has_default_value(t_field * field) {
|
||||||
t_type *type = field->get_type();
|
t_type *type = field->get_type();
|
||||||
if (!field->get_value()) {
|
if (!field->get_value()) {
|
||||||
if (type->is_struct() || type->is_xception() || type->is_map() ||
|
if ( field->get_req() == t_field::T_REQUIRED) {
|
||||||
type->is_set() || type->is_list()) {
|
if (type->is_struct() || type->is_xception() || type->is_map() ||
|
||||||
return true;
|
type->is_set() || type->is_list()) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
struct StructB
|
||||||
|
{
|
||||||
|
1: string x
|
||||||
|
}
|
||||||
|
|
||||||
struct StructA
|
struct StructA
|
||||||
{
|
{
|
||||||
1: string a,
|
1: string a,
|
||||||
@ -17,6 +22,13 @@ struct StructA
|
|||||||
15: double o = 3.14159,
|
15: double o = 3.14159,
|
||||||
16: list<string> string_list,
|
16: list<string> string_list,
|
||||||
17: list<byte> byte_list = [1, 2, 3],
|
17: list<byte> byte_list = [1, 2, 3],
|
||||||
18: set<string> string_set,
|
18: required list<string> rsl,
|
||||||
19: map<string, string> string_map
|
19: optional list<string> osl,
|
||||||
|
20: set<string> string_set,
|
||||||
|
21: required set<string> rss,
|
||||||
|
22: optional set<string> oss,
|
||||||
|
23: map<string, string> string_map,
|
||||||
|
24: required map<string, string> rsm,
|
||||||
|
25: optional map<string, string> osm,
|
||||||
|
26: StructB structb
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user