Difference between revisions of "Conversion between love objects and FFI structures"

m
Line 1: Line 1:
 +
{{notice|This is *NOT* recommended for anyone to use. It will break at any time. The only non-breaking conversions between love objects and FFI data is via [wiki]Data:getPointer[/wiki], which you can cast to a FFI pointer via ffi.cast.}}
 +
 
This page leads to conversion between löve objects and FFI (Foreign Function Interface) structures.
 
This page leads to conversion between löve objects and FFI (Foreign Function Interface) structures.
  

Revision as of 19:43, 24 May 2016

O.png This is *NOT* recommended for anyone to use. It will break at any time. The only non-breaking conversions between love objects and FFI data is via [wiki]Data:getPointer[/wiki], which you can cast to a FFI pointer via ffi.cast.  


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.