From 7c8c68d79343d04be382334c15a73d079450857c Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 17 Oct 2021 23:05:01 +0800 Subject: *misc --- Runtime/Scripting/LuaBindVM.cpp | 76 ----------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 Runtime/Scripting/LuaBindVM.cpp (limited to 'Runtime/Scripting/LuaBindVM.cpp') diff --git a/Runtime/Scripting/LuaBindVM.cpp b/Runtime/Scripting/LuaBindVM.cpp deleted file mode 100644 index 4677650..0000000 --- a/Runtime/Scripting/LuaBindVM.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "LuaBindInternal.h" -#include "LuaBindVM.h" - -namespace LuaBind -{ - - VM::VMap VM::VMs; // 通过线程查找虚拟机,为了方便 - - VM* VM::TryGetVM(global_State* gState) - { - auto it = VMs.find(gState); - if (it != VMs.end()) - return it->second; - else - return nullptr; - } - - VM* VM::TryGetVM(lua_State* state) - { - return TryGetVM(G(state)); - } - - VM::VM() - : mStrongRefTable() - , mWeakRefTable() - { - mMainThread = luaL_newstate(); - assert(mMainThread); - mGlobalState = G(mMainThread); - - VMs.insert(std::pair(mGlobalState, this)); - } - - VM::~VM() - { - VMs.erase(mGlobalState); - lua_close(mMainThread); - } - - // 初始化context - void VM::Setup() - { - LUA_BIND_STATE(mMainThread); - - mStrongRefTable.Init(state, "UNIVERSAL_STRONGREF_TABLE"); - mWeakRefTable.Init(state, "UNIVERSAL_WEAKREF_TABLE", "v"); - } - - lua_State* VM::CreateThread() - { - lua_State* thread = lua_newthread(mMainThread); - assert(thread); - return thread; - } - - lua_State* VM::GetMainThread() - { - return mMainThread; - } - - State VM::GetMainState() - { - return mMainThread; - } - - RefTable& VM::GetStrongRefTable() - { - return mStrongRefTable; - } - - RefTable& VM::GetWeakRefTable() - { - return mWeakRefTable; - } - -} \ No newline at end of file -- cgit v1.1-26-g67d0