Index: trunk/src/lua/lua_glm.cc
===================================================================
--- trunk/src/lua/lua_glm.cc	(revision 177)
+++ trunk/src/lua/lua_glm.cc	(revision 207)
@@ -13,4 +13,9 @@
 static size_t nlua_swizzel_lookup[256];
 
+using nv::lua::detail::is_vec;
+using nv::lua::detail::to_vec;
+using nv::lua::detail::to_pvec;
+using nv::lua::detail::push_vec;
+
 inline bool nlua_is_swizzel( const unsigned char* str, size_t max )
 {
@@ -42,5 +47,5 @@
 	static inline T construct( lua_State* L, int index ) {
 		if ( lua_type( L, index ) == LUA_TUSERDATA )
-			return nlua_to_vec<T>( L, index );
+			return to_vec<T>( L, index );
 		else
 			return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ) );
@@ -54,13 +59,13 @@
 		if ( lua_type( L, index ) == LUA_TUSERDATA )
 		{
-			if ( nlua_is_vec<T>( L, index ) )
-				return nlua_to_vec<T>( L, index );
+			if ( is_vec<T>( L, index ) )
+				return to_vec<T>( L, index );
 			else
-				return T( nlua_to_vec<vec2>( L, index ), lua_tonumber( L, index + 1 ) );
+				return T( to_vec<vec2>( L, index ), lua_tonumber( L, index + 1 ) );
 		}
 		else
 		{
 			if ( lua_type( L, index+1 ) == LUA_TUSERDATA )
-				return T( lua_tonumber( L, index ), nlua_to_vec<vec2>( L, index+1 ) );
+				return T( lua_tonumber( L, index ), to_vec<vec2>( L, index+1 ) );
 			else
 				return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ), lua_tonumber( L, index + 2 ) );
@@ -76,16 +81,16 @@
 		if ( lua_type( L, index ) == LUA_TUSERDATA )
 		{
-			if ( nlua_is_vec<T>( L, index ) )
-				return nlua_to_vec<T>( L, index );
+			if ( is_vec<T>( L, index ) )
+				return to_vec<T>( L, index );
 			else
 			{
-				if ( nlua_is_vec<vec3>( L, index ) )
-					return T( nlua_to_vec<vec3>( L, index ), lua_tonumber( L, index + 1 ) );
+				if ( is_vec<vec3>( L, index ) )
+					return T( to_vec<vec3>( L, index ), lua_tonumber( L, index + 1 ) );
 				else
 				{
 					if ( lua_type( L, index+1 ) == LUA_TUSERDATA )
-						return T( nlua_to_vec<vec2>( L, index ), nlua_to_vec<vec2>( L, index + 1 ) );
+						return T( to_vec<vec2>( L, index ), to_vec<vec2>( L, index + 1 ) );
 					else
-						return T( nlua_to_vec<vec2>( L, index ), lua_tonumber( L, index + 1 ), lua_tonumber( L, index + 2 ) );
+						return T( to_vec<vec2>( L, index ), lua_tonumber( L, index + 1 ), lua_tonumber( L, index + 2 ) );
 				}
 			}
@@ -95,13 +100,13 @@
 			if ( lua_type( L, index+1 ) == LUA_TUSERDATA )
 			{
-				if ( nlua_is_vec<vec3>( L, index+1 ) )
-					return T( lua_tonumber( L, index ), nlua_to_vec<vec3>( L, index+1 ) );
+				if ( is_vec<vec3>( L, index+1 ) )
+					return T( lua_tonumber( L, index ), to_vec<vec3>( L, index+1 ) );
 				else
-					return T( lua_tonumber( L, index ), nlua_to_vec<vec2>( L, index+1 ), lua_tonumber( L, index + 2 ) );
+					return T( lua_tonumber( L, index ), to_vec<vec2>( L, index+1 ), lua_tonumber( L, index + 2 ) );
 			}
 			else
 			{
 				if ( lua_type( L, index+2 ) == LUA_TUSERDATA )
-					return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ), nlua_to_vec<vec2>( L, index+2 ) );
+					return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ), to_vec<vec2>( L, index+2 ) );
 				else
 					return T( lua_tonumber( L, index ), lua_tonumber( L, index + 1 ), lua_tonumber( L, index + 2 ), lua_tonumber( L, index + 3 ) );
@@ -114,5 +119,5 @@
 int nlua_vec_new( lua_State* L )
 {
-	nlua_push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 1 ) );
+	push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 1 ) );
 	return 1;
 }
@@ -121,5 +126,5 @@
 int nlua_vec_random( lua_State* L )
 {
-	nlua_push_vec<T>( L, nv::random::get().range( nlua_to_vec<T>( L, 1 ), nlua_to_vec<T>( L, 2 ) ) );
+	push_vec<T>( L, nv::random::get().range( to_vec<T>( L, 1 ), to_vec<T>( L, 2 ) ) );
 	return 1;
 }
@@ -128,5 +133,5 @@
 int nlua_vec_clone( lua_State* L )
 {
-	nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) );
+	push_vec<T>( L, to_vec<T>( L, 1 ) );
 	return 1;
 }
@@ -135,5 +140,5 @@
 int nlua_vec_call( lua_State* L )
 {
-	nlua_push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 2 ) );
+	push_vec<T>( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::construct( L, 2 ) );
 	return 1;
 }
@@ -142,5 +147,5 @@
 static int nlua_vec_unm( lua_State* L )
 {
-	nlua_push_vec<T>( L, -nlua_to_vec<T>( L, 1 ) );
+	push_vec<T>( L, -to_vec<T>( L, 1 ) );
 	return 1;
 }
@@ -150,10 +155,10 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		nlua_push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) + nlua_to_vec<T>( L, 2 ) );
+		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) + to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) + (typename T::value_type)(lua_tonumber( L, 2 )) );
-		else
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) + nlua_to_vec<T>( L, 2 ) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) + (typename T::value_type)(lua_tonumber( L, 2 )) );
+		else
+			push_vec<T>( L, to_vec<T>( L, 1 ) + to_vec<T>( L, 2 ) );
 	return 1;
 }
@@ -163,10 +168,10 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		nlua_push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) - nlua_to_vec<T>( L, 2 ) );
+		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) - to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) - (typename T::value_type)(lua_tonumber( L, 2 )) );
-		else
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) - nlua_to_vec<T>( L, 2 ) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) - (typename T::value_type)(lua_tonumber( L, 2 )) );
+		else
+			push_vec<T>( L, to_vec<T>( L, 1 ) - to_vec<T>( L, 2 ) );
 	return 1;
 }
@@ -176,10 +181,10 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		nlua_push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) * nlua_to_vec<T>( L, 2 ) );
+		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) * to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) * (typename T::value_type)(lua_tonumber( L, 2 )) );
-		else
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) * nlua_to_vec<T>( L, 2 ) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) * (typename T::value_type)(lua_tonumber( L, 2 )) );
+		else
+			push_vec<T>( L, to_vec<T>( L, 1 ) * to_vec<T>( L, 2 ) );
 	return 1;
 }
@@ -189,10 +194,10 @@
 {
 	if ( lua_type( L, 1 ) == LUA_TNUMBER )
-		nlua_push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) / nlua_to_vec<T>( L, 2 ) );
+		push_vec<T>( L, (typename T::value_type)(lua_tonumber( L, 1 )) / to_vec<T>( L, 2 ) );
 	else
 		if ( lua_type( L, 2 ) == LUA_TNUMBER )
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) / (typename T::value_type)(lua_tonumber( L, 2 )) );
-		else
-			nlua_push_vec<T>( L, nlua_to_vec<T>( L, 1 ) / nlua_to_vec<T>( L, 2 ) );
+			push_vec<T>( L, to_vec<T>( L, 1 ) / (typename T::value_type)(lua_tonumber( L, 2 )) );
+		else
+			push_vec<T>( L, to_vec<T>( L, 1 ) / to_vec<T>( L, 2 ) );
 	return 1;
 }
@@ -201,5 +206,5 @@
 int nlua_vec_eq( lua_State* L )
 {
-	lua_pushboolean( L, nlua_to_vec<T>( L, 1 ) == nlua_to_vec<T>( L, 2 ) );
+	lua_pushboolean( L, to_vec<T>( L, 1 ) == to_vec<T>( L, 2 ) );
 	return 1;
 }
@@ -208,5 +213,5 @@
 int nlua_vec_get( lua_State* L )
 {
-	T v = nlua_to_vec<T>( L, 1 );
+	T v = to_vec<T>( L, 1 );
 	for ( size_t i = 0; i < v.length(); ++i )
 	{
@@ -219,5 +224,5 @@
 int nlua_vec_index( lua_State* L )
 {
-	T* v = nlua_to_pvec<T>( L, 1 );
+	T* v = to_pvec<T>( L, 1 );
 	size_t len  = 0;
 	size_t vlen = v->length();
@@ -237,7 +242,7 @@
 	{
 		switch (len) {
-		case 2 : nlua_push_vec( L, glm::detail::tvec2<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]] ) ); return 1;
-		case 3 : nlua_push_vec( L, glm::detail::tvec3<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]] ) ); return 1;
-		case 4 : nlua_push_vec( L, glm::detail::tvec4<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]], (*v)[nlua_swizzel_lookup[key[3]]] ) ); return 1;
+		case 2 : push_vec( L, glm::detail::tvec2<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]] ) ); return 1;
+		case 3 : push_vec( L, glm::detail::tvec3<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]] ) ); return 1;
+		case 4 : push_vec( L, glm::detail::tvec4<typename T::value_type>( (*v)[nlua_swizzel_lookup[key[0]]], (*v)[nlua_swizzel_lookup[key[1]]], (*v)[nlua_swizzel_lookup[key[2]]], (*v)[nlua_swizzel_lookup[key[3]]] ) ); return 1;
 		default: break;
 		}
@@ -257,5 +262,5 @@
 	typedef glm::detail::tvec4<typename T::value_type> vec4;
 
-	T* v = nlua_to_pvec<T>( L, 1 );
+	T* v = to_pvec<T>( L, 1 );
 	size_t len  = 0;
 	size_t vlen = v->length();
@@ -274,7 +279,7 @@
 	{
  		switch (len) {
-		case 2 : { vec2 v2 = nlua_to_vec<vec2>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;
-		case 3 : { vec3 v3 = nlua_to_vec<vec3>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;
-		case 4 : { vec4 v4 = nlua_to_vec<vec4>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;
+		case 2 : { vec2 v2 = to_vec<vec2>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v2[i]; } return 0;
+		case 3 : { vec3 v3 = to_vec<vec3>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v3[i]; } return 0;
+		case 4 : { vec4 v4 = to_vec<vec4>(L,3); for (size_t i = 0; i<len; ++i) (*v)[nlua_swizzel_lookup[key[i]]] = v4[i]; } return 0;
  		default: break;
 		}
@@ -286,5 +291,5 @@
 static int nlua_vec_tostring( lua_State* L )
 {
-	T v = nlua_to_vec<T>( L, 1 );
+	T v = to_vec<T>( L, 1 );
 	std::string s = "(";
 	for ( size_t i = 0; i < v.length(); ++i )
@@ -332,5 +337,5 @@
 	};
 
-	luaL_newmetatable( L, nlua_metatable_name<T>() );
+	luaL_newmetatable( L, nv::lua::detail::glm_metatable_name<T>() );
 	nlua_register( L, nlua_vec_m, -1 );
 	lua_createtable( L, 0, 0 );
@@ -345,12 +350,12 @@
 	lua_setmetatable( L, -2 );
 
-	nlua_push_vec( L, T() );
+	nv::lua::detail::push_vec( L, T() );
 	lua_setfield( L, -2, "ZERO" );
-	nlua_push_vec( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::unit() );
+	nv::lua::detail::push_vec( L, nlua_vec_constructor<T,sizeof( T ) / sizeof( typename T::value_type )>::unit() );
 	lua_setfield( L, -2, "UNIT" );
 	return 1;
 }
 
-void nlua_register_glm( lua_State* L )
+void nv::lua::register_glm( lua_State* L )
 { 
 	for (size_t i = 0; i < 256; ++i ) nlua_swizzel_lookup[i] = 255;
