1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2024-11-08 08:47:17 +01:00

Massive code reduction in the binding utility by using variadic templates.

Extensive code refactoring surrounding the StackStrF helper to facilitate the new changes.
Various other miscellaneous changes and code refactoring to facilitate the new changes.
This commit is contained in:
Sandu Liviu Catalin 2018-07-30 00:58:27 +03:00
parent 199e9ac502
commit f300e7ff4a
20 changed files with 724 additions and 9507 deletions

View File

@ -352,9 +352,9 @@ public:
static SQInteger iFmtNew(HSQUIRRELVM vm) { static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); StackStrF fmt(vm, 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }
@ -375,9 +375,9 @@ public:
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
} }
const StackStrF fmt(vm, 3, true); StackStrF fmt(vm, 3);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }
@ -425,9 +425,9 @@ public:
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
} }
const StackStrF fmt(vm, 5, true); StackStrF fmt(vm, 5);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }
@ -453,9 +453,9 @@ public:
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
} }
const StackStrF fmt(vm, 6, true); StackStrF fmt(vm, 6);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }
@ -515,9 +515,9 @@ public:
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
} }
const StackStrF fmt(vm, 8, true); StackStrF fmt(vm, 8);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }
@ -549,9 +549,9 @@ public:
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
} }
const StackStrF fmt(vm, 9, true); StackStrF fmt(vm, 9);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }
@ -843,7 +843,7 @@ public:
std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >* instance = reinterpret_cast<std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >*>(ptr); std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >* instance = reinterpret_cast<std::pair<C*, SharedPtr<typename unordered_map<C*, HSQOBJECT>::type> >*>(ptr);
instance->second->erase(instance->first); instance->second->erase(instance->first);
// Only delete our pair instance and leave the actual instance untouched // Only delete our pair instance and leave the actual instance untouched
//delete instance->first; //delete instance->first;
delete instance; delete instance;
return 0; return 0;
} }
@ -1220,9 +1220,9 @@ public:
static SQInteger iFmtNew(HSQUIRRELVM vm) { static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); StackStrF fmt(vm, 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }
@ -1243,9 +1243,9 @@ public:
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
} }
const StackStrF fmt(vm, 3, true); StackStrF fmt(vm, 3);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes; return fmt.mRes;
} }

View File

@ -407,7 +407,7 @@ public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class F> template<class F>
Class& FmtFunc(const SQChar* name, F method) { Class& FmtFunc(const SQChar* name, F method) {
BindFunc(name, &method, sizeof(method), SqMemberFuncFmt(method)); BindFunc(name, &method, sizeof(method), SqMemberFunc(method));
return *this; return *this;
} }
@ -496,7 +496,7 @@ public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class F> template<class F>
Class& StaticFmtFunc(const SQChar* name, F method) { Class& StaticFmtFunc(const SQChar* name, F method) {
BindFunc(name, &method, sizeof(method), SqGlobalFmtFunc(method)); BindFunc(name, &method, sizeof(method), SqGlobalFunc(method));
return *this; return *this;
} }

View File

@ -41,38 +41,98 @@ namespace Sqrat {
/// @cond DEV /// @cond DEV
//
// Squirrel Global Functions
//
template <class R> struct SqGlobalProxy {
template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) {
ArgPop<A...> a(vm, idx);
if (SQ_FAILED(a.Proc())) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R(*M)(A...);
M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr);
R ret = (*method)(a...);
PushVar(vm, ret);
});
return 1;
}
};
//
// reference return specialization
//
template <class R> struct SqGlobalProxy<R&> {
template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) {
ArgPop<A...> a(vm, idx);
if (SQ_FAILED(a.Proc())) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef R&(*M)(A...);
M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr);
R& ret = (*method)(a...);
PushVarR(vm, ret);
});
return 1;
}
};
//
// void return specialization
//
template <> struct SqGlobalProxy<void> {
template <class... A> static SQInteger Run(HSQUIRRELVM vm, SQInteger idx) {
ArgPop<A...> a(vm, idx);
if (SQ_FAILED(a.Proc())) {
return a.ProcRes();
}
a.Call(vm, [](HSQUIRRELVM vm, A... a) {
typedef void(*M)(A...);
M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), nullptr);
(*method)(a...);
});
return 0;
}
};
template<bool> struct SqGlobalParamCheck {
static inline bool Invalid(SQInteger top, SQInteger count) {
return top != count;
}
};
template<> struct SqGlobalParamCheck<true> {
static inline bool Invalid(SQInteger top, SQInteger count) {
return top < count;
}
};
// //
// Squirrel Global Functions // Squirrel Global Functions
// //
template <class R> struct SqGlobal { template <class R> struct SqGlobal {
// Function proxy // Function proxy
template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept { template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept {
typedef R(*M)(A...); 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) && sq_gettop(vm) != static_cast<SQInteger>(startIdx + sizeof...(A))) { if (!SQRAT_CONST_CONDITION(overloaded) &&
return sq_throwerror(vm, _SC("wrong number of parameters")); SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) {
} return sq_throwerror(vm, _SC("wrong number of parameters"));
}
#endif #endif
M* method; try {
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), NULL); return SqGlobalProxy<R>::Run(vm, startIdx);
} catch (const Exception& e) {
SQTRY() return sq_throwerror(vm, e.what());
ArgPop<A...> a(vm, startIdx); }
SQCATCH_NOEXCEPT(vm) { SQ_UNREACHABLE
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); };
}
R ret = a.template Eval<R,M>(*method);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
PushVar(vm, ret);
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 1;
};
} }
}; };
@ -83,32 +143,20 @@ template <class R> struct SqGlobal {
template <class R> struct SqGlobal<R&> { template <class R> struct SqGlobal<R&> {
// Function proxy // Function proxy
template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept { template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept {
typedef R&(*M)(A...); 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) && sq_gettop(vm) != static_cast<SQInteger>(startIdx + sizeof...(A))) { if (!SQRAT_CONST_CONDITION(overloaded) && sq_gettop(vm) &&
return sq_throwerror(vm, _SC("wrong number of parameters")); SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) {
} return sq_throwerror(vm, _SC("wrong number of parameters"));
}
#endif #endif
M* method; try {
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), NULL); return SqGlobalProxy<R&>::Run(vm, startIdx);
} catch (const Exception& e) {
SQTRY() return sq_throwerror(vm, e.what());
ArgPop<A...> a(vm, startIdx); }
SQCATCH_NOEXCEPT(vm) { SQ_UNREACHABLE
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); };
}
R& ret = a.template Eval<R&, M>(*method);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
PushVarR(vm, ret);
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 1;
};
} }
}; };
@ -119,31 +167,20 @@ template <class R> struct SqGlobal<R&> {
template <> struct SqGlobal<void> { template <> struct SqGlobal<void> {
// Function proxy // Function proxy
template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept { template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept {
typedef void(*M)(A...); 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) && sq_gettop(vm) != static_cast<SQInteger>(startIdx + sizeof...(A))) { if (!SQRAT_CONST_CONDITION(overloaded) && sq_gettop(vm) &&
return sq_throwerror(vm, _SC("wrong number of parameters")); SqGlobalParamCheck< ArgPop<A...>::HASFMT >::Invalid(sq_gettop(vm), startIdx + sizeof...(A))) {
} return sq_throwerror(vm, _SC("wrong number of parameters"));
}
#endif #endif
M* method; try {
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), NULL); return SqGlobalProxy<void>::Run(vm, startIdx);
} catch (const Exception& e) {
SQTRY() return sq_throwerror(vm, e.what());
ArgPop<A...> a(vm, startIdx); }
SQCATCH_NOEXCEPT(vm) { SQ_UNREACHABLE
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm)); };
}
a.template Exec<M>(*method);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
};
} }
}; };
@ -167,144 +204,6 @@ template <class R,class T,class... A> SQFUNCTION SqMemberGlobalFunc(R& (* /*meth
return SqGlobal<R&>::template GetProxy<1, false, T, A...>(); return SqGlobal<R&>::template GetProxy<1, false, T, A...>();
} }
//
// Squirrel Global Functions
//
template <class R> struct SqGlobalFmt {
// Function proxy
template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept {
typedef R(*M)(A...);
return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && sq_gettop(vm) < static_cast<SQInteger>(startIdx + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters"));
}
#endif
M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), NULL);
SQTRY()
ArgPop<A...> a(vm, startIdx, true);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
// Validate the format
if (SQ_FAILED(a.Last().value.mRes)) {
return a.Last().value.mRes;
}
R ret = a.template Eval<R,M>(*method);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
PushVar(vm, ret);
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 1;
};
}
};
//
// reference return specialization
//
template <class R> struct SqGlobalFmt<R&> {
// Function proxy
template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept {
typedef R&(*M)(A...);
return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && sq_gettop(vm) < static_cast<SQInteger>(startIdx + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters"));
}
#endif
M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), NULL);
SQTRY()
ArgPop<A...> a(vm, startIdx, true);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
// Validate the format
if (SQ_FAILED(a.Last().value.mRes)) {
return a.Last().value.mRes;
}
R& ret = a.template Eval<R&,M>(*method);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
PushVarR(vm, ret);
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 1;
};
}
};
//
// void return specialization
//
template <> struct SqGlobalFmt<void> {
// Function proxy
template <SQInteger startIdx, bool overloaded, class... A> static SQFUNCTION GetProxy() noexcept {
typedef void(*M)(A...);
return +[](HSQUIRRELVM vm) noexcept -> SQInteger {
#if !defined (SCRAT_NO_ERROR_CHECKING)
if (!SQRAT_CONST_CONDITION(overloaded) && sq_gettop(vm) < static_cast<SQInteger>(startIdx + sizeof...(A))) {
return sq_throwerror(vm, _SC("wrong number of parameters"));
}
#endif
M* method;
sq_getuserdata(vm, -1, reinterpret_cast<SQUserPointer*>(&method), NULL);
SQTRY()
ArgPop<A...> a(vm, startIdx, true);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
// Validate the format
if (SQ_FAILED(a.Last().value.mRes)) {
return a.Last().value.mRes;
}
a.template Exec<M>(*method);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
};
}
};
// Formatted Global Function Resolver
template <class R,class... A> SQFUNCTION SqGlobalFmtFunc(R (* /*method*/)(A...)) noexcept {
return SqGlobalFmt<R>::template GetProxy<2, false, A...>();
}
// Formatted Global Function Resolver
template <class R,class... A> SQFUNCTION SqGlobalFmtFunc(R& (* /*method*/)(A...)) noexcept {
return SqGlobalFmt<R&>::template GetProxy<2, false, A...>();
}
// Formatted Member Global Function Resolver
template <class R,class T,class... A> SQFUNCTION SqMemberGlobalFmtFunc(R (* /*method*/)(T, A...)) noexcept {
return SqGlobalFmt<R>::template GetProxy<1, false, T, A...>();
}
// Formatted Member Global Function Resolver
template <class R,class T,class... A> SQFUNCTION SqMemberGlobalFmtFunc(R& (* /*method*/)(T, A...)) noexcept {
return SqGlobalFmt<R&>::template GetProxy<1, false, T, A...>();
}
/// @endcond /// @endcond
} }

File diff suppressed because it is too large Load Diff

View File

@ -171,324 +171,26 @@ template <class R,class T,class... A> SQFUNCTION SqMemberGlobalOverloadedFunc(R&
return SqGlobal<R&>::template GetProxy<1, true, T, A...>(); return SqGlobal<R&>::template GetProxy<1, true, T, A...>();
} }
// // Member Overloaded Function Resolver
// Member Overloaded Function Resolvers template <class C, class R,class... A> SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A...)) noexcept {
// return SqMember<C,R>::template GetProxy<true, A...>();
// Arg Count 0
template <class C, class R>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)()) {
return &SqMember<C, R>::template Func0<true>;
} }
template <class C, class R> // Member Overloaded Function Resolver
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)() const) { template <class C, class R,class... A> SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A...) const) noexcept {
return &SqMember<C, R>::template Func0C<true>; return SqMember<C,R>::template GetProxyC<true, A...>();
} }
template <class C, class R> // Member Overloaded Function Resolver
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)()) { template <class C, class R,class... A> SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A...)) noexcept {
return &SqMember<C, R&>::template Func0<true>; return SqMember<C,R&>::template GetProxy<true, A...>();
}
template <class C, class R>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)() const) {
return &SqMember<C, R&>::template Func0C<true>;
} }
// Arg Count 1 // Member Overloaded Function Resolver
template <class C, class R, class A1> template <class C, class R,class... A> SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A...) const) noexcept {
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1)) { return SqMember<C,R&>::template GetProxyC<true, A...>();
return &SqMember<C, R>::template Func1<A1, true>;
} }
template <class C, class R, class A1>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1) const) {
return &SqMember<C, R>::template Func1C<A1, true>;
}
template <class C, class R, class A1>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1)) {
return &SqMember<C, R&>::template Func1<A1, true>;
}
template <class C, class R, class A1>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1) const) {
return &SqMember<C, R&>::template Func1C<A1, true>;
}
// Arg Count 2
template <class C, class R, class A1, class A2>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2)) {
return &SqMember<C, R>::template Func2<A1, A2, true>;
}
template <class C, class R, class A1, class A2>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2) const) {
return &SqMember<C, R>::template Func2C<A1, A2, true>;
}
template <class C, class R, class A1, class A2>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2)) {
return &SqMember<C, R&>::template Func2<A1, A2, true>;
}
template <class C, class R, class A1, class A2>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2) const) {
return &SqMember<C, R&>::template Func2C<A1, A2, true>;
}
// Arg Count 3
template <class C, class R, class A1, class A2, class A3>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3)) {
return &SqMember<C, R>::template Func3<A1, A2, A3, true>;
}
template <class C, class R, class A1, class A2, class A3>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3) const) {
return &SqMember<C, R>::template Func3C<A1, A2, A3, true>;
}
template <class C, class R, class A1, class A2, class A3>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3)) {
return &SqMember<C, R&>::template Func3<A1, A2, A3, true>;
}
template <class C, class R, class A1, class A2, class A3>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3) const) {
return &SqMember<C, R&>::template Func3C<A1, A2, A3, true>;
}
// Arg Count 4
template <class C, class R, class A1, class A2, class A3, class A4>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4)) {
return &SqMember<C, R>::template Func4<A1, A2, A3, A4, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4) const) {
return &SqMember<C, R>::template Func4C<A1, A2, A3, A4, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4)) {
return &SqMember<C, R&>::template Func4<A1, A2, A3, A4, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4) const) {
return &SqMember<C, R&>::template Func4C<A1, A2, A3, A4, true>;
}
// Arg Count 5
template <class C, class R, class A1, class A2, class A3, class A4, class A5>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5)) {
return &SqMember<C, R>::template Func5<A1, A2, A3, A4, A5, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5) const) {
return &SqMember<C, R>::template Func5C<A1, A2, A3, A4, A5, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5)) {
return &SqMember<C, R&>::template Func5<A1, A2, A3, A4, A5, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5) const) {
return &SqMember<C, R&>::template Func5C<A1, A2, A3, A4, A5, true>;
}
// Arg Count 6
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6)) {
return &SqMember<C, R>::template Func6<A1, A2, A3, A4, A5, A6, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6) const) {
return &SqMember<C, R>::template Func6C<A1, A2, A3, A4, A5, A6, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6)) {
return &SqMember<C, R&>::template Func6<A1, A2, A3, A4, A5, A6, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6) const) {
return &SqMember<C, R&>::template Func6C<A1, A2, A3, A4, A5, A6, true>;
}
// Arg Count 7
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7)) {
return &SqMember<C, R>::template Func7<A1, A2, A3, A4, A5, A6, A7, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7) const) {
return &SqMember<C, R>::template Func7C<A1, A2, A3, A4, A5, A6, A7, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7)) {
return &SqMember<C, R&>::template Func7<A1, A2, A3, A4, A5, A6, A7, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7) const) {
return &SqMember<C, R&>::template Func7C<A1, A2, A3, A4, A5, A6, A7, true>;
}
// Arg Count 8
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8)) {
return &SqMember<C, R>::template Func8<A1, A2, A3, A4, A5, A6, A7, A8, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8) const) {
return &SqMember<C, R>::template Func8C<A1, A2, A3, A4, A5, A6, A7, A8, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8)) {
return &SqMember<C, R&>::template Func8<A1, A2, A3, A4, A5, A6, A7, A8, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8) const) {
return &SqMember<C, R&>::template Func8C<A1, A2, A3, A4, A5, A6, A7, A8, true>;
}
// Arg Count 9
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) {
return &SqMember<C, R>::template Func9<A1, A2, A3, A4, A5, A6, A7, A8, A9, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const) {
return &SqMember<C, R>::template Func9C<A1, A2, A3, A4, A5, A6, A7, A8, A9, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9)) {
return &SqMember<C, R&>::template Func9<A1, A2, A3, A4, A5, A6, A7, A8, A9, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9) const) {
return &SqMember<C, R&>::template Func9C<A1, A2, A3, A4, A5, A6, A7, A8, A9, true>;
}
// Arg Count 10
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) {
return &SqMember<C, R>::template Func10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const) {
return &SqMember<C, R>::template Func10C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10)) {
return &SqMember<C, R&>::template Func10<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10) const) {
return &SqMember<C, R&>::template Func10C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, true>;
}
// Arg Count 11
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)) {
return &SqMember<C, R>::template Func11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) const) {
return &SqMember<C, R>::template Func11C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11)) {
return &SqMember<C, R&>::template Func11<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11) const) {
return &SqMember<C, R&>::template Func11C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, true>;
}
// Arg Count 12
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)) {
return &SqMember<C, R>::template Func12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) const) {
return &SqMember<C, R>::template Func12C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12)) {
return &SqMember<C, R&>::template Func12<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12) const) {
return &SqMember<C, R&>::template Func12C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, true>;
}
// Arg Count 13
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)) {
return &SqMember<C, R>::template Func13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) const) {
return &SqMember<C, R>::template Func13C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13)) {
return &SqMember<C, R&>::template Func13<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13) const) {
return &SqMember<C, R&>::template Func13C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, true>;
}
// Arg Count 14
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)) {
return &SqMember<C, R>::template Func14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14>
inline SQFUNCTION SqMemberOverloadedFunc(R (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) const) {
return &SqMember<C, R>::template Func14C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14)) {
return &SqMember<C, R&>::template Func14<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, true>;
}
template <class C, class R, class A1, class A2, class A3, class A4, class A5, class A6, class A7, class A8, class A9, class A10, class A11, class A12, class A13, class A14>
inline SQFUNCTION SqMemberOverloadedFunc(R& (C::* /*method*/)(A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14) const) {
return &SqMember<C, R&>::template Func14C<A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, true>;
}
// //
// Overload handler resolver // Overload handler resolver
// //

View File

@ -281,7 +281,7 @@ public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class F> template<class F>
TableBase& FmtFunc(const SQChar* name, F method) { TableBase& FmtFunc(const SQChar* name, F method) {
BindFunc(name, &method, sizeof(method), SqGlobalFmtFunc(method)); BindFunc(name, &method, sizeof(method), SqGlobalFunc(method));
return *this; return *this;
} }

View File

@ -1017,7 +1017,7 @@ struct Var<StackStrF> {
/// This function MUST have its Error handled if it occurred. /// This function MUST have its Error handled if it occurred.
/// ///
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Var(HSQUIRRELVM vm, SQInteger idx, bool fmt = false) : value(vm, idx, fmt) { Var(HSQUIRRELVM vm, SQInteger idx) : value(vm, idx) {
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1040,13 +1040,13 @@ struct Var<StackStrF> {
/// Used to get and push StackStrF instances to and from the stack as references (StackStrF should not be a reference) /// Used to get and push StackStrF instances to and from the stack as references (StackStrF should not be a reference)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<> template<>
struct Var<StackStrF&> : Var<StackStrF> {Var(HSQUIRRELVM vm, SQInteger idx, bool fmt = false) : Var<StackStrF>(vm, idx, fmt) {}}; struct Var<StackStrF&> : Var<StackStrF> {Var(HSQUIRRELVM vm, SQInteger idx) : Var<StackStrF>(vm, idx) {}};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Used to get and push StackStrF instances to and from the stack as references (StackStrF should not be a reference) /// Used to get and push StackStrF instances to and from the stack as references (StackStrF should not be a reference)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<> template<>
struct Var<const StackStrF&> : Var<StackStrF> {Var(HSQUIRRELVM vm, SQInteger idx, bool fmt = false) : Var<StackStrF>(vm, idx, fmt) {}}; struct Var<const StackStrF&> : Var<StackStrF> {Var(HSQUIRRELVM vm, SQInteger idx) : Var<StackStrF>(vm, idx) {}};
// Non-referencable type definitions // Non-referencable type definitions
template<class T> struct is_referencable {static const bool value = true;}; template<class T> struct is_referencable {static const bool value = true;};
@ -1167,13 +1167,39 @@ struct PushVarR_helper<T, false> {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class T> template<class T>
inline void PushVarR(HSQUIRRELVM vm, T& value) { inline void PushVarR(HSQUIRRELVM vm, T& value) {
if (!is_pointer<T>::value && is_referencable<typename remove_cv<T>::type>::value) { if (!std::is_pointer<T>::value && is_referencable<typename std::remove_cv<T>::type>::value) {
Var<T&>::push(vm, value); Var<T&>::push(vm, value);
} else { } else {
PushVarR_helper<T, is_pointer<T>::value>::push(vm, value); PushVarR_helper<T, std::is_pointer<T>::value>::push(vm, value);
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Helper used to process formatted arguments when necessary.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class> struct ArgPopHasFmt { static constexpr bool value = false; };
template<> struct ArgPopHasFmt<StackStrF> { static constexpr bool value = true; };
template<> struct ArgPopHasFmt<const StackStrF> { static constexpr bool value = true; };
template<> struct ArgPopHasFmt<StackStrF&> { static constexpr bool value = true; };
template<> struct ArgPopHasFmt<const StackStrF&> { static constexpr bool value = true; };
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Helper used to process formatted arguments when necessary.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<bool> struct ArgPopFmt {
static inline SQInteger Proc(StackStrF &, bool) {
return SQ_OK;
}
};
template<> struct ArgPopFmt<true> {
static inline SQInteger Proc(StackStrF & s, bool dummy = false) {
return s.Proc(true, dummy);
}
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.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1184,15 +1210,17 @@ template<class...> struct ArgPop;
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<> template<>
struct ArgPop<> { struct ArgPop<> {
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = false;
// Base constructor. Does nothing.
ArgPop(HSQUIRRELVM /*vm*/, SQInteger /*idx*/) ArgPop(HSQUIRRELVM /*vm*/, SQInteger /*idx*/)
{ } { }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { (void)(dummy); return SQ_OK; }
f(); SQInteger ProcRes() { return SQ_OK; }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm);
return f();
} }
}; };
@ -1201,78 +1229,84 @@ struct ArgPop<> {
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
template<class T1> template<class T1>
struct ArgPop<T1> { struct ArgPop<T1> {
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T1>::value;
// Implement ours
Var<T1> V1; Var<T1> V1;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: V1(vm, idx, a...) : V1(vm, idx)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T1> & Last() { return V1; } Var<T1> & Last() { return V1; }
const Var<T1> & Last() const { return V1; } const Var<T1> & Last() const { return V1; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V1.value, dummy); }
f(V1.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V1.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value);
return f(V1.value);
} }
}; };
template<class T1,class T2> template<class T1,class T2>
struct ArgPop<T1,T2> : public ArgPop<T1> { struct ArgPop<T1,T2> : public ArgPop<T1> {
using Base = ArgPop<T1>; using Base = ArgPop<T1>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T2>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
// Implement ours // Implement ours
Var<T2> V2; Var<T2> V2;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1>(vm, idx) : ArgPop<T1>(vm, idx)
, V2(vm, idx+1, a...) , V2(vm, idx+1)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T2> & Last() { return V2; } Var<T2> & Last() { return V2; }
const Var<T2> & Last() const { return V2; } const Var<T2> & Last() const { return V2; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V2.value, dummy); }
f(V1.value,V2.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V2.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value);
return f(V1.value,V2.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 ArgPop<T1,T2,T3> : public ArgPop<T1,T2> {
using Base = ArgPop<T1,T2>; using Base = ArgPop<T1,T2>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T3>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
// Implement ours // Implement ours
Var<T3> V3; Var<T3> V3;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2>(vm, idx) : ArgPop<T1,T2>(vm, idx)
, V3(vm, idx+2, a...) , V3(vm, idx+2)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T3> & Last() { return V3; } Var<T3> & Last() { return V3; }
const Var<T3> & Last() const { return V3; } const Var<T3> & Last() const { return V3; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V3.value, dummy); }
f(V1.value,V2.value,V3.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V3.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value);
return f(V1.value,V2.value,V3.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 ArgPop<T1,T2,T3,T4> : public ArgPop<T1,T2,T3> {
using Base = ArgPop<T1,T2,T3>; using Base = ArgPop<T1,T2,T3>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T4>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1280,26 +1314,27 @@ struct ArgPop<T1,T2,T3,T4> : public ArgPop<T1,T2,T3> {
// Implement ours // Implement ours
Var<T4> V4; Var<T4> V4;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3>(vm, idx) : ArgPop<T1,T2,T3>(vm, idx)
, V4(vm, idx+3, a...) , V4(vm, idx+3)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T4> & Last() { return V4; } Var<T4> & Last() { return V4; }
const Var<T4> & Last() const { return V4; } const Var<T4> & Last() const { return V4; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V4.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V4.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value,V4.value);
return f(V1.value,V2.value,V3.value,V4.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 ArgPop<T1,T2,T3,T4,T5> : public ArgPop<T1,T2,T3,T4> {
using Base = ArgPop<T1,T2,T3,T4>; using Base = ArgPop<T1,T2,T3,T4>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T5>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1308,26 +1343,27 @@ struct ArgPop<T1,T2,T3,T4,T5> : public ArgPop<T1,T2,T3,T4> {
// Implement ours // Implement ours
Var<T5> V5; Var<T5> V5;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4>(vm, idx) : ArgPop<T1,T2,T3,T4>(vm, idx)
, V5(vm, idx+4, a...) , V5(vm, idx+4)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T5> & Last() { return V5; } Var<T5> & Last() { return V5; }
const Var<T5> & Last() const { return V5; } const Var<T5> & Last() const { return V5; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V5.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V5.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value,V4.value,V5.value);
return f(V1.value,V2.value,V3.value,V4.value,V5.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 ArgPop<T1,T2,T3,T4,T5,T6> : public ArgPop<T1,T2,T3,T4,T5> {
using Base = ArgPop<T1,T2,T3,T4,T5>; using Base = ArgPop<T1,T2,T3,T4,T5>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T6>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1337,26 +1373,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6> : public ArgPop<T1,T2,T3,T4,T5> {
// Implement ours // Implement ours
Var<T6> V6; Var<T6> V6;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5>(vm, idx) : ArgPop<T1,T2,T3,T4,T5>(vm, idx)
, V6(vm, idx+5, a...) , V6(vm, idx+5)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T6> & Last() { return V6; } Var<T6> & Last() { return V6; }
const Var<T6> & Last() const { return V6; } const Var<T6> & Last() const { return V6; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V6.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V6.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value);
return f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.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 ArgPop<T1,T2,T3,T4,T5,T6,T7> : public ArgPop<T1,T2,T3,T4,T5,T6> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6>; using Base = ArgPop<T1,T2,T3,T4,T5,T6>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T7>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1367,26 +1404,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7> : public ArgPop<T1,T2,T3,T4,T5,T6> {
// Implement ours // Implement ours
Var<T7> V7; Var<T7> V7;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6>(vm, idx)
, V7(vm, idx+6, a...) , V7(vm, idx+6)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T7> & Last() { return V7; } Var<T7> & Last() { return V7; }
const Var<T7> & Last() const { return V7; } const Var<T7> & Last() const { return V7; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V7.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V7.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value);
return f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.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 ArgPop<T1,T2,T3,T4,T5,T6,T7,T8> : public ArgPop<T1,T2,T3,T4,T5,T6,T7> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7>; using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T8>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1398,26 +1436,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8> : public ArgPop<T1,T2,T3,T4,T5,T6,T7> {
// Implement ours // Implement ours
Var<T8> V8; Var<T8> V8;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6,T7>(vm, idx)
, V8(vm, idx+7, a...) , V8(vm, idx+7)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T8> & Last() { return V8; } Var<T8> & Last() { return V8; }
const Var<T8> & Last() const { return V8; } const Var<T8> & Last() const { return V8; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V8.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V8.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value);
return f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.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 ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8>; using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T9>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1430,26 +1469,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T
// Implement ours // Implement ours
Var<T9> V9; Var<T9> V9;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6,T7,T8>(vm, idx)
, V9(vm, idx+8, a...) , V9(vm, idx+8)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T9> & Last() { return V9; } Var<T9> & Last() { return V9; }
const Var<T9> & Last() const { return V9; } const Var<T9> & Last() const { return V9; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V9.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V9.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value);
return f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.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 ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9>; using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T10>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1463,26 +1503,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> : public ArgPop<T1,T2,T3,T4,T5,T6,
// Implement ours // Implement ours
Var<T10> V10; Var<T10> V10;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9>(vm, idx)
, V10(vm, idx+9, a...) , V10(vm, idx+9)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T10> & Last() { return V10; } Var<T10> & Last() { return V10; }
const Var<T10> & Last() const { return V10; } const Var<T10> & Last() const { return V10; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V10.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V10.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(F f) { f(vm,V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value);
return f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.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 ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> : public ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>; 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
static constexpr bool HASFMT = ArgPopHasFmt<T11>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1497,26 +1538,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11> : public ArgPop<T1,T2,T3,T4,T5
// Implement ours // Implement ours
Var<T11> V11; Var<T11> V11;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>(vm, idx)
, V11(vm, idx+10, a...) , V11(vm, idx+10)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T11> & Last() { return V11; } Var<T11> & Last() { return V11; }
const Var<T11> & Last() const { return V11; } const Var<T11> & Last() const { return V11; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V11.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V11.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(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);
return f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.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 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> {
using Base = ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>; 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
static constexpr bool HASFMT = ArgPopHasFmt<T12>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1532,26 +1574,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12> : public ArgPop<T1,T2,T3,T
// Implement ours // Implement ours
Var<T12> V12; Var<T12> V12;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>(vm, idx)
, V12(vm, idx+11, a...) , V12(vm, idx+11)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T12> & Last() { return V12; } Var<T12> & Last() { return V12; }
const Var<T12> & Last() const { return V12; } const Var<T12> & Last() const { return V12; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V12.value, dummy); }
f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.value,V12.value); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V12.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(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);
return f(V1.value,V2.value,V3.value,V4.value,V5.value,V6.value,V7.value,V8.value,V9.value,V10.value,V11.value,V12.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 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> {
using Base = ArgPop<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,T12>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T13>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1568,26 +1611,27 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13> : public ArgPop<T1,T2,
// Implement ours // Implement ours
Var<T13> V13; Var<T13> V13;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>(vm, idx)
, V13(vm, idx+12, a...) , V13(vm, idx+12)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T13> & Last() { return V13; } Var<T13> & Last() { return V13; }
const Var<T13> & Last() const { return V13; } const Var<T13> & Last() const { return V13; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V13.value, dummy); }
f(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); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V13.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(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);
return f(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);
} }
}; };
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 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> {
using Base = ArgPop<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,T13>;
// Used to tell whether the last template parameter is a StackStrF type
static constexpr bool HASFMT = ArgPopHasFmt<T14>::value;
// Import from base classes // Import from base classes
using Base::V1; using Base::V1;
using Base::V2; using Base::V2;
@ -1605,20 +1649,19 @@ struct ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14> : public ArgPop<T1
// Implement ours // Implement ours
Var<T14> V14; Var<T14> V14;
// Base constructor. Can also pass extra parameters to the last popped argument. // Base constructor. Can also pass extra parameters to the last popped argument.
template<class... A> ArgPop(HSQUIRRELVM vm, SQInteger idx, A&&... a) ArgPop(HSQUIRRELVM vm, SQInteger idx)
: ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(vm, idx) : ArgPop<T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>(vm, idx)
, V14(vm, idx+13, a...) , V14(vm, idx+13)
{ } { }
// Retrieve the last popped variable // Retrieve the last popped variable
Var<T14> & Last() { return V14; } Var<T14> & Last() { return V14; }
const Var<T14> & Last() const { return V14; } const Var<T14> & Last() const { return V14; }
// Forward the arguments to a functor that doesn't return anything // Process formatted arguments if necessary
template<class F> void Exec(F f) { SQInteger Proc(bool dummy = false) { return ArgPopFmt<HASFMT>::Proc(V14.value, dummy); }
f(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); SQInteger ProcRes() { return ArgPopFmt<HASFMT>::Get(V14.value); }
} // Forward the arguments to a function object
// Forward the arguments to a functor that returns a value template<class F> void Call(HSQUIRRELVM vm, F f) {
template<class R,class F> R Eval(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);
return f(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);
} }
}; };

View File

@ -45,6 +45,15 @@
namespace Sqrat { namespace Sqrat {
#if defined(__GNUC__)
#define SQ_UNREACHABLE __builtin_unreachable();
#elif defined(_MSVC)
static _Noreturn void unreachable() { return; }
#define SQ_UNREACHABLE unreachable();
#else
#define SQ_UNREACHABLE assert(0);
#endif
/// @cond DEV /// @cond DEV
#if defined(SCRAT_USE_CXX11_OPTIMIZATIONS) #if defined(SCRAT_USE_CXX11_OPTIMIZATIONS)
@ -1531,7 +1540,7 @@ struct StackGuard
{ {
sq_pop(m_VM, top - m_Top); // Trim the stack sq_pop(m_VM, top - m_Top); // Trim the stack
} }
} }
private: private:
@ -1549,6 +1558,7 @@ struct StackStrF
SQRESULT mRes; ///< The result of the retrieval attempts. SQRESULT mRes; ///< The result of the retrieval attempts.
HSQOBJECT mObj; ///< Strong reference to the string object. HSQOBJECT mObj; ///< Strong reference to the string object.
HSQUIRRELVM mVM; ///< The associated virtual machine. HSQUIRRELVM mVM; ///< The associated virtual machine.
SQInteger mIdx; ///< The index where the string should be retrieved from.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Default constructor. /// Default constructor.
@ -1559,9 +1569,9 @@ struct StackStrF
, mRes(SQ_OK) , mRes(SQ_OK)
, mObj() , mObj()
, mVM(DefaultVM::Get()) , mVM(DefaultVM::Get())
, mIdx(-1)
{ {
// Reset the converted value object sq_resetobject(&mObj); // Reset the converted value object
sq_resetobject(&mObj);
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1573,102 +1583,22 @@ struct StackStrF
, mRes(SQ_OK) , mRes(SQ_OK)
, mObj() , mObj()
, mVM(DefaultVM::Get()) , mVM(DefaultVM::Get())
, mIdx(-1)
{ {
// Reset the converted value object sq_resetobject(&mObj); // Reset the converted value object
sq_resetobject(&mObj);
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Base constructor. /// Base constructor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = false, bool dummy = false) StackStrF(HSQUIRRELVM vm, SQInteger idx)
: mPtr(nullptr) : mPtr(nullptr)
, mLen(-1) , mLen(-1)
, mRes(SQ_OK) , mRes(SQ_OK)
, mObj() , mObj()
, mVM(vm) , mVM(vm)
, mIdx(idx)
{ {
// Reset the converted value object
sq_resetobject(&mObj);
// is this a dummy request?
if (dummy)
{
// Since this is a dummy then avoid making it look like a failure
mPtr = _SC("");
mLen = 0;
// We're not supposed to proceed with this!
return;
}
// Grab the top of the stack
const SQInteger top = sq_gettop(vm);
// Was the string or value specified?
if (top <= (idx - 1))
{
mRes = sq_throwerror(vm, "Missing string or value");
}
// Do we have enough values to call the format function and are we allowed to?
else if (fmt && (top - 1) >= idx)
{
// Pointer to the generated string
SQChar * str = nullptr;
// Attempt to generate the specified string format
mRes = sqstd_format(vm, idx, &mLen, &str);
// Did the format succeeded but ended up with a null string pointer?
if (SQ_SUCCEEDED(mRes) && !str)
{
mRes = sq_throwerror(vm, "Unable to generate the string");
}
else
{
mPtr = const_cast< const SQChar * >(str);
}
}
// Is the value on the stack an actual string?
else if (sq_gettype(vm, idx) == OT_STRING)
{
// Obtain a reference to the string object
mRes = sq_getstackobj(vm, idx, &mObj);
// Could we retrieve the object from the stack?
if (SQ_SUCCEEDED(mRes))
{
// Keep a strong reference to the object
sq_addref(vm, &mObj);
// Attempt to retrieve the string value from the stack
mRes = sq_getstringandsize(vm, idx, &mPtr, &mLen);
}
// Did the retrieval succeeded but ended up with a null string pointer?
if (SQ_SUCCEEDED(mRes) && !mPtr)
{
mRes = sq_throwerror(vm, "Unable to retrieve the string");
}
}
// We have to try and convert it to string
else
{
// Attempt to convert the value from the stack to a string
mRes = sq_tostring(vm, idx);
// Could we convert the specified value to string?
if (SQ_SUCCEEDED(mRes))
{
// Obtain a reference to the resulted object
mRes = sq_getstackobj(vm, -1, &mObj);
// Could we retrieve the object from the stack?
if (SQ_SUCCEEDED(mRes))
{
// Keep a strong reference to the object
sq_addref(vm, &mObj);
// Attempt to obtain the string pointer
mRes = sq_getstringandsize(vm, -1, &mPtr, &mLen);
}
}
// Pop a value from the stack regardless of the result
sq_pop(vm, 1);
// Did the retrieval succeeded but ended up with a null string pointer?
if (SQ_SUCCEEDED(mRes) && !mPtr)
{
mRes = sq_throwerror(vm, "Unable to retrieve the value");
}
}
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -1685,11 +1615,13 @@ struct StackStrF
, mRes(o.mRes) , mRes(o.mRes)
, mObj(o.mObj) , mObj(o.mObj)
, mVM(o.mVM) , mVM(o.mVM)
, mIdx(o.mIdx)
{ {
o.mPtr = nullptr; o.mPtr = nullptr;
o.mLen = 0; o.mLen = 0;
o.mRes = SQ_OK; o.mRes = SQ_OK;
o.mVM = nullptr; o.mVM = nullptr;
o.mIdx = -1;
sq_resetobject(&o.mObj); sq_resetobject(&o.mObj);
} }
@ -1713,6 +1645,95 @@ struct StackStrF
/// Move assignment operator. (disabled) /// Move assignment operator. (disabled)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StackStrF & operator = (StackStrF && o) = delete; StackStrF & operator = (StackStrF && o) = delete;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Actual implementation.
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SQRESULT Proc(bool fmt = false, bool dummy = false) noexcept
{
// Reset the converted value object
sq_resetobject(&mObj);
// is this a dummy request?
if (dummy)
{
// Since this is a dummy then avoid making it look like a failure
mPtr = _SC("");
mLen = 0;
// We're not supposed to proceed with this!
return mRes;
}
// Grab the top of the stack
const SQInteger top = sq_gettop(mVM);
// Was the string or value specified?
if (top <= (mIdx - 1))
{
mRes = sq_throwerror(mVM, "Missing string or value");
}
// Do we have enough values to call the format function and are we allowed to?
else if (fmt && (top - 1) >= mIdx)
{
// Pointer to the generated string
SQChar * str = nullptr;
// Attempt to generate the specified string format
mRes = sqstd_format(mVM, mIdx, &mLen, &str);
// Did the format succeeded but ended up with a null string pointer?
if (SQ_SUCCEEDED(mRes) && !str)
{
mRes = sq_throwerror(mVM, "Unable to generate the string");
}
else
{
mPtr = const_cast< const SQChar * >(str);
}
}
// Is the value on the stack an actual string?
else if (sq_gettype(mVM, mIdx) == OT_STRING)
{
// Obtain a reference to the string object
mRes = sq_getstackobj(mVM, mIdx, &mObj);
// Could we retrieve the object from the stack?
if (SQ_SUCCEEDED(mRes))
{
// Keep a strong reference to the object
sq_addref(mVM, &mObj);
// Attempt to retrieve the string value from the stack
mRes = sq_getstringandsize(mVM, mIdx, &mPtr, &mLen);
}
// Did the retrieval succeeded but ended up with a null string pointer?
if (SQ_SUCCEEDED(mRes) && !mPtr)
{
mRes = sq_throwerror(mVM, "Unable to retrieve the string");
}
}
// We have to try and convert it to string
else
{
// Attempt to convert the value from the stack to a string
mRes = sq_tostring(mVM, mIdx);
// Could we convert the specified value to string?
if (SQ_SUCCEEDED(mRes))
{
// Obtain a reference to the resulted object
mRes = sq_getstackobj(mVM, -1, &mObj);
// Could we retrieve the object from the stack?
if (SQ_SUCCEEDED(mRes))
{
// Keep a strong reference to the object
sq_addref(mVM, &mObj);
// Attempt to obtain the string pointer
mRes = sq_getstringandsize(mVM, -1, &mPtr, &mLen);
}
}
// Pop a value from the stack regardless of the result
sq_pop(mVM, 1);
// Did the retrieval succeeded but ended up with a null string pointer?
if (SQ_SUCCEEDED(mRes) && !mPtr)
{
mRes = sq_throwerror(mVM, "Unable to retrieve the value");
}
}
return mRes;
}
}; };
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View File

@ -627,9 +627,9 @@ String SqTypeName(HSQUIRRELVM vm, SQInteger idx)
return _SC("unknown"); return _SC("unknown");
} }
// Attempt to convert the obtained value to a string // Attempt to convert the obtained value to a string
StackStrF val(vm, -1, false); StackStrF val(vm, -1);
// Did the conversion failed? // Did the conversion failed?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(false)))
{ {
return _SC("unknown"); return _SC("unknown");
} }

View File

@ -1024,16 +1024,16 @@ static SQInteger SqNameFilterCheck(HSQUIRRELVM vm)
return sq_throwerror(vm, "Missing name string"); return sq_throwerror(vm, "Missing name string");
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF filter(vm, 2, false); StackStrF filter(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(filter.mRes)) if (SQ_FAILED(filter.Proc(false)))
{ {
return filter.mRes; // Propagate the error! return filter.mRes; // Propagate the error!
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF name(vm, 3, true); StackStrF name(vm, 3);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(name.mRes)) if (SQ_FAILED(name.Proc(true)))
{ {
return name.mRes; // Propagate the error! return name.mRes; // Propagate the error!
} }
@ -1058,16 +1058,16 @@ static SQInteger SqNameFilterCheckInsensitive(HSQUIRRELVM vm)
return sq_throwerror(vm, "Missing name string"); return sq_throwerror(vm, "Missing name string");
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF filter(vm, 2, false); StackStrF filter(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(filter.mRes)) if (SQ_FAILED(filter.Proc(false)))
{ {
return filter.mRes; // Propagate the error! return filter.mRes; // Propagate the error!
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF name(vm, 3, true); StackStrF name(vm, 3);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(name.mRes)) if (SQ_FAILED(name.Proc(true)))
{ {
return name.mRes; // Propagate the error! return name.mRes; // Propagate the error!
} }

View File

@ -25,9 +25,9 @@ static SQInteger SqLoadScript(HSQUIRRELVM vm)
// Whether the script execution is delayed // Whether the script execution is delayed
SQBool delay = SQFalse; SQBool delay = SQFalse;
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 3, true); StackStrF val(vm, 3);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -2008,9 +2008,9 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, msgidx, true); StackStrF val(vm, msgidx);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -2089,9 +2089,9 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 3, true); StackStrF val(vm, 3);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -2195,9 +2195,9 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, msgidx, true); StackStrF val(vm, msgidx);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -2260,9 +2260,9 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -2317,9 +2317,9 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -2387,9 +2387,9 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 3, true); StackStrF val(vm, 3);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -2472,9 +2472,9 @@ SQInteger Player_FindAuto(HSQUIRRELVM vm)
case OT_STRING: case OT_STRING:
default: { default: {
// Attempt to convert the obtained value to a string // Attempt to convert the obtained value to a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Did the conversion failed? // Did the conversion failed?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error return val.mRes; // Propagate the error
} }
@ -2558,9 +2558,9 @@ SQInteger Player_ExistsAuto(HSQUIRRELVM vm)
case OT_STRING: case OT_STRING:
default: { default: {
// Attempt to convert the obtained value to a string // Attempt to convert the obtained value to a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Did the conversion failed? // Did the conversion failed?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error return val.mRes; // Propagate the error
} }

View File

@ -36,9 +36,9 @@ template < class T > T BaseHash< T >::Algo;
template < class T > static SQInteger HashF(HSQUIRRELVM vm) template < class T > static SQInteger HashF(HSQUIRRELVM vm)
{ {
// Attempt to retrieve the value from the stack as a string // Attempt to retrieve the value from the stack as a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -56,9 +56,9 @@ template < class T > static SQInteger HashF(HSQUIRRELVM vm)
static SQInteger WhirlpoolF(HSQUIRRELVM vm) static SQInteger WhirlpoolF(HSQUIRRELVM vm)
{ {
// Attempt to retrieve the value from the stack as a string // Attempt to retrieve the value from the stack as a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -94,9 +94,9 @@ static SQInteger WhirlpoolF(HSQUIRRELVM vm)
static SQInteger EncodeBase64F(HSQUIRRELVM vm) static SQInteger EncodeBase64F(HSQUIRRELVM vm)
{ {
// Attempt to retrieve the value from the stack as a string // Attempt to retrieve the value from the stack as a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -122,9 +122,9 @@ static SQInteger EncodeBase64F(HSQUIRRELVM vm)
static SQInteger DecodeBase64F(HSQUIRRELVM vm) static SQInteger DecodeBase64F(HSQUIRRELVM vm)
{ {
// Attempt to retrieve the value from the stack as a string // Attempt to retrieve the value from the stack as a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -153,9 +153,9 @@ static SQInteger SqNan(HSQUIRRELVM vm)
return sq_throwerror(vm, "Wrong number of arguments"); return sq_throwerror(vm, "Wrong number of arguments");
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -178,9 +178,9 @@ static SQInteger SqNanL(HSQUIRRELVM vm)
return sq_throwerror(vm, "Wrong number of arguments"); return sq_throwerror(vm, "Wrong number of arguments");
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -490,9 +490,9 @@ static SQInteger SplitWhereCharImpl(HSQUIRRELVM vm, int(*fn)(int), bool neg)
} }
// Attempt to retrieve the value from the stack as a string // Attempt to retrieve the value from the stack as a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -612,9 +612,9 @@ static SQInteger SqStrExplode(HSQUIRRELVM vm)
return sq_throwerror(vm, _SC("Missing string value")); return sq_throwerror(vm, _SC("Missing string value"));
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 4, true); StackStrF val(vm, 4);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -812,9 +812,9 @@ static CSStr FromArray(Array & arr)
static SQInteger StdPrintF(HSQUIRRELVM vm) static SQInteger StdPrintF(HSQUIRRELVM vm)
{ {
// Attempt to retrieve the value from the stack as a string // Attempt to retrieve the value from the stack as a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -21,9 +21,9 @@ extern void Register_SysPath(HSQUIRRELVM vm);
static SQInteger SqSysExec(HSQUIRRELVM vm) static SQInteger SqSysExec(HSQUIRRELVM vm)
{ {
// Attempt to retrieve the value from the stack as a string // Attempt to retrieve the value from the stack as a string
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -22,9 +22,9 @@ static SQInteger SqExtractIPv4(HSQUIRRELVM vm)
return sq_throwerror(vm, "Missing IP address string"); return sq_throwerror(vm, "Missing IP address string");
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -539,9 +539,9 @@ template < Uint8 L, bool S > static SQInteger LogBasicMessage(HSQUIRRELVM vm)
return sq_throwerror(vm, "Missing message value"); return sq_throwerror(vm, "Missing message value");
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -259,9 +259,9 @@ static SQInteger SqBroadcastMsg(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, msgidx, true); StackStrF val(vm, msgidx);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -339,9 +339,9 @@ static SQInteger SqBroadcastMsgP(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 3, true); StackStrF val(vm, 3);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -444,9 +444,9 @@ static SQInteger SqBroadcastMsgEx(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, msgidx, true); StackStrF val(vm, msgidx);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -508,9 +508,9 @@ static SQInteger SqBroadcastMessage(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -564,9 +564,9 @@ static SQInteger SqBroadcastAnnounce(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 2, true); StackStrF val(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }
@ -641,9 +641,9 @@ static SQInteger SqBroadcastAnnounceEx(HSQUIRRELVM vm)
} }
// Attempt to generate the string value // Attempt to generate the string value
StackStrF val(vm, 3, true); StackStrF val(vm, 3);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes)) if (SQ_FAILED(val.Proc(true)))
{ {
return val.mRes; // Propagate the error! return val.mRes; // Propagate the error!
} }

View File

@ -499,9 +499,9 @@ public:
return sq_throwerror(vm, e.what()); return sq_throwerror(vm, e.what());
} }
// Attempt to generate the string value // Attempt to generate the string value
const StackStrF tag(vm, 2, true); StackStrF tag(vm, 2);
// Have we failed to retrieve the string? // Have we failed to retrieve the string?
if (SQ_FAILED(tag.mRes)) if (SQ_FAILED(tag.Proc(true)))
{ {
return tag.mRes; // Propagate the error! return tag.mRes; // Propagate the error!
} }