Expand description
The binding model: a normalized, fully-lowered view of an Api that
every language backend consumes.
Before this module existed, each of the eleven generators re-walked the IR,
re-derived the C ABI calling convention, and re-invented every emitted C
symbol name. They drifted: iterators were lowered as lists in some targets,
listeners were emitted only by the C header, and a custom c_prefix reached
only the C and C++ outputs while the other nine hard-coded weaveffi_.
BindingModel::build walks the IR exactly once and produces a flat list
of ModuleBindings in which:
- every emitted C symbol name is precomputed once (so all backends agree by construction, and a non-default prefix is honored everywhere); and
- every function/struct/callback is paired with its lowered
AbiFnsignature (built fromcrate::abi), so no backend re-derives parameter arity, ordering, orout_*/out_errplacement.
A backend reads the idiomatic shape from the retained TypeRefs
(param.ty, field.ty, …) and the native shape from the AbiFns, then
writes only the marshalling that bridges the two in its own idioms. The hard,
drift-prone facts live here; only language syntax lives in the backends.
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. - Binding
Model - The whole API, normalized and lowered for code generation.
- Builder
Binding - The fluent builder lowered for a struct that opted in with
builder: true. - Callback
Binding - A callback function-pointer typedef declared at module scope.
- Enum
Binding - An enum, fully lowered.
- Enum
Variant Binding - A single enum variant with its precomputed C constant name.
- Error
Binding - The error domain in effect for a module: its own
errors:block, or the nearest ancestor’s when the module declares none. - Error
Code Binding - One error code of a module’s error domain, with its C constant name.
- Field
Binding - A struct field, retained with its getter symbol and lowered return.
- FnBinding
- A function, fully lowered.
- Interface
Binding - An interface (opaque object type), fully lowered.
- Iterator
Binding - The lowered surface of an
iter<T>-returning function. - Listener
Binding - A listener: a register/unregister pair bound to a callback.
- Module
Binding - One module, flattened with its underscore-joined symbol path.
- Param
Binding - One IR parameter, retained with its lowered ABI slots.
- Rich
Enum Binding - The opaque-object surface of a rich (algebraic) enum: how its tag is read, how each variant is constructed and projected, and how the object is freed.
- Rich
Variant Binding - One variant of a rich enum: its constructor and the getters for its associated data.
- Struct
Binding - A struct, fully lowered.
Enums§
- Call
Shape - How a function crosses the boundary. Exactly one shape applies to any given function: synchronous, asynchronous (callback-completed), or iterator-returning.
Functions§
- iterator_
item_ ctype - The element C type of an iterator’s
out_itemslot (the pointee ofT* out_item). Exposed for backends that materialize iterator results.