|
x-engine-c v0.2.13
The C engine for x-lang
|
Implementation of the base environment object. More...
#include "x-base.h"Macros | |
| #define | nil NULL |
| #define | pair(X, Y) (x_mkspair(p_base, X_OBJ_FLAG_SHARED, (X), (Y))) |
| #define | atom(X) (x_mksatom(p_base, X_OBJ_FLAG_SHARED, (X))) |
Functions | |
| x_obj_t * | x_base_make (x_obj_t *p_base, struct x_base_t base) |
| x_obj_t * | x_base_read (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_base_write (x_obj_t *p_base, x_obj_t *p_args) |
Implementation of the base environment object.
., .,
{O,O}
( )
" "
| #define atom | ( | X | ) | (x_mksatom(p_base, X_OBJ_FLAG_SHARED, (X))) |
| #define nil NULL |
| #define pair | ( | X, | |
| Y | |||
| ) | (x_mkspair(p_base, X_OBJ_FLAG_SHARED, (X), (Y))) |
Create a new base environment object.
Allocates and assembles the nested pair tree that holds all environment state. Every node is allocated with X_OBJ_FLAG_SHARED (via the local pair/atom macros) so the base tree is immune to garbage collection. Each leaf value is wrapped as pair(atom(value), nil) to form a one-element field stack (see x-base.h). Hook values passed as NULL produce (nil . nil) leaves (hook disabled). The tree layout matches the field accessor macros: x_base_field_filein() navigates to the filein leaf, x_base_field_hook_type_name() to the type_name hook, etc.
| p_base | Existing base for allocation context, or NULL for bootstrap. |
| base | Initialization parameters (file descriptors, hooks, etc.). |
Read data from the base's input file descriptor into an atom.
Uses the filein descriptor from the base environment, or falls back to STDIN_FILENO if the base is not initialized.
| p_base | Base (execution context). |
| p_args | Pair list: (destination-atom byte-count). |
Write data from an atom to the base's output or write buffer.
Checks the write_buf field first: if it holds a non-nil pair (pointer . position), data is memcpy'd into the buffer at the current position and the position is advanced. Otherwise, writes to the fileout file descriptor, falling back to STDOUT_FILENO if the base is not initialized.
| p_base | Base (execution context). |
| p_args | Pair list: (source-atom byte-count). |