#include "symrepr.h"
#include "heap.h"
#include "lbm_types.h"
#include "lbm_constants.h"
Go to the source code of this file.
|
#define | LBM_EXTENSION(name, argv, argn) __attribute__((aligned(LBM_STORABLE_ADDRESS_ALIGNMENT))) lbm_value name(lbm_value *(argv), lbm_uint (argn)) |
|
#define | LBM_CHECK_NUMBER_ALL() if (!lbm_check_number_all(args, argn)) {return ENC_SYM_EERROR;} |
|
#define | LBM_CHECK_ARGN(n) if (!lbm_check_argn(argn, n)) {return ENC_SYM_EERROR;} |
|
#define | LBM_CHECK_ARGN_NUMBER(n) if (!lbm_check_argn_number(args, argn, n)) {return ENC_SYM_EERROR;} |
|
◆ extension_fptr
Type representing an extension function.
- Parameters
-
Pointer | to array of lbm_values. |
Number | of arguments. |
- Returns
- Result value.
◆ lbm_add_extension()
Adds a symbol-extension mapping.
- Parameters
-
sym_str | String representation of symbol to use as key. |
ext | The extension function pointer. |
- Returns
- true on success and false on failure.
◆ lbm_check_argn()
bool lbm_check_argn |
( |
lbm_uint |
argn, |
|
|
lbm_uint |
n |
|
) |
| |
Check if the number of arguments is n. Sets error-reason if result is false.
- Parameters
-
argn | number of arguments. |
n | number of expected arguments. |
- Returns
- true if the number of arguments is correct. false otherwise
◆ lbm_check_argn_number()
bool lbm_check_argn_number |
( |
lbm_value * |
args, |
|
|
lbm_uint |
argn, |
|
|
lbm_uint |
n |
|
) |
| |
Check if all arguments are numbers and that there is n of them. Sets error-reason if result is false.
- Parameters
-
args | The argument array. |
argn | The number of arguments. |
n | The expected number of arguments. |
- Returns
- true or false.
◆ lbm_check_number_all()
bool lbm_check_number_all |
( |
lbm_value * |
args, |
|
|
lbm_uint |
argn |
|
) |
| |
Check if all arguments are numbers. Sets error-reason if result is false.
- Parameters
-
args | The argument array. |
argn | The number of arguments. |
- Returns
- true if all arguments are numbers, false otherwise.
◆ lbm_check_true_false()
Check if a value is the symbol t or the symbol nil
- Parameters
-
- Returns
- true if the value is t or nil otherwise false.
◆ lbm_clr_extension()
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.
- Parameters
-
sym_id | Symbol id of the extension to clear. |
- Returns
- true if successfully cleared an extension otherwise false.
◆ lbm_extensions_init()
int lbm_extensions_init |
( |
extension_fptr * |
extension_storage, |
|
|
int |
extension_storage_size |
|
) |
| |
Initialize the extensions subsystem.
- Parameters
-
extension_storage | Pointer to array of extension_fptr. |
extension_storage_size | Size of function pointer array. |
- Returns
- 1 on success and 0 for failure
◆ lbm_get_extension()
Look up an extension associated with a key symbol.
- Parameters
-
sym | Symbol bound to the extension to look for. |
- Returns
- extension_fptr on success or NULL on failure.
◆ lbm_get_max_extensions()
lbm_uint lbm_get_max_extensions |
( |
void |
| ) |
|
The number of extensions that can be allocated.
- Returns
- The maximum number of extensions that can be added.
◆ lbm_get_num_extensions()
lbm_uint lbm_get_num_extensions |
( |
void |
| ) |
|
Get the number of allocated extensions
- Returns
- The number of extensions that have been added.
◆ lbm_is_extension()
static bool lbm_is_extension |
( |
lbm_value |
exp | ) |
|
|
inlinestatic |
Check if an lbm_value is a symbol that is bound to an extension.
- Parameters
-
- Returns
- true if the lbm_value respresents an extension otherwise false.