summaryrefslogtreecommitdiff
path: root/Runtime/Lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-11-01 19:30:44 +0800
committerchai <chaifix@163.com>2021-11-01 19:30:44 +0800
commit4b652abe1d76f1bcbe5d7583a8986256f50c483d (patch)
treedaf81888f8e37c40483fcd309201bc33471b97fa /Runtime/Lua
parentb7310c9cce95bfc9bfe135063ee0e97fbc654928 (diff)
-LuaBindClass::RegisterNativeClass
Diffstat (limited to 'Runtime/Lua')
-rw-r--r--Runtime/Lua/LuaBind/LuaBindClass.hpp25
-rw-r--r--Runtime/Lua/LuaBind/LuaBindState.h3
-rw-r--r--Runtime/Lua/LuaBind/LuaBindUtility.h12
3 files changed, 4 insertions, 36 deletions
diff --git a/Runtime/Lua/LuaBind/LuaBindClass.hpp b/Runtime/Lua/LuaBind/LuaBindClass.hpp
index aed4741..dff4d30 100644
--- a/Runtime/Lua/LuaBind/LuaBindClass.hpp
+++ b/Runtime/Lua/LuaBind/LuaBindClass.hpp
@@ -102,7 +102,6 @@ namespace LuaBind
friend class State;
static void RegisterClassShared(State& state);
- static void RegisterNativeClass(State& state);
static void SetClassTableRef(State& state, int idx);
static void PushClassTable(State& state);
@@ -122,7 +121,6 @@ namespace LuaBind
// 工厂类相关
static int __gc (lua_State*);
- static int _GetRefTable (lua_State*);
//--------------------------------------------------------------------------------//
@@ -179,18 +177,6 @@ namespace LuaBind
state.RegisterMethods(regTable);
}
- // 工厂类的成员,注册在class table
- template<class TYPE, class BASE>
- void NativeClass<TYPE, BASE>::RegisterNativeClass(State& state)
- {
- luaL_Reg regTable[] = {
- { "GetRefTable", _GetRefTable },
- { NULL, NULL }
- };
-
- state.RegisterMethods(regTable);
- }
-
template<class TYPE, class BASE>
void NativeClass<TYPE, BASE>::SetClassTableRef(State& state, int idx)
{
@@ -560,17 +546,6 @@ namespace LuaBind
return 1;
}
- template<class TYPE, class BASE>
- int NativeClass<TYPE, BASE>::_GetRefTable(lua_State* L)
- {
- LUA_BIND_STATE(L);
- TYPE* self = state.GetUserdata<TYPE>(1);
- bool success = self->PushRefTable(state);
- if (!success)
- lua_pushnil(L);
- return 1;
- }
-
}
#endif \ No newline at end of file
diff --git a/Runtime/Lua/LuaBind/LuaBindState.h b/Runtime/Lua/LuaBind/LuaBindState.h
index 528c81a..21cde0d 100644
--- a/Runtime/Lua/LuaBind/LuaBindState.h
+++ b/Runtime/Lua/LuaBind/LuaBindState.h
@@ -273,8 +273,7 @@ namespace LuaBind
lua_newtable(L);
int clsIdx = lua_gettop(L);
TYPE::RegisterClassShared(state);
- TYPE::RegisterNativeClass(state);
- TYPE::RegisterClass(state);
+ TYPE::RegisterClass_(state);
// 自定义注册内容
if (onRegisterNativeClass)
diff --git a/Runtime/Lua/LuaBind/LuaBindUtility.h b/Runtime/Lua/LuaBind/LuaBindUtility.h
index b890b57..bf138e4 100644
--- a/Runtime/Lua/LuaBind/LuaBindUtility.h
+++ b/Runtime/Lua/LuaBind/LuaBindUtility.h
@@ -5,19 +5,15 @@
// RegisterClass 注册类的方法和成员,比如枚举、常量等到class table GetNativeClassName 获得工厂的类名,
// 同时用来避免注册时错误注册为了singleton,通过编译时报错避免
+// RegisterClass和win32的宏冲突,所以加个下划线
#define LUA_BIND_DECL_CLASS(type, ...) \
friend class LuaBind::State; \
friend class LuaBind::NativeClass<type,##__VA_ARGS__>; \
- static void RegisterClass(LuaBind::State&); \
+ static void RegisterClass_(LuaBind::State&); \
static void RegisterPostprocess(LuaBind::State&); \
static const char* GetNativeClassName() { return #type; };
//static const char* GetClassName() { return #type; };
-// 作为基类的抽象工厂类可以使用此宏,注册一个入口,在派生类的注册函数中调用,注册基类的这些方法。
-#define LUA_BIND_DECL_ABSTRACT_CLASS() \
- static void RegisterClass(::State&);\
- static void RegisterPostprocess(::State&)
-
#define LUA_BIND_DECL_METHOD(mtd) static int mtd(lua_State* L)
#define LUA_BIND_DECL_ENUM(e, under_line_index)
@@ -26,7 +22,7 @@
#define LUA_BIND_IMPL_METHOD(type, f) int type::f(lua_State* L)
// 由应用程序实现的两个接口。上下文里有一个state。
-#define LUA_BIND_REGISTRY(type) void type::RegisterClass(LuaBind::State& state)
+#define LUA_BIND_REGISTRY(type) void type::RegisterClass_(LuaBind::State& state)
#define LUA_BIND_POSTPROCESS(type) void type::RegisterPostprocess(LuaBind::State& state)
// 用来注册的宏。之前这里忘了用可变宏,导致没有luaclastable ref没有注册对。
@@ -53,8 +49,6 @@
return 0;\
}
-#define LUA_BIND_INHERIT(state, type) type::RegisterClass(state)
-
#define luaxport private
#endif \ No newline at end of file