Index: trunk/nv.lua
===================================================================
--- trunk/nv.lua	(revision 395)
+++ trunk/nv.lua	(revision 396)
@@ -4,5 +4,5 @@
 	kind "StaticLib"
 	includedirs { "." }
-	files { "nv/core/**.hh", "nv/stl/**.hh", "nv/interface/**.hh", "nv/detail/**.inc", "src/core/**.cc", "src/stl/**.cc"  }
+	files { "nv/common.hh", "nv/base/**.hh", "nv/core/**.hh", "nv/stl/**.hh", "nv/interface/**.hh", "nv/detail/**.inc", "src/core/**.cc", "src/stl/**.cc"  }
 
 project "nv-lib"
Index: trunk/nv/base/assert.hh
===================================================================
--- trunk/nv/base/assert.hh	(revision 396)
+++ trunk/nv/base/assert.hh	(revision 396)
@@ -0,0 +1,47 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+ * @file assert.hh
+ * @author Kornel Kisielewicz
+ * @brief Assert functions
+ */
+
+#ifndef NV_BASE_COMMON_HH
+#error "Do not include assert.hh directly, inlcude nv/common.hh"
+#endif
+
+#ifndef NV_BASE_ASSERT_HH
+#define NV_BASE_ASSERT_HH
+
+#ifdef NV_INTERNAL_INCLUDE
+#undef NV_BASE_COMMON_HH
+#include <nv/base/common.hh>
+#endif
+
+#if NV_COMPILER == NV_MSVC
+void nv_internal_assert( const wchar_t * message, const wchar_t* file, unsigned line );
+#	if NV_DEBUG
+#	define NV_ASSERT_IMPL(cond) (void)( (!!(cond)) || (nv_internal_assert(NV_WIDE(#cond), NV_WIDE(__FILE__), __LINE__), 0) )
+#	else
+#	define NV_ASSERT_IMPL(cond) 
+#	endif
+#else
+void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function );
+#	if NV_DEBUG
+#	define NV_ASSERT_IMPL(cond) ((cond) ? static_cast<void>(0) : nv_internal_assert(NV_STRINGIZE(cond), __FILE__, __LINE__, __PRETTY_FUNCTION__))
+#	else
+#	define NV_ASSERT_IMPL(cond) 
+#	endif
+#endif
+
+#if NV_DEBUG
+#define NV_ASSERT(cond, msg) NV_ASSERT_IMPL( (cond) && "assertion failed:" msg )
+#else  
+#define NV_ASSERT(cond, msg)     ((void)0)
+#endif 
+
+#endif // NV_BASE_ASSERT_HH
Index: trunk/nv/base/capi.hh
===================================================================
--- trunk/nv/base/capi.hh	(revision 396)
+++ trunk/nv/base/capi.hh	(revision 396)
@@ -0,0 +1,122 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+ * @file capi.hh
+ * @author Kornel Kisielewicz
+ * @brief C API functions
+ *
+ * This header is temporary
+ */
+
+#ifndef NV_BASE_CAPI_HH
+#define NV_BASE_CAPI_HH
+
+#include <nv/common.hh>
+
+namespace nv
+{
+
+	namespace detail
+	{
+
+#if NV_COMPILER == NV_MSVC
+#define NV_CAPI_CALL(name) detail::name
+		extern "C" {
+			NV_NOALIAS NV_RESTRICT void * __cdecl calloc( size_t _Count, size_t _Size );
+			NV_NOALIAS             void   __cdecl free( void * _Memory );
+			NV_NOALIAS NV_RESTRICT void * __cdecl malloc( size_t );
+			NV_NOALIAS NV_RESTRICT void * __cdecl realloc( void * _Memory, size_t _NewSize );
+			void *  __cdecl memcpy( void * _Dst, const void * _Src, size_t _Size );
+			void *  __cdecl memmove( void * _Dst, const void * _Src, size_t _Size );
+			void *  __cdecl memset( void * _Dst, int _Val, size_t _Size );
+			void *  __cdecl memchr( const void * _Buf, int _Val, size_t _MaxCount );
+			int     __cdecl memcmp( const void * _Buf1, const void * _Buf2, size_t _Size );
+			int     __cdecl strcmp( const char * _Str1, const char * _Str2 );
+			int     __cdecl strncmp( const char * _Str1, const char * _Str2, size_t _MaxCount );
+			size_t  __cdecl strlen( const char * _Str );
+		}
+#endif 
+		// TODO: remove when clang 3.5 will be used (with builtins)
+#if NV_COMPILER == NV_CLANG || NV_COMPILER == NV_GNUC
+#define NV_CAPI_CALL(name) detail::name
+		extern "C" {
+			extern void * __cdecl calloc( nv::size_t, nv::size_t );
+			extern void   __cdecl free( void * );
+			extern void * __cdecl malloc( nv::size_t );
+			extern void * __cdecl realloc( void * , nv::size_t );
+			extern void * __cdecl memcpy( void * , const void * , nv::size_t );
+			extern void * __cdecl memmove( void * , const void * , nv::size_t );
+			extern void * __cdecl memset( void * , int , nv::size_t );
+			extern void * __cdecl memchr( const void * , int , nv::size_t );
+			extern int    __cdecl memcmp( const void * , const void * , nv::size_t  );
+			extern int    __cdecl strcmp ( const char * , const char * );
+			extern int    __cdecl strncmp( const char * , const char * , size_t );
+			extern nv::size_t __cdecl strlen ( const char * );
+		}
+#endif
+	}
+
+	inline void* nvmalloc( size_t size )
+	{
+		return NV_CAPI_CALL(malloc)( size );
+	}
+	inline void* nvrealloc( void* p, size_t size )
+	{
+		if ( size > 0 ) return NV_CAPI_CALL( realloc )( p, size );
+		NV_CAPI_CALL( free )( p );
+		return nullptr;
+	}
+	inline void nvfree( void* p )
+	{
+		if ( p ) NV_CAPI_CALL( free )( p );
+	}
+
+	inline void* nvmemcpy( void *dest, const void *src, size_t count )
+	{
+		return NV_CAPI_CALL( memcpy )( dest, src, count );
+	}
+
+	inline void* nvmemmove( void *dest, const void *src, size_t count )
+	{
+		return NV_CAPI_CALL( memmove )( dest, src, count );
+	}
+
+	inline void* nvmemset( void *dest, unsigned char value, size_t count )
+	{
+		return NV_CAPI_CALL( memset )( dest, (int)value, count );
+	}
+
+	inline void* nvmemchr( const void *src, unsigned char value, size_t max_count )
+	{
+		return NV_CAPI_CALL( memchr )( src, (int)value, max_count );
+	}
+
+	inline int nvmemcmp( const void * m1, const void * m2, nv::size_t max_count )
+	{
+		return NV_CAPI_CALL( memcmp )( m1, m2, max_count );
+	}
+
+	inline int nvstrcmp( const char * s1, const char * s2 )
+	{
+		return NV_CAPI_CALL( strcmp )( s1, s2 );
+	}	
+
+	inline int nvstrncmp( const char * s1, const char * s2, size_t max_count )
+	{
+		return NV_CAPI_CALL( strncmp )( s1, s2, max_count );
+	}
+
+	inline nv::size_t nvstrlen( const char * s )
+	{
+		return NV_CAPI_CALL( strlen )( s );
+	}
+
+}
+
+#undef NV_CAPI_CALL
+
+#endif // NV_BASE_CAPI_HH
Index: trunk/nv/base/common.hh
===================================================================
--- trunk/nv/base/common.hh	(revision 396)
+++ trunk/nv/base/common.hh	(revision 396)
@@ -0,0 +1,276 @@
+// Copyright (C) 2012-2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+#ifndef NV_BASE_COMMON_HH
+#define NV_BASE_COMMON_HH
+
+#define _ITERATOR_DEBUG_LEVEL 0
+
+// NV Library version
+#define NV_VERSION_MAJOR 0
+#define NV_VERSION_MINOR 1
+#define NV_VERSION_PATCH 0
+#define NV_VERSION    (NV_VERSION_MAJOR << 16) | (NV_VERSION_MINOR << 8) | NV_VERSION_PATCH)
+
+// Platform
+#define NV_WINDOWS        1
+#define NV_LINUX          2
+#define NV_APPLE          3
+
+// Compiler
+#define NV_MSVC           1
+#define NV_GNUC           2
+#define NV_CLANG          3
+
+// Endianess
+#define NV_LITTLEENDIAN   1
+#define NV_BIGENDIAN      2
+
+// Bits
+#define NV_32BIT          1
+#define NV_64BIT          2
+
+// Assumption
+#define NV_ENDIANESS NV_LITTLEENDIAN
+
+// Platform detection
+#if defined( __WIN32__ ) || defined( _WIN32 )
+#define NV_PLATFORM NV_WINDOWS
+#elif defined( __APPLE_CC__)
+#define NV_PLATFORM NV_APPLE
+#else
+#define NV_PLATFORM NV_LINUX
+#endif
+
+// Compiler detection
+#if defined( _MSC_VER )
+#define NV_COMPILER NV_MSVC
+#define NV_COMP_VER _MSC_VER
+#elif defined( __clang__ )
+#define NV_COMPILER NV_CLANG
+#define NV_COMP_VER (((__clang_major__)*100) + (__clang_minor__*10) + __clang_patchlevel__)
+#elif defined( __GNUC__ )
+#define NV_COMPILER NV_GNUC
+#define NV_COMP_VER (((__GNUC__)*100) + (__GNUC_MINOR__*10) + __GNUC_PATCHLEVEL__)
+#else
+#error "Unknown compiler!"
+#endif
+
+// Architecture detection
+#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__)
+#define NV_ARCHITECTURE NV_64BIT
+#elif defined(__ia64__) || defined(__s390__) || defined(__s390x__)
+#define NV_ARCHITECTURE NV_64BIT
+#else
+#define NV_ARCHITECTURE NV_32BIT
+#endif
+
+// Platform specific settings.
+#if NV_COMPILER == NV_MSVC
+#ifdef _DEBUG
+#define NV_DEBUG 1
+#else
+#define NV_DEBUG 0
+#endif
+#else
+#ifdef NDEBUG
+#define NV_DEBUG 0
+#else
+#define NV_DEBUG 1
+#endif
+#endif
+
+#if NV_DEBUG
+#ifndef NV_PROFILER
+#define NV_PROFILER 
+#endif
+#endif
+
+#ifdef NV_PROFILER
+#undef NV_PROFILER
+#define NV_PROFILER 1
+#else
+#define NV_PROFILER 0
+#endif
+
+#if NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
+#define NV_POSIX
+#endif
+
+#if NV_COMPILER == NV_MSVC && NV_COMP_VER < 1900
+#error "MSVC 2015+ required!"
+#endif
+
+#if NV_COMPILER == NV_GNUC && NV_COMP_VER < 480
+#error "GCC 4.8+ required!"
+#endif
+
+#if NV_COMPILER == NV_CLANG && NV_COMP_VER < 330
+#error "clang 3.3+ required!"
+#endif
+
+#if NV_COMPILER == NV_MSVC 
+#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
+#pragma warning( disable : 4510 ) // default constructor could not be generated
+#pragma warning( disable : 4610 ) // object 'class' can never be instantiated - user-defined constructor required
+#undef _SCL_SECURE_NO_WARNINGS // to prevent redefining
+#define _SCL_SECURE_NO_WARNINGS
+#endif
+
+#define NV_STRINGIZE_DETAIL(x) #x
+#define NV_STRINGIZE(x) NV_STRINGIZE_DETAIL(x)
+
+#if NV_COMPILER == NV_MSVC
+#define NV_WIDE_DETAIL(x) L ## x
+#define NV_WIDE(x) NV_WIDE_DETAIL(x)
+#endif
+
+#if NV_COMPILER == NV_MSVC
+#define NV_DEPRECATED(func) __declspec(deprecated) func
+#define NV_ALIGN(value) __declspec(align(value))
+#define NV_ALIGNED_STRUCT(value) __declspec(align(value)) struct
+#define NV_NOALIAS __declspec(noalias)
+#define NV_RESTRICT __declspec(restrict)
+#define NV_RESTRICT_VAR __restrict
+#if NV_ARCHITECTURE == NV_64BIT
+#define NV_OFFSET_OF(obj,m) (nv::size_t)( (nv::ptrdiff_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) )
+#else // NV_32BIT
+#define NV_OFFSET_OF(obj,m) (nv::size_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m))
+#define NV_MSVC_SUPRESS( warn_number ) __pragma( warning( suppress : warn_number ) )
+#endif  
+#elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG
+#define NV_DEPRECATED(func) func __attribute__ ((deprecated))
+#define NV_ALIGN(value) __attribute__((aligned(value)))
+#define NV_ALIGNED_STRUCT(value) struct __attribute__((aligned(value)))
+#define NV_RESTRICT __restrict__
+#define NV_RESTRICT_VAR __restrict__
+#define NV_OFFSET_OF(obj, m) __builtin_offsetof(obj, m)
+#define NV_MSVC_SUPRESS( warn_number ) 
+#else
+#error "Unknown compiler, cannot proceed!"
+#endif 
+
+#define NV_UNUSED(x) (void)(x)
+#define NV_THROW(eobj, ...) { \
+	NV_LOG_ERROR( __FILE__ " line " NV_STRINGIZE(__LINE__) " - exception thrown - " #eobj ); \
+	throw eobj( __VA_ARGS__ ); \
+} 
+
+// MSVC and GCC is too stupid to notice fully covered enums, clang 
+// is picky about it
+#if NV_COMPILER == NV_CLANG
+#define NV_RETURN_COVERED_DEFAULT( value ) 
+#else
+#define NV_RETURN_COVERED_DEFAULT( value ) default : return value
+#endif
+
+#define NV_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((nv::size_t)(!(sizeof(x) % sizeof(0[x])))))
+#define NV_SAFE_ARRAY( arr, idx, def ) ( index < NV_COUNT_OF(arr) ? (arr)[idx] : (def) )
+
+#define NV_TYPE_FAIL(T) (nv::static_assert_fail<T>::value)
+#define NV_TEMPLATE_FAIL(T,message) static_assert( NV_TYPE_FAIL(T), message );
+
+namespace nv
+{
+	template < typename T >
+	struct static_assert_fail
+	{
+		static constexpr bool value = false;
+	};
+
+#if NV_COMPILER == NV_MSVC 
+	using ::size_t;
+#else
+	using size_t    = decltype( 0 );
+#endif
+	using ptrdiff_t = decltype((int*)0 - (int*)0);
+	using nullptr_t = decltype( nullptr );
+	
+#if NV_ARCHITECTURE == NV_64BIT
+	using uintptr_t = unsigned long long;
+#else
+	using uintptr_t = unsigned int;
+#endif
+
+	// Typedefs for fixed size types.
+	typedef signed   char      sint8;
+	typedef signed   short     sint16;
+	typedef signed   int       sint32;
+
+	typedef unsigned char      uint8;
+	typedef unsigned short     uint16;
+	typedef unsigned int       uint32;
+
+	typedef signed   long long sint64;
+	typedef unsigned long long uint64;
+
+	typedef unsigned char      uchar8;
+	typedef unsigned short     uchar16;
+	typedef unsigned int       uchar32;
+
+	typedef signed char        schar8;
+	typedef signed short       schar16;
+	typedef signed long        schar32;
+
+	typedef float              f32;
+	typedef double             f64;
+
+	typedef uint64             uid;
+
+	struct empty_type {};
+
+	template < typename T >
+	class empty_base_class {};
+
+	template < int a, int b, int c, int d >
+	struct four_cc
+	{
+		static constexpr unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
+	};
+
+	class noncopyable
+	{
+	protected:
+		constexpr noncopyable() = default;
+		~noncopyable() = default;
+		noncopyable( const noncopyable& ) = delete;
+		noncopyable& operator=( const noncopyable& ) = delete;
+	};
+
+	template <typename OBJ, typename T>
+	inline size_t offset_of( T OBJ::*ptr )
+	{
+		return ( ( size_t )&( ( (OBJ*)0 )->*ptr ) );
+	}
+
+	template <typename T, typename U>
+	constexpr T narrow_cast( const U& a )
+	{
+		return static_cast<T>( a & T( -1 ) );
+	}
+
+} // namespace nv
+
+static_assert( sizeof( nv::sint8 ) == 1, "sint8 size isn't 1 bytes" );
+static_assert( sizeof( nv::sint16 ) == 2, "sint16 size isn't 2 bytes" );
+static_assert( sizeof( nv::sint32 ) == 4, "sint32 size isn't 4 bytes" );
+static_assert( sizeof( nv::sint64 ) == 8, "sint64 size isn't 8 bytes" );
+
+static_assert( sizeof( nv::uint8 ) == 1, "uint8 size isn't 1 byte" );
+static_assert( sizeof( nv::uint16 ) == 2, "uint16 size isn't 2 bytes" );
+static_assert( sizeof( nv::uint32 ) == 4, "uint32 size isn't 4 bytes" );
+static_assert( sizeof( nv::uint64 ) == 8, "uint64 size isn't 8 bytes" );
+
+static_assert( sizeof( nv::f32 ) == 4, "float32 size isn't 4 bytes" );
+static_assert( sizeof( nv::f64 ) == 8, "float64 size isn't 8 bytes" );
+
+#include <nv/base/assert.hh>
+#include <nv/base/rtti_support.hh>
+#include <nv/base/new.hh>
+#include <nv/base/capi.hh>
+
+#endif // NV_BASE_COMMON_HH
+
Index: trunk/nv/base/config.hh
===================================================================
--- trunk/nv/base/config.hh	(revision 396)
+++ trunk/nv/base/config.hh	(revision 396)
@@ -0,0 +1,14 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+#ifndef NV_BASE_CONFIG_HH
+#define NV_BASE_CONFIG_HH
+
+#define NV_LIB_STATIC  1
+#define NV_LIB_SHARED  2
+#define NV_LIB_DYNAMIC 3
+
+#endif // NV_BASE_CONFIG_HH
Index: trunk/nv/base/new.hh
===================================================================
--- trunk/nv/base/new.hh	(revision 396)
+++ trunk/nv/base/new.hh	(revision 396)
@@ -0,0 +1,27 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+//
+// The purpose of this header is to define placement new if it's already 
+// not defined.
+
+#ifndef NV_BASE_NEW_HH
+#define NV_BASE_NEW_HH
+
+#ifdef _MSC_VER
+#ifndef __PLACEMENT_NEW_INLINE
+#define __PLACEMENT_NEW_INLINE
+inline void* __cdecl operator new( size_t, void* ptr ) throw( )
+{
+	return ptr;
+}
+
+inline void __cdecl operator delete( void*, void* ) throw( )
+{
+}
+#endif
+#endif
+
+#endif // NV_BASE_NEW_HH
Index: trunk/nv/base/rtti_support.hh
===================================================================
--- trunk/nv/base/rtti_support.hh	(revision 396)
+++ trunk/nv/base/rtti_support.hh	(revision 396)
@@ -0,0 +1,80 @@
+// Copyright (C) 2015 ChaosForge Ltd
+// http://chaosforge.org/
+//
+// This file is part of Nova libraries. 
+// For conditions of distribution and use, see copying.txt file in root folder.
+
+/**
+ * @file rtti_support.hh
+ * @author Kornel Kisielewicz
+ * @brief RTTI emulation
+ * 
+ * This is the minimal support header for our rtti to work.
+ * TODO: not thread safe - once constexpr works move to runtime hash!
+ */
+
+#ifndef NV_BASE_RTTI_SUPPORT_HH
+#define NV_BASE_RTTI_SUPPORT_HH
+
+#define NV_RTTI_DECLARE(T) \
+namespace nv { \
+template<> struct rtti_type_hash< T > { \
+	static const char* name() { return #T; } \
+	static nv::uint64 hash() { \
+NV_MSVC_SUPRESS( 4307 )\
+		static const nv::uint64 value = nv::rtti_const_hash(#T); \
+		return value; \
+	} \
+};} \
+
+#define NV_RTTI_DECLARE_NAME(T,NAME) \
+namespace nv { \
+template<> struct rtti_type_hash< T > { \
+	static const char* name() { return NAME; } \
+	static nv::uint64 hash() { \
+NV_MSVC_SUPRESS( 4307 )\
+		static const nv::uint64 value = nv::rtti_const_hash(#T); \
+		return value; \
+				} \
+};} \
+
+namespace nv
+{
+
+	namespace detail
+	{
+		static constexpr unsigned long long rtti_hash_basis = 14695981039346656037ULL;
+		static constexpr unsigned long long rtti_hash_prime = 1099511628211ULL;
+
+ 		constexpr uint64 rtti_hash_impl( char c, const char* remain, uint64 value )
+ 		{
+ 			return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, (uint64)(uint64)( value ^ (uint64)c ) * rtti_hash_prime );
+ 		}
+
+		template < typename T >	struct rtti_type_fail { static const bool value = false; };
+	}
+
+ 	// compile-time hash
+ 	constexpr uint64 rtti_const_hash( const char* str )
+ 	{
+ 		return detail::rtti_hash_impl( str[0], str + 1, detail::rtti_hash_basis );
+ 	}
+
+	template < typename T >
+	struct rtti_type_hash
+	{
+		static uint64 hash()
+		{
+			static_assert( NV_TYPE_FAIL(T), "Type not registered!" );
+			return 0;
+		}
+		static const char* name()
+		{
+			static_assert( NV_TYPE_FAIL( T ), "Type not registered!" );
+			return nullptr;
+		}
+	};
+
+}
+
+#endif // NV_BASE_RTTI_SUPPORT_HH
Index: trunk/nv/common.hh
===================================================================
--- trunk/nv/common.hh	(revision 395)
+++ trunk/nv/common.hh	(revision 396)
@@ -8,5 +8,5 @@
 #define NV_COMMON_HH
 
-#include <nv/core/common.hh>
+#include <nv/base/common.hh>
 
 #endif NV_COMMON_HH
Index: trunk/nv/core/common.hh
===================================================================
--- trunk/nv/core/common.hh	(revision 395)
+++ 	(revision )
@@ -1,274 +1,0 @@
-// Copyright (C) 2012-2015 ChaosForge Ltd
-// http://chaosforge.org/
-//
-// This file is part of Nova libraries. 
-// For conditions of distribution and use, see copying.txt file in root folder.
-
-#ifndef NV_BASE_COMMON_HH
-#define NV_BASE_COMMON_HH
-
-#define _ITERATOR_DEBUG_LEVEL 0
-
-// NV Library version
-#define NV_VERSION_MAJOR 0
-#define NV_VERSION_MINOR 1
-#define NV_VERSION_PATCH 0
-#define NV_VERSION    (NV_VERSION_MAJOR << 16) | (NV_VERSION_MINOR << 8) | NV_VERSION_PATCH)
-
-// Platform
-#define NV_WINDOWS        1
-#define NV_LINUX          2
-#define NV_APPLE          3
-
-// Compiler
-#define NV_MSVC           1
-#define NV_GNUC           2
-#define NV_CLANG          3
-
-// Endianess
-#define NV_LITTLEENDIAN   1
-#define NV_BIGENDIAN      2
-
-// Bits
-#define NV_32BIT          1
-#define NV_64BIT          2
-
-// Assumption
-#define NV_ENDIANESS NV_LITTLEENDIAN
-
-// Platform detection
-#if defined( __WIN32__ ) || defined( _WIN32 )
-#define NV_PLATFORM NV_WINDOWS
-#elif defined( __APPLE_CC__)
-#define NV_PLATFORM NV_APPLE
-#else
-#define NV_PLATFORM NV_LINUX
-#endif
-
-// Compiler detection
-#if defined( _MSC_VER )
-#define NV_COMPILER NV_MSVC
-#define NV_COMP_VER _MSC_VER
-#elif defined( __clang__ )
-#define NV_COMPILER NV_CLANG
-#define NV_COMP_VER (((__clang_major__)*100) + (__clang_minor__*10) + __clang_patchlevel__)
-#elif defined( __GNUC__ )
-#define NV_COMPILER NV_GNUC
-#define NV_COMP_VER (((__GNUC__)*100) + (__GNUC_MINOR__*10) + __GNUC_PATCHLEVEL__)
-#else
-#error "Unknown compiler!"
-#endif
-
-// Architecture detection
-#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__)
-#define NV_ARCHITECTURE NV_64BIT
-#elif defined(__ia64__) || defined(__s390__) || defined(__s390x__)
-#define NV_ARCHITECTURE NV_64BIT
-#else
-#define NV_ARCHITECTURE NV_32BIT
-#endif
-
-// Platform specific settings.
-#if NV_COMPILER == NV_MSVC
-#ifdef _DEBUG
-#define NV_DEBUG 1
-#else
-#define NV_DEBUG 0
-#endif
-#else
-#ifdef NDEBUG
-#define NV_DEBUG 0
-#else
-#define NV_DEBUG 1
-#endif
-#endif
-
-#if NV_DEBUG
-#ifndef NV_PROFILER
-#define NV_PROFILER 
-#endif
-#endif
-
-#ifdef NV_PROFILER
-#undef NV_PROFILER
-#define NV_PROFILER 1
-#else
-#define NV_PROFILER 0
-#endif
-
-#if NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
-#define NV_POSIX
-#endif
-
-#if NV_COMPILER == NV_MSVC && NV_COMP_VER < 1900
-#error "MSVC 2015+ required!"
-#endif
-
-#if NV_COMPILER == NV_GNUC && NV_COMP_VER < 480
-#error "GCC 4.8+ required!"
-#endif
-
-#if NV_COMPILER == NV_CLANG && NV_COMP_VER < 330
-#error "clang 3.3+ required!"
-#endif
-
-#if NV_COMPILER == NV_MSVC 
-#pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
-#pragma warning( disable : 4510 ) // default constructor could not be generated
-#pragma warning( disable : 4610 ) // object 'class' can never be instantiated - user-defined constructor required
-#undef _SCL_SECURE_NO_WARNINGS // to prevent redefining
-#define _SCL_SECURE_NO_WARNINGS
-#endif
-
-#define NV_STRINGIZE_DETAIL(x) #x
-#define NV_STRINGIZE(x) NV_STRINGIZE_DETAIL(x)
-
-#if NV_COMPILER == NV_MSVC
-#define NV_WIDE_DETAIL(x) L ## x
-#define NV_WIDE(x) NV_WIDE_DETAIL(x)
-#endif
-
-#if NV_COMPILER == NV_MSVC
-#define NV_DEPRECATED(func) __declspec(deprecated) func
-#define NV_ALIGN(value) __declspec(align(value))
-#define NV_ALIGNED_STRUCT(value) __declspec(align(value)) struct
-#define NV_NOALIAS __declspec(noalias)
-#define NV_RESTRICT __declspec(restrict)
-#define NV_RESTRICT_VAR __restrict
-#if NV_ARCHITECTURE == NV_64BIT
-#define NV_OFFSET_OF(obj,m) (nv::size_t)( (nv::ptrdiff_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) )
-#else // NV_32BIT
-#define NV_OFFSET_OF(obj,m) (nv::size_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m))
-#define NV_MSVC_SUPRESS( warn_number ) __pragma( warning( suppress : warn_number ) )
-#endif  
-#elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG
-#define NV_DEPRECATED(func) func __attribute__ ((deprecated))
-#define NV_ALIGN(value) __attribute__((aligned(value)))
-#define NV_ALIGNED_STRUCT(value) struct __attribute__((aligned(value)))
-#define NV_RESTRICT __restrict__
-#define NV_RESTRICT_VAR __restrict__
-#define NV_OFFSET_OF(obj, m) __builtin_offsetof(obj, m)
-#define NV_MSVC_SUPRESS( warn_number ) 
-#else
-#error "Unknown compiler, cannot proceed!"
-#endif 
-
-#define NV_UNUSED(x) (void)(x)
-#define NV_THROW(eobj, ...) { \
-	NV_LOG_ERROR( __FILE__ " line " NV_STRINGIZE(__LINE__) " - exception thrown - " #eobj ); \
-	throw eobj( __VA_ARGS__ ); \
-} 
-
-// MSVC and GCC is too stupid to notice fully covered enums, clang 
-// is picky about it
-#if NV_COMPILER == NV_CLANG
-#define NV_RETURN_COVERED_DEFAULT( value ) 
-#else
-#define NV_RETURN_COVERED_DEFAULT( value ) default : return value
-#endif
-
-#define NV_COUNT_OF(x) ((sizeof(x)/sizeof(0[x])) / ((nv::size_t)(!(sizeof(x) % sizeof(0[x])))))
-#define NV_SAFE_ARRAY( arr, idx, def ) ( index < NV_COUNT_OF(arr) ? (arr)[idx] : (def) )
-
-#define NV_TYPE_FAIL(T) (nv::static_assert_fail<T>::value)
-#define NV_TEMPLATE_FAIL(T,message) static_assert( NV_TYPE_FAIL(T), message );
-
-namespace nv
-{
-	template < typename T >
-	struct static_assert_fail
-	{
-		static constexpr bool value = false;
-	};
-
-#if NV_COMPILER == NV_MSVC 
-	using ::size_t;
-#else
-	using size_t    = decltype( 0 );
-#endif
-	using ptrdiff_t = decltype((int*)0 - (int*)0);
-	using nullptr_t = decltype( nullptr );
-	
-#if NV_ARCHITECTURE == NV_64BIT
-	using uintptr_t = unsigned long long;
-#else
-	using uintptr_t = unsigned int;
-#endif
-
-	// Typedefs for fixed size types.
-	typedef signed   char      sint8;
-	typedef signed   short     sint16;
-	typedef signed   int       sint32;
-
-	typedef unsigned char      uint8;
-	typedef unsigned short     uint16;
-	typedef unsigned int       uint32;
-
-	typedef signed   long long sint64;
-	typedef unsigned long long uint64;
-
-	typedef unsigned char      uchar8;
-	typedef unsigned short     uchar16;
-	typedef unsigned int       uchar32;
-
-	typedef signed char        schar8;
-	typedef signed short       schar16;
-	typedef signed long        schar32;
-
-	typedef float              f32;
-	typedef double             f64;
-
-	typedef uint64             uid;
-
-	struct empty_type {};
-
-	template < typename T >
-	class empty_base_class {};
-
-	template < int a, int b, int c, int d >
-	struct four_cc
-	{
-		static constexpr unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
-	};
-
-	class noncopyable
-	{
-	protected:
-		constexpr noncopyable() = default;
-		~noncopyable() = default;
-		noncopyable( const noncopyable& ) = delete;
-		noncopyable& operator=( const noncopyable& ) = delete;
-	};
-
-	template <typename OBJ, typename T>
-	inline size_t offset_of( T OBJ::*ptr )
-	{
-		return ( ( size_t )&( ( (OBJ*)0 )->*ptr ) );
-	}
-
-	template <typename T, typename U>
-	constexpr T narrow_cast( const U& a )
-	{
-		return static_cast<T>( a & T( -1 ) );
-	}
-
-} // namespace nv
-
-static_assert( sizeof( nv::sint8 ) == 1, "sint8 size isn't 1 bytes" );
-static_assert( sizeof( nv::sint16 ) == 2, "sint16 size isn't 2 bytes" );
-static_assert( sizeof( nv::sint32 ) == 4, "sint32 size isn't 4 bytes" );
-static_assert( sizeof( nv::sint64 ) == 8, "sint64 size isn't 8 bytes" );
-
-static_assert( sizeof( nv::uint8 ) == 1, "uint8 size isn't 1 byte" );
-static_assert( sizeof( nv::uint16 ) == 2, "uint16 size isn't 2 bytes" );
-static_assert( sizeof( nv::uint32 ) == 4, "uint32 size isn't 4 bytes" );
-static_assert( sizeof( nv::uint64 ) == 8, "uint64 size isn't 8 bytes" );
-
-static_assert( sizeof( nv::f32 ) == 4, "float32 size isn't 4 bytes" );
-static_assert( sizeof( nv::f64 ) == 8, "float64 size isn't 8 bytes" );
-
-#include <nv/stl/assert.hh>
-#include <nv/stl/rtti_support.hh>
-
-#endif // NV_BASE_COMMON_HH
-
Index: trunk/nv/core/config.hh
===================================================================
--- trunk/nv/core/config.hh	(revision 395)
+++ 	(revision )
@@ -1,14 +1,0 @@
-// Copyright (C) 2015 ChaosForge Ltd
-// http://chaosforge.org/
-//
-// This file is part of Nova libraries. 
-// For conditions of distribution and use, see copying.txt file in root folder.
-
-#ifndef NV_BASE_CONFIG_HH
-#define NV_BASE_CONFIG_HH
-
-#define NV_LIB_STATIC  1
-#define NV_LIB_SHARED  2
-#define NV_LIB_DYNAMIC 3
-
-#endif // NV_BASE_CONFIG_HH
Index: trunk/nv/core/logging.hh
===================================================================
--- trunk/nv/core/logging.hh	(revision 395)
+++ trunk/nv/core/logging.hh	(revision 396)
@@ -15,5 +15,5 @@
 
 #include <nv/common.hh>
-#include <nv/stl/capi.hh>
+#include <nv/base/capi.hh>
 #include <nv/stl/string.hh>
 #include <nv/stl/singleton.hh>
Index: trunk/nv/lua/lua_path.hh
===================================================================
--- trunk/nv/lua/lua_path.hh	(revision 395)
+++ trunk/nv/lua/lua_path.hh	(revision 396)
@@ -17,5 +17,4 @@
 #include <nv/stl/string.hh>
 #include <nv/stl/utility.hh>
-#include <nv/stl/capi.hh>
 
 struct lua_State;
Index: trunk/nv/stl/algorithm/raw.hh
===================================================================
--- trunk/nv/stl/algorithm/raw.hh	(revision 395)
+++ trunk/nv/stl/algorithm/raw.hh	(revision 396)
@@ -15,5 +15,5 @@
 
 #include <nv/stl/algorithm/common.hh>
-#include <nv/stl/capi.hh>
+#include <nv/base/capi.hh>
 
 namespace nv
Index: trunk/nv/stl/assert.hh
===================================================================
--- trunk/nv/stl/assert.hh	(revision 395)
+++ 	(revision )
@@ -1,47 +1,0 @@
-// Copyright (C) 2015 ChaosForge Ltd
-// http://chaosforge.org/
-//
-// This file is part of Nova libraries. 
-// For conditions of distribution and use, see copying.txt file in root folder.
-
-/**
- * @file assert.hh
- * @author Kornel Kisielewicz
- * @brief Assert functions
- */
-
-#ifndef NV_BASE_COMMON_HH
-#error "Do not include assert.hh directly, inlcude nv/common.hh"
-#endif
-
-#ifndef NV_BASE_ASSERT_HH
-#define NV_BASE_ASSERT_HH
-
-#ifdef NV_INTERNAL_INCLUDE
-#undef NV_BASE_COMMON_HH
-#include <nv/core/common.hh>
-#endif
-
-#if NV_COMPILER == NV_MSVC
-void nv_internal_assert( const wchar_t * message, const wchar_t* file, unsigned line );
-#	if NV_DEBUG
-#	define NV_ASSERT_IMPL(cond) (void)( (!!(cond)) || (nv_internal_assert(NV_WIDE(#cond), NV_WIDE(__FILE__), __LINE__), 0) )
-#	else
-#	define NV_ASSERT_IMPL(cond) 
-#	endif
-#else
-void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function );
-#	if NV_DEBUG
-#	define NV_ASSERT_IMPL(cond) ((cond) ? static_cast<void>(0) : nv_internal_assert(NV_STRINGIZE(cond), __FILE__, __LINE__, __PRETTY_FUNCTION__))
-#	else
-#	define NV_ASSERT_IMPL(cond) 
-#	endif
-#endif
-
-#if NV_DEBUG
-#define NV_ASSERT(cond, msg) NV_ASSERT_IMPL( (cond) && "assertion failed:" msg )
-#else  
-#define NV_ASSERT(cond, msg)     ((void)0)
-#endif 
-
-#endif // NV_BASE_ASSERT_HH
Index: trunk/nv/stl/capi.hh
===================================================================
--- trunk/nv/stl/capi.hh	(revision 395)
+++ 	(revision )
@@ -1,122 +1,0 @@
-// Copyright (C) 2015 ChaosForge Ltd
-// http://chaosforge.org/
-//
-// This file is part of Nova libraries. 
-// For conditions of distribution and use, see copying.txt file in root folder.
-
-/**
- * @file capi.hh
- * @author Kornel Kisielewicz
- * @brief C API functions
- *
- * This header is temporary
- */
-
-#ifndef NV_BASE_CAPI_HH
-#define NV_BASE_CAPI_HH
-
-#include <nv/common.hh>
-
-namespace nv
-{
-
-	namespace detail
-	{
-
-#if NV_COMPILER == NV_MSVC
-#define NV_CAPI_CALL(name) detail::name
-		extern "C" {
-			NV_NOALIAS NV_RESTRICT void * __cdecl calloc( size_t _Count, size_t _Size );
-			NV_NOALIAS             void   __cdecl free( void * _Memory );
-			NV_NOALIAS NV_RESTRICT void * __cdecl malloc( size_t );
-			NV_NOALIAS NV_RESTRICT void * __cdecl realloc( void * _Memory, size_t _NewSize );
-			void *  __cdecl memcpy( void * _Dst, const void * _Src, size_t _Size );
-			void *  __cdecl memmove( void * _Dst, const void * _Src, size_t _Size );
-			void *  __cdecl memset( void * _Dst, int _Val, size_t _Size );
-			void *  __cdecl memchr( const void * _Buf, int _Val, size_t _MaxCount );
-			int     __cdecl memcmp( const void * _Buf1, const void * _Buf2, size_t _Size );
-			int     __cdecl strcmp( const char * _Str1, const char * _Str2 );
-			int     __cdecl strncmp( const char * _Str1, const char * _Str2, size_t _MaxCount );
-			size_t  __cdecl strlen( const char * _Str );
-		}
-#endif 
-		// TODO: remove when clang 3.5 will be used (with builtins)
-#if NV_COMPILER == NV_CLANG || NV_COMPILER == NV_GNUC
-#define NV_CAPI_CALL(name) detail::name
-		extern "C" {
-			extern void * __cdecl calloc( nv::size_t, nv::size_t );
-			extern void   __cdecl free( void * );
-			extern void * __cdecl malloc( nv::size_t );
-			extern void * __cdecl realloc( void * , nv::size_t );
-			extern void * __cdecl memcpy( void * , const void * , nv::size_t );
-			extern void * __cdecl memmove( void * , const void * , nv::size_t );
-			extern void * __cdecl memset( void * , int , nv::size_t );
-			extern void * __cdecl memchr( const void * , int , nv::size_t );
-			extern int    __cdecl memcmp( const void * , const void * , nv::size_t  );
-			extern int    __cdecl strcmp ( const char * , const char * );
-			extern int    __cdecl strncmp( const char * , const char * , size_t );
-			extern nv::size_t __cdecl strlen ( const char * );
-		}
-#endif
-	}
-
-	inline void* nvmalloc( size_t size )
-	{
-		return NV_CAPI_CALL(malloc)( size );
-	}
-	inline void* nvrealloc( void* p, size_t size )
-	{
-		if ( size > 0 ) return NV_CAPI_CALL( realloc )( p, size );
-		NV_CAPI_CALL( free )( p );
-		return nullptr;
-	}
-	inline void nvfree( void* p )
-	{
-		if ( p ) NV_CAPI_CALL( free )( p );
-	}
-
-	inline void* nvmemcpy( void *dest, const void *src, size_t count )
-	{
-		return NV_CAPI_CALL( memcpy )( dest, src, count );
-	}
-
-	inline void* nvmemmove( void *dest, const void *src, size_t count )
-	{
-		return NV_CAPI_CALL( memmove )( dest, src, count );
-	}
-
-	inline void* nvmemset( void *dest, unsigned char value, size_t count )
-	{
-		return NV_CAPI_CALL( memset )( dest, (int)value, count );
-	}
-
-	inline void* nvmemchr( const void *src, unsigned char value, size_t max_count )
-	{
-		return NV_CAPI_CALL( memchr )( src, (int)value, max_count );
-	}
-
-	inline int nvmemcmp( const void * m1, const void * m2, nv::size_t max_count )
-	{
-		return NV_CAPI_CALL( memcmp )( m1, m2, max_count );
-	}
-
-	inline int nvstrcmp( const char * s1, const char * s2 )
-	{
-		return NV_CAPI_CALL( strcmp )( s1, s2 );
-	}	
-
-	inline int nvstrncmp( const char * s1, const char * s2, size_t max_count )
-	{
-		return NV_CAPI_CALL( strncmp )( s1, s2, max_count );
-	}
-
-	inline nv::size_t nvstrlen( const char * s )
-	{
-		return NV_CAPI_CALL( strlen )( s );
-	}
-
-}
-
-#undef NV_CAPI_CALL
-
-#endif // NV_BASE_CAPI_HH
Index: trunk/nv/stl/container/contiguous_storage.hh
===================================================================
--- trunk/nv/stl/container/contiguous_storage.hh	(revision 395)
+++ trunk/nv/stl/container/contiguous_storage.hh	(revision 396)
@@ -16,5 +16,5 @@
 #include <nv/common.hh>
 #include <nv/stl/type_traits/alignment.hh>
-#include <nv/stl/capi.hh>
+#include <nv/base/capi.hh>
 
 namespace nv
Index: trunk/nv/stl/cstring_store.hh
===================================================================
--- trunk/nv/stl/cstring_store.hh	(revision 395)
+++ trunk/nv/stl/cstring_store.hh	(revision 396)
@@ -17,5 +17,4 @@
 #include <nv/stl/unordered_map.hh>
 #include <nv/stl/array.hh>
-#include <nv/stl/capi.hh>
 
 namespace nv
Index: trunk/nv/stl/memory.hh
===================================================================
--- trunk/nv/stl/memory.hh	(revision 395)
+++ trunk/nv/stl/memory.hh	(revision 396)
@@ -17,10 +17,8 @@
 
 #include <nv/common.hh>
-#include <nv/stl/new.hh>
 #include <nv/stl/type_traits/properties.hh>
 #include <nv/stl/type_traits/alignment.hh>
 #include <nv/stl/utility.hh>
 #include <nv/stl/iterator.hh>
-#include <nv/stl/capi.hh>
 
 namespace nv
Index: trunk/nv/stl/rtti_support.hh
===================================================================
--- trunk/nv/stl/rtti_support.hh	(revision 395)
+++ 	(revision )
@@ -1,80 +1,0 @@
-// Copyright (C) 2015 ChaosForge Ltd
-// http://chaosforge.org/
-//
-// This file is part of Nova libraries. 
-// For conditions of distribution and use, see copying.txt file in root folder.
-
-/**
- * @file rtti_support.hh
- * @author Kornel Kisielewicz
- * @brief RTTI emulation
- * 
- * This is the minimal support header for our rtti to work.
- * TODO: not thread safe - once constexpr works move to runtime hash!
- */
-
-#ifndef NV_BASE_RTTI_SUPPORT_HH
-#define NV_BASE_RTTI_SUPPORT_HH
-
-#define NV_RTTI_DECLARE(T) \
-namespace nv { \
-template<> struct rtti_type_hash< T > { \
-	static const char* name() { return #T; } \
-	static nv::uint64 hash() { \
-NV_MSVC_SUPRESS( 4307 )\
-		static const nv::uint64 value = nv::rtti_const_hash(#T); \
-		return value; \
-	} \
-};} \
-
-#define NV_RTTI_DECLARE_NAME(T,NAME) \
-namespace nv { \
-template<> struct rtti_type_hash< T > { \
-	static const char* name() { return NAME; } \
-	static nv::uint64 hash() { \
-NV_MSVC_SUPRESS( 4307 )\
-		static const nv::uint64 value = nv::rtti_const_hash(#T); \
-		return value; \
-				} \
-};} \
-
-namespace nv
-{
-
-	namespace detail
-	{
-		static constexpr unsigned long long rtti_hash_basis = 14695981039346656037ULL;
-		static constexpr unsigned long long rtti_hash_prime = 1099511628211ULL;
-
- 		constexpr uint64 rtti_hash_impl( char c, const char* remain, uint64 value )
- 		{
- 			return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, (uint64)(uint64)( value ^ (uint64)c ) * rtti_hash_prime );
- 		}
-
-		template < typename T >	struct rtti_type_fail { static const bool value = false; };
-	}
-
- 	// compile-time hash
- 	constexpr uint64 rtti_const_hash( const char* str )
- 	{
- 		return detail::rtti_hash_impl( str[0], str + 1, detail::rtti_hash_basis );
- 	}
-
-	template < typename T >
-	struct rtti_type_hash
-	{
-		static uint64 hash()
-		{
-			static_assert( NV_TYPE_FAIL(T), "Type not registered!" );
-			return 0;
-		}
-		static const char* name()
-		{
-			static_assert( NV_TYPE_FAIL( T ), "Type not registered!" );
-			return nullptr;
-		}
-	};
-
-}
-
-#endif // NV_BASE_RTTI_SUPPORT_HH
Index: trunk/src/stl/assert.cc
===================================================================
--- trunk/src/stl/assert.cc	(revision 395)
+++ trunk/src/stl/assert.cc	(revision 396)
@@ -7,5 +7,5 @@
 #define NV_BASE_COMMON_HH
 #define NV_INTERNAL_INCLUDE
-#include "nv/stl/assert.hh"
+#include "nv/base/assert.hh"
 #undef NV_BASE_COMMON_HH
 
Index: trunk/src/stl/capi.cc
===================================================================
--- trunk/src/stl/capi.cc	(revision 395)
+++ trunk/src/stl/capi.cc	(revision 396)
@@ -5,3 +5,3 @@
 // For conditions of distribution and use, see copying.txt file in root folder.
 
-#include "nv/stl/capi.hh"
+#include "nv/base/capi.hh"
