From 1497dccd63a84b7ee2b229b1ad9c5c02718f2a78 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 19 Mar 2019 23:06:27 +0800 Subject: *rename --- source/3rd-party/Luax/luax_runtime.h | 59 ++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 source/3rd-party/Luax/luax_runtime.h (limited to 'source/3rd-party/Luax/luax_runtime.h') 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 + +#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_State并将其从runtime中删除。 + /// + 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 handle到context的映射 + /// + std::map mContexts; + + }; + +#define LUAX_RUNTIME() \ + LuaxRuntime& runtime = LuaxRuntime::Get() + +} + +#endif \ No newline at end of file -- cgit v1.1-26-g67d0