lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Aug 11, 2009 at 7:17 AM, Lawrie Nichols<lawrien@gmail.com> wrote:
> Hi Patrick
>
> thanks, but it's really the pointers I'm looking for. Firstly, I need to be
> able to store UD pointers in a weak-keyed table so that I can look it up
> based on a pointer coming into a C callback,

Light Userdata and Numbers are both considered strong references in
any weak table. Also, passing a pointer to an integer on the stack is
just as simple in my opinion as passing a pointer returned from
lua_topointer.

> Obviously, if the function pointer
> might be updated by Lua, this wouldn't work, but as it is I think I'm going
> to try using it :-)
>
> Finally, not too sure if refs work in weak-referenced tables....
>
> Thanks for the pointer (no pun intended) anyway,

Lua's luaL_ref and luaL_unref both work in a weak valued table so long
as you eventually luaL_unref each collected item.

-- 
-Patrick Donnelly

"Let all men know thee, but no man know thee thoroughly: Men freely
ford that see the shallows."

- Benjamin Franklin