A way to associate a Lua value with a FFI pointer?

  • From: Daniel Kolesa <quaker66@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Wed, 9 Apr 2014 09:54:31 +0100

Hello,

I would like to know if there is any way to associate a generic Lua value
with a FFI pointer. I'm binding a library which implements some custom
containers, which are sometimes returned by its functions. I would like to
expose those containers without having to do a copy into a Lua table every
time something returns. The contents of those containers are just pointers.
Thing is, I'd also make it possible to store arbitrary Lua values in them -
Lua 5.2/LuaJIT with 5.2 flag enabled already has something kind of similar
to what I'd need (debug.getuservalue/setuservalue) but that only works on
full userdata and there is no way to cast a void* back to light userdata
anyway.

Thanks,

Daniel

Other related posts: