|
From: William S F. <ws...@fu...> - 2016-10-23 19:52:28
|
On 23 October 2016 at 20:30, Ervin Hegedüs <ai...@gm...> wrote:
> Hi William,
>
> thanks for the answer,
>
> On Sun, Oct 23, 2016 at 08:15:28PM +0100, William S Fulton wrote:
>> On 22 October 2016 at 18:43, Ervin Hegedüs <ai...@gm...> wrote:
>> > 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.
>
> do you mean should I return the SWIG_arg from that typemap?
>
> I've tested, but it doesn't work: the array in Lua is still "nil"
> value, the expected value is "table: 0xaddr", when I just
> reference that in a print() function.
>
The reference typemaps I suggested you look at are in the Lib
directory in the SWIG distribution tarball.
William
|