1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-01-31 18:07:14 +01:00

Make sure that the free variable containing the pointer of the registered native closures is taken into account when registering functions with formatting support that take no extra parameters other than the formatting string and trailing variable arguments.

This commit is contained in:
Sandu Liviu Catalin 2017-06-17 22:41:03 +03:00
parent 30fd6b274b
commit bb7a6881c6
3 changed files with 20 additions and 10 deletions

View File

@ -2403,7 +2403,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;
@ -2822,7 +2822,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;
@ -3241,7 +3241,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;

View File

@ -5462,7 +5462,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;
@ -5507,7 +5507,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;
@ -6514,7 +6514,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;
@ -6559,7 +6559,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;
@ -7566,7 +7566,7 @@ public:
SQTRY() SQTRY()
const StackStrF fmt(vm, 2, true); const StackStrF fmt(vm, 2, true, sq_gettop(vm) == 2);
// Validate the format // Validate the format
if (SQ_FAILED(fmt.mRes)) { if (SQ_FAILED(fmt.mRes)) {
return fmt.mRes; return fmt.mRes;

View File

@ -1510,16 +1510,26 @@ struct StackStrF
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// Base constructor. /// Base constructor.
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true) StackStrF(HSQUIRRELVM vm, SQInteger idx, bool fmt = true, bool dummy = false)
: mPtr(nullptr) : mPtr(nullptr)
, mLen(-1) , mLen(-1)
, mRes(SQ_OK) , mRes(SQ_OK)
, mObj() , mObj()
, mVM(vm) , mVM(vm)
{ {
const SQInteger top = sq_gettop(vm);
// Reset the converted value object // Reset the converted value object
sq_resetobject(&mObj); 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? // Was the string or value specified?
if (top <= (idx - 1)) if (top <= (idx - 1))
{ {