Advertisement

[SOLVED] Casting in AngelScript

Started by May 07, 2010 03:38 PM
1 comment, last by Thoran 14 years, 9 months ago
Hi everyone! I have a class hierarchy in my app that is being exported to the script interface. It looks like: BoolPort derives from Port Registered method used in the sample(method is wrapping the actual AS register call, that's why it looks slightly different):

engine.registerClassMember("Transition","Port@ getInputPort(const string& in)",asMETHOD(Transition,getInputPort));


Now when I do the following in the script:

Port@ locPort = trans.getInputPort("fsm_end");
BoolPort@ locBoolPort = cast<BoolPort>(locPort);


I get the following messages from Angelscript parsing:

../../../../scripts/gamescripts/Proximity.as (102, 26) : ERR  : No conversion from 'Port@' to 'BoolPort@' available.
../../../../scripts/gamescripts/Proximity.as (102, 26) : ERR  : Can't implicitly convert from 'const int' to 'BoolPort@&'.


getInputPort is a method registered in the application interface and returns a Port* which actually contains a pointer to an instance of BoolPort. My question is now: Do I need to register casting behaviours when I want to do casting in the script, or should this work implicitly? Why does the logging message talk about "BoolPort@&"? That confuses me. Is it a handle or an object reference? Any help is greatly appreciated. Thoran [Edited by - Thoran on May 8, 2010 9:52:29 AM]
My website
AngelScript doesn't know about casting behavior if you don't explicitly tell it about them. You can see how to register cast behaviors here.
Advertisement
Thanks for this information. I really should dig better into the documentation, but I obviously missed that section on class hierarchies and casting.

Thoran
My website

This topic is closed to new replies.

Advertisement