diff options
author | chai <chaifix@163.com> | 2021-10-29 13:36:49 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-29 13:36:49 +0800 |
commit | 91c32cb173201ac8803a1e4452e8342969b8e484 (patch) | |
tree | 5e78c485b5fcfcf839a2348667597d7e10476214 /Runtime/Lua/LuaBind | |
parent | 1f92d4c389cceba6f90261d9cb29885c8a3ca24c (diff) |
*GLSL test
Diffstat (limited to 'Runtime/Lua/LuaBind')
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindRef.cpp | 22 | ||||
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindRef.h | 7 | ||||
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindState.cpp | 6 |
3 files changed, 34 insertions, 1 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindRef.cpp b/Runtime/Lua/LuaBind/LuaBindRef.cpp index d0f2766..313824e 100644 --- a/Runtime/Lua/LuaBind/LuaBindRef.cpp +++ b/Runtime/Lua/LuaBind/LuaBindRef.cpp @@ -3,6 +3,12 @@ namespace LuaBind { + UniversalRef::UniversalRef(RefMode mode) + : mRefID(LUA_NOREF) + , mMode(mode) + , mOwner(NULL) // 延后设置 + { + } UniversalRef::UniversalRef(LuaBind::VM* vm, RefMode mode) : mRefID(LUA_NOREF) @@ -43,7 +49,11 @@ namespace LuaBind void UniversalRef::SetRef(LuaBind::State& state, int idx) { - assert(state.GetVM() == mOwner); + //assert(state.GetVM() == mOwner); + // 延后设置vm + if (mOwner == NULL) { + mOwner = state.GetVM(); + } VM* vm = mOwner; if (!vm) return; @@ -83,11 +93,21 @@ namespace LuaBind return true; } + StrongRef::StrongRef() + : UniversalRef(STRONG_REF) + { + } + StrongRef::StrongRef(LuaBind::VM* vm) : UniversalRef(vm, STRONG_REF) { } + WeakRef::WeakRef() + : UniversalRef(WEAK_REF) + { + } + WeakRef::WeakRef(LuaBind::VM* vm) : UniversalRef(vm, WEAK_REF) { diff --git a/Runtime/Lua/LuaBind/LuaBindRef.h b/Runtime/Lua/LuaBind/LuaBindRef.h index 793559e..a19e5bf 100644 --- a/Runtime/Lua/LuaBind/LuaBindRef.h +++ b/Runtime/Lua/LuaBind/LuaBindRef.h @@ -18,6 +18,7 @@ namespace LuaBind WEAK_REF }; + UniversalRef(RefMode mode = STRONG_REF); // 延后到SetRef设置vm UniversalRef(LuaBind::VM* vm, RefMode mode = STRONG_REF); virtual ~UniversalRef(); @@ -46,6 +47,9 @@ namespace LuaBind class StrongRef: public UniversalRef { public: + // 延后到SetRef设置vm + StrongRef(); + StrongRef(LuaBind::VM* vm); }; @@ -54,6 +58,9 @@ namespace LuaBind class WeakRef : public UniversalRef { public: + // 延后到SetRef设置vm + WeakRef(); + WeakRef(LuaBind::VM* vm); }; diff --git a/Runtime/Lua/LuaBind/LuaBindState.cpp b/Runtime/Lua/LuaBind/LuaBindState.cpp index 9210768..384cba2 100644 --- a/Runtime/Lua/LuaBind/LuaBindState.cpp +++ b/Runtime/Lua/LuaBind/LuaBindState.cpp @@ -602,6 +602,12 @@ namespace LuaBind case '+': if (type == LUA_TNIL) expected = false; break; + + // nil + case '!': + if (type != LUA_TNIL) expected = false; + break; + } if (!expected) { |