Advertisement

Auto handles with the ref add-on

Started by August 23, 2018 11:40 PM
1 comment, last by MrFloat 6 years, 6 months ago

Hello,

I am trying to implement a member function that will return a `ref@`object.

I got the basic function working, but I did not want to deal with reference counting in my code, so I added the auto handle to the object to make it: `ref@+`

However, when I try to register this method I get an error from Angelscript:

(0, 0) : ERR  : Failed in call to function 'RegisterObjectMethod' with 'ScriptObjectHandle' and 'ref@+ get()' (Code: -10)

 

If I remove the auto handle it works fine. If I use a different type (i.e. a type that I have added), it also works fine.

Does anyone know what I'm doing wrong?

Cheers

Jarrett

 

I don't think you're supposed to use @+ for types with asOBJ_ASHANDLE flag
If you look at the ref type registration, it doesn't even have the functionality tegistered to have a counter for itself and asOBJ_ASHANDLE types are a value type, so I guess they don't need a counter.
I assume you don't need track ref counting for the "ref" type itself but for whatever "ref" type holds and looking at the implementation, that is already done when you assign values to the type.

This topic is closed to new replies.

Advertisement