From 82956beb1fe17e1226327638c8ab22b5f5adfc1d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 20 Mar 2019 22:43:25 +0800 Subject: *misc --- source/3rd-party/Luax/luax_class.hpp | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'source/3rd-party/Luax/luax_class.hpp') diff --git a/source/3rd-party/Luax/luax_class.hpp b/source/3rd-party/Luax/luax_class.hpp index ea1fab9..539ff1a 100644 --- a/source/3rd-party/Luax/luax_class.hpp +++ b/source/3rd-party/Luax/luax_class.hpp @@ -35,15 +35,32 @@ namespace Luax static const char* GetLuaxClassName() { return #type; }; \ static bool IsLuaxClassSingleton() { return true; }; + /// + /// 标明方法实现的宏。上下文里有一个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) -#define LUAX_REGISTER_FACTORY(stt, type) stt.RegisterFactory() - -#define LUAX_REGISTER_SINGLETON(stt, type) stt.RegisterSingleton() + /// + /// 用来注册的宏。 + /// +#define LUAX_REGISTER_FACTORY(state, type) state.RegisterFactory() +#define LUAX_REGISTER_SINGLETON(state, type) state.RegisterSingleton() +#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) /// /// 需要暴露给lua的native class需要继承此类。通过lua管理的实例要确保引用计数的正确性,在多个线程中需要确定不会误释放。 -- cgit v1.1-26-g67d0