#ifndef __DEBUGMACROS__
#define __DEBUGMACROS__
#include <DriverServices.h>
#include <NumberFormatting.h>
#include "OxcartDebug.h"
#undef AssertionFailed
#define BranchIf(condition, label) if((condition)) goto label;
#define AssertionMessage(cond, file, line, handler) \
"\pAssertion \"" #cond "\" failed in " #file " at line " #line " goto " #handler
#define AssertionFailed(cond, file, line, handler) \
OXCART_DEBUGSTR( (StringPtr) AssertionMessage (cond, file, line, handler) );
#define AssertionMessageString(cond, file, line, handler) \
"\pAssertion \"" #cond "\" failed in " #file " at line " #line " goto " #handler " value -> "
#define AssertionFailedString(cond, file, line, handler, str) \
{ \
Str255 mystr21; \
PStrCopy( mystr21, AssertionMessageString (cond, file, line, handler)); \
PStrCat( mystr21, str); \
DebugStr( mystr21); \
}
#ifdef DEBUG
#define FailWithVal(cond, handler, num) \
if (cond) { \
Str255 mystr; \
NumToString( num, mystr); \
AssertionFailedString(cond, __FILE__, __LINE__, handler, mystr) \
goto handler; \
}
#else
#define FailWithVal(cond, handler,num) \
if (cond) { \
goto handler; \
}
#endif DEBUG
#ifdef DEBUG
#define FailWithStringVal(cond, handler, str, num) \
if (cond) { \
Str255 mystr, mystr2; \
NumToString( num, mystr); \
PStrCopy( mystr2, str); \
PStrCat( mystr2, mystr); \
AssertionFailedString(cond, __FILE__, __LINE__, handler, mystr2) \
goto handler; \
}
#else
#define FailWithStringVal(cond, handler, str, num) \
if (cond) { \
goto handler; \
}
#endif DEBUG
#ifdef DEBUG
#define FailWithString(cond, handler, str) \
if (cond) { \
AssertionFailedString(cond, __FILE__, __LINE__, handler, str) \
goto handler; \
}
#else
#define FailWithString(cond, handler, str, num) \
if (cond) { \
goto handler; \
}
#endif DEBUG
#ifdef DEBUG
#define FailIf(cond, handler) \
if (cond) { \
AssertionFailed(cond, __FILE__, __LINE__, handler) \
goto handler; \
}
#else
#define FailIf(cond, handler) \
if (cond) { \
goto handler; \
}
#endif
#ifdef DEBUG
#define FailWithActionVal(cond, action, handler, num) \
if (cond) { \
Str255 mystr; \
NumToString( num, mystr); \
AssertionFailedString(cond, __FILE__, __LINE__, handler, mystr) \
{ action; } \
goto handler; \
}
#else
#define FailWithActionVal(cond, action, handler, num) \
if (cond) { \
{ action; } \
goto handler; \
}
#endif DEBUG
#ifdef DEBUG
#define FailWithAction(cond, action, handler) \
if (cond) { \
AssertionFailed(cond, __FILE__, __LINE__, handler) \
{ action; } \
goto handler; \
}
#else
#define FailWithAction(cond, action, handler) \
if (cond) { \
{ action; } \
goto handler; \
}
#endif
#ifdef DEBUG
#define FailMessage(cond) if (cond) AssertionFailed(cond, __FILE__, __LINE__, handler)
#else
#define FailMessage(cond) {}
#endif
#ifdef DEBUG
#define FailMessageVal(cond, num) \
if (cond) { \
Str255 __mystr; \
NumToString( num, __mystr); \
AssertionFailedString(cond, __FILE__, __LINE__, handler, __mystr) \
}
#else
#define FailMessageVal(cond, num) {}
#endif
#ifdef DEBUG
#define ErrorMessage(cond) if (cond) AssertionFailed(cond, __FILE__, __LINE__, handler)
#else
#define ErrorMessage(cond) (cond)
#endif
#ifdef DEBUG
#define DebugMessage(s) DebugString((ConstStr255Param)s)
#else
#define DebugMessage(s) {}
#endif
#if defined(DEBUG) && defined(DEBUGVERBOSE)
#define FailIfVerbose(cond, handler) \
if (cond) { \
AssertionFailed(cond, __FILE__, __LINE__, handler) \
goto handler; \
}
#else
#define FailIfVerbose(cond, handler) \
if (cond) { \
goto handler; \
}
#endif
#if defined(DEBUG) && defined(DEBUGVERBOSE)
#define FailWithActionVerbose(cond, action, handler) \
if (cond) { \
AssertionFailed(cond, __FILE__, __LINE__, handler) \
{ action; } \
goto handler; \
}
#else
#define FailWithActionVerbose(cond, action, handler) \
if (cond) { \
{ action; } \
goto handler; \
}
#endif
#if defined(DEBUG) && defined(DEBUGVERBOSE)
#define FailMessageVerbose(cond) if (cond) AssertionFailed(cond, __FILE__, __LINE__, handler)
#else
#define FailMessageVerbose(cond) {}
#endif
#if defined(DEBUG) && defined(DEBUGVERBOSE)
#define ErrorMessageVerbose(cond) if (cond) AssertionFailed(cond, __FILE__, __LINE__, handler)
#else
#define ErrorMessageVerbose(cond) (cond)
#endif
#ifdef DEBUG
#define VDQFailMessage(cond,s) \
if (cond) { \
DebugStr ((ConstStr255Param)"\p"#s); \
}
#else
#define VDQFailMessage(cond, s) \
((void) 0)
#endif DEBUG
#ifdef DEBUG
#define VDQErrorMessage(cond) if (cond) DebugStr((ConstStr255Param)"\p"#cond)
#else
#define VDQErrorMessage(cond) (cond)
#endif DEBUG
#ifdef DEBUG
#define VDQDebugMessage(s) DebugStr ((ConstStr255Param)"\p"#s)
#else
#define VDQDebugMessage(s) ((void) 0)
#endif DEBUG
#if 0
#undef DisposHandle
#define DisposeHandle(thandle) { DisposeHandle(thandle); if (MemError() != noErr) DebugMessage(wackyHandle); }
#define DisposHandle DisposeHandle
#undef DisposPtr
#define DisposePtr(tptr) { DisposePtr(tptr); if (MemError() != noErr) DebugMessage(wackyPointer); }
#define DisposPtr DisposePtr
#endif
#endif