Jump to content
  • Advertisement
Sign in to follow this  
glcolor

Add support for ref-counted system which uses 0 as initial ref count?

This topic is 1032 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

Hi,Andreas.
Recently I have to add scripting support for an old project,this project uses a ref-counted system which uses 0 as the initial ref count instead of 1,just like COM, this causes crash in AngelScript by the wrong ref count, could you add some support for this kind of ref-counted system?
Thanks a lot.

Share this post


Link to post
Share on other sites
Advertisement

As far as i know, the only place where Angelscript needs to know the ref count is when using the asBEHAVE_GETREFCOUNT behavior. Simply adding 1 when returning this value should suffice, unless i'm missing something.

Share this post


Link to post
Share on other sites
I have not noticed asBEHAVE_GETREFCOUNT before,it looks like just be used by classes registered with asOBJ_GC,but I registered the classes with only the asOBJ_REF flag,so only asBEHAVE_ADDREF and asBEHAVE_RELEASE will be used. I'll study it,thanks.

Share this post


Link to post
Share on other sites

Solokiller is correct. Besides asBEHAVE_GETREFCOUNT AngelScript doesn't need to know the actual value of the refcount.

 

The only thing the application must make sure is that when it returns a handle to the script the refcount for the returned handle is accounted for, as AngelScript will release that handle afterwards when it is done with it. This can either be done manually or automatically using the auto-handles @+.

 

Whether your refcount starts at 0 or 1 has no importance to AngelScript, as long as you implement the release behavior accordingly, i.e. if it starts at 0, you'll want to destroy the object when the refcount becomes negative rather than when it reaches 0.

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!