mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-02 04:04:19 +00:00
Propagate boolean default values from proto to fbs (#5964)
This commit is contained in:
@@ -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";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user