Loom C API
Public Loom compiler C API
Loading...
Searching...
No Matches
module_config.h File Reference

Applying and inspecting configuration on in-memory modules. More...

Go to the source code of this file.

Data Structures

struct  loomc_module_config_options_t
 Configuration bindings and resolution policy for a module operation. More...

Functions

loomc_status_t loomc_module_apply_config (loomc_module_t *module, loomc_workspace_t *workspace, const loomc_module_config_options_t *options, loomc_allocator_t allocator, loomc_result_t **out_result)
 Applies text/JSON bindings to the module's existing configuration symbols.
loomc_status_t loomc_module_query_config_schema (loomc_module_t *module, loomc_allocator_t allocator, loomc_result_t **out_result)
 Returns the module's configuration schema as a JSON REPORT artifact.

Detailed Description

Applying and inspecting configuration on in-memory modules.

Function Documentation

◆ loomc_module_apply_config()

loomc_status_t loomc_module_apply_config ( loomc_module_t * module,
loomc_workspace_t * workspace,
const loomc_module_config_options_t * options,
loomc_allocator_t allocator,
loomc_result_t ** out_result )

Applies text/JSON bindings to the module's existing configuration symbols.

Explicit bindings override JSON entries, and unmatched keys are ignored. Applied values become module-owned; no borrowed binding storage escapes the call. Successful application preserves continuing compilation facts and records the applied values alongside them. Configuration changes affect the current IR; they do not undo transformations that have already consumed it.

With no bindings, REQUIRE_RESOLVED checks that no unresolved declarations remain after pipeline execution. This check does not mutate IR or discard retained compilation facts, including when unresolved declarations remain.

Parameters
moduleModule to configure; its IR must satisfy input invariants.
workspaceWorkspace providing transient configuration scratch.
optionsBindings and policy, or NULL for an admission-only check.
allocatorHost allocator used for result and transient storage.
out_resultReceives one owned result on an OK return.
Returns
OK for successful application or diagnosed invalid IR/configuration. API misuse and infrastructure failures return non-OK with NULL result.
Ownership
The caller releases the result with loomc_result_release. A failed binding application may leave partially modified IR and invalidates compilation facts. Discard that module, or clone before applying to support rollback.
Thread safety
Requires exclusive access to the module and both its owning workspace and the supplied scratch workspace for the duration of the call.

◆ loomc_module_query_config_schema()

loomc_status_t loomc_module_query_config_schema ( loomc_module_t * module,
loomc_allocator_t allocator,
loomc_result_t ** out_result )

Returns the module's configuration schema as a JSON REPORT artifact.

A successful result contains one artifact named config-schema.json with format LOOMC_ARTIFACT_FORMAT_JSON. It describes unresolved declarations and resolved definitions, including their types, values, and constraints, using the same JSON schema as loom-opt --print-config-schema.

Parameters
moduleModule to inspect; admission may populate verification caches.
allocatorHost allocator used for result and report storage.
out_resultReceives one owned result on an OK return.
Returns
OK for a schema report or diagnosed invalid IR. API misuse and infrastructure failures return non-OK with NULL result.
Ownership
The result owns the report bytes independently of the module, context, and workspace. The caller releases the result with loomc_result_release.
Thread safety
Requires exclusive access to the module and its workspace. The module's IR and retained compilation facts are unchanged.