1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#ifndef __LUA_BIND_UTILITY_H__
#define __LUA_BIND_UTILITY_H__
// ����native�ӿ�
// RegisterNativeClass ע����ķ����ͳ�Ա������ö�١������ȵ�class table GetNativeClassName ��ù�����������
// ͬʱ��������ע��ʱ����ע��Ϊ��singleton��ͨ������ʱ��������
#define LUA_BIND_DECL_CLASS(type, ...) \
friend class LuaBind::State; \
friend class LuaBind::NativeClass<type,##__VA_ARGS__>; \
static void RegisterNativeClass(LuaBind::State&); \
static void RegisterPostprocess(LuaBind::State&); \
static const char* GetNativeClassName() { return #type; };
//static const char* GetClassName() { return #type; };
#define LUA_BIND_DECL_METHOD(mtd) static int mtd(lua_State* L)
#define LUA_BIND_DECL_ENUM(e, under_line_index)
// ��������ʵ�ֵĺꡣ����������һ��L��
#define LUA_BIND_IMPL_METHOD(type, f) int type::f(lua_State* L)
// ��Ӧ�ó���ʵ�ֵ������ӿڡ�����������һ��state��
#define LUA_BIND_REGISTRY(type) void type::RegisterNativeClass(LuaBind::State& state)
#define LUA_BIND_POSTPROCESS(type) void type::RegisterPostprocess(LuaBind::State& state)
// ����ע��ĺꡣ֮ǰ���������ÿɱ�꣬����û��luaclastable refû��ע��ԡ�
#define LUA_BIND_REGISTER_CLASS(state, param) state.RegisterNativeClass<param>()
#define LUA_BIND_REGISTER_ABSTRACT_CLASS(state, type) type::RegisterPostprocess(state)
#define LUA_BIND_REGISTER_METHODS(state, ...) \
do{ \
luaL_Reg __m[] = {__VA_ARGS__,{0, 0}}; \
state.RegisterMethods(__m); \
}while(0)
#define LUA_BIND_REGISTER_ENUM(state, name, ...) \
do{ \
LuaBind::Enum __e[] = {__VA_ARGS__,{0, 0}}; \
state.RegisterEnum(name, __e); \
}while(0)
#define LUA_BIND_PREPARE(L, T) \
LUA_BIND_STATE(L); \
T* self = state.GetUserdata<T>(1);
#define LUA_BIND_CHECK(L, params)\
if(!state.CheckParams(1, params)) {\
luaL_error(state, "Unexcepted parameters.");\
return 0;\
}
#define luaxport private
#endif
|