Variable Argument List

It is possible to call library functions with a variable length argument list. In this case, the function has to determine somehow how many arguments are given; usually this involves looking for NULL or -1 as the terminating argument, or by providing a number of arguments. If you fail to do this correctly, a crash can (and probably will) ensue.

LuaGnome has to convert each Lua Value you provide to a C value. Following conversions are done in the function src/types.c:lua2ffi_vararg():

Lua Data typeC (ffi) data type
booleanunsigned int (false=0, true=1)
numberFor integers, signed int, else double
lightuserdatapointer (currently not used for anything)
userdataA userdata can be one of the following:
  • ENUM or FLAGS: converted to unsigned int
  • void wrapper: converted to pointer
  • boxed value: depends on the type stored in the boxed value
  • widget: converted to pointer
tableThe table should have a field "_type" set to the desired type:
  • "string": conversion to char**
  • "boxed": conversion to a boxed value

Unhandled Lua types: function and thread. I haven't yet seen the need to support those two.