From f4c338c63f3456a8eccd56c35e233843687d55be Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 29 Mar 2019 00:43:25 +0800 Subject: *thread --- source/3rd-party/Luax/luax_state.h | 71 +++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 35 deletions(-) (limited to 'source/3rd-party/Luax/luax_state.h') diff --git a/source/3rd-party/Luax/luax_state.h b/source/3rd-party/Luax/luax_state.h index e9c394a..b6d1ff0 100644 --- a/source/3rd-party/Luax/luax_state.h +++ b/source/3rd-party/Luax/luax_state.h @@ -9,7 +9,7 @@ namespace Luax { - class LuaxContext; + class LuaxVM; class LuaxEnum; class LuaxStrongRef; class LuaxWeakRef; @@ -20,7 +20,8 @@ namespace Luax /// member table /// ref table /// userdata - /// 从userdata通过getmetatable获取上级metatable。除此之外还有一个class table注册在对应的名称空间里。 + /// 从userdata通过getmetatable获取上级metatable。除此之外还有一个class table注册在对应 + /// 的名称空间里。 /// LUAX_API class LuaxState { @@ -36,11 +37,11 @@ namespace Luax /// inline lua_State* GetHandle() { return mState; }; - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// void OpenLibs(); - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// // 名称空间管理,名称空间就是一个表,_G是最上面的表 void PushGlobalNamespace(); @@ -48,7 +49,7 @@ namespace Luax void PopNamespace(); bool IsNamespace(int idx); - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// void SetTop(int top); int GetTop(); @@ -56,7 +57,7 @@ namespace Luax int AbsIndex(int idx); void Call(int nArgs, int nResults); - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// void GetField(int idx, cc8* name); void GetField(int idx, int key); @@ -117,11 +118,11 @@ namespace Luax template T* GetUserdata(int idx = 1); - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// int ErrorType(int idx, cc8* hint); - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// template T GetValue(int idx, T default_value); template T GetField(int idx, int key, T value); @@ -130,14 +131,14 @@ namespace Luax template void SetFieldByIndex(int idx, int key, T value); template T* CheckUserdata(int idx); - template T CheckParam(int idx); + template T CheckValue(int idx); - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// void DoString(const std::string& code); void DoFile(const std::string& file); - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// // 注册方法 /// @@ -166,9 +167,9 @@ namespace Luax void RegisterMethod(cc8* fname, lua_CFunction func); /// - /// 把preloader加到package.preload里,当require"libname"时lua的loader_preload根据libname找到preloader直接加载。 - /// 用来实现需要require的时候才加载,并且加载过一次后package.loaded记录下来,下次不会再加载。通过require会调用这个 - /// preloader。 + /// 把preloader加到package.preload里,当require"libname"时lua的loader_preload根据 + /// libname找到preloader直接加载。用来实现需要require的时候才加载,并且加载过一次后 + /// package.loaded记录下来,下次不会再加载。通过require会调用这个preloader。 /// void RegisterPreloader(cc8* libname, lua_CFunction preloader); @@ -191,11 +192,11 @@ namespace Luax void RegisterPlainEnumRegistry(cc8* name); #endif - //------------------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------// protected: - friend class LuaxContext; + friend class LuaxVM; LuaxState(lua_State* state); LuaxState(const LuaxState& state); @@ -211,7 +212,7 @@ namespace Luax }; - //-------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------// // GetValue()模板特化 template <> bool LuaxState::GetValue < bool >(int idx, const bool value); @@ -229,23 +230,23 @@ 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); - //-------------------------------------------------------------------------------------------------------------- - // CheckParam模板特化 - - template <> bool LuaxState::CheckParam < bool >(int idx); - template <> cc8* LuaxState::CheckParam < cc8* >(int idx); - template <> double LuaxState::CheckParam < double >(int idx); - template <> float LuaxState::CheckParam < float >(int idx); - template <> s8 LuaxState::CheckParam < s8 >(int idx); - template <> s16 LuaxState::CheckParam < s16 >(int idx); - template <> s32 LuaxState::CheckParam < s32 >(int idx); - template <> s64 LuaxState::CheckParam < s64 >(int idx); - template <> u8 LuaxState::CheckParam < u8 >(int idx); - template <> u16 LuaxState::CheckParam < u16 >(int idx); - template <> u32 LuaxState::CheckParam < u32 >(int idx); - template <> u64 LuaxState::CheckParam < u64 >(int idx); - template <> std::string LuaxState::CheckParam < std::string >(int idx); - template <> const void* LuaxState::CheckParam < const void* >(int idx); + //--------------------------------------------------------------------------------// + // CheckValue模板特化 + + template <> bool LuaxState::CheckValue < bool >(int idx); + template <> cc8* LuaxState::CheckValue < cc8* >(int idx); + template <> double LuaxState::CheckValue < double >(int idx); + template <> float LuaxState::CheckValue < float >(int idx); + template <> s8 LuaxState::CheckValue < s8 >(int idx); + template <> s16 LuaxState::CheckValue < s16 >(int idx); + template <> s32 LuaxState::CheckValue < s32 >(int idx); + template <> s64 LuaxState::CheckValue < s64 >(int idx); + template <> u8 LuaxState::CheckValue < u8 >(int idx); + template <> u16 LuaxState::CheckValue < u16 >(int idx); + template <> u32 LuaxState::CheckValue < u32 >(int idx); + template <> u64 LuaxState::CheckValue < u64 >(int idx); + template <> std::string LuaxState::CheckValue < std::string >(int idx); + template <> const void* LuaxState::CheckValue < const void* >(int idx); /// /// 在成员方法里创建LuaxState并对参数进行检查。 @@ -258,7 +259,7 @@ namespace Luax #define LUAX_STATE(L) \ Luax::LuaxState& state = Luax::LuaxRuntime::Get().GetLuaxState(L) - //-------------------------------------------------------------------------------------------------------------- + //--------------------------------------------------------------------------------// /// /// 确保不安全的lua调用能够在调用之后返回到最初stack状态。 -- cgit v1.1-26-g67d0