True Axis Physics SDK 1.2.0.1 Beta Documentation
www.trueaxis.com

Debug.h

00001 //---------------------------------------------------------------------------------
00002 // File Name: Debug.h
00003 // Description:
00004 //
00005 // Copyright (C) 2004 - 2006 True Axis Pty Ltd, Australia. 
00006 // All Rights Reserved.
00007 //
00008 // History:
00009 //      Created File.
00010 //---------------------------------------------------------------------------------
00011 
00012 #ifndef TA_DEBUG_H
00013 #define TA_DEBUG_H
00014 
00015 #ifndef TA_COMMON_H
00016 #include "Common.h"
00017 #endif // TA_COMMON_H
00018 
00019 TA_OBFUSCATION_SKIP_PASS_2
00020 
00021 namespace TA
00022 {
00023 
00024 #define TA_DEBUG_OUTPUT(szString) TA::Debug::Output(szString);
00025 
00026 #ifdef _DEBUG
00027     #ifdef TA_IN_PLACE_ASSERT
00028         #if defined (TA_GCC_X86_INLINE_ASM)
00029             #define TA_ASSERT(x)            \
00030                 do                          \
00031                 {                           \
00032                     if (!(x))               \
00033                     {                       \
00034                         asm("int $3")       \
00035                     }                       \
00036                 } while (0)
00037         #elif defined(TA_MSVC_X86_INLINE_ASM)
00038             #define TA_ASSERT(x)            \
00039                 do                          \
00040                 {                           \
00041                     if (!(x))               \
00042                     {                       \
00043                         __asm { int 3 }     \
00044                     }                       \
00045                 } while (0)
00046         #endif
00047         #define TA_ASSERT_MSG(x, szMsg) TA_ASSERT(x)
00048     #else
00049         #define TA_ASSERT(x) do { if (!(x)) TA::Debug::Assert(__FILE__, __LINE__, #x, 0); } while (0)
00050         #define TA_ASSERT_MSG(x, szMsg) do { if (!(x)) TA::Debug::Assert(__FILE__, __LINE__, #x, szMsg); } while (0)
00051         namespace Debug
00052         {
00053             extern void TAC_CALL Assert(const char* szFile, int nLine, const char* szCondition, const char* szMsg);
00054         }
00055     #endif
00056     #define TA_VERIFY(x) TA_ASSERT(x)
00057     #define TA_NO_DEFAULT TA_ASSERT(0)
00058     #define TA_ASSERT_ASSUME(x) TA_ASSERT(x)
00059     #define TA_ASSERT_ASSUME_MSG(x, szMsg) TA_ASSERT_MSG(x, szMsg)
00060     #define TA_TODO_MSG(szMsg) TA_ASSERT_MSG(0, szMsg)
00061     #ifdef TA_WARNING_AS_ASSERT
00062         #define TA_WARNING_MSG(x, szMsg) TA_ASSERT_MSG(x, szMsg)
00063     #else
00064         #define TA_WARNING_MSG(x, szMsg) do { if (!(x)) TA::Debug::Warning(__FILE__, __LINE__, #x, szMsg); } while (0)
00065         namespace Debug
00066         {
00067             extern void TAC_CALL Warning(const char* szFile, int nLine, const char* szCondition, const char* szMsg);
00068         }
00069     #endif  
00070 #else // _DEBUG
00071     TA_OBFUSCATION_RESERVED_ON
00072     #define TA_ASSERT(x)
00073     #define TA_VERIFY(x) x
00074     TA_OBFUSCATION_RESERVED_OFF
00075     #define TA_ASSERT_MSG(x, szMsg)
00076     #ifdef TA_MSVC
00077         #define TA_NO_DEFAULT __assume(0) // helps optimisation
00078         #define TA_ASSERT_ASSUME(x) __assume(x) // helps optimisation
00079         #define TA_ASSERT_ASSUME_MSG(x, szMsg) __assume(x)
00080     #else
00081         #define TA_NO_DEFAULT
00082         #define TA_ASSERT_ASSUME(x)
00083         #define TA_ASSERT_ASSUME_MSG(x, szMsg)
00084     #endif
00085     #define TA_TODO_MSG(szMsg) TA_ASSERT_MSG(0, szMsg)
00086     #define TA_WARNING_MSG(x, szMsg) TA_ASSERT_MSG(x, szMsg)
00087 #endif // _DEBUG
00088 
00089 #ifdef _DEBUG
00090 TA_OBFUSCATION_RESERVED_ON
00091 namespace Debug
00092 {   
00093     void TAC_CALL OpenOutputFile(const char* szFileName);
00094     void TAC_CALL CloseOutputFile();
00095     void TAC_CALL Output(const char* szText);
00096     void TAC_CALL SetDebugAssertsEnable(bool bEnabled);
00097     void TAC_CALL SetExitWitFailureOnAssert(bool bEnabled); 
00098 TA_OBFUSCATION_RESERVED_OFF
00099 }
00100 #endif // _DEBUG
00101 
00102 }
00103 
00104 #endif // TA_DEBUG_H
00105 


© Copyright 2004-2006 TRUE AXIS PTY LTD Australia. All rights reserved.