diff options
| author | TakaRikka <38417346+TakaRikka@users.noreply.github.com> | 2025-01-19 21:05:53 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-19 22:05:53 -0700 |
| commit | e0824a15908f4e6ad70d3d0f2364efe043a98c0f (patch) | |
| tree | 3e85ea5ea5282c7ca3397a3adc1535674fc496aa /src/m_Do/m_Do_hostIO.cpp | |
| parent | 7137f49bfc9535d95f980fb92552adf7b7c3c3ce (diff) | |
most of JHostIO / m_Do_hostIO done (#2288)
Diffstat (limited to 'src/m_Do/m_Do_hostIO.cpp')
| -rw-r--r-- | src/m_Do/m_Do_hostIO.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/src/m_Do/m_Do_hostIO.cpp b/src/m_Do/m_Do_hostIO.cpp new file mode 100644 index 0000000000..61c2cbebd6 --- /dev/null +++ b/src/m_Do/m_Do_hostIO.cpp @@ -0,0 +1,138 @@ +#include "m_Do/m_Do_hostIO.h" +#include <dolphin.h> + +#ifdef DEBUG + +void mDoHIO_updateChild(s8 i_no); +void mDoHIO_deleteChild(s8 i_no); +s8 mDoHIO_createChild(const char*, JORReflexible*); + +mDoHIO_root_c mDoHIO_root; + +mDoHIO_root_c::~mDoHIO_root_c() {} + +mDoHIO_subRoot_c::~mDoHIO_subRoot_c() {} + +mDoHIO_child_c::~mDoHIO_child_c() {} + +void mDoHIO_root_c::genMessage(JORMContext* i_context) { + i_context->genNode("Node", &mSub, 0, 0); +} + +void mDoHIO_subRoot_c::genMessage(JORMContext* i_context) { + for (int i = 0; i < 80; i++) { + JORReflexible* node = mChildren[i].getPt(); + + if (node != NULL) { + i_context->genNode(mChildren[i].getName(), node, 0, 0); + } + } +} + +void mDoHIO_root_c::update() { + JORMContext* context = attachJORMContext(5); + context->invalidNode(this, 3); + releaseJORMContext(context); +} + +s8 mDoHIO_subRoot_c::createChild(const char* i_name, JORReflexible* i_node) { + for (int i = 0; i < 80; i++) { + if (mChildren[i].getPt() == i_node) { + OSReport_Error("危険:既に登録されているホストIOをふたたび登録\nしようとしているのを発見しました。<%s>%08x\n削除処理が正しく呼ばれていない可能性があります。\n登録と削除は1:1で呼ぶように修正してください。\n", i_name, i_node); + return -1; + } + } + + for (int i = 0; i < 80; i++) { + if (mChildren[i].getPt() == NULL) { + mChildren[i].setName(i_name); + mChildren[i].setPt(i_node); + return i + 1; + } + } + + OSReport_Error("ホストIOの空きエントリがありません。登録できませんでした。<%s>\n", i_name); + return -1; +} + +void mDoHIO_subRoot_c::deleteChild(s8 i_no) { + i_no--; + + if (i_no >= 0) { + if (mChildren[i_no].getPt() == NULL) { + OSReport_Error("危険:削除済みホストIOをさらに削除しようとしています<%s>\n", mChildren[i_no].getName()); + } else { + mChildren[i_no].setPt(NULL); + } + } else { + OSReport_Error("mDoHIO_subRoot_c::deleteChild\n"); + } +} + +void mDoHIO_subRoot_c::updateChild(s8 i_no) { + i_no--; + + if (i_no >= 0) { + JORMContext* context = attachJORMContext(5); + context->invalidNode(mChildren[i_no].getPt(), 3); + releaseJORMContext(context); + } +} + +mDoHIO_entry_c::mDoHIO_entry_c() { + mNo = -1; + mCount = 0; +} + +mDoHIO_entry_c::~mDoHIO_entry_c() { + if (mCount != 0) { + OSReport_Error("~mDoHIO_entry_c mCount=%d mNo=%d\n", mCount, mNo); + mDoHIO_deleteChild(mNo); + mDoHIO_deleteChild(mNo); + } +} + +void mDoHIO_deleteChild(s8 i_no) { + mDoHIO_root.deleteChild(i_no); +} + +void mDoHIO_root_c::deleteChild(s8 i_no) { + mSub.deleteChild(i_no); +} + +void mDoHIO_entry_c::entryHIO(const char* i_name) { + if (mCount >= 127) { + // "mDoHIO_entry_c::entryHIO too many calls\n" + OSReport_Error("mDoHIO_entry_c::entryHIO 呼びすぎです\n"); + return; + } + + if (mNo == -1 && i_name != NULL) { + mNo = mDoHIO_createChild(i_name, this); + } + + mCount++; +} + +void mDoHIO_entry_c::removeHIO() { + if (mCount != 0) { + mCount--; + + if (mCount == 0 && mNo != -1) { + mDoHIO_deleteChild(mNo); + mNo =-1; + } + } else { + OSReport_Error("mDoHIO_entry_c::removeHIO 呼びすぎです\n"); + } +} + +void mDoHIO_updateChild(s8 i_no) { + mDoHIO_root.updateChild(i_no); +} + +void mDoHIO_root_c::updateChild(s8 i_no) { + mSub.updateChild(i_no); +} + +#endif |
