author | rubidium |
Tue, 17 Jun 2008 11:46:09 +0000 | |
branch | noai |
changeset 10992 | 4dd4f4327c3a |
parent 10734 | 06f95974ac15 |
child 11002 | 3a11ba88eb7c |
permissions | -rw-r--r-- |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
1 |
/* $Id$ */ |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
2 |
|
9424
90e9aa6326f3
(svn r9226) [NoAI] -Change: moved some ai/squirrel files to root
truelight
parents:
9387
diff
changeset
|
3 |
/** @file squirrel_helper.hpp declarations and parts of the implementation of the class for convert code */ |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
4 |
|
9424
90e9aa6326f3
(svn r9226) [NoAI] -Change: moved some ai/squirrel files to root
truelight
parents:
9387
diff
changeset
|
5 |
#ifndef SQUIRREL_HELPER_HPP |
90e9aa6326f3
(svn r9226) [NoAI] -Change: moved some ai/squirrel files to root
truelight
parents:
9387
diff
changeset
|
6 |
#define SQUIRREL_HELPER_HPP |
90e9aa6326f3
(svn r9226) [NoAI] -Change: moved some ai/squirrel files to root
truelight
parents:
9387
diff
changeset
|
7 |
|
90e9aa6326f3
(svn r9226) [NoAI] -Change: moved some ai/squirrel files to root
truelight
parents:
9387
diff
changeset
|
8 |
#include <squirrel.h> |
9723
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
9 |
#include "core/math_func.hpp" |
eee46cb39750
(svn r11796) [NoAI] -Sync: with trunk r11502:11795.
rubidium
parents:
9722
diff
changeset
|
10 |
#include "economy_type.h" |
10722
6ea1daff57aa
(svn r13272) [NoAI] -Codechange: strdup all parameter strings coming from Squirrel going into the API after the possible WChar* -> char* conversion and free them after return.
rubidium
parents:
9813
diff
changeset
|
11 |
#include "misc/smallvec.h" |
10992
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
12 |
#include "squirrel_helper_type.hpp" |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
13 |
|
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
14 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
15 |
* The Squirrel convert routines |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
16 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
17 |
namespace SQConvert { |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
18 |
/** |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
19 |
* Pointers assigned to this class will be free'd when this instance |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
20 |
* comes out of scope. Useful to make sure you can use strdup(), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
21 |
* without leaking memory. |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
22 |
*/ |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
23 |
struct SQAutoFreePointers : SmallVector<void *, 1> { |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
24 |
~SQAutoFreePointers() |
10722
6ea1daff57aa
(svn r13272) [NoAI] -Codechange: strdup all parameter strings coming from Squirrel going into the API after the possible WChar* -> char* conversion and free them after return.
rubidium
parents:
9813
diff
changeset
|
25 |
{ |
6ea1daff57aa
(svn r13272) [NoAI] -Codechange: strdup all parameter strings coming from Squirrel going into the API after the possible WChar* -> char* conversion and free them after return.
rubidium
parents:
9813
diff
changeset
|
26 |
for (uint i = 0; i < this->items; i++) free(this->data[i]); |
6ea1daff57aa
(svn r13272) [NoAI] -Codechange: strdup all parameter strings coming from Squirrel going into the API after the possible WChar* -> char* conversion and free them after return.
rubidium
parents:
9813
diff
changeset
|
27 |
} |
6ea1daff57aa
(svn r13272) [NoAI] -Codechange: strdup all parameter strings coming from Squirrel going into the API after the possible WChar* -> char* conversion and free them after return.
rubidium
parents:
9813
diff
changeset
|
28 |
}; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
29 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
30 |
template <bool Y> struct YesT { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
31 |
static const bool Yes = Y; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
32 |
static const bool No = !Y; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
33 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
34 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
35 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
36 |
* Helper class to recognize if the given type is void. Usage: 'IsVoidT<T>::Yes' |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
37 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
38 |
template <typename T> struct IsVoidT : YesT<false> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
39 |
template <> struct IsVoidT<void> : YesT<true> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
40 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
41 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
42 |
* Helper class to recognize if the function/method return type is void. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
43 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
44 |
template <typename Tfunc> struct HasVoidReturnT; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
45 |
/* functions */ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
46 |
template <typename Tretval> struct HasVoidReturnT<Tretval (*)()> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
47 |
template <typename Tretval, typename Targ1> struct HasVoidReturnT<Tretval (*)(Targ1)> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
48 |
template <typename Tretval, typename Targ1, typename Targ2> struct HasVoidReturnT<Tretval (*)(Targ1, Targ2)> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
49 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3> struct HasVoidReturnT<Tretval (*)(Targ1, Targ2, Targ3)> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
50 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4> struct HasVoidReturnT<Tretval (*)(Targ1, Targ2, Targ3, Targ4)> : IsVoidT<Tretval> {}; |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
51 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4, typename Targ5> struct HasVoidReturnT<Tretval (*)(Targ1, Targ2, Targ3, Targ4, Targ5)> : IsVoidT<Tretval> {}; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
52 |
/* methods */ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
53 |
template <class Tcls, typename Tretval> struct HasVoidReturnT<Tretval (Tcls::*)()> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
54 |
template <class Tcls, typename Tretval, typename Targ1> struct HasVoidReturnT<Tretval (Tcls::*)(Targ1)> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
55 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2> struct HasVoidReturnT<Tretval (Tcls::*)(Targ1, Targ2)> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
56 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3> struct HasVoidReturnT<Tretval (Tcls::*)(Targ1, Targ2, Targ3)> : IsVoidT<Tretval> {}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
57 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4> struct HasVoidReturnT<Tretval (Tcls::*)(Targ1, Targ2, Targ3, Targ4)> : IsVoidT<Tretval> {}; |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
58 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4, typename Targ5> struct HasVoidReturnT<Tretval (Tcls::*)(Targ1, Targ2, Targ3, Targ4, Targ5)> : IsVoidT<Tretval> {}; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
59 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
60 |
|
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
61 |
/** |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
62 |
* Special class to make it possible for the compiler to pick the correct GetParam(). |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
63 |
*/ |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
64 |
template <typename T> class ForceType { }; |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
65 |
|
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
66 |
/** |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
67 |
* To return a value to squirrel, we call this function. It converts to the right format. |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
68 |
*/ |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
69 |
template <typename T> static int Return(HSQUIRRELVM vm, T t); |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
70 |
|
9532
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
71 |
template <> inline int Return<uint8> (HSQUIRRELVM vm, uint8 res) { sq_pushinteger(vm, (int32)res); return 1; } |
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
72 |
template <> inline int Return<uint16> (HSQUIRRELVM vm, uint16 res) { sq_pushinteger(vm, (int32)res); return 1; } |
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
73 |
template <> inline int Return<uint32> (HSQUIRRELVM vm, uint32 res) { sq_pushinteger(vm, (int32)res); return 1; } |
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
74 |
template <> inline int Return<int8> (HSQUIRRELVM vm, int8 res) { sq_pushinteger(vm, res); return 1; } |
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
75 |
template <> inline int Return<int16> (HSQUIRRELVM vm, int16 res) { sq_pushinteger(vm, res); return 1; } |
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
76 |
template <> inline int Return<int32> (HSQUIRRELVM vm, int32 res) { sq_pushinteger(vm, res); return 1; } |
9629 | 77 |
template <> inline int Return<int64> (HSQUIRRELVM vm, int64 res) { sq_pushinteger(vm, ClampToI32(res)); return 1; } |
9722
ebf0ece7d8f6
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
rubidium
parents:
9679
diff
changeset
|
78 |
template <> inline int Return<Money> (HSQUIRRELVM vm, Money res) { sq_pushinteger(vm, ClampToI32(res)); return 1; } |
9532
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
79 |
template <> inline int Return<bool> (HSQUIRRELVM vm, bool res) { sq_pushbool (vm, res); return 1; } |
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
80 |
template <> inline int Return<char *> (HSQUIRRELVM vm, char *res) { if (res == NULL) sq_pushnull(vm); else sq_pushstring (vm, OTTD2FS(res), strlen(res)); free(res); return 1; } |
539c48d64eea
(svn r9453) [NoAI] -Codechange: make a difference between static and non-static methods in the squirrel export script.
rubidium
parents:
9531
diff
changeset
|
81 |
template <> inline int Return<const char *>(HSQUIRRELVM vm, const char *res) { if (res == NULL) sq_pushnull(vm); else sq_pushstring (vm, OTTD2FS(res), strlen(res)); return 1; } |
9651
6e2860c67455
(svn r10551) [NoAI] -Add: added SQ support for "void *"
truelight
parents:
9635
diff
changeset
|
82 |
template <> inline int Return<void *> (HSQUIRRELVM vm, void *res) { sq_pushuserpointer(vm, res); return 1; } |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
83 |
|
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
84 |
/** |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
85 |
* To get a param from squirrel, we call this function. It converts to the right format. |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
86 |
*/ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
87 |
template <typename T> static T GetParam(ForceType<T>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr); |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
88 |
|
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
89 |
template <> inline uint8 GetParam(ForceType<uint8> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
90 |
template <> inline uint16 GetParam(ForceType<uint16> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
91 |
template <> inline uint32 GetParam(ForceType<uint32> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
92 |
template <> inline int8 GetParam(ForceType<int8> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
93 |
template <> inline int16 GetParam(ForceType<int16> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
94 |
template <> inline int32 GetParam(ForceType<int32> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQInteger tmp; sq_getinteger (vm, index, &tmp); return tmp; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
95 |
template <> inline bool GetParam(ForceType<bool> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQBool tmp; sq_getbool (vm, index, &tmp); return tmp != 0; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
96 |
template <> inline const char *GetParam(ForceType<const char *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { const SQChar *tmp; sq_getstring (vm, index, &tmp); char *tmp_str = strdup(FS2OTTD(tmp)); *ptr->Append() = (void *)tmp_str; return tmp_str; } |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
97 |
template <> inline void *GetParam(ForceType<void *> , HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) { SQUserPointer tmp; sq_getuserpointer(vm, index, &tmp); return tmp; } |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
98 |
|
10992
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
99 |
template <> inline Array *GetParam(ForceType<Array *>, HSQUIRRELVM vm, int index, SQAutoFreePointers *ptr) |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
100 |
{ |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
101 |
SQObject obj; |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
102 |
sq_getstackobj(vm, index, &obj); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
103 |
sq_pushobject(vm, obj); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
104 |
sq_pushnull(vm); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
105 |
|
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
106 |
SmallVector<int32, 2> data; |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
107 |
|
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
108 |
while (SQ_SUCCEEDED(sq_next(vm, -2))) { |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
109 |
SQInteger tmp; |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
110 |
if (SQ_SUCCEEDED(sq_getinteger(vm, -1, &tmp))) { |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
111 |
*data.Append() = (int32)tmp; |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
112 |
} else { |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
113 |
// TODO: handle following error properly: "array member is not numeric; ignoring member" |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
114 |
} |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
115 |
|
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
116 |
sq_pop(vm, 2); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
117 |
} |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
118 |
sq_pop(vm, 2); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
119 |
|
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
120 |
Array *arr = (Array*)MallocT<byte>(sizeof(Array) + sizeof(int32) * data.Length()); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
121 |
arr->size = data.Length(); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
122 |
memcpy(arr->array, data.Begin(), sizeof(int32) * data.Length()); |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
123 |
|
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
124 |
*ptr->Append() = arr; |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
125 |
return arr; |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
126 |
} |
4dd4f4327c3a
(svn r13546) [NoAI] -Codechange: add support to pass arrays with integers to C++ functions.
rubidium
parents:
10734
diff
changeset
|
127 |
|
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
128 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
129 |
* Helper class to recognize the function type (retval type, args) and use the proper specialization |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
130 |
* for SQ callback. The partial specializations for the second arg (Tis_void_retval) are not possible |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
131 |
* on the function. Therefore the class is used instead. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
132 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
133 |
template <typename Tfunc, bool Tis_void_retval = HasVoidReturnT<Tfunc>::Yes> struct HelperT; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
134 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
135 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
136 |
* The real C++ caller for function with return value and 0 params. |
9437
28e0105114a4
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents:
9434
diff
changeset
|
137 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
138 |
template <typename Tretval> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
139 |
struct HelperT<Tretval (*)(), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
140 |
static int SQCall(void *instance, Tretval (*func)(), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
141 |
{ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
142 |
return Return(vm, (*func)()); |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
143 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
144 |
}; |
9437
28e0105114a4
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents:
9434
diff
changeset
|
145 |
|
28e0105114a4
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents:
9434
diff
changeset
|
146 |
/** |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
147 |
* The real C++ caller for function with no return value and 0 params. |
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
148 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
149 |
template <typename Tretval> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
150 |
struct HelperT<Tretval (*)(), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
151 |
static int SQCall(void *instance, Tretval (*func)(), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
152 |
{ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
153 |
(*func)(); |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
154 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
155 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
156 |
}; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
157 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
158 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
159 |
* The real C++ caller for method with return value and 0 params. |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
160 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
161 |
template <class Tcls, typename Tretval> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
162 |
struct HelperT<Tretval (Tcls::*)(), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
163 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
164 |
{ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
165 |
return Return(vm, (instance->*func)()); |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
166 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
167 |
}; |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
168 |
|
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
169 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
170 |
* The real C++ caller for method with no return value and 0 params. |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
171 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
172 |
template <class Tcls, typename Tretval> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
173 |
struct HelperT<Tretval (Tcls::*)(), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
174 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
175 |
{ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
176 |
(instance->*func)(); |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
177 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
178 |
} |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
179 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
180 |
static Tcls *SQConstruct(Tcls *instance, Tretval (Tcls::*func)(), HSQUIRRELVM vm) |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
181 |
{ |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
182 |
return new Tcls(); |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
183 |
} |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
184 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
185 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
186 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
187 |
* The real C++ caller for function with return value and 1 param. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
188 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
189 |
template <typename Tretval, typename Targ1> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
190 |
struct HelperT<Tretval (*)(Targ1), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
191 |
static int SQCall(void *instance, Tretval (*func)(Targ1), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
192 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
193 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
194 |
Tretval ret = (*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
195 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
196 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
197 |
sq_pop(vm, 1); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
198 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
199 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
200 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
201 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
202 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
203 |
* The real C++ caller for function with no return value and 1 param. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
204 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
205 |
template <typename Tretval, typename Targ1> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
206 |
struct HelperT<Tretval (*)(Targ1), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
207 |
static int SQCall(void *instance, Tretval (*func)(Targ1), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
208 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
209 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
210 |
(*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
211 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
212 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
213 |
sq_pop(vm, 1); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
214 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
215 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
216 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
217 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
218 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
219 |
* The real C++ caller for method with return value and 1 param. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
220 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
221 |
template <class Tcls, typename Tretval, typename Targ1> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
222 |
struct HelperT<Tretval (Tcls::*)(Targ1), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
223 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
224 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
225 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
226 |
Tretval ret = (instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
227 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
228 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
229 |
sq_pop(vm, 1); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
230 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
231 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
232 |
}; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
233 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
234 |
/** |
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
235 |
* The real C++ caller for method with no return value and 1 param. |
9437
28e0105114a4
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents:
9434
diff
changeset
|
236 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
237 |
template <class Tcls, typename Tretval, typename Targ1> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
238 |
struct HelperT<Tretval (Tcls::*)(Targ1), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
239 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
240 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
241 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
242 |
(instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
243 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
244 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
245 |
sq_pop(vm, 1); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
246 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
247 |
} |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
248 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
249 |
static Tcls *SQConstruct(Tcls *instance, Tretval (Tcls::*func)(Targ1), HSQUIRRELVM vm) |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
250 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
251 |
SQAutoFreePointers ptr; |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
252 |
Tcls *inst = new Tcls( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
253 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr) |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
254 |
); |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
255 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
256 |
return inst; |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
257 |
} |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
258 |
}; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
259 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
260 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
261 |
* The real C++ caller for function with return value and 2 params. |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
262 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
263 |
template <typename Tretval, typename Targ1, typename Targ2> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
264 |
struct HelperT<Tretval (*)(Targ1, Targ2), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
265 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
266 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
267 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
268 |
Tretval ret = (*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
269 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
270 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
271 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
272 |
sq_pop(vm, 2); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
273 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
274 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
275 |
}; |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
276 |
|
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
277 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
278 |
* The real C++ caller for function with no return value and 2 params. |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
279 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
280 |
template <typename Tretval, typename Targ1, typename Targ2> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
281 |
struct HelperT<Tretval (*)(Targ1, Targ2), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
282 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
283 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
284 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
285 |
(*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
286 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
287 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
288 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
289 |
sq_pop(vm, 2); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
290 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
291 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
292 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
293 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
294 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
295 |
* The real C++ caller for method with return value and 2 params. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
296 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
297 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
298 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
299 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
300 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
301 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
302 |
Tretval ret = (instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
303 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
304 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
305 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
306 |
sq_pop(vm, 2); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
307 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
308 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
309 |
}; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
310 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
311 |
/** |
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
312 |
* The real C++ caller for method with no return value and 2 params. |
9437
28e0105114a4
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents:
9434
diff
changeset
|
313 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
314 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
315 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
316 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
317 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
318 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
319 |
(instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
320 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
321 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
322 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
323 |
sq_pop(vm, 2); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
324 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
325 |
} |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
326 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
327 |
static Tcls *SQConstruct(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2), HSQUIRRELVM vm) |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
328 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
329 |
SQAutoFreePointers ptr; |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
330 |
Tcls *inst = new Tcls( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
331 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
332 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr) |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
333 |
); |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
334 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
335 |
return inst; |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
336 |
} |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
337 |
}; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
338 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
339 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
340 |
* The real C++ caller for function with return value and 3 params. |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
341 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
342 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
343 |
struct HelperT<Tretval (*)(Targ1, Targ2, Targ3), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
344 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2, Targ3), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
345 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
346 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
347 |
Tretval ret = (*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
348 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
349 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
350 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
351 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
352 |
sq_pop(vm, 3); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
353 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
354 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
355 |
}; |
9437
28e0105114a4
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents:
9434
diff
changeset
|
356 |
|
28e0105114a4
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents:
9434
diff
changeset
|
357 |
/** |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
358 |
* The real C++ caller for function with no return value and 3 params. |
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
359 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
360 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
361 |
struct HelperT<Tretval (*)(Targ1, Targ2, Targ3), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
362 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2, Targ3), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
363 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
364 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
365 |
(*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
366 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
367 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
368 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
369 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
370 |
sq_pop(vm, 3); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
371 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
372 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
373 |
}; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
374 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
375 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
376 |
* The real C++ caller for method with return value and 3 params. |
9480
d071f885f918
(svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents:
9437
diff
changeset
|
377 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
378 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
379 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2, Targ3), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
380 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
381 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
382 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
383 |
Tretval ret = (instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
384 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
385 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
386 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
387 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
388 |
sq_pop(vm, 3); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
389 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
390 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
391 |
}; |
9480
d071f885f918
(svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents:
9437
diff
changeset
|
392 |
|
d071f885f918
(svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents:
9437
diff
changeset
|
393 |
/** |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
394 |
* The real C++ caller for method with no return value and 3 params. |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
395 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
396 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
397 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2, Targ3), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
398 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
399 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
400 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
401 |
(instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
402 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
403 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
404 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
405 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
406 |
sq_pop(vm, 3); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
407 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
408 |
} |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
409 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
410 |
static Tcls *SQConstruct(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3), HSQUIRRELVM vm) |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
411 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
412 |
SQAutoFreePointers ptr; |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
413 |
Tcls *inst = new Tcls( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
414 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
415 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
416 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr) |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
417 |
); |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
418 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
419 |
return inst; |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
420 |
} |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
421 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
422 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
423 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
424 |
* The real C++ caller for function with return value and 4 params. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
425 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
426 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
427 |
struct HelperT<Tretval (*)(Targ1, Targ2, Targ3, Targ4), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
428 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2, Targ3, Targ4), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
429 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
430 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
431 |
Tretval ret = (*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
432 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
433 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
434 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
435 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
436 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
437 |
sq_pop(vm, 4); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
438 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
439 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
440 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
441 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
442 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
443 |
* The real C++ caller for function with no return value and 4 params. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
444 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
445 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
446 |
struct HelperT<Tretval (*)(Targ1, Targ2, Targ3, Targ4), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
447 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2, Targ3, Targ4), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
448 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
449 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
450 |
(*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
451 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
452 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
453 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
454 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
455 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
456 |
sq_pop(vm, 4); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
457 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
458 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
459 |
}; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
460 |
|
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
461 |
/** |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
462 |
* The real C++ caller for method with return value and 4 params. |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
463 |
*/ |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
464 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
465 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2, Targ3, Targ4), false> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
466 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3, Targ4), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
467 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
468 |
SQAutoFreePointers ptr; |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
469 |
Tretval ret = (instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
470 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
471 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
472 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
473 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr) |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
474 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
475 |
sq_pop(vm, 4); |
9656
ddb4260f3051
(svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents:
9651
diff
changeset
|
476 |
return Return(vm, ret); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
477 |
} |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
478 |
}; |
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
479 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
480 |
/** |
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
481 |
* The real C++ caller for method with no return value and 4 params. |
9480
d071f885f918
(svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents:
9437
diff
changeset
|
482 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
483 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4> |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
484 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2, Targ3, Targ4), true> { |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
485 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3, Targ4), HSQUIRRELVM vm) |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
486 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
487 |
SQAutoFreePointers ptr; |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
488 |
(instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
489 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
490 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
491 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
492 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr) |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
493 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
494 |
sq_pop(vm, 4); |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
495 |
return 0; |
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
496 |
} |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
497 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
498 |
static Tcls *SQConstruct(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3, Targ4), HSQUIRRELVM vm) |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
499 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
500 |
SQAutoFreePointers ptr; |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
501 |
Tcls *inst = new Tcls( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
502 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
503 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
504 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
505 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr) |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
506 |
); |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
507 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
508 |
return inst; |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
509 |
} |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
510 |
}; |
9480
d071f885f918
(svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents:
9437
diff
changeset
|
511 |
|
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
512 |
/** |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
513 |
* The real C++ caller for function with return value and 5 params. |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
514 |
*/ |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
515 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4, typename Targ5> |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
516 |
struct HelperT<Tretval (*)(Targ1, Targ2, Targ3, Targ4, Targ5), false> { |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
517 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2, Targ3, Targ4, Targ5), HSQUIRRELVM vm) |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
518 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
519 |
SQAutoFreePointers ptr; |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
520 |
Tretval ret = (*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
521 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
522 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
523 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
524 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
525 |
GetParam(ForceType<Targ5>(), vm, 6, &ptr) |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
526 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
527 |
sq_pop(vm, 5); |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
528 |
return Return(vm, ret); |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
529 |
} |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
530 |
}; |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
531 |
|
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
532 |
/** |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
533 |
* The real C++ caller for function with no return value and 5 params. |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
534 |
*/ |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
535 |
template <typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4, typename Targ5> |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
536 |
struct HelperT<Tretval (*)(Targ1, Targ2, Targ3, Targ4, Targ5), true> { |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
537 |
static int SQCall(void *instance, Tretval (*func)(Targ1, Targ2, Targ3, Targ4, Targ5), HSQUIRRELVM vm) |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
538 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
539 |
SQAutoFreePointers ptr; |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
540 |
(*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
541 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
542 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
543 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
544 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
545 |
GetParam(ForceType<Targ5>(), vm, 6, &ptr) |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
546 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
547 |
sq_pop(vm, 5); |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
548 |
return 0; |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
549 |
} |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
550 |
}; |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
551 |
|
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
552 |
/** |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
553 |
* The real C++ caller for method with return value and 5 params. |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
554 |
*/ |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
555 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4, typename Targ5> |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
556 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2, Targ3, Targ4, Targ5), false> { |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
557 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3, Targ4, Targ5), HSQUIRRELVM vm) |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
558 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
559 |
SQAutoFreePointers ptr; |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
560 |
Tretval ret = (instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
561 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
562 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
563 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
564 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
565 |
GetParam(ForceType<Targ5>(), vm, 6, &ptr) |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
566 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
567 |
sq_pop(vm, 5); |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
568 |
return Return(vm, ret); |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
569 |
} |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
570 |
}; |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
571 |
|
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
572 |
/** |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
573 |
* The real C++ caller for method with no return value and 5 params. |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
574 |
*/ |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
575 |
template <class Tcls, typename Tretval, typename Targ1, typename Targ2, typename Targ3, typename Targ4, typename Targ5> |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
576 |
struct HelperT<Tretval (Tcls::*)(Targ1, Targ2, Targ3, Targ4, Targ5), true> { |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
577 |
static int SQCall(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3, Targ4, Targ5), HSQUIRRELVM vm) |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
578 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
579 |
SQAutoFreePointers ptr; |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
580 |
(instance->*func)( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
581 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
582 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
583 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
584 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
585 |
GetParam(ForceType<Targ5>(), vm, 6, &ptr) |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
586 |
); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
587 |
sq_pop(vm, 5); |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
588 |
return 0; |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
589 |
} |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
590 |
|
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
591 |
static Tcls *SQConstruct(Tcls *instance, Tretval (Tcls::*func)(Targ1, Targ2, Targ3, Targ4, Targ5), HSQUIRRELVM vm) |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
592 |
{ |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
593 |
SQAutoFreePointers ptr; |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
594 |
Tcls *inst = new Tcls( |
10734
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
595 |
GetParam(ForceType<Targ1>(), vm, 2, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
596 |
GetParam(ForceType<Targ2>(), vm, 3, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
597 |
GetParam(ForceType<Targ3>(), vm, 4, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
598 |
GetParam(ForceType<Targ4>(), vm, 5, &ptr), |
06f95974ac15
(svn r13284) [NoAI] -Change r13272: make the auto-free-pointers much more general, so in the future we can use it for other things, and not limited to strings
truebrain
parents:
10722
diff
changeset
|
599 |
GetParam(ForceType<Targ5>(), vm, 6, &ptr) |
9658
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
600 |
); |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
601 |
|
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
602 |
return inst; |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
603 |
} |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
604 |
}; |
e7675771bca4
(svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents:
9656
diff
changeset
|
605 |
|
9490
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
606 |
|
999eb7531205
(svn r9360) [NoAI] -Add: class-functions can now be static and still be added to SQ. There they behave as they are non-static, which is fine for that level of coding.
truelight
parents:
9480
diff
changeset
|
607 |
/** |
9530
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
608 |
* A general template for all non-static method callbacks from Squirrel. |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
609 |
* In here the function_proc is recovered, and the SQCall is called that |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
610 |
* can handle this exact amount of params. |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
611 |
*/ |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
612 |
template <typename Tcls, typename Tmethod> |
9530
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
613 |
inline SQInteger DefSQNonStaticCallback(HSQUIRRELVM vm) |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
614 |
{ |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
615 |
/* Find the amount of params we got */ |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
616 |
int nparam = sq_gettop(vm); |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
617 |
SQUserPointer ptr = NULL; |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
618 |
SQUserPointer real_instance = NULL; |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
619 |
HSQOBJECT instance; |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
620 |
|
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
621 |
/* Get the 'SQ' instance of this class */ |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
622 |
Squirrel::GetInstance(vm, &instance); |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
623 |
|
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
624 |
/* Protect against calls to a non-static method in a static way */ |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
625 |
sq_pushroottable(vm); |
9531
6a2e35738593
(svn r9452) [NoAI] -Fix r9450: compilation with _UNICODE was broken
glx
parents:
9530
diff
changeset
|
626 |
sq_pushstring(vm, OTTD2FS(Tcls::GetClassName()), -1); |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
627 |
sq_get(vm, -2); |
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
628 |
sq_pushobject(vm, instance); |
9531
6a2e35738593
(svn r9452) [NoAI] -Fix r9450: compilation with _UNICODE was broken
glx
parents:
9530
diff
changeset
|
629 |
if (sq_instanceof(vm) != SQTrue) return sq_throwerror(vm, _SC("class method is non-static")); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
630 |
sq_pop(vm, 3); |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
631 |
|
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
632 |
/* Get the 'real' instance of this class */ |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
633 |
sq_getinstanceup(vm, 1, &real_instance, 0); |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
634 |
/* Get the real function pointer */ |
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
635 |
sq_getuserdata(vm, nparam, &ptr, 0); |
9635
9ee82e091af7
(svn r10526) [NoAI] -Fix: a class with params for the constructor lost his instance when called from SQ (templates can be really useful ;))
truelight
parents:
9629
diff
changeset
|
636 |
if (real_instance == NULL) return sq_throwerror(vm, _SC("couldn't detect real instance of class for non-static call")); |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
637 |
/* Remove the userdata from the stack */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
638 |
sq_pop(vm, 1); |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
639 |
|
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
640 |
/* Delegate it to a template that can handle this specific function */ |
9529
5f26f4bc574b
(svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents:
9510
diff
changeset
|
641 |
return HelperT<Tmethod>::SQCall((Tcls *)real_instance, *(Tmethod *)ptr, vm); |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
642 |
} |
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
643 |
|
9530
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
644 |
/** |
9813
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
645 |
* A general template for all non-static advanced method callbacks from Squirrel. |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
646 |
* In here the function_proc is recovered, and the SQCall is called that |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
647 |
* can handle this exact amount of params. |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
648 |
*/ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
649 |
template <typename Tcls, typename Tmethod> |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
650 |
inline SQInteger DefSQAdvancedNonStaticCallback(HSQUIRRELVM vm) |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
651 |
{ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
652 |
/* Find the amount of params we got */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
653 |
int nparam = sq_gettop(vm); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
654 |
SQUserPointer ptr = NULL; |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
655 |
SQUserPointer real_instance = NULL; |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
656 |
HSQOBJECT instance; |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
657 |
|
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
658 |
/* Get the 'SQ' instance of this class */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
659 |
Squirrel::GetInstance(vm, &instance); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
660 |
|
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
661 |
/* Protect against calls to a non-static method in a static way */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
662 |
sq_pushroottable(vm); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
663 |
sq_pushstring(vm, OTTD2FS(Tcls::GetClassName()), -1); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
664 |
sq_get(vm, -2); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
665 |
sq_pushobject(vm, instance); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
666 |
if (sq_instanceof(vm) != SQTrue) return sq_throwerror(vm, _SC("class method is non-static")); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
667 |
sq_pop(vm, 3); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
668 |
|
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
669 |
/* Get the 'real' instance of this class */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
670 |
sq_getinstanceup(vm, 1, &real_instance, 0); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
671 |
/* Get the real function pointer */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
672 |
sq_getuserdata(vm, nparam, &ptr, 0); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
673 |
if (real_instance == NULL) return sq_throwerror(vm, _SC("couldn't detect real instance of class for non-static call")); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
674 |
/* Remove the userdata from the stack */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
675 |
sq_pop(vm, 1); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
676 |
|
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
677 |
/* Call the function, which its only param is always the VM */ |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
678 |
return (SQInteger)(((Tcls *)real_instance)->*(*(Tmethod *)ptr))(vm); |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
679 |
} |
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
680 |
|
9646f7e37c31
(svn r12409) [NoAI] -Add: allow an AdvancedMethod which gives you complete control over the param handling from a call from SQ
truebrain
parents:
9723
diff
changeset
|
681 |
/** |
9530
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
682 |
* A general template for all function/static method callbacks from Squirrel. |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
683 |
* In here the function_proc is recovered, and the SQCall is called that |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
684 |
* can handle this exact amount of params. |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
685 |
*/ |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
686 |
template <typename Tcls, typename Tmethod> |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
687 |
inline SQInteger DefSQStaticCallback(HSQUIRRELVM vm) |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
688 |
{ |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
689 |
/* Find the amount of params we got */ |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
690 |
int nparam = sq_gettop(vm); |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
691 |
SQUserPointer ptr = NULL; |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
692 |
|
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
693 |
/* Get the real function pointer */ |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
694 |
sq_getuserdata(vm, nparam, &ptr, 0); |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
695 |
|
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
696 |
/* Delegate it to a template that can handle this specific function */ |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
697 |
return HelperT<Tmethod>::SQCall((Tcls *)NULL, *(Tmethod *)ptr, vm); |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
698 |
} |
5b93bc87cc5e
(svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents:
9529
diff
changeset
|
699 |
|
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
700 |
/** |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
701 |
* A general template for the destructor of SQ instances. This is needed |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
702 |
* here as it has to be in the same scope as DefSQConstructorCallback. |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
703 |
*/ |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
704 |
template <typename Tcls> |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
705 |
static SQInteger DefSQDestructorCallback(SQUserPointer p, SQInteger size) |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
706 |
{ |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
707 |
/* Remove the real instance too */ |
9679
788e083db48b
(svn r10625) [NoAI] -Fix: returning C++ classes, by creating a temp SQ class, had its problems, this should fix them all (double-frees, wrong scope, ..)
truelight
parents:
9658
diff
changeset
|
708 |
if (p != NULL) ((Tcls *)p)->Release(); |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
709 |
return 0; |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
710 |
} |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
711 |
|
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
712 |
/** |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
713 |
* A general template to handle creating of instance with any amount of |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
714 |
* params. It creates the instance in C++, and it sets all the needed |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
715 |
* settings in SQ to register the instance. |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
716 |
*/ |
9635
9ee82e091af7
(svn r10526) [NoAI] -Fix: a class with params for the constructor lost his instance when called from SQ (templates can be really useful ;))
truelight
parents:
9629
diff
changeset
|
717 |
template <typename Tcls, typename Tmethod, int Tnparam> |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
718 |
inline SQInteger DefSQConstructorCallback(HSQUIRRELVM vm) |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
719 |
{ |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
720 |
/* Create the real instance */ |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
721 |
Tcls *instance = HelperT<Tmethod>::SQConstruct((Tcls *)NULL, (Tmethod)NULL, vm); |
9635
9ee82e091af7
(svn r10526) [NoAI] -Fix: a class with params for the constructor lost his instance when called from SQ (templates can be really useful ;))
truelight
parents:
9629
diff
changeset
|
722 |
sq_setinstanceup(vm, -Tnparam, instance); |
9ee82e091af7
(svn r10526) [NoAI] -Fix: a class with params for the constructor lost his instance when called from SQ (templates can be really useful ;))
truelight
parents:
9629
diff
changeset
|
723 |
sq_setreleasehook(vm, -Tnparam, DefSQDestructorCallback<Tcls>); |
9679
788e083db48b
(svn r10625) [NoAI] -Fix: returning C++ classes, by creating a temp SQ class, had its problems, this should fix them all (double-frees, wrong scope, ..)
truelight
parents:
9658
diff
changeset
|
724 |
instance->AddRef(); |
9609
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
725 |
return 0; |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
726 |
} |
f0dbf5850145
(svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents:
9608
diff
changeset
|
727 |
|
9510
261d33fbabb8
(svn r9406) [NoAI] -Fix: made the detection of 'void' against 'non-void' functions for the class->SQ convertor via templates (as MSVC failed to understand the other method) (KUDr)
truelight
parents:
9499
diff
changeset
|
728 |
}; // namespace SQConvert |
9387
4255a0a2d272
(svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff
changeset
|
729 |
|
9424
90e9aa6326f3
(svn r9226) [NoAI] -Change: moved some ai/squirrel files to root
truelight
parents:
9387
diff
changeset
|
730 |
#endif /* SQUIRREL_HELPER_HPP */ |