Jump to content
  • Advertisement
Sign in to follow this  
zopenge

How to register this by angelscript ?

This topic is 3845 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

class A { operator const char* ( ) const { //do something ... } }; How to register it ? use METHOD() or METHODPR( ) ?

Share this post


Link to post
Share on other sites
Advertisement
Thanks again ~~ I will try it :P

error C2833: 'operator const' is not a recognized operator or type

it give me an error when I try to use asMETHOD( classname, operator const char* )

:(

[Edited by - zopenge on April 6, 2008 11:54:50 PM]

Share this post


Link to post
Share on other sites
I successfully did it with:


class A
{
public:
operator const char * ( ) const { return 0; }
};

engine->RegisterObjectMethod("obj", "void f()", asMETHOD(A, operator const char *), asCALL_THISCALL);


I'm using MSVC7.1. What compiler are you using?

Share this post


Link to post
Share on other sites
Perhaps if you try it without the macro, i.e:


asSMethodPtr<sizeof(void (c::*)())>::Convert(&c::operator const char *)


If that still doesn't work I suggest you write a light wrapper function:


const char *ClassName_CastConstCharPtr(const ClassName *obj)
{
return (const char *)obj;
}

RegisterObjectMethod("obj", "void f()", asFUNCTION(ClassName_CastConstCharPtr), asCALL_CDECL_OBJLAST);


Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!