[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Getting Lua tables from C
- From: "anon" <dev@...>
- Date: Fri, 20 Apr 2001 11:45:12 -0700
Weak keyed tables are usually for garbage collection and such, so if a key
is no longer referenced the key and value can be deleted from the table and
the key recycled, the value/memory can also be recycled, unless theres a
strong reference too it.
but lua's use may be different.
----- Original Message -----
From: <Ultron14@aol.com>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Friday, April 20, 2001 8:29 AM
Subject: Re: Getting Lua tables from C
> Thanks for the help. This is all working great for me now! What do weak
> tables mean? I saw that on the Lua 4.1 (possible) feature list.
>
> Jules
>
>
> In a message dated 4/18/01 5:49:12 PM, froese@gmx.de writes:
>
> << I assume you mean this kind of tables: { "foo", "bar" }
>
> These are regular tables. Only the keys are the numbers 1, 2, ...
>
> lua_newtable(state);
> lua_pushnumber(state, 1);
> lua_pushnumber(state, lastworld->active);
> lua_settable(state,-3);
>
> or:
>
> lua_newtable(state);
> lua_pushnumber(state, lastworld->active);
> lua_rawseti(state, -2, 1); // the 1 is the numeric index
>
> > 2) how I GET the values from a table passed in (both indexed and with
> > properties)
>
> Same as above:
>
> lua_pushstring(state, "active");
> lua_gettable(state, <tableindex>);
>
> or
>
> lua_pushnumber(state, 1);
> lua_gettable(state, <tableindex>);
>
> or
>
> lua_rawgeti(state, <tableindex>, 1); // get field nr 1
>
> or iterate over all elements using lua_next().
>
> Ciao, ET. >>
>