|
nngn
|
#include <state.h>

Public Member Functions | |
| state_view (void)=default | |
Empty state, must call init before any other function is called. | |
| state_view (lua_State *L_) | |
Wraps an existing luaState. | |
| operator lua_State * (void) const | |
| Implicit conversion so the state can be passed to Lua functions. | |
| bool | init (alloc_info *i=nullptr) |
| Initializes a new state. | |
| state_view | release (void) |
| void | destroy (void) |
Destroys the associated lua_State. | |
| int | top (void) const |
| type | get_type (int i) const |
| template<typename T = lua_Integer> | |
| T | len (int i) const |
| std::pair< lua_Alloc, void * > | allocator (void) const |
| Get memory allocator data. | |
| global_table | globals (void) const |
| void | set_top (int i) const |
| void | set_meta_table (auto &&mt, int i) |
| void | print_stack (void) const |
| Non-static version. | |
| void | print_traceback (void) const |
| Non-static version. | |
| bool | doarg (std::string_view s) const |
Calls dofile or dostring depending on s[0] == '@'. | |
| bool | dofile (std::string_view filename) const |
| bool | dostring (std::string_view src) const |
| bool | dofunction (std::string_view f) const |
Executes the global function f. | |
| template<typename T > | |
| T * | new_user_data (int nv=0) const |
| template<typename T > | |
| table | new_user_type (void) const |
| Registers a new user type and returns its meta table. | |
| table | create_table (void) const |
| Creates a table and pushes it on the stack. | |
| table | create_table (int narr, int nrec) const |
| Creates a table and pushes it on the stack. | |
| template<typename T = value_view> | |
| T | get (int i) const |
| Reads a value from the stack. | |
| template<typename T = value_view> | |
| T | push (auto &&x) const |
| Pushes a value onto the stack. | |
| void | pop (int n=1) const |
| void | remove (int i) const |
| void | call (auto &&f, auto &&...args) const |
| Function call, protected in debug mode. | |
| int | pcall (auto &&h, auto &&f, auto &&...args) const |
| Protected function call with error handler. | |
| std::pair< value, std::string_view > | to_string (int i) const |
| Pushes a string representation of a value onto the stack. | |
| bool | heartbeat (void) const |
Execute the global heartbeat function. | |
Protected Attributes | |
| lua_State * | L = nullptr |
|
default |
Empty state, must call init before any other function is called.
|
inline |
Wraps an existing luaState.
|
inline |
Get memory allocator data.


| void nngn::lua::state_view::call | ( | auto && | f, |
| auto &&... | args ) const |
Function call, protected in debug mode.


Creates a table and pushes it on the stack.
|
inline |
Creates a table and pushes it on the stack.


| void nngn::lua::state_view::destroy | ( | void | ) |
Destroys the associated lua_State.


| bool nngn::lua::state_view::doarg | ( | std::string_view | s | ) | const |
Calls dofile or dostring depending on s[0] == '@'.
See how the lua interpreter program handles LUA_INIT.

| bool nngn::lua::state_view::dofile | ( | std::string_view | filename | ) | const |


| bool nngn::lua::state_view::dofunction | ( | std::string_view | f | ) | const |
Executes the global function f.

| bool nngn::lua::state_view::dostring | ( | std::string_view | src | ) | const |


Reads a value from the stack.




|
inline |
| bool nngn::lua::state_view::heartbeat | ( | void | ) | const |
Execute the global heartbeat function.

| bool nngn::lua::state_view::init | ( | alloc_info * | i = nullptr | ) |
Initializes a new state.
The current state, if it exists, is destroyed.
| i | If set, track all allocations (if compiled with custom allocator support). |





Registers a new user type and returns its meta table.


|
inline |
Implicit conversion so the state can be passed to Lua functions.
| int nngn::lua::state_view::pcall | ( | auto && | h, |
| auto && | f, | ||
| auto &&... | args ) const |
Protected function call with error handler.


|
inline |

|
inline |
Non-static version.


|
inline |
Non-static version.

Pushes a value onto the stack.


|
inline |

|
inline |

| void nngn::lua::state_view::set_meta_table | ( | auto && | mt, |
| int | i ) |

|
inline |
Pushes a string representation of a value onto the stack.

|
inline |

|
protected |