diff options
Diffstat (limited to 'source/external')
-rw-r--r-- | source/external/Luax/luax_class.hpp | 79 | ||||
-rw-r--r-- | source/external/Luax/luax_utility.h | 66 |
2 files changed, 67 insertions, 78 deletions
diff --git a/source/external/Luax/luax_class.hpp b/source/external/Luax/luax_class.hpp index fd9f75a..12eb268 100644 --- a/source/external/Luax/luax_class.hpp +++ b/source/external/Luax/luax_class.hpp @@ -13,88 +13,13 @@ #include "luax_memberref.h" #include "luax_cfunctions.h" #include "luax_watchdog.h" +#include "luax_utility.h" namespace Luax { class LuaxVM; -/// -/// RegisterLuaxClass עķͳԱö١ȵclass table -/// LuaxGetFactoryName ùͬʱעʱעΪsingletonͨ -/// ʱ -/// -#define LUAX_DECL_FACTORY(type, ...) \ - friend class Luax::LuaxState; \ - friend class Luax::LuaxNativeClass<type,##__VA_ARGS__>; \ - static void RegisterLuaxClass(Luax::LuaxState&); \ - static void RegisterLuaxPostprocess(Luax::LuaxState&); \ - static const char* GetLuaxFactoryName() { return #type; };\ - static const char* GetLuaxClassName() { return #type; };\ - static bool IsLuaxClassSingleton() { return false; } - -/// -/// Ϊijʹô˺꣬עһڣעắеãעЩ -/// -/// -#define LUAX_DECL_ABSTRACT_FACTORY() \ - static void RegisterLuaxClass(Luax::LuaxState&);\ - static void RegisterLuaxPostprocess(Luax::LuaxState&) - -/// -/// RegisterLuaxClass עķͳԱö١ȵclass table -/// LuaxGetSingletonName õ -/// -#define LUAX_DECL_SINGLETON(type, ...) \ - friend class Luax::LuaxState; \ - friend class Luax::LuaxNativeClass<type,##__VA_ARGS__>; \ - static void RegisterLuaxClass(Luax::LuaxState&); \ - static void RegisterLuaxPostprocess(Luax::LuaxState&); \ - static const char* GetLuaxSingletonName() { return #type; }; \ - static const char* GetLuaxClassName() { return #type; }; \ - static bool IsLuaxClassSingleton() { return true; } - -#define LUAX_DECL_METHOD(mtd) static int mtd(lua_State* L) - -#define LUAX_DECL_ENUM(e, under_line_index) - -/// -/// ʵֵĺꡣһL -/// -#define LUAX_IMPL_METHOD(type, f) int type::f(lua_State* L) - -/// -/// Ӧóʵֵӿڡһstate -/// -#define LUAX_REGISTRY(type) void type::RegisterLuaxClass(Luax::LuaxState& state) -#define LUAX_POSTPROCESS(type) void type::RegisterLuaxPostprocess(Luax::LuaxState& state) - -/// -/// עĺꡣ֮ǰÿɱ꣬ûluaclastable refûעԡ -/// -#define LUAX_REGISTER_FACTORY(state, param) state.RegisterFactory<param>() -#define LUAX_REGISTER_SINGLETON(state, param) state.RegisterSingleton<param>() -#define LUAX_REGISTER_ABSTRACT_FACTORY(state, type) type::RegisterLuaxPostprocess(state) -#define LUAX_REGISTER_METHODS(state, ...) \ - do{ \ - luaL_Reg __m[] = {__VA_ARGS__,{0, 0}}; \ - state.RegisterMethods(__m); \ - }while(0) -#define LUAX_REGISTER_ENUM(state, name, ...) \ - do{ \ - Luax::LuaxEnum __e[] = {__VA_ARGS__,{0, 0}}; \ - state.RegisterEnum(name, __e); \ - }while(0) - -#define LUAX_PREPARE(L, T) \ - LUAX_STATE(L); \ - T* self = state.GetUserdata<T>(1); - -#define LUAX_INHERIT(state, type) type::RegisterLuaxClass(state) - -#define luaxport private - - /// /// ࣬Ϊʵֶ̬ҪЩӿڵⲿҪ̳д֮࣬оͻ /// öӦʵķע̳дʱʵķʵLuaxNativeClassУʵֻ @@ -244,9 +169,7 @@ namespace Luax /// LuaxWeakRef mUserdata; - /// /// ͨɾ - /// LuaxWatchDog mWatchDog; #if LUAX_PROFILER diff --git a/source/external/Luax/luax_utility.h b/source/external/Luax/luax_utility.h new file mode 100644 index 0000000..79601e0 --- /dev/null +++ b/source/external/Luax/luax_utility.h @@ -0,0 +1,66 @@ +#ifndef __LUAX_UTILITY_H__ +#define __LUAX_UTILITY_H__ + +// nativeӿ + +/// RegisterLuaxClass עķͳԱö١ȵclass table LuaxGetFactoryName ù +/// ͬʱעʱעΪsingletonͨʱ +#define LUAX_DECL_FACTORY(type, ...) \ + friend class Luax::LuaxState; \ + friend class Luax::LuaxNativeClass<type,##__VA_ARGS__>; \ + static void RegisterLuaxClass(Luax::LuaxState&); \ + static void RegisterLuaxPostprocess(Luax::LuaxState&); \ + static const char* GetLuaxFactoryName() { return #type; };\ + static const char* GetLuaxClassName() { return #type; };\ + static bool IsLuaxClassSingleton() { return false; } + +/// Ϊijʹô˺꣬עһڣעắеãעЩ +#define LUAX_DECL_ABSTRACT_FACTORY() \ + static void RegisterLuaxClass(Luax::LuaxState&);\ + static void RegisterLuaxPostprocess(Luax::LuaxState&) + +/// RegisterLuaxClass עķͳԱö١ȵclass table LuaxGetSingletonName õ +#define LUAX_DECL_SINGLETON(type, ...) \ + friend class Luax::LuaxState; \ + friend class Luax::LuaxNativeClass<type,##__VA_ARGS__>; \ + static void RegisterLuaxClass(Luax::LuaxState&); \ + static void RegisterLuaxPostprocess(Luax::LuaxState&); \ + static const char* GetLuaxSingletonName() { return #type; }; \ + static const char* GetLuaxClassName() { return #type; }; \ + static bool IsLuaxClassSingleton() { return true; } + +#define LUAX_DECL_METHOD(mtd) static int mtd(lua_State* L) + +#define LUAX_DECL_ENUM(e, under_line_index) + +/// ʵֵĺꡣһL +#define LUAX_IMPL_METHOD(type, f) int type::f(lua_State* L) + +/// Ӧóʵֵӿڡһstate +#define LUAX_REGISTRY(type) void type::RegisterLuaxClass(Luax::LuaxState& state) +#define LUAX_POSTPROCESS(type) void type::RegisterLuaxPostprocess(Luax::LuaxState& state) + +/// עĺꡣ֮ǰÿɱ꣬ûluaclastable refûעԡ +#define LUAX_REGISTER_FACTORY(state, param) state.RegisterFactory<param>() +#define LUAX_REGISTER_SINGLETON(state, param) state.RegisterSingleton<param>() +#define LUAX_REGISTER_ABSTRACT_FACTORY(state, type) type::RegisterLuaxPostprocess(state) +#define LUAX_REGISTER_METHODS(state, ...) \ + do{ \ + luaL_Reg __m[] = {__VA_ARGS__,{0, 0}}; \ + state.RegisterMethods(__m); \ + }while(0) +#define LUAX_REGISTER_ENUM(state, name, ...) \ + do{ \ + Luax::LuaxEnum __e[] = {__VA_ARGS__,{0, 0}}; \ + state.RegisterEnum(name, __e); \ + }while(0) + +#define LUAX_PREPARE(L, T) \ + LUAX_STATE(L); \ + T* self = state.GetUserdata<T>(1); + +#define LUAX_INHERIT(state, type) type::RegisterLuaxClass(state) + +#define luaxport private + +#endif
\ No newline at end of file |