Propagate boolean default values from proto to fbs (#5964)

This commit is contained in:
Mika Raento
2020-06-11 20:15:19 +03:00
committed by GitHub
parent 7cb4762a61
commit a28357d7ac

View File

@@ -2608,10 +2608,13 @@ CheckedError Parser::ParseProtoFields(StructDef *struct_def, bool isextend,
auto val = attribute_;
ECHECK(ParseProtoCurliesOrIdent());
if (key == "default") {
// Temp: skip non-numeric defaults (enums).
// Temp: skip non-numeric and non-boolean defaults (enums).
auto numeric = strpbrk(val.c_str(), "0123456789-+.");
if (IsScalar(type.base_type) && numeric == val.c_str())
if (IsScalar(type.base_type) && numeric == val.c_str()) {
field->value.constant = val;
} else if (val == "true") {
field->value.constant = val;
} // "false" is default, no need to handle explicitly.
} else if (key == "deprecated") {
field->deprecated = val == "true";
}