Summary
scriptc's FFI manifest binds signature-only declarations to C ABI calls, but it provides no way to pass a C function pointer to a native symbol. Any library API that takes a callback becomes unbindable: it must either be removed or replaced with a polling workaround.
(I'm aware the Native FFI guide lists callbacks as not-yet-supported — filing this to capture the concrete API impact and the demand.)
Why this matters
Callbacks aren't an edge case in the C ecosystem — they're the primary integration point of most real libraries (SDL, FFmpeg, libcurl, GTK, libgit2, …). Event-driven, game, and UI frameworks are callback-shaped by design, and an FFI that can't pass function pointers leaves those libraries largely unusable. Concretely:
- Synchronous callbacks can't be worked around at all. Event filters must return a bool in-place; polling can't express that.
- The workaround is per-API and invasive. A timer/log-output workaround means writing a C trampoline + mutex-protected ring buffer + main-loop drain for each API — the bound surface degrades, and reverting it later is a large change.
- Native-thread callbacks need careful synchronization. Timers, audio, and I/O callbacks fire off the main thread, ruling out high-frequency or latency-sensitive callbacks.
Suggested direction (for discussion)
- A function-pointer FFI parameter that lowers to a registered C trampoline + a TS closure, with an explicit ownership/lifetime contract (e.g. a userdata handle passed back on invocation, GC pinning while registered, and an unregister call).
- A story for callbacks invoked from native threads — either documented invocation on the calling thread or marshalling onto the main loop.
Summary
scriptc's FFI manifest binds signature-only declarations to C ABI calls, but it provides no way to pass a C function pointer to a native symbol. Any library API that takes a callback becomes unbindable: it must either be removed or replaced with a polling workaround.
(I'm aware the Native FFI guide lists callbacks as not-yet-supported — filing this to capture the concrete API impact and the demand.)
Why this matters
Callbacks aren't an edge case in the C ecosystem — they're the primary integration point of most real libraries (SDL, FFmpeg, libcurl, GTK, libgit2, …). Event-driven, game, and UI frameworks are callback-shaped by design, and an FFI that can't pass function pointers leaves those libraries largely unusable. Concretely:
Suggested direction (for discussion)