[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C++ integration / DSEL alternative questions
- From: Sean Conner <sean@...>
- Date: Tue, 1 Apr 2014 12:01:10 -0400
It was thus said that the Great Moose once stated:
> Hello Lua Community,
>
> I am maintaining an existing C++ application that features, in a core
> library of it, an embedded C++ DSEL (written inlined in boost spirit) to
> execute user defined tasks. Those tasks call functions in the library
> itself. I would like to evaluate Lua as an optional alternative to the
> embedded DSEL, while keeping the architecture itself intact.
>
> About this, I have a few questions:
>
> 1) Can Lua scripts call functions in the very same DLL that calls the
> interpreter?
I can't answer this for Windows, but under Unix (specifically, using the
GCC build chain) you need to specify "-rdynamic" when linking to make the
symbols in the main program visible to shared libraries loaded during
program execution. Perhaps something similar is needed under Windows?
> 3) Can multiple Lua States coexist nicely?
If you mean somethign like:
L1 = luaL_newstate();
L2 = luaL_newstate();
then yes, they can coexist nicely (Lua has no global variables). But
transfering data between the two is a bit harder.
> 4) In a real world use case my users have many scripts in my DSEL that
> get executed at a frequency of about 30 Hz or more. Would I create a Lua
> state and execute the chunk every time or can I re-use the state after
> instantiating it once and excecute many times?
It depends. If the global state of a Lua instance isn't messed up, then
you could probably get by with reusing existing states. But if you want to
make sure nothing bad can happen, you may want to recreate states as needed.
But this is something you'll have to measure.
-spc