1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-02-21 20:27:13 +01:00

Refactor the binding library even further to reduce code size and complexity.

This commit is contained in:
Sandu Liviu Catalin 2018-07-30 21:44:04 +03:00
parent ecca09d6ce
commit 0deb209e7b
4 changed files with 298 additions and 454 deletions

View File

@ -46,18 +46,15 @@ namespace Sqrat {
// //
template <class R> struct SqGlobalProxy { template <class R> struct SqGlobalProxy {
template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) { template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) {
ArgPop<A...> a(vm, idx); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sq_gettop(vm) == idx - 1 + static_cast< SQInteger >(sizeof...(A))))) { a.Call(vm, idx, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R(*M)(A...); typedef R(*M)(A...);
M* method; M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr); sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr);
R ret = (*method)(a...); R ret = (*method)(a...);
PushVar(vm, ret); PushVar(vm, ret);
}); });
return 1; return SQ_FAILED(a.mRes) ? a.mRes : 1;
} }
}; };
@ -67,18 +64,15 @@ template <class R> struct SqGlobalProxy {
template <class R> struct SqGlobalProxy<R&> { template <class R> struct SqGlobalProxy<R&> {
template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) { template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) {
ArgPop<A...> a(vm, idx); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sq_gettop(vm) == idx - 1 + static_cast< SQInteger >(sizeof...(A))))) { a.Call(vm, idx, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R&(*M)(A...); typedef R&(*M)(A...);
M* method; M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr); sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr);
R& ret = (*method)(a...); R& ret = (*method)(a...);
PushVarR(vm, ret); PushVarR(vm, ret);
}); });
return 1; return SQ_FAILED(a.mRes) ? a.mRes : 1;
} }
}; };
@ -88,27 +82,24 @@ template <class R> struct SqGlobalProxy<R&> {
template <> struct SqGlobalProxy<void> { template <> struct SqGlobalProxy<void> {
template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) { template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) {
ArgPop<A...> a(vm, idx); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sq_gettop(vm) == idx - 1 + static_cast< SQInteger >(sizeof...(A))))) { a.Call(vm, idx, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef void(*M)(A...); typedef void(*M)(A...);
M* method; M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr); sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr);
(*method)(a...); (*method)(a...);
}); });
return 0; return SQ_FAILED(a.mRes) ? a.mRes : 0;
} }
}; };
template<bool> struct SqGlobalParamCheck { template<bool> struct SqGlobalParamCheck {
static inline bool Invalid(SQInteger top, SQInteger count) { static inline bool Invalid(SQInteger top, SQInteger count) noexcept {
return top != count; return top != count;
} }
}; };
template<> struct SqGlobalParamCheck<true> { template<> struct SqGlobalParamCheck<true> {
static inline bool Invalid(SQInteger top, SQInteger count) { static inline bool Invalid(SQInteger top, SQInteger count) noexcept {
return top < (count - 1); return top < (count - 1);
} }
}; };
@ -122,7 +113,7 @@ template <class R> struct SqGlobal {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -130,6 +121,8 @@ template <class R> struct SqGlobal {
return SqGlobalProxy<R>::template Run<A...>(vm, startIdx); return SqGlobalProxy<R>::template Run<A...>(vm, startIdx);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };
@ -146,7 +139,7 @@ template <class R> struct SqGlobal<R&> {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -154,6 +147,8 @@ template <class R> struct SqGlobal<R&> {
return SqGlobalProxy<R&>::template Run<A...>(vm, startIdx); return SqGlobalProxy<R&>::template Run<A...>(vm, startIdx);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };
@ -170,7 +165,7 @@ template <> struct SqGlobal<void> {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -178,6 +173,8 @@ template <> struct SqGlobal<void> {
return SqGlobalProxy<void>::Run<A...>(vm, startIdx); return SqGlobalProxy<void>::Run<A...>(vm, startIdx);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };

View File

@ -46,11 +46,8 @@ namespace Sqrat {
// //
template <class C,class R> struct SqMemberProxy { template <class C,class R> struct SqMemberProxy {
template <class... A> static SQInteger Run(HSQUIRRELVM vm) noexcept { template <class... A> static SQInteger Run(HSQUIRRELVM vm) noexcept {
ArgPop<A...> a(vm, 2); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sizeof...(A) == 0 && sq_gettop(vm) == 2))) { a.Call(vm, 2, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R(C::*M)(A...); typedef R(C::*M)(A...);
C* inst = Var<C*>(vm, 1).value; C* inst = Var<C*>(vm, 1).value;
M* methodPtr; M* methodPtr;
@ -59,14 +56,11 @@ template <class C,class R> struct SqMemberProxy {
R ret = (inst->*method)(a...); R ret = (inst->*method)(a...);
PushVar(vm, ret); PushVar(vm, ret);
}); });
return 1; return SQ_FAILED(a.mRes) ? a.mRes : 1;
} }
template <class... A> static SQInteger RunC(HSQUIRRELVM vm) noexcept { template <class... A> static SQInteger RunC(HSQUIRRELVM vm) noexcept {
ArgPop<A...> a(vm, 2); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sizeof...(A) == 0 && sq_gettop(vm) == 2))) { a.Call(vm, 2, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R(C::*M)(A...) const; typedef R(C::*M)(A...) const;
C* inst = Var<C*>(vm, 1).value; C* inst = Var<C*>(vm, 1).value;
M* methodPtr; M* methodPtr;
@ -75,7 +69,7 @@ template <class C,class R> struct SqMemberProxy {
R ret = (inst->*method)(a...); R ret = (inst->*method)(a...);
PushVar(vm, ret); PushVar(vm, ret);
}); });
return 1; return SQ_FAILED(a.mRes) ? a.mRes : 1;
} }
}; };
@ -85,11 +79,8 @@ template <class C,class R> struct SqMemberProxy {
template <class C, class R> struct SqMemberProxy<C,R&> { template <class C, class R> struct SqMemberProxy<C,R&> {
template <class... A> static SQInteger Run(HSQUIRRELVM vm) noexcept { template <class... A> static SQInteger Run(HSQUIRRELVM vm) noexcept {
ArgPop<A...> a(vm, 2); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sizeof...(A) == 0 && sq_gettop(vm) == 2))) { a.Call(vm, 2, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R&(C::*M)(A...); typedef R&(C::*M)(A...);
C* inst = Var<C*>(vm, 1).value; C* inst = Var<C*>(vm, 1).value;
M* methodPtr; M* methodPtr;
@ -98,14 +89,11 @@ template <class C, class R> struct SqMemberProxy<C,R&> {
R& ret = (inst->*method)(a...); R& ret = (inst->*method)(a...);
PushVarR(vm, ret); PushVarR(vm, ret);
}); });
return 1; return SQ_FAILED(a.mRes) ? a.mRes : 1;
} }
template <class... A> static SQInteger RunC(HSQUIRRELVM vm) noexcept { template <class... A> static SQInteger RunC(HSQUIRRELVM vm) noexcept {
ArgPop<A...> a(vm, 2); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sizeof...(A) == 0 && sq_gettop(vm) == 2))) { a.Call(vm, 2, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R&(C::*M)(A...) const; typedef R&(C::*M)(A...) const;
C* inst = Var<C*>(vm, 1).value; C* inst = Var<C*>(vm, 1).value;
M* methodPtr; M* methodPtr;
@ -114,7 +102,7 @@ template <class C, class R> struct SqMemberProxy<C,R&> {
R& ret = (inst->*method)(a...); R& ret = (inst->*method)(a...);
PushVarR(vm, ret); PushVarR(vm, ret);
}); });
return 1; return SQ_FAILED(a.mRes) ? a.mRes : 1;
} }
}; };
@ -124,11 +112,8 @@ template <class C, class R> struct SqMemberProxy<C,R&> {
template <class C> struct SqMemberProxy<C, void> { template <class C> struct SqMemberProxy<C, void> {
template <class... A> static SQInteger Run(HSQUIRRELVM vm) noexcept { template <class... A> static SQInteger Run(HSQUIRRELVM vm) noexcept {
ArgPop<A...> a(vm, 2); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sizeof...(A) == 0 && sq_gettop(vm) == 2))) { a.Call(vm, 2, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef void(C::*M)(A...); typedef void(C::*M)(A...);
C* inst = Var<C*>(vm, 1).value; C* inst = Var<C*>(vm, 1).value;
M* methodPtr; M* methodPtr;
@ -136,14 +121,11 @@ template <class C> struct SqMemberProxy<C, void> {
M method = *methodPtr; M method = *methodPtr;
(inst->*method)(a...); (inst->*method)(a...);
}); });
return 0; return SQ_FAILED(a.mRes) ? a.mRes : 0;
} }
template <class... A> static SQInteger RunC(HSQUIRRELVM vm) noexcept { template <class... A> static SQInteger RunC(HSQUIRRELVM vm) noexcept {
ArgPop<A...> a(vm, 2); ArgFwd<A...> a{SQ_OK};
if (SQ_FAILED(a.Proc(sizeof...(A) == 0 && sq_gettop(vm) == 2))) { a.Call(vm, 2, [](HSQUIRRELVM vm, A... a) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef void(C::*M)(A...) const; typedef void(C::*M)(A...) const;
C* inst = Var<C*>(vm, 1).value; C* inst = Var<C*>(vm, 1).value;
M* methodPtr; M* methodPtr;
@ -151,17 +133,17 @@ template <class C> struct SqMemberProxy<C, void> {
M method = *methodPtr; M method = *methodPtr;
(inst->*method)(a...); (inst->*method)(a...);
}); });
return 0; return SQ_FAILED(a.mRes) ? a.mRes : 0;
} }
}; };
template<bool> struct SqMemberParamCheck { template<bool> struct SqMemberParamCheck {
static inline bool Invalid(SQInteger top, SQInteger count) { static inline bool Invalid(SQInteger top, SQInteger count) noexcept {
return top != count; return top != count;
} }
}; };
template<> struct SqMemberParamCheck<true> { template<> struct SqMemberParamCheck<true> {
static inline bool Invalid(SQInteger top, SQInteger count) { static inline bool Invalid(SQInteger top, SQInteger count) noexcept {
return top < count; return top < count;
} }
}; };
@ -175,7 +157,7 @@ template <class C,class R> struct SqMember {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -183,6 +165,8 @@ template <class C,class R> struct SqMember {
return SqMemberProxy<C, R>:: template Run<A...>(vm); return SqMemberProxy<C, R>:: template Run<A...>(vm);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };
@ -192,7 +176,7 @@ template <class C,class R> struct SqMember {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -200,6 +184,8 @@ template <class C,class R> struct SqMember {
return SqMemberProxy<C,R>::template RunC<A...>(vm); return SqMemberProxy<C,R>::template RunC<A...>(vm);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };
@ -216,7 +202,7 @@ template <class C, class R> struct SqMember<C,R&> {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -224,6 +210,8 @@ template <class C, class R> struct SqMember<C,R&> {
return SqMemberProxy<C,R&>::template Run<A...>(vm); return SqMemberProxy<C,R&>::template Run<A...>(vm);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };
@ -233,7 +221,7 @@ template <class C, class R> struct SqMember<C,R&> {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -241,6 +229,8 @@ template <class C, class R> struct SqMember<C,R&> {
return SqMemberProxy<C,R&>::template RunC<A...>(vm); return SqMemberProxy<C,R&>::template RunC<A...>(vm);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };
@ -258,7 +248,7 @@ template <class C> struct SqMember<C, void> {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -266,6 +256,8 @@ template <class C> struct SqMember<C, void> {
return SqMemberProxy<C, void>::template Run<A...>(vm); return SqMemberProxy<C, void>::template Run<A...>(vm);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };
@ -275,7 +267,7 @@ template <class C> struct SqMember<C, void> {
return +[](HSQUIRRELVM vm) noexcept -> SQInteger { return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING) #if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && if (!SQRAT_CONST_CONDITION(overloaded) &&
SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) { SqGlobalParamCheck< ArgFwd<A...>::HASFMT >::Invalid(sq_gettop(vm), 2 + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters")); return sq_throwerror(vm, _SC("wrong number of parameters"));
} }
#endif #endif
@ -283,6 +275,8 @@ template <class C> struct SqMember<C, void> {
return SqMemberProxy<C,void>::template RunC<A...>(vm); return SqMemberProxy<C,void>::template RunC<A...>(vm);
} catch (const Exception& e) { } catch (const Exception& e) {
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
} }
SQ_UNREACHABLE SQ_UNREACHABLE
}; };

View File

@ -1177,52 +1177,40 @@ inline void PushVarR(HSQUIRRELVM vm, T& value) {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Helper used to process formatted arguments when necessary. /// Helper used to process formatted arguments when necessary.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class> struct ArgPopHasFmt { static constexpr bool value = false; }; template<class> struct ArgFwdHasFmt { static constexpr bool value = false; };
template<> struct ArgPopHasFmt<StackStrF> { static constexpr bool value = true; }; template<> struct ArgFwdHasFmt<StackStrF> { static constexpr bool value = true; };
template<> struct ArgPopHasFmt<const StackStrF> { static constexpr bool value = true; }; template<> struct ArgFwdHasFmt<const StackStrF> { static constexpr bool value = true; };
template<> struct ArgPopHasFmt<StackStrF&> { static constexpr bool value = true; }; template<> struct ArgFwdHasFmt<StackStrF&> { static constexpr bool value = true; };
template<> struct ArgPopHasFmt<const StackStrF&> { static constexpr bool value = true; }; template<> struct ArgFwdHasFmt<const StackStrF&> { static constexpr bool value = true; };
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Helper used to process formatted arguments when necessary. /// Helper used to process formatted arguments when necessary.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<bool> struct ArgPopFmt { template<bool> struct ArgFwdFmt {
template<class T> static inline SQInteger Proc(T &, bool) { template<class T> static inline SQInteger Proc(T &, bool) noexcept { return SQ_OK; }
return SQ_OK; template<class T> static inline SQInteger Get(T &) noexcept { return SQ_OK; }
}
template<class T> static inline SQInteger Get(T &) {
return SQ_OK;
}
}; };
template<> struct ArgPopFmt<true> { template<> struct ArgFwdFmt<true> {
static inline SQInteger Proc(StackStrF & s, bool dummy = false) { static inline SQInteger Proc(StackStrF & s, bool dummy = false) noexcept { return s.Proc(true, dummy); }
return s.Proc(true, dummy); static inline SQInteger Get(StackStrF & s) noexcept { return s.mRes; }
}
static inline SQInteger Get(StackStrF & s) {
return s.mRes;
}
}; };
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Helper used to pop multiple variables from the stack and forward them to a functor. /// Helper used to pop multiple variables from the stack and forward them to a functor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class...> struct ArgPop; template<class...> struct ArgFwd;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Special case for when nothing has to be popped. /// Special case for when nothing has to be popped.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<> template<>
struct ArgPop<> { struct ArgFwd<> {
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = false; static constexpr bool HASFMT = false;
// Base constructor. Does nothing. // Where Squirrel result codes can be stored
ArgPop(HSQUIRRELVM /*vm*/, SQInteger /*idx*/) SQInteger mRes;
{ }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { (void)(dummy); return SQ_OK; }
SQInteger ProcRes() { return SQ_OK; }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger /*idx*/, F f) {
f(vm); f(vm);
} }
}; };
@ -1231,443 +1219,308 @@ struct ArgPop<> {
/// Incremental specialization for when types are actually specified. /// Incremental specialization for when types are actually specified.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class T1> template<class T1>
struct ArgPop<T1> { struct ArgFwd<T1> {
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T1>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T1>::value;
// Implement ours // Where Squirrel result codes can be stored
Var<T1> V1; SQInteger mRes;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: V1(vm, idx)
{ }
// Retrieve the last popped variable
Var<T1> & Last() { return V1; }
const Var<T1> & Last() const { return V1; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V1.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V1.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value); Var<T1> a1(vm, idx);
mRes = ArgFwdFmt<HASFMT>::Proc(a1.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value);
} }
}; };
template<class T1,class T2> template<class T1,class T2>
struct ArgPop<T1,T2> : public ArgPop<T1> { struct ArgFwd<T1,T2> {
using Base = ArgPop<T1>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T2>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T2>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
// Implement ours
Var<T2> V2;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1>(vm, idx)
, V2(vm, idx+1)
{ }
// Retrieve the last popped variable
Var<T2> & Last() { return V2; }
const Var<T2> & Last() const { return V2; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V2.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V2.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
mRes = ArgFwdFmt<HASFMT>::Proc(a2.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value);
} }
}; };
template<class T1,class T2,class T3> template<class T1,class T2,class T3>
struct ArgPop<T1,T2,T3> : public ArgPop<T1,T2> { struct ArgFwd<T1,T2,T3> {
using Base = ArgPop<T1,T2>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T3>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T3>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
// Implement ours
Var<T3> V3;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2>(vm, idx)
, V3(vm, idx+2)
{ }
// Retrieve the last popped variable
Var<T3> & Last() { return V3; }
const Var<T3> & Last() const { return V3; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V3.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V3.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
mRes = ArgFwdFmt<HASFMT>::Proc(a3.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value);
} }
}; };
template<class T1,class T2,class T3,class T4> template<class T1,class T2,class T3,class T4>
struct ArgPop<T1,T2,T3,T4> : public ArgPop<T1,T2,T3> { struct ArgFwd<T1,T2,T3,T4> {
using Base = ArgPop<T1,T2,T3>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T4>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T4>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
// Implement ours
Var<T4> V4;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3>(vm, idx)
, V4(vm, idx+3)
{ }
// Retrieve the last popped variable
Var<T4> & Last() { return V4; }
const Var<T4> & Last() const { return V4; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V4.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V4.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
mRes = ArgFwdFmt<HASFMT>::Proc(a4.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5> template<class T1,class T2,class T3,class T4,class T5>
struct ArgPop<T1,T2,T3,T4,T5> : public ArgPop<T1,T2,T3,T4> { struct ArgFwd<T1,T2,T3,T4,T5> {
using Base = ArgPop<T1,T2,T3,T4>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T5>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T5>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
// Implement ours
Var<T5> V5;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4>(vm, idx)
, V5(vm, idx+4)
{ }
// Retrieve the last popped variable
Var<T5> & Last() { return V5; }
const Var<T5> & Last() const { return V5; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V5.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V5.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
mRes = ArgFwdFmt<HASFMT>::Proc(a5.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value,a5.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6> template<class T1,class T2,class T3,class T4,class T5,class T6>
struct ArgPop<T1,T2,T3,T4,T5,T6> : public ArgPop<T1,T2,T3,T4,T5> { struct ArgFwd<T1,T2,T3,T4,T5,T6> {
using Base = ArgPop<T1,T2,T3,T4,T5>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T6>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T6>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
// Implement ours
Var<T6> V6;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5>(vm, idx)
, V6(vm, idx+5)
{ }
// Retrieve the last popped variable
Var<T6> & Last() { return V6; }
const Var<T6> & Last() const { return V6; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V6.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V6.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
mRes = ArgFwdFmt<HASFMT>::Proc(a6.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7> : public ArgPop<T1,T2,T3,T4,T5,T6> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T7>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T7>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
// Implement ours
Var<T7> V7;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6>(vm, idx)
, V7(vm, idx+6)
{ }
// Retrieve the last popped variable
Var<T7> & Last() { return V7; }
const Var<T7> & Last() const { return V7; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V7.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V7.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
mRes = ArgFwdFmt<HASFMT>::Proc(a7.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8> : public ArgPop<T1,T2,T3,T4,T5,T6,T7> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7,T8> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T8>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T8>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
using Base::V7;
// Implement ours
Var<T8> V8;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7>(vm, idx)
, V8(vm, idx+7)
{ }
// Retrieve the last popped variable
Var<T8> & Last() { return V8; }
const Var<T8> & Last() const { return V8; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V8.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V8.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
Var<T8> a8(vm, idx+7);
mRes = ArgFwdFmt<HASFMT>::Proc(a8.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7,T8,T9> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T9>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T9>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
using Base::V7;
using Base::V8;
// Implement ours
Var<T9> V9;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8>(vm, idx)
, V9(vm, idx+8)
{ }
// Retrieve the last popped variable
Var<T9> & Last() { return V9; }
const Var<T9> & Last() const { return V9; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V9.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V9.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
Var<T8> a8(vm, idx+7);
Var<T9> a9(vm, idx+8);
mRes = ArgFwdFmt<HASFMT>::Proc(a9.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T10>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T10>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
using Base::V7;
using Base::V8;
using Base::V9;
// Implement ours
Var<T10> V10;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9>(vm, idx)
, V10(vm, idx+9)
{ }
// Retrieve the last popped variable
Var<T10> & Last() { return V10; }
const Var<T10> & Last() const { return V10; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V10.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V10.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
Var<T8> a8(vm, idx+7);
Var<T9> a9(vm, idx+8);
Var<T10> a10(vm, idx+9);
mRes = ArgFwdFmt<HASFMT>::Proc(a10.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T11>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T11>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
using Base::V7;
using Base::V8;
using Base::V9;
using Base::V10;
// Implement ours
Var<T11> V11;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(vm, idx)
, V11(vm, idx+10)
{ }
// Retrieve the last popped variable
Var<T11> & Last() { return V11; }
const Var<T11> & Last() const { return V11; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V11.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V11.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
Var<T8> a8(vm, idx+7);
Var<T9> a9(vm, idx+8);
Var<T10> a10(vm, idx+9);
Var<T11> a11(vm, idx+10);
mRes = ArgFwdFmt<HASFMT>::Proc(a11.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
f(vm,a1.value,a2.value,a3.value,a4.value,a5.value,a6.value,a7.value,a8.value,a9.value,a10.value,a11.value);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T12>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T12>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
using Base::V7;
using Base::V8;
using Base::V9;
using Base::V10;
using Base::V11;
// Implement ours
Var<T12> V12;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(vm, idx)
, V12(vm, idx+11)
{ }
// Retrieve the last popped variable
Var<T12> & Last() { return V12; }
const Var<T12> & Last() const { return V12; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V12.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V12.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.value,V12.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
Var<T8> a8(vm, idx+7);
Var<T9> a9(vm, idx+8);
Var<T10> a10(vm, idx+9);
Var<T11> a11(vm, idx+10);
Var<T12> a12(vm, idx+11);
mRes = ArgFwdFmt<HASFMT>::Proc(a12.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
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);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T13>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T13>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
using Base::V7;
using Base::V8;
using Base::V9;
using Base::V10;
using Base::V11;
using Base::V12;
// Implement ours
Var<T13> V13;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(vm, idx)
, V13(vm, idx+12)
{ }
// Retrieve the last popped variable
Var<T13> & Last() { return V13; }
const Var<T13> & Last() const { return V13; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V13.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V13.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.value,V12.value,V13.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
Var<T8> a8(vm, idx+7);
Var<T9> a9(vm, idx+8);
Var<T10> a10(vm, idx+9);
Var<T11> a11(vm, idx+10);
Var<T12> a12(vm, idx+11);
Var<T13> a13(vm, idx+12);
mRes = ArgFwdFmt<HASFMT>::Proc(a13.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
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);
} }
}; };
template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14> template<class T1,class T2,class T3,class T4,class T5,class T6,class T7,class T8,class T9,class T10,class T11,class T12,class T13,class T14>
struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> { struct ArgFwd<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>;
// Used to tell whether the last template parameter is a StackStrF type // Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T14>::value; static constexpr bool HASFMT = ArgFwdHasFmt<T14>::value;
// Import from base classes // Where Squirrel result codes can be stored
using Base::V1; SQInteger mRes;
using Base::V2;
using Base::V3;
using Base::V4;
using Base::V5;
using Base::V6;
using Base::V7;
using Base::V8;
using Base::V9;
using Base::V10;
using Base::V11;
using Base::V12;
using Base::V13;
// Implement ours
Var<T14> V14;
// Base constructor. Can also pass extra parameters to the last popped argument.
ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(vm, idx)
, V14(vm, idx+13)
{ }
// Retrieve the last popped variable
Var<T14> & Last() { return V14; }
const Var<T14> & Last() const { return V14; }
// Process formatted arguments if necessary
SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V14.value, dummy); }
SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V14.value); }
// Forward the arguments to a function object // Forward the arguments to a function object
template<class F> void Call(HSQUIRRELVM vm, F f) { template<class F> inline void Call(HSQUIRRELVM vm, SQInteger idx, F f) {
f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.value,V12.value,V13.value,V14.value); Var<T1> a1(vm, idx);
Var<T2> a2(vm, idx+1);
Var<T3> a3(vm, idx+2);
Var<T4> a4(vm, idx+3);
Var<T5> a5(vm, idx+4);
Var<T6> a6(vm, idx+5);
Var<T7> a7(vm, idx+6);
Var<T8> a8(vm, idx+7);
Var<T9> a9(vm, idx+8);
Var<T10> a10(vm, idx+9);
Var<T11> a11(vm, idx+10);
Var<T12> a12(vm, idx+11);
Var<T13> a13(vm, idx+12);
Var<T14> a14(vm, idx+13);
mRes = ArgFwdFmt<HASFMT>::Proc(a14.value, sq_gettop(vm) < idx);
if (SQ_SUCCEEDED(mRes))
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);
} }
}; };
} }
#endif #endif

View File

@ -1563,7 +1563,7 @@ struct StackStrF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default constructor. /// Default constructor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StackStrF() StackStrF() noexcept
: mPtr(_SC("")) : mPtr(_SC(""))
, mLen(0) , mLen(0)
, mRes(SQ_OK) , mRes(SQ_OK)
@ -1577,7 +1577,7 @@ struct StackStrF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Compile time string constructor. /// Compile time string constructor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template < size_t N > StackStrF(const SQChar(&str)[N]) template < size_t N > StackStrF(const SQChar(&str)[N]) noexcept
: mPtr(str) : mPtr(str)
, mLen(N) , mLen(N)
, mRes(SQ_OK) , mRes(SQ_OK)
@ -1591,7 +1591,7 @@ struct StackStrF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Base constructor. /// Base constructor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StackStrF(HSQUIRRELVM vm, SQInteger idx) StackStrF(HSQUIRRELVM vm, SQInteger idx) noexcept
: mPtr(nullptr) : mPtr(nullptr)
, mLen(SQ_ERROR) , mLen(SQ_ERROR)
, mRes(SQ_OK) , mRes(SQ_OK)
@ -1609,7 +1609,7 @@ struct StackStrF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Move constructor. /// Move constructor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StackStrF(StackStrF && o) StackStrF(StackStrF && o) noexcept
: mPtr(o.mPtr) : mPtr(o.mPtr)
, mLen(o.mLen) , mLen(o.mLen)
, mRes(o.mRes) , mRes(o.mRes)
@ -1628,7 +1628,7 @@ struct StackStrF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Destructor. /// Destructor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
~StackStrF() ~StackStrF() noexcept
{ {
if (mVM && !sq_isnull(mObj)) if (mVM && !sq_isnull(mObj))
{ {