Jump to content
  • Advertisement
Sign in to follow this  
iraxef

When to use asOBJ_APP_CLASS_ALLINTS

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

Advertisement

The flags asOBJ_APP_CLASS_ALLINTS/FLOATS are used to tell AngelScript what the type of content the object has, so AngelScript can decide how the object should be passed to registered functions in native calling conventions. The only ABI so far that needs these flags is the AMD/Intel 64bit ABI that the g++ compiler uses. This specific ABI can decide to put the object in the CPU float registers or general registers depending on the type of the members of the class.

 

On any other platform or compiler the flags will have no effect.

 

The documentation that describes when/how to use these flags is here:

 

Manual: Value types and native calling convention

 

Regards,

Andreas

Share this post


Link to post
Share on other sites

Hi Andreas,

So the pointer is also a type of "integer" in this case, right?

thanks

More: If I have an empty value type like:

struct PH1ST {};

Then should I use the asOBJ_APP_CLASS_ALLINTS flag to register it? I think I should, because an object of the empty class also has its size. But when I add this flag to it, the engine crashed :(

Edited by ASBai

Share this post


Link to post
Share on other sites

Yes, pointers are treated by the compilers as pure POD types, same as integers. If you intend to register a pointer as a type, then you should use the flag asOBJ_APP_PRIMITIVE.

I believe how an empty struct like this is treated is compiler specific. I would guess that the flags asOBJ_APP_CLASS | asOBJ_APP_CLASS_ALLINTS should be used, but only by testing it can you be certain. It is possible that the compiler treats this type like a primitive too, in which case asOBJ_APP_PRIMITIVE should be used instead.

 

Share this post


Link to post
Share on other sites

Hi Andreas,

Thanks for your answer. I'm now using "asOBJ_VALUE|asOBJ_POD" for an empty struct. It seems work fine on 32bit vc8 (x86). But when I add asOBJ_APP_CLASS_ALLINTS flag, it crashed.  I'll test it on other platform.

:-)

UPDATE:

I've tried to use:

struct PH1ST {};
// ...
int r = pENGINE->RegisterObjectType("PH1ST",  sizeof(PH1ST), asOBJ_VALUE|asOBJ_POD|asOBJ_APP_PRIMITIVE); 

assert(r >= 0);

And it also works fine now.

Edited by ASBai

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.

GameDev.net 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!