add lua/C++ dynamic_cast<>
[ardour.git] / libs / lua / LuaBridge / detail / FuncTraits.h
1 //------------------------------------------------------------------------------
2 /*
3   https://github.com/vinniefalco/LuaBridge
4
5   Copyright 2012, Vinnie Falco <vinnie.falco@gmail.com>
6
7   License: The MIT License (http://www.opensource.org/licenses/mit-license.php)
8
9   Permission is hereby granted, free of charge, to any person obtaining a copy
10   of this software and associated documentation files (the "Software"), to deal
11   in the Software without restriction, including without limitation the rights
12   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13   copies of the Software, and to permit persons to whom the Software is
14   furnished to do so, subject to the following conditions:
15
16   The above copyright notice and this permission notice shall be included in all
17   copies or substantial portions of the Software.
18
19   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25   SOFTWARE.
26 */
27 //==============================================================================
28
29 /**
30   Since the throw specification is part of a function signature, the FuncTraits
31   family of templates needs to be specialized for both types. The
32   LUABRIDGE_THROWSPEC macro controls whether we use the 'throw ()' form, or
33   'noexcept' (if C++11 is available) to distinguish the functions.
34 */
35 #if defined (__APPLE_CPP__) || defined(__APPLE_CC__) || defined(__clang__) || defined(__GNUC__) || \
36     (defined (_MSC_VER) && (_MSC_VER >= 1700))
37 // Do not define LUABRIDGE_THROWSPEC since the Xcode and gcc  compilers do not
38 // distinguish the throw specification in the function signature.
39 #else
40 // Visual Studio 10 and earlier pay too much mind to useless throw() spec.
41 //
42 # define LUABRIDGE_THROWSPEC throw()
43 #endif
44
45 //==============================================================================
46 /**
47     Traits for function pointers.
48
49     There are three types of functions: global, non-const member, and const
50     member. These templates determine the type of function, which class type it
51     belongs to if it is a class member, the const-ness if it is a member
52     function, and the type information for the return value and argument list.
53
54     Expansions are provided for functions with up to 8 parameters. This can be
55     manually extended, or expanded to an arbitrary amount using C++11 features.
56 */
57 template <class MemFn, class D = MemFn>
58 struct FuncTraits
59 {
60 };
61
62 /* Ordinary function pointers. */
63
64 template <class R, class D>
65 struct FuncTraits <R (*) (), D>
66 {
67   static bool const isMemberFunction = false;
68   typedef D DeclType;
69   typedef R ReturnType;
70   typedef None Params;
71   static R call (D fp, TypeListValues <Params>)
72   {
73     return fp ();
74   }
75 };
76
77 template <class R, class P1, class D>
78 struct FuncTraits <R (*) (P1), D>
79 {
80   static bool const isMemberFunction = false;
81   typedef D DeclType;
82   typedef R ReturnType;
83   typedef TypeList <P1> Params;
84   static R call (D fp, TypeListValues <Params>& tvl)
85   {
86     return fp (tvl.hd);
87   }
88 };
89
90 template <class R, class P1, class P2, class D>
91 struct FuncTraits <R (*) (P1, P2), D>
92 {
93   static bool const isMemberFunction = false;
94   typedef D DeclType;
95   typedef R ReturnType;
96   typedef TypeList <P1, TypeList <P2> > Params;
97   static R call (D fp, TypeListValues <Params>& tvl)
98   {
99     return fp (tvl.hd, tvl.tl.hd);
100   }
101 };
102
103 template <class R, class P1, class P2, class P3, class D>
104 struct FuncTraits <R (*) (P1, P2, P3), D>
105 {
106   static bool const isMemberFunction = false;
107   typedef D DeclType;
108   typedef R ReturnType;
109   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
110   static R call (D fp, TypeListValues <Params>& tvl)
111   {
112     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
113   }
114 };
115
116 template <class R, class P1, class P2, class P3, class P4, class D>
117 struct FuncTraits <R (*) (P1, P2, P3, P4), D>
118 {
119   static bool const isMemberFunction = false;
120   typedef D DeclType;
121   typedef R ReturnType;
122   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
123   static R call (D fp, TypeListValues <Params>& tvl)
124   {
125     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
126   }
127 };
128
129 template <class R, class P1, class P2, class P3, class P4, class P5, class D>
130 struct FuncTraits <R (*) (P1, P2, P3, P4, P5), D>
131 {
132   static bool const isMemberFunction = false;
133   typedef D DeclType;
134   typedef R ReturnType;
135   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
136   static R call (D fp, TypeListValues <Params>& tvl)
137   {
138     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
139   }
140 };
141
142 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
143 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6), D>
144 {
145   static bool const isMemberFunction = false;
146   typedef D DeclType;
147   typedef R ReturnType;
148   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5,  TypeList <P6> > > > > > Params;
149   static R call (D fp, TypeListValues <Params>& tvl)
150   {
151     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
152   }
153 };
154
155 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
156 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7), D>
157 {
158   static bool const isMemberFunction = false;
159   typedef D DeclType;
160   typedef R ReturnType;
161   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
162   static R call (D fp, TypeListValues <Params>& tvl)
163   {
164     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
165   }
166 };
167
168 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
169 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8), D>
170 {
171   static bool const isMemberFunction = false;
172   typedef D DeclType;
173   typedef R ReturnType;
174   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
175   static R call (D fp, TypeListValues <Params>& tvl)
176   {
177     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
178   }
179 };
180
181 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class D>
182 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8, P9), D>
183 {
184   static bool const isMemberFunction = false;
185   typedef D DeclType;
186   typedef R ReturnType;
187   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8, TypeList <P9> > > > > > > > > Params;
188   static R call (D fp, TypeListValues <Params>& tvl)
189   {
190     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd);
191   }
192 };
193
194
195 /* Non-const member function pointers. */
196
197 template <class T, class R, class D>
198 struct FuncTraits <R (T::*) (), D>
199 {
200   static bool const isMemberFunction = true;
201   static bool const isConstMemberFunction = false;
202   typedef D DeclType;
203   typedef T ClassType;
204   typedef R ReturnType;
205   typedef None Params;
206   static R call (T* obj, D fp, TypeListValues <Params>)
207   {
208     return (obj->*fp)();
209   }
210 };
211
212 template <class T, class R, class P1, class D>
213 struct FuncTraits <R (T::*) (P1), D>
214 {
215   static bool const isMemberFunction = true;
216   static bool const isConstMemberFunction = false;
217   typedef D DeclType;
218   typedef T ClassType;
219   typedef R ReturnType;
220   typedef TypeList <P1> Params;
221   static R call (T* obj, D fp, TypeListValues <Params> &tvl)
222   {
223     return (obj->*fp)(tvl.hd);
224   }
225 };
226
227 template <class T, class R, class P1, class P2, class D>
228 struct FuncTraits <R (T::*) (P1, P2), D>
229 {
230   static bool const isMemberFunction = true;
231   static bool const isConstMemberFunction = false;
232   typedef D DeclType;
233   typedef T ClassType;
234   typedef R ReturnType;
235   typedef TypeList <P1, TypeList <P2> > Params;
236   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
237   {
238     return (obj->*fp)(tvl.hd, tvl.tl.hd);
239   }
240 };
241
242 template <class T, class R, class P1, class P2, class P3, class D>
243 struct FuncTraits <R (T::*) (P1, P2, P3), D>
244 {
245   static bool const isMemberFunction = true;
246   static bool const isConstMemberFunction = false;
247   typedef D DeclType;
248   typedef T ClassType;
249   typedef R ReturnType;
250   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
251   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
252   {
253     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
254   }
255 };
256
257 template <class T, class R, class P1, class P2, class P3, class P4, class D>
258 struct FuncTraits <R (T::*) (P1, P2, P3, P4), D>
259 {
260   static bool const isMemberFunction = true;
261   static bool const isConstMemberFunction = false;
262   typedef D DeclType;
263   typedef T ClassType;
264   typedef R ReturnType;
265   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
266   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
267   {
268     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
269   }
270 };
271
272 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
273 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5), D>
274 {
275   static bool const isMemberFunction = true;
276   static bool const isConstMemberFunction = false;
277   typedef D DeclType;
278   typedef T ClassType;
279   typedef R ReturnType;
280   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
281   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
282   {
283     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
284   }
285 };
286
287 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
288 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6), D>
289 {
290   static bool const isMemberFunction = true;
291   static bool const isConstMemberFunction = false;
292   typedef D DeclType;
293   typedef T ClassType;
294   typedef R ReturnType;
295   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
296   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
297   {
298     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
299   }
300 };
301
302 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
303 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7), D>
304 {
305   static bool const isMemberFunction = true;
306   static bool const isConstMemberFunction = false;
307   typedef D DeclType;
308   typedef T ClassType;
309   typedef R ReturnType;
310   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
311   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
312   {
313     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
314   }
315 };
316
317 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
318 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8), D>
319 {
320   static bool const isMemberFunction = true;
321   static bool const isConstMemberFunction = false;
322   typedef D DeclType;
323   typedef T ClassType;
324   typedef R ReturnType;
325   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
326   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
327   {
328     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
329   }
330 };
331
332 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class D>
333 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8, P9), D>
334 {
335   static bool const isMemberFunction = true;
336   static bool const isConstMemberFunction = false;
337   typedef D DeclType;
338   typedef T ClassType;
339   typedef R ReturnType;
340   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8, TypeList <P9> > > > > > > > > Params;
341   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
342   {
343     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd);
344   }
345 };
346
347
348 /* Const member function pointers. */
349
350 template <class T, class R, class D>
351 struct FuncTraits <R (T::*) () const, D>
352 {
353   static bool const isMemberFunction = true;
354   static bool const isConstMemberFunction = true;
355   typedef D DeclType;
356   typedef T ClassType;
357   typedef R ReturnType;
358   typedef None Params;
359   static R call (T const* obj, D fp, TypeListValues <Params>)
360   {
361     return (obj->*fp)();
362   }
363 };
364
365 template <class T, class R, class P1, class D>
366 struct FuncTraits <R (T::*) (P1) const, D>
367 {
368   static bool const isMemberFunction = true;
369   static bool const isConstMemberFunction = true;
370   typedef D DeclType;
371   typedef T ClassType;
372   typedef R ReturnType;
373   typedef TypeList <P1> Params;
374   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
375   {
376     return (obj->*fp)(tvl.hd);
377   }
378 };
379
380 template <class T, class R, class P1, class P2, class D>
381 struct FuncTraits <R (T::*) (P1, P2) const, D>
382 {
383   static bool const isMemberFunction = true;
384   static bool const isConstMemberFunction = true;
385   typedef D DeclType;
386   typedef T ClassType;
387   typedef R ReturnType;
388   typedef TypeList <P1, TypeList <P2> > Params;
389   static R call (T const* obj, R (T::*fp) (P1, P2) const,
390     TypeListValues <Params>& tvl)
391   {
392     return (obj->*fp)(tvl.hd, tvl.tl.hd);
393   }
394 };
395
396 template <class T, class R, class P1, class P2, class P3, class D>
397 struct FuncTraits <R (T::*) (P1, P2, P3) const, D>
398 {
399   static bool const isMemberFunction = true;
400   static bool const isConstMemberFunction = true;
401   typedef D DeclType;
402   typedef T ClassType;
403   typedef R ReturnType;
404   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
405   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
406   {
407     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
408   }
409 };
410
411 template <class T, class R, class P1, class P2, class P3, class P4, class D>
412 struct FuncTraits <R (T::*) (P1, P2, P3, P4) const, D>
413 {
414   static bool const isMemberFunction = true;
415   static bool const isConstMemberFunction = true;
416   typedef D DeclType;
417   typedef T ClassType;
418   typedef R ReturnType;
419   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
420   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
421   {
422     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
423   }
424 };
425
426 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
427 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) const, D>
428 {
429   static bool const isMemberFunction = true;
430   static bool const isConstMemberFunction = true;
431   typedef D DeclType;
432   typedef T ClassType;
433   typedef R ReturnType;
434   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
435   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
436   {
437     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
438   }
439 };
440
441 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
442 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) const, D>
443 {
444   static bool const isMemberFunction = true;
445   static bool const isConstMemberFunction = true;
446   typedef D DeclType;
447   typedef T ClassType;
448   typedef R ReturnType;
449   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
450   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
451   {
452     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
453   }
454 };
455
456 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
457 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) const, D>
458 {
459   static bool const isMemberFunction = true;
460   static bool const isConstMemberFunction = true;
461   typedef D DeclType;
462   typedef T ClassType;
463   typedef R ReturnType;
464   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
465   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
466   {
467     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
468   }
469 };
470
471 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
472 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) const, D>
473 {
474   static bool const isMemberFunction = true;
475   static bool const isConstMemberFunction = true;
476   typedef D DeclType;
477   typedef T ClassType;
478   typedef R ReturnType;
479   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
480   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
481   {
482     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
483   }
484 };
485
486 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class D>
487 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8, P9) const, D>
488 {
489   static bool const isMemberFunction = true;
490   static bool const isConstMemberFunction = true;
491   typedef D DeclType;
492   typedef T ClassType;
493   typedef R ReturnType;
494   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8, TypeList <P9> > > > > > > > > Params;
495   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
496   {
497     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd);
498   }
499 };
500
501
502 #if defined (LUABRIDGE_THROWSPEC)
503
504 /* Ordinary function pointers. */
505
506 template <class R, class D>
507 struct FuncTraits <R (*) () LUABRIDGE_THROWSPEC, D>
508 {
509   static bool const isMemberFunction = false;
510   typedef D DeclType;
511   typedef R ReturnType;
512   typedef None Params;
513   static R call (D fp, TypeListValues <Params> const&)
514   {
515     return fp ();
516   }
517 };
518
519 template <class R, class P1, class D>
520 struct FuncTraits <R (*) (P1) LUABRIDGE_THROWSPEC, D>
521 {
522   static bool const isMemberFunction = false;
523   typedef D DeclType;
524   typedef R ReturnType;
525   typedef TypeList <P1> Params;
526   static R call (D fp, TypeListValues <Params>& tvl)
527   {
528     return fp (tvl.hd);
529   }
530 };
531
532 template <class R, class P1, class P2, class D>
533 struct FuncTraits <R (*) (P1, P2) LUABRIDGE_THROWSPEC, D>
534 {
535   static bool const isMemberFunction = false;
536   typedef D DeclType;
537   typedef R ReturnType;
538   typedef TypeList <P1, TypeList <P2> > Params;
539   static R call (D fp, TypeListValues <Params>& tvl)
540   {
541     return fp (tvl.hd, tvl.tl.hd);
542   }
543 };
544
545 template <class R, class P1, class P2, class P3, class D>
546 struct FuncTraits <R (*) (P1, P2, P3) LUABRIDGE_THROWSPEC, D>
547 {
548   static bool const isMemberFunction = false;
549   typedef D DeclType;
550   typedef R ReturnType;
551   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
552   static R call (D fp, TypeListValues <Params>& tvl)
553   {
554     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
555   }
556 };
557
558 template <class R, class P1, class P2, class P3, class P4, class D>
559 struct FuncTraits <R (*) (P1, P2, P3, P4) LUABRIDGE_THROWSPEC, D>
560 {
561   static bool const isMemberFunction = false;
562   typedef D DeclType;
563   typedef R ReturnType;
564   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
565   static R call (D fp, TypeListValues <Params>& tvl)
566   {
567     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
568   }
569 };
570
571 template <class R, class P1, class P2, class P3, class P4, class P5, class D>
572 struct FuncTraits <R (*) (P1, P2, P3, P4, P5) LUABRIDGE_THROWSPEC, D>
573 {
574   static bool const isMemberFunction = false;
575   typedef D DeclType;
576   typedef R ReturnType;
577   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
578   static R call (D fp, TypeListValues <Params>& tvl)
579   {
580     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
581   }
582 };
583
584 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
585 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6) LUABRIDGE_THROWSPEC, D>
586 {
587   static bool const isMemberFunction = false;
588   typedef D DeclType;
589   typedef R ReturnType;
590   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5,  TypeList <P6> > > > > > Params;
591   static R call (D fp, TypeListValues <Params>& tvl)
592   {
593     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
594   }
595 };
596
597 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
598 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7) LUABRIDGE_THROWSPEC, D>
599 {
600   static bool const isMemberFunction = false;
601   typedef D DeclType;
602   typedef R ReturnType;
603   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
604   static R call (D fp, TypeListValues <Params>& tvl)
605   {
606     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
607   }
608 };
609
610 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
611 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8) LUABRIDGE_THROWSPEC, D>
612 {
613   static bool const isMemberFunction = false;
614   typedef D DeclType;
615   typedef R ReturnType;
616   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
617   static R call (D fp, TypeListValues <Params>& tvl)
618   {
619     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
620   }
621 };
622
623 template <class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class D>
624 struct FuncTraits <R (*) (P1, P2, P3, P4, P5, P6, P7, P8, P9) LUABRIDGE_THROWSPEC, D>
625 {
626   static bool const isMemberFunction = false;
627   typedef D DeclType;
628   typedef R ReturnType;
629   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8, TypeList <P9> > > > > > > > > Params;
630   static R call (D fp, TypeListValues <Params>& tvl)
631   {
632     return fp (tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd);
633   }
634 };
635
636 /* Non-const member function pointers with THROWSPEC. */
637
638 template <class T, class R, class D>
639 struct FuncTraits <R (T::*) () LUABRIDGE_THROWSPEC, D>
640 {
641   static bool const isMemberFunction = true;
642   static bool const isConstMemberFunction = false;
643   typedef D DeclType;
644   typedef T ClassType;
645   typedef R ReturnType;
646   typedef None Params;
647   static R call (T* obj, D fp, TypeListValues <Params> const&)
648   {
649     return (obj->*fp)();
650   }
651 };
652
653 template <class T, class R, class P1, class D>
654 struct FuncTraits <R (T::*) (P1) LUABRIDGE_THROWSPEC, D>
655 {
656   static bool const isMemberFunction = true;
657   static bool const isConstMemberFunction = false;
658   typedef D DeclType;
659   typedef T ClassType;
660   typedef R ReturnType;
661   typedef TypeList <P1> Params;
662   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
663   {
664     return (obj->*fp)(tvl.hd);
665   }
666 };
667
668 template <class T, class R, class P1, class P2, class D>
669 struct FuncTraits <R (T::*) (P1, P2) LUABRIDGE_THROWSPEC, D>
670 {
671   static bool const isMemberFunction = true;
672   static bool const isConstMemberFunction = false;
673   typedef D DeclType;
674   typedef T ClassType;
675   typedef R ReturnType;
676   typedef TypeList <P1, TypeList <P2> > Params;
677   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
678   {
679     return (obj->*fp)(tvl.hd, tvl.tl.hd);
680   }
681 };
682
683 template <class T, class R, class P1, class P2, class P3, class D>
684 struct FuncTraits <R (T::*) (P1, P2, P3) LUABRIDGE_THROWSPEC, D>
685 {
686   static bool const isMemberFunction = true;
687   static bool const isConstMemberFunction = false;
688   typedef D DeclType;
689   typedef T ClassType;
690   typedef R ReturnType;
691   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
692   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
693   {
694     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
695   }
696 };
697
698 template <class T, class R, class P1, class P2, class P3, class P4, class D>
699 struct FuncTraits <R (T::*) (P1, P2, P3, P4) LUABRIDGE_THROWSPEC, D>
700 {
701   static bool const isMemberFunction = true;
702   static bool const isConstMemberFunction = false;
703   typedef D DeclType;
704   typedef T ClassType;
705   typedef R ReturnType;
706   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
707   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
708   {
709     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
710   }
711 };
712
713 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
714 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) LUABRIDGE_THROWSPEC, D>
715 {
716   static bool const isMemberFunction = true;
717   static bool const isConstMemberFunction = false;
718   typedef D DeclType;
719   typedef T ClassType;
720   typedef R ReturnType;
721   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
722   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
723   {
724     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd);
725   }
726 };
727
728 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
729 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) LUABRIDGE_THROWSPEC, D>
730 {
731   static bool const isMemberFunction = true;
732   static bool const isConstMemberFunction = false;
733   typedef D DeclType;
734   typedef T ClassType;
735   typedef R ReturnType;
736   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
737   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
738   {
739     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
740   }
741 };
742
743 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
744 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) LUABRIDGE_THROWSPEC, D>
745 {
746   static bool const isMemberFunction = true;
747   static bool const isConstMemberFunction = false;
748   typedef D DeclType;
749   typedef T ClassType;
750   typedef R ReturnType;
751   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
752   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
753   {
754     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
755   }
756 };
757
758 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
759 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) LUABRIDGE_THROWSPEC, D>
760 {
761   static bool const isMemberFunction = true;
762   static bool const isConstMemberFunction = false;
763   typedef D DeclType;
764   typedef T ClassType;
765   typedef R ReturnType;
766   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
767   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
768   {
769     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
770   }
771 };
772
773 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class D>
774 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8, P9) LUABRIDGE_THROWSPEC, D>
775 {
776   static bool const isMemberFunction = true;
777   static bool const isConstMemberFunction = false;
778   typedef D DeclType;
779   typedef T ClassType;
780   typedef R ReturnType;
781   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8, TypeList <P9> > > > > > > > > Params;
782   static R call (T* obj, D fp, TypeListValues <Params>& tvl)
783   {
784     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd);
785   }
786 };
787
788
789 /* Const member function pointers with THROWSPEC. */
790
791 template <class T, class R, class D>
792 struct FuncTraits <R (T::*) () const LUABRIDGE_THROWSPEC, D>
793 {
794   static bool const isMemberFunction = true;
795   static bool const isConstMemberFunction = true;
796   typedef D DeclType;
797   typedef T ClassType;
798   typedef R ReturnType;
799   typedef None Params;
800   static R call (T const* obj, D fp, TypeListValues <Params>)
801   {
802     return (obj->*fp)();
803   }
804 };
805
806 template <class T, class R, class P1, class D>
807 struct FuncTraits <R (T::*) (P1) const LUABRIDGE_THROWSPEC, D>
808 {
809   static bool const isMemberFunction = true;
810   static bool const isConstMemberFunction = true;
811   typedef D DeclType;
812   typedef T ClassType;
813   typedef R ReturnType;
814   typedef TypeList <P1> Params;
815   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
816   {
817     return (obj->*fp)(tvl.hd);
818   }
819 };
820
821 template <class T, class R, class P1, class P2, class D>
822 struct FuncTraits <R (T::*) (P1, P2) const LUABRIDGE_THROWSPEC, D>
823 {
824   static bool const isMemberFunction = true;
825   static bool const isConstMemberFunction = true;
826   typedef D DeclType;
827   typedef T ClassType;
828   typedef R ReturnType;
829   typedef TypeList <P1, TypeList <P2> > Params;
830   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
831   {
832     return (obj->*fp)(tvl.hd, tvl.tl.hd);
833   }
834 };
835
836 template <class T, class R, class P1, class P2, class P3, class D>
837 struct FuncTraits <R (T::*) (P1, P2, P3) const LUABRIDGE_THROWSPEC, D>
838 {
839   static bool const isMemberFunction = true;
840   static bool const isConstMemberFunction = true;
841   typedef D DeclType;
842   typedef T ClassType;
843   typedef R ReturnType;
844   typedef TypeList <P1, TypeList <P2, TypeList <P3> > > Params;
845   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
846   {
847     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd);
848   }
849 };
850
851 template <class T, class R, class P1, class P2, class P3, class P4, class D>
852 struct FuncTraits <R (T::*) (P1, P2, P3, P4) const LUABRIDGE_THROWSPEC, D>
853 {
854   static bool const isMemberFunction = true;
855   static bool const isConstMemberFunction = true;
856   typedef D DeclType;
857   typedef T ClassType;
858   typedef R ReturnType;
859   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4> > > > Params;
860   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
861   {
862     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd);
863   }
864 };
865
866 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class D>
867 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5) const LUABRIDGE_THROWSPEC, D>
868 {
869   static bool const isMemberFunction = true;
870   static bool const isConstMemberFunction = true;
871   typedef D DeclType;
872   typedef T ClassType;
873   typedef R ReturnType;
874   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5> > > > > Params;
875   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
876   {
877     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd,
878       tvl.tl.tl.tl.tl.hd);
879   }
880 };
881
882 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class D>
883 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6) const LUABRIDGE_THROWSPEC, D>
884 {
885   static bool const isMemberFunction = true;
886   static bool const isConstMemberFunction = true;
887   typedef D DeclType;
888   typedef T ClassType;
889   typedef R ReturnType;
890   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6> > > > > > Params;
891   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
892   {
893     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd);
894   }
895 };
896
897 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class D>
898 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7) const LUABRIDGE_THROWSPEC, D>
899 {
900   static bool const isMemberFunction = true;
901   static bool const isConstMemberFunction = true;
902   typedef D DeclType;
903   typedef T ClassType;
904   typedef R ReturnType;
905   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7> > > > > > > Params;
906   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
907   {
908     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd);
909   }
910 };
911
912 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class D>
913 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8) const LUABRIDGE_THROWSPEC, D>
914 {
915   static bool const isMemberFunction = true;
916   static bool const isConstMemberFunction = true;
917   typedef D DeclType;
918   typedef T ClassType;
919   typedef R ReturnType;
920   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8> > > > > > > > Params;
921   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
922   {
923     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd);
924   }
925 };
926
927 template <class T, class R, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class D>
928 struct FuncTraits <R (T::*) (P1, P2, P3, P4, P5, P6, P7, P8, P9) const LUABRIDGE_THROWSPEC, D>
929 {
930   static bool const isMemberFunction = true;
931   static bool const isConstMemberFunction = true;
932   typedef D DeclType;
933   typedef T ClassType;
934   typedef R ReturnType;
935   typedef TypeList <P1, TypeList <P2, TypeList <P3, TypeList <P4, TypeList <P5, TypeList <P6, TypeList <P7, TypeList <P8, TypeList <P9> > > > > > > > > Params;
936   static R call (T const* obj, D fp, TypeListValues <Params>& tvl)
937   {
938     return (obj->*fp)(tvl.hd, tvl.tl.hd, tvl.tl.tl.hd, tvl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.hd, tvl.tl.tl.tl.tl.tl.tl.tl.tl.hd);
939   }
940 };
941
942
943 #endif