Python: fix default bool value. (#4773)
* Python: fix default bool value. * Small style tweak.
This commit is contained in:
parent
4cfe36ae8e
commit
ab3b721a54
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue