-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLuaGlobalProcedureBindings.h
More file actions
160 lines (129 loc) · 5.27 KB
/
LuaGlobalProcedureBindings.h
File metadata and controls
160 lines (129 loc) · 5.27 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// Copyright 2006-12 HumaNature Studios Inc.
#ifndef __LuaGlobalProcedureBindingS_H__
#define __LuaGlobalProcedureBindingS_H__
#include "LuaFunctionBinding.h"
namespace core {
template<typename ReturnType>
class LuaGlobalProcedureBinding0
: public LuaFunctionBinding
{
public:
LuaGlobalProcedureBinding0(ReturnType (*globalFunction)())
: mGlobalFunction(globalFunction)
{
};
virtual void interpretLuaParametersAndCall(lua_State* L)
{
UNUSED_PARAM(L);
(*mGlobalFunction)();
}
protected:
ReturnType (*mGlobalFunction)();
};
template<typename ReturnType, typename ParamType0>
class LuaGlobalProcedureBinding1
: public LuaFunctionBinding
{
public:
LuaGlobalProcedureBinding1(ReturnType (*globalFunction)(ParamType0))
: mGlobalFunction(globalFunction)
{
};
virtual void interpretLuaParametersAndCall(lua_State* L)
{
(*mGlobalFunction)
(
interpretLuaParameter<typename StripConstReference<ParamType0>::Type>(mName.c_str(), L, 0)
);
}
protected:
ReturnType (*mGlobalFunction)(ParamType0);
};
template <typename ReturnType, typename ParamType0, typename ParamType1>
class LuaGlobalProcedureBinding2
: public LuaFunctionBinding
{
public:
LuaGlobalProcedureBinding2(ReturnType (*globalFunction)(ParamType0, ParamType1))
: mGlobalFunction(globalFunction)
{
};
virtual void interpretLuaParametersAndCall(lua_State* L)
{
(*mGlobalFunction)
(
interpretLuaParameter<typename StripConstReference<ParamType0>::Type>(mName.c_str(), L, 0),
interpretLuaParameter<typename StripConstReference<ParamType1>::Type>(mName.c_str(), L, 1)
);
}
protected:
ReturnType (*mGlobalFunction)(ParamType0, ParamType1);
};
template <typename ReturnType, typename ParamType0, typename ParamType1, typename ParamType2>
class LuaGlobalProcedureBinding3
: public LuaFunctionBinding
{
public:
LuaGlobalProcedureBinding3(ReturnType (*globalFunction)(ParamType0, ParamType1, ParamType2))
: mGlobalFunction(globalFunction)
{
};
virtual void interpretLuaParametersAndCall(lua_State* L)
{
(*mGlobalFunction)
(
interpretLuaParameter<typename StripConstReference<ParamType0>::Type>(mName.c_str(), L, 0),
interpretLuaParameter<typename StripConstReference<ParamType1>::Type>(mName.c_str(), L, 1),
interpretLuaParameter<typename StripConstReference<ParamType2>::Type>(mName.c_str(), L, 2)
);
}
protected:
ReturnType (*mGlobalFunction)(ParamType0, ParamType1, ParamType2);
};
template <typename ReturnType, typename ParamType0, typename ParamType1, typename ParamType2, typename ParamType3>
class LuaGlobalProcedureBinding4
: public LuaFunctionBinding
{
public:
LuaGlobalProcedureBinding4(ReturnType (*globalFunction)(ParamType0, ParamType1, ParamType2, ParamType3))
: mGlobalFunction(globalFunction)
{
};
virtual void interpretLuaParametersAndCall(lua_State* L)
{
(*mGlobalFunction)
(
interpretLuaParameter<typename StripConstReference<ParamType0>::Type>(mName.c_str(), L, 0),
interpretLuaParameter<typename StripConstReference<ParamType1>::Type>(mName.c_str(), L, 1),
interpretLuaParameter<typename StripConstReference<ParamType2>::Type>(mName.c_str(), L, 2),
interpretLuaParameter<typename StripConstReference<ParamType3>::Type>(mName.c_str(), L, 3)
);
}
protected:
ReturnType (*mGlobalFunction)(ParamType0, ParamType1, ParamType2, ParamType3);
};
template <typename ReturnType, typename ParamType0, typename ParamType1, typename ParamType2, typename ParamType3, typename ParamType4>
class LuaGlobalProcedureBinding5
: public LuaFunctionBinding
{
public:
LuaGlobalProcedureBinding5(ReturnType (*globalFunction)(ParamType0, ParamType1, ParamType2, ParamType3, ParamType4))
: mGlobalFunction(globalFunction)
{
};
virtual void interpretLuaParametersAndCall(lua_State* L)
{
(*mGlobalFunction)
(
interpretLuaParameter<typename StripConstReference<ParamType0>::Type>(mName.c_str(), L, 0),
interpretLuaParameter<typename StripConstReference<ParamType1>::Type>(mName.c_str(), L, 1),
interpretLuaParameter<typename StripConstReference<ParamType2>::Type>(mName.c_str(), L, 2),
interpretLuaParameter<typename StripConstReference<ParamType3>::Type>(mName.c_str(), L, 3),
interpretLuaParameter<typename StripConstReference<ParamType4>::Type>(mName.c_str(), L, 4)
);
}
protected:
ReturnType (*mGlobalFunction)(ParamType0, ParamType1, ParamType2, ParamType3, ParamType4);
};
} // namespace core
#endif // __LuaGlobalProcedureBindingS_H__