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.
asOBJ_APP_PRIMITIVE and generic calling convention
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.
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.
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.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.