tags:

views:

46

answers:

1

I have following function :

typedef struct tagT{
int a ;
int b ;
}Point;

int lib_a_f_5(Point *out_t)
{

out_t->a = 20;
out_t->b = 30;

return 0;
}

How should I direct the SWIG to generate the correct code for ruby (or lua)? When putting following statement to the interface file :

%apply SWIGTYPE Point* {Point *out_t};

I got a warning :

liba.i:7: Warning(453): Can't apply (Point *OUTPUT). No typemaps are defined.

Did i need to write a typemap? How should I do it?

+1  A: 

No special action should be taken in the interface file. SWIG can take care of it.

Lua 5.1.3  Copyright (C) 1994-2008 Lua.org, PUC-Rio
> require 'mylib_swig'
> t=mylib_swig.Point()
> print(t.a)
0
> print(t.b)
0
> mylib_swig.lib_a_f_5(t)
in lib_a_f_5 
> print(t.a)
20
> print(t.b)
30
> 
pierr