lua-users home
lua-l archive

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


I do a similar thing by using the globals table.  I load all the
functionality I want and then save a reference in C to the globals.  then I
install a empty globals table (making the old one inaccessible from Lua) and
do a *shallow* copy of all the entries from the saved state to the new
globals.  Then after running scripts that could corrupt the state I reset by
installing a new globals table and doing a shallow copy to it.

Doesn't solve the general problem of course but it works for all non-table
globals.  And is faster than recreating the original state.

Russ

> From: Ignacio Castaño <castanyo@yahoo.es>
> Reply-To: lua-l@tecgraf.puc-rio.br
> Date: Tue, 12 Feb 2002 18:46:20 +0100
> To: Multiple recipients of list <lua-l@tecgraf.puc-rio.br>
> Subject: Re: Clone a Lua State
> 
> Jean Claude Morlier wrote:
>> I'm interesting by the way that you resolve it.
>> I would appreciate that you tell me how. You can contact me in a private
>> thread If you want.
>> I have also a do it in a different way. But I have some difficulties to
>> propagate function and tag to cloned state.
> 
> I just kept all the modifications in a table so that after running the
> script I could clean the results with ease (table=nil). I know it's not
> completely safe, but it was ok for me.
> 
> 
> Ignacio Castaño
> castano@asidesoft.com
> 
> 
> 
> 
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>