|
On Feb 26, 2007, at 1:56 PM, Sam Roberts wrote:
REGISTRY[weakvaluedtable][table] = ptr^-- probably unnecessary, see below// from C++ ptr to table: getfenv(REGISTRY[weakvaluedtable][ptr]) // from table to C++ ptr: REGISTRY[weakvaluedtable][table]Why would you would you want to map the table to the ptr?lua code will have only a udata, and will pass a udata to C code, your Ccode will call lua_touserdata() to get the ptr. No table required.
Because I want to call back into the lua State from C++ at a later point in time (after the main Lua chunk has run). That's why I need to
A) prevent the table being collected until I'm ready B) get to the userdata/table from a raw pointer
Optional: if you need to go from udata -> table, maybe to store some number of lua values with your udata, thats what lua_getfenv() is for.
Yes, but how do I get to the udata from a raw C++ pointer, after the main Lua chunk has run (i.e. in response to a C++ event)?