I know I can't create objects without AddRef, Release behaviors, but how can I register Ref objects without implementing AddRef/Release (for example setting _Void function) for them ?
for example singletons or references to existing application objects ?
I just don't want to override all of my classes with AddRef/Release, that's a little bit lame.
I did something like this, and I got assertion failure at registering asBEHAVE_ADDREF behaviour :
It fails because asCALL_CDECL is an illegal calling convention in this case, as AngelScript must be able to pass the object pointer to the function. You need a function that takes the object pointer as a parameter, and then you can use for example asCALL_CDECL_OBJLAST convention:
void _NullFunc(Physics *ptr)
{
}
If you have a lot of classes to register without proper reference counting, you can template the _NullFunc:
It fails because asCALL_CDECL is an illegal calling convention in this case, as AngelScript must be able to pass the object pointer to the function. You need a function that takes the object pointer as a parameter, and then you can use for example asCALL_CDECL_OBJLAST convention:
void _NullFunc(Physics *ptr)
{
}
If you have a lot of classes to register without proper reference counting, you can template the _NullFunc: