mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-04 16:51:11 +00:00
Python: fix default bool value. (#4773)
* Python: fix default bool value. * Small style tweak.
This commit is contained in:
committed by
Wouter van Oortmerssen
parent
4cfe36ae8e
commit
ab3b721a54
@@ -147,8 +147,13 @@ static void GetScalarFieldOfTable(const StructDef &struct_def,
|
|||||||
getter = "bool(" + getter + ")";
|
getter = "bool(" + getter + ")";
|
||||||
}
|
}
|
||||||
code += Indent + Indent + Indent + "return " + getter + "\n";
|
code += Indent + Indent + Indent + "return " + getter + "\n";
|
||||||
auto defaultValue = (is_bool ? "False" : field.value.constant);
|
std::string default_value;
|
||||||
code += Indent + Indent + "return " + defaultValue + "\n\n";
|
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.
|
// Get a struct by initializing an existing struct.
|
||||||
|
|||||||
Reference in New Issue
Block a user