[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LUA_USERSTATE.. doesn't work
- From: jim@...
- Date: Thu, 31 Jan 2002 10:54:29 -0600
| SomeDataStructure allthedata;
| };
| #define LUA_USERSTATE MyData mydata;
| ...
| L.mydata.SetData(id, data);
| ...
| Data = L.GetData(id);
|
| Or of course a struct instead of a class for C users. I like the
| ultimate flexibility the way it is.
| Curt
The main problem is the required recompile of the Lua library to use
LUA_USERSTATE, and the fact that if your compiling more than one
external library that makes use of LUA_USERSTATE you run into
problems. I wouldn't consider this very flexible.
Speed in accessing the info is needed (in some cases) because your
usually accessing the custom state info on every wrapper callback.
Now in thinking about it, i see a problem with the id as a reference
method, since where would you store the id when your programming
context (non-static data) libraries! arrgh.
The only thing I can come up with is :
#define myid 1 (in the header so it can be changed)
lua_setcontextdata(L,myid,data);
...
data = lua_getcontextdata(L,myid);
and the state has 10 or so default spaces for contexts. this seems a bit
too complex though. hmm. :/ Maybe LUA_USERSTATE is the best,
but not perfect solution...
Regards,
Jim