bug? asBEHAVE_VALUE_CAST with bool
Because it might be a bug, it reports.
The error occurs if bool is specified with asBEHAVE_VALUE_CAST.
r = engine->RegisterObjectType("CDispatchResult", 0, asOBJ_REF); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("CDispatchResult", asBEHAVE_FACTORY, "CDispatchResult @f()", asFUNCTION(CDispatchResultWrapper::DefaultFactory), asCALL_CDECL); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("CDispatchResult", asBEHAVE_ADDREF, "void f()", asMETHOD(CDispatchResultWrapper,AddRef), asCALL_THISCALL); assert( r >= 0 );
r = engine->RegisterObjectBehaviour("CDispatchResult", asBEHAVE_RELEASE, "void f()", asMETHOD(CDispatchResultWrapper,Release), asCALL_THISCALL); assert( r >= 0 );
r = engine->RegisterObjectMethod("CDispatchResult", "CDispatchResult &opAssign(const CDispatchResult &in)", asMETHODPR(CDispatchResultWrapper, operator =, (const CDispatchResultWrapper&), CDispatchResultWrapper&), asCALL_THISCALL); assert( r >= 0 );
// bool
r = engine->RegisterObjectMethod("CDispatchResult", "bool get_Bool() const", asMETHODPR(CDispatchResultWrapper, get_Bool, (void) const, bool),asCALL_THISCALL); assert(r>=0);
/* Error*/ r = engine->RegisterObjectBehaviour("CDispatchResult", asBEHAVE_VALUE_CAST, "bool f() const", asMETHODPR(CDispatchResultWrapper, get_Bool, (void) const, bool),asCALL_THISCALL); assert(r>=0);
// float
r = engine->RegisterObjectMethod("CDispatchResult", "float get_Float() const", asMETHODPR(CDispatchResultWrapper, get_Float, (void) const, float),asCALL_THISCALL); assert(r>=0);
/* OK */ r = engine->RegisterObjectBehaviour("CDispatchResult", asBEHAVE_VALUE_CAST, "float f() const", asMETHODPR(CDispatchResultWrapper, get_Float, (void) const, float),asCALL_THISCALL); assert(r>=0);
// double
r = engine->RegisterObjectMethod("CDispatchResult", "double get_Double() const", asMETHODPR(CDispatchResultWrapper, get_Double, (void) const, double),asCALL_THISCALL); assert(r>=0);
/* OK */ r = engine->RegisterObjectBehaviour("CDispatchResult", asBEHAVE_VALUE_CAST, "double f() const", asMETHODPR(CDispatchResultWrapper, get_Double, (void) const, double),asCALL_THISCALL); assert(r>=0);
This is not a bug. It is by design.
No types can be converted to or from the boolean type. I took this design because it is a very common bug for non-experienced programmers to incorrectly interpret boolean values by not explicitly comparing the value with true or false.
This is also documented in the manual, though I could probably explain it a bit better.
No types can be converted to or from the boolean type. I took this design because it is a very common bug for non-experienced programmers to incorrectly interpret boolean values by not explicitly comparing the value with true or false.
This is also documented in the manual, though I could probably explain it a bit better.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement