Autowrapper for generic calling convention and ?& arguments

Started by
1 comment, last by WitchLord 4 years, 6 months ago

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() &&
                !dt->IsObjectHandle())
                return *(void**) &stackPointer[offset];
            // Get the address of the value
            return &stackPointer[offset];
        }
        if (dt->GetTokenType() == ttQuestion) {
            n++;
            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?

Advertisement

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.

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement