Advertisement

Port on Mac OS and iPad - problems and question

Started by February 27, 2012 12:53 PM
8 comments, last by FDsagizi 12 years, 8 months ago
Hellosmile.png

Mac OS x 10.7.2 x64:

ERR [0] Don't support returning type 'Vec3' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Quat' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Color' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Object' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Body' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Wheel' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Entity' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Light' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Animator' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Mat' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'Cam' by value from application in native calling convention on this platform
ERR [0] Don't support returning type 'SubEntity' by value from application in native calling convention on this platform
....
ERR [0] Invalid configuration. Verify the registered application interface.
[/quote]



What should be done to make it work?

Transform all the classes under (asREF)?

would like to ask but will there still any problems realties of scripts on iOS which ARM processor?
On Mac OSX 64bit AngelScript needs to know the content of the simple classes in order to know how to return them by value. I can only guess to the content of each of these classes, but I believe most of them can use either asOBJ_APP_CLASS_ALLINTS or asOBJ_APP_CLASS_ALLFLOATS. If you have a class that is a mixture of ints and floats, then you can try with asOBJ_APP_CLASS_ALLINTS anyway, but you'll have to test it because it depends on the actual layout of the class members whether it will work or not.

An alternative is to make sure the classes are always treated as complex, i.e. by defining an explicit destructor or copy constructor for the classes.

A third alternative is use the generic calling convention. With the new autowrappers that SiCrane provided this is just as easy as using the native calling conventions. You just use the different macros WRAP_FN, WRAP_MFN instead of asFUNCTION and asMETHOD. You can find the new autowrappers in the SVN.


There are currently no known problems with iOS / ARM processors.

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

Advertisement
Andreas Jonsson - Many thanks, perfectly work!!!

There are currently no known problems with iOS / ARM processors. [/quote]

iPad support native call ?
Yes.

Let me know if you encounter any problems.

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


Yes.

Let me know if you encounter any problems.


So first trabl with union

i use Vector3 from Ogre3D library

class Vec3
{
union {
struct{ float fa[3]; };
struct{ float x, y, z; };
struct{ unsigned int ix, iy, iz; };
struct{ unsigned int ia[3]; };
};

...
}


In visual studio its grate work, in MacOS and GCC 4.4.2 x64 work not correct

a'm change class Vector3 to this

class Vec3
{
float x,y,z;

...
}


register:



r=en->RegisterObjectProperty("Vec3", "float x", offsetof(Vec3, x)); assert( r >= 0 );
r=en->RegisterObjectProperty("Vec3", "float y", offsetof(Vec3, y)); assert( r >= 0 );
r=en->RegisterObjectProperty("Vec3", "float z", offsetof(Vec3, z)); assert( r >= 0 );


until such works - on the iPad is not launched

smile.png
What were the problems and how did you register the type before?

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

Advertisement

What were the problems and how did you register the type before?


script



Vec3 v( 1,-1,99 );


print( "vec x: " + v.x ); \\ result = 1

print( "vec y: " + v.y ); \\ result = -1

print( "vec z: " + v.z ); \\ result = 99



OK!

but if i get Vec3 from c++ or Vec3 to c++ from script - haw bug's exemple's

c++


Vec3 GetV()
{
return Vec3(1,-1,99 );
}


script




Vec3 v = GetV();


print( "vec x: " + v.x ); \\ result = 1

print( "vec y: " + v.y ); \\ result = 0

print( "vec z: " + v.z ); \\ result = 99




or next exemple
script


Vec3 v(1,-1,99);

CppPrintVector( v );


c++


void CppPrintVector( Vec3 & )
{
// Print: 99 0 0
}

Register all time:



void Vec3::Register( asIScriptEngine *en )
{
int r;


r=en->RegisterObjectType( "Vec3", sizeof( Vec3), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CA | asOBJ_APP_CLASS_ALLFLOATS ); assert( r >= 0 );

r=en->RegisterObjectProperty("Vec3", "float x", offsetof(Vec3, x)); assert( r >= 0 );
r=en->RegisterObjectProperty("Vec3", "float y", offsetof(Vec3, y)); assert( r >= 0 );
r=en->RegisterObjectProperty("Vec3", "float z", offsetof(Vec3, z)); assert( r >= 0 );

// Register the constructors
r=en->RegisterObjectBehaviour("Vec3", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(Vector3DefaultConstructor), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r=en->RegisterObjectBehaviour("Vec3", asBEHAVE_CONSTRUCT, "void f(const Vec3 &in)", asFUNCTION(Vector3CopyConstructor), asCALL_CDECL_OBJLAST); assert( r >= 0 );
r=en->RegisterObjectBehaviour("Vec3", asBEHAVE_CONSTRUCT, "void f(float, float, float)", asFUNCTION(Vector3InitConstructor), asCALL_CDECL_OBJLAST); assert( r >= 0 );

// Register the operator overloads
r=en->RegisterObjectMethod("Vec3", "Vec3 &opAddAssign(const Vec3 &in)", asMETHODPR(Vec3, operator+=, (const Vec3 &), Vec3&), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 &opSubAssign(const Vec3 &in)", asMETHODPR(Vec3, operator-=, (const Vec3 &), Vec3&), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 &opMulAssign(const Vec3 &in)", asMETHODPR(Vec3, operator*=, (const Vec3 &), Vec3&), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 &opDivAssign(const Vec3 &in)", asMETHODPR(Vec3, operator/=, (const Vec3 &), Vec3&), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 &opMulAssign(const float)", asMETHODPR(Vec3, operator*=, (const float), Vec3&), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 &opDivAssign(const float)", asMETHODPR(Vec3, operator/=, (const float), Vec3&), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "bool opEquals(const Vec3 &in)const",asMETHODPR(Vec3, operator==, (const Vec3&) const, bool), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 opAdd(const Vec3 &in)const", asMETHODPR(Vec3, operator+, (const Vec3&)const, Vec3), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 opSub(const Vec3 &in)const", asMETHODPR(Vec3, operator-, (const Vec3&)const, Vec3), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 opMul(const float)const", asMETHODPR(Vec3, operator*, (const float)const, Vec3), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 opMul(const Vec3 &in)const", asMETHODPR(Vec3, operator*, (const Vec3&)const, Vec3), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 opDiv(const float)const", asMETHODPR(Vec3, operator/, (const float)const, Vec3), asCALL_THISCALL); assert( r >= 0 );

// Register the object methods
r=en->RegisterObjectMethod("Vec3", "float normalise()", asMETHOD(Vec3,normalise), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "float length() const", asMETHOD(Vec3,length), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "float distance(const Vec3 &in) const", asMETHOD(Vec3,distance), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "float dotProduct(const Vec3 &in) const", asMETHOD(Vec3,dotProduct), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "float absDotProduct(const Vec3 &in) const", asMETHOD(Vec3,absDotProduct), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 crossProduct(const Vec3 &in) const", asMETHOD(Vec3,crossProduct), asCALL_THISCALL); assert( r >= 0 );
r=en->RegisterObjectMethod("Vec3", "Vec3 reflect(const Vec3 &in) const", asMETHOD(Vec3,reflect), asCALL_THISCALL); assert( r >= 0 );
}
I think the problem is because of the unions it is not possible to consider this type as being all floats.

It may work with all ints instead, i.e asOBJ_APP_CLASS_ALLINTS. Can you try it and let me know the result?

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


I think the problem is because of the unions it is not possible to consider this type as being all floats.

It may work with all ints instead, i.e asOBJ_APP_CLASS_ALLINTS. Can you try it and let me know the result?


Yes, it's work ok!

This topic is closed to new replies.

Advertisement