[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: LuaJIT FFI: pointer<->lightuserdata ?
- From: Javier Guerra Giraldez <javier@...>
- Date: Wed, 16 Feb 2011 07:58:42 -0500
still in the assimilating phase of learning LuaJIT's FFI, and
daydreaming about how to call system functions (and ditching not only
Lua bindings but also several common C libraries in favor of plain Lua
code), a curious doubt is forming in my head:
the "don't use cdata as table keys" is very reasonable; but a common
idiom i've used before is to take a C pointer, make it into a
lightuserdata and use as a table key. the suggested workaround is to
use tonumber(); why not cast into a lightuserdata?
in the FFI reference, the lightuserdata->(void *) conversion is
automatic; but i don't see how to do the converse.
am i missing some downside of a (void *)->lightuserdata conversion?