Index: trunk/src/lua/lua_proxy.cc
===================================================================
--- trunk/src/lua/lua_proxy.cc	(revision 538)
+++ trunk/src/lua/lua_proxy.cc	(revision 539)
@@ -13,5 +13,55 @@
 using namespace nv::lua;
 
-nv::string64 nv::lua::stack_proxy::get_string64() const
+uint32 nv::lua::stack_proxy::get_uint32( uint32 def ) const
+{
+	return lua_type( *m_state, m_index ) == LUA_TNUMBER ? nlua_tounsigned( *m_state, m_index ) : def;
+}
+
+sint32 nv::lua::stack_proxy::get_sint32( sint32 def ) const
+{
+	return lua_type( *m_state, m_index ) == LUA_TNUMBER ? static_cast<sint32>( lua_tointeger( *m_state, m_index ) ) : def;
+}
+
+char nv::lua::stack_proxy::get_char( char def /*= ' ' */ ) const
+{
+	return ( lua_type( *m_state, m_index ) == LUA_TSTRING && nlua_rawlen( *m_state, m_index ) > 0 ) ? lua_tostring( *m_state, m_index )[0] : def;
+}
+
+nv::f64 nv::lua::stack_proxy::get_f64( f64 def /*= 0.0 */ ) const
+{
+	return lua_type( *m_state, m_index ) == LUA_TNUMBER ? lua_tonumber( *m_state, m_index ) : def;
+}
+
+nv::f32 nv::lua::stack_proxy::get_f32( f32 def /*= 0.0f */ ) const
+{
+	return lua_type( *m_state, m_index ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( *m_state, m_index ) ) : def;
+}
+
+bool nv::lua::stack_proxy::get_bool( bool def /*= false */ ) const
+{
+	return lua_type( *m_state, m_index ) == LUA_TBOOLEAN ? lua_toboolean( *m_state, m_index ) != 0 : def;
+}
+
+bool nv::lua::stack_proxy::is_number() const
+{
+	return lua_type( *m_state, m_index ) == LUA_TNUMBER;
+}
+
+bool nv::lua::stack_proxy::is_bool() const
+{
+	return lua_type( *m_state, m_index ) == LUA_TBOOLEAN;
+}
+
+bool nv::lua::stack_proxy::is_string() const
+{
+	return lua_type( *m_state, m_index ) == LUA_TSTRING;
+}
+
+bool nv::lua::stack_proxy::is_table() const
+{
+	return lua_type( *m_state, m_index ) == LUA_TTABLE;
+}
+
+nv::string_view nv::lua::stack_proxy::get_string_view() const
 {
 	size_t l = 0;
@@ -21,12 +71,23 @@
 		str = lua_tolstring( *m_state, m_index, &l );
 	}
-	return string64( str, static_cast<uint32>( l ) );
+	return string_view( str, static_cast<uint32>( l ) );
 }
 
-nv::string64 nv::lua::stack_proxy::to_string64()
+nv::string_view nv::lua::stack_proxy::as_string_view()
 {
 	size_t l = 0;
 	const char* str = nullptr;
 	str = lua_tolstring( *m_state, m_index, &l );
-	return string64( str, static_cast<uint32>( l ) );
+	return string_view( str, static_cast<uint32>( l ) );
 }
+
+nv::lua::temporary_proxy::temporary_proxy( state* state )
+	: stack_proxy( state, -1 )
+{
+
+}
+
+nv::lua::temporary_proxy::~temporary_proxy()
+{
+	lua_pop( *m_state, 1 );
+}
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 538)
+++ trunk/src/lua/lua_state.cc	(revision 539)
@@ -185,341 +185,14 @@
 }
 
-shash64 nv::lua::table_guard::get_string_hash_64( string_view element, uint64 defval /*= 0 */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	size_t l = 0;
-	const char* str = nullptr;
-	uint64 result = defval;
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-		result = hash_string< uint64 >( str, static_cast< uint32 >( l ) );
-		//NV_LOG_DEBUG( str );
-	}
-	lua_pop( m_state, 1 );
-	return shash64( result );
-}
-
-nv::shash64 nv::lua::table_guard::get_string( string_view element, string_table* table, uint64 defval /*= 0 */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	size_t l = 0;
-	const char* str = nullptr;
-	shash64 result = shash64( defval );
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-		string_view sv( str, static_cast< uint32 >( l ) );
-		result = table ? table->insert( sv ) : shash64( sv );
-	}
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-shash64 nv::lua::table_guard::get_string_hash_64( int i, uint64 defval /*= 0 */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	size_t l = 0;
-	const char* str = nullptr;
-	uint64 result = defval;
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-		result = hash_string< uint64 >( str, static_cast< uint32 >( l ) );
-		//NV_LOG_DEBUG( str );
-	}
-	lua_pop( m_state, 1 );
-	return shash64( result );
-}
-
-nv::string128 nv::lua::table_guard::get_string128( int i, string_view defval /*= string_view() */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	size_t l = 0;
-	const char* str = nullptr;
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-	}
-	else
-	{
-		l = defval.size();
-		str = defval.data();
-	}
-	string128 result( str, static_cast< uint32 >( l ) );
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-const_string nv::lua::table_guard::get_string( int i, string_view defval /*= string_view() */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	size_t l = 0;
-	const char* str = nullptr;
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-	}
-	else
-	{
-		l = defval.size();
-		str = defval.data();
-	}
-	const_string result( str, static_cast< uint32 >( l ) );
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-shash64 nv::lua::table_guard::get_string( int i, string_table* table, uint64 defval /*= 0 */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	size_t l = 0;
-	const char* str = nullptr;
-	shash64 result = shash64( defval );
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-		string_view sv( str, static_cast< uint32 >( l ) );
-		result = table ? table->insert( sv ) : shash64( sv );
-	}
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-const_string lua::table_guard::get_string( string_view element, string_view defval /*= string_view() */ )
-{
- 	lua_getfield( m_state, -1, element.data() );
- 	size_t l = 0;
- 	const char* str = nullptr;
- 	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
- 	{
- 		str = lua_tolstring( m_state, -1, &l );
- 	}
- 	else
- 	{
- 		l = defval.size();
- 		str = defval.data();
- 	}
- 	const_string result( str, static_cast< uint32 >( l ) );
- 	lua_pop( m_state, 1 );
- 	return result;
-}
-
-string128 lua::table_guard::get_string128( string_view element, string_view defval )
-{
-	lua_getfield( m_state, -1, element.data() );
-	size_t l = 0;
-	const char* str = nullptr;
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-	}
-	else
-	{
-		l = defval.size();
-		str = defval.data();
-	}
-	string128 result( str, static_cast< uint32 >( l ) );
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-nv::string64 nv::lua::table_guard::get_string64( string_view element, string_view defval /*= string_view() */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	size_t l = 0;
-	const char* str = nullptr;
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-	}
-	else
-	{
-		l = defval.size();
-		str = defval.data();
-	}
-	string64 result( str, static_cast< uint32 >( l ) );
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-
-nv::string32 nv::lua::table_guard::get_string32( string_view element, string_view defval /*= string_view() */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	size_t l = 0;
-	const char* str = nullptr;
-	if ( lua_type( m_state, -1 ) == LUA_TSTRING )
-	{
-		str = lua_tolstring( m_state, -1, &l );
-	}
-	else
-	{
-		l = defval.size();
-		str = defval.data();
-	}
-	string32 result( str, static_cast< uint32 >( l ) );
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-char lua::table_guard::get_char( string_view element, char defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	char result = ( lua_type( m_state, -1 ) == LUA_TSTRING && nlua_rawlen( m_state, -1 ) > 0 ) ? lua_tostring( m_state, -1 )[0] : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-int lua::table_guard::get_integer( string_view element, int defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	lua_Integer result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tointeger( m_state, -1 ) : defval;
-	lua_pop( m_state, 1 );
-	return static_cast< int >( result );
-}
-
-unsigned lua::table_guard::get_unsigned( string_view element, unsigned defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	unsigned result = lua_type( m_state, -1 ) == LUA_TNUMBER ? nlua_tounsigned( m_state, -1 ) : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-double lua::table_guard::get_double( string_view element, double defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	double result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tonumber( m_state, -1 ) : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-char nv::lua::table_guard::get_char( int i, char defval /*= ' ' */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	char result = ( lua_type( m_state, -1 ) == LUA_TSTRING && nlua_rawlen( m_state, -1 ) > 0 ) ? lua_tostring( m_state, -1 )[0] : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-int nv::lua::table_guard::get_integer( int i, int defval /*= 0 */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	lua_Integer result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tointeger( m_state, -1 ) : defval;
-	lua_pop( m_state, 1 );
-	return static_cast<int>( result );
-}
-
-unsigned nv::lua::table_guard::get_unsigned( int i, unsigned defval /*= 0 */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	unsigned result = lua_type( m_state, -1 ) == LUA_TNUMBER ? nlua_tounsigned( m_state, -1 ) : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-double nv::lua::table_guard::get_double( int i, double defval /*= 0.0 */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	double result = lua_type( m_state, -1 ) == LUA_TNUMBER ? lua_tonumber( m_state, -1 ) : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-float nv::lua::table_guard::get_float( int i, float defval /*= 0.0 */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( m_state, -1 ) ) : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::get_boolean( int i, bool defval /*= false */ )
-{
-	lua_rawgeti( m_state, -1, i );
-	bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN ? lua_toboolean( m_state, -1 ) != 0 : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-float nv::lua::table_guard::get_float( string_view element, float defval /*= 0.0 */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	float result = lua_type( m_state, -1 ) == LUA_TNUMBER ? static_cast<float>( lua_tonumber( m_state, -1 ) ) : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool lua::table_guard::get_boolean( string_view element, bool defval /*= "" */ )
-{
-	lua_getfield( m_state, -1, element.data() );
-	bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN ? lua_toboolean( m_state, -1 ) != 0 : defval;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_table( string_view element )
-{
-	lua_getfield( m_state, -1, element.data() );
-	bool result = lua_type( m_state, -1 ) == LUA_TTABLE;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_table( int i )
-{
-	lua_rawgeti( m_state, -1, i );
-	bool result = lua_type( m_state, -1 ) == LUA_TTABLE;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_number( int i )
-{
-	lua_rawgeti( m_state, -1, i );
-	bool result = lua_type( m_state, -1 ) == LUA_TNUMBER;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_boolean( int i )
-{
-	lua_rawgeti( m_state, -1, i );
-	bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_string( int i )
-{
-	lua_rawgeti( m_state, -1, i );
-	bool result = lua_type( m_state, -1 ) == LUA_TSTRING;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_number( string_view element )
-{
-	lua_getfield( m_state, -1, element.data() );
-	bool result = lua_type( m_state, -1 ) == LUA_TNUMBER;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_boolean( string_view element )
-{
-	lua_getfield( m_state, -1, element.data() );
-	bool result = lua_type( m_state, -1 ) == LUA_TBOOLEAN;
-	lua_pop( m_state, 1 );
-	return result;
-}
-
-bool nv::lua::table_guard::is_string( string_view element )
-{
-	lua_getfield( m_state, -1, element.data() );
-	bool result = lua_type( m_state, -1 ) == LUA_TSTRING;
-	lua_pop( m_state, 1 );
-	return result;
+const nv::lua::temporary_proxy nv::lua::table_guard::operator[]( const string_view& key ) const
+{
+	lua_getfield( m_state, -1, key.data() );
+	return temporary_proxy( m_parent );
+}
+
+const nv::lua::temporary_proxy nv::lua::table_guard::operator[]( sint32 key ) const
+{
+	lua_rawgeti( m_state, -1, key );
+	return temporary_proxy( m_parent );
 }
 
