Vote count:
0
Im using SWIG for generating my Lua wrapper and I have the following structure in my SWIG interface file:
%module Object
%{
vec3 Object_location_get( Object *object )
{
vec3 t = { object.m.r3.x,
object.m.r3.y,
object.m.r3.z };
return t;
}
void Object_location_set( Object *object, const vec3 location )
{
object->basis_matrix.r3.x = location.x;
object->basis_matrix.r3.y = location.y;
object->basis_matrix.r3.z = location.z;
}
%}
typedef struct
{
%mutable;
float x,y,z;
} vec3;
typedef struct
{
%mutable;
float x,y,z,w;
} vec4;
typedef struct
{
%mutable;
vec4 r0,r1,r2,r3;
} mat4;
typedef struct
{
%mutable;
mat4 m;
%extend
{
%mutable;
vec3 location;
};
} Object;
...
...
...
Basically the basics are working as expected using the following:
MyObject.location=vec3_set(1.0,2.0,3.0)
However when assigning a specific component it does not have no effect since; in example the X will go trigger the _wrap_vec3_set_x function.
MyObject.location.x=1.0
I might be wrong but; I read the SWIG and it seems to be possible to change this behavior by using a %typemap with Object::location::x. I try many different combinations but without any success... What Im trying to do is to make SWIG generate the proper wrapper function when accessing only the (in example) X component of the Object location. Is that event possible or Im missing something?
asked 1 min ago
Using SWIG %typemap to extend structure behaviors
Aucun commentaire:
Enregistrer un commentaire