lua-users home
lua-l archive

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


Not to blow my own horn, but if you want to do this for arbitrary
datatypes (and you're currently using lua 5.0) you can use Pluto to
serialize the data to a string, then deserialize it into the other
state. http://luaforge.net/projects/pluto/ .

Ben

On 7/26/05, Jeffrey Williams <jwilliams@mfchelp.com> wrote:
> I've been using lua_xmove to allow one lua_State to call functions in
> another lua_State, but I am concerned that what I am doing is not a
> legitimate usage of lua.
> 
> Here are some more specifics...  the two lua_State's involved are not lua
> "threads", they are two separate states created by two calls to
> lua_Open/lua_dofile
> 
> I do something like this:
> 
> lua_getglobal(L, "myfunc"); // on top of stack now resides a function
> lua_xmove(L, L2, 1);
> lua_pushnumber(L2, 23);
> lua_pcall(L2, 0, 0, 0); // call myfunc(2) in L from state L2
> 
> It seems to work, but I am concerned that perhaps I am misusing the api and
> that it only works in certain cases.  So my question is:  Is this proper
> usage or is it just luck that it doesnt crash on me?
> 
> Jeff
> 
> 
>