|
|
(10 intermediate revisions by 4 users not shown) |
Line 1: |
Line 1: |
− | 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
| |
− | * 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 ==
| |
− | <i>cdata</i> Object, <i>number</i> Type, <i>string</i> TypeName = <b>love.ffi</b>(<i>Object</i> Object)<br>
| |
− | 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.
| |
− |
| |
− | <i>Object</i> Object = <b>love.fromffi</b>(<i>cdata</i> Object, <i>number</i> Type, <i>string</i> TypeName)<br>
| |
− | 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.
| |