§tiro

§Namespaces

Name
tiro::detail

§Classes

Name
classtiro::api_error
Represents an error thrown by the tiro c library.
classtiro::array
Refers to an array value.
classtiro::async_frame
Represents the call frame of a asynchronous function call.
classtiro::async_token
A token that can be used to resume a yielding coroutine.
classtiro::bad_handle_cast
Thrown when an invalid cast is attempted.
classtiro::bad_handle_check
Thrown when a debug mode handle check failed.
classtiro::boolean
Refers to a boolean value (true or false).
classtiro::compiled_module
Represents a compiled bytecode module.
classtiro::compiler
Translates a set of source files into a module.
structtiro::compiler_message
Represents a diagnostic message emitted by the compiler.
structtiro::compiler_settings
An instance of this type can be passed to the compiler to configure it.
classtiro::coroutine
Refers to a coroutine.
classtiro::error
Base class for all errors thrown by this library.
classtiro::error_adapter
Error adapter class for the tiroerror_t* argument expected by most tiro* functions.
classtiro::exception
Refers to an exception.
classtiro::float_
Refers to a float value.
classtiro::function
Refers to a function value.
classtiro::generic_error
Generic error with a simple message.
classtiro::handle
A handle represents a reference to an object.
classtiro::integer
Refers to an integer value.
classtiro::module
Refers to a module.
classtiro::native
Refers to a native object.
classtiro::native_type
classtiro::null
Refers to a null value.
classtiro::record
Refers to a record value.
classtiro::record_schema
Refers to a record schema.
classtiro::result
Refers to a result value.
classtiro::resumable_frame
Represents the call frame of a resumable function call.
classtiro::string
Refers to a string value.
classtiro::sync_frame
Represents the call frame of a synchronous function call.
classtiro::tuple
Refers to a tuple value.
classtiro::type
Refers to a type.
structtiro::version
Represents a library version.
classtiro::vm
structtiro::vm_settings
Settings to control the construction of a virtual machine.

§Types

Name
enum class intseverity { warning = TIRO_SEVERITY_WARNING, error = TIRO_SEVERITY_ERROR}
Defines the possible values for the severity of diagnostic compiler messages.
enum class intapi_errc { ok = TIRO_OK, bad_state = TIRO_ERROR_BAD_STATE, bad_arg = TIRO_ERROR_BAD_ARG, bad_source = TIRO_ERROR_BAD_SOURCE, bad_type = TIRO_ERROR_BAD_TYPE, bad_key = TIRO_ERROR_BAD_KEY, module_exists = TIRO_ERROR_MODULE_EXISTS, module_not_found = TIRO_ERROR_MODULE_NOT_FOUND, export_not_found = TIRO_ERROR_EXPORT_NOT_FOUND, out_of_bounds = TIRO_ERROR_OUT_OF_BOUNDS, alloc = TIRO_ERROR_ALLOC, internal = TIRO_ERROR_INTERNAL}
Defines all possible error codes.
enum class intvalue_kind { null = TIROKIND_NULL, boolean = TIRO_KIND_BOOLEAN, integer = TIRO_KIND_INTEGER, float = TIRO_KIND_FLOAT, string = TIRO_KIND_STRING, function = TIRO_KIND_FUNCTION, tuple = TIRO_KIND_TUPLE, record = TIRO_KIND_RECORD, record_schema = TIRO_KIND_RECORD_SCHEMA, array = TIRO_KIND_ARRAY, result = TIRO_KIND_RESULT, exception = TIRO_KIND_EXCEPTION, coroutine = TIRO_KIND_COROUTINE, module = TIRO_KIND_MODULE, type = TIRO_KIND_TYPE, native = TIRO_KIND_NATIVE, internal = TIRO_KIND_INTERNAL, invalid = TIRO_KIND_INVALID}
Represents the kind of a value.

§Functions

Name
const char *to_string(severity s)
Returns the string representation of the given severity value.
const char *name(api_errc e)
Returns the name of the given error code.
const char *message(api_errc e)
Returns the human readable message associated with the error code.
template <auto Function>
function
make_sync_function(vm & v, const string & name, size_t argc, const handle & closure)
Constructs a new function object with the given name that will invoke the native function when called.
template <auto Function>
function
make_async_function(vm & v, const string & name, size_t argc, const handle & closure)
Constructs a new function object with the given name that will invoke the native function when called.
template <auto Function>
function
make_resumable_function(vm & v, const string & name, size_t argc, size_t locals, const handle & closure)
Creates a new resumable function with the given parameters.
const char *to_string(value_kind k)
Returns the string representation of the given value kind.
handlemake_copy(vm & v, tiro_handle_t value)
Constructs a new handle as a copy of the given value.
boolsame(vm & v, const handle & a, const handle & b)
Returns true if and only if a and b refer to the same value.
nullmake_null(vm & v)
Constructs a new handle, initialized to null.
booleanmake_boolean(vm & v, bool value)
Constructs a new boolean value.
integermake_integer(vm & v, int64_t value)
Constructs a new integer value.
float_make_float(vm & v, double value)
Constructs a new float value.
stringmake_string(vm & v, std::string_view value)
Constructs a new string value.
tuplemake_tuple(vm & v, size_t size)
Constructs a new tuple value with the given size.
record_schemamake_record_schema(vm & v, const array & keys)
Creates a new record schema from the given array of keys.
recordmake_record(vm & v, const record_schema & schema)
Constructs a new record with the property names specified by the given schema.
arraymake_array(vm & v, size_t initial_capacity =0)
Constructs a new array with the given initial capacity. The array will be empty.
resultmake_success(vm & v, const handle & value)
Creates a new successful result with the given value.
resultmake_error(vm & v, const handle & err)
Creates a new error result with the given error value.
coroutinemake_coroutine(vm & v, const function & func, const handle & arguments)
Constructs a new coroutine value.
coroutinemake_coroutine(vm & v, const function & func)
Constructs a new coroutine value.
modulemake_module(vm & v, std::string_view name, const std::vector< std::pair< std::string, handle >> & exports)
Creates a new module with the given name and exports.
handleget_export(const vm & v, std::string_view module_name, std::string_view export_name)
Attempts to find an exported value called export_name in the module module_name.
voidload_module(const vm & v, const module & m)
Attempts to load the given module into the virtual machine.
template <typename Callback >
void
run_async(vm & v, const function & func, Callback && cb)
Schedules execution of func in a new coroutine without any arguments.
template <typename Callback >
void
run_async(vm & v, const function & func, const handle & args, Callback && cb)
Schedules execution of func in a new coroutine, with the provided arguments.
constexpr versioncompile_time_version()
Returns the compile time version of the tiro library, i.e.
versionruntime_version()
Returns the runtime version of the tiro library, i.e.

§Types Documentation

§enum severity

EnumeratorValueDescription
warningTIRO_SEVERITY_WARNING
errorTIRO_SEVERITY_ERROR

Defines the possible values for the severity of diagnostic compiler messages.

§enum api_errc

EnumeratorValueDescription
okTIRO_OKSuccess.
bad_stateTIRO_ERROR_BAD_STATEInstance is not in the correct state.
bad_argTIRO_ERROR_BAD_ARGInvalid argument.
bad_sourceTIRO_ERROR_BAD_SOURCEInvalid source code.
bad_typeTIRO_ERROR_BAD_TYPEOperation not supported on type.
bad_keyTIRO_ERROR_BAD_KEYKey does not exist on object.
module_existsTIRO_ERROR_MODULE_EXISTSModule name defined more than once.
module_not_foundTIRO_ERROR_MODULE_NOT_FOUNDRequested module does not exist.
export_not_foundTIRO_ERROR_EXPORT_NOT_FOUNDRequested export does not exist.
out_of_boundsTIRO_ERROR_OUT_OF_BOUNDSArgument was out of bounds.
allocTIRO_ERROR_ALLOCAllocation failure.
internalTIRO_ERROR_INTERNALInternal error.

Defines all possible error codes.

§enum value_kind

EnumeratorValueDescription
nullTIRO_KIND_NULLValue is null.
booleanTIRO_KIND_BOOLEANValue is true or false.
integerTIRO_KIND_INTEGERValue is an integer.
float_TIRO_KIND_FLOATValue is a floating point number.
stringTIRO_KIND_STRINGValue is a string.
functionTIRO_KIND_FUNCTIONValue is a function.
tupleTIRO_KIND_TUPLEValue is a tuple.
recordTIRO_KIND_RECORDValue is a record.
record_schemaTIRO_KIND_RECORD_SCHEMAValue is a record schema.
arrayTIRO_KIND_ARRAYValue is an array.
resultTIRO_KIND_RESULTValue is a result.
exceptionTIRO_KIND_EXCEPTIONValue is an exception.
coroutineTIRO_KIND_COROUTINEValue is a coroutine.
moduleTIRO_KIND_MODULEValue is a module.
typeTIRO_KIND_TYPEValue is a type.
nativeTIRO_KIND_NATIVEValue is a native object.
internalTIRO_KIND_INTERNALValue is some other, internal type.
invalidTIRO_KIND_INVALIDInvalid value (e.g. null handle)

Represents the kind of a value.

§Functions Documentation

§function to_string

inline const char * to_string(
severity s
)

Returns the string representation of the given severity value.

The returned string is allocated in static storage.

§function name

inline const char * name(
api_errc e
)

Returns the name of the given error code.

The returned string is allocated in static storage.

§function message

inline const char * message(
api_errc e
)

Returns the human readable message associated with the error code.

The returned string is allocated in static storage.

§function make_sync_function

template <auto Function>
function make_sync_function(
vm & v,
const string & name,
size_t argc,
const handle & closure
)

Constructs a new function object with the given name that will invoke the native function when called.

argc is the number of arguments required for calling Function. closure may be an arbitrary value that will be passed to the function on every invocation.

Synchronous functions are appropriate for simple, nonblocking operations. Use asynchronous functions for long running operations (such as network I/O) instead.

Function will receive two arguments when invoked:

  • A reference to the vm (vm&).
  • A reference to the call frame ([sync_frame](/docs/api/classes/classtiro_1_1sync__frame)&). Use this reference to access call arguments. Both references may only be used during the function call. The function should return its return value as a handle.

§function make_async_function

template <auto Function>
function make_async_function(
vm & v,
const string & name,
size_t argc,
const handle & closure
)

Constructs a new function object with the given name that will invoke the native function when called.

argc is the number of arguments required for calling Function. closure may be an arbitrary value that will be passed to the function on every invocation.

Function will receive two arguments when invoked:

  • A reference to the vm (vm&).
  • A call frame value ([async_frame](/docs/api/classes/classtiro_1_1async__frame)). Use this value to access call arguments and to set the return value.

§function make_resumable_function

template <auto Function>
function make_resumable_function(
vm & v,
const string & name,
size_t argc,
size_t locals,
const handle & closure
)

Creates a new resumable function with the given parameters.

§function to_string

inline const char * to_string(
value_kind k
)

Returns the string representation of the given value kind.

The returned string is allocated in static storage.

§function make_copy

inline handle make_copy(
vm & v,
tiro_handle_t value
)

Constructs a new handle as a copy of the given value.

§function same

inline bool same(
vm & v,
const handle & a,
const handle & b
)

Returns true if and only if a and b refer to the same value.

§function make_null

inline null make_null(
vm & v
)

Constructs a new handle, initialized to null.

§function make_boolean

inline boolean make_boolean(
vm & v,
bool value
)

Constructs a new boolean value.

§function make_integer

inline integer make_integer(
vm & v,
int64_t value
)

Constructs a new integer value.

§function make_float

inline float_ make_float(
vm & v,
double value
)

Constructs a new float value.

§function make_string

inline string make_string(
vm & v,
std::string_view value
)

Constructs a new string value.

§function make_tuple

inline tuple make_tuple(
vm & v,
size_t size
)

Constructs a new tuple value with the given size.

All elements of that tuple will be initialized to null.

§function make_record_schema

inline record_schema make_record_schema(
vm & v,
const array & keys
)

Creates a new record schema from the given array of keys.

All keys must be strings.

§function make_record

inline record make_record(
vm & v,
const record_schema & schema
)

Constructs a new record with the property names specified by the given schema.

All values of the record will be initialized to null.

§function make_array

inline array make_array(
vm & v,
size_t initial_capacity =0
)

Constructs a new array with the given initial capacity. The array will be empty.

§function make_success

inline result make_success(
vm & v,
const handle & value
)

Creates a new successful result with the given value.

§function make_error

inline result make_error(
vm & v,
const handle & err
)

Creates a new error result with the given error value.

§function make_coroutine

inline coroutine make_coroutine(
vm & v,
const function & func,
const handle & arguments
)

Constructs a new coroutine value.

The coroutine will call the given function with the provided arguments, once it has been started.

§function make_coroutine

inline coroutine make_coroutine(
vm & v,
const function & func
)

Constructs a new coroutine value.

The coroutine will call the given function without any arguments, once it has been started.

§function make_module

inline module make_module(
vm & v,
std::string_view name,
const std::vector< std::pair< std::string, handle >> & exports
)

Creates a new module with the given name and exports.

§function get_export

inline handle get_export(
const vm & v,
std::string_view module_name,
std::string_view export_name
)

Attempts to find an exported value called export_name in the module module_name.

§function load_module

inline void load_module(
const vm & v,
const module & m
)

Attempts to load the given module into the virtual machine.

§function run_async

template <typename Callback >
inline void run_async(
vm & v,
const function & func,
Callback && cb
)

Schedules execution of func in a new coroutine without any arguments.

The callback cb will be called once func has completed its execution. Note that func will not be executed from within this function (the next call to [vm.run_ready()](/docs/api/classes/classtiro_1_1vm#function-run-ready) will do that). TODO: Extract the result() from the coroutine and pass it directly to the callback.

§function run_async

template <typename Callback >
inline void run_async(
vm & v,
const function & func,
const handle & args,
Callback && cb
)

Schedules execution of func in a new coroutine, with the provided arguments.

The callback cb will be called once func has completed its execution. Note that func will not be executed from within this function (the next call to [vm.run_ready()](/docs/api/classes/classtiro_1_1vm#function-run-ready) will do that). TODO: Extract the result() from the coroutine and pass it directly to the callback.

§function compile_time_version

inline constexpr version compile_time_version()

Returns the compile time version of the tiro library, i.e.

the version the application was built against.

§function runtime_version

inline version runtime_version()

Returns the runtime version of the tiro library, i.e.

the version the application is currently running against.


Updated on 2022-02-27 at 21:17:13 +0100