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:
James Urquhart 2015-02-07 22:41:54 +00:00
parent b1ad72692c
commit f44a3f27d6
43 changed files with 1781 additions and 358 deletions

View file

@ -114,19 +114,22 @@ public:
~SimConsoleEvent();
virtual void process(SimObject *object);
/// Creates a reference to our internal args list in argv
void populateArgs(ConsoleValueRef *argv);
};
/// Used by Con::threadSafeExecute()
struct SimConsoleThreadExecCallback
{
Semaphore *sem;
const char *retVal;
ConsoleValueRef retVal;
SimConsoleThreadExecCallback();
~SimConsoleThreadExecCallback();
void handleCallback(const char *ret);
const char *waitForResult();
void handleCallback(ConsoleValueRef ret);
ConsoleValueRef waitForResult();
};
class SimConsoleThreadExecEvent : public SimConsoleEvent
@ -136,6 +139,7 @@ class SimConsoleThreadExecEvent : public SimConsoleEvent
public:
SimConsoleThreadExecEvent(S32 argc, ConsoleValueRef *argv, bool onObject, SimConsoleThreadExecCallback *callback);
SimConsoleThreadExecCallback& getCB() { return *cb; }
virtual void process(SimObject *object);
};