Sign in to follow this  
Pris

REF_CAST

Recommended Posts

Hello, First, thank you again for such excellent script engine :) I would like to ask, when you intend to implement support for casting reference types (REF_CAST), I asking about it because i need to plan my work in my job. Thank you in advance

Share this post


Link to post
Share on other sites
I've been quite busy the latest weeks, between private life, work, and the BMFont update. But I hope to get more time to work on the next release for AngelScript now.

REF_CAST is on the top of my to-do list and I'll probably implement it very soon (though you'll probably have to give me at least another month or two).

Regards,
Andreas

Share this post


Link to post
Share on other sites
Hi Pris,

I just checked in the first support for asBEHAVE_REF_CAST in the SVN.


// Example REF_CAST behaviour
B* castAtoB(A* a)
{
B* b = dynamic_cast<B*>(a);
if( b == 0 )
{
// Since the cast couldn't be made, we need to release the handle we received
a->release();
}
return b;
}

// Example registration of the behaviour
r = engine->RegisterGlobalBehaviour(asBEHAVE_REF_CAST, "B@ f(A@)", asFUNCTION(castAToB), asCALL_CDECL); assert( r >= 0 );


In the script this is used as follows:


// AngelScript
A a;
B @b = cast<B@>(a);


Currently the casting can only be done via explicit casts, but later on I'll implement asBEHAVE_REF_CAST_IMPLICIT that will allow the application to tell AngelScript which casts that can be made implicitly, e.g. when casting from derived class to base class.

Share this post


Link to post
Share on other sites
Hello,


Thank you for so quick feature implementation. I try it very soon and give you a reply.

//EDIT

I've updated script engine to new version. Implemented REF_CAST and what I could say, it's working :). Thanks a lot.

[Edited by - Pris on May 26, 2008 8:57:49 AM]

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