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

Use variatic templates to simplify DefaultAllocator.

This commit is contained in:
Sandu Liviu Catalin 2018-10-31 20:08:31 +02:00
parent f3f4fce80b
commit b6d157311b

View File

@ -136,516 +136,20 @@ public:
return New(vm);
}
template <typename A1>
template <class... A>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
Var<A7> a7(vm, 8);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value,
a7.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7,typename A8>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
Var<A7> a7(vm, 8);
Var<A8> a8(vm, 9);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value,
a7.value,
a8.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7,typename A8,typename A9>
static SQInteger iNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
Var<A7> a7(vm, 8);
Var<A8> a8(vm, 9);
Var<A9> a9(vm, 10);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value,
a7.value,
a8.value,
a9.value
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
/// @endcond
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// @cond DEV
/// following iNew functions are used only if constructors are bound via FmtCtor() in Sqrat::Class (safe to ignore)
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
StackStrF fmt(vm, 2);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
try {
SetInstance(vm, 1, ArgFwd<A...>{}.Call(vm, 2, [](HSQUIRRELVM /*vm*/, A... a) -> C * {
return new C(a...);
}));
} catch (const Exception& e) {
return sq_throwerror(vm, e.what());
} catch (...) {
return sq_throwerror(vm, _SC("unknown exception occured"));
}
return 0;
}
template <typename A1>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 3);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 4);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 5);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 6);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 7);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 8);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
Var<A7> a7(vm, 8);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 9);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value,
a7.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7,typename A8>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
Var<A7> a7(vm, 8);
Var<A8> a8(vm, 9);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 10);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value,
a7.value,
a8.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
template <typename A1,typename A2,typename A3,typename A4,typename A5,typename A6,typename A7,typename A8,typename A9>
static SQInteger iFmtNew(HSQUIRRELVM vm) {
SQTRY()
Var<A1> a1(vm, 2);
Var<A2> a2(vm, 3);
Var<A3> a3(vm, 4);
Var<A4> a4(vm, 5);
Var<A5> a5(vm, 6);
Var<A6> a6(vm, 7);
Var<A7> a7(vm, 8);
Var<A8> a8(vm, 9);
Var<A9> a9(vm, 10);
SQCATCH_NOEXCEPT(vm) {
return sq_throwerror(vm, SQWHAT_NOEXCEPT(vm));
}
StackStrF fmt(vm, 11);
// Validate the format
if (SQ_FAILED(fmt.Proc(true))) {
return fmt.mRes;
}
SetInstance(vm, 1, new C(
a1.value,
a2.value,
a3.value,
a4.value,
a5.value,
a6.value,
a7.value,
a8.value,
a9.value,
fmt
));
SQCATCH(vm) {
return sq_throwerror(vm, SQWHAT(vm));
}
return 0;
}
/// @endcond
public: