nngn
Loading...
Searching...
No Matches
nngn::lua::state Struct Reference

Owning lua_State wrapper. More...

#include <state.h>

Inheritance diagram for nngn::lua::state:
Collaboration diagram for nngn::lua::state:

Public Member Functions

 state (const state &)=delete
 
stateoperator= (const state &)=delete
 
 state (void)=default
 Empty state, must call init before any other function is called.
 
 state (lua_State *L_)
 Takes ownership of an existing luaState.
 
 state (state &&rhs) noexcept
 Transfers the lua_State from another object.
 
stateoperator= (state &&rhs) noexcept
 Transfers the lua_State from another object.
 
 ~state (void)
 Destroys the associated lua_State.
 
- Public Member Functions inherited from nngn::lua::state_view
 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 >
Tnew_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.
 

Additional Inherited Members

- Protected Attributes inherited from nngn::lua::state_view
lua_State * L = nullptr
 

Detailed Description

Owning lua_State wrapper.

Constructor & Destructor Documentation

◆ state() [1/4]

nngn::lua::state::state ( const state & )
delete

◆ state() [2/4]

nngn::lua::state::state ( void )
default

Empty state, must call init before any other function is called.

◆ state() [3/4]

nngn::lua::state::state ( lua_State * L_)
inlineexplicit

Takes ownership of an existing luaState.

◆ state() [4/4]

nngn::lua::state::state ( state && rhs)
inlinenoexcept

Transfers the lua_State from another object.

◆ ~state()

nngn::lua::state::~state ( void )
inline

Destroys the associated lua_State.

Here is the call graph for this function:

Member Function Documentation

◆ operator=() [1/2]

state & nngn::lua::state::operator= ( const state & )
delete

◆ operator=() [2/2]

state & nngn::lua::state::operator= ( state && rhs)
inlinenoexcept

Transfers the lua_State from another object.


The documentation for this struct was generated from the following file: