mirror of
https://github.com/encounter/tp.git
synced 2026-07-11 06:18:46 -07:00
more various JSystem work (#2046)
* most of J3DAnmLoader done * J3D / JKernel / JUTConsole work * remove asm * fix build * dol 50%
This commit is contained in:
+173
-123
@@ -2,7 +2,6 @@
|
||||
#define LINKLIST_H
|
||||
|
||||
#include "dolphin/types.h"
|
||||
#include "JSystem/JUtility/JUTAssert.h"
|
||||
|
||||
namespace JGadget {
|
||||
struct TLinkListNode {
|
||||
@@ -11,46 +10,84 @@ struct TLinkListNode {
|
||||
mPrev = NULL;
|
||||
}
|
||||
|
||||
TLinkListNode* getNext() { return mNext; }
|
||||
TLinkListNode* getPrev() { return mPrev; }
|
||||
TLinkListNode* getNext() const { return mNext; }
|
||||
TLinkListNode* getPrev() const { return mPrev; }
|
||||
|
||||
public:
|
||||
/* 0x0 */ TLinkListNode* mNext;
|
||||
/* 0x4 */ TLinkListNode* mPrev;
|
||||
}; // Size: 0x8
|
||||
|
||||
struct TNodeLinkList {
|
||||
struct iterator {
|
||||
iterator(TLinkListNode* pNode) { node = pNode; }
|
||||
iterator(const iterator& iter) { *this = iter; }
|
||||
explicit iterator(TLinkListNode* pNode) { node = pNode; }
|
||||
|
||||
iterator& operator++() {
|
||||
node = node->getNext();
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
iterator& operator--() {
|
||||
node = node->getPrev();
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
TLinkListNode* operator->() { return node; }
|
||||
iterator operator++(int) {
|
||||
const iterator old(*this);
|
||||
(void)++*this;
|
||||
return old;
|
||||
}
|
||||
iterator operator--(int) {
|
||||
const iterator old(*this);
|
||||
(void)--*this;
|
||||
return old;
|
||||
}
|
||||
friend bool operator==(iterator a, iterator b) { return a.node == b.node; }
|
||||
friend bool operator!=(iterator a, iterator b) { return !(a == b); }
|
||||
|
||||
inline friend bool operator==(iterator a, iterator b) { return a.node == b.node; }
|
||||
TLinkListNode* operator->() const { return node; }
|
||||
TLinkListNode& operator*() const { return *node; }
|
||||
|
||||
TLinkListNode* node;
|
||||
public:
|
||||
/* 0x00 */ TLinkListNode* node;
|
||||
};
|
||||
|
||||
struct const_iterator {
|
||||
const_iterator(TLinkListNode* pNode) { node = pNode; }
|
||||
explicit const_iterator(TLinkListNode* pNode) { node = pNode; }
|
||||
const_iterator(const const_iterator& iter) { *this = iter; }
|
||||
const_iterator(iterator iter) { *this = iter; }
|
||||
TLinkListNode* operator->() const { return node; }
|
||||
explicit const_iterator(iterator it) { node = it.node; }
|
||||
|
||||
const_iterator& operator++() {
|
||||
node = node->getNext();
|
||||
return *this;
|
||||
return *this;
|
||||
}
|
||||
const_iterator& operator--() {
|
||||
node = node->getPrev();
|
||||
return *this;
|
||||
}
|
||||
const_iterator operator++(int) {
|
||||
const const_iterator old(*this);
|
||||
(void)++*this;
|
||||
return old;
|
||||
}
|
||||
const_iterator operator--(int) {
|
||||
const const_iterator old(*this);
|
||||
(void)--*this;
|
||||
return old;
|
||||
}
|
||||
friend bool operator==(const_iterator a, const_iterator b) { return a.node == b.node; }
|
||||
friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
|
||||
|
||||
TLinkListNode* node;
|
||||
friend bool operator==(const_iterator a, iterator b) { return a.node == b.node; }
|
||||
friend bool operator!=(const_iterator a, iterator b) { return !(a == b); }
|
||||
|
||||
const TLinkListNode* operator->() const { return node; }
|
||||
const TLinkListNode& operator*() const { return *node; }
|
||||
|
||||
public:
|
||||
/* 0x00 */ TLinkListNode* node;
|
||||
};
|
||||
|
||||
TNodeLinkList() : ocObject_() { Initialize_(); }
|
||||
~TNodeLinkList();
|
||||
|
||||
void Initialize_() {
|
||||
count = 0;
|
||||
@@ -58,31 +95,47 @@ struct TNodeLinkList {
|
||||
ocObject_.mPrev = &ocObject_;
|
||||
}
|
||||
|
||||
iterator end() {
|
||||
iterator iter(&ocObject_);
|
||||
return iter;
|
||||
}
|
||||
|
||||
iterator begin() {
|
||||
return iterator(ocObject_.getNext());
|
||||
}
|
||||
|
||||
iterator begin() { return iterator(ocObject_.getNext()); }
|
||||
const_iterator begin() const { return const_iterator(ocObject_.getNext()); }
|
||||
iterator end() { return iterator(&ocObject_); }
|
||||
const_iterator end() const { return const_iterator((TLinkListNode*)(&ocObject_)); }
|
||||
u32 size() { return count; }
|
||||
bool empty() { return size() == 0; }
|
||||
iterator pop_front() {
|
||||
return erase(begin());
|
||||
iterator pop_front() { return erase(begin()); }
|
||||
|
||||
iterator erase(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList::iterator);
|
||||
iterator erase(JGadget::TNodeLinkList::iterator);
|
||||
void splice(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList&,
|
||||
JGadget::TNodeLinkList::iterator);
|
||||
iterator Find(const JGadget::TLinkListNode*);
|
||||
iterator Insert(JGadget::TNodeLinkList::iterator, JGadget::TLinkListNode*);
|
||||
iterator Erase(JGadget::TLinkListNode*);
|
||||
void Remove(JGadget::TLinkListNode*);
|
||||
|
||||
bool Iterator_isEnd_(const_iterator it) const { return it.node == &ocObject_; }
|
||||
template <typename Predicate>
|
||||
void Remove_if(Predicate predicate, TNodeLinkList& tList) {
|
||||
iterator it = begin();
|
||||
|
||||
while (!Iterator_isEnd_(const_iterator(it))) {
|
||||
if (predicate(*it)) {
|
||||
iterator itPrev = it;
|
||||
++it;
|
||||
tList.splice(tList.end(), *this, itPrev);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 802DCA1C */ ~TNodeLinkList();
|
||||
/* 802DCAA0 */ iterator erase(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList::iterator);
|
||||
/* 802DCA58 */ iterator erase(JGadget::TNodeLinkList::iterator);
|
||||
/* 802DCB08 */ void splice(JGadget::TNodeLinkList::iterator, JGadget::TNodeLinkList&,
|
||||
JGadget::TNodeLinkList::iterator);
|
||||
/* 802DCBA8 */ iterator Insert(JGadget::TNodeLinkList::iterator, JGadget::TLinkListNode*);
|
||||
/* 802DCBD4 */ iterator Erase(JGadget::TLinkListNode*);
|
||||
/* 802DCBF8 */ void Remove(JGadget::TLinkListNode*);
|
||||
template <typename Predicate>
|
||||
void remove_if(Predicate predicate) {
|
||||
TNodeLinkList list;
|
||||
Remove_if(predicate, list);
|
||||
}
|
||||
|
||||
/* 0x00 */ int count;
|
||||
public:
|
||||
/* 0x00 */ u32 count;
|
||||
/* 0x04 */ TLinkListNode ocObject_;
|
||||
}; // Size: 0xC
|
||||
|
||||
@@ -90,108 +143,105 @@ template <typename T, int I>
|
||||
struct TLinkList : public TNodeLinkList {
|
||||
TLinkList() : TNodeLinkList() {}
|
||||
|
||||
struct iterator : TNodeLinkList::iterator {
|
||||
iterator(TNodeLinkList::iterator iter) : TNodeLinkList::iterator(iter) {}
|
||||
T& operator*() { return *operator->(); }
|
||||
T* operator->() {
|
||||
TLinkListNode* node = TNodeLinkList::iterator::operator->();
|
||||
JUT_ASSERT(541, node != 0);
|
||||
return Element_toValue(node);
|
||||
struct iterator {
|
||||
explicit iterator(TNodeLinkList::iterator iter) : base(iter) {}
|
||||
|
||||
iterator& operator++() {
|
||||
++base;
|
||||
return *this;
|
||||
}
|
||||
iterator& operator--() {
|
||||
TNodeLinkList::iterator::operator--();
|
||||
--base;
|
||||
return *this;
|
||||
}
|
||||
// Stack issues. See JStudio::ctb::TControl::getObject
|
||||
inline friend bool operator==(iterator a, iterator b) {
|
||||
TNodeLinkList::iterator ita = a;
|
||||
TNodeLinkList::iterator itb = b;
|
||||
return operator==(ita,itb);
|
||||
iterator operator++(int) {
|
||||
const iterator old(*this);
|
||||
++*this;
|
||||
return old;
|
||||
}
|
||||
inline friend bool operator!=(iterator a, iterator b) { return !(a == b); }
|
||||
iterator operator--(int) {
|
||||
const iterator old(*this);
|
||||
--*this;
|
||||
return old;
|
||||
}
|
||||
friend bool operator==(iterator a, iterator b) { return a.base == b.base; }
|
||||
friend bool operator!=(iterator a, iterator b) { return !(a == b); }
|
||||
|
||||
T* operator->() const { return Element_toValue(base.operator->()); }
|
||||
T& operator*() const { return *operator->(); }
|
||||
|
||||
public:
|
||||
/* 0x00 */ TNodeLinkList::iterator base;
|
||||
};
|
||||
|
||||
struct const_iterator : TNodeLinkList::const_iterator {
|
||||
const_iterator(TNodeLinkList::const_iterator iter) : TNodeLinkList::const_iterator(iter) {}
|
||||
const_iterator(iterator iter) : TNodeLinkList::const_iterator(iter) {}
|
||||
const T* operator->() const {
|
||||
return Element_toValue(TNodeLinkList::const_iterator::operator->());
|
||||
}
|
||||
const T& operator*() const { return *operator->(); }
|
||||
struct const_iterator {
|
||||
explicit const_iterator(TNodeLinkList::const_iterator iter) : base(iter) {}
|
||||
explicit const_iterator(iterator iter) : base(iter.base) {}
|
||||
|
||||
const_iterator& operator++() {
|
||||
TNodeLinkList::const_iterator::operator++();
|
||||
++base;
|
||||
return *this;
|
||||
}
|
||||
|
||||
friend bool operator==(const_iterator a, const_iterator b) { return a == b; }
|
||||
const_iterator& operator--() {
|
||||
--base;
|
||||
return *this;
|
||||
}
|
||||
const_iterator operator++(int) {
|
||||
const const_iterator old(*this);
|
||||
++*this;
|
||||
return old;
|
||||
}
|
||||
const_iterator operator--(int) {
|
||||
const const_iterator old(*this);
|
||||
--*this;
|
||||
return old;
|
||||
}
|
||||
friend bool operator==(const_iterator a, const_iterator b) { return a.base == b.base; }
|
||||
friend bool operator!=(const_iterator a, const_iterator b) { return !(a == b); }
|
||||
|
||||
const T* operator->() const { return Element_toValue(base.operator->()); }
|
||||
const T& operator*() const { return *operator->(); }
|
||||
|
||||
public:
|
||||
/* 0x00 */ TNodeLinkList::const_iterator base;
|
||||
};
|
||||
|
||||
TLinkListNode* Element_toNode(T* element) const { return &element->ocObject_; }
|
||||
static T* Element_toValue(TLinkListNode* node) { return (T*)((char*)node - offsetof(T, ocObject_)); }
|
||||
|
||||
iterator Insert(TLinkList::iterator iter, T* element) {
|
||||
TLinkListNode* node = Element_toNode(element);
|
||||
return TNodeLinkList::Insert(iter, node);
|
||||
static const TLinkListNode* Element_toNode(const T* element) {
|
||||
(void)element; // Debug-only assert
|
||||
return reinterpret_cast<const TLinkListNode*>(reinterpret_cast<const char*>(element) - I);
|
||||
}
|
||||
static TLinkListNode* Element_toNode(T* element) {
|
||||
(void)element; // Debug-only assert
|
||||
return reinterpret_cast<TLinkListNode*>(reinterpret_cast<char*>(element) - I);
|
||||
}
|
||||
static const T* Element_toValue(const TLinkListNode* node) {
|
||||
(void)node; // Debug-only assert
|
||||
return reinterpret_cast<const T*>(reinterpret_cast<const char*>(node) + I);
|
||||
}
|
||||
static T* Element_toValue(TLinkListNode* node) {
|
||||
(void)node; // Debug-only assert
|
||||
return reinterpret_cast<T*>(reinterpret_cast<char*>(node) + I);
|
||||
}
|
||||
|
||||
iterator Erase(T* element) {
|
||||
TLinkListNode* node = Element_toNode(element);
|
||||
return ((TNodeLinkList*)this)->Erase(node);
|
||||
iterator Insert(iterator iter, T* element) {
|
||||
return iterator(TNodeLinkList::Insert(iter.base, Element_toNode(element)));
|
||||
}
|
||||
iterator Erase(T* element) { return iterator(TNodeLinkList::Erase(Element_toNode(element))); }
|
||||
|
||||
TLinkList::iterator end() {
|
||||
return iterator(TNodeLinkList::end());
|
||||
}
|
||||
|
||||
TLinkList::const_iterator end() const {
|
||||
return TLinkList::const_iterator(((TLinkList*)this)->end());
|
||||
}
|
||||
|
||||
TLinkList::iterator begin() {
|
||||
return iterator(TNodeLinkList::begin());
|
||||
}
|
||||
|
||||
TLinkList::const_iterator begin() const {
|
||||
return TLinkList::const_iterator(((TLinkList*)this)->begin());
|
||||
}
|
||||
|
||||
void Push_back(T* element) {
|
||||
TLinkList::iterator iter = TLinkList::end();
|
||||
this->Insert(iter, element);
|
||||
}
|
||||
|
||||
T& front() {
|
||||
JUT_ASSERT(642, !empty());
|
||||
return *begin();
|
||||
}
|
||||
|
||||
T& back() {
|
||||
JUT_ASSERT(652, !empty());
|
||||
return *--TLinkList::end();
|
||||
iterator begin() { return iterator(TNodeLinkList::begin()); }
|
||||
const_iterator begin() const { return const_iterator(const_cast<TLinkList*>(this)->begin()); }
|
||||
iterator end() { return iterator(TNodeLinkList::end()); }
|
||||
const_iterator end() const { return const_iterator(const_cast<TLinkList*>(this)->end()); }
|
||||
T& front() { return *begin(); }
|
||||
T& back() { return *--end(); }
|
||||
void Push_front(T* element) { Insert(begin(), element); }
|
||||
void Push_back(T* element) { Insert(end(), element); }
|
||||
iterator Find(const T* element) {
|
||||
return iterator(TNodeLinkList::Find(Element_toNode(element)));
|
||||
}
|
||||
void Remove(T* element) { TNodeLinkList::Remove(Element_toNode(element)); }
|
||||
};
|
||||
|
||||
template<typename T, int I>
|
||||
bool operator==(const typename TLinkList<T, I>::const_iterator iter1, const typename TLinkList<T, I>::const_iterator iter2) {
|
||||
return iter1->node == iter2->node;
|
||||
}
|
||||
|
||||
template<typename T, int I>
|
||||
bool operator!=(const typename TLinkList<T, I>::const_iterator iter1, const typename TLinkList<T, I>::const_iterator iter2) {
|
||||
return !(iter1 == iter2);
|
||||
}
|
||||
|
||||
// template<typename T, int I>
|
||||
// inline bool operator==(typename TLinkList<T, I>::iterator iter1, typename TLinkList<T, I>::iterator iter2) {
|
||||
// return iter1->node == iter2->node;
|
||||
// }
|
||||
|
||||
// template<typename T, int I>
|
||||
// inline bool operator!=(typename TLinkList<T, I>::iterator iter1, typename TLinkList<T, I>::iterator iter2) {
|
||||
// return !(iter1 == iter2);
|
||||
// }
|
||||
|
||||
template <typename T, int I>
|
||||
struct TLinkList_factory : public TLinkList<T, I> {
|
||||
virtual ~TLinkList_factory() {}
|
||||
@@ -208,14 +258,14 @@ struct TLinkList_factory : public TLinkList<T, I> {
|
||||
|
||||
template <typename T, int I>
|
||||
struct TEnumerator {
|
||||
inline TEnumerator(typename TLinkList<T,I>::const_iterator _current, typename TLinkList<T,I>::const_iterator _end) :
|
||||
current(_current), end(_end)
|
||||
{}
|
||||
inline TEnumerator(typename TLinkList<T, I>::const_iterator _current,
|
||||
typename TLinkList<T, I>::const_iterator _end)
|
||||
: current(_current), end(_end) {}
|
||||
|
||||
bool isEnd() const { return current.node == end.node; }
|
||||
operator bool() const { return isEnd(); }
|
||||
T& operator*() {
|
||||
T& rv = (T&)*current;
|
||||
T& rv = (T&)*current;
|
||||
++current;
|
||||
return rv;
|
||||
}
|
||||
@@ -226,8 +276,8 @@ struct TEnumerator {
|
||||
|
||||
template <typename T, int I>
|
||||
struct TContainerEnumerator_const : public TEnumerator<T, I> {
|
||||
inline TContainerEnumerator_const(const T* param_0) : TEnumerator<T,I>(param_0->begin(), param_0->end())
|
||||
{}
|
||||
inline TContainerEnumerator_const(const T* param_0)
|
||||
: TEnumerator<T, I>(param_0->begin(), param_0->end()) {}
|
||||
};
|
||||
|
||||
}; // namespace JGadget
|
||||
|
||||
Reference in New Issue
Block a user