Index: trunk/nv/lua/lua_dispatch.hh
===================================================================
--- trunk/nv/lua/lua_dispatch.hh	(revision 212)
+++ trunk/nv/lua/lua_dispatch.hh	(revision 213)
@@ -154,5 +154,5 @@
 			int fixed_method_wrapper( lua_State* L ) 
 			{
-				C* c = (C*)to_pointer( L, nv::lua::upvalue_index(1) );
+				C* c = (C*)to_pointer( L, nv::lua::detail::upvalue_index(1) );
 				return dispatcher<typename return_type<F>::type>::call( L, c, 1, f );
 			}
Index: trunk/nv/lua/lua_state.hh
===================================================================
--- trunk/nv/lua/lua_state.hh	(revision 212)
+++ trunk/nv/lua/lua_state.hh	(revision 213)
@@ -4,4 +4,8 @@
 // This file is part of NV Libraries.
 // For conditions of distribution and use, see copyright notice in nv.hh
+//
+// TODO: decouple from the type database
+// TODO: paths for function registration?
+
 
 #ifndef NV_LUA_HH
@@ -25,6 +29,4 @@
 		const int ref_nil   = -1;
 		const int ret_multi = -1;
-
-		int upvalue_index( int i );
 
 		typedef int reference;
Index: trunk/nv/lua/lua_values.hh
===================================================================
--- trunk/nv/lua/lua_values.hh	(revision 212)
+++ trunk/nv/lua/lua_values.hh	(revision 213)
@@ -52,5 +52,5 @@
 		namespace detail
 		{
-			struct void_type {};
+			int upvalue_index( int i );
 
 			void push_unsigned( lua_State *L, lunsigned v );
Index: trunk/src/lua/lua_state.cc
===================================================================
--- trunk/src/lua/lua_state.cc	(revision 212)
+++ trunk/src/lua/lua_state.cc	(revision 213)
@@ -433,6 +433,2 @@
 }
 
-int nv::lua::upvalue_index( int i )
-{
-	return lua_upvalueindex(i);
-}
Index: trunk/src/lua/lua_values.cc
===================================================================
--- trunk/src/lua/lua_values.cc	(revision 212)
+++ trunk/src/lua/lua_values.cc	(revision 213)
@@ -13,4 +13,9 @@
 using nv::lua::lnumber;
 using nv::lua::lunsigned;
+
+int nv::lua::detail::upvalue_index( int i )
+{
+	return lua_upvalueindex(i);
+}
 
 bool nv::lua::detail::is_userdata( lua_State *L, int index, const char* metatable )
Index: trunk/tests/lualib_test/lualib_test.cc
===================================================================
--- trunk/tests/lualib_test/lualib_test.cc	(revision 212)
+++ trunk/tests/lualib_test/lualib_test.cc	(revision 213)
@@ -1,4 +1,5 @@
 #include <nv/lib/lua.hh>
 #include <nv/lua/lua_state.hh>
+#include <nv/lua/lua_dispatch.hh>
 #include <nv/lua/lua_raw.hh>
 #include <nv/lua/lua_glm.hh>
@@ -10,4 +11,10 @@
 #include <functional>
 #include <nv/gui/gui_element.hh>
+
+void hello( const std::string& h )
+{
+	std::cout << h << " world from C++!" << std::endl;
+}
+
 
 int main(int, char* [])
@@ -22,7 +29,9 @@
 	{
 		nv::lua::state state( true );
-		nlua_register_glm( state );
+		nv::lua::register_glm( state );
 		// run the Lua script
+		state.register_function<decltype(hello),&hello>( "hello" );
 		state.do_file( "init.lua" );
+		//std::cout << nv::function_traits<decltype(hello)>::arg_count << std::endl;
 
 		log.set_level( nv::LOG_INFO );
