From ad2805aa839892589c13a615730da52f6e474709 Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 17 Mar 2019 10:49:50 +0800 Subject: *luax --- Source/3rdParty/Luax/luax_class.hpp | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) (limited to 'Source/3rdParty/Luax/luax_class.hpp') diff --git a/Source/3rdParty/Luax/luax_class.hpp b/Source/3rdParty/Luax/luax_class.hpp index 539093c..6557c0b 100644 --- a/Source/3rdParty/Luax/luax_class.hpp +++ b/Source/3rdParty/Luax/luax_class.hpp @@ -14,12 +14,10 @@ namespace Luax /// /// RegisterLuaxClass 注册类的方法和成员,比如枚举、常量等到class table - /// LuaxRegisterInterface 注册接口方法到interface table /// LuaxGetFactoryName 获得工厂的类名,同时用来避免注册时错误注册为了singleton,通过编译时报错避免 /// #define LUAX_DECL_FACTORY(type) \ static void RegisterLuaxClass(Luax::LuaxState&);\ - static void RegisterLuaxInterface(Luax::LuaxState&);\ static void RegisterLuaxPostprocess(Luax::LuaxState&); \ static const char* GetLuaxFactoryName() { return #type; };\ static const char* GetLuaxClassName() { return #type; };\ @@ -37,7 +35,7 @@ namespace Luax static bool IsLuaxClassSingleton() { return true; }; /// - /// 需要暴露给lua的class需要继承此类。通过lua管理的实例要确保引用计数的正确性,在多个线程中需要确定不会误释放。 + /// 需要暴露给lua的native class需要继承此类。通过lua管理的实例要确保引用计数的正确性,在多个线程中需要确定不会误释放。 /// template class LuaxClass @@ -81,12 +79,8 @@ namespace Luax static void RegisterLuaxFactoryClass(LuaxState& state); static void RegisterLuaxSingletonClass(LuaxState& state); - static void RegisterLuaxInterface(LuaxState& state); - - static void SetLuaxInterfaceTableRef(LuaxState& state, int idx); static void SetLuaxClassTableRef(LuaxState& state, int idx); - static void PushLuaxInterfaceTable(LuaxState& state); static void PushLuaxClassTable(LuaxState& state); /// @@ -106,7 +100,6 @@ namespace Luax /// 所有LuaxClass类型的实例共享的内容 /// static LuaxStrongRef mClassTable; // class table,工厂和单例都有 - static LuaxStrongRef mInterfaceTable; // 如果类是工厂,interface table用来保存类实例化的对象的共有方法 static LuaxStrongRef mSingletonRefTable; // 如果类是单例,这个用来保存singleton的成员,以保证不会被回收类似普通类的 // ref table。单例的成员是全生命周期的,所以直接在_LUAX_STRONGREF_TABLE @@ -114,7 +107,7 @@ namespace Luax /// 通过userdata可以拿到: /// 1: ref table /// 2: member table - /// 3: interface table + /// 3: class table /// LuaxWeakRef mUserdata; @@ -132,7 +125,6 @@ namespace Luax LUAX_DECL_METHOD( l___gc ); LUAX_DECL_METHOD( l_ExtendFactory ); LUAX_DECL_METHOD( l_GetClass ); - LUAX_DECL_METHOD( l_GetInterfaceTable ); LUAX_DECL_METHOD( l_GetRefTable ); //------------------------------------------------------------------------------------------------------------ @@ -142,6 +134,25 @@ namespace Luax }; + //-------------------------------------------------------------------------------------------------------------- + + /// + /// 纯lua类 + /// + class LuaxPlainClass + { + public: + + /// + /// 用来注册类的入口函数。可以通过registry(类名)注册类。 + /// + static int registry(lua_State* L); + + LUAX_DECL_METHOD( l_Extend ); + LUAX_DECL_METHOD( l_New ); + + }; + } #endif \ No newline at end of file -- cgit v1.1-26-g67d0