Difference between revisions of "Conversion between love objects and FFI structures"
(Created page with "This tutorial leads to conversion between löve objects and FFI (Foreign Function Interface) structures. * If you don't know what FFI is, check http://luajit.org/ext_ffi.html...") |
|||
Line 1: | Line 1: | ||
− | This | + | This page leads to conversion between löve objects and FFI (Foreign Function Interface) structures. |
* If you don't know what FFI is, check http://luajit.org/ext_ffi.html | * If you don't know what FFI is, check http://luajit.org/ext_ffi.html |
Revision as of 18:25, 24 May 2016
This page leads to conversion between löve objects and FFI (Foreign Function Interface) structures.
- If you don't know what FFI is, check http://luajit.org/ext_ffi.html
- Download the code from here http://pastebin.com/Ad9dPKiZ
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.