Registry access from FFI

  • From: Scott Lembcke <slembcke@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 5 Sep 2012 08:53:14 -0500

Is it possible to access the registry from the FFI? I need to store references 
to Lua objects in FFI structs, but it doesn't seem like you can access the 
registry in order to do it. luaL_ref() doesn't show up in the ffi.C namespace 
(I didn't really look into why, maybe it's an inline function or macro or 
something?), and I have no idea where to get a lua_State pointer to pass to it. 
The FFI API docs said that the Lua/C API was supposed to be accessible from the 
ffi.C namespace, so I'm not sure if I'm just doing it wrong or missing 
something really obvious.

Do I need to write a regular Lua CFunction to do that? If that's the case, it 
seems like it would be handy to have those built into the FFI library. 
Something like ffi.ref([table], obj) and ffi.unref([table], ref).

Other related posts: