[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: LUA_USERSTATE
- From: Nick Trout <Nick.Trout@...>
- Date: Thu, 31 Jan 2002 12:10:07 -0000
> So after using this a little and also in lea of the discussion on
> libraries - wouldn't a functional interface be a better
> solution? One that can accept multiple user contexts referenced
> by id? I'm also having to include lstate.h so I can reference my
> user context. (I'm using the first work release)
>
> as an alternate solution - for example:
>
> id = lua_setuserctx( L, (void*) p );
>
> p (mycontext*) = lua_getuserctx( L, id );
>
> and in the state structure something like:
>
> #define MAXUSERCTX 10
>
> lua_State {
> ..
> void* userctx[MAXUSERCTX];
> };
Ooop, sorry I didnt get this the first time I read it but after thinking
about your previous post, I can see what you're talking about!!
I think something like this is more flexible.
id = lua_registercontext(L);
lua_setcontextdata(L,id,data);
...
data = lua_getcontextdata(L,id);
Nick