$#! · 0-9 · A · B · C · D · E · F · G · H · I · J · K · L · M · N · O · P · Q · R · S · T · U · V · W · X · Y · Z
 API Reference-Lily
 Argument handling
 Basic typedefs
 Calling a function
 Class id macros
 Configuring import
 Configuring render
 Error callbacks
 Error Capture
 Exception raise
 Foreign bits
 lily_config_get, lily_config
 lily_config_init, lily_config
Fetch and/or test arguments passed to a foreign function.
Functions for calling back into the interpreter.
Class ids for predefined classes.
The configuration struct and related functions.
The import hook and functions it uses.
Render hook and related functions.
Foreign function cleanup.
Capture error information after a failed parse/render.
Functions for raising an exception.
Items of interest for putting a foreign class into Lily.
int lily_arg_boolean (lily_state *s,
int index)
Fetch a Boolean from the stack.
uint8_t lily_arg_byte (lily_state *s,
int index)
Fetch a Byte from the stack.
lily_bytestring_val *lily_arg_bytestring(lily_state *s,
int index)
Fetch a ByteString from the stack.
lily_container_val * lily_arg_container (lily_state *s,
int index)
Fetch a user-defined class, (non-empty) variant, List, or Tuple.
uint16_t lily_arg_count(lily_state *s)
How many arguments the function being called was given.
double lily_arg_double (lily_state *s,
int index)
Fetch a Double from the stack.
lily_file_val * lily_arg_file (lily_state *s,
int index)
Fetch a File from the stack.
lily_function_val * lily_arg_function (lily_state *s,
int index)
Fetch a Function from the stack.
lily_generic_val * lily_arg_generic (lily_state *s,
int index)
Fetch a pointer-based (foreign) value from the stack.
lily_hash_val * lily_arg_hash (lily_state *s,
int index)
Fetch a Hash from the stack.
int64_t lily_arg_integer (lily_state *s,
int index)
Fetch a Integer from the stack.
Calls lily_arg_isa with LILY_ID_FAILURE.
Calls lily_arg_isa with LILY_ID_NONE.
Calls lily_arg_isa with LILY_ID_SOME.
Calls lily_arg_isa with LILY_ID_SUCCESS.
int lily_arg_isa(lily_state *s,
int index,
uint16_t class_id)
Check if an argument has an exact class id.
lily_string_val * lily_arg_string (lily_state *s,
int index)
Fetch a String from the stack.
char * lily_arg_string_raw(lily_state *s,
int index)
Fetch the underlying buffer of a String from the stack.
lily_value * lily_arg_value (lily_state *s,
int index)
Fetch a complete value with flags and class information.
int lily_as_boolean (lily_value *value)
Extract a Boolean.
uint8_t lily_as_byte (lily_value *value)
Extract a Byte.
lily_bytestring_val *lily_as_bytestring(lily_value *value)
Extract a ByteString.
lily_container_val * lily_as_container (lily_value *value)
Extract a container (user-defined class, non-empty variant, List, or Tuple).
double lily_as_double (lily_value *value)
Extract a Double.
lily_file_val * lily_as_file (lily_value *value)
Extract a File.
lily_function_val * lily_as_function (lily_value *value)
Extract a Function.
lily_generic_val * lily_as_generic (lily_value *value)
Extract a generic pointer (to be cast to some other type)..
lily_hash_val * lily_as_hash (lily_value *value)
Extract a Hash.
int64_t lily_as_integer (lily_value *value)
Extract a Integer.
lily_string_val * lily_as_string (lily_value *value)
Extract a String.
char * lily_as_string_raw(lily_value *value)
Extract the raw buffer behind a String.
uint32_t lily_bytestring_length(lily_bytestring_val *byte_val)
Get the size (in bytes) of a ByteString.
char *lily_bytestring_raw(lily_bytestring_val *byte_val)
Get the raw buffer behind a ByteString.
Holds a ByteString value.
void lily_call(lily_state *s,
uint16_t count)
(Stack: -count) Perform a prepared call using values from the stack.
An dynaload entry in the call_table corresponding to the info_table.
void lily_call_prepare(lily_state *s,
lily_function_val *func)
(Stack: +1) Reserve a result register and prepare ‘func’.
lily_value *lily_call_result(lily_state *s)
Return the register that ‘lily_call_prepare’ reserved.
uint16_t lily_cid_at(lily_state *s,
int index)
Function for autogenerated ID_* macros to get a class id.
lily_value *lily_con_get(lily_container_val *con,
uint32_t index)
Fetch an element from a container.
void lily_con_set(lily_container_val *con,
uint32_t index,
lily_value *value)
Set an element into a container.
void lily_con_set_from_stack(lily_state *s,
lily_container_val *con,
uint32_t index)
(Stack: -1) Set an element into a container from the stack.
uint32_t lily_con_size(lily_container_val *con)
Return the number of occupied values in a container.
typedef struct lily_config_
All interpreter config info goes here.
lily_config *lily_config_get(lily_state *s)
Fetch an interpreter’s config struct.
void lily_config_init(lily_config *config)
Initialize a config to default values.
Holds a variant, user-defined class, List, or Tuple.
void lily_default_import_func(lily_state *s,
const char *target)
This is the default import hook.
Hook called when a value is to be destroyed.
void lily_DivisionByZeroError(lily_state *s,
const char *format,
Raise DivisionByZeroError with the given message and args.
Callback for when lily_call raises an exception.
void lily_error_callback_pop(lily_state *s)
Remove an error callback (typically at foreign function exit).
void lily_error_callback_push(lily_state *s,
lily_error_callback_func callback_fn)
Push an error callback for the current foreign function.
const char *lily_error_message(lily_state *s)
Fetch the message and traceback of the last failed parse/render.
const char *lily_error_message_no_trace(lily_state *s)
Fetch only the message of the last failed parse/render.
int lily_exit_code(lily_state *s)
Return a suitable exit code based on the status of the interpreter.
FILE *lily_file_for_read(lily_state *s,
lily_file_val *file)
Return the underlying FILE * of a File (if in read mode), or raise IOError.
FILE *lily_file_for_write(lily_state *s,
lily_file_val *file)
Return the underlying FILE * of a File (if in write mode), or raise IOError.
Holds a File value.
lily_function_val *lily_find_function(lily_state *s,
const char *name)
Search for a function called ‘name’.
Put this macro at the top of any struct that is later introduced as a foreign class to the interpreter.
Holds a foreign class.
void lily_free_msgbuf(lily_msgbuf *msgbuf)
Free a msgbuf struct and the underlying buffer.
void lily_free_state(lily_state *s)
Destroy an interpreter and any values it holds.
uint16_t *lily_function_bytecode(lily_function_val *func,
uint16_t *length)
Return the bytecode of a Function.
int lily_function_is_foreign(lily_function_val *func)
Return 1 if the Function has a foreign implementation, 0 otherwise.
int lily_function_is_native(lily_function_val *func)
Return 1 if the Function has a native implementation, 0 otherwise.
Holds a Function (could be native or foreign).
Holds some kind of pointer value (usually, to be cast to a foreign class).
int lily_has_exited(lily_state *s)
Return 1 if an exit function has been called, 0 otherwise.
lily_value *lily_hash_get(lily_state *s,
lily_hash_val *hash,
lily_value *key)
Look for a given key within a Hash.
void lily_hash_set(lily_state *s,
lily_hash_val *hash,
lily_value *key,
lily_value *record)
Set ‘key’ to ‘value’ within a given hash.
void lily_hash_set_from_stack(lily_state *s,
lily_hash_val *hash)
(Stack: -2) lily_hash_set, but key and value come from the stack.
int lily_hash_take(lily_state *s,
lily_hash_val *hash,
lily_value *key)
(Stack: +1?)
Holds a Hash value.
Identity of the Boolean class.
Identity of the Byte class.
Identity of the ByteString class.
Identity of the DivisionByZero class.
Identity of the Double class.
Identity of the Exception class.
Identity of the Failure variant of Result.
Identity of the File class.
Identity of the Function class.
Identity of the Hash class.
Identity of the IndexError class.
Identity of the Integer class.
Identity of the IOError class.
Identity of the KeyError class.
Identity of the List class.
Identity of the None variant.
Identity of the Option enum.
Identity of the Result enum.
Identity of the RuntimeError class.
Identity of the Some variant.
Identity of the String class.
Identity of the Success variant of Result.
Identity of the Tuple class.
Identity of the Unit class.
False identity for testing if a value is unset.
Identity of the ValueError class.
const char *lily_import_current_root_dir(lily_state *s)
Return the directory of the package that the source import belongs to.
int lily_import_file(lily_state *s,
const char *target)
Import a file for the interpreter.
Invoked to find a module after registered modules have been tried.
int lily_import_library(lily_state *s,
const char *target)
Load a library from a given path.
int lily_import_library_data(lily_state *s,
const char *target,
const char **info_table,
lily_call_entry_func *call_table)
Load a preloaded library.
int lily_import_string(lily_state *s,
const char *target,
const char *content)
Load a string (context path, then content) as a library.
void lily_import_use_local_dir(lily_state *s,
const char *dir)
Use a local directory for upcoming imports.
void lily_import_use_package_dir(lily_state *s,
const char *dir)
Use a package directory for upcoming imports.
void lily_IndexError(lily_state *s,
const char *format,
Raise IndexError with the given message and args.
void lily_IOError(lily_state *s,
const char *format,
Raise IOError with the given message and args.
int lily_is_valid_utf8(const char *source)
Check if ‘source’ is valid utf-8.
The value is a ‘Boolean’.
The value is a ‘Byte’.
The value is a ‘ByteString’.
The value is a ‘Double’.
This is a variant that does not have any values inside of it.
The value is a ‘File’.
This is a class defined in C.
The value is a ‘Function’.
The value is a ‘Hash’.
The value is an ‘Integer’.
The value is a ‘List’.
This is a class with fields, usually defined in native Lily code.
The value is a ‘String’.
The value is a ‘Tuple’.
The value is a ‘Unit’.
The value is a variant with a non-zero number of fields.
void lily_KeyError(lily_state *s,
const char *format,
Raise KeyError with the given message and args.
void lily_list_insert(lily_container_val *con,
uint32_t index,
lily_value *value)
Insert a value, pushing others to the right.
void lily_list_push(lily_container_val *con,
lily_value *value)
Push a value onto the end of a List.
void lily_list_reserve(lily_container_val *con,
uint32_t size)
Reserve N elements in a List.
void lily_list_take(lily_state *s,
lily_container_val *con,
uint32_t index)
(Stack: +1) Take an element out of a List, pushing it onto the stack.
int lily_load_file(lily_state *s,
const char *path)
Prepare a file for the interpreter.
int lily_load_string(lily_state *s,
const char *context,
const char *str)
Prepare a string for the interpreter.
void lily_mb_add(lily_msgbuf *msgbuf,
const char *source)
Add ‘source’ to the msgbuf.
void lily_mb_add_char(lily_msgbuf *msgbuf,
char ch)
Add a single character ‘ch’ to the msgbuf.
void lily_mb_add_fmt(lily_msgbuf *msgbuf,
const char *format,
Add to the msgbuf based on a format string.
void lily_mb_add_fmt_va(lily_msgbuf *msgbuf,
const char *format,
lily_mb_add_fmt, but using a va_list.
void lily_mb_add_sized(lily_msgbuf *msgbuf,
const char *source,
int count)
Add ‘count’ characters of ‘source’ to the msgbuf.
void lily_mb_add_slice(lily_msgbuf *msgbuf,
const char *source,
int start,
int end)
Add ‘source’ to the msgbuf, from ‘start’ to ‘end’.
void lily_mb_add_value(lily_msgbuf *msgbuf,
lily_state *s,
lily_value *value)
Interpolate a value into the msgbuf.
lily_msgbuf *lily_mb_flush(lily_msgbuf *msgbuf)
Drop all contents in the msgbuf.
const char *lily_mb_html_escape(lily_msgbuf *msgbuf,
const char *input)
Add html-escaped version of ‘input’ to the msgbuf.
int lily_mb_pos(lily_msgbuf *msgbuf)
Return the length of the msgbuf.
const char *lily_mb_raw(lily_msgbuf *msgbuf)
Return the underlying buffer of a msgbuf.
const char *lily_mb_sprintf(lily_msgbuf *msgbuf,
const char *format,
Equivalent to flush, add_fmt, returning the underlying buffer.
Opaque typedef for a msgbuf.
lily_msgbuf *lily_msgbuf_get(lily_state *)
Return the common msgbuf of the interpreter.
lily_msgbuf *lily_new_msgbuf(uint32_t size)
Create a new msgbuf with a starting size of ‘size’.
lily_state *lily_new_state(lily_config *config)
Create a new interpreter.
int lily_optional_boolean(lily_state *s,
int pos,
int fallback)
Fetch a Boolean at ‘index’ or use the ‘fallback’ value.
int64_t lily_optional_integer(lily_state *s,
int pos,
int64_t fallback)
Fetch an Integer at ‘index’ or use the ‘fallback’ value.
const char *lily_optional_string_raw(lily_state *s,
int pos,
const char *fallback)
Fetch the backing of a String at ‘index’ or use the ‘fallback’ value.
int lily_parse_content(lily_state *s)
Parse content prepared for the interpreter.
int lily_parse_expr(lily_state *s,
const char **output)
Parse an expression prepared for the interpreter.
int lily_parse_manifest(lily_state *s)
Parse content as a manifest file.
void lily_push_boolean (lily_state *s,
int value)
(Stack: +1) Push a Boolean value onto the stack.
void lily_push_byte (lily_state *s,
uint8_t value)
(Stack: +1) Push a Byte value onto the stack.
void lily_push_bytestring (lily_state *s,
const char *source,
int size)
(Stack: +1) Push a ByteString value onto the stack.
void lily_push_double (lily_state *s,
double value)
(Stack: +1) Push a Double value onto the stack.
void lily_push_empty_variant(lily_state *s,
uint16_t class_id)
(Stack: +1) Push an empty variant (such as None) onto the stack.
Shorthand for lily_push_variant with LILY_ID_FAILURE.
lily_foreign_val * lily_push_foreign (lily_state *s,
uint16_t class_id,
lily_destroy_func destroy_fn,
size_t size)
(Stack: +1) Push a foreign class value onto the stack.
lily_hash_val * lily_push_hash (lily_state *s,
int size)
(Stack: +1) Push a new Hash with ‘size’ slots reserved onto the stack.
lily_container_val *lily_push_instance (lily_state *s,
uint16_t class_id,
uint32_t size)
(Stack: +1) Push a user-defined class instance with ‘size’ values onto the stack.
void lily_push_integer (lily_state *s,
int64_t value)
(Stack: +1) Push a new Integer onto the stack.
lily_container_val *lily_push_list (lily_state *s,
uint32_t size)
(Stack: +1) Push a List with ‘size’ values onto the stack.
Shorthand for lily_push_empty_variant with LILY_ID_NONE.
Shorthand for lily_push_some with LILY_ID_SOME.
void lily_push_string (lily_state *s,
const char *source)
(Stack: +1) Push a String wrapping over ‘source’ onto the stack.
void lily_push_string_sized (lily_state *s,
const char *source,
int size)
(Stack: +1) Push a String of ‘size’ bytes from ‘source’ onto the stack.
Shorthand for lily_push_success with LILY_ID_SUCCESS.
lily_container_val *lily_push_super (lily_state *s,
uint16_t class_id,
uint32_t size)
(Stack: +1) Push a superclass onto the stack.
lily_container_val *lily_push_tuple (lily_state *s,
uint32_t size)
(Stack: +1) Push a Tuple with ‘size’ values onto the stack.
void lily_push_unit (lily_state *s)
(Stack: +1) Push the unit value (of class Unit) onto the stack.
void lily_push_unset (lily_state *s)
(Stack: +1) Push an unset value onto the stack.
void lily_push_value (lily_state *s,
lily_value *value)
(Stack: +1) Push a full value onto the stack.
lily_container_val *lily_push_variant (lily_state *s,
uint16_t class_id,
uint32_t size)
(Stack: +1) Push a variant of ‘class_id’ and ‘size’ values onto the stack.
Make a module called ‘name’ available to the interpreter.
int lily_render_content(lily_state *s)
Parse content prepared for the interpreter.
Invoked when template mode needs to render content.
void lily_return_boolean(lily_state *s,
int value)
Set a Boolean return value.
void lily_return_byte (lily_state *s,
uint8_t value)
Set a Byte return value.
void lily_return_double (lily_state *s,
double value)
Set a Double return value.
void lily_return_integer(lily_state *s,
int64_t value)
Set an Integer return value.
void lily_return_none (lily_state *s)
Set a None return value.
void lily_return_some_of_top(lily_state *s)
Set a Some holding the top of the stack as the return value.
void lily_return_string (lily_state *s,
const char *value)
Set a String return value.
void lily_return_super (lily_state *s)
Use this if lily_push_super was used.
void lily_return_top (lily_state *s)
Set the return value as the value currently at the top of the stack.
void lily_return_unit (lily_state *s)
Set a Unit return value.
void lily_return_value (lily_state *s,
lily_value *value)
Set the value given as the return value.
void lily_RuntimeError(lily_state *s,
const char *format,
Raise RuntimeError with the given message and args.
void lily_stack_drop_top(lily_state *s)
Pop the top of the stack, deref-ing it if necessary.
lily_value *lily_stack_get_top(lily_state *s)
Return the value at the top of the stack.
uint32_t lily_string_length(lily_string_val *string_val)
Returns the size (in bytes) of a String buffer.
char *lily_string_raw(lily_string_val *string_val)
Returns the raw buffer behind a String.
Holds a String value.
int lily_validate_content(lily_state *s)
Parse (but don’t execute) content prepared for the interpreter.
A complete value with class and flag information.
lily_value_group lily_value_get_group(lily_value *value)
Find out what group that a value belongs to.
void lily_value_tag(lily_state *s,
lily_value *value)
Place a gc tag onto ‘value’.
void lily_ValueError(lily_state *s,
const char *format,
Raise ValueError with the given message and args.