nngn
Loading...
Searching...
No Matches
lua.h File Reference
#include <numeric>
#include <optional>
#include <lua.hpp>
#include "utils/concepts.h"
#include "utils/fixed_string.h"
#include "utils/fn.h"
#include "utils/ranges.h"
#include "utils/utils.h"
Include dependency graph for lua.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  nngn::lua::nil_type
 Used to push nil values onto the stack. More...
 
struct  nngn::lua::error< T >
 "Pushing" this value causes lua_error to be called. More...
 
struct  nngn::lua::stack_push< void >
 Generic version of stack_push, deduces type from the argument. More...
 
struct  nngn::lua::detail::table_base_tag
 Tag to relate all table_base instantiations via inheritance. More...
 
struct  nngn::lua::detail::table_proxy_tag
 Tag to relate all table_proxy instantiations via inheritance. More...
 

Namespaces

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

Concepts

concept  nngn::lua::user_type
 
concept  nngn::lua::detail::stack_value
 A type which can be read from / pushed onto the stack.
 
concept  nngn::lua::detail::stack_type
 A built-in type from this library with stack manipulation operations.
 
concept  nngn::lua::detail::integer
 A type which can be fully represented by a lua_Integer.
 
concept  nngn::lua::detail::number
 A type which can be fully represented by a lua_Number.
 
concept  nngn::lua::stack_ref
 

Macros

#define NNGN_LUA_TYPES(X)
 
#define X(n, v)   n = v,
 
#define X(n, _)   case type::n: return #n;
 

Enumerations

enum class  nngn::lua::type : int {
  nngn::lua::X , nngn::lua::none = LUA_TNONE , nngn::lua::nil = LUA_TNIL , nngn::lua::boolean = LUA_TBOOLEAN ,
  nngn::lua::light_user_data = LUA_TLIGHTUSERDATA , nngn::lua::number = LUA_TNUMBER , nngn::lua::string = LUA_TSTRING , nngn::lua::table = LUA_TTABLE ,
  nngn::lua::function = LUA_TFUNCTION , nngn::lua::user_data = LUA_TUSERDATA , nngn::lua::thread = LUA_TTHREAD , nngn::lua::X ,
  nngn::lua::none = LUA_TNONE , nngn::lua::nil = LUA_TNIL , nngn::lua::boolean = LUA_TBOOLEAN , nngn::lua::light_user_data = LUA_TLIGHTUSERDATA ,
  nngn::lua::number = LUA_TNUMBER , nngn::lua::string = LUA_TSTRING , nngn::lua::table = LUA_TTABLE , nngn::lua::function = LUA_TFUNCTION ,
  nngn::lua::user_data = LUA_TUSERDATA , nngn::lua::thread = LUA_TTHREAD
}
 LUA_T* constants as a scoped enumeration. More...
 
enum  nngn::lua::detail::op_mode { nngn::lua::detail::normal , nngn::lua::detail::raw , nngn::lua::detail::normal , nngn::lua::detail::raw }
 

Functions

template<typename T >
 nngn::lua::error (T) -> error< T >
 
constexpr type nngn::lua::type_from_lua (int t)
 Maps LUA_T* values to type.
 
template<typename R , typename ... Args>
nngn::lua::call (lua_State *L, R(*f)(Args...), int i)
 Calls the regular function f with arguments taken from the stack.
 
template<typename R , typename T , typename ... Args>
nngn::lua::call (lua_State *L, R(T::*f)(Args...), int i)
 Calls member function f with object/arguments taken from the stack.
 
template<stateless_lambda T>
 nngn::lua::call (lua_State *L, T, int i)
 Calls a stateless lambda.
 
std::string_view nngn::lua::type_str (type t)
 
int nngn::lua::msgh (lua_State *L)
 Default message handler for lua_pcall.
 
void nngn::lua::print_stack (lua_State *L)
 Logs the current data stack.
 
void nngn::lua::print_traceback (lua_State *L)
 Logs the current call stack.
 

Macro Definition Documentation

◆ NNGN_LUA_TYPES

#define NNGN_LUA_TYPES (   X)
Value:
X(none, LUA_TNONE) \
X(nil, LUA_TNIL) \
X(boolean, LUA_TBOOLEAN) \
X(light_user_data, LUA_TLIGHTUSERDATA) \
X(number, LUA_TNUMBER) \
X(string, LUA_TSTRING) \
X(table, LUA_TTABLE) \
X(function, LUA_TFUNCTION) \
X(user_data, LUA_TUSERDATA) \
X(thread, LUA_TTHREAD)
#define X(n, v)
Definition: lua.h:78

◆ X [1/2]

#define X (   n,
  _ 
)    case type::n: return #n;

◆ X [2/2]

#define X (   n,
  v 
)    n = v,