summaryrefslogtreecommitdiff
path: root/source/3rd-party/Luax/luax_runtime.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/3rd-party/Luax/luax_runtime.h')
-rw-r--r--source/3rd-party/Luax/luax_runtime.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/source/3rd-party/Luax/luax_runtime.h b/source/3rd-party/Luax/luax_runtime.h
new file mode 100644
index 0000000..1234627
--- /dev/null
+++ b/source/3rd-party/Luax/luax_runtime.h
@@ -0,0 +1,59 @@
+#ifndef __LUAX_RUNTIME_H__
+#define __LUAX_RUNTIME_H__
+
+#include <map>
+
+#include "luax_ref.h"
+#include "luax_config.h"
+#include "luax_state.h"
+#include "luax_context.h"
+
+namespace Luax
+{
+
+ ///
+ /// ͳһе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);
+
+ LuaxContext& operator[](lua_State* L);
+
+ private:
+
+ LuaxRuntime();
+ ~LuaxRuntime();
+
+ static LuaxRuntime* mRuntime;
+
+ ///
+ /// lua_State handlecontextӳ
+ ///
+ std::map<lua_State*, LuaxContext> mContexts;
+
+ };
+
+#define LUAX_RUNTIME() \
+ LuaxRuntime& runtime = LuaxRuntime::Get()
+
+}
+
+#endif \ No newline at end of file