Sign in to follow this  
jamesmintram

Implicit cast to another class?

Recommended Posts

jamesmintram    101
Hello,

Is it possible with angelcode script to create a class that can be implicitly cast to another class?
Here is an example of usage (not written in Angelcode but you should get the idea)

[CODE]
class node
{
};

class anotherNode
{
public:
operator node () { return m_node; }

protected:
node m_node;
};

void needsNode ( node item ) {}

anotherNode someItem;
needsNode ( someItem ); //Here we call a function that needs a node class so someItem is implicity cast
[/CODE]

I should also note that I am wanting to do this with references/handles not concrete objects.

Hopefully you can see what I am trying to achieve [img]http://public.gamedev.net//public/style_emoticons/default/smile.png[/img]

Regards,
James Mintram

Share this post


Link to post
Share on other sites
WitchLord    4677
No, this is something that is currently unavailable.

You can do it for registered classes by registering the asBEHAVE_IMPLICIT_REF_CAST, but this is not available for script classes.

Can't anotherNode inherit from the node class, rather than keep it as a member? If it inherited from the node class, then the implicit cast would work.

Share this post


Link to post
Share on other sites
jamesmintram    101
I cannot inherit from Node as it is a registered c++ class. I was hoping by wrapping it in a script class that would be inmplictly cast to a Node which would achieve the same effect for me as inheriting directly from Node.

Is there another way to achieve what I am trying to do?

If not is it likely some feature like this would be implemented in the near future?

Regards,
James Mintram

Share this post


Link to post
Share on other sites
WitchLord    4677
Unfortunately not. The best that can be done at the moment is to provide a method to explicitly return the inner node.

I'll study the case and see what I can implement to support implicit cast operators in the script language.

Share this post


Link to post
Share on other sites

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