lua-users home
lua-l archive

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

The function uses the Lua state of the script as a context to associate
the event subscription with, but as far as I can tell the Lua state is
not available to functions wrapped by SWIG.  It seems like the script
will have to pass its state as an explicit argument.  Is this correct,
or is there a way for the function to determine this?

To pass the Lua state around I use just this directive:

%typemap(in) lua_State*
 $1 = L;

Where L is the conventional variable name for the lua_State* as passed
around within the SWIG/Lua module implementation.

I use coroutines extensively so I adopted this practice became as a
matter of proper engineering. I think passing it as an explicit
argument like this, is the simplest and cleanest choice.

I've not needed multiple states so far, but from what I've read from
the SWIG/Lua source (all of it) it should work just as well

I hope this helps !