(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions noai
authortruelight
Fri, 16 Mar 2007 09:57:39 +0000
branchnoai
changeset 9437 28e0105114a4
parent 9436 e28503f827a5
child 9438 c9a59f791321
(svn r9248) [NoAI] -Add: added templates for void func() to SQ functions
src/squirrel_helper.hpp
--- a/src/squirrel_helper.hpp	Fri Mar 16 09:44:13 2007 +0000
+++ b/src/squirrel_helper.hpp	Fri Mar 16 09:57:39 2007 +0000
@@ -37,6 +37,16 @@
 	}
 
 	/**
+	 * The real C++ caller for function with no return value and 0 params.
+	 */
+	template <typename CL>
+	static int SQCall(CL *instance, void (CL::*func)(), HSQUIRRELVM vm)
+	{
+		(instance->*func)();
+		return 0;
+	}
+
+	/**
 	 * The real C++ caller for function with a return value and 1 param.
 	 */
 	template <typename CL, typename RT, typename P1>
@@ -48,6 +58,18 @@
 	}
 
 	/**
+	 * The real C++ caller for function with no return value and 1 param.
+	 */
+	template <typename CL, typename P1>
+	static int SQCall(CL *instance, void (CL::*func)(P1), HSQUIRRELVM vm)
+	{
+		(instance->*func)(
+						GetParam(ForceType<P1>(), vm, 2)
+					);
+		return 0;
+	}
+
+	/**
 	 * The real C++ caller for function with a return value and 2 params.
 	 */
 	template <typename CL, typename RT, typename P1, typename P2>
@@ -60,6 +82,19 @@
 	}
 
 	/**
+	 * 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 (CL::*func)(P1, P2), HSQUIRRELVM vm)
+	{
+		(instance->*func)(
+						GetParam(ForceType<P1>(), vm, 2),
+						GetParam(ForceType<P2>(), vm, 3)
+					);
+		return 0;
+	}
+
+	/**
 	 * The real C++ caller for function with a return value and 3 params.
 	 */
 	template <typename CL, typename RT, typename P1, typename P2, typename P3>
@@ -73,6 +108,20 @@
 	}
 
 	/**
+	 * 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 (CL::*func)(P1, P2, P3), HSQUIRRELVM vm)
+	{
+		(instance->*func)(
+						GetParam(ForceType<P1>(), vm, 2),
+						GetParam(ForceType<P2>(), vm, 3),
+						GetParam(ForceType<P3>(), vm, 4)
+					);
+		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.