From 64f89347883d519b202711a11d2ea175bd80be37 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 15 Nov 2020 09:59:22 +0800 Subject: +lua binding --- Runtime/Scripting/luax_vm.cpp | 76 ------------------------------------------- 1 file changed, 76 deletions(-) delete mode 100644 Runtime/Scripting/luax_vm.cpp (limited to 'Runtime/Scripting/luax_vm.cpp') diff --git a/Runtime/Scripting/luax_vm.cpp b/Runtime/Scripting/luax_vm.cpp deleted file mode 100644 index 4dc7e0c..0000000 --- a/Runtime/Scripting/luax_vm.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "luax_internal.h" -#include "luax_vm.h" - -namespace Luax -{ - - LuaxVM::VMap LuaxVM::VMs; // 通过线程查找虚拟机,为了方便 - - LuaxVM* LuaxVM::TryGetVM(global_State* gState) - { - auto it = VMs.find(gState); - if (it != VMs.end()) - return it->second; - else - return nullptr; - } - - LuaxVM* LuaxVM::TryGetVM(lua_State* state) - { - return TryGetVM(G(state)); - } - - LuaxVM::LuaxVM() - : mStrongRefTable() - , mWeakRefTable() - { - mMainThread = luaL_newstate(); - assert(mMainThread); - mGlobalState = G(mMainThread); - - VMs.insert(std::pair(mGlobalState, this)); - } - - LuaxVM::~LuaxVM() - { - VMs.erase(mGlobalState); - lua_close(mMainThread); - } - - // 初始化context - void LuaxVM::Setup() - { - LUAX_STATE(mMainThread); - - mStrongRefTable.Init(state, "_LUAX_STRONGREF_TABLE"); - mWeakRefTable.Init(state, "_LUAX_WEAKREF_TABLE", "v"); - } - - lua_State* LuaxVM::CreateThread() - { - lua_State* thread = lua_newthread(mMainThread); - assert(thread); - return thread; - } - - lua_State* LuaxVM::GetMainThread() - { - return mMainThread; - } - - LuaxState LuaxVM::GetMainState() - { - return mMainThread; - } - - LuaxRefTable& LuaxVM::GetStrongRefTable() - { - return mStrongRefTable; - } - - LuaxRefTable& LuaxVM::GetWeakRefTable() - { - return mWeakRefTable; - } - -} \ No newline at end of file -- cgit v1.1-26-g67d0