lua-users home
lua-l archive

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


Well there is no Lua API to do this and a full clone would be immensely difficult. You would have to deep copy the registry, and in the process would hit things that are not easily copied such as user data and threads. So in practice this could only work if the source Lua state had no userdata and no threads. You would also have to handle issues with loaded libraries and special case some of the standard libraries.

--Tim

> On Oct 6, 2014, at 9:25 AM, Philipp Kraus <philipp.kraus@tu-clausthal.de> wrote:
> 
> Hello,
> 
> I have encapsulate the lua_state in a C++ class and I can run my Lua scripts well, but I would like to create a Copy-Ctor which creates a fill in depended clone of the current lua_state.
> How can I clone the current lua_state with a full deep-copy? Does there exists a C API function, how can I do this?
> 
> Thanks a lot
> 
> Phil