2

Let's say that I have the following LuaJIT code:

local ffi = require "ffi"

ffi.cdef[[
    typedef struct { int num; } container;
]]

local a = ffi.new("container")
a.num = 10

library.doSomethingTo(a)

and let's say that library.doSomethingTo is defined by the following C code:

int doSomethingDo(lua_State *L) {
    //code here
}

what code would need to go at //code here in order to make library.doSomethingTo(a) print 10?

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
NetherGranite
  • 1,940
  • 1
  • 14
  • 42
  • So, to recap: you want to take an object created through FFI and talk to it through the Lua API. – Nicol Bolas Sep 13 '18 at 03:21
  • @NicolBolas I guess? I am not knowledgeable enough to confirm that that is an accurate summary of my question. – NetherGranite Oct 19 '18 at 13:54
  • You can use C exported functions with `ffi.cdef` as well, but if you want to use standard Lua C functions then you need to parse parameters into LuaVM somehow – M. Sol Oct 22 '18 at 07:03

0 Answers0