Sign in to follow this  
Followers 0
Ash Taheri

Failed to pass or return value type from application in native calling convention

3 posts in this topic

Hi

Sorry for my bad English
 
When I try to pass a value type to a function in Ubuntu 14.04 amd64 I get the following error:
 
Don't support returning type 'Vector2' by value from application in native calling convention on this platform
 
But my code works prefectly in Windows systems. How can I get rid of this error?
 
Thanks
 
My register code:

void RegisterMathVector2Script()
{
    #if defined(_SCRIPT_ACTIVE_)
        int result;
        result = Engine::ScriptEngine->SetDefaultNamespace(""); assert(result >= 0);

        if (strstr(asGetLibraryOptions(), "AS_MAX_PORTABILITY") == 0)
        {
            #if AS_CAN_USE_CPP11
                result = Engine::ScriptEngine->RegisterObjectType("Vector2", sizeof(Vector2), asOBJ_VALUE | asOBJ_POD |
                    asGetTypeTraits<Vector2>()); assert(result >= 0);
            #else
                result = Engine::ScriptEngine->RegisterObjectType("Vector2", sizeof(Vector2), asOBJ_VALUE | asOBJ_POD |
                    asOBJ_APP_CLASS | asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT); assert(result >= 0);
            #endif

            result = Engine::ScriptEngine->RegisterObjectBehaviour("Vector2", asBEHAVE_CONSTRUCT, "void f(float x, float y)",
                asFUNCTION(Vector2Construct), asCALL_CDECL_OBJLAST); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void Set(float x, float y)", asMETHOD(Vector2, Set),
                asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "float GetLength()", asMETHOD(Vector2, GetLength),
                asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "float GetAngle()", asMETHOD(Vector2, GetAngle),
                asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void SetLengthAngle(float len, float ang)",
                asMETHOD(Vector2, SetLengthAngle), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void Invert()", asMETHOD(Vector2, Invert),
                asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void Normalize()", asMETHOD(Vector2, Normalize),
                asCALL_THISCALL); assert(result >= 0);

            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 &opAssign(const Vector2 &in) const",
                asMETHODPR(Vector2, operator =, (const Vector2&), void), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 &opAddAssign(const Vector2 &in) const",
                asMETHODPR(Vector2, operator +=, (const Vector2&), void), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 &opSubAssign(const Vector2 &in) const",
                asMETHODPR(Vector2, operator -=, (const Vector2&), void), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 &opMulAssign(const float &in) const",
                asMETHODPR(Vector2, operator *=, (const float&), void), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 &opDivAssign(const float &in) const",
                asMETHODPR(Vector2, operator /=, (const float&), void), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 &opMulAssign(const Vector2 &in) const",
                asMETHODPR(Vector2, operator *=, (const Vector2&), void), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 &opDivAssign(const Vector2 &in) const",
                asMETHODPR(Vector2, operator /=, (const Vector2&), void), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "bool opEquals(const Vector2 &in) const",
                asMETHODPR(Vector2, operator ==, (const Vector2&), bool), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opAdd(const Vector2 &in) const",
                asMETHODPR(Vector2, operator +, (const Vector2&), Vector2), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opSub(const Vector2 &in) const",
                asMETHODPR(Vector2, operator -, (const Vector2&), Vector2), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opMul(const Vector2 &in) const",
                asMETHODPR(Vector2, operator *, (const Vector2&), Vector2), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opDiv(const Vector2 &in) const",
                asMETHODPR(Vector2, operator /, (const Vector2&), Vector2), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opMul(const float &in) const",
                asMETHODPR(Vector2, operator *, (const float&), Vector2), asCALL_THISCALL); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opDiv(const float &in) const",
                asMETHODPR(Vector2, operator /, (const float&), Vector2), asCALL_THISCALL); assert(result >= 0);
        }
        else
        {
            result = Engine::ScriptEngine->RegisterObjectType("Vector2", sizeof(Vector2), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS |
                asOBJ_APP_CLASS_CONSTRUCTOR | asOBJ_APP_CLASS_ASSIGNMENT); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectBehaviour("Vector2", asBEHAVE_CONSTRUCT, "void f(float x, float y)",
                asFUNCTION(Vector2ConstructGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void Set(float x, float y)",
                asFUNCTION(Vector2MethodSetGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "float GetLength()",
                asFUNCTION(Vector2MethodGetLengthGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "float GetAngle()",
                asFUNCTION(Vector2MethodGetAngleGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void SetLengthAngle(float len, float ang)",
                asFUNCTION(Vector2MethodSetLengthAngleGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void Invert()",
                asFUNCTION(Vector2MethodInvertGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void Normalize()",
                asFUNCTION(Vector2MethodNormalizeGeneric), asCALL_GENERIC); assert(result >= 0);

            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void &opAssign(const Vector2 &in) const",
                asFUNCTION(Vector2OpAssignGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void &opAddAssign(const Vector2 &in) const",
                asFUNCTION(Vector2OpAddAssignGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void &opSubAssign(const Vector2 &in) const",
                asFUNCTION(Vector2OpSubAssignGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void &opMulAssign(const float &in) const",
                asFUNCTION(Vector2OpMulAssignfGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void &opDivAssign(const float &in) const",
                asFUNCTION(Vector2OpDivAssignfGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void &opMulAssign(const Vector2 &in) const",
                asFUNCTION(Vector2OpMulAssignGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "void &opDivAssign(const Vector2 &in) const",
                asFUNCTION(Vector2OpDivAssignGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "bool opEquals(const Vector2 &in) const",
                asFUNCTION(Vector2OpEqualsGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opAdd(const Vector2 &in) const",
                asFUNCTION(Vector2OpAddGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opSub(const Vector2 &in) const",
                asFUNCTION(Vector2OpSubGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opMul(const Vector2 &in) const",
                asFUNCTION(Vector2OpMulGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opDiv(const Vector2 &in) const",
                asFUNCTION(Vector2OpDivGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opMul(const float &in) const",
                asFUNCTION(Vector2OpMulfGeneric), asCALL_GENERIC); assert(result >= 0);
            result = Engine::ScriptEngine->RegisterObjectMethod("Vector2", "Vector2 opDiv(const float &in) const",
                asFUNCTION(Vector2OpDivfGeneric), asCALL_GENERIC); assert(result >= 0);
        }

        result = Engine::ScriptEngine->RegisterObjectProperty("Vector2", "float X", asOFFSET(Vector2, X)); assert(result >= 0);
        result = Engine::ScriptEngine->RegisterObjectProperty("Vector2", "float Y", asOFFSET(Vector2, Y)); assert(result >= 0);
    #endif
}
0

Share this post


Link to post
Share on other sites

On Linux 64bit AngelScript needs to know a bit more about the type in order to be able to pass POD types to registered native functions.

I assume the Vector2 class is actually a structure with 2 floats and nothing else. In that case you should add the flag asOBJ_APP_CLASS_ALLFLOATS to the RegisterObjectType, 

Regards,
Andreas

 

0

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  
Followers 0