Jump to content
  • Advertisement
Sign in to follow this  
chewbakka

Autohandles with generic callconv

This topic is 2216 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!