diff options
author | chai <chaifix@163.com> | 2021-10-29 22:28:12 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-10-29 22:28:12 +0800 |
commit | 164885fd98d48703bd771f802d79557b7db97431 (patch) | |
tree | 7c396e475082644ec6994bcc7f3914eb4efb0c5a /Runtime/Lua/LuaBind | |
parent | 655466e2d798b72ee3d3be7fcfe32db6af2d4466 (diff) |
* !!! 允许NativeClass延后绑定VM
Diffstat (limited to 'Runtime/Lua/LuaBind')
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindClass.hpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindClass.hpp b/Runtime/Lua/LuaBind/LuaBindClass.hpp index 1da8513..aed4741 100644 --- a/Runtime/Lua/LuaBind/LuaBindClass.hpp +++ b/Runtime/Lua/LuaBind/LuaBindClass.hpp @@ -81,6 +81,8 @@ namespace LuaBind protected: + // ӺVM + NativeClass(); // Ҫָ NativeClass(LuaBind::VM* vm); virtual ~NativeClass(); @@ -108,6 +110,9 @@ namespace LuaBind // userdataʵstate void BindToLua(State& state); + // ӺVMBindToLua + void LateBindVM(VM* vm); + //------------------------------------------------------------------------------// // @@ -196,6 +201,12 @@ namespace LuaBind } template<class TYPE, class BASE> + void NativeClass<TYPE, BASE>::LateBindVM(VM* vm) + { + mOwner = vm; + } + + template<class TYPE, class BASE> void NativeClass<TYPE, BASE>::PushClassTable(State& state) { LuaBind::VM* vm = state.GetVM(); @@ -203,6 +214,17 @@ namespace LuaBind } template<class TYPE, class BASE> + NativeClass<TYPE, BASE>::NativeClass() + : mWatchDog() + , mUserdata(NULL) + , mOwner(NULL) +#if LUA_BIND_PROFILER + , mSafer(false) +#endif + { + } + + template<class TYPE, class BASE> NativeClass<TYPE, BASE>::NativeClass(LuaBind::VM* vm) : mWatchDog() , mUserdata(vm) @@ -341,6 +363,11 @@ namespace LuaBind { assert(!mUserdata);
+ if (mOwner == NULL)
+ {
+ LateBindVM(state.GetVM());
+ }
+
// userdataջעַҪתΪTYPE*ֱthisܻᵼ¶ؼ̳еɥʧ̬
// ֱӴthisȥڶؼ̳£òһͷ麯ġҪthis
// תΪĵ͵ַõһ麯ͨһʵֶ̬
|