Kaynağa Gözat

Added debugOutput.

bkaradzic 12 yıl önce
ebeveyn
işleme
24786dd2d0
2 değiştirilmiş dosya ile 25 ekleme ve 0 silme
  1. 20 0
      include/bx/debug.h
  2. 5 0
      include/bx/macros.h

+ 20 - 0
include/bx/debug.h

@@ -8,6 +8,14 @@
 
 
 #include "bx.h"
 #include "bx.h"
 
 
+#if BX_PLATFORM_ANDROID
+#	include <android/log.h>
+#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
+extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str);
+#else
+#	include <stdio.h>
+#endif // BX_PLATFORM_WINDOWS
+
 namespace bx
 namespace bx
 {
 {
 	inline void debugBreak()
 	inline void debugBreak()
@@ -26,6 +34,18 @@ namespace bx
 #endif // BX
 #endif // BX
 	}
 	}
 
 
+	inline void debugOutput(const char* _out)
+	{
+#if BX_PLATFORM_ANDROID
+		__android_log_write(ANDROID_LOG_DEBUG, "", _out);
+#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
+		OutputDebugStringA(_out);
+#else
+		fputs(_out, stderr);
+		fflush(stderr);
+#endif // BX_PLATFORM_
+	}
+
 } // namespace bx
 } // namespace bx
 
 
 #endif // __BX_DEBUG_H__
 #endif // __BX_DEBUG_H__

+ 5 - 0
include/bx/macros.h

@@ -20,6 +20,9 @@
 #define BX_STRINGIZE(_x) BX_STRINGIZE_(_x)
 #define BX_STRINGIZE(_x) BX_STRINGIZE_(_x)
 #define BX_STRINGIZE_(_x) #_x
 #define BX_STRINGIZE_(_x) #_x
 
 
+#define BX_CONCATENATE(_x, _y) BX_CONCATENATE_(_x, _y)
+#define BX_CONCATENATE_(_x, _y) _x ## _y
+
 #define BX_FILE_LINE_LITERAL "" __FILE__ "(" BX_STRINGIZE(__LINE__) "): "
 #define BX_FILE_LINE_LITERAL "" __FILE__ "(" BX_STRINGIZE(__LINE__) "): "
 
 
 #define BX_ALIGN_MASK(_value, _mask) ( ( (_value)+(_mask) ) & ( (~0)&(~(_mask) ) ) )
 #define BX_ALIGN_MASK(_value, _mask) ( ( (_value)+(_mask) ) & ( (~0)&(~(_mask) ) ) )
@@ -37,6 +40,7 @@
 #	define BX_NO_VTABLE
 #	define BX_NO_VTABLE
 #	define BX_OVERRIDE
 #	define BX_OVERRIDE
 #	define BX_PRINTF_ARGS(_format, _args) __attribute__ ( (format(__printf__, _format, _args) ) )
 #	define BX_PRINTF_ARGS(_format, _args) __attribute__ ( (format(__printf__, _format, _args) ) )
+#	define BX_STATIC_ASSERT(_condition, ...) static_assert(_condition, __VA_ARGS__)
 #	if BX_COMPILER_CLANG
 #	if BX_COMPILER_CLANG
 #		define BX_THREAD /* not supported right now */
 #		define BX_THREAD /* not supported right now */
 #	else
 #	else
@@ -52,6 +56,7 @@
 #	define BX_NO_VTABLE __declspec(novtable)
 #	define BX_NO_VTABLE __declspec(novtable)
 #	define BX_OVERRIDE override
 #	define BX_OVERRIDE override
 #	define BX_PRINTF_ARGS(_format, _args)
 #	define BX_PRINTF_ARGS(_format, _args)
+#	define BX_STATIC_ASSERT(_condition, ...) typedef char BX_CONCATENATE(BX_STATIC_ASSERT_, __LINE__)[1][(_condition)]
 #	define BX_THREAD __declspec(thread)
 #	define BX_THREAD __declspec(thread)
 #else
 #else
 #	error "Unknown BX_COMPILER_?"
 #	error "Unknown BX_COMPILER_?"