I'm trying to create a way to dynamically call methods on a script object, in order to do this I thought I would suspend execution on the active context, create a new context and execute the method, then resume execution on the original context. To start to test this plan I first am trying to suspend the execution and thats where I've hit a issue. I call Suspend on the context and it returns a value of 0, but then if I check the current state it says that it's still active.
Here is my code for suspending, it's part of a template class
bool callMethodVoid(void *objRef, int typeId, const UString& methodName)
{
asIScriptContext* ctx = asGetActiveContext();
int r = ctx->Suspend();
printf("Suspend Return: %i\n", r);
printf("Current State: %i\n", ctx->GetState());
r = ctx->Execute();
printf("Execute Return: %i\n", r);
return true;
}
Here is the output for above:
Suspend Return: 0
Current State: 6
Execute Return: -4
It's called in the script language with the following
class Test
{
void test()
{
stdout << "Works!";
}
}
Object<Test> obj;
Test a;
obj.callMethod(a, "test");
Any idea what would keep the context from suspending?
Thank You,
dkrusu