nngn
Loading...
Searching...
No Matches
push.h File Reference

Functions for pushing values onto the stack. More...

#include <string_view>
#include <tuple>
#include <utility>
#include <variant>
#include "utils/concepts/fundamental.h"
#include "lua.h"
#include "user.h"
Include dependency graph for push.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nngn::lua::stack_push< std::optional< T > >
 Pushes a T if the object contains a value, otherwise nothing. More...
 
struct  nngn::lua::stack_push< std::variant< Ts... > >
 Pushes the active member of the variant. More...
 
struct  nngn::lua::stack_push< error< T > >
 Emits an error. More...
 
struct  nngn::lua::stack_push< nil_type >
 Pushes a Lua nil value. More...
 
struct  nngn::lua::stack_push< bool >
 Pushes a value as a Lua boolean. More...
 
struct  nngn::lua::stack_push< T * >
 Pushes a generic pointer as a light user data value. More...
 
struct  nngn::lua::stack_push< T >
 Pushes a value convertible to lua_Integer. More...
 
struct  nngn::lua::stack_push< const char * >
 Pushes a C string value. More...
 
struct  nngn::lua::stack_push< std::string_view >
 Pushes a ptr+size string value. More...
 
struct  nngn::lua::stack_push< std::string >
 Convenience specialization for the std::string_view overload. More...
 
struct  nngn::lua::stack_push< lua_CFunction >
 Pushes a lua_CFunction value. More...
 
struct  nngn::lua::stack_push< R(*)(Args...)>
 Pushes a function pointer. More...
 
struct  nngn::lua::stack_push< R(T::*)(Args...)>
 Same as the previous specialization, but for member functions. More...
 
struct  nngn::lua::stack_push< R(T::*)(Args...) const >
 Same as the previous specialization, but for const member functions. More...
 
struct  nngn::lua::stack_push< T & >
 Pushes a user type as a full user data value (reference specialization). More...
 
struct  nngn::lua::stack_push< std::tuple< Ts... > >
 Pushes a sequence of values onto the stack. More...
 

Namespaces

namespace  nngn
 
namespace  nngn::lua
 
namespace  nngn::lua::detail
 

Functions

template<typename R , typename T >
int nngn::lua::detail::push_fn_wrapper (lua_State *L, T f)
 
template<member_pointer auto p>
int nngn::lua::accessor (lua_State *L)
 Lua function template which pushes an object's member.
 
template<member_pointer auto p>
int nngn::lua::value_accessor (lua_State *L)
 Similar to nngn::lua::accessor, but returns the member by value.
 

Detailed Description

Functions for pushing values onto the stack.

These implement the low-level sending of values to the Lua stack. Regular users almost certainly will want a higher-level interface, such as push or state_view::push. These are the underlying functions used in their implementation.

Special handling for custom types can be added by creating stack_push specializations in the nngn::lua namespace (_but note that to simply treat a type as a user value, follow the instructions in register.h). The single static function push should take a lua_State and a value and return the number of items pushed.