Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualJake Albano

Posted 01 April 2013 - 09:13 AM

You can only use object handles with reference types, but inout references will work with value types if you allow the script engine to use unsafe references.

engine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES, true);

 

You can then use them inside scripts as well as passing tom C++.

void modify(Sprite & inout s)
{
    // modify the sprite
}

 

Be aware that you are now responsible for ensuring that parameters passed as inout remain valid for as long as they're in use. The script engine can't guarantee their lifetime, so it's possible to crash your application by passing temporary values into C++.


#1Jake Albano

Posted 01 April 2013 - 09:13 AM

You can only use object handles with reference types, but inout references will work with value types if you allow the script engine to use unsafe references.

engine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCES, true);

You can then use them inside scripts as well as passing tom C++.

void modify(Sprite & inout s)
{
    // modify the sprite
}

Be aware that you are now responsible for ensuring that parameters passed as inout remain valid for as long as they're in use. The script engine can't guarantee their lifetime, so it's possible to crash your application by passing temporary values into C++.


PARTNERS