Jump to content

  • Log In with Google      Sign In   
  • Create Account


- - - - -

Method overloading in Angelscript


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 24 April 2004 - 12:30 PM

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

Sponsor:

#2 Andreas Jonsson   Moderators   -  Reputation: 3261

Like
Likes
Like

Posted 24 April 2004 - 10:56 PM

You'll have to let the compiler know which method you mean by casting the pointer to the right type.


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]

#3 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 24 April 2004 - 11:55 PM

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:


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]

#4 Andreas Jonsson   Moderators   -  Reputation: 3261

Like
Likes
Like

Posted 26 April 2004 - 02:13 AM

Sorry about that.

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

#5 Desdemona   Members   -  Reputation: 158

Like
Likes
Like

Posted 26 April 2004 - 05:18 AM

Ok, that didnt work either, but it got me started; the correct syntax appears to be

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]

#6 meink   Members   -  Reputation: 133

Like
Likes
Like

Posted 02 May 2004 - 02:28 PM

Just as a reference for anyone else having this problem, using MSVC6 you need to use the following syntax:
asMETHOD((void (CCamera::*)(float, float, float))CCamera::SetView)

Note the extra CCamera towards the end.

- Xavier




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS