|
x-engine-c v0.2.13
The C engine for x-lang
|
Bind C functions into the x-lang environment. More...
Data Structures | |
| struct | x_callable_entry_t |
Functions | |
| void | x_value_bind (x_obj_t *p_base, x_char_t *name, x_obj_t *p_val) |
| void | x_callable_bind (x_obj_t *p_base, x_char_t *name, x_fn_t fn) |
| void | x_callable_bind_table (x_obj_t *p_base, const x_callable_entry_t *table, int count) |
Bind C functions into the x-lang environment.
Bind a single C function as a named callable in the environment.
Bind a C primitive function in the base's root environment.
Creates a symbol, wraps the C function as a prim object, and binds the pair in the root, where every environment in the base reaches it.
| p_base | x_obj_t* – Base (execution context) |
| name | x_char_t* – Symbol name to bind |
| fn | x_fn_t – C function pointer |
Symbol interning. x_make_symbol interns the name so that all references to the same name share a single symbol object. This enables O(1) pointer-identity comparison in the environment lookups.
def shares | void x_callable_bind_table | ( | x_obj_t * | p_base, |
| const x_callable_entry_t * | table, | ||
| int | count | ||
| ) |
Bind an array of name/function entries into the environment.
Bind an array of C primitive entries into the global environment.
Iterates table and calls x_callable_bind for each entry.
| p_base | x_obj_t* – Base (execution context) |
| table | const x_callable_entry_t* – Array of (name, fn) entries |
| count | int – Number of entries |
Bind a named symbol to an arbitrary value in the global environment.
Bind a named symbol to an arbitrary value in the base's root environment.
| p_base | x_obj_t* – Base (execution context) |
| name | x_char_t* – Symbol name to bind |
| p_val | x_obj_t* – Value to bind |