Jump to content
  • Advertisement
Sign in to follow this  

bug with ?& and ?&out

This topic is 1708 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! smile.png

if we are register functions as "bool retrieve(?&out)" this logic work fine:

AS:
SomeScriptObject @obj_null;
retrieve( obj_null );

c++:
bool retrieve( void *ptr, int type_id ){
   ptr != 0x000000; // ok
}

And them, if we are use without out - "bool retrieve(?&)" in c++ handle will be always 0x000000.  

AS:
SomeScriptObject @obj_null;
retrieve( obj_null );

c++:
bool retrieve( void *ptr, int type_id ){
   ptr == 0x000000; // always
}

use unsafe refences == true!

Share this post


Link to post
Share on other sites
Advertisement

Sorry for taking so long in looking into this.

 

Actually, both examples that you gave above are correct. What happens is that in the first case AngelScript will create dummy instance of SomeScriptObject and pass the reference to that object to the function so that the function can assign the output value in it. This is why the reference is always pointing to a valid object. In the second case AngelScript will always send the reference to the true object, which in this case is null. 

 

There was a bug however related to var args and unsafe references, and that was in this scenario:

 

AS:
SomeScriptObject @obj_null;
retrieve( @obj_null );

c++:
bool retrieve( void *ptr, int type_id ){
   ptr == 0x000000; // not ok. should be a reference to the handle
}

 

In this case AngelScript was supposed to pass the reference to the handle (since it was explicitly told so with @), but it was passing the reference to the object instead, which in this case would be null.

 

I've fixed this problem in revision 1726.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!