Sign in to follow this  

When to use asOBJ_APP_CLASS_ALLINTS

Recommended Posts

I read this post and it mentions the AMD64 ABI: http://www.gamedev.net/topic/614684-asobj-app-class-allints/

 

Does that mean that there's no benefit to using asOBJ_APP_CLASS_ALLINTS/FLOATS if you're targetting e.g. 32-bit Intel? I couldn't find anything in the documentation (besides the listing in the enum) as far as guidance for this thing's use.

 

Thank you

Share this post


Link to post
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this