Expand description
The C ABI (impl plan §4 step 8). Verbatim rules: no global state
(SoilRuntime* is the instance); explicit init/teardown; no
unwinding across the boundary — every entry point is wrapped in
catch_unwind, and a caught panic becomes a SoilError of kind
Internal.
Threading: a runtime and every handle created under it belong to one thread (non-atomic refcounts by resolved decision). Parallel hosts run one runtime per thread.
Ownership: constructors return owned handles; every input handle is
borrowed (internally refcount-bumped as needed), so the caller
frees exactly what it was returned — values with soil_value_free,
strings with soil_string_free, errors with soil_error_free.
Closures are not constructible over this ABI yet (soil_closure_new
arrives with compiled code, plan 05).
Structs§
- Soil
Runtime - Opaque C-side names.
SoilRuntime*is aRuntime,SoilValue*aValue,SoilError*aSoilError; the internal layouts are not part of the ABI.
Functions§
- soil_
debug_ live_ values - Live runtime allocations on this thread — debug builds only (always 0 in release). The leak-check hook.
- soil_
decode ⚠ - Type-directed decode —
parse(design §3.7).shape_jsonis a shape in the descriptor-JSON encoding ({"tag": "Named", "value": "Doc"},{"tag": "List", "value": {"tag": "I64"}}, …). - soil_eq⚠
- Derived structural equality (design §3.7). Returns 1, 0, or -1 with
*errset. - soil_
error_ ⚠free - Safety
- soil_
error_ ⚠kind - The
PanicKindas a stable small integer (order of declaration). - soil_
error_ ⚠message - Safety
- soil_
f64_ new - soil_
i64_ ⚠get - Read an
I64out of a value handle. Returns 0 on success. - soil_
i64_ new - soil_
init - Create a runtime instance. Never fails; returns null only on an internal panic.
- soil_
list_ ⚠new - Build a list from borrowed elements.
- soil_
main - The trivial
mainwrapper (design §3.10): init, hand the runtime to the host’s entry function, tear down, return its exit code. - soil_
record_ ⚠new - Build a record from its non-ignored fields in declaration order;
ignoredfields are refilled from their defaults, exactly as in JSON decode (micro-pin §8.6). Field values are borrowed. - soil_
register_ ⚠types - Register types from descriptor JSON (see
descriptor_json). Returns 0 on success, nonzero with*errset on failure. - soil_
show ⚠ - Canonical JSON of a value —
show(design §3.7). Returns an owned NUL-terminated string; free withsoil_string_free. - soil_
string_ ⚠free - Safety
- soil_
sum_ ⚠new - Build a sum value by variant name.
payloadis null for nullary variants, borrowed otherwise. - soil_
teardown ⚠ - Tear down a runtime. Values created under it must already be freed.
- soil_
type_ ⚠lookup - Look up a type id by name. Returns
UINT32_MAXif unknown. - soil_
unit_ new - soil_
utf8_ ⚠new - Safety
- soil_
value_ ⚠clone - Safety
- soil_
value_ ⚠free - Safety