🎉 Celebrating 25 Years of GameDev.net! 🎉
Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!
Do I need to call Discard()
Hi, Dear Andreas:
In My environment,
I need to load many small script step by step.
All the script share the global registerd functions and types.
(I don't release asEngine until program exit)
here is my codes
CScript script;
script.AddModuleSection(file, section) (which module name is "Temp")
r = script.BuildModule();
r = script.ExecuteFunction("void main()");
r = script.DiscardModule();
When I run my first one script file, It works fine.
But the next file will fail and raise some exception.
The error message depend, sometimes in asCDataType::Format(),
and sometimes raised by AS engined which tell that "some registered function" is undefined.
If I remove DiscardModule(), all the workflow are perfect.
I feel so confused, Do I need to call DiscardModule ?
Thanks
Regards,
lobo
No, you shouldn't have to call DiscardModule(). When compiling a new script with the same module name it will automatically discard the old module.
However, it worries me that you get errors after manually calling DiscardModule(). Another developer had this problem as well and I tried to reproduce it then, but I had no luck. Would it be possible for you to write a small test that reproduces the problem and then send that to me so that I can test it.
Also, what version of AngelScript are you using?
Regards,
Andreas
However, it worries me that you get errors after manually calling DiscardModule(). Another developer had this problem as well and I tried to reproduce it then, but I had no luck. Would it be possible for you to write a small test that reproduces the problem and then send that to me so that I can test it.
Also, what version of AngelScript are you using?
Regards,
Andreas
Hi:
After a few testing, I think I could reproduce the error!
I just using samples\tutorial for testing,
and add the following function.
static uint8 Test(asIScriptArray* cmd, asIScriptArray* rcv, uint8 send_len, uint32 timeout)
{
return 0;
}
RegisterAPI()
{
r = engine->RegisterGlobalFunction("uint8 Test(uint8[] ∈, uint8[] &inout, uint8, uint32)", asFUNCTION(Test), asCALL_CDECL); assert( r >= 0 );
}
After Registering this function, compile the following script:
float calc(float a, float b)
{
uint8[] kk(10);
uint8[] kk2(10);
Test(kk, kk2, 10, 100);
// Do the calculation and return the value to the application
return a * b;
}
after running the script with right result,
I call engine->Discard(0), and recompile the script,
it will report "no matching signature to Test(uint8[]&, uint8[]&, const uint, const uint)"
the Building will fail.
But Removing engine->Discard(0), everything will be fine.
After a few testing, I think I could reproduce the error!
I just using samples\tutorial for testing,
and add the following function.
static uint8 Test(asIScriptArray* cmd, asIScriptArray* rcv, uint8 send_len, uint32 timeout)
{
return 0;
}
RegisterAPI()
{
r = engine->RegisterGlobalFunction("uint8 Test(uint8[] ∈, uint8[] &inout, uint8, uint32)", asFUNCTION(Test), asCALL_CDECL); assert( r >= 0 );
}
After Registering this function, compile the following script:
float calc(float a, float b)
{
uint8[] kk(10);
uint8[] kk2(10);
Test(kk, kk2, 10, 100);
// Do the calculation and return the value to the application
return a * b;
}
after running the script with right result,
I call engine->Discard(0), and recompile the script,
it will report "no matching signature to Test(uint8[]&, uint8[]&, const uint, const uint)"
the Building will fail.
But Removing engine->Discard(0), everything will be fine.
I've been able to reproduce the problem with your instructions. Thanks.
Now I just need to find the solution. :)
Regards,
Andreas
Now I just need to find the solution. :)
Regards,
Andreas
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement