[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: coroutine from registry
- From: "Brent Arias" <barias@...>
- Date: Fri, 2 Sep 2005 01:50:29 -0700
In my C++ code, I have successfully
1)created a lua thread,
2)set a key-value pair (
pushlightuserdata(newThread),pushlightuserdata(this) ) into GLOBAL space
3)resumed the thread/coroutine
4)fielded a callback from the lua coroutine to C++ that retrieves the
key-value pair from GLOBAL space
But then I decided to change the above so that the key-value pair is kept in
the registry rather than in global space. When I do that, step 4 above does
not successfully retrieve the key-value pair. Instead the value it
retrieves is 0, rather than the C++ "this" pointer I had expected.
Why is this?
The retrieval function used in step #4 above looks like this:
static ILuaScript* GetScriptObject(lua_State *l)
lua_gettable(l, LUA_GLOBALSINDEX );
s = (ILuaScript *)lua_touserdata(l, -1);
The sample above is the working version, where the GLOBAL space is assumed.
The non-working version simply replaces the GLOBAL with the REGISTRY both
here, and symmetrically in the code related to step #2 above.