in c++
void OBJ::SomeFunc()
{
asIScriptContext *ctx = asGetActiveContext();
}
i get the ctx that called the script. thats fine.
but now i want to call some other script script function inside SomeFunc()
i cant call ctx->Prepare(func);
i do not want to create a new context (very slow), and dont have access to my context pool since this an extension.
how do call my script function without creating a new context?
Pre-2.24.0 the asGetActiveContext was only used to get the context for reporting a script exception, suspending the execution, getting user data from it, or possibly inspecting the call stack.
But with 2.24.0 you can now reuse the context for a new script call without having to create another context or access a context pool. It's done something like this:
// call the new function
ctx->Prepare(...);
ctx->Execute(...);
// restore the previous state to continue the original script
ctx->PopState();
}
asGetActiveContext() will return the context that is currently executing in the current thread, so you can use it even if you're calling scripts from multiple threads in parallel.
Pre-2.24.0 the asGetActiveContext was only used to get the context for reporting a script exception, suspending the execution, getting user data from it, or possibly inspecting the call stack.
But with 2.24.0 you can now reuse the context for a new script call without having to create another context or access a context pool. It's done something like this:
// call the new function
ctx->Prepare(...);
ctx->Execute(...);
// restore the previous state to continue the original script
ctx->PopState();
}
asGetActiveContext() will return the context that is currently executing in the current thread, so you can use it even if you're calling scripts from multiple threads in parallel.