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 type | C (ffi) data type |
|---|---|
| boolean | unsigned int (false=0, true=1) |
| number | For integers, signed int, else double |
| string | char* |
| nil | NULL |
| lightuserdata | pointer (currently not used for anything) |
| userdata | A userdata can be one of the following:
|
| table | The table should have a field "_type" set to the desired
type:
|
Unhandled Lua types: function and thread. I haven't yet seen the need to support those two.