From 66c5fdc564dd892ed265132d6c1378dbe3cebcee Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 27 Mar 2019 09:07:54 +0800 Subject: *misc --- source/3rd-party/Luax/luax_class.cpp | 14 +++++++------- source/3rd-party/Luax/luax_class.hpp | 7 +++++-- source/3rd-party/Luax/luax_class.inl | 8 ++++---- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'source/3rd-party/Luax') diff --git a/source/3rd-party/Luax/luax_class.cpp b/source/3rd-party/Luax/luax_class.cpp index e2019d4..9f316c1 100644 --- a/source/3rd-party/Luax/luax_class.cpp +++ b/source/3rd-party/Luax/luax_class.cpp @@ -73,7 +73,7 @@ namespace Luax } /// - /// New函数接受n个参数,并尝试获取Ctor,将参数传给Ctor初始化实例。 + /// New函数接受n个参数,并尝试获取__init,将参数传给__init初始化实例。 /// int LuaxPlainClass::l_New(lua_State* L) { @@ -95,11 +95,11 @@ namespace Luax lua_setmetatable(L, -2); // 找到构造函数,会触发metatable.__index,根据继承链向上找。 - lua_getfield(L, classTable, "Ctor"); + lua_getfield(L, classTable, "__init"); if (state.IsType(-1, LUA_TFUNCTION)) { // stack: - // -1: Ctor() + // -1: __init() // -2: instance // -3~-n-2: params @@ -107,27 +107,27 @@ namespace Luax // stack: // -1: instance // -2~-n-1: params - // -n-2: Ctor() + // -n-2: __init() lua_pushvalue(L, -1); // stack: // -1: instance // -2: instance // -3~-n-2: params - // -n-3: Ctor + // -n-3: __init lua_insert(L, -3 - n); // stack: // -1: instance // -2~-n-1: params - // -n-2: Ctor() + // -n-2: __init() // -n-3: instance lua_insert(L, -1 - n); // stack: // -1~-n: params // -n-1: instance - // -n-2: Ctor() + // -n-2: __init() // -n-3: instance lua_pcall(L, n + 1, 0, 0); diff --git a/source/3rd-party/Luax/luax_class.hpp b/source/3rd-party/Luax/luax_class.hpp index 3d7ede6..af52b5f 100644 --- a/source/3rd-party/Luax/luax_class.hpp +++ b/source/3rd-party/Luax/luax_class.hpp @@ -11,8 +11,6 @@ namespace Luax { -#define LUAX_DECL_METHOD(mtd) static int mtd(lua_State* L) - /// /// RegisterLuaxClass 注册类的方法和成员,比如枚举、常量等到class table /// LuaxGetFactoryName 获得工厂的类名,同时用来避免注册时错误注册为了singleton,通过编译时报错避免 @@ -35,6 +33,10 @@ namespace Luax 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) + /// /// 标明方法实现的宏。上下文里有一个L。 /// @@ -106,6 +108,7 @@ namespace Luax /// /// 将userdata push到栈顶,如果没有初始化mUserdata,初始化设置好元表并把初始化好的userdata留在栈顶。并添加一个引用。 + /// 这是一个将native对象所有权移交给lua控制的方法。 /// bool PushLuaxUserdata(LuaxState& state); bool PushLuaxMemberTable(LuaxState& state); diff --git a/source/3rd-party/Luax/luax_class.inl b/source/3rd-party/Luax/luax_class.inl index e2b8de8..7ee3de9 100644 --- a/source/3rd-party/Luax/luax_class.inl +++ b/source/3rd-party/Luax/luax_class.inl @@ -363,8 +363,8 @@ namespace Luax #if LUAX_ENABLE_NATIVE_EXTEND /// - /// 派生出子类,在lua里对派生类的成员和行为进行重新设计,但是保证了userdata的统一。Native class的派生提供Ctor支持,在 - /// native实体创建后可以使用Ctor进行初始化,派生类拥有和基类一样的New参数列表,且native对象是一样的类型。 + /// 派生出子类,在lua里对派生类的成员和行为进行重新设计,但是保证了userdata的统一。Native class的派生提供__init支持,在 + /// native实体创建后可以使用__init进行初始化,派生类拥有和基类一样的New参数列表,且native对象是一样的类型。 /// template int LuaxNativeClass::l_ExtendFactory(lua_State* L) @@ -541,8 +541,8 @@ namespace Luax int args = state.AbsIndex(-1 - n); - // 尝试调用Ctor函数 - lua_getfield(L, lua_upvalueindex(1), "Ctor"); + // 尝试调用__init函数 + lua_getfield(L, lua_upvalueindex(1), "__init"); if (state.IsType(-1, LUA_TFUNCTION)) { -- cgit v1.1-26-g67d0