Use c_char type for Int8 arrays in ir_to_ctypes

This commit is contained in:
Pragyansh Chaturvedi
2025-10-20 03:48:02 +05:30
parent c580aab1c4
commit ddbbce400e

View File

@ -22,9 +22,14 @@ def ir_type_to_ctypes(ir_type):
elif isinstance(ir_type, ir.ArrayType):
count = ir_type.count
element_type = ir_type_to_ctypes(ir_type.element)
return element_type * count
element_type_ir = ir_type.element
if isinstance(element_type_ir, ir.IntType) and element_type_ir.width == 8:
# Use c_char for string fields (will have .decode())
return ctypes.c_char * count
else:
element_type = ir_type_to_ctypes(element_type_ir)
return element_type * count
elif isinstance(ir_type, ir.PointerType):
return ctypes.c_void_p