[debug] simplify macros, add EX versions

This commit is contained in:
sbird 2022-09-23 03:48:58 +02:00
parent 22329d3318
commit 12670e8e3e

View File

@ -7,52 +7,52 @@
#define DebugPrintf(pBuf, ...) #define DebugPrintf(pBuf, ...)
#define MgbaOpen() #define MgbaOpen()
#define MgbaClose() #define MgbaClose()
#define AGB_ASSERT(exp)
#define AGB_WARNING(exp)
#define AGBPrintInit() #define AGBPrintInit()
#define DebugAssert(pFile, nLine, pExpression, nStopProgram)
#else #else
#if (LOG_HANDLER == LOG_HANDLER_MGBA_PRINT)
bool32 MgbaOpen(void); bool32 MgbaOpen(void);
void MgbaClose(void); void MgbaClose(void);
void MgbaPrintf(const char *pBuf, ...); void MgbaPrintf(const char *pBuf, ...);
void MgbaAssert(const char *pFile, s32 nLine, const char *pExpression, bool32 nStopProgram); void MgbaAssert(const char *pFile, s32 nLine, const char *pExpression, bool32 nStopProgram);
#define DebugPrintf(pBuf, ...) MgbaPrintf(pBuf, __VA_ARGS__) void NoCashGBAPrintf(const char *pBuf, ...);
#define AGB_ASSERT(exp) (exp) ? ((void*)0) : MgbaAssert(__FILE__, __LINE__, #exp, TRUE) void NoCashGBAAssert(const char *pFile, s32 nLine, const char *pExpression, bool32 nStopProgram);
#define AGB_WARNING(exp) (exp) ? ((void*)0) : MgbaAssert(__FILE__, __LINE__, #exp, FALSE)
// Not used in this configuration
#define AGBPrintfInit()
#elif (LOG_HANDLER == LOG_HANDLER_NOCASH_PRINT)
void NoCashGBAPrintf(const char *pBuf, ...)
void NoCashGBAAssert(const char *pFile, s32 nLine, const char *pExpression, bool32 nStopProgram)
#define DebugPrintf(pBuf, ...) NoCashGBAPrintf(pBuf, __VA_ARGS__)
#define AGB_ASSERT(exp) (exp) ? ((void*)0) : NoCashGBAAssert(__FILE__, __LINE__, #exp, TRUE);
#define AGB_WARNING(exp) (exp) ? ((void*)0) : NoCashGBAAssert(__FILE__, __LINE__, #exp, FALSE)
// Not used in this configuration
#define MgbaOpen()
#define MgbaClose()
#define AGBPrintInit()
#else // Default to AGBPrint
void AGBPrintf(const char *pBuf, ...); void AGBPrintf(const char *pBuf, ...);
void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram);
void AGBPrintInit(void); void AGBPrintInit(void);
#if (LOG_HANDLER == LOG_HANDLER_MGBA_PRINT)
#define DebugPrintf(pBuf, ...) MgbaPrintf(pBuf, __VA_ARGS__)
#define DebugAssert(pFile, nLine, pExpression, nStopProgram) MgbaAssert(pFile, nLine, pExpression, nStopProgram)
#elif (LOG_HANDLER == LOG_HANDLER_NOCASH_PRINT)
#define DebugPrintf(pBuf, ...) NoCashGBAPrintf(pBuf, __VA_ARGS__)
#define DebugAssert(pFile, nLine, pExpression, nStopProgram) NoCashGBAAssert(pFile, nLine, pExpression, nStopProgram)
#else // Default to AGBPrint
#define DebugPrintf(pBuf, ...) AGBPrintf(const char *pBuf, ...) #define DebugPrintf(pBuf, ...) AGBPrintf(const char *pBuf, ...)
#define AGB_ASSERT(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, TRUE) #define DebugAssert(pFile, nLine, pExpression, nStopProgram) AGBAssert(pFile, nLine, pExpression, nStopProgram)
#define AGB_WARNING(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, FALSE)
// Not used in this configuration
#define MgbaOpen()
#define MgbaClose()
#endif #endif
#endif #endif
// for matching purposes
#ifdef NDEBUG #ifdef NDEBUG
#define AGB_ASSERT_EX(exp, file, line)
#define AGB_ASSERT(exp)
#define AGB_WARNING(exp)
#define AGB_ASSERT_EX(exp, file, line)
#define AGB_WARNING_EX(exp, file, line)
#else #else
#define AGB_ASSERT_EX(exp, file, line) AGB_ASSERT(exp);
#define AGB_ASSERT(exp) (exp) ? ((void*)0) : DebugAssert(__FILE__, __LINE__, #exp, TRUE)
#define AGB_WARNING(exp) (exp) ? ((void*)0) : DebugAssert(__FILE__, __LINE__, #exp, FALSE)
#define AGB_WARNING_EX(exp, file, line) (exp) ? ((void *)0) : DebugAssert(file, line, #exp, FALSE);
#define AGB_ASSERT_EX(exp, file, line) (exp) ? ((void *)0) : DebugAssert(file, line, #exp, TRUE);
#endif #endif
#endif // GUARD_GBA_ISAGBPRINT_H #endif // GUARD_GBA_ISAGBPRINT_H