Skip to content

Commit

Permalink
JUTAssert: simplify assert
Browse files Browse the repository at this point in the history
  • Loading branch information
magcius committed Sep 10, 2023
1 parent 32f62c1 commit f945d95
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 24 deletions.
14 changes: 5 additions & 9 deletions include/JSystem/JUtility/JUTAssert.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
12 changes: 6 additions & 6 deletions src/DynamicLink.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ BOOL DynamicModuleControlBase::link() {
mDoLinkCount++;
}
}
JUT_ASSERT(__FILE__, 100, mLinkCount < 65535);
JUT_ASSERT(100, mLinkCount < 65535);
if (mLinkCount < 65535) {
mLinkCount++;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -412,7 +412,7 @@ BOOL DynamicModuleControl::do_link() {
}
}
} else {
JUT_ASSERT(__FILE__, 724, 0);
JUT_ASSERT(724, 0);
}
OSGetTime();
sAllocBytes = sAllocBytes + getModuleSize();
Expand Down Expand Up @@ -494,15 +494,15 @@ void ModuleUnresolved() {
}

void ModuleConstructorsX(const VoidFunc* _ctors) {
JUT_ASSERT(__FILE__, 850, _ctors);
JUT_ASSERT(850, _ctors);
while (*_ctors != 0) {
(**_ctors)();
_ctors++;
}
}

void ModuleDestructorsX(const VoidFunc* _dtors) {
JUT_ASSERT(__FILE__, 864, _dtors);
JUT_ASSERT(864, _dtors);
while (*_dtors != 0) {
(**_dtors)();
_dtors++;
Expand Down
2 changes: 1 addition & 1 deletion src/JSystem/JKernel/JKRFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/JSystem/JParticle/JPATexture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/JSystem/JUtility/JUTNameTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/f_op/f_op_overlap_mng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/f_op/f_op_scene_mng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion src/f_pc/f_pc_deletor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/f_pc/f_pc_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f945d95

Please sign in to comment.