Python: fix default bool value. (#4773)

* Python: fix default bool value.

* Small style tweak.
This commit is contained in:
Tin Tvrtković 2018-06-07 21:02:35 +02:00 committed by Wouter van Oortmerssen
parent 4cfe36ae8e
commit ab3b721a54
1 changed files with 7 additions and 2 deletions

View File

@ -147,8 +147,13 @@ static void GetScalarFieldOfTable(const StructDef &struct_def,
getter = "bool(" + getter + ")";
}
code += Indent + Indent + Indent + "return " + getter + "\n";
auto defaultValue = (is_bool ? "False" : field.value.constant);
code += Indent + Indent + "return " + defaultValue + "\n\n";
std::string default_value;
if (is_bool) {
default_value = field.value.constant == "0" ? "False" : "True";
} else {
default_value = field.value.constant;
}
code += Indent + Indent + "return " + default_value + "\n\n";
}
// Get a struct by initializing an existing struct.