diff --git a/include/sqrat/sqratTypes.h b/include/sqrat/sqratTypes.h index 5b999973..b340cefc 100644 --- a/include/sqrat/sqratTypes.h +++ b/include/sqrat/sqratTypes.h @@ -1242,6 +1242,11 @@ template struct ArgFwdFmtVar : Var { ArgFwdFmtVar(HSQUIRRELVM vm, SQInteger idx) : Var(vm, idx, true, Var::DropFuncPtr) {} }; +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/// Helper used to get the return type of a given functor used to forward arguments. +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +template using ArgFwdRet = typename std::result_of::type; + ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// Helper used to pop multiple variables from the stack and forward them to a functor. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -1255,8 +1260,8 @@ struct ArgFwd<> { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = false; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger /*idx*/, F f) { - f(vm); + template inline auto Call(HSQUIRRELVM vm, SQInteger /*idx*/, F f) { + return f(vm); } }; @@ -1268,9 +1273,9 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { ArgFwdFmtVar a1(vm, idx); - f(vm,a1.value); + return f(vm,a1.value); } }; @@ -1279,10 +1284,10 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); ArgFwdFmtVar a2(vm, idx); - f(vm,a1.value,a2.value); + return f(vm,a1.value,a2.value); } }; @@ -1291,11 +1296,11 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); ArgFwdFmtVar a3(vm, idx); - f(vm,a1.value,a2.value,a3.value); + return f(vm,a1.value,a2.value,a3.value); } }; @@ -1305,12 +1310,12 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); ArgFwdFmtVar a4(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value); + return f(vm,a1.value,a2.value,a3.value,a4.value); } }; @@ -1319,13 +1324,13 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); Var a4(vm, idx++); ArgFwdFmtVar a5(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value); } }; @@ -1334,14 +1339,14 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); Var a4(vm, idx++); Var a5(vm, idx++); ArgFwdFmtVar a6(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value); } }; @@ -1350,7 +1355,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1358,7 +1363,7 @@ struct ArgFwd { Var a5(vm, idx++); Var a6(vm, idx++); ArgFwdFmtVar a7(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value); } }; @@ -1367,7 +1372,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1376,7 +1381,7 @@ struct ArgFwd { Var a6(vm, idx++); Var a7(vm, idx++); ArgFwdFmtVar a8(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value); } }; @@ -1385,7 +1390,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1395,7 +1400,7 @@ struct ArgFwd { Var a7(vm, idx++); Var a8(vm, idx++); ArgFwdFmtVar a9(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value); } }; @@ -1404,7 +1409,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1415,7 +1420,7 @@ struct ArgFwd { Var a8(vm, idx++); Var a9(vm, idx++); ArgFwdFmtVar a10(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value); } }; @@ -1424,7 +1429,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1436,7 +1441,7 @@ struct ArgFwd { Var a9(vm, idx++); Var a10(vm, idx++); ArgFwdFmtVar a11(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value); } }; @@ -1445,7 +1450,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1458,7 +1463,7 @@ struct ArgFwd { Var a10(vm, idx++); Var a11(vm, idx++); ArgFwdFmtVar a12(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value,a12.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value,a12.value); } }; @@ -1467,7 +1472,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1481,7 +1486,7 @@ struct ArgFwd { Var a11(vm, idx++); Var a12(vm, idx++); ArgFwdFmtVar a13(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value,a12.value,a13.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value,a12.value,a13.value); } }; @@ -1490,7 +1495,7 @@ struct ArgFwd { // Used to tell whether the last template parameter is a StackStrF type static constexpr bool HASFMT = ArgFwdHasFmt::value; // Forward the arguments to a function object - template inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) { + template inline auto Call(HSQUIRRELVM vm, SQInteger idx, F f) { Var a1(vm, idx++); Var a2(vm, idx++); Var a3(vm, idx++); @@ -1505,7 +1510,7 @@ struct ArgFwd { Var a12(vm, idx++); Var a13(vm, idx++); ArgFwdFmtVar a14(vm, idx); - f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value,a12.value,a13.value,a14.value); + return f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value,a12.value,a13.value,a14.value); } };