lua-users home
lua-l archive

Re: noob - How to architect c++ code to use lua as external code

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


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

AltStyle によって変換されたページ (->オリジナル) /