mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-13 03:33:48 +00:00
Fix stack balancing problems by refactoring execution calls
- Con::executef now uses a template - All public execution functions now restore the console stack upon return - Fixed bad parameters on some callbacks - Reverts get*Arg behavior
This commit is contained in:
parent
b1ad72692c
commit
f44a3f27d6
43 changed files with 1781 additions and 358 deletions
|
|
@ -31,12 +31,11 @@ void ConsoleValueStack::getArgcArgv(StringTableEntry name, U32 *argc, ConsoleVal
|
|||
U32 argCount = getMin(mStackPos - startStack, (U32)MaxArgs - 1);
|
||||
|
||||
*in_argv = mArgv;
|
||||
mArgv[0] = name;
|
||||
mArgv[0].value = CSTK.pushStackString(name);
|
||||
|
||||
for(U32 i = 0; i < argCount; i++) {
|
||||
ConsoleValueRef *ref = &mArgv[i+1];
|
||||
ref->value = &mStack[startStack + i];
|
||||
ref->stringStackValue = NULL;
|
||||
}
|
||||
argCount++;
|
||||
|
||||
|
|
@ -96,6 +95,36 @@ void ConsoleValueStack::pushValue(ConsoleValue &variable)
|
|||
}
|
||||
}
|
||||
|
||||
ConsoleValue* ConsoleValueStack::reserveValues(U32 count)
|
||||
{
|
||||
U32 startPos = mStackPos;
|
||||
if (startPos+count >= ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK reserveValues %i", mStackPos, count);
|
||||
mStackPos += count;
|
||||
return &mStack[startPos];
|
||||
}
|
||||
|
||||
bool ConsoleValueStack::reserveValues(U32 count, ConsoleValueRef *outValues)
|
||||
{
|
||||
U32 startPos = mStackPos;
|
||||
if (startPos+count >= ConsoleValueStack::MaxStackDepth) {
|
||||
AssertFatal(false, "Console Value Stack is empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
//Con::printf("[%i]CSTK reserveValues %i", mStackPos, count);
|
||||
for (U32 i=0; i<count; i++)
|
||||
{
|
||||
outValues[i].value = &mStack[mStackPos+i];
|
||||
}
|
||||
mStackPos += count;
|
||||
return true;
|
||||
}
|
||||
|
||||
ConsoleValue *ConsoleValueStack::pushString(const char *value)
|
||||
{
|
||||
if (mStackPos == ConsoleValueStack::MaxStackDepth) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue