diff options
Diffstat (limited to 'Source/3rdParty/Luax/luax_state.h')
-rw-r--r-- | Source/3rdParty/Luax/luax_state.h | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/Source/3rdParty/Luax/luax_state.h b/Source/3rdParty/Luax/luax_state.h index 2b143f8..166ac26 100644 --- a/Source/3rdParty/Luax/luax_state.h +++ b/Source/3rdParty/Luax/luax_state.h @@ -10,6 +10,9 @@ namespace Luax { class Context; + class LuaxEnum; + class LuaxStrongRef; + class LuaxWeakRef; /// /// lua_StateĴ˱һlua_Stateòݡһʵmetatable£ @@ -23,15 +26,15 @@ namespace Luax { public: - operator lua_State*(); - operator bool(); - lua_State* operator ->(); - lua_State& operator *(); + inline lua_State* operator ->() { return mState; }; + inline lua_State& operator *() { return *mState; }; + inline operator lua_State*() { return mState; } + inline operator bool() { return mState != nullptr; }; /// /// ȡlua_State /// - lua_State* GetHandle(); + inline lua_State* GetHandle() { return mState; }; //------------------------------------------------------------------------------------------------------------ @@ -55,7 +58,7 @@ namespace Luax /// /// עCעһ{0 0} /// - void Register(const luaL_Reg *l); + void RegisterMethods(const luaL_Reg *l); void GetField(int idx, cc8* name); void GetField(int idx, int key); @@ -110,11 +113,6 @@ namespace Luax template<typename T> T* GetLuaUserdata(int idx); //------------------------------------------------------------------------------------------------------------ - // õĹregister[LUAX_STRONG_REFTABLE]register[LUAX_WEAK_REFTABLE] - - void Ref(); - - //------------------------------------------------------------------------------------------------------------ template<typename T> T GetValue(int idx, T default_value); template<typename T> T GetField(int idx, int key, T value); @@ -139,6 +137,11 @@ namespace Luax /// template<typename T> void RegisterSingleton(); + /// + /// עö + /// + void RegisterEnum(cc8* name, LuaxEnum* enums); + private: friend class Context; @@ -175,6 +178,17 @@ namespace Luax template <> std::string LuaxState::GetValue < std::string >(int idx, const std::string value); template <> const void* LuaxState::GetValue < const void* >(int idx, const void* value); + /// + /// ڳԱﴴLuaxStateԲм顣 + /// +#define LUAX_SETUP(L, params) \ + LuaxRuntime& runtime = LuaxRuntime::Get(); \ + LuaxState& state = runtime[L].state; \ + if(!state.CheckParams(1, params)) return 0 + +#define LUAX_STATE(L) \ + LuaxState& state = LuaxRuntime::Get().GetLuaxState(L) + } #endif
\ No newline at end of file |