lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 1/23/12, Solinsky, Jeff - PAL <Jeff.Solinsky@peektraffic.com> wrote:
> Jensen, Joshua wrote:
>> luaffi [1] works under standard Lua and implements the LuaJIT FFI
>> interface.
>
> Very cool, was not aware of that project, although it looks like it only
> targets x86/x64/ARM currently, though I imagine it should not be too
> difficult to merge PowerPC support from the latest LuaJIT 2 beta 9 source.
>
> ~Jeff
>

PowerPC? If you are on Mac (I know you might not be) and are on 10.5,
you can also look at LuaCocoa. It uses Apple's included libffi and
BridgeSupport to bind to C functions.

The BridgeSupport toolchain includes pregenerated XML files of the
non-introspectable APIs that ship on OS X (i.e. everything that is not
clean Objective-C which means C), plus additional things like dynamic
library stubs containing symbols for inline functions, etc. It also
contains command line tools so you can generate those things for your
own APIs.

BridgeSupport language bindings like LuaCocoa then take care of the
rest so you don't have to do much. Example Lua(Cocoa) script:

LuaCocoa.import("Foundation")
-- NSLog is like printf but prints to the system log
NSLog("%s, %d, %f", "Hello World", 1, 2.3)
-- 2012-01-23 17:03:16.654 luacocoa[70363:507] Hello World, 1, 2.300000

http://playcontrol.net/opensource/LuaCocoa/

-Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/