[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table.remove in C api?
- From: Javier Guerra <javier@...>
- Date: Fri, 21 Aug 2009 14:55:40 -0500
On Fri, Aug 21, 2009 at 2:47 PM, Chris Camacho<c.camacho@ntlworld.com> wrote:
> I have a table indexed by pointers (lightuserdata) with userdata values
> to allow me to look up pointers and return userdata to Lua
>
> However in the userdata's __gc method I need to remove the
> pointer key from the table, there seems to be no analogue of
> table.remove(t,i) in lua's C api - or am I missing something obvious
table.remove(t [,pos]) is handy for working with the array part of a
table, not the hash part where you're storing your userdatas (since
they're indexed by lightuserdatas and not small consecutive indexes).
for the hash part, simply assign nil: t(yourlightuserdata)=nil
in C, use lua_pushnil() and lua_settable() or lua_rawset()
--
Javier