Since I use AS there is a bug in the generic calling convention when returning auto handles.
When a function returns an autohandle, the generic callconv doesn't increase it's reference counter and later it is going to cause crashes. I've managed to fix this by adding
[source lang="cpp"] if ( sysFunction->returnType.IsObject()
&& !sysFunction->returnType.IsReference()
&& sysFunction->returnType.IsObjectHandle()
&& sysFunc->returnAutoHandle
&& m_regs.objectRegister )
m_engine->CallObjectMethod( m_regs.objectRegister, sysFunction->returnType.GetObjectType()->beh.addref );
[/source]
to the asCContext::CallGeneric function before "Clean up function parameters" (line 4382 in 2.24.1).
I'm using this for a long time now (copying it over upon AS upgrade), but not sure if this is the correct solution. It works though.
Autohandles with generic callconv
Auto handles were only intended to be used with native calling conventions. For generic calling conventions they have always been ignored.
However, I'll look into this scenario to see if a definite solution can be made.
However, I'll look into this scenario to see if a definite solution can be made.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
I use autohandles on my script interface. The solution itself can be compiled to use native calling conventions or generic, based on the target device (I use generic on android mips and used to use it for arm too before). I use macros like
_DelegateClassMethod( T, FrameServer, AddListener );
and the compiler decides if it is going to be registered natively or generic. With the little fix, the autohandles are working well for generic calling too (no crashes/leaks).
_DelegateClassMethod( T, FrameServer, AddListener );
and the compiler decides if it is going to be registered natively or generic. With the little fix, the autohandles are working well for generic calling too (no crashes/leaks).
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement