|
LispBM
|
#include <lbm_memory.h>#include <stdio.h>#include <stdlib.h>#include <stdbool.h>#include <string.h>#include <eval_cps.h>#include <lbm_c_interop.h>#include "extensions.h"#include "lbm_utils.h"
Variables | |
| static lbm_uint | ext_max = 0 |
| static lbm_uint | next_extension_ix = 0 |
| lbm_extension_t * | extension_table = NULL |
| bool dec_opt_uint | ( | lbm_value * | args, |
| lbm_uint | argn, | ||
| lbm_uint | idx, | ||
| size_t | default_val, | ||
| size_t * | out | ||
| ) |
Decode an optional non-negative integer argument, or a default if the argument wasn't supplied. Negative user input is clamped to 0.
| args | Extension argument array. |
| argn | Number of arguments actually supplied. |
| idx | Index of the optional argument to decode. |
| default_val | Value to use if argn <= idx. |
| out | Output: the decoded (or default) value. |
| bool lbm_add_extension | ( | const char * | sym_str, |
| extension_fptr | ext | ||
| ) |
Adds a symbol-extension mapping.
| sym_str | String representation of symbol to use as key. |
| ext | The extension function pointer. |
Check if the number of arguments is n. Sets error-reason if result is false.
| argn | number of arguments. |
| n | number of expected arguments. |
Check if all arguments are numbers and that there is n of them. Sets error-reason if result is false.
| args | The argument array. |
| argn | The number of arguments. |
| n | The expected number of arguments. |
Check if all arguments are numbers. Sets error-reason if result is false.
| args | The argument array. |
| argn | The number of arguments. |
| bool lbm_clr_extension | ( | lbm_uint | sym_id | ) |
Reset an extension back to the default value. Trying to apply the extension after clearing it will result in an eval error.
| sym_id | Symbol id of the extension to clear. |
| bool lbm_extensions_init | ( | lbm_extension_t * | extension_storage, |
| lbm_uint | extension_storage_size | ||
| ) |
Initialize the extensions subsystem. Extension storage is allocated on lbm_memory.
| extension_storage_size | Size of function pointer array. |
| void lbm_extensions_set_next | ( | lbm_uint | i | ) |
Set the next index to be given out to the next added extension.
| i | Next index. |
| extension_fptr lbm_get_extension | ( | lbm_uint | sym | ) |
Look up an extension associated with a key symbol.
| sym | Symbol bound to the extension to look for. |
| lbm_uint lbm_get_max_extensions | ( | void | ) |
The number of extensions that can be allocated.
| lbm_uint lbm_get_num_extensions | ( | void | ) |
Get the number of allocated extensions
| bool lbm_lookup_extension_id | ( | char * | sym_str, |
| lbm_uint * | ix | ||
| ) |
Lookup an extensions index.
| sym_str | Extension name to look up. |
| ix | Pointer used to store result. |
| lbm_value make_list | ( | int | num, |
| ... | |||
| ) |
Create a list.
| num | The number of elements to allocate space for. |
| ... | The elements to initialize the list with. |
| lbm_value span_to_lbm | ( | const char * | data, |
| size_t | len | ||
| ) |
Build a new LBM string by copying len bytes out of a raw C buffer and end with \0.
| data | Pointer to the source bytes. |
| len | Number of bytes to copy. |
| size_t strlen_max | ( | const char * | s, |
| size_t | maxlen | ||
| ) |
check length of string. like strnlen.
| s | String. |
| maxlen | Maximum length. |
| bool strmatch | ( | const char * | str1, |
| const char * | str2 | ||
| ) |
Compare strings for equality Compares two strings up to the length of the first of string arguments.
| str1 | First string to match against a prefix of second. |
| str2 | Second string. |
|
static |
| lbm_extension_t* extension_table = NULL |
|
static |