[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: RE: Private data
- From: "Curt Carpenter" <curtc@...>
- Date: Wed, 3 Oct 2001 16:12:46 -0700
Sorry, just to clarify, when you guys mentioned the registry, my brain
immediately misinterpreted that you were referring to the Windows
registry. I wasn't familiar with the Lua registry, which I just
discovered. I'll check that out.
From: Curt Carpenter [mailto:firstname.lastname@example.org]
Sent: Wednesday, October 03, 2001 2:59 PM
To: Multiple recipients of list
Subject: RE: Private data
>>Does anyone have any good suggestions for how to deal with getting
>>to some private instance data when in a global C function called by
>How about upvalues (ie C closures)? There's also the registry, where
you can store anything you want. --lhf
Upvalues won't work. I need a solution that applies to all functions
that could be called by Lua, including tag methods and call/line hooks.
Two people suggesting using the registry??? You guys scare me! :-) If I
were going to do that, I'd rather create a global variable in the lua
state and use that. But the point is I want a VERY fast O(1) map
(because it will be used all the time) from the lua_State to some
pointer into my own stuff. I think I'm going to resort to modifying Lua,
and I would make this a feature request for 4.1.
Just add the following two functions:
LUA_API void * lua_GetPrivateData(lua_State *L)
LUA_API void * lua_SetPrivateData(lua_State *L, void * p)
L->pprivatedata = p;
void * pprivatedata;
to the struct lua_State.