summaryrefslogtreecommitdiff
path: root/Source/3rdParty/Luax/luax_runtime.h
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2019-03-12 23:08:31 +0800
committerchai <chaifix@163.com>2019-03-12 23:08:31 +0800
commit6016ece202eef94ed76bd20d4f7879ccc71cc2e6 (patch)
treeda0d0be011ee24489174bde1ec1c436ce7aaa1b2 /Source/3rdParty/Luax/luax_runtime.h
parent9eba034f5c2ffd49f33d38c283b24230f9e362e0 (diff)
*luax
Diffstat (limited to 'Source/3rdParty/Luax/luax_runtime.h')
-rw-r--r--Source/3rdParty/Luax/luax_runtime.h64
1 files changed, 60 insertions, 4 deletions
diff --git a/Source/3rdParty/Luax/luax_runtime.h b/Source/3rdParty/Luax/luax_runtime.h
index 94d8ecc..2414c2e 100644
--- a/Source/3rdParty/Luax/luax_runtime.h
+++ b/Source/3rdParty/Luax/luax_runtime.h
@@ -1,13 +1,69 @@
#ifndef __LUAX_RUNTIME_H__
#define __LUAX_RUNTIME_H__
-namespace Luax
+#include <map>
+
+#include "luax_config.h"
+#include "luax_state.h"
+
+namespace Luax
{
- enum RegisterIndex
+ ///
+ /// lua_stateصcontextһϵдļϣҲûϵҪΪ˽Լڴ档
+ ///
+ class Context
{
- LUAX_OBJECT_INDEX = 1,
- LUAX_OBJECT_MODULE = 2,
+ public:
+ Context(lua_State* L);
+ ~Context();
+
+ LuaxState state; // lua state
+ LuaxRefTable strongRefTable; // strong ref table
+ LuaxRefTable weakRefTable; // weak ref table
+
+ size_t objectCount; // ͳڴstateдʵ
+
+ };
+
+ ///
+ /// ͳһеlua states
+ ///
+ class LuaxRuntime
+ {
+ public:
+
+ static LuaxRuntime& Get();
+
+ ///
+ /// һµlua_Stateصlua_State*һ8\4ֽڵkey
+ ///
+ lua_State* Open();
+
+ ///
+ /// رlua_Stateruntimeɾ
+ ///
+ void Close(lua_State* L);
+
+ bool HasLuaxState(lua_State* L);
+ LuaxState& GetLuaxState(lua_State* L);
+ LuaxRefTable& GetStrongRefTable(lua_State* L);
+ LuaxRefTable& GetWeaksRefTable(lua_State* L);
+
+ Context& operator[](lua_State* L);
+
+ private:
+
+ LuaxRuntime();
+ ~LuaxRuntime();
+
+ static LuaxRuntime* mRuntime;
+
+ ///
+ /// lua_stateҵcontext
+ ///
+ std::map<lua_State*, Context> mContexts;
+
};
}