diff options
Diffstat (limited to 'Source/3rdParty/Luax/luax_state.h')
-rw-r--r-- | Source/3rdParty/Luax/luax_state.h | 236 |
1 files changed, 0 insertions, 236 deletions
diff --git a/Source/3rdParty/Luax/luax_state.h b/Source/3rdParty/Luax/luax_state.h deleted file mode 100644 index 8c5b8d6..0000000 --- a/Source/3rdParty/Luax/luax_state.h +++ /dev/null @@ -1,236 +0,0 @@ -#ifndef __LUAX_STATE_H__ -#define __LUAX_STATE_H__ - -#include <string> - -#include "luax_config.h" -#include "luax_reftable.h" - -namespace Luax -{ - - class LuaxContext; - class LuaxEnum; - class LuaxStrongRef; - class LuaxWeakRef; - - /// - /// lua_StateĴ˱һlua_Stateòݡһʵmetatable£ - /// class table - /// member table - /// ref table - /// userdata - /// userdataͨgetmetatableȡϼmetatable֮һclass tableעڶӦƿռ - /// - LUAX_API class LuaxState - { - public: - - 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 - /// - inline lua_State* GetHandle() { return mState; }; - - //------------------------------------------------------------------------------------------------------------ - - void OpenLibs(); - - //------------------------------------------------------------------------------------------------------------ - // ƿռƿռһ_Gı - - void PushGlobalNamespace(); - void PushNamespace(cc8* name); - void PopNamespace(); - bool IsNamespace(int idx); - - //------------------------------------------------------------------------------------------------------------ - - void SetTop(int top); - int GetTop(); - bool CheckParams(int idx, cc8* format); - int AbsIndex(int idx); - void Call(int nArgs, int nResults); - - //------------------------------------------------------------------------------------------------------------ - - void GetField(int idx, cc8* name); - void GetField(int idx, int key); - std::string GetField(int idx, cc8* key, cc8* value); - std::string GetField(int idx, int key, cc8* value); - std::string GetField(int idx, cc8* key, const std::string& value); - std::string GetField(int idx, int key, const std::string& value); - bool GetFieldWithType(int idx, cc8* name, int type); - bool GetFieldWithType(int idx, int key, int type); - bool GetSubfieldWithType(int idx, cc8* format, int type, ...); - static cc8* GetLuaTypeName(int type); - - void SetField(int idx, cc8* key); - - bool IsNil(int idx); - bool IsNilOrNone(int idx); - bool IsTableOrUserdata(int idx); - bool IsTrueOrNotNil(int idx); - bool IsType(int idx, int type); - bool IsType(int idx, cc8* name, int type); - bool IsValid(); - - bool HasField(int idx, cc8* name); - bool HasField(int idx, int key); - bool HasField(int idx, cc8* name, int type); - bool HasField(int idx, int name, int type); - bool HasKeys(int idx); - - void PushNil(); - void Push(bool value); - void Push(cc8* value); - void Push(double value); - void Push(float value); - void Push(int value); - void Push(u16 value); - void Push(u32 value); - void Push(u64 value); - void Push(uintptr value); - void Push(lua_CFunction value); - void Push(void* data, size_t size); - void Push(const void* value); - - /// - /// idxʼnpushջidxᱻȡn - /// - void PushValues(int idx, int n); - - /// - /// void** ʽuserdataֵΪptr - /// - void PushPtrUserData(void* ptr); - - void Pop(int n = 1); - - void Settop(int idx); - - template<typename T> T* GetLuaUserdata(int idx = 1); - - //------------------------------------------------------------------------------------------------------------ - - template<typename T> T GetValue(int idx, T default_value); - template<typename T> T GetField(int idx, int key, T value); - template<typename T> T GetField(int idx, cc8* key, T value); - template<typename T> void SetField(int idx, cc8* key, T value); - template<typename T> void SetFieldByIndex(int idx, int key, T value); - - //------------------------------------------------------------------------------------------------------------ - - void DoString(const std::string& code); - void DoFile(const std::string& file); - - //------------------------------------------------------------------------------------------------------------ - // ע᷽ - - /// - /// עṤͨ࣬New - /// - template<typename T> void RegisterFactory(); - - /// - /// עᵥûNew - /// - template<typename T> void RegisterSingleton(); - - /// - /// עö - /// - void RegisterEnum(cc8* name, LuaxEnum* enums); - - /// - /// עCעһ{0 0} - /// - void RegisterMethods(const luaL_Reg *l); - - /// - /// עᵥC - /// - void RegisterMethod(cc8* fname, lua_CFunction func); - - /// - /// preloaderӵpackage.preloadrequire"libname"ʱlualoader_preloadlibnameҵpreloaderֱӼء - /// ʵҪrequireʱżأҼعһκpackage.loaded¼´βټءͨrequire - /// preloader - /// - void RegisterPreloader(cc8* libname, lua_CFunction preloader); - - /// - /// luaL_Reglib table_Gpackage.loadedlibnameָlib table - /// - void RegisterLib(cc8* libname, const luaL_Reg* l); - -#ifdef LUAX_ENABLE_PLAIN_CLASS - /// - /// עᴿluaעắluaࡣ - /// - void RegisterPlainClassRegistry(cc8* name); -#endif - -#ifdef LUAX_ENABLE_PLAIN_ENABLE - /// - /// עᴿluaö٣Էֹöֵ - /// - void RegisterPlainEnumRegistry(cc8* name); -#endif - - //------------------------------------------------------------------------------------------------------------ - - private: - - friend class LuaxContext; - - LuaxState(lua_State* state); - LuaxState(const LuaxState& state); - ~LuaxState(); - - /// - /// ζLuaxStateĵַز - /// - void* operator &(); - void* operator new(size_t size); - - lua_State* const mState; - - }; - - //-------------------------------------------------------------------------------------------------------------- - // GetValue()ģػ - - template <> bool LuaxState::GetValue < bool >(int idx, const bool value); - template <> cc8* LuaxState::GetValue < cc8* >(int idx, const cc8* value); - template <> double LuaxState::GetValue < double >(int idx, const double value); - template <> float LuaxState::GetValue < float >(int idx, const float value); - template <> s8 LuaxState::GetValue < s8 >(int idx, const s8 value); - template <> s16 LuaxState::GetValue < s16 >(int idx, const s16 value); - template <> s32 LuaxState::GetValue < s32 >(int idx, const s32 value); - template <> s64 LuaxState::GetValue < s64 >(int idx, const s64 value); - template <> u8 LuaxState::GetValue < u8 >(int idx, const u8 value); - template <> u16 LuaxState::GetValue < u16 >(int idx, const u16 value); - template <> u32 LuaxState::GetValue < u32 >(int idx, const u32 value); - template <> u64 LuaxState::GetValue < u64 >(int idx, const u64 value); - 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 |