The LuaJIT Wiki

not logged in | [Login]

While binding to C APIs that need callbacks is fine most of the time, occasionally you will hit a rare case where the API needs features that the FFI does not yet support - specifically, callback signatures with varargs or pass-by-value aggregates.

Please list examples here as you encounter them.

Win32 Drag-and-Drop

Implementing the IDropTarget COM interface requires methods that need pass-by-value POINTL struct parameters.

Chipmunk Spatial Queries

cpSpaceNearestPointQuery and cpSpaceSegmentQuery require callbacks with pass-by-value cpVect struct parameters.

libuv uv_read_cb

uv_read_start requires uv_read_cb callback with pass-by-value uv_buf_t struct parameter. There is an open discussion with a proposal to change it.

libclang AST visitor callback

clang_visitChildren requires callbacks to receive CXCursor by value.

Please see this example for how to overcome this: FFI Callbacks with pass-by-value structs

libretro vararg logging function

retro_log_printf_t takes log level, format and varargs to be presented to e g vsnprintf.

Vararg callbacks don't work so there's no way to set this function from luajit (?).