Przeglądaj źródła

Merge branch 'master' of github.com:bkaradzic/bx

bkaradzic 12 lat temu
rodzic
commit
7e0058ab6d
4 zmienionych plików z 48 dodań i 17 usunięć
  1. 25 3
      include/bx/macros.h
  2. 7 10
      include/bx/platform.h
  3. 12 3
      include/bx/spscqueue.h
  4. 4 1
      include/bx/thread.h

+ 25 - 3
include/bx/macros.h

@@ -100,9 +100,31 @@
 #	define BX_UNUSED(...) BX_MACRO_DISPATCHER(BX_UNUSED_, __VA_ARGS__)(__VA_ARGS__)
 #	define BX_UNUSED(...) BX_MACRO_DISPATCHER(BX_UNUSED_, __VA_ARGS__)(__VA_ARGS__)
 #endif // BX_COMPILER_MSVC
 #endif // BX_COMPILER_MSVC
 
 
-#define BX_CLASS_NO_COPY_NO_ASSIGNMENT(_class) \
-			_class(const _class&); \
-			_class& operator=(const _class&)
+#define BX_CLASS_NO_DEFAULT_CTOR(_class) \
+			private: _class()
+
+#define BX_CLASS_NO_COPY(_class) \
+			private: _class(const _class& _rhs)
+
+#define BX_CLASS_NO_ASSIGNMENT(_class) \
+			private: _class& operator=(const _class& _rhs)
+
+#define BX_CLASS_ALLOCATOR(_class) \
+			public: void* operator new(size_t _size); \
+			public: void  operator delete(void* _ptr); \
+			public: void* operator new[](size_t _size); \
+			public: void  operator delete[](void* _ptr)
+
+#define BX_CLASS_1(_class, _a1) BX_CONCATENATE(BX_CLASS_, _a1)(_class)
+#define BX_CLASS_2(_class, _a1, _a2) BX_CLASS_1(_class, _a1); BX_CLASS_1(_class, _a2)
+#define BX_CLASS_3(_class, _a1, _a2, _a3) BX_CLASS_2(_class, _a1, _a2); BX_CLASS_1(_class, _a3)
+#define BX_CLASS_4(_class, _a1, _a2, _a3, _a4) BX_CLASS_3(_class, _a1, _a2, _a3); BX_CLASS_1(_class, _a4)
+
+#if BX_COMPILER_MSVC
+#	define BX_CLASS(_class, ...) BX_MACRO_DISPATCHER(BX_CLASS_, __VA_ARGS__) BX_VA_ARGS_PASS(_class, __VA_ARGS__)
+#else
+#	define BX_CLASS(_class, ...) BX_MACRO_DISPATCHER(BX_CLASS_, __VA_ARGS__)(_class, __VA_ARGS__)
+#endif // BX_COMPILER_MSVC
 
 
 #ifndef BX_CHECK
 #ifndef BX_CHECK
 #	define BX_CHECK(_condition, ...) do {} while(0)
 #	define BX_CHECK(_condition, ...) do {} while(0)

+ 7 - 10
include/bx/platform.h

@@ -51,7 +51,13 @@
 #	define BX_PLATFORM_XBOX360 1
 #	define BX_PLATFORM_XBOX360 1
 #elif defined(_WIN32) || defined(_WIN64)
 #elif defined(_WIN32) || defined(_WIN64)
 #	undef BX_PLATFORM_WINDOWS
 #	undef BX_PLATFORM_WINDOWS
-#	define BX_PLATFORM_WINDOWS 1
+// http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
+#	if !defined(WINVER) && !defined(_WIN32_WINNT)
+// Windows Server 2003 with SP1, Windows XP with SP2 and above
+#		define WINVER 0x0502
+#		define _WIN32_WINNT 0x0502
+#	endif // !defined(WINVER) && !defined(_WIN32_WINNT)
+#	define BX_PLATFORM_WINDOWS _WIN32_WINNT
 #elif defined(__native_client__)
 #elif defined(__native_client__)
 // NaCl compiler defines __linux__
 // NaCl compiler defines __linux__
 #	undef BX_PLATFORM_NACL
 #	undef BX_PLATFORM_NACL
@@ -145,13 +151,4 @@
 typedef struct { long double x, y; } __float128;
 typedef struct { long double x, y; } __float128;
 #endif // BX_COMPILER_CLANG && BX_PLATFORM_LINUX
 #endif // BX_COMPILER_CLANG && BX_PLATFORM_LINUX
 
 
-#if BX_PLATFORM_WINDOWS
-// http://msdn.microsoft.com/en-us/library/6sehtctf.aspx
-#	if !defined(WINVER) && !defined(_WIN32_WINNT)
-		// Windows Server 2003 with SP1, Windows XP with SP2 and above
-#		define WINVER 0x0502
-#		define _WIN32_WINNT 0x0502
-#	endif // !defined(WINVER) && !defined(_WIN32_WINNT)
-#endif // BX_PLATFORM_WINDOWS
-
 #endif // __BX_PLATFORM_H__
 #endif // __BX_PLATFORM_H__

+ 12 - 3
include/bx/spscqueue.h

@@ -19,7 +19,10 @@ namespace bx
 	template <typename Ty>
 	template <typename Ty>
 	class SpScUnboundedQueueLf
 	class SpScUnboundedQueueLf
 	{
 	{
-		BX_CLASS_NO_COPY_NO_ASSIGNMENT(SpScUnboundedQueueLf);
+		BX_CLASS(SpScUnboundedQueueLf
+			, NO_COPY
+			, NO_ASSIGNMENT
+			);
 
 
 	public:
 	public:
 		SpScUnboundedQueueLf()
 		SpScUnboundedQueueLf()
@@ -95,7 +98,10 @@ namespace bx
 	template<typename Ty>
 	template<typename Ty>
 	class SpScUnboundedQueueMutex
 	class SpScUnboundedQueueMutex
 	{
 	{
-		BX_CLASS_NO_COPY_NO_ASSIGNMENT(SpScUnboundedQueueMutex);
+		BX_CLASS(SpScUnboundedQueueMutex
+			, NO_COPY
+			, NO_ASSIGNMENT
+			);
 
 
 	public:
 	public:
 		SpScUnboundedQueueMutex()
 		SpScUnboundedQueueMutex()
@@ -151,7 +157,10 @@ namespace bx
 	template <typename Ty>
 	template <typename Ty>
 	class SpScBlockingUnboundedQueue
 	class SpScBlockingUnboundedQueue
 	{
 	{
-		BX_CLASS_NO_COPY_NO_ASSIGNMENT(SpScBlockingUnboundedQueue);
+		BX_CLASS(SpScBlockingUnboundedQueue
+			, NO_COPY
+			, NO_ASSIGNMENT
+			);
 
 
 	public:
 	public:
 		SpScBlockingUnboundedQueue()
 		SpScBlockingUnboundedQueue()

+ 4 - 1
include/bx/thread.h

@@ -18,7 +18,10 @@ namespace bx
 
 
 	class Thread
 	class Thread
 	{
 	{
-		BX_CLASS_NO_COPY_NO_ASSIGNMENT(Thread);
+		BX_CLASS(Thread
+			, NO_COPY
+			, NO_ASSIGNMENT
+			);
 
 
 	public:
 	public:
 		Thread()
 		Thread()