[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [ANN] LuaJIT-2.0.0-beta6
- From: Mike Pall <mikelu-1102@...>
- Date: Mon, 14 Feb 2011 00:36:11 +0100
Dušan Majkić wrote:
> I was hoping for something like:
> lua_register_via_FFI(my_nonlua_func, "int my_nonlua_func(int s, const
> char *m)");
> or FFIs bulk register, like luaL_register.
Create a record with function/procedure pointers and initialize it
with your exported functions. Then pass the address of that record
as a lightuserdata to Lua.
On the Lua side, declare an equivalent C struct containing
function pointers. Then use ffi.cast to cast the lightuserdata
object into a pointer to this struct. Store it somewhere and then
use it like 'y = p.foo(x) + p.bar(x)' from then on.
> I'm using Lua in delphi app,
> and there is no way to export functions from exe project.
According to a short search, there is a way to do that: edit the
.DPR and add an explicit 'exports' clause, listing all exported
functions. I think this is easier than the above.