Sign in to follow this  

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

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

This topic is 822 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this