Hi,
I have a couple of objects that I currently introduce as single reference types into the scripting environment. This is because they are in-place allocated in a special memory manager. They obviously do not have any ref counting behaviours, either.
Now the management class only handles base pointers to the class hierarchy. I would like to create casting behaviours in AS now so that I can safely cast the types up and down the hierarchy.
I am not able to register the type casting like it is documented in the Class Hierarchies chapter of the manual. Returning by value is obviously wrong, returning by @ is equally wrong since there is no ref counting. Returning by & returns an error when I try to register the type cast.
Any ideas or hints on what I could also do?
Thanks!
Type-Casting single reference types
Working with STL makes a lot more sense if you think about the "std::" as referring to Sexually Transmitted Diseases.
I think the safest solution would be to register explicit methods that return a & to the other type, rather than attempting the use of the cast operator. If these other types are also registered as single reference types this should work, without allowing the script to keep references to the cast type.
If you don't care if the script keep handles to these in-place allocated objects you can register them as asOBJ_REF | asOBJ_NOCOUNT. AngelScript will then treat them as ordinary reference types, except that it will not attempt to call AddRef or Release on them.
If you don't care if the script keep handles to these in-place allocated objects you can register them as asOBJ_REF | asOBJ_NOCOUNT. AngelScript will then treat them as ordinary reference types, except that it will not attempt to call AddRef or Release on them.
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement