Index: /trunk/nv/lua/lua_raw.hh
===================================================================
--- /trunk/nv/lua/lua_raw.hh	(revision 51)
+++ /trunk/nv/lua/lua_raw.hh	(revision 51)
@@ -0,0 +1,21 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+#ifndef NV_LUA_RAW_HH
+#define NV_LUA_RAW_HH
+
+#include <nv/lib/lua.hh>
+#include <nv/common.hh>
+#include <istream>
+#include <string>
+#include <bitset>
+#include <map>
+
+std::string nlua_typecontent( lua_State* L, int idx );
+void nlua_shallowcopy( lua_State *L, int index );
+void nlua_deepcopy( lua_State *L, int index );
+
+#endif // NV_LUA_RAW_HH
+
Index: /trunk/src/lua/lua_raw.cc
===================================================================
--- /trunk/src/lua/lua_raw.cc	(revision 51)
+++ /trunk/src/lua/lua_raw.cc	(revision 51)
@@ -0,0 +1,75 @@
+// Copyright (C) 2012-2013 ChaosForge / Kornel Kisielewicz
+// http://chaosforge.org/
+//
+// This file is part of NV Libraries.
+// For conditions of distribution and use, see copyright notice in nv.hh
+
+#include "nv/lua/lua_raw.hh"
+
+#include "nv/string.hh"
+
+std::string nlua_typecontent( lua_State* L, int idx )
+{
+	switch ( lua_type( L, idx ) )
+	{
+	case LUA_TNONE          : return "NONE"; 
+	case LUA_TNIL		    : return "NIL"; 
+	case LUA_TBOOLEAN		: return lua_toboolean( L, idx ) == 0 ? "false" : "true"; 
+	case LUA_TLIGHTUSERDATA	: return nv::to_string( nv::uint64( lua_touserdata( L, idx ) ) ); 
+	case LUA_TNUMBER		: return nv::to_string( lua_tonumber( L, idx ) ); 
+	case LUA_TSTRING		: return lua_tostring( L, idx ); 
+	case LUA_TTABLE		    : return "TABLE"; 
+	case LUA_TFUNCTION		: return "FUNCTION"; 
+	case LUA_TUSERDATA		: return nv::to_string( nv::uint64( lua_touserdata( L, idx ) ) ); 
+	case LUA_TTHREAD		: return "THREAD"; 
+	default : return "UNKNOWN!"; 
+	}
+}
+
+void nlua_shallowcopy( lua_State *L, int index )
+{
+	index = lua_absindex(L,index);
+	lua_newtable(L);
+	lua_pushnil(L);
+
+	while ( lua_next( L, index ) != 0 )
+	{
+		lua_pushvalue(L, -2);
+		lua_insert(L, -2);
+		lua_settable(L, -4);
+	}
+}
+
+void nlua_shallowmerge( lua_State *L, int index )
+{
+	index = lua_absindex(L,index);
+	lua_pushnil(L);
+
+	while( lua_next(L, index) != 0 )
+	{
+		lua_pushvalue(L, -2);
+		lua_insert(L, -2);
+		lua_rawset(L, -4);
+	}
+}
+
+void nlua_deepcopy( lua_State *L, int index )
+{
+	index = lua_absindex(L,index);
+	lua_newtable(L);
+	lua_pushnil(L);
+
+	while ( lua_next( L, index ) != 0 )
+	{
+		if ( lua_istable( L, -1 ) )
+		{
+			nlua_deepcopy( L, -1 );
+			lua_insert( L, -2 );
+			lua_pop( L, 1 );
+		}
+		lua_pushvalue(L, -2);
+		lua_insert(L, -2);
+		lua_settable(L, -4);
+	}
+}
+
Index: /trunk/src/lua/lua_state.cc
===================================================================
--- /trunk/src/lua/lua_state.cc	(revision 50)
+++ /trunk/src/lua/lua_state.cc	(revision 51)
@@ -7,31 +7,9 @@
 #include "nv/lua/lua_state.hh"
 
-#include "nv/lib/lua.hh"
+#include "nv/lua/lua_raw.hh"
 #include "nv/logging.hh"
 #include "nv/string.hh"
 
 using namespace nv;
-
-// The following should be moved to lua_raw
-
-std::string lua_typecontent( lua_State* L, int idx )
-{
-	switch ( lua_type( L, idx ) )
-	{
-	case LUA_TNONE          : return "NONE"; 
-	case LUA_TNIL		    : return "NIL"; 
-	case LUA_TBOOLEAN		: return lua_toboolean( L, idx ) == 0 ? "false" : "true"; 
-	case LUA_TLIGHTUSERDATA	: return nv::to_string( uint64( lua_touserdata( L, idx ) ) ); 
-	case LUA_TNUMBER		: return nv::to_string( lua_tonumber( L, idx ) ); 
-	case LUA_TSTRING		: return lua_tostring( L, idx ); 
-	case LUA_TTABLE		    : return "TABLE"; 
-	case LUA_TFUNCTION		: return "FUNCTION"; 
-	case LUA_TUSERDATA		: return nv::to_string( uint64( lua_touserdata( L, idx ) ) ); 
-	case LUA_TTHREAD		: return "THREAD"; 
-	default : return "UNKNOWN!"; 
-	}
-}
-
-// -----
 
 lua::stack_guard::stack_guard( lua::state* L )
@@ -297,5 +275,5 @@
 	for ( int i = 0; i < top; ++i )
 	{
-		NV_LOG( LOG_DEBUG, "#" << i+1 << " - " << lua_typename(L, i+1) << " = " << lua_typecontent(L, i+1) );
+		NV_LOG( LOG_DEBUG, "#" << i+1 << " - " << lua_typename(L, i+1) << " = " << nlua_typecontent(L, i+1) );
 	}
 }
