[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Userdata and luaL_ref
- From: James Norton <jamesnorton@...>
- Date: Tue, 12 Feb 2013 14:22:48 -0500
I create a reference to the object in the registry using
ref = luaL_ref(L, LUA_REGISTRYINDEX);
Then I can retrieve it later using
lua_rawgeti(L, LUA_REGISTRYINDEX,, ref);
On Tuesday, February 12, 2013 at 1:57 PM, Marc Lepage wrote:
Hi, I'm doing more with userdata and am just wondering, is it safe to push the address of a (full) userdata to keep a reference to it? And remove that reference in the userdata's __gc function?
Basically, I want to store within the C userdata itself, a reference to the Lua object version of it. This is so that even if I pass it through C code (without Lua), I can later get back the Lua version of it, for additional processing.
Or, is there a better way to turn the address of a (full) userdata, in C, back into its Lua object?