bug with ?& and ?&out

Started by
1 comment, last by WitchLord 10 years, 7 months ago

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!

Advertisement

Thanks. I'll look into this.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement