[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: retrieve top-level lua_State?
- From: Wesley Smith <wesley.hoke@...>
- Date: Mon, 8 Jun 2009 13:52:08 -0700
On Sat, Jun 6, 2009 at 3:15 PM, Sam Roberts<firstname.lastname@example.org> wrote:
> On Sat, Jun 6, 2009 at 11:02 AM, Wesley Smith<email@example.com> wrote:
>> Let's say you have a userdata that performs a callback into the
>> lua_State based on events received C-side. To actually do the
>> callback, you need a pointer to the lua_State that the userdata
>> belongs, which must be stored in the userdata.
> Not so, when being called from lua, always use the L you were passed,
> until the time that you return to lua, at which time you should assume
> that L to be invalid.
If you assume the L to be invalid, then how do you manage to send a
callback that doesn't come from Lua at all, but say from the OS event
loop, into the lua_State?
> Say you have function make() that calls into C and stores a userdata.
> And function dispatch() that calls into C, and in C code, based on
> some event, calls a method on the userdata.
I understand the example, but this doesn't reflect the situation I'm
dealing with. There is a function make() but the dispatch() is a C
function with no lua interaction whatsoever.