I have a type registered as asOBJ_REF|asOBJ_SCOPED and I would like to return it from an operator add, etc. I need it scoped because it requires special alignment upon allocation, but does not support reference counting, nor should it.
I can't return it by value because it is a reference type.
I can't return it by handle (@) because it doesn't support handles.
Returning it by reference (&) lets it compile, but the memory is leaked since I have to allocate a new instance of the type in the operator add.
Any ideas of how to handle my situation?
(I emailed Andreas, but I know he's really busy right now, so just in case someone on the board knows the answer)
Indeed I'm quite busy. But this does require my attention because it could be thought of as a bug, at very least a design flaw, as it renders the scoped reference types quite difficult to use.
The solution (as I mentioned in the e-mail, but repeat here for the benefit of others) is to change AngelScript to allow the application to register functions to return these scoped reference types by handle (even though within the scripts the handle of the type cannot be taken, as it is supposed to emulate value types). This will allow AngelScript to receive the value and then immediately release it after it has copied it to whatever variable the script wants to store it in.