Advertisement Jump to content
Sign in to follow this  

register irrlicht-engine string

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

Hey Guys, ive tried to register the irrlicht string type and everything works fine besides the registration of the global behaviours.. what i have so far:
typedef irr::core::stringc string;
//RFB = return false, if condition is false

bool registerIrrStr( asEnginePtr *engine ) {

//this code is taken from stdstring.cpp

RFB( engine->RegisterObjectType("string", sizeof(string), asOBJ_VALUE | asOBJ_APP_CLASS_CDA) >= 0 );

RFB( engine->RegisterStringFactory("string", asFUNCTION(StringFactory), asCALL_CDECL) >= 0 );

RFB( engine->RegisterObjectBehaviour("string", asBEHAVE_CONSTRUCT,  "void f()",                    asFUNCTION(ConstructString), asCALL_CDECL_OBJLAST) >= 0 );

RFB( engine->RegisterObjectBehaviour("string", asBEHAVE_DESTRUCT,   "void f()",                    asFUNCTION(DestructString),  asCALL_CDECL_OBJLAST) >= 0 );

RFB( engine->RegisterObjectBehaviour("string", asBEHAVE_ASSIGNMENT, "string&f(const string &in)", asMETHODPR(string, operator =, (const string&), string&), asCALL_THISCALL) >= 0 );

RFB( engine->RegisterObjectBehaviour("string", asBEHAVE_ADD_ASSIGN, "string&f(const string&in)", asMETHODPR(string, operator+=, (const string&), string&), asCALL_THISCALL) >= 0 );

/////so when i want to register the equal operator, compiler says:
////error C2065: '==': undeclared identifier
RFB( engine->RegisterGlobalBehaviour(asBEHAVE_EQUAL,       "bool f(const string&in, const string&in)",   asFUNCTIONPR(operator ==, (const string&, const string&), bool), asCALL_CDECL) >= 0 );


return true;


how come it does work with std::string which is basicly the same as irr::string?

Share this post

Link to post
Share on other sites
That is indeed strange. Somehow the compiler is mistaking '==' for an identifier rather than the operator token.

You're registering the operator exactly the same way I do it in the CScriptString add-on, except that you're using an RFB macro that I'm not familiar with. Presumably to check for errors.

It could be that this macro is expanded to some invalid syntax when used with the operator ==.

How is the macro defined? Does the problem occur even if you don't use the RFB macro?

Share this post

Link to post
Share on other sites
yep tried it your way with assert and still, he does not recognize the equal operator. i mean i could write a wrapper around it but this cant be the overall solution imo..
i also thought about problems with namespaces, since in stdstring you use
namespace std but using irrlicht´s namespace didnt solve the problem..


#define returnfail( COND_BOOL, VFAIL ) if(!(COND_BOOL)) return VFAIL
#define RFB( COND_BOOL ) returnfail(COND_BOOL,false)

Share this post

Link to post
Share on other sites
Is the irrlicht string equality operator declared as a global function, or a class method?

If it is a class method, then you'll need to write a wrapper function. Still, if it was a class method the compiler error should have been that it can't find the function, not the parser error that you're getting.

What compiler are you using?


I checked out the source for irrlicht, and the operator is indeed declared as a class method. AngelScript expects a global function, so you will indeed have to write a simple wrapper function.

Share this post

Link to post
Share on other sites
It does, and it is.

Just as information, a future version of AngelScript will allow both class methods and global functions for the operator behaviours.

Share this post

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

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!