🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Parameter type can't be 'MyType &in', because the type cannot be instantiated

Started by
1 comment, last by WitchLord 6 years, 2 months ago

Hi, I'm defining the following function inside a script:


void TestFunction(const MyType &in testType)
{
  // ...
}

and 'MyType' is an object type that I registered in application with flag asOBJ_REF and I have only registered AddRef and Release behaviours.

I've also registered the following function on engine: "void TestRetrieve(const MyType &in)".

The problem here is, "TestRetrieve" is successfully registered, I got no errors or problems using this function, reference will be retrieved and the object is working.

But when I try to define a function inside the script, the error in the title will happen!

However, I commented https://www.sourceforge.net/p/angelscript/code/HEAD/tree/trunk/sdk/angelscript/source/as_compiler.cpp#l377 - 389 and the code is working fine, why it needs instantiation at all? The object is instantiated in the application, in fact, I don't want it to be instantiated by the script, I want it to be passed into script by inref.

Advertisement

'&in' means pretty much as passing the object by value, since any modification to the object received by the function must not affect the original object in the calling function. The only difference to pass by value is that instead of pushing the actual object on the stack, a reference to a copy of the object is pushed on the stack. (&in is only really necessary to keep compatibility with C++ functions that often take parameters by reference even though the object shouldn't be modified)

In your case you can just skip the 'in', since your object is a reference type and you've declared the reference as 'const'.

 

 

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