Skip to main content
GameDev.net gamedev.net
🔒 Locked

asOBJ_APP_PRIMITIVE and generic calling convention

Started by HenryAWE Mar 17, 2025 at 5:00 AM 2 replies 1.9k views
Original Post
HenryAWE
HenryAWE

I've registered char32_t from C++ as a value type with asOBJ_APP_PRIMITIVE | asOBJ_POD | asOBJ_APP_CLASS_MORE_CONSTRUCTORS. In the generic wrapper, I use GetArgDWord/SetReturnDWord to retrieve/return the value, but the result seems wrong. The same code works correctly in native calling convention. If I use *(char32_t*)gen->GetAddressOfArg and new(gen->GetAddressOfReturnLocation()), the result will be as expected.

None
WitchLord
WitchLord

I'll investigate.

The combination of asOBJ_APP_PRIMITIVE | asOBJ_POD | asOBJ_APP_CLASS_MORE_CONSTRUCTORS seems odd though. A primitive wouldn't have constructors. Presumably you should be using asOBJ_VALUE | asOBJ_POD | asOBJ_APP_PRIMITIVE for the char32_t type, though I haven't tested it yet.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
HenryAWE
HenryAWE

I've implemented a function to convert an int value to UTF-32 char as constructor, so I set the asOBJ_APP_CLASS_MORE_CONSTRUCTORS. Because the document says this flag is needed when the C++ class has additional constructors beyond the default and copy constructors.

However, if I remove the asOBJ_APP_CLASS_MORE_CONSTRUCTORS from my code, it still needs *(char32_t*)gen->GetAddressOfArg and new(gen->GetAddressOfReturnLocation()) to work as expected.

None
WitchLord
WitchLord

The asOBJ_APP_xxx flags are used during the native calling convention only so Angelscript can understand how the types should be passed to/from native C++ functions/methods. They have no impact to the generic calling convention.

I think I understand what is going on. GetArgDWord/SetArgDWord are meant for built in primitive types. To AngelScript the registered char32_t type is not a built in primitive, even though it is a primitive in C++.

I'll look into potentially changing this so Get/SetArgDWord can be used with registered types as long as they have been registered with asOBJ_POD.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.