![]() |
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Used for storing references to object in the global registry. More...
#include <LuaState.h>
Public Member Functions | |
template<typename T > | |
void | CreateFromObject (cLuaState &a_LuaState, T &&a_Object) |
Creates a Lua reference to the specified object instance in the specified Lua state. More... | |
cRef (void) | |
Creates an unbound reference object. More... | |
cRef (cLuaState &a_LuaState, int a_StackPos) | |
Creates a reference in the specified LuaState for object at the specified StackPos. More... | |
cRef (cRef &&a_FromRef) | |
Moves the reference from the specified instance into a newly created instance. More... | |
lua_State * | GetLuaState (void) |
Returns the Lua state associated with the value. More... | |
bool | IsValid (void) const |
Returns true if the reference is valid. More... | |
operator int (void) const | |
Allows to use this class wherever an int (i. More... | |
void | RefStack (cLuaState &a_LuaState, int a_StackPos) |
Creates a reference to Lua object at the specified stack pos, binds this object to it. More... | |
void | UnRef (void) |
Removes the bound reference, resets the object to Unbound state. More... | |
~cRef () | |
Protected Member Functions | |
cRef (const cRef &)=delete | |
Protected Attributes | |
lua_State * | m_LuaState |
int | m_Ref |
Used for storing references to object in the global registry.
Can be bound (contains a reference) or unbound (doesn't contain reference). The reference can also be reset by calling RefStack().
Definition at line 161 of file LuaState.h.
cLuaState::cRef::cRef | ( | void | ) |
Creates an unbound reference object.
Definition at line 2435 of file LuaState.cpp.
cLuaState::cRef::cRef | ( | cLuaState & | a_LuaState, |
int | a_StackPos | ||
) |
Creates a reference in the specified LuaState for object at the specified StackPos.
Definition at line 2445 of file LuaState.cpp.
cLuaState::cRef::cRef | ( | cRef && | a_FromRef | ) |
Moves the reference from the specified instance into a newly created instance.
The old instance is then "!IsValid()".
Definition at line 2456 of file LuaState.cpp.
cLuaState::cRef::~cRef | ( | ) |
Definition at line 2468 of file LuaState.cpp.
|
protecteddelete |
|
inline |
Creates a Lua reference to the specified object instance in the specified Lua state.
This is useful to make anti-GC references for objects that were created by Lua and need to stay alive longer than Lua GC would normally guarantee.
Definition at line 194 of file LuaState.h.
|
inline |
Returns the Lua state associated with the value.
Definition at line 190 of file LuaState.h.
|
inline |
Returns true if the reference is valid.
Definition at line 184 of file LuaState.h.
|
inlineexplicit |
Allows to use this class wherever an int (i.
e. ref) is to be used
Definition at line 187 of file LuaState.h.
void cLuaState::cRef::RefStack | ( | cLuaState & | a_LuaState, |
int | a_StackPos | ||
) |
Creates a reference to Lua object at the specified stack pos, binds this object to it.
Calls UnRef() first if previously bound to another reference.
Definition at line 2480 of file LuaState.cpp.
void cLuaState::cRef::UnRef | ( | void | ) |
Removes the bound reference, resets the object to Unbound state.
Definition at line 2497 of file LuaState.cpp.
|
protected |
Definition at line 202 of file LuaState.h.
|
protected |
Definition at line 203 of file LuaState.h.