As a young magician apprentice I’m not even starting to grasp all the magic and mysteries behind this class. It keeps me awake at night and is the source for 50% of the bugs in my project. I seek for advice in the obscure art of registering methods to the Script API…
Now seriously! I’m using a mixture of C++ and AngelScript in my project and to do so I’m registering each of my C++ components to the Script API.
Sometimes you have to return an array handle because it’s the most sensible thing to do for an API, even if that involves the overhead of converting a Vector into a CScriptArray*. Looking through Urho’s source I’ve come up with many of the answers on how to do so. I’ve got two questions:
First of all, and that’s just a confirmation: When registering a function that returns a CSriptArray as something like Array@ I should get the return value with a @ right? Because CScriptArray doesn’t inherit from RefCounted. This has worked for me but I want to know if I’ve got it right.
And second, when I do something like:
CScriptArray* GetSomething() {
Vector v = GetSomething(); //Returns a Vector, overloaded method.
return VectorToArrau(v, “Array<Something”);
}
Does the CScriptArray get auto-deleted when nothing points to it anymore? Should I use auto-handles for the registered return value for that matter? (Array@+ instead of Array@).
Thanks!