开发者

wrapp a function whose parameters are out type pointer to structure using swig

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 开发者_如何学GoSWIG 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?


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜