diff options
Diffstat (limited to 'Runtime/Lua/LuaBind/LuaBindVM.h')
-rw-r--r-- | Runtime/Lua/LuaBind/LuaBindVM.h | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindVM.h b/Runtime/Lua/LuaBind/LuaBindVM.h index 3bfe899..37810b9 100644 --- a/Runtime/Lua/LuaBind/LuaBindVM.h +++ b/Runtime/Lua/LuaBind/LuaBindVM.h @@ -3,6 +3,7 @@ #include <map> #include <unordered_set> +#include <unordered_map> #include "LuaBindRef.h" #include "LuaBindConfig.h" @@ -32,20 +33,22 @@ namespace LuaBind lua_State* CreateThread(); State GetMainState(); - RefTable& GetStrongRefTable(); + RefTable& GetStrongRefTable(); RefTable& GetWeakRefTable(); - private: + int RegisterClassI(State& state, int classID, int index); + void PushClassTable(State& state, int classID); - typedef std::map<global_State*, VM*> VMap; + private: + static std::map<global_State*, VM*> VMs; // 通过global_State索引虚拟机,为了方便 - static VMap VMs; // 通过global_State索引虚拟机,为了方便 + global_State* mGlobalState; // 虚拟机的global_State,由当前虚拟机的所有线程共享,保存注册表、管理GC + lua_State* mMainThread; // 主线程 - RefTable mStrongRefTable; // GAMELAB_UNIVERSAL_STRONG_REFERENCE_TABLE - RefTable mWeakRefTable; // GAMELAB_UNIVERSAL_WEAK_REFERENCE_TABLE + RefTable mStrongRefTable; // 全局强引用表 + RefTable mWeakRefTable; // 全局弱引用表 - global_State* mGlobalState; // 虚拟机的global_State,由当前虚拟机的所有线程共享 - lua_State* mMainThread; // 主线程 + std::unordered_map<int/*ClassID*/, StrongRef> mClasses; // 类型 #if LUA_BIND_PROFILER size_t mObjectCount; // 统计所有在此虚拟机中创建的实例 |