[Python] [Codegen] Fixes nested structs with underscore names (#6686)

Fixes #6648
This commit is contained in:
Russell Chreptyk
2021-06-10 15:52:19 -04:00
committed by GitHub
parent f069396d1b
commit 6415ef05d3

View File

@@ -478,7 +478,7 @@ class PythonGenerator : public BaseGenerator {
// a nested struct, prefix the name with the field name. // a nested struct, prefix the name with the field name.
auto subprefix = nameprefix; auto subprefix = nameprefix;
if (has_field_name) { if (has_field_name) {
subprefix += NormalizedName(field) + fieldname_suffix; subprefix += MakeLowerCamel(field) + fieldname_suffix;
} }
StructBuilderArgs(*field.value.type.struct_def, subprefix, namesuffix, StructBuilderArgs(*field.value.type.struct_def, subprefix, namesuffix,
has_field_name, fieldname_suffix, code_ptr); has_field_name, fieldname_suffix, code_ptr);
@@ -518,7 +518,7 @@ class PythonGenerator : public BaseGenerator {
indent + " builder.Pad(" + NumToString(field.padding) + ")\n"; indent + " builder.Pad(" + NumToString(field.padding) + ")\n";
if (IsStruct(field_type)) { if (IsStruct(field_type)) {
StructBuilderBody(*field_type.struct_def, StructBuilderBody(*field_type.struct_def,
(nameprefix + (NormalizedName(field) + "_")).c_str(), (nameprefix + (MakeLowerCamel(field) + "_")).c_str(),
code_ptr, index, in_array); code_ptr, index, in_array);
} else { } else {
const auto index_var = "_idx" + NumToString(index); const auto index_var = "_idx" + NumToString(index);
@@ -531,7 +531,7 @@ class PythonGenerator : public BaseGenerator {
if (IsStruct(type)) { if (IsStruct(type)) {
StructBuilderBody( StructBuilderBody(
*field_type.struct_def, *field_type.struct_def,
(nameprefix + (NormalizedName(field) + "_")).c_str(), code_ptr, (nameprefix + (MakeLowerCamel(field) + "_")).c_str(), code_ptr,
index + 1, in_array); index + 1, in_array);
} else { } else {
code += IsArray(field_type) ? " " : ""; code += IsArray(field_type) ? " " : "";