From a28357d7ac57e23d4174bf47a8a99d4fad042e83 Mon Sep 17 00:00:00 2001 From: Mika Raento Date: Thu, 11 Jun 2020 20:15:19 +0300 Subject: [PATCH] Propagate boolean default values from proto to fbs (#5964) --- src/idl_parser.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/idl_parser.cpp b/src/idl_parser.cpp index 4749f36..af74610 100644 --- a/src/idl_parser.cpp +++ b/src/idl_parser.cpp @@ -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"; } -- 2.7.4