JUTAssert: simplify assert

This commit is contained in:
Jasper St. Pierre
2023-09-09 23:02:40 -07:00
parent 32f62c1402
commit f945d95281
9 changed files with 20 additions and 24 deletions
+5 -9
View File
@@ -4,18 +4,14 @@
#include "dolphin/types.h"
#include "dolphin/os/OS.h"
#define JUT_ASSERT(FILE, LINE, COND) \
#define JUT_ASSERT(LINE, COND) \
if (!(COND)) { \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), FILE, LINE, #COND); \
OSPanic(FILE, LINE, "Halt"); \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), __FILE__, LINE, #COND); \
OSPanic(__FILE__, LINE, "Halt"); \
}
#define JUT_WARN(FILE, LINE, ...) \
JUTAssertion::setWarningMessage_f(JUTAssertion::getSDevice(), FILE, LINE, __VA_ARGS__); \
#define JUT_PANIC(FILE, LINE, TEXT) \
JUTAssertion::showAssert(JUTAssertion::getSDevice(), FILE, LINE, TEXT); \
OSPanic(FILE, LINE, "Halt");
#define JUT_WARN(LINE, ...) \
JUTAssertion::setWarningMessage_f(JUTAssertion::getSDevice(), __FILE__, LINE, __VA_ARGS__); \
namespace JUTAssertion {
u32 getSDevice();
+6 -6
View File
@@ -73,7 +73,7 @@ BOOL DynamicModuleControlBase::link() {
mDoLinkCount++;
}
}
JUT_ASSERT(__FILE__, 100, mLinkCount < 65535);
JUT_ASSERT(100, mLinkCount < 65535);
if (mLinkCount < 65535) {
mLinkCount++;
}
@@ -343,8 +343,8 @@ BOOL DynamicModuleControl::do_link() {
do_load();
}
if (mModule != NULL) {
JUT_ASSERT(__FILE__, 613, mModule->info.sectionInfoOffset < 0x80000000);
JUT_ASSERT(__FILE__, 615, (u32)mModule + mModule->fixSize < 0x82000000);
JUT_ASSERT(613, mModule->info.sectionInfoOffset < 0x80000000);
JUT_ASSERT(615, (u32)mModule + mModule->fixSize < 0x82000000);
OSGetTime();
OSGetTime();
if (mModule->mModuleVersion >= 3) {
@@ -412,7 +412,7 @@ BOOL DynamicModuleControl::do_link() {
}
}
} else {
JUT_ASSERT(__FILE__, 724, 0);
JUT_ASSERT(724, 0);
}
OSGetTime();
sAllocBytes = sAllocBytes + getModuleSize();
@@ -494,7 +494,7 @@ void ModuleUnresolved() {
}
void ModuleConstructorsX(const VoidFunc* _ctors) {
JUT_ASSERT(__FILE__, 850, _ctors);
JUT_ASSERT(850, _ctors);
while (*_ctors != 0) {
(**_ctors)();
_ctors++;
@@ -502,7 +502,7 @@ void ModuleConstructorsX(const VoidFunc* _ctors) {
}
void ModuleDestructorsX(const VoidFunc* _dtors) {
JUT_ASSERT(__FILE__, 864, _dtors);
JUT_ASSERT(864, _dtors);
while (*_dtors != 0) {
(**_dtors)();
_dtors++;
+1 -1
View File
@@ -9,7 +9,7 @@
/* 802BC610-802BC6B4 .text read__7JKRFileFPvll */
s32 JKRFile::read(void* data, s32 length, long offset) {
JUT_ASSERT("JKRFile.cpp", 34, ( length & 0x1f ) == 0);
JUT_ASSERT(34, ( length & 0x1f ) == 0);
while (true) {
s32 result = readData(data, length, offset);
if (length != result)
+1 -1
View File
@@ -17,7 +17,7 @@ JPATextureArc::JPATextureArc(const unsigned char * pData) {
/* 802586D0-80258BB4 .text initialize__17JPADefaultTextureFP7JKRHeap */
void JPADefaultTexture::initialize(JKRHeap* pHeap) {
imgBuf = (u8*)JKRHeap::alloc(0x80, 0x20, pHeap);
JUT_ASSERT("JPATexture.cpp", 50, imgBuf);
JUT_ASSERT(50, imgBuf);
imgBuf[0x00] = 0x00;
imgBuf[0x01] = 0xff;
imgBuf[0x02] = 0x00;
+2 -2
View File
@@ -28,7 +28,7 @@ void JUTNameTab::setResource(const ResNTAB* pNameTable) {
}
s32 JUTNameTab::getIndex(const char* pName) const {
JUT_ASSERT("JUTNameTab.cpp", 101, mNameTable != 0);
JUT_ASSERT(101, mNameTable != 0);
const ResNTAB::Entry* pEntry = mNameTable->mEntries;
u16 keyCode = calcKeyCode(pName);
@@ -42,7 +42,7 @@ s32 JUTNameTab::getIndex(const char* pName) const {
}
const char* JUTNameTab::getName(u16 index) const {
JUT_ASSERT("JUTNameTab.cpp", 138, mNameTable != 0);
JUT_ASSERT(138, mNameTable != 0);
if (index < mNameNum)
return mNameTable->getName(index);
+1 -1
View File
@@ -94,7 +94,7 @@ int fopOvlpM_Cancel() {
if (fopOvlpReq_Cancel((overlap_request_class*)l_fopOvlpM_overlap[0]) == true) {
l_fopOvlpM_overlap[0] = NULL;
JUT_WARN("f_op_overlap_mng.cpp", 331, "%s", "fopOvlpM_Cancel SUCCESSED");
JUT_WARN(331, "%s", "fopOvlpM_Cancel SUCCESSED");
return 1;
}
+1 -1
View File
@@ -46,7 +46,7 @@ u32 fopScnM_ReRequest(s16 param_1, u32 param_2) {
void fopScnM_Management() {
if (!fopScnRq_Handler())
JUT_ASSERT("f_op_scene_mng.cpp", 326, 0);
JUT_ASSERT(326, 0);
}
void fopScnM_Init() {
+1 -1
View File
@@ -68,7 +68,7 @@ s32 fpcDt_ToDeleteQ(base_process_class* i_proc) {
layer_class* layer = &procNode->mLayer;
if (!fpcLy_Cancel(layer))
JUT_ASSERT("f_pc_deletor.cpp", 196, 0);
JUT_ASSERT(196, 0);
if (fpcLyIt_OnlyHereLY(layer, (fpcLyIt_OnlyHereFunc)fpcDt_ToDeleteQ, NULL) == 0) {
return 0;
+2 -2
View File
@@ -85,10 +85,10 @@ void fpcM_Management(fpcM_ManagementFunc callBack1, fpcM_ManagementFunc callBack
cAPIGph_Painter();
fpcDt_Handler();
if (!fpcPi_Handler())
JUT_ASSERT("f_pc_manager.cpp", 548, 0);
JUT_ASSERT(548, 0);
if (!fpcCt_Handler())
JUT_ASSERT("f_pc_manager.cpp", 552, 0);
JUT_ASSERT(552, 0);
if (callBack1 != NULL)
callBack1();