[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tables to/from C
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Fri, 7 Jan 2000 00:29:00 -0200 (EDT)
>From lua-l@tecgraf.puc-rio.br Thu Jan 6 21:40:58 2000
>From: "Kenneth Rochel de Camargo Jr." <kenneth@uerj.br>
>I haven't been able to figure how to get/set tables in Lua with C code.
See ldblib.c, in 3.2.
>I need to write functions to deal with lists of strings, so they'd either
>accept a table with consecutive indices 1...n with a string at each node, or
>would generate such lists as return value.
To create a list of strings:
lua_Object result = lua_createtable(L);
To set the i-th entry in the list to string s:
lua_pushobject(L,result);
lua_pushnumber(L,i);
lua_pushstring(L,s);
lua_settable(L);
To return the list to Lua:
lua_pushobject(L,result);
return;
--lhf