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
+15 -3
View File
@@ -27,7 +27,7 @@
- pointer-only `c_struct` support with target c layout
- `Some :: c_struct { ... }`: defined c-layout struct
- `Some :: c_struct`: opaque c-layout struct
- defer passing c structs by value until target ABI classification exists
- passing c structs by value was deferred until milestone 4.1
2. restricted c header imports (implemented)
- treat an imported header as a synthetic, file-local package namespace
@@ -55,8 +55,20 @@
- reject general `u8`/`c_char` interchange, slice-to-pointer coercion, and conversion to mutable c character pointers
4. advanced c interop
- by-value records and unions
- function pointers and callbacks
- by-value records and unions (implemented)
- complete plain imported structs/unions and manual `c_struct` values
- fixed C arrays inside imported records
- keyed struct literals and exactly-one-field union literals
- field reads/writes, storage, and fixed-signature calls/returns
- aarch64-macos small aggregate, homogeneous float aggregate, and indirect ABI lowering
- keep incomplete, bitfield, packed, flexible-array, qualified-field, and otherwise non-plain records pointer-only
- keep C variadic record arguments unsupported
- function pointers and callbacks (implemented)
- imported C function pointer typedefs lower to nullable pointer types
- manual `?*c_func(...) T` callback type spelling
- concrete `c_func` declarations/definitions can be passed as callback values
- postfix calls through non-null function pointers, including `callback?(...)`
- fixed and C-variadic callback ABI emission through LLVM indirect calls
- external variables
- macros and static inline functions
- exporting brolang functions to c