lua-users home
lua-l archive

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


Hello all,

I'd like to tap the collective brainpower of this mailing list to try
and resolve a problem I'm having...

Today, I have a C function that I've registered with Lua whose purpose
is to block the invoking script on a specified event using lua_yield().
When that event occurs, lua_resume() is used to wake up the script.
Simple enough.

I'd like to leverage SWIG in my project, so that I can easily expose
other functions and structures of my application to Lua.  In looking at
the conversion of the few functions I've already got, there would seem
to be a problem with the block function described above.

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?

Something along the lines of pthread_self() for Lua, but called from
within a function rather than the script.  BTW, is there a means for a
script to get a handle to its own state for passing to a function if
that's the route I have to go?

Thanks,
Brian