summaryrefslogtreecommitdiff
path: root/Runtime/Scripting/LuaBindVM.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-17 23:05:01 +0800
committerchai <chaifix@163.com>2021-10-17 23:05:01 +0800
commit7c8c68d79343d04be382334c15a73d079450857c (patch)
tree9aaacc042f0b7eeb4123c07dcc5f49c14fd8026c /Runtime/Scripting/LuaBindVM.cpp
parent6e73ca6ada8a41692809dae5db89c8db0675ce1e (diff)
*misc
Diffstat (limited to 'Runtime/Scripting/LuaBindVM.cpp')
-rw-r--r--Runtime/Scripting/LuaBindVM.cpp76
1 files changed, 0 insertions, 76 deletions
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<global_State*, VM*>(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