Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Callback registration

Platform spec article

Callback registration

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

Foreign hosts (game engines, shells, OS services) register Beskid callbacks before or during runtime. v0.3 Standard defines:

  1. Exported Beskid functions — normal [Export] entrypoints.
  2. Registration contract — a Beskid contract describing callback function-pointer types the host implements or consumes.
  3. Registration export — a stable C symbol the host calls to install a table of function pointers.

The platform reserves a runtime or generated symbol (exact name is toolchain-defined; example):

beskid_register_callbacks(version: u32, table: *const CallbackTable, count: usize) -> i32
FieldMeaning
versionUser FFI layout band — must match BESKID_USER_FFI_LAYOUT_BAND
tableArray of { symbol_id, fn_ptr, userdata } rows
countNumber of rows
Return0 success; non-zero stable error codes

Hosts must reject unknown version values.

The reference runtime exposes beskid_register_callbacks from compiler/crates/beskid_runtime/src/builtins/callback.rs, registered in RUNTIME_EXPORT_SYMBOLS and BUILTIN_SPECS via compiler/crates/beskid_abi/src/symbols.rs. Hosts must pass version == BESKID_USER_FFI_LAYOUT_BAND (initial Standard value 1).

Each callback slot points at a [Export(Abi:"C")] function or a compiler-generated trampoline that:

  • Enters runtime TLS / heap scope.
  • Performs any GC safepoint policy required before executing Beskid code.
  • Maps parameters from C layout to Beskid types.

Extern contracts may accept function-pointer parameters when the pointee is a documented Export or trampoline symbol. See callback call shapes.

  • Automatic binding generation from C headers.
  • Foreign-thread callback without host lifecycle contract (Proposed later).