It hasn't been much time since I started using AngelScript, so I that 'bug' was maybe my own vault. (If so I'd really appreciate to hear a solution for it)
Sometimes when I just compiled one of my tiny test-scripts I get an exception in as_context.cpp.
It is this code which makes trouble (Line: ~1027, Execute() )
if( status == asEXECUTION_FINISHED )
{
regs.objectType = initialFunction->returnType.GetObjectType(); // <-- initialFunction is NULL
return asEXECUTION_FINISHED;
}
After messing around with this for a while I noticed that this only happens when I use a different package than my EngineMedia package to load the script.
Some background information:
My Engine stores all data in some kind of package-file. Each file stored there has it's own File-Chunk which simply holds the Data and some other properties.
The EngineMedia-Package is the first loaded package of my engine.
When I link a script to a "ContentMark", which is an Object which links to some Content or Actor with some Components in one of the packages, the Package and the FileChunk will be grabbed from
the selection the user made in the Browser of the Editor.
Then that ContentMark gets those Pointers and then gets the Data out.
And then we simply have a char-array and every package related work is done.
The char-array will be given to the ScriptEngine, which compiles it just fine, and then, when I call my first function it crashes.
Because of that weird thing I have going on with the different packages I guess the problem was maybe caused by myself, but I thought you should know about another possible exception in your great library.
---
Also got that error in line 751 of as_context.cpp ( SetArgAddress(...) ):
if( arg >= (unsigned)initialFunction->parameterTypes.GetLength() ) // <-- initialFunction NULL again!
{
status = asEXECUTION_ERROR;
return asINVALID_ARG;
}
Here is the code which called the function:
/** Sets the content mark we are linked to */
void EngineContentMarkScriptObject::SetContentMark(WContentMark* CM)
{
ContentMark=CM;
CMScriptObject=CM->GetInScriptObject();
int SetCMIdx = Module->GetFunctionIdByName("ENGINE_SetContentMark");
if(Context->Prepare(SetCMIdx) >= 0)
{
Context->SetArgAddress(0, (void *)CMScriptObject); // <-- That
Context->Execute();
}
CallOnLoad();
}
That works when compiling the code out of another package. Can't tell why.
(And also, sorry for the weird and confusing posting, I had new ideas to try out after writing every single line...)
Someone got an idea what is going on?