diff options
Diffstat (limited to 'Source/3rdParty/Luax/luax_runtime.h')
-rw-r--r-- | Source/3rdParty/Luax/luax_runtime.h | 64 |
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; + }; } |