Jump to content
  • Advertisement
Sign in to follow this  
Alexander Orefkov

Autowrapper for generic calling convention and ?& arguments

Recommended Posts

Hi. I use Urho3D game engine with AngelScript. But it segviolated on Android arm64-v8a. After some searches, I found that the reason was in the applied automatic wrapper for arm64, which does not work with "?&" parameters correctly. Therefore, I changed the void *asCGeneric::GetAddressOfArg(asUINT arg) function to this implementation:

    // fix for wrap16.h return address of real arg, parametr ?& count as 2 arg.
    int offset = 0;
    for (asUINT n = 0, real = 0; real < sysFunction->parameterTypes.GetLength(); n++, real++) {
        asCDataType* dt = &sysFunction->parameterTypes[real];
        if (n == arg) {
            if (!dt->IsReference() &&
                dt->IsObject() &&
                return *(void**) &stackPointer[offset];
            // Get the address of the value
            return &stackPointer[offset];
        if (dt->GetTokenType() == ttQuestion) {
            if (n == arg)
                return &stackPointer[offset + AS_PTR_SIZE];
        offset += dt->GetSizeOnStackDWords();
    return 0;

After that, everything began to work correctly. But this only works for automatic wrapper and break the program in case of normal use.

Is it possible to add this code in engine as the "void *GetAddressOfRealArg(asUINT arg)" function and rewrite the wrapper to use it?

Edited by Alexander Orefkov

Share this post

Link to post
Share on other sites

I'll need to think about this.

The ? type isn't really supposed to be treated as two separate arguments. Perhaps the case should be treated in the auto-wrapper instead.

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  

  • 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!