nngn
Loading...
Searching...
No Matches
nngn::lua::state_view Class Reference

#include <state.h>

Inheritance diagram for nngn::lua::state_view:

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 >
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.
 
 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.
 

Protected Attributes

lua_State * L = nullptr
 

Constructor & Destructor Documentation

◆ state_view() [1/4]

nngn::lua::state_view::state_view ( void  )
default

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

◆ state_view() [2/4]

nngn::lua::state_view::state_view ( lua_State *  L_)
inline

Wraps an existing luaState.

◆ state_view() [3/4]

nngn::lua::state_view::state_view ( void  )
default

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

◆ state_view() [4/4]

nngn::lua::state_view::state_view ( lua_State *  L_)
inline

Wraps an existing luaState.

Member Function Documentation

◆ allocator() [1/2]

std::pair< lua_Alloc, void * > nngn::lua::state_view::allocator ( void  ) const
inline

Get memory allocator data.

See also
lua_getallocf
Here is the call graph for this function:
Here is the caller graph for this function:

◆ allocator() [2/2]

std::pair< lua_Alloc, void * > nngn::lua::state_view::allocator ( void  ) const

Get memory allocator data.

See also
lua_getallocf

◆ call() [1/2]

void nngn::lua::state_view::call ( auto &&  f,
auto &&...  args 
) const

Function call, protected in debug mode.

See also
lua_call
Here is the call graph for this function:
Here is the caller graph for this function:

◆ call() [2/2]

void nngn::lua::state_view::call ( auto &&  f,
auto &&...  args 
) const

Function call, protected in debug mode.

See also
lua_call

◆ create_table() [1/4]

table nngn::lua::state_view::create_table ( int  narr,
int  nrec 
) const
inline

Creates a table and pushes it on the stack.

◆ create_table() [2/4]

table nngn::lua::state_view::create_table ( int  narr,
int  nrec 
) const

Creates a table and pushes it on the stack.

◆ create_table() [3/4]

table nngn::lua::state_view::create_table ( void  ) const
inline

Creates a table and pushes it on the stack.

See also
lua_createtable
Here is the call graph for this function:
Here is the caller graph for this function:

◆ create_table() [4/4]

table nngn::lua::state_view::create_table ( void  ) const

Creates a table and pushes it on the stack.

See also
lua_createtable

◆ destroy() [1/2]

void nngn::lua::state_view::destroy ( void  )

Destroys the associated lua_State.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ destroy() [2/2]

void nngn::lua::state_view::destroy ( void  )

Destroys the associated lua_State.

◆ doarg() [1/2]

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.

Here is the call graph for this function:

◆ doarg() [2/2]

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.

◆ dofile() [1/2]

bool nngn::lua::state_view::dofile ( std::string_view  filename) const
See also
luaL_dofile
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dofile() [2/2]

bool nngn::lua::state_view::dofile ( std::string_view  filename) const
See also
luaL_dofile

◆ dofunction() [1/2]

bool nngn::lua::state_view::dofunction ( std::string_view  f) const

Executes the global function f.

Here is the call graph for this function:

◆ dofunction() [2/2]

bool nngn::lua::state_view::dofunction ( std::string_view  f) const

Executes the global function f.

◆ dostring() [1/2]

bool nngn::lua::state_view::dostring ( std::string_view  src) const
See also
luaL_dostring
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dostring() [2/2]

bool nngn::lua::state_view::dostring ( std::string_view  src) const
See also
luaL_dostring

◆ get() [1/2]

template<typename T >
T nngn::lua::state_view::get ( int  i) const

Reads a value from the stack.

Here is the caller graph for this function:

◆ get() [2/2]

template<typename T = value_view>
T nngn::lua::state_view::get ( int  i) const

Reads a value from the stack.

◆ get_type() [1/2]

type nngn::lua::state_view::get_type ( int  i) const
inline
See also
lua_type
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_type() [2/2]

type nngn::lua::state_view::get_type ( int  i) const
See also
lua_type

◆ globals() [1/2]

global_table nngn::lua::state_view::globals ( void  ) const
inline
See also
nngn::lua::global_table
Here is the caller graph for this function:

◆ globals() [2/2]

global_table nngn::lua::state_view::globals ( void  ) const

◆ heartbeat() [1/2]

bool nngn::lua::state_view::heartbeat ( void  ) const

Execute the global heartbeat function.

Here is the call graph for this function:

◆ heartbeat() [2/2]

bool nngn::lua::state_view::heartbeat ( void  ) const

Execute the global heartbeat function.

◆ init() [1/2]

bool nngn::lua::state_view::init ( alloc_info i = nullptr)

Initializes a new state.

The current state, if it exists, is destroyed.

Parameters
iIf set, track all allocations (if compiled with custom allocator support).
Here is the call graph for this function:
Here is the caller graph for this function:

◆ init() [2/2]

bool nngn::lua::state_view::init ( alloc_info i = nullptr)

Initializes a new state.

The current state, if it exists, is destroyed.

Parameters
iIf set, track all allocations (if compiled with custom allocator support).

◆ len() [1/2]

template<typename T >
T nngn::lua::state_view::len ( int  i) const
See also
lua_len
Here is the call graph for this function:

◆ len() [2/2]

template<typename T = lua_Integer>
T nngn::lua::state_view::len ( int  i) const
See also
lua_len

◆ new_user_data() [1/2]

template<typename T >
T * nngn::lua::state_view::new_user_data ( int  nv = 0) const
See also
lua_newuserdatauv
Here is the call graph for this function:

◆ new_user_data() [2/2]

template<typename T >
T * nngn::lua::state_view::new_user_data ( int  nv = 0) const
See also
lua_newuserdatauv

◆ new_user_type() [1/2]

template<typename T >
table nngn::lua::state_view::new_user_type ( void  ) const

Registers a new user type and returns its meta table.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ new_user_type() [2/2]

template<typename T >
table nngn::lua::state_view::new_user_type ( void  ) const

Registers a new user type and returns its meta table.

◆ operator lua_State *() [1/2]

nngn::lua::state_view::operator lua_State * ( void  ) const
inline

Implicit conversion so the state can be passed to Lua functions.

◆ operator lua_State *() [2/2]

nngn::lua::state_view::operator lua_State * ( void  ) const
inline

Implicit conversion so the state can be passed to Lua functions.

◆ pcall() [1/2]

int nngn::lua::state_view::pcall ( auto &&  h,
auto &&  f,
auto &&...  args 
) const

Protected function call with error handler.

See also
lua_pcall
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pcall() [2/2]

int nngn::lua::state_view::pcall ( auto &&  h,
auto &&  f,
auto &&...  args 
) const

Protected function call with error handler.

See also
lua_pcall

◆ pop() [1/2]

void nngn::lua::state_view::pop ( int  n = 1) const
inline
See also
lua_pop
Here is the caller graph for this function:

◆ pop() [2/2]

void nngn::lua::state_view::pop ( int  n = 1) const
inline
See also
lua_pop

◆ print_stack() [1/2]

void nngn::lua::state_view::print_stack ( void  ) const
inline

Non-static version.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_stack() [2/2]

void nngn::lua::state_view::print_stack ( void  ) const
inline

Non-static version.

Here is the call graph for this function:

◆ print_traceback() [1/2]

void nngn::lua::state_view::print_traceback ( void  ) const
inline

Non-static version.

Here is the call graph for this function:

◆ print_traceback() [2/2]

void nngn::lua::state_view::print_traceback ( void  ) const
inline

Non-static version.

Here is the call graph for this function:

◆ push() [1/2]

template<typename T >
T nngn::lua::state_view::push ( auto &&  x) const

Pushes a value onto the stack.

Here is the caller graph for this function:

◆ push() [2/2]

template<typename T = value_view>
T nngn::lua::state_view::push ( auto &&  x) const

Pushes a value onto the stack.

◆ release() [1/2]

state_view nngn::lua::state_view::release ( void  )
inline
Here is the caller graph for this function:

◆ release() [2/2]

state_view nngn::lua::state_view::release ( void  )
inline

◆ remove() [1/2]

void nngn::lua::state_view::remove ( int  i) const
inline
See also
lua_remove
Here is the caller graph for this function:

◆ remove() [2/2]

void nngn::lua::state_view::remove ( int  i) const
inline
See also
lua_remove

◆ set_meta_table() [1/2]

void nngn::lua::state_view::set_meta_table ( auto &&  mt,
int  i 
)
See also
lua_setmetatable
Here is the call graph for this function:

◆ set_meta_table() [2/2]

void nngn::lua::state_view::set_meta_table ( auto &&  mt,
int  i 
)
See also
lua_setmetatable

◆ set_top() [1/2]

void nngn::lua::state_view::set_top ( int  i) const
inline
See also
lua_settop

◆ set_top() [2/2]

void nngn::lua::state_view::set_top ( int  i) const
inline
See also
lua_settop

◆ to_string() [1/2]

std::pair< value, std::string_view > nngn::lua::state_view::to_string ( int  i) const
inline

Pushes a string representation of a value onto the stack.

Here is the caller graph for this function:

◆ to_string() [2/2]

std::pair< value, std::string_view > nngn::lua::state_view::to_string ( int  i) const

Pushes a string representation of a value onto the stack.

◆ top() [1/2]

int nngn::lua::state_view::top ( void  ) const
inline
See also
lua_gettop
Here is the caller graph for this function:

◆ top() [2/2]

int nngn::lua::state_view::top ( void  ) const
inline
See also
lua_gettop

Member Data Documentation

◆ L

lua_State * nngn::lua::state_view::L = nullptr
protected

The documentation for this class was generated from the following files: