summaryrefslogtreecommitdiffstats
path: root/src/Bindings/LuaState.h
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-02-11 09:07:08 +0100
committerMattes D <github@xoft.cz>2014-02-11 09:07:08 +0100
commit1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e (patch)
tree0cacd6ad93e9d02c0228bc314834bd7e8edae1bc /src/Bindings/LuaState.h
parentMerge pull request #660 from worktycho/boatsFix (diff)
parentDebuggers: Updated messaging functions (diff)
downloadcuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.gz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.bz2
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.lz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.xz
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.tar.zst
cuberite-1f96454b9cc35e76bfab2fb5dbea5dc34b0fe28e.zip
Diffstat (limited to '')
-rw-r--r--src/Bindings/LuaState.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Bindings/LuaState.h b/src/Bindings/LuaState.h
index dda45bb28..1c9c99e69 100644
--- a/src/Bindings/LuaState.h
+++ b/src/Bindings/LuaState.h
@@ -65,14 +65,27 @@ class cLuaState
{
public:
- /** Used for storing references to object in the global registry */
+ /** 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(). */
class cRef
{
public:
+ /** Creates an unbound reference object. */
+ cRef(void);
+
/** Creates a reference in the specified LuaState for object at the specified StackPos */
cRef(cLuaState & a_LuaState, int a_StackPos);
+
~cRef();
+ /** 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. */
+ void RefStack(cLuaState & a_LuaState, int a_StackPos);
+
+ /** Removes the bound reference, resets the object to Unbound state. */
+ void UnRef(void);
+
/** Returns true if the reference is valid */
bool IsValid(void) const {return (m_Ref != LUA_REFNIL); }
@@ -80,7 +93,7 @@ public:
operator int(void) const { return m_Ref; }
protected:
- cLuaState & m_LuaState;
+ cLuaState * m_LuaState;
int m_Ref;
} ;