64#ifndef NNGN_LUA_FUNCTION_H
65#define NNGN_LUA_FUNCTION_H
86template<
typename CRTP>
114template<
typename CRTP>
117 const auto &crtp =
static_cast<const CRTP&
>(*this);
118 crtp.state().call(crtp,
FWD(args)...);
124template<
typename R,
typename ...Args>
125R
call(lua_State *L, R(*
f)(Args...),
int i) {
130template<
typename R,
typename T,
typename ...Args>
131R
call(lua_State *L, R(T::*
f)(Args...),
int i) {
136template<
typename R,
typename T,
typename ...Args>
137R
call(lua_State *L, R(T::*
f)(Args...)
const,
int i) {
138 return std::apply(
f, stack_get<std::tuple<const T&, Args...>>
::get(L, i));
142template<stateless_lambda T>
143decltype(
auto)
call(lua_State *L, T,
int i) {
144 return call(L, +T{}, i);
147static_assert(detail::stack_type<function_view>);
148static_assert(detail::stack_type<function_value>);
Base, non-owning generic stack value reference.
Definition: value.h:18
value_view(lua_State *L, int i)
Definition: value.h:21
#define NNGN_LOG_CONTEXT_CF(c)
Definition: log.h:11
Definition: alloc.cpp:100
R call(lua_State *L, R(*f)(Args...), int i)
Calls the regular function f with arguments taken from the stack.
Definition: function.h:125
Functions for pushing values onto the stack.
get
Definition: camera.lua:36
Reference to a function on the stack.
Definition: function.h:87
void operator()(auto &&...args) const
Pushes each argument onto the stack and calls the function.
Definition: function.h:115
Owning reference to a function on the stack.
Definition: function.h:106
~function_value(void)=default
Non-owning reference to a function on the stack.
Definition: function.h:98
Reads a value from the Lua stack.
Definition: lua.h:117
Owning stack value reference.
Definition: value.h:48
value(value_view v)
Definition: value.h:51
#define FWD(...)
Definition: utils.h:18
#define NNGN_MOVE_ONLY(x)
Definition: utils.h:39
Operations on generic stack values.