Skip to main content
GameDev.net gamedev.net
🔒 Locked

Function overloading issue.

Started by BornToCode Jun 21, 2008 at 7:32 PM 3 replies 1.3k views
Original Post
BornToCode
BornToCode
In my C++ class i have methods which are overloaded. In angel script i tried to bind those method but it keeps on telling me that it cannot differentiate which one of the overloaded method to use, event though i am passing the proper parameters to it. Here is an example of what i am doing This is my C++ class. int GetTileAnimationFrame(int index); int GetTileAnimationFrame(int x,int y); AngelScript. r = engine->RegisterObjectMethod("TileImage","int GetTileFrame(int x,int y)",asMETHOD(Emotion2D::CTileImage,GetTileAnimationFrame),asCALL_THISCALL);assert(r>=0); This is the error i am getting. cannot convert from 'overloaded-function' to 'void (__thiscall Emotion2D::CTileImage::* )(void)'
WitchLord
WitchLord
For overloaded functions you need to use the asMETHODPR macro, which let's you inform the parameters and return type of the method. Otherwise C++ won't know which function you want to take the address of.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
silvermace
silvermace
or you should be able to cast the method pointer (this what you do with boost.python):

(int (Emotion2D::CTileImage::*)(int,int))&GetTileAnimationFrame
WitchLord
WitchLord
Which is exactly what the asMETHODPR macro does behind the scenes. :)
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
BornToCode
BornToCode
Could you give an example using asMETHODPR.
Forget it i figure it out.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.