Jump to content
  • Advertisement
Sign in to follow this  
RsblsbShawn

does asOBJ_APP_FLOAT work?

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

it's not in any of the tests, and the only documentation says it's for float or double types. I tried registering a type as such: engine->RegisterObjectType("Real", sizeof(math::Real), asOBJ_VALUE | asOBJ_APP_FLOAT) and it returns -5 (asINVALID_ARG) (Real is #defined as either double or float depending on how it's compiled) If I change the type to asOBJ_VALUE | asOBJ_POD it compiles, but obviously the Real type doesn't work as it should Thanks again! -Shawn.

Share this post


Link to post
Share on other sites
Advertisement
It appears that there is a bug in RegisterObjectType() that prevents the type from being registered.



// as_scriptengine.cpp : line 1180
else if( flags & asOBJ_APP_FLOAT )
{
// Must not set the class flags nor the primitive flag
if( flags & (asOBJ_APP_CLASS |
asOBJ_APP_CLASS_CONSTRUCTOR |
asOBJ_APP_CLASS_DESTRUCTOR |
asOBJ_APP_CLASS_ASSIGNMENT |
asOBJ_APP_FLOAT) ) // <-- remove this!
return ConfigError(asINVALID_ARG);
}

Share this post


Link to post
Share on other sites
Excellent, thanks so much. As per the comment I changed it to asOBJ_APP_PRIMITIVE, probably just a copy & paste error by the original author.

-Shawn.

Share this post


Link to post
Share on other sites
Upon further inspection I don't know if it actually works correctly.

Functions taking double or float don't work with Real types, so I think it's more than just the registration that doesn't work.

Share this post


Link to post
Share on other sites
Quote:
Original post by RsblsbShawn
Upon further inspection I don't know if it actually works correctly.

Functions taking double or float don't work with Real types, so I think it's more than just the registration that doesn't work.


I've never used it myself but IIRC it's treated the same as any other object except when used as a return type. With that in mind you probably need to register some behaviors (cast, assignment, construction, etc.) for special cases.

Share this post


Link to post
Share on other sites
The asOBJ_APP_xxx flags only tells AngelScript what the real object is for C++, it doesn't affect how AngelScript will treat the object type. These flags are necessary when AngelScript needs to pass a value of the type to a registered function by value (or return by value). They are not used anywhere else.

If you want the "Real" type to work like a float or double you need to register the proper behaviours as Digital_Asphyxia pointed out.

However, you can also wait until I've incorporated the typedef feature that Digital_Asphyxia implemented, which would then let you do what you really want.

Another option is to use a preprocessor pass before adding scripts to AngelScript to substitute all "Real" keywords for "float" or "double". For this you may be interested in looking into Deyja's preprocessor: http://www.omnisu.com/preprocessor.html (Hmm, doesn't seem like the link works any more. Deyja: Are you reading this?)

Regards,
Andreas

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!