2
// SqPlus constant type and constant member function support created by Simon Michelmore.
3
// Modular integration 11/14/05 jcs.
5
#ifdef SQPLUS_DECLARE_INSTANCE_TYPE_CONST
6
#undef SQPLUS_DECLARE_INSTANCE_TYPE_CONST
8
// Kamaitati's NULL_INSTANCE support. 5/28/06 jcs
10
#ifdef SQPLUS_SUPPORT_NULL_INSTANCES
12
#define DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,NAME) \
13
DECLARE_INSTANCE_TYPE_NAME_(TYPE,NAME) \
15
inline void Push(HSQUIRRELVM v,const TYPE * value) { \
16
if (!value) sq_pushnull(v); \
17
else if (!CreateNativeClassInstance(v,GetTypeName(*value),(TYPE*)value,0)) \
18
throw SquirrelError(sqT("Push(): could not create INSTANCE (check registration name)")); } \
19
inline void Push(HSQUIRRELVM v,const TYPE & value) { if (!CreateCopyInstance(GetTypeName(value),value)) throw SquirrelError(sqT("Push(): could not create INSTANCE copy (check registration name)")); } \
20
inline bool Match(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return GetInstance<TYPE>(v,idx) != NULL; } \
21
inline const TYPE & Get(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return *GetInstance<TYPE>(v,idx); } \
26
#define DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,NAME) \
27
DECLARE_INSTANCE_TYPE_NAME_(TYPE,NAME) \
29
inline void Push(HSQUIRRELVM v,const TYPE * value) { if (!CreateNativeClassInstance(v,GetTypeName(*value),(TYPE*)value,0)) throw SquirrelError(sqT("Push(): could not create INSTANCE (check registration name)")); } \
30
inline void Push(HSQUIRRELVM v,const TYPE & value) { if (!CreateCopyInstance(GetTypeName(value),value)) throw SquirrelError(sqT("Push(): could not create INSTANCE copy (check registration name)")); } \
31
inline bool Match(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return GetInstance<TYPE>(v,idx) != NULL; } \
32
inline const TYPE & Get(TypeWrapper<const TYPE &>,HSQUIRRELVM v,int idx) { return *GetInstance<TYPE>(v,idx); } \
37
#define DECLARE_INSTANCE_TYPE(TYPE) DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,TYPE)
38
#define DECLARE_INSTANCE_TYPE_NAME(TYPE,NAME) DECLARE_INSTANCE_TYPE_NAME_CONST(TYPE,NAME)
41
#ifdef SQPLUS_CALL_CONST_MFUNC_RET0
42
#undef SQPLUS_CALL_CONST_MFUNC_RET0
43
template <typename Callee>
44
static int Call(Callee & callee,RT (Callee::*func)() const,HSQUIRRELVM v,int /*index*/) {
45
RT ret = (callee.*func)();
50
template <typename Callee,typename P1>
51
static int Call(Callee & callee,RT (Callee::*func)(P1) const,HSQUIRRELVM v,int index) {
52
sq_argassert(1,index + 0);
53
RT ret = (callee.*func)(
54
Get(TypeWrapper<P1>(),v,index + 0)
60
template<typename Callee,typename P1,typename P2>
61
static int Call(Callee & callee,RT (Callee::*func)(P1,P2) const,HSQUIRRELVM v,int index) {
62
sq_argassert(1,index + 0);
63
sq_argassert(2,index + 1);
64
RT ret = (callee.*func)(
65
Get(TypeWrapper<P1>(),v,index + 0),
66
Get(TypeWrapper<P2>(),v,index + 1)
72
template<typename Callee,typename P1,typename P2,typename P3>
73
static int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3) const,HSQUIRRELVM v,int index) {
74
sq_argassert(1,index + 0);
75
sq_argassert(2,index + 1);
76
sq_argassert(3,index + 2);
77
RT ret = (callee.*func)(
78
Get(TypeWrapper<P1>(),v,index + 0),
79
Get(TypeWrapper<P2>(),v,index + 1),
80
Get(TypeWrapper<P3>(),v,index + 2)
86
template<typename Callee,typename P1,typename P2,typename P3,typename P4>
87
static int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4) const,HSQUIRRELVM v,int index) {
88
sq_argassert(1,index + 0);
89
sq_argassert(2,index + 1);
90
sq_argassert(3,index + 2);
91
sq_argassert(4,index + 3);
92
RT ret = (callee.*func)(
93
Get(TypeWrapper<P1>(),v,index + 0),
94
Get(TypeWrapper<P2>(),v,index + 1),
95
Get(TypeWrapper<P3>(),v,index + 2),
96
Get(TypeWrapper<P4>(),v,index + 3)
102
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5>
103
static int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4,P5) const,HSQUIRRELVM v,int index) {
104
sq_argassert(1,index + 0);
105
sq_argassert(2,index + 1);
106
sq_argassert(3,index + 2);
107
sq_argassert(4,index + 3);
108
sq_argassert(5,index + 4);
109
RT ret = (callee.*func)(
110
Get(TypeWrapper<P1>(),v,index + 0),
111
Get(TypeWrapper<P2>(),v,index + 1),
112
Get(TypeWrapper<P3>(),v,index + 2),
113
Get(TypeWrapper<P4>(),v,index + 3),
114
Get(TypeWrapper<P5>(),v,index + 4)
120
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6>
121
static int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4,P5,P6) const,HSQUIRRELVM v,int index) {
122
sq_argassert(1,index + 0);
123
sq_argassert(2,index + 1);
124
sq_argassert(3,index + 2);
125
sq_argassert(4,index + 3);
126
sq_argassert(5,index + 4);
127
sq_argassert(6,index + 5);
128
RT ret = (callee.*func)(
129
Get(TypeWrapper<P1>(),v,index + 0),
130
Get(TypeWrapper<P2>(),v,index + 1),
131
Get(TypeWrapper<P3>(),v,index + 2),
132
Get(TypeWrapper<P4>(),v,index + 3),
133
Get(TypeWrapper<P5>(),v,index + 4),
134
Get(TypeWrapper<P6>(),v,index + 5)
140
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7>
141
static int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4,P5,P6,P7) const,HSQUIRRELVM v,int index) {
142
sq_argassert(1,index + 0);
143
sq_argassert(2,index + 1);
144
sq_argassert(3,index + 2);
145
sq_argassert(4,index + 3);
146
sq_argassert(5,index + 4);
147
sq_argassert(6,index + 5);
148
sq_argassert(7,index + 6);
149
RT ret = (callee.*func)(
150
Get(TypeWrapper<P1>(),v,index + 0),
151
Get(TypeWrapper<P2>(),v,index + 1),
152
Get(TypeWrapper<P3>(),v,index + 2),
153
Get(TypeWrapper<P4>(),v,index + 3),
154
Get(TypeWrapper<P5>(),v,index + 4),
155
Get(TypeWrapper<P6>(),v,index + 5),
156
Get(TypeWrapper<P7>(),v,index + 6)
163
#ifdef SQPLUS_CALL_CONST_MFUNC_NORET
164
#undef SQPLUS_CALL_CONST_MFUNC_NORET
165
template<typename Callee>
166
static int Call(Callee & callee,void (Callee::*func)() const,HSQUIRRELVM,int /*index*/) {
171
template<typename Callee,typename P1>
172
static int Call(Callee & callee,void (Callee::*func)(P1) const,HSQUIRRELVM v,int index) {
173
sq_argassert(1,index + 0);
175
Get(TypeWrapper<P1>(),v,index + 0)
180
template<typename Callee,typename P1,typename P2>
181
static int Call(Callee & callee,void (Callee::*func)(P1,P2) const,HSQUIRRELVM v,int index) {
182
sq_argassert(1,index + 0);
183
sq_argassert(2,index + 1);
185
Get(TypeWrapper<P1>(),v,index + 0),
186
Get(TypeWrapper<P2>(),v,index + 1)
191
template<typename Callee,typename P1,typename P2,typename P3>
192
static int Call(Callee & callee,void (Callee::*func)(P1,P2,P3) const,HSQUIRRELVM v,int index) {
193
sq_argassert(1,index + 0);
194
sq_argassert(2,index + 1);
195
sq_argassert(3,index + 2);
197
Get(TypeWrapper<P1>(),v,index + 0),
198
Get(TypeWrapper<P2>(),v,index + 1),
199
Get(TypeWrapper<P3>(),v,index + 2)
204
template<typename Callee,typename P1,typename P2,typename P3,typename P4>
205
static int Call(Callee & callee,void (Callee::*func)(P1,P2,P3,P4) const,HSQUIRRELVM v,int index) {
206
sq_argassert(1,index + 0);
207
sq_argassert(2,index + 1);
208
sq_argassert(3,index + 2);
209
sq_argassert(4,index + 3);
211
Get(TypeWrapper<P1>(),v,index + 0),
212
Get(TypeWrapper<P2>(),v,index + 1),
213
Get(TypeWrapper<P3>(),v,index + 2),
214
Get(TypeWrapper<P4>(),v,index + 3)
219
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5>
220
static int Call(Callee & callee,void (Callee::*func)(P1,P2,P3,P4,P5) const,HSQUIRRELVM v,int index) {
221
sq_argassert(1,index + 0);
222
sq_argassert(2,index + 1);
223
sq_argassert(3,index + 2);
224
sq_argassert(4,index + 3);
225
sq_argassert(5,index + 4);
227
Get(TypeWrapper<P1>(),v,index + 0),
228
Get(TypeWrapper<P2>(),v,index + 1),
229
Get(TypeWrapper<P3>(),v,index + 2),
230
Get(TypeWrapper<P4>(),v,index + 3),
231
Get(TypeWrapper<P5>(),v,index + 4)
236
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6>
237
static int Call(Callee & callee,void (Callee::*func)(P1,P2,P3,P4,P5,P6) const,HSQUIRRELVM v,int index) {
238
sq_argassert(1,index + 0);
239
sq_argassert(2,index + 1);
240
sq_argassert(3,index + 2);
241
sq_argassert(4,index + 3);
242
sq_argassert(5,index + 4);
243
sq_argassert(6,index + 5);
245
Get(TypeWrapper<P1>(),v,index + 0),
246
Get(TypeWrapper<P2>(),v,index + 1),
247
Get(TypeWrapper<P3>(),v,index + 2),
248
Get(TypeWrapper<P4>(),v,index + 3),
249
Get(TypeWrapper<P5>(),v,index + 4),
250
Get(TypeWrapper<P6>(),v,index + 5)
255
template<typename Callee,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7>
256
static int Call(Callee & callee,void (Callee::*func)(P1,P2,P3,P4,P5,P6,P7) const,HSQUIRRELVM v,int index) {
257
sq_argassert(1,index + 0);
258
sq_argassert(2,index + 1);
259
sq_argassert(3,index + 2);
260
sq_argassert(4,index + 3);
261
sq_argassert(5,index + 4);
262
sq_argassert(6,index + 5);
263
sq_argassert(7,index + 6);
265
Get(TypeWrapper<P1>(),v,index + 0),
266
Get(TypeWrapper<P2>(),v,index + 1),
267
Get(TypeWrapper<P3>(),v,index + 2),
268
Get(TypeWrapper<P4>(),v,index + 3),
269
Get(TypeWrapper<P5>(),v,index + 4),
270
Get(TypeWrapper<P6>(),v,index + 5),
271
Get(TypeWrapper<P7>(),v,index + 6)
277
#ifdef SQPLUS_CALL_CONST_MFUNC_RET1
278
#undef SQ_REG_CONST_STATIC_VAR
279
template<typename Callee,typename RT>
280
int Call(Callee & callee, RT (Callee::*func)() const,HSQUIRRELVM v,int index) {
281
return ReturnSpecialization<RT>::Call(callee,func,v,index);
284
template<typename Callee,typename RT,typename P1>
285
int Call(Callee & callee,RT (Callee::*func)(P1) const,HSQUIRRELVM v,int index) {
286
return ReturnSpecialization<RT>::Call(callee,func,v,index);
289
template<typename Callee,typename RT,typename P1,typename P2>
290
int Call(Callee & callee,RT (Callee::*func)(P1,P2) const,HSQUIRRELVM v,int index) {
291
return ReturnSpecialization<RT>::Call(callee,func,v,index);
294
template<typename Callee,typename RT,typename P1,typename P2,typename P3>
295
int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3) const,HSQUIRRELVM v,int index) {
296
return ReturnSpecialization<RT>::Call(callee,func,v,index);
299
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4>
300
int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4) const,HSQUIRRELVM v,int index) {
301
return ReturnSpecialization<RT>::Call(callee,func,v,index);
304
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4,typename P5>
305
int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4,P5) const,HSQUIRRELVM v,int index) {
306
return ReturnSpecialization<RT>::Call(callee,func,v,index);
309
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6>
310
int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4,P5,P6) const,HSQUIRRELVM v,int index) {
311
return ReturnSpecialization<RT>::Call(callee,func,v,index);
314
template<typename Callee,typename RT,typename P1,typename P2,typename P3,typename P4,typename P5,typename P6,typename P7>
315
int Call(Callee & callee,RT (Callee::*func)(P1,P2,P3,P4,P5,P6,P7) const,HSQUIRRELVM v,int index) {
316
return ReturnSpecialization<RT>::Call(callee,func,v,index);
318
#undef SQPLUS_CALL_CONST_MFUNC_RET1
321
#ifdef SQ_REG_CONST_STATIC_VAR
322
template<typename VarType>
323
SQClassDef & staticVar(const VarType * pvar,const SQChar * name,VarAccessType access=VAR_ACCESS_READ_ONLY) {
326
} cv; // Cast Variable helper.
328
RegisterInstanceVariable(newClass,ClassType<TClassType>::type(),*(VarType **)&cv,name,VarAccessType(access|VAR_ACCESS_STATIC));