Re: Key lookup optimizations...

  • From: Alex Szpakowski <aszpakowski@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 1 Sep 2015 18:21:26 -0300


On Sep 1, 2015, at 6:10 PM, Lance Thornblad <lance.thornblad@xxxxxxxxx> wrote:

What's the difference, when you say C function vs. Lua C API function?

C function:

int foo(int bar) { return bar * 3; }

Lua C API function:

int luafoo(lua_State *L) { int bar = luaL_checkint(L, 1); lua_pushnumber(L,
foo(bar)); return 1; }

You can call C functions directly from inside LuaJIT by using its FFI. More
info is here: http://luajit.org/ext_ffi_tutorial.html

Other related posts: