lua-users home
lua-l archive

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


On Oct 7, 2014, at 11:51 AM, Philipp Kraus <philipp.kraus@tu-clausthal.de> wrote:

> 
> Sorry for my bad description, my Lua script ist added by the user, so I have got a script
> with a lot of global functions, so on the dump process, I need to get all non-default functions.
> I must do something like:
> 
> std::vector< std::string > function = lua_getglobalfunction();
> for(std::size_t i=0; i < function.size(); ++i
> {
>     lua_getglobal( L, function[i].c_str() );
>     lua_dump
> }
> 

Can you clarify your intent here? Are you trying to clone the *current state* of an existing lua_State, so that when cloned it can continue from the point of the clone, or are you trying to clone the original chunk of Lua code that was launched by the source state? Some of your posts seem to imply this.

If you just wish to clone the script and re-start it, there should be no need for a deep copy unless you have loaded scripts externally at run-time. Otherwise, as the other posters have noted, you will end up in a complete mess trying to find out what state to copy.

What is the ultimate goal of cloning the Lua state anyway? Why do you need a copy constructor?

—Tim