Index: trunk/nv/gl/gl_device.hh
===================================================================
--- trunk/nv/gl/gl_device.hh	(revision 61)
+++ trunk/nv/gl/gl_device.hh	(revision 62)
@@ -26,5 +26,5 @@
 		virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr );
 		virtual vertex_array* create_vertex_array();
-		virtual texture2d* create_texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler, void* data = nullptr );
+		virtual texture2d* create_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data = nullptr );
 		virtual ~gl_device();
 	private:
Index: trunk/nv/gl/gl_enum.hh
===================================================================
--- trunk/nv/gl/gl_enum.hh	(revision 61)
+++ trunk/nv/gl/gl_enum.hh	(revision 62)
@@ -37,6 +37,6 @@
 	unsigned int primitive_to_enum( primitive p );
 
-	unsigned int type_to_gl_enum( type type );
-	type gl_enum_to_type( unsigned int gl_enum );
+	unsigned int type_to_gl_enum( etype type );
+	etype gl_enum_to_type( unsigned int gl_enum );
 
 } // namespace nv
Index: trunk/nv/gl/gl_texture2d.hh
===================================================================
--- trunk/nv/gl/gl_texture2d.hh	(revision 61)
+++ trunk/nv/gl/gl_texture2d.hh	(revision 62)
@@ -22,5 +22,5 @@
 	{
 	public:
-		gl_texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler, void* data = nullptr );
+		gl_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data = nullptr );
 		virtual void assign( void* data );
 		virtual void bind( int slot = 0 );
Index: trunk/nv/interface/device.hh
===================================================================
--- trunk/nv/interface/device.hh	(revision 61)
+++ trunk/nv/interface/device.hh	(revision 62)
@@ -31,5 +31,5 @@
 		virtual index_buffer* create_index_buffer( buffer_hint hint, int size, void* source = nullptr ) = 0;
 		virtual vertex_array* create_vertex_array() = 0;
-		virtual texture2d* create_texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler, void* data = nullptr ) = 0;
+		virtual texture2d* create_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data = nullptr ) = 0;
 	};
 
Index: trunk/nv/interface/program.hh
===================================================================
--- trunk/nv/interface/program.hh	(revision 61)
+++ trunk/nv/interface/program.hh	(revision 62)
@@ -28,5 +28,5 @@
 			const string& name,
 			int location,
-			type type,
+			etype type,
 			int length ) :
 			m_name( name ),
@@ -40,5 +40,5 @@
 		const string& get_name() const { return m_name; }
 		int get_location() const { return m_location; }
-		type get_type() const { return m_type; }
+		etype get_type() const { return m_type; }
 		int get_length() const { return m_length; }
 
@@ -46,5 +46,5 @@
 		string m_name;
 		int    m_location;
-		type   m_type;
+		etype  m_type;
 		int    m_length;
 	};
@@ -53,7 +53,7 @@
 	{
 	public: 
-		uniform_base( const string& name, type type, int location, int length ) 
+		uniform_base( const string& name, etype type, int location, int length ) 
 			: m_name( name ), m_type( type ), m_location(location), m_length( length ), m_dirty( true ) {}
-		type get_type() const { return m_type; }
+		etype get_type() const { return m_type; }
 		int get_location() const { return m_location; }
 		int get_length() const { return m_length; }
@@ -62,8 +62,8 @@
 	protected:
 		string m_name;
-		type m_type;
-		int m_location;
-		int m_length;
-		bool m_dirty;
+		etype  m_type;
+		int    m_location;
+		int    m_length;
+		bool   m_dirty;
 	};
 
@@ -164,5 +164,5 @@
 		}
 	protected:
-		uniform_base* create_uniform( type utype, const string& name, int location, int length )
+		uniform_base* create_uniform( etype utype, const string& name, int location, int length )
 		{
 			switch( utype )
Index: trunk/nv/interface/texture2d.hh
===================================================================
--- trunk/nv/interface/texture2d.hh	(revision 61)
+++ trunk/nv/interface/texture2d.hh	(revision 62)
@@ -60,5 +60,5 @@
 	public:
 
-		texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler ) : 
+		texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler ) : 
 			m_size( size ), m_format( aformat ), m_datatype( adatatype ), m_sampler( asampler ) {}
 		virtual void assign( void* data ) = 0;
@@ -70,10 +70,10 @@
 		int get_height() const { return m_size.y; }
 		image_format get_format() const { return m_format; }
-		type get_datatype() const { return m_datatype; }
+		etype get_datatype() const { return m_datatype; }
 		const sampler& get_sampler() const { return m_sampler; }
 	protected:
 		ivec2        m_size;
 		image_format m_format;
-		type         m_datatype;
+		etype         m_datatype;
 		sampler      m_sampler;
 	};
Index: trunk/nv/interface/vertex_buffer.hh
===================================================================
--- trunk/nv/interface/vertex_buffer.hh	(revision 61)
+++ trunk/nv/interface/vertex_buffer.hh	(revision 62)
@@ -58,9 +58,9 @@
 	{
 	public:
-		vertex_buffer_attribute( vertex_buffer* buffer, type datatype, int components, int offset = 0, int stride = 0, bool owner = true )
+		vertex_buffer_attribute( vertex_buffer* buffer, etype datatype, int components, int offset = 0, int stride = 0, bool owner = true )
 			: m_buffer( buffer ), m_datatype( datatype ), m_components( components ), m_offset( offset ), m_stride( stride ), m_owner( owner ) {}
 
 		vertex_buffer* get_buffer() const { return m_buffer; }
-		type get_datatype() const { return m_datatype; }
+		etype get_datatype() const { return m_datatype; }
 		int get_components() const { return m_components; }
 		int get_offset() const { return m_offset; }
@@ -76,5 +76,5 @@
 	protected:
 		vertex_buffer* m_buffer;
-		type           m_datatype;
+		etype           m_datatype;
 		int  m_components;
 		int  m_offset;
@@ -89,5 +89,5 @@
 	public:
 		vertex_array() : m_map(), m_index( nullptr ) {}
-		void add_vertex_buffer( int location, vertex_buffer* buffer, type datatype, int components, int offset = 0, int stride = 0, bool owner = true ) 
+		void add_vertex_buffer( int location, vertex_buffer* buffer, etype datatype, int components, int offset = 0, int stride = 0, bool owner = true ) 
 		{
 			m_map[ location ] = new vertex_buffer_attribute( buffer, datatype, components, offset, stride, owner );
Index: trunk/nv/lib/sdl12.hh
===================================================================
--- trunk/nv/lib/sdl12.hh	(revision 61)
+++ trunk/nv/lib/sdl12.hh	(revision 62)
@@ -1019,5 +1019,5 @@
 NV_SDL_FUN( void, SDL_SetEventFilter, (SDL_EventFilter filter) );
 NV_SDL_FUN( SDL_EventFilter, SDL_GetEventFilter, (void) );
-NV_SDL_FUN( Uint8, SDL_EventState, (Uint8 type, int state) );
+NV_SDL_FUN( Uint8, SDL_EventState, (Uint8 etype, int state) );
 
 #define SDL_RWseek(ctx, offset, whence)	(ctx)->seek(ctx, offset, whence)
Index: trunk/nv/lib/sdl_image.hh
===================================================================
--- trunk/nv/lib/sdl_image.hh	(revision 61)
+++ trunk/nv/lib/sdl_image.hh	(revision 62)
@@ -41,5 +41,5 @@
 NV_SDL_FUN( int, IMG_Init, (int flags) );
 NV_SDL_FUN( void, IMG_Quit, (void) );
-NV_SDL_FUN( SDL_Surface *, IMG_LoadTyped_RW, (SDL_RWops *src, int freesrc, char *type) );
+NV_SDL_FUN( SDL_Surface *, IMG_LoadTyped_RW, (SDL_RWops *src, int freesrc, char *etype) );
 NV_SDL_FUN( SDL_Surface *, IMG_Load, (const char *file) );
 NV_SDL_FUN( SDL_Surface *, IMG_Load_RW, (SDL_RWops *src, int freesrc) );
Index: trunk/nv/types.hh
===================================================================
--- trunk/nv/types.hh	(revision 61)
+++ trunk/nv/types.hh	(revision 62)
@@ -20,5 +20,5 @@
 {
 
-	enum type
+	enum etype
 	{
 		INT,
@@ -52,5 +52,5 @@
 	typedef glm::mat4 mat4;
 
-	template < type EnumType > struct enum_to_type {};
+	template < etype EnumType > struct enum_to_type {};
 
 	template <> struct enum_to_type< INT >   { typedef int type; };
@@ -76,23 +76,23 @@
 	template < typename TYPE > struct type_to_enum {};
 
-	template <> struct type_to_enum< int >           { static const type type = INT; };
-	template <> struct type_to_enum< unsigned int >  { static const type type = UINT; };
-	template <> struct type_to_enum< short >         { static const type type = SHORT; };
-	template <> struct type_to_enum< unsigned short >{ static const type type = USHORT; };
-	template <> struct type_to_enum< char >          { static const type type = BYTE; };
-	template <> struct type_to_enum< unsigned char > { static const type type = UBYTE; };
-	template <> struct type_to_enum< f32 > { static const type type = FLOAT; };
-
-	template <> struct type_to_enum< vec2 > { static const type type = FLOAT_VECTOR_2; };
-	template <> struct type_to_enum< vec3 > { static const type type = FLOAT_VECTOR_3; };
-	template <> struct type_to_enum< vec4 > { static const type type = FLOAT_VECTOR_4; };
-
-	template <> struct type_to_enum< ivec2 > { static const type type = INT_VECTOR_2; };
-	template <> struct type_to_enum< ivec3 > { static const type type = INT_VECTOR_3; };
-	template <> struct type_to_enum< ivec4 > { static const type type = INT_VECTOR_4; };
-
-	template <> struct type_to_enum< mat2 > { static const type type = FLOAT_MATRIX_2; };
-	template <> struct type_to_enum< mat3 > { static const type type = FLOAT_MATRIX_3; };
-	template <> struct type_to_enum< mat4 > { static const type type = FLOAT_MATRIX_4; };
+	template <> struct type_to_enum< int >           { static const etype type = INT; };
+	template <> struct type_to_enum< unsigned int >  { static const etype type = UINT; };
+	template <> struct type_to_enum< short >         { static const etype type = SHORT; };
+	template <> struct type_to_enum< unsigned short >{ static const etype type = USHORT; };
+	template <> struct type_to_enum< char >          { static const etype type = BYTE; };
+	template <> struct type_to_enum< unsigned char > { static const etype type = UBYTE; };
+	template <> struct type_to_enum< f32 > { static const etype type = FLOAT; };
+
+	template <> struct type_to_enum< vec2 > { static const etype type = FLOAT_VECTOR_2; };
+	template <> struct type_to_enum< vec3 > { static const etype type = FLOAT_VECTOR_3; };
+	template <> struct type_to_enum< vec4 > { static const etype type = FLOAT_VECTOR_4; };
+
+	template <> struct type_to_enum< ivec2 > { static const etype type = INT_VECTOR_2; };
+	template <> struct type_to_enum< ivec3 > { static const etype type = INT_VECTOR_3; };
+	template <> struct type_to_enum< ivec4 > { static const etype type = INT_VECTOR_4; };
+
+	template <> struct type_to_enum< mat2 > { static const etype type = FLOAT_MATRIX_2; };
+	template <> struct type_to_enum< mat3 > { static const etype type = FLOAT_MATRIX_3; };
+	template <> struct type_to_enum< mat4 > { static const etype type = FLOAT_MATRIX_4; };
 
 	template <typename TYPE>
Index: trunk/src/gl/gl_device.cc
===================================================================
--- trunk/src/gl/gl_device.cc	(revision 61)
+++ trunk/src/gl/gl_device.cc	(revision 62)
@@ -67,5 +67,5 @@
 }
 
-texture2d* gl_device::create_texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler, void* data /*= nullptr */ )
+texture2d* gl_device::create_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data /*= nullptr */ )
 {
 	return new gl_texture2d( size, aformat, adatatype, asampler, data );
Index: trunk/src/gl/gl_enum.cc
===================================================================
--- trunk/src/gl/gl_enum.cc	(revision 61)
+++ trunk/src/gl/gl_enum.cc	(revision 62)
@@ -185,5 +185,5 @@
 }
 
-unsigned int nv::type_to_gl_enum( type type )
+unsigned int nv::type_to_gl_enum( etype type )
 {
 	switch( type )
@@ -209,5 +209,5 @@
 }
 
-nv::type nv::gl_enum_to_type( unsigned int gl_enum )
+nv::etype nv::gl_enum_to_type( unsigned int gl_enum )
 {
 	switch( gl_enum )
@@ -229,5 +229,5 @@
 	case GL_INT_VEC3       : return INT_VECTOR_3;
 	case GL_INT_VEC4       : return INT_VECTOR_4;
-	default : return type(0); // TODO: throw!
-	}
-}
+	default : return etype(0); // TODO: throw!
+	}
+}
Index: trunk/src/gl/gl_program.cc
===================================================================
--- trunk/src/gl/gl_program.cc	(revision 61)
+++ trunk/src/gl/gl_program.cc	(revision 62)
@@ -180,5 +180,5 @@
 
 		int uni_loc = glGetUniformLocation( m_name.get_value(), name.c_str() );
-		type utype = gl_enum_to_type( uni_type );
+		etype utype = gl_enum_to_type( uni_type );
 		m_uniform_map[ name ] = create_uniform( utype, name, uni_loc, uni_len );
 	}
Index: trunk/src/gl/gl_texture2d.cc
===================================================================
--- trunk/src/gl/gl_texture2d.cc	(revision 61)
+++ trunk/src/gl/gl_texture2d.cc	(revision 62)
@@ -10,5 +10,5 @@
 using namespace nv;
 
-nv::gl_texture2d::gl_texture2d( ivec2 size, image_format aformat, type adatatype, sampler asampler, void* data /*= nullptr */ )
+nv::gl_texture2d::gl_texture2d( ivec2 size, image_format aformat, etype adatatype, sampler asampler, void* data /*= nullptr */ )
 	: texture2d( size, aformat, adatatype, asampler ), m_name()
 {
Index: trunk/tests/lualib_test/lualib_test.cc
===================================================================
--- trunk/tests/lualib_test/lualib_test.cc	(revision 61)
+++ trunk/tests/lualib_test/lualib_test.cc	(revision 62)
@@ -3,14 +3,37 @@
 #include <nv/lua/lua_glm.hh>
 #include <nv/logger.hh>
+#include <nv/types.hh>
+#include <nv/object.hh>
 #include <string>
 #include <iostream>
+#include <functional>
+
+struct test_struct
+{
+	std::string f;
+	int i;
+};
+
+NV_REGISTER_NAME( test_struct )
 
 int main(int, char* [])
 {
+	nv::type_database db;
+	nv::object::register_type( &db );
+
+	db.create_type<int>();
+	db.create_type<std::string>();
+	nv::type_field fields[] = { 
+		nv::type_field("f", &test_struct::f ),
+		nv::type_field("i", &test_struct::i ),
+	};
+	db.create_type<test_struct>().fields( fields );
+
+
 	nv::logger log(nv::LOG_TRACE);
 	log.add_sink( new nv::log_file_sink("log.txt"), nv::LOG_TRACE );
 	log.add_sink( new nv::log_console_sink(), nv::LOG_TRACE );
 	nv::load_lua_library();
-		
+	
 	NV_LOG( nv::LOG_NOTICE, "Logging started" );
 
@@ -38,5 +61,5 @@
 	luaL_dofile(lua_state, "init.lua");
 
-	while (true)
+	for (;;)
 	{
 		std::string input;
