Skip to main content

Module model

Module model 

Source
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 resolved Ty (no unresolved names), so a backend dispatches on Ty::family and Ty::wire instead 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 AbiFn signature (built from crate::abi), so no backend re-derives parameter arity, ordering, or out_*/out_err placement; and
  • the TypeIndex, which maps each (global) type name to its declaration and owning module, behind typed lookups such as Model::interface and Model::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.
AsyncBinding
The lowered surface of an async function.
CallbackInterfaceBinding
A callback interface, fully lowered.
CallbackMethodBinding
One method of a callback interface, lowered to its vtable entry.
EnumBinding
An enum, fully lowered.
EnumVariantBinding
A single enum variant with its precomputed C constant name and any associated data.
ErrorBinding
An error domain, lowered on the module that declares it.
ErrorCodeBinding
One error code of a module’s error domain, with its C constant name.
FieldBinding
A field of a record, a rich-enum variant, or an error code’s payload.
FnBinding
A function, fully lowered.
InterfaceBinding
An interface (reference-counted object type), fully lowered.
IteratorBinding
The lowered surface of an iter<T>-returning function.
Model
The whole API, validated and lowered for code generation.
ModuleBinding
One module, flattened with its underscore-joined symbol path.
ParamBinding
One IR parameter, retained with its lowered ABI slots.
StructBinding
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§

CallShape
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, and T_free.

Functions§

contract_check_symbol
The C header’s static inline checker 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 (see crate::contract).