Re: LuaJit FFI with iOS

  • From: Mike Pall <mike-1306@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Mon, 24 Jun 2013 12:33:46 +0200

Dominik Weinhold wrote:
> At the moment I am looking into getting it to run for an iOS app but I'm
> having trouble with the FFI. From what I know Apple does not allow any
> dynamic library in App-Store Apps. So I was wondering if there is a way to
> use the LuaJit FFI with static libraries so that apple will accept it?

Use a static struct holding function pointers on the C side. Pass
a pointer to that as a lightuserdata to Lua. Declare the same
struct on the Lua side and cast the received lightuserdata to a
pointer (or reference) to it.

[You probably know that Apple doesn't permit JIT-compilation,
which means you only get the fast LuaJIT interpreter. Alas, the
FFI is quite slow when only interpreted. This might be a problem
on iOS, if you plan to call C functions via the FFI in performance
sensitive contexts (millions of calls in a loop).]

--Mike

Other related posts: