lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


We implemented this same thing almost exactly. It was quite useful to get
from a lua_State * to a pointer for our C++ wrapper class. I've heard that
Lua 4.1 has some macros to make this easier, but I have not really
investigated.

Eric

> Just add the following two functions:
> LUA_API void * lua_GetPrivateData(lua_State *L)
> {
>     return L->pprivatedata;
> }
>
> LUA_API void * lua_SetPrivateData(lua_State *L, void * p)
> {
>     L->pprivatedata = p;
> }
> And add
> 	void * pprivatedata;
> to the struct lua_State.
>