Jump to content

  • Log In with Google      Sign In   
  • Create Account

- - - - -

Operator add,sub,multiply,divide with scoped types


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 midnite   Members   -  Reputation: 170

Like
0Likes
Like

Posted 09 September 2008 - 07:14 AM

I have a type registered as asOBJ_REF|asOBJ_SCOPED and I would like to return it from an operator add, etc. I need it scoped because it requires special alignment upon allocation, but does not support reference counting, nor should it. I can't return it by value because it is a reference type. I can't return it by handle (@) because it doesn't support handles. Returning it by reference (&) lets it compile, but the memory is leaked since I have to allocate a new instance of the type in the operator add. Any ideas of how to handle my situation? (I emailed Andreas, but I know he's really busy right now, so just in case someone on the board knows the answer)

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3444

Like
0Likes
Like

Posted 09 September 2008 - 02:39 PM

Indeed I'm quite busy. But this does require my attention because it could be thought of as a bug, at very least a design flaw, as it renders the scoped reference types quite difficult to use.

The solution (as I mentioned in the e-mail, but repeat here for the benefit of others) is to change AngelScript to allow the application to register functions to return these scoped reference types by handle (even though within the scripts the handle of the type cannot be taken, as it is supposed to emulate value types). This will allow AngelScript to receive the value and then immediately release it after it has copied it to whatever variable the script wants to store it in.

Regards,
Andreas
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS