Jump to content
  • Advertisement
Sign in to follow this  
loboWu

Do I need to call Discard()

This topic is 4509 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
Advertisement
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
I've been able to reproduce the problem with your instructions. Thanks.

Now I just need to find the solution. :)

Regards,
Andreas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!