Fixed whole-number float default values missing a .0 suffix.

A previous commit that added "f" for C++/Java/C# would break
on gcc of constants like 3f, which are now output as 3.0f

Tested: on Linux

Change-Id: If9cabbe3c6d6948a5050b8b123bda9c06e181f52
This commit is contained in:
Wouter van Oortmerssen
2016-04-18 11:48:53 -07:00
parent 791c83aa7e
commit 4d7890c2c9
12 changed files with 82 additions and 11 deletions

View File

@@ -543,6 +543,10 @@ CheckedError Parser::ParseField(StructDef &struct_def) {
if (!IsScalar(type.base_type))
return Error("default values currently only supported for scalars");
ECHECK(ParseSingleValue(field->value));
if (IsFloat(field->value.type.base_type)) {
if (!strpbrk(field->value.constant.c_str(), ".eE"))
field->value.constant += ".0";
}
}
if (type.enum_def &&