Advertisement

How to register this by angelscript ?

Started by April 01, 2008 03:55 AM
4 comments, last by WitchLord 16 years, 7 months ago
class A { operator const char* ( ) const { //do something ... } }; How to register it ? use METHOD() or METHODPR( ) ?
Good question. :)

I think, you can use asMETHOD like this:

asMETHOD(A, operator const char*)

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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]
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?

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

I am using VC8(2005) :(
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);


AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement