Method overloading in Angelscript
I noticed the other day Angelscript supports method/function overloading now. I have this working with two methods in my C++ code SetView and SetView2 both exposed as SetView in Angelscript. Is there any way to expose overloaded methods to Angelscript (e.g. if both methods in C++ were called SetView)?
If I try this using asMETHOD(CCamera::SetView) for both methods then my compiler doesnt know which method I mean. Is there any syntax to tell the compiler which method I mean?
Thanks
Joe
You'll have to let the compiler know which method you mean by casting the pointer to the right type.
Andreas
__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game
[edited by - WitchLord on April 25, 2004 5:57:32 AM]
class CTest{ void SetView(int); void SetView(float);} engine->RegisterObjectMethod("test", "void SetView(int)", asMETHOD((void CTest::(*)(int))SetView), asCALL_THISCALL);engine->RegisterObjectMethod("test", "void SetView(float)", asMETHOD((void CTest::(*)(float))SetView), asCALL_THISCALL);
Andreas
__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game
[edited by - WitchLord on April 25, 2004 5:57:32 AM]
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Okay that is pointing me in the right dirrection; I was only familiar with the syntax for function pointers, not methods. But it still doesnt work.
I'm using Visual Studio.NET 2003, and the C++ compiler is coughing up an error with that syntax:
Any suggestions? What compiler are you using?
Joe
[edited by - Desdemona on April 25, 2004 6:59:59 AM]
I'm using Visual Studio.NET 2003, and the C++ compiler is coughing up an error with that syntax:
asMETHOD((bool CCamera::(*)(float, float, float))SetView)
error C2589: '(' : illegal token on right side of '::'Any suggestions? What compiler are you using?
Joe
[edited by - Desdemona on April 25, 2004 6:59:59 AM]
Sorry about that.
I think the correct syntax is without the paranthesis:
__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game
I think the correct syntax is without the paranthesis:
asMETHOD((bool CCamera::*(float, float, float))SetView)
__________________________________________________________
www.AngelCode.com - game development and more...
AngelScript - free scripting library - Tower - free puzzle game
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game
Ok, that didnt work either, but it got me started; the correct syntax appears to be
Thanks
[edited by - Desdemona on April 26, 2004 12:22:56 PM]
engine->RegisterObjectMethod("CCamera", "void SetView(const VECTOR3& vPosition)", asMETHOD((void (CCamera::*)(const D3DXVECTOR3&))SetView), asCALL_THISCALL);engine->RegisterObjectMethod("CCamera", "void SetView(float x, float y, float z)", asMETHOD((void (CCamera::*)(float, float, float))SetView), asCALL_THISCALL);
Thanks
[edited by - Desdemona on April 26, 2004 12:22:56 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement