nngn
|
Data block allocated for user data objects. More...
#include <user.h>
Public Types | |
using | get_type = std::remove_pointer_t<T>* |
Public Member Functions | |
user_data (const T &x) | |
Creates a non-owning (reference) object. | |
user_data (T &&x) | |
Creates an owning (copy) object. | |
get_type | get (void) const |
Pointer to the contained/referenced object. | |
void | destroy (void) |
Destroys the T value if this is an owning user data value. | |
Static Public Member Functions | |
static get_type | get (state_view lua, int i) |
Retrieves a user data of type T from the stack. | |
static get_type | from_light (const void *p) |
Retrieves a user data of type T from a light user data value. | |
static bool | check_type (state_view lua, int i) |
Verifies that the value on the stack is a user data of type T . | |
static table | push_metatable (state_view lua) |
Pushes the type's meta table onto the stack. | |
static int | gc (lua_State *L) |
Function to be used as a user data's __gc meta-method. | |
static int | eq (lua_State *L) |
Function to be used as a user data's __eq meta-method. | |
template<typename R > | |
static int | push (state_view lua, R &&r) |
Pushes a value on the stack as a user data of type T . | |
Private Types | |
using | header_type = user_data_header<T> |
using | base_type = typename alloc_block<header_type, T>::storage |
Private Types inherited from nngn::alloc_block< H, T >::storage | |
using | parent = alloc_block |
Static Private Member Functions | |
static get_type | get_pointer (state_view lua, int i) |
Static Private Member Functions inherited from nngn::lua::detail::user_data_base | |
static table | push_metatable (state_view lua, std::string_view meta) |
Pushes the table stored as meta in the global table. | |
static bool | check_type (state_view lua, int i, std::string_view meta) |
static bool | check_pointer_type (state_view lua, int i, std::string_view meta) |
Static Private Attributes | |
static constexpr auto | meta |
Friends | |
class | user_data< T * > |
Additional Inherited Members | |
Private Attributes inherited from nngn::alloc_block< H, T >::storage | |
header_type | header = {} |
value_type | data = {} |
Data block allocated for user data objects.
This object is owning (i.e. must be destroyed / garbage collected) if header.p
points to data
. Otherwise,header.p
points to an existing (external) object and no space is allocated for data
.
|
private |
using nngn::lua::user_data< T >::get_type = std::remove_pointer_t<T>* |
|
private |
|
explicit |
Creates a non-owning (reference) object.
|
explicit |
Creates an owning (copy) object.
|
static |
Verifies that the value on the stack is a user data of type T
.
void nngn::lua::user_data< T >::destroy | ( | void | ) |
Destroys the T
value if this is an owning user data value.
This is done when the value was initially pushed as a value / rvalue reference type.
|
static |
Function to be used as a user data's __eq
meta-method.
Compares objects by identity (i.e. address).
|
static |
Retrieves a user data of type T
from a light user data value.
No type verification is performed.
p | Must be a pointer to an object in the same format as what is pushed by push. |
|
static |
|
static |
Retrieves a user data of type T
from the stack.
|
inline |
Pointer to the contained/referenced object.
|
staticprivate |
|
static |
Pushes a value on the stack as a user data of type T
.
R
may be either a pointer, reference, or value type. For pointers and lvalue references, the user data is a reference to an existing value. For value or rvalue references, the user data is pushed as an independent copy of the value.
|
static |
Pushes the type's meta table onto the stack.
|
staticconstexprprivate |