diff options
Diffstat (limited to 'Source/external/Luax/luax_utility.h')
-rw-r--r-- | Source/external/Luax/luax_utility.h | 66 |
1 files changed, 66 insertions, 0 deletions
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 |