[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C API question
- From: Patrick Donnelly <batrick@...>
- Date: Mon, 10 Jan 2011 12:15:46 -0500
On Mon, Jan 10, 2011 at 11:30 AM, Doug Currie <doug.currie@gmail.com> wrote:
> On Jan 10, 2011, at 7:14 AM, Daniel Silverstone wrote:
>
>> I suggested that in a conversation a few of us were having recently (not on
>> list or IRC) and it was pointed out to me that pushing and then looking up a
>> light userdata in a table, may be more expensive than a rawgeti invocation.
>
> One way to avoid Lua refs, and avoid using the global registry, is to associate callbacks (and other Lua objects needed by C) with small integer keys in a related full userdata environment (known as a uservalue in 5.2). However, when a callback from C happens, there is no documented way to convert a userdata pointer (void *), AKA block address, to a Lua object. I.e., what is the inverse of lua_touserdata?
Well, the inverse operation is not documented probably because it's
easy to do yourself. Just have a light userdata pointing to the full
userdata block address (lua_touserdata) as keys in the registry with
the corresponding full userdata value.
--
- Patrick Donnelly
- References:
- C API question, joao lobato
- Re: C API question, GrayFace
- Re: C API question, steve donovan
- Re: C API question, joao lobato
- Re: C API question, Roberto Ierusalimschy
- Re: C API question, Mark Hamburg
- Re: C API question, Roberto Ierusalimschy
- Re: C API question, Jerome Vuarand
- Re: C API question, Roberto Ierusalimschy
- Re: C API question, Daniel Silverstone
- Re: C API question, Doug Currie