Skip to content

Commit 365f38b

Browse files
committed
updates to the code generator
1 parent 2200cc3 commit 365f38b

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

gen/python_api_gen_mpy.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ def is_struct(type):
624624

625625
forward_struct_decls = {}
626626

627-
for item in ast.ext[:]:
627+
for item in ast.ext:
628628
if (
629629
isinstance(item, c_ast.Decl) and
630630
item.name is None and
@@ -633,17 +633,9 @@ def is_struct(type):
633633
):
634634
if item.type.decls is None:
635635
forward_struct_decls[item.type.name] = [item]
636-
else:
637-
if item.type.name in forward_struct_decls:
638-
decs = forward_struct_decls[item.type.name]
639-
if len(decs) == 2:
640-
decl, td = decs
641636

642-
td.type.type.decls = item.type.decls[:]
643-
644-
ast.ext.remove(decl)
645-
ast.ext.remove(item)
646-
elif (
637+
for item in ast.ext:
638+
if (
647639
isinstance(item, c_ast.Typedef) and
648640
isinstance(item.type, c_ast.TypeDecl) and
649641
item.name and item.type.declname and item.name == item.type.declname and
@@ -654,6 +646,23 @@ def is_struct(type):
654646
forward_struct_decls[item.type.type.name].append(item)
655647

656648

649+
for item in ast.ext[:]:
650+
if (
651+
isinstance(item, c_ast.Decl) and
652+
item.name is None and
653+
isinstance(item.type, c_ast.Struct) and
654+
item.type.name is not None
655+
):
656+
if item.type.name in forward_struct_decls:
657+
decs = forward_struct_decls[item.type.name]
658+
if len(decs) == 2:
659+
decl, td = decs
660+
661+
td.type.type.decls = item.type.decls[:]
662+
663+
ast.ext.remove(decl)
664+
ast.ext.remove(item)
665+
657666

658667
# ast_file = open(os.path.join(os.path.dirname(__file__), 'ast.txt'), 'w')
659668
# ast_file.write(str(ast))

0 commit comments

Comments
 (0)