|
From: William S F. <ws...@fu...> - 2016-10-23 19:16:16
|
On 22 October 2016 at 18:43, Ervin Hegedüs <ai...@gm...> wrote:
> Hi,
>
> I'ld like to make a library for Lua from a C code. There is a variable,
> which has int[10] type.
>
> Without typemap, Lua shows that variable as userdata. (In other languages
> also shows any different types in case of referenc of that variable, eg.
> Python shows it as SWIG_object (or something like this - it doesn't matter).
> In case of other languages (Python, Perl, Tcl) I could fixup this problem
> with own typemap.)
>
> I'm trying this way:
>
> %typemap(out) int [ANY] {
> int len,i;
> len = $1_dim0;
> lua_createtable (L, len, 0);
> for(i=0; i<len; i++) {
> lua_pushinteger(L, (lua_Integer)$1[i]);
> }
> lua_settable(L, (-1)*(len+1));
> }
>
> but in Lua script shows only this:
>
> nil
>
> What'em I missing? Could anybody helps in this problem?
Have you looked at the Lua typemaps shipped with SWIG? I don't know
Lua, but all the "out" typemaps increment SWIG_arg, so I'd try adding
that in.
William
|