Skip to content

Commit 8153e8d

Browse files
committed
Add union support
1 parent cb59cc4 commit 8153e8d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

generate-wrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
try:
3232
from pycparser import c_parser, c_ast, parse_file, c_generator
33-
from pycparser.c_ast import Decl, FuncDecl, IdentifierType, TypeDecl, Struct, PtrDecl, EllipsisParam, ArrayDecl, Typedef, Enum
33+
from pycparser.c_ast import Decl, FuncDecl, IdentifierType, TypeDecl, Struct, Union, PtrDecl, EllipsisParam, ArrayDecl, Typedef, Enum
3434
except:
3535
print("pycparser not found.")
3636
print("Try installing it with pip install pycparser or using your distributions package manager.")
@@ -71,6 +71,8 @@ def stringify_declaration(ext, t):
7171
return(f"enum {t.type.name}")
7272
elif isinstance(t.type, Struct):
7373
return(f"struct {t.type.name}{pointer}")
74+
elif isinstance(t.type, Union):
75+
return(f"union {t.type.name}")
7476
elif isinstance(t.type, PtrDecl):
7577
return(f"{stringify_declaration(ext, t.type.type)}*")
7678
elif isinstance(t.type, ArrayDecl):

0 commit comments

Comments
 (0)