Index: trunk/nv/core/type_traits.hh
===================================================================
--- trunk/nv/core/type_traits.hh	(revision 344)
+++ trunk/nv/core/type_traits.hh	(revision 345)
@@ -79,38 +79,11 @@
 		};
 
-		template < typename R, typename T1 >
-		struct function_traits_impl< R (*)( T1 ) >
+		template < typename R, typename... Args >
+		struct function_traits_impl < R(*)(Args...) >
 		{
-			typedef R (*type)();
+			typedef R(*type)( Args... );
 			typedef R        return_type;
 			typedef void     class_type;
-			static const int arg_count = 1;
-		};
-
-		template < typename R, typename T1, typename T2 >
-		struct function_traits_impl< R (*)( T1, T2 ) >
-		{
-			typedef R (*type)();
-			typedef R        return_type;
-			typedef void     class_type;
-			static const int arg_count = 2;
-		};
-
-		template < typename R, typename T1, typename T2, typename T3 >
-		struct function_traits_impl< R (*)( T1, T2, T3 ) >
-		{
-			typedef R (*type)();
-			typedef R        return_type;
-			typedef void     class_type;
-			static const int arg_count = 3;
-		};
-
-		template < typename R, typename T1, typename T2, typename T3, typename T4 >
-		struct function_traits_impl< R (*)( T1, T2, T3, T4 ) >
-		{
-			typedef R (*type)();
-			typedef R        return_type;
-			typedef void     class_type;
-			static const int arg_count = 4;
+			static const int arg_count = sizeof...(Args);
 		};
 
@@ -124,38 +97,11 @@
 		};
 
-		template < class C, typename R, typename T1 >
-		struct function_traits_impl< R (C::*)( T1 ) >
+		template < class C, typename R, typename... Args >
+		struct function_traits_impl < R(C::*)(Args...) >
 		{
-			typedef R (*type)();
-			typedef R       return_type;
-			typedef C       class_type;
-			static const int arg_count = 1;
-		};
-
-		template < class C, typename R, typename T1, typename T2 >
-		struct function_traits_impl< R (C::*)( T1, T2 ) >
-		{
-			typedef R (*type)();
-			typedef R       return_type;
-			typedef C       class_type;
-			static const int arg_count = 2;
-		};
-
-		template < class C, typename R, typename T1, typename T2, typename T3 >
-		struct function_traits_impl< R (C::*)( T1, T2, T3 ) >
-		{
-			typedef R (*type)();
-			typedef R       return_type;
-			typedef C       class_type;
-			static const int arg_count = 3;
-		};
-
-		template < class C, typename R, typename T1, typename T2, typename T3, typename T4 >
-		struct function_traits_impl< R (C::*)( T1, T2, T3, T4 ) >
-		{
-			typedef R (*type)();
-			typedef R       return_type;
-			typedef C       class_type;
-			static const int arg_count = 4;
+			typedef R(C::*type)(Args...);
+			typedef R        return_type;
+			typedef C        class_type;
+			static const int arg_count = sizeof...(Args);
 		};
 
Index: trunk/nv/lua/lua_dispatch.hh
===================================================================
--- trunk/nv/lua/lua_dispatch.hh	(revision 344)
+++ trunk/nv/lua/lua_dispatch.hh	(revision 345)
@@ -29,117 +29,80 @@
 		namespace detail
 		{
+			template <typename...>
+			struct types {};
+
 			template < typename R >
-			struct dispatcher
+			struct call_and_push
 			{
-				static int call( lua_State* L, int, R (*func)() )
+				template <typename... Args, typename... Vs>
+				static void do_call(lua_State* L, R(*func)(Args...), Vs&&... vs)
 				{
-					push_value( L, func() ); return 1;
+					push_value(L, func(std::forward<Vs>(vs)...)); 
 				}
-				template < typename T1 >
-				static int call( lua_State* L, int index, R (*func)( T1 ) )
+				template <class C, typename... Args, typename... Vs>
+				static void do_call(lua_State* L, C& c, R(C::*func)(Args...), Vs&&... vs)
 				{
-					push_value( L, func( get_value<T1>( L, index + 0 ) ) ); return 1;
-				}
-				template < typename T1, typename T2 >
-				static int call( lua_State* L, int index, R (*func)( T1, T2 ) )
-				{
-					push_value( L, func( get_value<T1>( L, index + 0 ),	get_value<T2>( L, index + 1 ) ) ); return 1;
-				}
-				template < typename T1, typename T2, typename T3 >
-				static int call( lua_State* L, int index, R (*func)( T1, T2, T3 ) )
-				{
-					push_value( L, func( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ) ) ); return 1;
-				}
-				template < typename T1, typename T2, typename T3, typename T4 >
-				static int call( lua_State* L, int index, R (*func)( T1, T2, T3, T4 ) )
-				{
-					push_value( L, func( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ), get_value<T4>( L, index + 3 ) ) ); return 1;
-				}
-				template < class C >
-				static int call( lua_State* L, int, C& c, R (C::*func)() )
-				{
-					push_value( L, (c.*func)() ); return 1;
-				}
-				template < class C, typename T1 >
-				static int call( lua_State* L, int index, C& c, R (C::*func)( T1 ) )
-				{
-					push_value( L, (c.*func)( get_value<T1>( L, index + 0 ) ) ); return 1;
-				}
-				template < class C, typename T1, typename T2 >
-				static int call( lua_State* L, int index, C& c, R (C::*func)( T1, T2 ) )
-				{
-					push_value( L, (c.*func)( get_value<T1>( L, index + 0 ),	get_value<T2>( L, index + 1 ) ) ); return 1;
-				}
-				template < class C, typename T1, typename T2, typename T3 >
-				static int call( lua_State* L, int index, C& c, R (C::*func)( T1, T2, T3 ) )
-				{
-					push_value( L, (c.*func)( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ) ) ); return 1;
-				}
-				template < class C, typename T1, typename T2, typename T3, typename T4 >
-				static int call( lua_State* L, int index, C& c, R (C::*func)( T1, T2, T3, T4 ) )
-				{
-					push_value( L, (c.*func)( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ), get_value<T4>( L, index + 3 ) ) ); return 1;
+					push_value(L, (c.*func)(std::forward<Vs>(vs)...)); 
 				}
 			};
-			
+
 			template <>
-			struct dispatcher< void >
+			struct call_and_push<void>
 			{
-				static int call( lua_State*, int, void (*func)() )
+				template <typename... Args, typename... Vs>
+				static void do_call(lua_State*, void(*func)(Args...), Vs&&... vs)
 				{
-					func(); return 0;
+					func(std::forward<Vs>(vs)...);
 				}
-				template < typename T1 >
-				static int call( lua_State* L, int index, void (*func)( T1 ) )
+				template <class C, typename... Args, typename... Vs>
+				static void do_call(lua_State*, C& c, void(C::*func)(Args...), Vs&&... vs)
 				{
-					func( get_value<T1>( L, index + 0 ) ); return 0;
+					(c.*func)(std::forward<Vs>(vs)...);
 				}
-				template < typename T1, typename T2 >
-				static int call( lua_State* L, int index, void (*func)( T1, T2 ) )
-				{
-					func( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ) ); return 0;
-				}
-				template < typename T1, typename T2, typename T3 >
-				static int call( lua_State* L, int index, void (*func)( T1, T2, T3 ) )
-				{
-					func( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ) ); return 0;
-				}
-				template < typename T1, typename T2, typename T3, typename T4 >
-				static int call( lua_State* L, int index, void (*func)( T1, T2, T3, T4 ) )
-				{
-					func( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ), get_value<T4>( L, index + 3 ) ); return 0;
-				}
-				template < class C >
-				static int call( lua_State*, int, C& c, void (C::*func)() )
-				{
-					(c.*func)(); return 0;
-				}
-				template < class C, typename T1 >
-				static int call( lua_State* L, int index, C& c, void (C::*func)( T1 ) )
-				{
-					(c.*func)( get_value<T1>( L, index + 0 ) ); return 0;
-				}
-				template < class C, typename T1, typename T2 >
-				static int call( lua_State* L, int index, C& c, void (C::*func)( T1, T2 ) )
-				{
-					(c.*func)( get_value<T1>( L, index + 0 ),	get_value<T2>( L, index + 1 ) ); return 0;
-				}
-				template < class C, typename T1, typename T2, typename T3 >
-				static int call( lua_State* L, int index, C& c, void (C::*func)( T1, T2, T3 ) )
-				{
-					(c.*func)( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ) ); return 0;
-				}
-				template < class C, typename T1, typename T2, typename T3, typename T4 >
-				static int call( lua_State* L, int index, C& c, void (C::*func)( T1, T2, T3, T4 ) )
-				{
-					(c.*func)( get_value<T1>( L, index + 0 ), get_value<T2>( L, index + 1 ), get_value<T3>( L, index + 2 ), get_value<T4>( L, index + 3 ) ); return 0;
-				}
+			};
 
-			};
+			template <typename R, typename... Args, typename Head, typename ...Tail, typename... Vs>
+			int do_call(lua_State* L, int index, R(*func)(Args...), types<Head, Tail...>, Vs&&... vs)
+			{
+				do_call(L, index + 1, func, types < Tail... > {}, std::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;
+			}
+
+			template <typename R, class C, typename... Args, typename Head, typename ...Tail, typename... Vs>
+			int do_call(lua_State* L, int index, C& c, R(C::*func)(Args...), types<Head, Tail...>, Vs&&... vs)
+			{
+				do_call(L, index + 1, c, func, types < Tail... > {}, std::forward<Vs>(vs)..., get_value<Head>(L, index)); return 1;
+			}
+
+			template <typename R, typename... Args, typename... Vs>
+			int do_call(lua_State* L, int, R(*func)(Args...), types<>, Vs&&... vs)
+			{
+				call_and_push<R>::do_call(L, func, std::forward<Vs>(vs)...);
+				return 1;
+			}
+
+			template <typename R, class C, typename... Args, typename... Vs>
+			int do_call(lua_State* L, int, C& c, R(C::*func)(Args...), types<>, Vs&&... vs)
+			{
+				call_and_push<R>::do_call(L, c, func, std::forward<Vs>(vs)...);
+				return 1;
+			}
+
+			template < typename R, typename... Args >
+			int dispatch(lua_State* L, int index, R(*func)(Args...))
+			{
+				do_call(L, index, func, types < Args... > {});
+				return 1;
+			}
+			template < typename R, class C, typename... Args >
+			int dispatch(lua_State* L, int index, C& c, R(C::*func)(Args...))
+			{
+				do_call(L, index, c, func, types < Args... > {});
+				return 1;
+			}
 
 			template < typename F, F f > 
 			int function_wrapper( lua_State* L ) 
 			{
-				return dispatcher<typename return_type<F>::type>::call( L, 1, f );
+				return dispatch(L, 1, f);
 			}
 
@@ -148,5 +111,5 @@
 			{
 				C* c = (C*)to_ref_object( L, 1 );
-				return dispatcher<typename return_type<F>::type>::call( L, 2, *c, f );
+				return dispatch( L, 2, *c, f );
 			}
 
@@ -155,19 +118,7 @@
 			{
 				C* c = (C*)to_pointer( L, nv::lua::detail::upvalue_index(1) );
-				return dispatcher<typename return_type<F>::type>::call( L, 1, *c, f );
+				return dispatch( L, 1, *c, f );
 			}
 			
-			template< typename F >
-			int call( lua_State* L, int index, F func )
-			{
-				return dispatcher<typename return_type<F>::type>::call( L, index, func );
-			}
-
-			template< class C, typename F >
-			int call( lua_State* L, int index, C& c, F func )
-			{
-				return dispatcher<typename return_type<F>::type>::call( L, index, c, func );
-			}
-
 		}
 
Index: trunk/nv/lua/lua_function.hh
===================================================================
--- trunk/nv/lua/lua_function.hh	(revision 344)
+++ trunk/nv/lua/lua_function.hh	(revision 345)
@@ -51,27 +51,12 @@
 			}
 
-			template <typename T1>
-			R operator()( const T1& p1 )
+			template <typename... Args>
+			R operator()( Args&&... args )
 			{
 				retrieve();
-				detail::push_value( L, p1 );
-				return call_result<R>(1);
+				detail::push_values(L, std::forward<Args>(args)...);
+				return call_result<R>(sizeof...(Args));
 			}
 
-			template <typename T1, typename T2>
-			R operator()(const T1& p1, const T2& p2)
-			{
-				retrieve();
-				detail::push_values( L, p1, p2 );
-				return call_result<R>(2);
-			}
-
-			template <typename T1, typename T2, typename T3>
-			R operator()(const T1& p1, const T2& p2, const T3& p3)
-			{
-				retrieve();
-				detail::push_values( L, p1, p2, p3 );
-				return call_result<R>(3);
-			}
 		protected:
 			template< typename RR >
Index: trunk/nv/lua/lua_path.hh
===================================================================
--- trunk/nv/lua/lua_path.hh	(revision 344)
+++ trunk/nv/lua/lua_path.hh	(revision 345)
@@ -89,4 +89,5 @@
 			bool resolve( lua_State* L, bool global = true ) const;
 		private:
+
 			void parse();
 			void push( size_t start, size_t length );
Index: trunk/nv/lua/lua_state.hh
===================================================================
--- trunk/nv/lua/lua_state.hh	(revision 344)
+++ trunk/nv/lua/lua_state.hh	(revision 345)
@@ -55,52 +55,13 @@
 				return R();
 			}
-			template < typename R, typename T1 >
-			R call( const path& p, const T1& p1 )
-			{
-				if ( push_function( p, m_global ) )
-				{
-					detail::push_value( m_state, p1 );
-					if ( call_function( 1, detail::return_count< R >::value ) == 0 )
+			template < typename R, typename... Args >
+			R call(const path& p, Args&&... args )
+			{
+				if (push_function(p, m_global))
+				{
+					detail::push_values(m_state, std::forward<Args>(args)...);
+					if (call_function(sizeof...(Args), detail::return_count< R >::value) == 0)
 					{
-						return detail::pop_return_value<R>( m_state );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2 >
-			R call( const path& p, const T1& p1, const T2& p2 )
-			{
-				if ( push_function( p, m_global ) )
-				{
-					detail::push_values( m_state, p1, p2 );
-					if ( call_function( 2, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( m_state );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2, typename T3 >
-			R call( const path& p, const T1& p1, const T2& p2, const T3& p3 )
-			{
-				if ( push_function( p, m_global ) )
-				{
-					detail::push_values( m_state, p1, p2, p3 );
-					if ( call_function( 3, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( m_state );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2, typename T3, typename T4 >
-			R call( const path& p, const T1& p1, const T2& p2, const T3& p3, const T4& p4 )
-			{
-				if ( push_function( p, m_global ) )
-				{
-					detail::push_value( m_state, p1, p2, p3, p4 );
-					if ( call_function( 4, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( m_state );
+						return detail::pop_return_value<R>(m_state);
 					}
 				}
@@ -306,6 +267,6 @@
 				return R();
 			}
-			template < typename R, typename T1 >
-			R call( ref table, const path& p, const T1& p1 )
+			template < typename R, typename... Args >
+			R call( ref table, const path& p, Args&&... args )
 			{
 				stack_guard guard( this ); // TODO: remove
@@ -313,51 +274,6 @@
 				if ( push_function( p, false ) )
 				{
-					detail::push_value( m_state, p1 );
-					if ( call_function( 1, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( m_state );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2 >
-			R call( ref table, const path& p, const T1& p1, const T2& p2 )
-			{
-				stack_guard guard( this ); // TODO: remove
-				detail::push_ref_object( m_state, table );
-				if ( push_function( p, false ) )
-				{
-					detail::push_values( m_state, p1, p2 );
-					if ( call_function( 2, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( m_state );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2, typename T3 >
-			R call( ref table, const path& p, const T1& p1, const T2& p2, const T3& p3 )
-			{
-				stack_guard guard( this ); // TODO: remove
-				detail::push_ref_object( m_state, table );
-				if ( push_function( p, false ) )
-				{
-					detail::push_values( m_state, p1, p2, p3 );
-					if ( call_function( 3, detail::return_count< R >::value ) == 0 )
-					{
-						return detail::pop_return_value<R>( m_state );
-					}
-				}
-				return R();
-			}
-			template < typename R, typename T1, typename T2, typename T3, typename T4 >
-			R call( ref table, const path& p, const T1& p1, const T2& p2, const T3& p3, const T4& p4 )
-			{
-				stack_guard guard( this ); // TODO: remove
-				detail::push_ref_object( m_state, table );
-				if ( push_function( p, false ) )
-				{
-					detail::push_value( m_state, p1, p2, p3, p4 );
-					if ( call_function( 4, detail::return_count< R >::value ) == 0 )
+					detail::push_values( m_state, std::forward<Args>(args)... );
+					if (call_function(sizeof...(Args), detail::return_count< R >::value) == 0)
 					{
 						return detail::pop_return_value<R>( m_state );
Index: trunk/nv/lua/lua_values.hh
===================================================================
--- trunk/nv/lua/lua_values.hh	(revision 344)
+++ trunk/nv/lua/lua_values.hh	(revision 345)
@@ -213,14 +213,16 @@
  			}
 
-			template < typename T1 >
-			void push_values( lua_State *L, const T1& p1 ) { push_value( L, p1 ); }
-			template < typename T1, typename T2 >
-			void push_values( lua_State *L, const T1& p1, const T2& p2 ) { push_value( L, p1 ); push_value( L, p2 ); }
-			template < typename T1, typename T2, typename T3 >
-			void push_values( lua_State *L, const T1& p1, const T2& p2, const T3& p3 ) { push_value( L, p1 ); push_value( L, p2 ); push_value( L, p3 ); }
-			template < typename T1, typename T2, typename T3, typename T4 >
-			void push_values( lua_State *L, const T1& p1, const T2& p2, const T3& p3, const T4& p4 ) { push_value( L, p1 ); push_value( L, p2 ); push_value( L, p3 ); push_value( L, p4 ); }
-			template < typename T1, typename T2, typename T3, typename T4, typename T5 >
-			void push_values( lua_State *L, const T1& p1, const T2& p2, const T3& p3, const T4& p4, const T5& p5 ) { push_value( L, p1 ); push_value( L, p2 ); push_value( L, p3 ); push_value( L, p4 ); push_value( L, p5 ); }
+			template < typename T >
+			void push_values(lua_State *L, T&& p)
+			{
+				push_value( L, std::forward<T>(p) );
+			}
+			template < typename T, typename ...Ts >
+			void push_values(lua_State *L, T&& p, Ts&& ...ps)
+			{
+				push_value(L, std::forward<T>(p));
+				push_values(L, std::forward<Ts>(ps)...);
+			}
+
 
 			template < typename T >
