Conversion between love objects and FFI structures

O.png This is NOT recommended for anyone to use. It will break at any time. The only non-breaking conversion between love objects and FFI data is via Data:getPointer, which you can cast to a FFI pointer via ffi.cast. The garbage collector is going erase the original userdata at any time.  


This page leads to conversion between löve objects and FFI (Foreign Function Interface) structures.

Love objects in lua are always stored in a userdata object (Proxy) that contains the object itself and a type identifier.

  • Check the line 99 to see the structure of the Proxy object

Functions

cdata Object, number Type, string TypeName = love.ffi(Object Object)
Description: This function converts a love object into a FFI cdata object. It returns the object itself (not the Proxy object), it's type and type name.

Object Object = love.fromffi(cdata Object, number Type, string TypeName)
Description: This function converts a FFI cdata object into a Proxy userdata object, it is required to give the type name to assign the metatable to the userdata object, and the type id for the Proxy object.