This commit is contained in:
nub31
2025-10-22 17:45:59 +02:00
parent 99826fc362
commit 0f96e83e44
2 changed files with 744 additions and 1 deletions

View File

@@ -148,5 +148,22 @@ for cursor in tu.cursor.walk_preorder():
field_type = map_type(field.type)
print(f" {field_name}: {field_type}")
else:
raise Exception(f"Unsupported child of struct: {field.spelling}")
raise Exception(
f"Unsupported child of struct: {field.spelling}: {field.kind}"
)
print("}")
elif cursor.kind == CursorKind.ENUM_DECL:
name = cursor.spelling
print(f"export enum {name} : u32")
print("{")
for field in cursor.get_children():
if field.kind == CursorKind.ENUM_CONSTANT_DECL:
field_name = field.spelling
field_value = field.enum_value
print(f" {field_name} = {field_value}")
else:
raise Exception(
f"Unsupported child of enum: {field.spelling}: {field.kind}"
)
print("}")