template/env
env-new
(env-new :)
create a new empty Env handle.
An Env handle to be freed by env-free.
(let [e (env-new)] (env-free e))
Since: 0.1.0
env-set
(env-set [env : int key : cstr val : cstr] :)
set or shadow a scalar string binding in the env.
| env | Env handle from env-new | |
| key | variable name (NUL-terminated) | |
| val | string value (NUL-terminated) |
(env-set e "title" "Hello")
Since: 0.1.0
env-set-list
(env-set-list [env : int key : cstr vals : int] :)
set or shadow a list-valued binding in the env.
| env | Env handle from env-new | |
| key | variable name (NUL-terminated) | |
| vals | cons list of cstr values (0 for nil) |
(env-set-list e "items" (cons "a" (cons "b" 0)))
Since: 0.1.0
env-get
(env-get [env : int key : cstr] :)
look up a key, returning the first (scalar) value.
| env | Env handle | |
| key | variable name |
The bound cstr, or the empty string if no binding exists.
(env-get e "title") ; => "Hello"
Since: 0.1.0
env-has?
(env-has? [env : int key : cstr] :)
check whether a binding exists for `key`.
| env | Env handle | |
| key | variable name |
true if some binding is present, false otherwise.
(env-has? e "title") ; => true
Since: 0.1.0
env-get-list-len
(env-get-list-len [env : int key : cstr] :)
number of values bound to `key`.
| env | Env handle | |
| key | variable name |
Length of the bound list (1 for scalar, 0 if missing).
(env-get-list-len e "items") ; => 3
Since: 0.1.0
env-get-list-at
(env-get-list-at [env : int key : cstr i : int] :)
fetch the i-th value bound to `key`.
| env | Env handle | |
| key | variable name | |
| i | zero-based index |
The i-th value, or "" if out of range.
(env-get-list-at e "items" 1) ; => "b"
Since: 0.1.0
env-push-scalar
(env-push-scalar [env : int key : cstr val : cstr] :)
push a single scalar binding (for renderer scopes).
env-push-list
(env-push-list [env : int key : cstr vals : int] :)
push a list binding (for renderer scopes).
env-pop
(env-pop [env : int] :)
remove the top binding from the env stack.
env-free
(env-free [env : int] :)
release all storage associated with an Env handle.
| env | Env handle returned by env-new |
(env-free e)
Since: 0.1.0