function pointers and callbacks

This commit is contained in:
2026-06-15 21:09:46 +02:00
parent 3b7c3fcbd0
commit f5605fd3ec
21 changed files with 1927 additions and 122 deletions
+30
View File
@@ -24,19 +24,41 @@ Type_Kind :: enum u8 {
C_Double,
C_Longdouble,
Pointer,
Array,
Function,
Record,
}
Type :: struct {
kind: Type_Kind,
child: Type_Id,
params: []Type_Id,
record: u32,
count: u64,
mutable: bool,
variadic: bool,
}
Record_Kind :: enum u8 {
Struct,
Union,
}
Field :: struct {
name: string,
type: Type_Id,
offset: u64,
}
Record :: struct {
name: string,
identity: string,
fields: [dynamic]Field,
size: u64,
alignment: u32,
kind: Record_Kind,
complete: bool,
reason: string,
}
Alias :: struct {
@@ -82,9 +104,17 @@ init_result :: proc(allocator := context.allocator) -> Result {
}
destroy_result :: proc(result: ^Result) {
for type_item in result.types {
delete(type_item.params, result.allocator)
}
for record in result.records {
delete(record.name, result.allocator)
delete(record.identity, result.allocator)
for field in record.fields {
delete(field.name, result.allocator)
}
delete(record.fields)
delete(record.reason, result.allocator)
}
for alias in result.aliases {
delete(alias.name, result.allocator)