summaryrefslogtreecommitdiff
path: root/Runtime/Lua/LuaBind/LuaBindRef.h
diff options
context:
space:
mode:
Diffstat (limited to 'Runtime/Lua/LuaBind/LuaBindRef.h')
-rw-r--r--Runtime/Lua/LuaBind/LuaBindRef.h21
1 files changed, 11 insertions, 10 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindRef.h b/Runtime/Lua/LuaBind/LuaBindRef.h
index 7058094..cd2fad1 100644
--- a/Runtime/Lua/LuaBind/LuaBindRef.h
+++ b/Runtime/Lua/LuaBind/LuaBindRef.h
@@ -11,40 +11,41 @@ namespace LuaBind
class Ref
{
public:
-
enum RefMode
{
STRONG_REF,
WEAK_REF
};
- Ref(RefMode mode = STRONG_REF);
+ Ref(LuaBind::VM* vm, RefMode mode = STRONG_REF);
virtual ~Ref();
operator bool();
// 将栈上的对象添加到全局引用表中
- void SetRef(State& state, int idx);
+ void SetRef(LuaBind::State& state, int idx);
+
+ // 解除引用
+ void UnRef();
// 将引用的对象压入栈
- bool PushRef(State& state);
+ bool PushRef(LuaBind::State& state);
int GetRefID() { return mRefID; }
RefMode GetRefMode() { return mMode; }
private:
-
- int mRefID;
- RefMode mMode;
-
+ LuaBind::VM* mOwner; // 所属的虚拟机
+ RefMode mMode; // 模式
+ int mRefID; // 引用ID
};
// 强引用,在LUA_REGISTRYINDEX["GAMELAB_UNIVERSAL_STRONG_REFERENCE_TABLE"]里,保证lua object不会被回收
class StrongRef: public Ref
{
public:
- StrongRef();
+ StrongRef(LuaBind::VM* vm);
};
@@ -52,7 +53,7 @@ namespace LuaBind
class WeakRef : public Ref
{
public:
- WeakRef();
+ WeakRef(LuaBind::VM* vm);
};