Sign in to follow this  

Do I need to call Discard()

This topic is 4198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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[] &in, 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.

Share this post


Link to post
Share on other sites

This topic is 4198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this