--- a/src/squirrel_helper.hpp Tue Mar 20 00:12:35 2007 +0000
+++ b/src/squirrel_helper.hpp Tue Mar 20 00:14:29 2007 +0000
@@ -28,7 +28,7 @@
template <typename T> static T GetParam(ForceType<T>, HSQUIRRELVM vm, int index);
/**
- * The real C++ caller for function with a return value and 0 params.
+ * The real C++ caller for method with a return value and 0 params.
*/
template <typename CL, typename RT>
static int SQCall(CL *instance, RT (CL::*func)(), HSQUIRRELVM vm)
@@ -37,7 +37,16 @@
}
/**
- * The real C++ caller for function with no return value and 0 params.
+ * The real C++ caller for function with a return value and 0 params.
+ */
+ template <typename CL, typename RT>
+ static int SQCall(CL *instance, RT (*func)(), HSQUIRRELVM vm)
+ {
+ return Return(vm, (*func)());
+ }
+
+ /**
+ * The real C++ caller for method with no return value and 0 params.
*/
template <typename CL>
static int SQCall(CL *instance, void (CL::*func)(), HSQUIRRELVM vm)
@@ -47,7 +56,17 @@
}
/**
- * The real C++ caller for function with a return value and 1 param.
+ * The real C++ caller for function with no return value and 0 params.
+ */
+ template <typename CL>
+ static int SQCall(CL *instance, void (*func)(), HSQUIRRELVM vm)
+ {
+ (*func)();
+ return 0;
+ }
+
+ /**
+ * The real C++ caller for method with a return value and 1 param.
*/
template <typename CL, typename RT, typename P1>
static int SQCall(CL *instance, RT (CL::*func)(P1), HSQUIRRELVM vm)
@@ -58,7 +77,18 @@
}
/**
- * The real C++ caller for function with no return value and 1 param.
+ * The real C++ caller for function with a return value and 1 param.
+ */
+ template <typename CL, typename RT, typename P1>
+ static int SQCall(CL *instance, RT (*func)(P1), HSQUIRRELVM vm)
+ {
+ return Return(vm, (*func)(
+ GetParam(ForceType<P1>(), vm, 2)
+ ));
+ }
+
+ /**
+ * The real C++ caller for method with no return value and 1 param.
*/
template <typename CL, typename P1>
static int SQCall(CL *instance, void (CL::*func)(P1), HSQUIRRELVM vm)
@@ -70,7 +100,19 @@
}
/**
- * The real C++ caller for function with a return value and 2 params.
+ * The real C++ caller for function with no return value and 1 param.
+ */
+ template <typename CL, typename P1>
+ static int SQCall(CL *instance, void (*func)(P1), HSQUIRRELVM vm)
+ {
+ (*func)(
+ GetParam(ForceType<P1>(), vm, 2)
+ );
+ return 0;
+ }
+
+ /**
+ * The real C++ caller for method with a return value and 2 params.
*/
template <typename CL, typename RT, typename P1, typename P2>
static int SQCall(CL *instance, RT (CL::*func)(P1, P2), HSQUIRRELVM vm)
@@ -82,7 +124,19 @@
}
/**
- * The real C++ caller for function with no return value and 2 params.
+ * The real C++ caller for function with a return value and 2 params.
+ */
+ template <typename CL, typename RT, typename P1, typename P2>
+ static int SQCall(CL *instance, RT (*func)(P1, P2), HSQUIRRELVM vm)
+ {
+ return Return(vm, (*func)(
+ GetParam(ForceType<P1>(), vm, 2),
+ GetParam(ForceType<P2>(), vm, 3)
+ ));
+ }
+
+ /**
+ * The real C++ caller for method with no return value and 2 params.
*/
template <typename CL, typename P1, typename P2>
static int SQCall(CL *instance, void (CL::*func)(P1, P2), HSQUIRRELVM vm)
@@ -95,7 +149,20 @@
}
/**
- * The real C++ caller for function with a return value and 3 params.
+ * The real C++ caller for function with no return value and 2 params.
+ */
+ template <typename CL, typename P1, typename P2>
+ static int SQCall(CL *instance, void (*func)(P1, P2), HSQUIRRELVM vm)
+ {
+ (*func)(
+ GetParam(ForceType<P1>(), vm, 2),
+ GetParam(ForceType<P2>(), vm, 3)
+ );
+ return 0;
+ }
+
+ /**
+ * The real C++ caller for method with a return value and 3 params.
*/
template <typename CL, typename RT, typename P1, typename P2, typename P3>
static int SQCall(CL *instance, RT (CL::*func)(P1, P2, P3), HSQUIRRELVM vm)
@@ -108,7 +175,20 @@
}
/**
- * The real C++ caller for function with no return value and 3 params.
+ * The real C++ caller for function with a return value and 3 params.
+ */
+ template <typename CL, typename RT, typename P1, typename P2, typename P3>
+ static int SQCall(CL *instance, RT (*func)(P1, P2, P3), HSQUIRRELVM vm)
+ {
+ return Return(vm, (*func)(
+ GetParam(ForceType<P1>(), vm, 2),
+ GetParam(ForceType<P2>(), vm, 3),
+ GetParam(ForceType<P3>(), vm, 4)
+ ));
+ }
+
+ /**
+ * The real C++ caller for method with no return value and 3 params.
*/
template <typename CL, typename P1, typename P2, typename P3>
static int SQCall(CL *instance, void (CL::*func)(P1, P2, P3), HSQUIRRELVM vm)
@@ -122,7 +202,21 @@
}
/**
- * The real C++ caller for function with a return value and 4 params.
+ * The real C++ caller for function with no return value and 3 params.
+ */
+ template <typename CL, typename P1, typename P2, typename P3>
+ static int SQCall(CL *instance, void (*func)(P1, P2, P3), HSQUIRRELVM vm)
+ {
+ (*func)(
+ GetParam(ForceType<P1>(), vm, 2),
+ GetParam(ForceType<P2>(), vm, 3),
+ GetParam(ForceType<P3>(), vm, 4)
+ );
+ return 0;
+ }
+
+ /**
+ * The real C++ caller for method with a return value and 4 params.
*/
template <typename CL, typename RT, typename P1, typename P2, typename P3, typename P4>
static int SQCall(CL *instance, RT (CL::*func)(P1, P2, P3, P4), HSQUIRRELVM vm)
@@ -136,7 +230,21 @@
}
/**
- * The real C++ caller for function with no return value and 4 params.
+ * The real C++ caller for function with a return value and 4 params.
+ */
+ template <typename CL, typename RT, typename P1, typename P2, typename P3, typename P4>
+ static int SQCall(CL *instance, RT (*func)(P1, P2, P3, P4), HSQUIRRELVM vm)
+ {
+ return Return(vm, (*func)(
+ GetParam(ForceType<P1>(), vm, 2),
+ GetParam(ForceType<P2>(), vm, 3),
+ GetParam(ForceType<P3>(), vm, 4),
+ GetParam(ForceType<P3>(), vm, 5)
+ ));
+ }
+
+ /**
+ * The real C++ caller for method with no return value and 4 params.
*/
template <typename CL, typename P1, typename P2, typename P3, typename P4>
static int SQCall(CL *instance, void (CL::*func)(P1, P2, P3, P4), HSQUIRRELVM vm)
@@ -151,6 +259,21 @@
}
/**
+ * The real C++ caller for function with no return value and 4 params.
+ */
+ template <typename CL, typename P1, typename P2, typename P3, typename P4>
+ static int SQCall(CL *instance, void (*func)(P1, P2, P3, P4), HSQUIRRELVM vm)
+ {
+ (*func)(
+ GetParam(ForceType<P1>(), vm, 2),
+ GetParam(ForceType<P2>(), vm, 3),
+ GetParam(ForceType<P3>(), vm, 4),
+ GetParam(ForceType<P3>(), vm, 5)
+ );
+ return 0;
+ }
+
+ /**
* A general template for all callback functions from Squirrel.
* In here the function_proc is recovered, and the SQCall is called that
* can handle this exact amount of params.