From: Tin Tvrtković Date: Thu, 7 Jun 2018 19:02:35 +0000 (+0200) Subject: Python: fix default bool value. (#4773) X-Git-Tag: v1.10.0~108 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab3b721a540f2279267235ee21767b7f705699a0;p=platform%2Fupstream%2Fflatbuffers.git Python: fix default bool value. (#4773) * Python: fix default bool value. * Small style tweak. --- diff --git a/src/idl_gen_python.cpp b/src/idl_gen_python.cpp index ba7dd56..419270c 100644 --- a/src/idl_gen_python.cpp +++ b/src/idl_gen_python.cpp @@ -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.