lua-users home
lua-l archive

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


----- Original Message -----
From: Solinsky, Jeff - PAL
Date: 1/23/2012 11:28 AM
Ani Wrote:
Can I know that the functions are to be called in the /if/ context
(and internally populate
some C data structures for the same) ?   ... hope I made the question clear.
Is this possible in pure Lua, or I need some add-ons ?
If you are using standard Lua, you need a foreign function interface to call C functions that don't use the Lua stack for passing parameters and returning values.

Alien is a Lua add-on that allows you to call C functions and has support for buffers to manipulate C structures from Lua if you must do that.

LuaJIT has a fast function interface with support for creating and using C types built-in that is much faster than Alien and much easier for defining functions due to it's ability to parse C headers (though it has no C pre-parser support); however, LuaJIT ffi only works with LuaJIT (it isn't available for the c implementation of Lua from lua.org).

luaffi [1] works under standard Lua and implements the LuaJIT FFI interface.

-Josh

[1] https://github.com/jmckaskill/luaffi