Expand description
The model: the one validated, fully lowered view of an API that every language backend consumes.
validate checks an Api and builds the
Model exactly once per run. The model owns everything a generator
reads:
- the library’s
Identity(C symbol prefix, library name, package metadata) and the schema version; - a flat list of
ModuleBindings in which every type is a resolvedTy(no unresolved names), so a backend dispatches onTy::familyandTy::wireinstead of re-deriving what a name means; - every emitted C symbol name, precomputed once, so all backends agree by construction;
- every function, interface member, and callback-interface method paired
with its lowered
AbiFnsignature (built fromcrate::abi), so no backend re-derives parameter arity, ordering, orout_*/out_errplacement; and - the
TypeIndex, which maps each (global) type name to its declaration and owning module, behind typed lookups such asModel::interfaceandModel::owner.
A backend reads the idiomatic shape from the retained Tys
(param.ty, field.ty, …) and the native shape from the AbiFns,
then writes only the marshalling that bridges the two (see
crate::plan) in its own idioms. Generators never see the Api.
Structs§
- AbiFn
- A single lowered C symbol: its name, ordered ABI parameter slots, and C return type. This is what a backend declares to its FFI layer and calls.
- Async
Binding - The lowered surface of an
asyncfunction. - Callback
Interface Binding - A callback interface, fully lowered.
- Callback
Method Binding - One method of a callback interface, lowered to its vtable entry.
- Enum
Binding - An enum, fully lowered.
- Enum
Variant Binding - A single enum variant with its precomputed C constant name and any associated data.
- Error
Binding - An error domain, lowered on the module that declares it.
- Error
Code Binding - One error code of a module’s error domain, with its C constant name.
- Field
Binding - A field of a record, a rich-enum variant, or an error code’s payload.
- FnBinding
- A function, fully lowered.
- Interface
Binding - An interface (reference-counted object type), fully lowered.
- Iterator
Binding - The lowered surface of an
iter<T>-returning function. - Model
- The whole API, validated and lowered for code generation.
- Module
Binding - One module, flattened with its underscore-joined symbol path.
- Param
Binding - One IR parameter, retained with its lowered ABI slots.
- Struct
Binding - A struct (record), fully lowered: a plain value type generators emit as a native data class plus buffer read/write functions. No C symbols exist for a record; instances cross the ABI serialized in value buffers.
Enums§
- Call
Shape - How a function crosses the boundary. Exactly one shape applies to any given function: synchronous, asynchronous (callback-completed), or iterator-returning.
Constants§
- ABI_
VERSION - The C ABI revision this model lowers to. Producers export it from
{prefix}_abi_version()and every generated consumer checks it at load. - RESERVED_
SYMBOL_ FAMILIES - Identifier families the generated C value-buffer helper header
(
{library}_buffer.h) declares, without the{prefix}_that begins each: a user declaration whose C symbol falls in one of these families would collide with a helper. - RUNTIME_
SYMBOLS - The runtime symbols every producer exports (and every C header declares),
without the
{prefix}_that begins each one. See the C ABI contract for their signatures. - VALUE_
CODECS - The codec functions the C value-buffer helper header declares for each
record, rich enum, and error payload struct
T:T_write,T_read,T_decode, andT_free.
Functions§
- contract_
check_ symbol - The C header’s
static inlinechecker of a top-level module’s contract,{prefix}_{module}_contract_check. - contract_
symbol - The symbol of a top-level module’s contract table function,
{prefix}_{module}_contract(seecrate::contract).