Commit ab3b721a authored by Tin Tvrtković's avatar Tin Tvrtković Committed by Wouter van Oortmerssen

Python: fix default bool value. (#4773)

* Python: fix default bool value.

* Small style tweak.
parent 4cfe36ae
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment