1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-09-08 08:07:10 +02: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

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

View File

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

View File

@@ -2008,9 +2008,9 @@ SQInteger CPlayer::Msg(HSQUIRRELVM vm)
}
// Attempt to generate the string value
StackStrF val(vm, msgidx, true);
StackStrF val(vm, msgidx);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -2089,9 +2089,9 @@ SQInteger CPlayer::MsgP(HSQUIRRELVM vm)
}
// Attempt to generate the string value
StackStrF val(vm, 3, true);
StackStrF val(vm, 3);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -2195,9 +2195,9 @@ SQInteger CPlayer::MsgEx(HSQUIRRELVM vm)
}
// Attempt to generate the string value
StackStrF val(vm, msgidx, true);
StackStrF val(vm, msgidx);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -2260,9 +2260,9 @@ SQInteger CPlayer::Message(HSQUIRRELVM vm)
}
// Attempt to generate the string value
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -2317,9 +2317,9 @@ SQInteger CPlayer::Announce(HSQUIRRELVM vm)
}
// Attempt to generate the string value
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -2387,9 +2387,9 @@ SQInteger CPlayer::AnnounceEx(HSQUIRRELVM vm)
}
// Attempt to generate the string value
StackStrF val(vm, 3, true);
StackStrF val(vm, 3);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -2472,9 +2472,9 @@ SQInteger Player_FindAuto(HSQUIRRELVM vm)
case OT_STRING:
default: {
// Attempt to convert the obtained value to a string
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Did the conversion failed?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error
}
@@ -2558,9 +2558,9 @@ SQInteger Player_ExistsAuto(HSQUIRRELVM vm)
case OT_STRING:
default: {
// Attempt to convert the obtained value to a string
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Did the conversion failed?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
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)
{
// 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?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -56,9 +56,9 @@ template < class T > static SQInteger HashF(HSQUIRRELVM vm)
static SQInteger WhirlpoolF(HSQUIRRELVM vm)
{
// 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?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -94,9 +94,9 @@ static SQInteger WhirlpoolF(HSQUIRRELVM vm)
static SQInteger EncodeBase64F(HSQUIRRELVM vm)
{
// 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?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -122,9 +122,9 @@ static SQInteger EncodeBase64F(HSQUIRRELVM vm)
static SQInteger DecodeBase64F(HSQUIRRELVM vm)
{
// 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?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
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");
}
// Attempt to generate the string value
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -178,9 +178,9 @@ static SQInteger SqNanL(HSQUIRRELVM vm)
return sq_throwerror(vm, "Wrong number of arguments");
}
// Attempt to generate the string value
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
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
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -612,9 +612,9 @@ static SQInteger SqStrExplode(HSQUIRRELVM vm)
return sq_throwerror(vm, _SC("Missing string value"));
}
// Attempt to generate the string value
StackStrF val(vm, 4, true);
StackStrF val(vm, 4);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}
@@ -812,9 +812,9 @@ static CSStr FromArray(Array & arr)
static SQInteger StdPrintF(HSQUIRRELVM vm)
{
// 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?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}

View File

@@ -21,9 +21,9 @@ extern void Register_SysPath(HSQUIRRELVM vm);
static SQInteger SqSysExec(HSQUIRRELVM vm)
{
// 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?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
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");
}
// Attempt to generate the string value
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
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");
}
// Attempt to generate the string value
StackStrF val(vm, 2, true);
StackStrF val(vm, 2);
// Have we failed to retrieve the string?
if (SQ_FAILED(val.mRes))
if (SQ_FAILED(val.Proc(true)))
{
return val.mRes; // Propagate the error!
}

View File

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

View File

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