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
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#ifndef __LUAX_UTILITY_H__
#define __LUAX_UTILITY_H__
// nativeӿ
/// RegisterLuaxClass עķͳԱö١ȵclass table LuaxGetFactoryName ù
/// ͬʱעʱעΪsingletonͨʱ
#define LUAX_DECL_FACTORY(type, ...) \
friend class Luax::LuaxState; \
friend class Luax::LuaxNativeClass<type,##__VA_ARGS__>; \
static void RegisterLuaxClass(Luax::LuaxState&); \
static void RegisterLuaxPostprocess(Luax::LuaxState&); \
static const char* GetLuaxFactoryName() { return #type; };\
static const char* GetLuaxClassName() { return #type; };\
static bool IsLuaxClassSingleton() { return false; }
/// Ϊijʹô˺꣬עһڣעắеãעЩ
#define LUAX_DECL_ABSTRACT_FACTORY() \
static void RegisterLuaxClass(Luax::LuaxState&);\
static void RegisterLuaxPostprocess(Luax::LuaxState&)
/// RegisterLuaxClass עķͳԱö١ȵclass table LuaxGetSingletonName õ
#define LUAX_DECL_SINGLETON(type, ...) \
friend class Luax::LuaxState; \
friend class Luax::LuaxNativeClass<type,##__VA_ARGS__>; \
static void RegisterLuaxClass(Luax::LuaxState&); \
static void RegisterLuaxPostprocess(Luax::LuaxState&); \
static const char* GetLuaxSingletonName() { return #type; }; \
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, under_line_index)
/// ʵֵĺꡣһ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)
/// עĺꡣ֮ǰÿɱ꣬ûluaclastable refûעԡ
#define LUAX_REGISTER_FACTORY(state, param) state.RegisterFactory<param>()
#define LUAX_REGISTER_SINGLETON(state, param) state.RegisterSingleton<param>()
#define LUAX_REGISTER_ABSTRACT_FACTORY(state, type) type::RegisterLuaxPostprocess(state)
#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)
#define LUAX_PREPARE(L, T) \
LUAX_STATE(L); \
T* self = state.GetUserdata<T>(1);
#define LUAX_INHERIT(state, type) type::RegisterLuaxClass(state)
#define luaxport private
#endif
|