|
Loom C API
Public Loom compiler C API
|
Immutable source handles used by parsing, indexing, linking, and compiling. More...
Go to the source code of this file.
Data Structures | |
| struct | loomc_source_options_t |
| Source creation options. More... | |
| struct | loomc_source_load_options_t |
| Source load options for host file and path constructors. More... | |
Typedefs | |
| typedef struct loomc_source_t | loomc_source_t |
| Immutable source handle. | |
| typedef void(* | loomc_source_release_fn_t) (void *user_data, loomc_byte_span_t contents) |
| Callback used to release externally owned source bytes. | |
Enumerations | |
| enum | loomc_source_format_t { LOOMC_SOURCE_FORMAT_UNKNOWN = 0 , LOOMC_SOURCE_FORMAT_TEXT = 1 , LOOMC_SOURCE_FORMAT_BYTECODE = 2 } |
| Source byte format. More... | |
| enum | loomc_source_storage_t { LOOMC_SOURCE_STORAGE_BORROWED = 0 , LOOMC_SOURCE_STORAGE_COPY = 1 , LOOMC_SOURCE_STORAGE_EXTERNAL = 2 } |
| Storage policy for source bytes. More... | |
Functions | |
| loomc_status_t | loomc_source_create (const loomc_source_options_t *options, loomc_allocator_t allocator, loomc_source_t **out_source) |
| Creates an immutable source handle. | |
| loomc_status_t | loomc_source_create_from_file (FILE *file, const loomc_source_load_options_t *options, loomc_allocator_t allocator, loomc_source_t **out_source) |
| Creates an immutable source by reading an open file. | |
| loomc_status_t | loomc_source_create_from_path (loomc_string_view_t path, const loomc_source_load_options_t *options, loomc_allocator_t allocator, loomc_source_t **out_source) |
| Creates an immutable source by reading a filesystem path. | |
| void | loomc_source_retain (loomc_source_t *source) |
| Retains source for another owner. | |
| void | loomc_source_release (loomc_source_t *source) |
| Releases source from one owner. | |
| loomc_source_format_t | loomc_source_format (const loomc_source_t *source) |
| Returns the source format. | |
| loomc_string_view_t | loomc_source_identifier (const loomc_source_t *source) |
| Returns the source identifier. | |
| loomc_byte_span_t | loomc_source_contents (const loomc_source_t *source) |
| Returns the source contents. | |
Immutable source handles used by parsing, indexing, linking, and compiling.
Sources carry bytes plus stable identity. They are distinct from parsed modules and from output artifacts. Source identity is used for diagnostics, cache keys, and deterministic link-index provenance.
| typedef void(* loomc_source_release_fn_t) (void *user_data, loomc_byte_span_t contents) |
Callback used to release externally owned source bytes.
| user_data | Caller-provided value from loomc_source_options_t. |
| contents | Source bytes being released. |
| typedef struct loomc_source_t loomc_source_t |
Immutable source handle.
Storage policy for source bytes.
| loomc_byte_span_t loomc_source_contents | ( | const loomc_source_t * | source | ) |
Returns the source contents.
| source | Source to inspect. |
| loomc_status_t loomc_source_create | ( | const loomc_source_options_t * | options, |
| loomc_allocator_t | allocator, | ||
| loomc_source_t ** | out_source ) |
Creates an immutable source handle.
| options | Source format, identity, bytes, and storage policy. |
| allocator | Host allocator used for source-owned storage. |
| out_source | Receives one retained source on success. |
| loomc_status_t loomc_source_create_from_file | ( | FILE * | file, |
| const loomc_source_load_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_source_t ** | out_source ) |
Creates an immutable source by reading an open file.
| file | Open file positioned at the first byte to read. |
| options | Source format and identity metadata, or NULL for defaults. |
| allocator | Host allocator used for source and byte storage. |
| out_source | Receives one retained source on success. |
| loomc_status_t loomc_source_create_from_path | ( | loomc_string_view_t | path, |
| const loomc_source_load_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_source_t ** | out_source ) |
Creates an immutable source by reading a filesystem path.
| path | Path to read. The path view need not be NUL-terminated. |
| options | Source format and identity metadata, or NULL for defaults. |
| allocator | Host allocator used for source and byte storage. |
| out_source | Receives one retained source on success. |
| loomc_source_format_t loomc_source_format | ( | const loomc_source_t * | source | ) |
Returns the source format.
| source | Source to inspect. |
| loomc_string_view_t loomc_source_identifier | ( | const loomc_source_t * | source | ) |
Returns the source identifier.
| source | Source to inspect. |
| void loomc_source_release | ( | loomc_source_t * | source | ) |
Releases source from one owner.
| source | Source to release. Passing NULL is allowed. |
| void loomc_source_retain | ( | loomc_source_t * | source | ) |
Retains source for another owner.
| source | Source to retain. |