src/squirrel_helper.hpp
author rubidium
Fri, 23 Nov 2007 16:59:30 +0000
branchnoai
changeset 9722 ebf0ece7d8f6
parent 9679 788e083db48b
child 9723 eee46cb39750
permissions -rw-r--r--
(svn r11503) [NoAI] -Sync: with trunk r11308:11502.
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>
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
     9
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    10
/**
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
    11
 * The Squirrel convert routines
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    12
 */
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
    13
namespace SQConvert {
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
    14
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
	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
    16
		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
    17
		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
    18
	};
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
    19
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
    20
	/**
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
    21
	 * 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
    22
	 */
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
    23
	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
    24
	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
    25
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
    26
	/**
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
    27
	 * 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
    28
	 */
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
	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
    30
	/* 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
    31
	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
    32
	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
    33
	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
    34
	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
    35
	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
    36
	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
    37
	/* 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
    38
	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
    39
	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
    40
	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
    41
	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
    42
	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
    43
	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
    44
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
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    46
	/**
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    47
	 * 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
    48
	 */
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    49
	template <typename T> class ForceType { };
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    50
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    51
	/**
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    52
	 * 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
    53
	 */
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    54
	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
    55
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
    56
	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
    57
	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
    58
	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
    59
	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
    60
	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
    61
	template <> inline int Return<int32>       (HSQUIRRELVM vm, int32 res)       { sq_pushinteger(vm, res); return 1; }
9629
66dde6412125 (svn r10350) [NoAI] -Sync with trunk r10194:10349
glx
parents: 9609
diff changeset
    62
	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
    63
	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
    64
	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
    65
	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
    66
	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
    67
	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
    68
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    69
	/**
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    70
	 * 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
    71
	 */
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    72
	template <typename T> static T GetParam(ForceType<T>, HSQUIRRELVM vm, int index);
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    73
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    74
	template <> inline uint8       GetParam(ForceType<uint8>       , HSQUIRRELVM vm, int index) { SQInteger     tmp; sq_getinteger    (vm, index, &tmp); return tmp; }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    75
	template <> inline uint16      GetParam(ForceType<uint16>      , HSQUIRRELVM vm, int index) { SQInteger     tmp; sq_getinteger    (vm, index, &tmp); return tmp; }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    76
	template <> inline uint32      GetParam(ForceType<uint32>      , HSQUIRRELVM vm, int index) { SQInteger     tmp; sq_getinteger    (vm, index, &tmp); return tmp; }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    77
	template <> inline int8        GetParam(ForceType<int8>        , HSQUIRRELVM vm, int index) { SQInteger     tmp; sq_getinteger    (vm, index, &tmp); return tmp; }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    78
	template <> inline int16       GetParam(ForceType<int16>       , HSQUIRRELVM vm, int index) { SQInteger     tmp; sq_getinteger    (vm, index, &tmp); return tmp; }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    79
	template <> inline int32       GetParam(ForceType<int32>       , HSQUIRRELVM vm, int index) { SQInteger     tmp; sq_getinteger    (vm, index, &tmp); return tmp; }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    80
	template <> inline bool        GetParam(ForceType<bool>        , HSQUIRRELVM vm, int index) { SQBool        tmp; sq_getbool       (vm, index, &tmp); return tmp != 0; }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    81
	template <> inline const char *GetParam(ForceType<const char *>, HSQUIRRELVM vm, int index) { const SQChar *tmp; sq_getstring     (vm, index, &tmp); return FS2OTTD(tmp); }
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
    82
	template <> inline void       *GetParam(ForceType<void *>      , HSQUIRRELVM vm, int index) { 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
    83
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
    84
	/**
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
    85
	* 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
    86
	* 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
    87
	* 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
    88
	*/
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
    89
	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
    90
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
    91
	/**
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
    92
	 * 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
    93
	 */
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
    94
	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
    95
	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
    96
		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
    97
		{
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
    98
			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
    99
		}
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
   100
	};
9437
28e0105114a4 (svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents: 9434
diff changeset
   101
28e0105114a4 (svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents: 9434
diff changeset
   102
	/**
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
   103
	 * 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
   104
	 */
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
   105
	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
   106
	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
   107
		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
   108
		{
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
   109
			(*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
   110
			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
   111
		}
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
   112
	};
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
   113
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
   114
	/**
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
   115
	 * 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
   116
	 */
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
   117
	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
   118
	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
   119
		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
   120
		{
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
   121
			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
   122
		}
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
   123
	};
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   124
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   125
	/**
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
   126
	 * 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
   127
	 */
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
   128
	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
   129
	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
   130
		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
   131
		{
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
			(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
   133
			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
   134
		}
9609
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   135
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   136
		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
   137
		{
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   138
			return new Tcls();
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   139
		}
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
   140
	};
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
	/**
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
	 * 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
   144
	 */
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
   145
	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
   146
	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
   147
		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
   148
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   149
			Tretval ret = (*func)(
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
   150
				GetParam(ForceType<Targ1>(), vm, 2)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   151
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   152
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   153
			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
   154
		}
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
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
   157
	/**
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
   158
	 * 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
   159
	 */
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
   160
	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
   161
	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
   162
		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
   163
		{
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
			(*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
   165
				GetParam(ForceType<Targ1>(), vm, 2)
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
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   167
			sq_remove(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
   168
			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
   169
		}
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
	};
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
   171
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
	/**
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
	 * 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
   174
	 */
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
	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
   176
	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
   177
		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
   178
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   179
			Tretval ret = (instance->*func)(
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
   180
				GetParam(ForceType<Targ1>(), vm, 2)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   181
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   182
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   183
			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
   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
	};
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
   186
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
   187
	/**
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
   188
	 * 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
   189
	 */
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
   190
	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
   191
	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
   192
		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
   193
		{
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
   194
			(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
   195
				GetParam(ForceType<Targ1>(), vm, 2)
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
   196
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   197
			sq_remove(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
   198
			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
   199
		}
9609
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   200
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   201
		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
   202
		{
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   203
			Tcls *inst = new Tcls(
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   204
				GetParam(ForceType<Targ1>(), vm, 2)
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   205
			);
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   206
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   207
			return inst;
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   208
		}
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
   209
	};
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
   210
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
   211
	/**
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
	 * 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
   213
	 */
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
	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
   215
	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
   216
		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
   217
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   218
			Tretval ret = (*func)(
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
   219
				GetParam(ForceType<Targ1>(), vm, 2),
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
				GetParam(ForceType<Targ2>(), vm, 3)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   221
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   222
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   223
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   224
			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
   225
		}
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
   226
	};
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   227
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   228
	/**
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
   229
	 * 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
   230
	 */
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
	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
   232
	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
   233
		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
   234
		{
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
   235
			(*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
   236
				GetParam(ForceType<Targ1>(), vm, 2),
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
				GetParam(ForceType<Targ2>(), vm, 3)
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
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   239
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   240
			sq_remove(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
   241
			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
   242
		}
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
   243
	};
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
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
   245
	/**
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
	 * 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
   247
	 */
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
   248
	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
   249
	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
   250
		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
   251
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   252
			Tretval ret = (instance->*func)(
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
   253
				GetParam(ForceType<Targ1>(), vm, 2),
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
   254
				GetParam(ForceType<Targ2>(), vm, 3)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   255
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   256
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   257
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   258
			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
   259
		}
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
   260
	};
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
   261
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
   262
	/**
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
   263
	 * 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
   264
	 */
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
   265
	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
   266
	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
   267
		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
   268
		{
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
   269
			(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
   270
				GetParam(ForceType<Targ1>(), vm, 2),
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
   271
				GetParam(ForceType<Targ2>(), vm, 3)
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
   272
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   273
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   274
			sq_remove(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
   275
			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
   276
		}
9609
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   277
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   278
		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
   279
		{
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   280
			Tcls *inst = new Tcls(
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   281
				GetParam(ForceType<Targ1>(), vm, 2),
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   282
				GetParam(ForceType<Targ2>(), vm, 3)
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   283
			);
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   284
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   285
			return inst;
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   286
		}
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
   287
	};
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
   288
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
   289
	/**
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
	 * 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
   291
	 */
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
   292
	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
   293
	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
   294
		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
   295
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   296
			Tretval ret = (*func)(
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
   297
				GetParam(ForceType<Targ1>(), vm, 2),
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
				GetParam(ForceType<Targ2>(), vm, 3),
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
				GetParam(ForceType<Targ3>(), vm, 4)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   300
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   301
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   302
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   303
			sq_remove(vm, 4);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   304
			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
   305
		}
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
   306
	};
9437
28e0105114a4 (svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents: 9434
diff changeset
   307
28e0105114a4 (svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
truelight
parents: 9434
diff changeset
   308
	/**
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
   309
	 * 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
   310
	 */
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
   311
	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
   312
	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
   313
		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
   314
		{
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
			(*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
   316
				GetParam(ForceType<Targ1>(), vm, 2),
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
				GetParam(ForceType<Targ2>(), vm, 3),
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
   318
				GetParam(ForceType<Targ3>(), vm, 4)
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
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   320
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   321
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   322
			sq_remove(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
   323
			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
   324
		}
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
	};
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
   326
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
   327
	/**
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
   328
	 * 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
   329
	 */
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
   330
	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
   331
	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
   332
		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
   333
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   334
			Tretval ret = (instance->*func)(
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
   335
				GetParam(ForceType<Targ1>(), vm, 2),
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
   336
				GetParam(ForceType<Targ2>(), vm, 3),
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
				GetParam(ForceType<Targ3>(), vm, 4)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   338
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   339
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   340
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   341
			sq_remove(vm, 4);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   342
			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
   343
		}
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
	};
9480
d071f885f918 (svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents: 9437
diff changeset
   345
d071f885f918 (svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents: 9437
diff changeset
   346
	/**
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
   347
	 * 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
   348
	 */
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
   349
	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
   350
	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
   351
		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
   352
		{
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
   353
			(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
   354
				GetParam(ForceType<Targ1>(), vm, 2),
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
				GetParam(ForceType<Targ2>(), vm, 3),
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
   356
				GetParam(ForceType<Targ3>(), vm, 4)
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
   357
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   358
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   359
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   360
			sq_remove(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
   361
			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
   362
		}
9609
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   363
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   364
		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
   365
		{
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   366
			Tcls *inst = new Tcls(
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   367
				GetParam(ForceType<Targ1>(), vm, 2),
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   368
				GetParam(ForceType<Targ2>(), vm, 3),
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   369
				GetParam(ForceType<Targ3>(), vm, 4)
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   370
			);
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   371
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   372
			return inst;
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   373
		}
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
   374
	};
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
   375
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
	/**
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
   377
	 * 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
   378
	 */
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
	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
   380
	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
   381
		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
   382
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   383
			Tretval ret = (*func)(
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
   384
				GetParam(ForceType<Targ1>(), vm, 2),
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
   385
				GetParam(ForceType<Targ2>(), vm, 3),
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
   386
				GetParam(ForceType<Targ3>(), vm, 4),
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
   387
				GetParam(ForceType<Targ4>(), vm, 5)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   388
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   389
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   390
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   391
			sq_remove(vm, 4);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   392
			sq_remove(vm, 5);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   393
			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
   394
		}
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
   395
	};
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
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
	/**
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
	 * 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
   399
	 */
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
   400
	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
   401
	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
   402
		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
   403
		{
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
   404
			(*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
   405
				GetParam(ForceType<Targ1>(), vm, 2),
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
   406
				GetParam(ForceType<Targ2>(), vm, 3),
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
				GetParam(ForceType<Targ3>(), vm, 4),
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
				GetParam(ForceType<Targ4>(), vm, 5)
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
   409
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   410
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   411
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   412
			sq_remove(vm, 4);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   413
			sq_remove(vm, 5);
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
   414
			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
   415
		}
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
   416
	};
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
   417
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
   418
	/**
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
   419
	 * 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
   420
	 */
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
	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
   422
	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
   423
		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
   424
		{
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   425
			Tretval ret = (instance->*func)(
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
   426
				GetParam(ForceType<Targ1>(), vm, 2),
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
				GetParam(ForceType<Targ2>(), vm, 3),
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
				GetParam(ForceType<Targ3>(), vm, 4),
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
				GetParam(ForceType<Targ4>(), vm, 5)
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   430
			);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   431
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   432
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   433
			sq_remove(vm, 4);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   434
			sq_remove(vm, 5);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   435
			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
   436
		}
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
   437
	};
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
   438
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
   439
	/**
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
   440
	 * 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
   441
	 */
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
   442
	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
   443
	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
   444
		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
   445
		{
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
			(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
   447
				GetParam(ForceType<Targ1>(), vm, 2),
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
				GetParam(ForceType<Targ2>(), vm, 3),
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
   449
				GetParam(ForceType<Targ3>(), vm, 4),
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
				GetParam(ForceType<Targ4>(), vm, 5)
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
   451
			);
9656
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   452
			sq_remove(vm, 2);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   453
			sq_remove(vm, 3);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   454
			sq_remove(vm, 4);
ddb4260f3051 (svn r10558) [NoAI] -Fix: don't use free'd memory (tnx glx for tracing!!)
truelight
parents: 9651
diff changeset
   455
			sq_remove(vm, 5);
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
   456
			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
   457
		}
9609
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   458
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   459
		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
   460
		{
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   461
			Tcls *inst = new Tcls(
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   462
				GetParam(ForceType<Targ1>(), vm, 2),
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   463
				GetParam(ForceType<Targ2>(), vm, 3),
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   464
				GetParam(ForceType<Targ3>(), vm, 4),
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   465
				GetParam(ForceType<Targ4>(), vm, 5)
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   466
			);
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   467
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   468
			return inst;
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   469
		}
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
   470
	};
9480
d071f885f918 (svn r9329) [NoAI] -Fix: add AIRoad() for Squirrel
truelight
parents: 9437
diff changeset
   471
9658
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   472
	/**
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   473
	 * 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
   474
	 */
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   475
	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
   476
	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
   477
		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
   478
		{
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   479
			Tretval ret = (*func)(
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   480
				GetParam(ForceType<Targ1>(), vm, 2),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   481
				GetParam(ForceType<Targ2>(), vm, 3),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   482
				GetParam(ForceType<Targ3>(), vm, 4),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   483
				GetParam(ForceType<Targ4>(), vm, 5),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   484
				GetParam(ForceType<Targ5>(), vm, 6)
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   485
			);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   486
			sq_remove(vm, 2);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   487
			sq_remove(vm, 3);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   488
			sq_remove(vm, 4);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   489
			sq_remove(vm, 5);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   490
			sq_remove(vm, 6);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   491
			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
   492
		}
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   493
	};
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   494
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   495
	/**
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   496
	 * 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
   497
	 */
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   498
	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
   499
	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
   500
		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
   501
		{
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   502
			(*func)(
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   503
				GetParam(ForceType<Targ1>(), vm, 2),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   504
				GetParam(ForceType<Targ2>(), vm, 3),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   505
				GetParam(ForceType<Targ3>(), vm, 4),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   506
				GetParam(ForceType<Targ4>(), vm, 5),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   507
				GetParam(ForceType<Targ5>(), vm, 6)
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   508
			);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   509
			sq_remove(vm, 2);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   510
			sq_remove(vm, 3);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   511
			sq_remove(vm, 4);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   512
			sq_remove(vm, 5);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   513
			sq_remove(vm, 6);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   514
			return 0;
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   515
		}
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   516
	};
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   517
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   518
	/**
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   519
	 * 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
   520
	 */
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   521
	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
   522
	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
   523
		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
   524
		{
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   525
			Tretval ret = (instance->*func)(
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   526
				GetParam(ForceType<Targ1>(), vm, 2),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   527
				GetParam(ForceType<Targ2>(), vm, 3),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   528
				GetParam(ForceType<Targ3>(), vm, 4),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   529
				GetParam(ForceType<Targ4>(), vm, 5),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   530
				GetParam(ForceType<Targ5>(), vm, 6)
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
			sq_remove(vm, 2);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   533
			sq_remove(vm, 3);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   534
			sq_remove(vm, 4);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   535
			sq_remove(vm, 5);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   536
			sq_remove(vm, 6);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   537
			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
   538
		}
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   539
	};
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   540
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   541
	/**
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   542
	 * 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
   543
	 */
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   544
	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
   545
	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
   546
		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
   547
		{
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   548
			(instance->*func)(
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   549
				GetParam(ForceType<Targ1>(), vm, 2),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   550
				GetParam(ForceType<Targ2>(), vm, 3),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   551
				GetParam(ForceType<Targ3>(), vm, 4),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   552
				GetParam(ForceType<Targ4>(), vm, 5),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   553
				GetParam(ForceType<Targ5>(), vm, 6)
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
			sq_remove(vm, 2);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   556
			sq_remove(vm, 3);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   557
			sq_remove(vm, 4);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   558
			sq_remove(vm, 5);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   559
			sq_remove(vm, 6);
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   560
			return 0;
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   561
		}
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   562
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   563
		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
   564
		{
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   565
			Tcls *inst = new Tcls(
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   566
				GetParam(ForceType<Targ1>(), vm, 2),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   567
				GetParam(ForceType<Targ2>(), vm, 3),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   568
				GetParam(ForceType<Targ3>(), vm, 4),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   569
				GetParam(ForceType<Targ4>(), vm, 5),
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   570
				GetParam(ForceType<Targ5>(), vm, 6)
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
			return inst;
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
	};
e7675771bca4 (svn r10565) [NoAI] -Add: allow giving width, height and radius to check for cargo acceptance
truelight
parents: 9656
diff changeset
   576
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
   577
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
   578
	/**
9530
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   579
	 * 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
   580
	 *  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
   581
	 *  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
   582
	 */
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
   583
	template <typename Tcls, typename Tmethod>
9530
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   584
	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
   585
	{
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   586
		/* 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
   587
		int nparam = sq_gettop(vm);
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   588
		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
   589
		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
   590
		HSQOBJECT instance;
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9510
diff changeset
   591
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9510
diff changeset
   592
		/* 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
   593
		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
   594
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9510
diff changeset
   595
		/* 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
   596
		sq_pushroottable(vm);
9531
6a2e35738593 (svn r9452) [NoAI] -Fix r9450: compilation with _UNICODE was broken
glx
parents: 9530
diff changeset
   597
		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
   598
		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
   599
		sq_pushobject(vm, instance);
9531
6a2e35738593 (svn r9452) [NoAI] -Fix r9450: compilation with _UNICODE was broken
glx
parents: 9530
diff changeset
   600
		if (sq_instanceof(vm) != SQTrue) return sq_throwerror(vm, _SC("class method is non-static"));
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9510
diff changeset
   601
		sq_settop(vm, nparam);
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   602
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   603
		/* 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
   604
		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
   605
		/* Get the real function pointer */
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   606
		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
   607
		if (real_instance == NULL) return sq_throwerror(vm, _SC("couldn't detect real instance of class for non-static call"));
9529
5f26f4bc574b (svn r9450) [NoAI] -Fix: don't allow static-method calls from SQ to non-static functions
truelight
parents: 9510
diff changeset
   608
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
   609
		/* 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
   610
		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
   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
9530
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   613
	/**
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   614
	 * 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
   615
	 *  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
   616
	 *  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
   617
	 */
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   618
	template <typename Tcls, typename Tmethod>
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   619
	inline SQInteger DefSQStaticCallback(HSQUIRRELVM vm)
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   620
	{
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   621
		/* 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
   622
		int nparam = sq_gettop(vm);
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   623
		SQUserPointer ptr = NULL;
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   624
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   625
		/* Get the real function pointer */
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   626
		sq_getuserdata(vm, nparam, &ptr, 0);
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   627
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   628
		/* 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
   629
		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
   630
	}
5b93bc87cc5e (svn r9451) [NoAI] -Add: allow static and non-static members for SQ
truelight
parents: 9529
diff changeset
   631
9609
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   632
	/**
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   633
	 * 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
   634
	 *  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
   635
	 */
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   636
	template <typename Tcls>
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   637
	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
   638
	{
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   639
		/* 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
   640
		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
   641
		return 0;
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   642
	}
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   643
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   644
	/**
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   645
	 * 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
   646
	 *  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
   647
	 *  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
   648
	 */
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
   649
	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
   650
	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
   651
	{
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   652
		/* Create the real instance */
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   653
		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
   654
		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
   655
		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
   656
		instance->AddRef();
9609
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   657
		return 0;
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   658
	}
f0dbf5850145 (svn r9767) [NoAI] -Add: add support for params in the constructor (via C++ templates)
truelight
parents: 9608
diff changeset
   659
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
   660
}; // namespace SQConvert
9387
4255a0a2d272 (svn r9179) [NoAI] -Add: added templates that makes adding classes to squirrel very easy
truelight
parents:
diff changeset
   661
9424
90e9aa6326f3 (svn r9226) [NoAI] -Change: moved some ai/squirrel files to root
truelight
parents: 9387
diff changeset
   662
#endif /* SQUIRREL_HELPER_HPP */