lua-users home
lua-l archive

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


Open a new state
Push your c functions in there, similar to where you open the standard libs
Push and call your lua script

That ought to work. 


-------- Oorspronkelijk bericht --------
Van: Moose
Datum:01-04-2014 11:14 (GMT+01:00)
Aan: Lua mailing list
Onderwerp: Re: C++ integration / DSEL alternative questions

Am 01.04.2014 10:53 schrieb Kevin Martin:
> On 1 Apr 2014, at 09:42, Moose <moose@posteo.de> wrote:
>
>>> 1) Can Lua scripts call functions in the very same DLL that calls
>>> the
>>> interpreter?
>
> Is there a particular reason you are using the ffi? Can you not write
> your C function as a lua_CFunction, and then use
> lua_pushcfunction/lua_setglobal to make it accessible to the script?

Sort of.
There's three weak reasons:
1) I don't know (yet) how the regular C API Bindings work and only
intend to find out if ffi is indeed the problem.
2) LuaJit docs suggest that ffi bound functions are a lot faster as
they are subject to JIT optimization
3) I wanted to try the easy way first.

If there's reason to believe that C API Bindings will work in the same
scenario I'm happy to give that a shot and learn it.

Thanks,
Moose