Jump to content
  • Advertisement
Sign in to follow this  
Takayuki

bug? asBEHAVE_VALUE_CAST with bool

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

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);

Share this post


Link to post
Share on other sites
Advertisement
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.

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!