Sign in to follow this  
FDsagizi

bug with ?& and ?&out

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

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

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