On Mon, Oct 22, 2012 at 11:08 AM, Kevin Martin <
kev82@khn.org.uk> wrote:
>
> On 22 Oct 2012, at 18:51, Coda Highland wrote:
>
>> Why use something as clumsy as a UUID for the key when you get a
>> unique ID back from luaL_ref?
>
> How can I use luaL_ref? I'm thinking to have a static function such as:
>
> static int foo(lua_State *l) {
> lua_pushstring(l, "special key");
> lua_gettable(l, LUA_REGISTRYINDEX);
> SomeObject *o = lua_touserdata(l, -1);
>
> o->bar();
>
> return 0;
> }
>
> foo needs to know at compile time where to look to get the object (as there is no runtime data passed to foo), the returned value from luaL_ref is not known until runtime.
>
> Thanks,
> Kev