Daniele Bartolini 10 лет назад
Родитель
Сommit
0a86d85e12

+ 2 - 3
src/core/containers/array.h

@@ -5,10 +5,9 @@
 
 #pragma once
 
+#include "allocator.h"
 #include "container_types.h"
 #include "error.h"
-#include "macros.h"
-#include "allocator.h"
 #include <string.h> // memcpy
 
 namespace crown
@@ -123,7 +122,7 @@ namespace array
 		{
 			T* tmp = a._data;
 			a._capacity = capacity;
-			a._data = (T*)a._allocator->allocate(capacity * sizeof(T), CE_ALIGNOF(T));
+			a._data = (T*)a._allocator->allocate(capacity * sizeof(T), alignof(T));
 
 			memcpy(a._data, tmp, a._size * sizeof(T));
 

+ 2 - 16
src/core/containers/map.h

@@ -83,7 +83,7 @@ namespace map_internal
 		return m._data[n].color;
 	}
 
-	#ifdef RBTREE_VERIFY
+#ifdef RBTREE_VERIFY
 	template<typename TKey, typename TValue>
 	inline s32 dbg_verify(Map<TKey, TValue>& m, u32 n)
 	{
@@ -122,18 +122,7 @@ namespace map_internal
 
 		return bhL;
 	}
-
-	template<typename TKey, typename TValue>
-	inline s32 dump(Map<TKey, TValue>& m)
-	{
-		for (u32 i = 0; i < vector::size(m._data); i++)
-		{
-			printf("%d = [%d, %d, %d] ", i, parent(m, i), left(m, i), right(m, i));
-		}
-		printf("\n");
-		return 0;
-	}
-	#endif
+#endif // RBTREE_VERIFY
 
 	template <typename TKey, typename TValue>
 	inline u32 min(const Map<TKey, TValue>& m, u32 x)
@@ -441,12 +430,9 @@ namespace map_internal
 
 		if (p != m._sentinel && m._data[p].pair.first == key)
 		{
-			printf("Found\n");
 			return p;
 		}
 
-		printf("Not found, adding...\n");
-
 		typename Map<TKey, TValue>::Node n;
 		n.key = key;
 		n.value = TValue();

+ 2 - 3
src/core/containers/vector.h

@@ -5,10 +5,9 @@
 
 #pragma once
 
-#include "container_types.h"
 #include "allocator.h"
+#include "container_types.h"
 #include "error.h"
-#include "macros.h"
 
 namespace crown
 {
@@ -121,7 +120,7 @@ namespace vector
 		{
 			T* tmp = v._data;
 			v._capacity = capacity;
-			v._data = (T*)v._allocator->allocate(capacity * sizeof(T), CE_ALIGNOF(T));
+			v._data = (T*)v._allocator->allocate(capacity * sizeof(T), alignof(T));
 
 			for (u32 i = 0; i < v._size; ++i)
 				new (v._data + i) T(tmp[i]);

+ 2 - 1
src/core/json/json.cpp

@@ -4,9 +4,10 @@
  */
 
 #include "json.h"
+#include "macros.h"
+#include "map.h"
 #include "string_utils.h"
 #include "temp_allocator.h"
-#include "map.h"
 
 namespace crown
 {

+ 3 - 2
src/core/json/sjson.cpp

@@ -3,11 +3,12 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
+#include "macros.h"
+#include "map.h"
+#include "quaternion.h"
 #include "sjson.h"
 #include "string_utils.h"
 #include "temp_allocator.h"
-#include "map.h"
-#include "quaternion.h"
 
 namespace crown
 {

+ 5 - 7
src/core/macros.h

@@ -7,16 +7,14 @@
 
 #include "platform.h"
 
-#ifdef CROWN_COMPILER_MSVC
-	#define CE_ALIGNOF(x) __alignof(x)
-	#define CE_EXPORT __declspec(dllexport)
-	#define CE_INLINE __inline
-	#define CE_THREAD __declspec(thread)
-#elif CROWN_COMPILER_GCC
-	#define CE_ALIGNOF(x) __alignof__(x)
+#if CROWN_COMPILER_GCC
 	#define CE_EXPORT __attribute__ ((visibility("default")))
 	#define CE_INLINE inline
 	#define CE_THREAD __thread
+#elif CROWN_COMPILER_MSVC
+	#define CE_EXPORT __declspec(dllexport)
+	#define CE_INLINE __inline
+	#define CE_THREAD __declspec(thread)
 #else
 	#error "Compiler not supported"
 #endif

+ 1 - 2
src/core/memory/memory.h

@@ -8,7 +8,6 @@
 #include "types.h"
 #include "error.h"
 #include "allocator.h"
-#include "macros.h"
 #include <new>
 
 /// @defgroup Memory Memory
@@ -94,7 +93,7 @@ namespace memory_globals
 /// and calls constructor on it.
 /// @note
 /// @a allocator must be a reference to an existing allocator.
-#define CE_NEW(allocator, T) new ((allocator).allocate(sizeof(T), CE_ALIGNOF(T))) T
+#define CE_NEW(allocator, T) new ((allocator).allocate(sizeof(T), alignof(T))) T
 
 /// Calls destructor on @a ptr and deallocates memory using the
 /// given @a allocator.

+ 6 - 5
src/core/os.h

@@ -5,14 +5,15 @@
 
 #pragma once
 
-#include "platform.h"
-#include "types.h"
-#include "vector.h"
 #include "dynamic_string.h"
-#include "string_utils.h"
 #include "error.h"
-#include "temp_allocator.h"
+#include "macros.h"
+#include "platform.h"
 #include "string_stream.h"
+#include "string_utils.h"
+#include "temp_allocator.h"
+#include "types.h"
+#include "vector.h"
 
 #if CROWN_PLATFORM_POSIX
 	#include <dirent.h> // opendir, readdir

+ 2 - 1
src/input/input_manager.cpp

@@ -3,8 +3,9 @@
  * License: https://github.com/taylor001/crown/blob/master/LICENSE
  */
 
-#include "input_manager.h"
 #include "input_device.h"
+#include "input_manager.h"
+#include "macros.h"
 #include "memory.h"
 
 namespace crown

+ 1 - 0
src/resource/material_resource.cpp

@@ -6,6 +6,7 @@
 #include "compile_options.h"
 #include "dynamic_string.h"
 #include "filesystem.h"
+#include "macros.h"
 #include "map.h"
 #include "material_resource.h"
 #include "reader_writer.h"

+ 1 - 1
src/resource/physics_resource.cpp

@@ -7,7 +7,7 @@
 #include "compile_options.h"
 #include "dynamic_string.h"
 #include "filesystem.h"
-#include "map.h"
+#include "macros.h"
 #include "map.h"
 #include "physics_resource.h"
 #include "quaternion.h"

+ 1 - 0
src/resource/unit_compiler.cpp

@@ -5,6 +5,7 @@
 
 #include "array.h"
 #include "compile_options.h"
+#include "macros.h"
 #include "map.h"
 #include "math_utils.h"
 #include "physics_resource.h"