• Advertisement
Sign in to follow this  

How to register this by angelscript ?

This topic is 3574 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