mirror of
https://github.com/ACreTeam/ac-decomp
synced 2026-06-20 22:51:17 -04:00
Link linklist.cpp
This commit is contained in:
@@ -409,8 +409,22 @@ JSYSTEM_BASE = [
|
||||
"-sym on", # might also be on for base flags?
|
||||
"-O4,s" # in mkdd some libraries use O4,p, might be the case here too
|
||||
]
|
||||
JSYSTEM_JGADGET_BASE = [
|
||||
"-lang=c++",
|
||||
"-inline on",
|
||||
"-fp fmadd",
|
||||
#"-fp_contract on",
|
||||
#"-pool off", # this is wrong
|
||||
"-Cpp_exceptions off",
|
||||
"-RTTI on",
|
||||
"-char signed",
|
||||
"-enum int",
|
||||
# "-sym on", # might also be on for base flags?
|
||||
"-O4,s" # in mkdd some libraries use O4,p, might be the case here too
|
||||
]
|
||||
|
||||
JSYSTEM_CFLAGS = ' '.join(JSYSTEM_BASE + LOCAL_CFLAGS)
|
||||
JSYSTEM_JGADGET_CFLAGS = ' '.join(JSYSTEM_JGADGET_BASE + LOCAL_CFLAGS)
|
||||
DOL_CFLAGS = ' '.join(BASE_DOL_CFLAGS + LOCAL_CFLAGS)
|
||||
DOL_BOOT_CFLAGS = ' '.join(BOOT_CFLAGS + LOCAL_CFLAGS)
|
||||
DOL_DVDERR_CFLAGS = ' '.join(DVDERR_CFLAGS + LOCAL_CFLAGS)
|
||||
|
||||
@@ -230,6 +230,8 @@ JSystem/JSupport/JSUInputStream.cpp:
|
||||
# .text: [0x8006e3e4, 0x8006e604]
|
||||
# .data: [0x800dedb8, 0x800dee60]
|
||||
# .sdata: [0x80218068, 0x80218088]
|
||||
JSystem/JGadget/linklist.cpp:
|
||||
.text: [0x8006e604, 0x8006e800]
|
||||
JSystem/JUtility/JUTGamePad.cpp:
|
||||
.text: [0x80070274, 0x800713b0]
|
||||
.ctors: [0x800a97ac, 0x800a97b0]
|
||||
|
||||
@@ -618,6 +618,9 @@ class CSource(Source):
|
||||
if path.startswith("src/dolphin/"):
|
||||
self.cflags = c.SDK_FLAGS
|
||||
self.cc = c.OCC
|
||||
elif path.startswith("src/JSystem/JGadget/"):
|
||||
self.cflags = c.JSYSTEM_JGADGET_CFLAGS
|
||||
self.cc = c.CC
|
||||
elif path.startswith("src/JSystem/"):
|
||||
self.cflags = c.JSYSTEM_CFLAGS
|
||||
self.cc = c.CC
|
||||
|
||||
@@ -16,7 +16,7 @@ public:
|
||||
TPRIsEqual_pointer_<T>(const T* p) { this->p_ = p; }
|
||||
|
||||
bool operator()(const T& rSrc) const {
|
||||
return this->p_ == &rSrc;
|
||||
return &rSrc == this->p_;
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -32,7 +32,14 @@ public:
|
||||
this->pPrev_ = nullptr;
|
||||
}
|
||||
|
||||
~TLinkListNode();
|
||||
~TLinkListNode() {
|
||||
// Seemingly not present in earlier versions of JSystem
|
||||
/*
|
||||
#line 77
|
||||
JUT_ASSERT(pNext_==NULL);
|
||||
JUT_ASSERT(pPrev_==NULL);
|
||||
*/
|
||||
}
|
||||
|
||||
TLinkListNode* getNext() const {
|
||||
return this->pNext_;
|
||||
@@ -42,7 +49,10 @@ public:
|
||||
return this->pPrev_;
|
||||
}
|
||||
|
||||
void clear_();
|
||||
void clear_() {
|
||||
this->pNext_ = nullptr;
|
||||
this->pPrev_ = nullptr;
|
||||
}
|
||||
|
||||
TLinkListNode* pNext_;
|
||||
TLinkListNode* pPrev_;
|
||||
@@ -50,7 +60,7 @@ public:
|
||||
|
||||
class TNodeLinkList {
|
||||
public:
|
||||
TNodeLinkList();
|
||||
TNodeLinkList() : oNode_() { Initialize_(); }
|
||||
~TNodeLinkList();
|
||||
|
||||
class iterator {
|
||||
@@ -104,7 +114,20 @@ public:
|
||||
iterator Find(const TLinkListNode* node);
|
||||
iterator Insert(iterator it, TLinkListNode* node);
|
||||
void Remove(TLinkListNode* node);
|
||||
template <typename Predicate> void Remove_if(Predicate predicate, TNodeLinkList& other);
|
||||
template <typename Predicate> void Remove_if(Predicate predicate, TNodeLinkList& tList) {
|
||||
iterator it = this->begin();
|
||||
|
||||
while(!Iterator_isEnd_(it)) {
|
||||
if (predicate(*it)) {
|
||||
iterator itPrev = it;
|
||||
++it;
|
||||
tList.splice(tList.end(), *this, itPrev);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s32 size() const { return this->size_; }
|
||||
bool empty() const { return this->size() == 0; }
|
||||
@@ -129,24 +152,31 @@ public:
|
||||
const_iterator end() const { return &this->oNode_; }
|
||||
|
||||
private:
|
||||
void Initialize_();
|
||||
bool Iterator_isEnd_(const_iterator it) const { return &this->oNode_ == it.p_; }
|
||||
void Initialize_() {
|
||||
this->size_ = 0;
|
||||
this->oNode_.pNext_ = &this->oNode_;
|
||||
this->oNode_.pPrev_ = &this->oNode_;
|
||||
}
|
||||
|
||||
bool Iterator_isEnd_(const_iterator it) const { return it.p_ == &this->oNode_; }
|
||||
|
||||
s32 size_;
|
||||
TLinkListNode oNode_;
|
||||
};
|
||||
|
||||
bool operator==(TNodeLinkList::iterator lhs, TNodeLinkList::iterator rhs) { return lhs.p_ == rhs.p_; }
|
||||
bool operator!=(TNodeLinkList::iterator lhs, TNodeLinkList::iterator rhs) { return !(lhs == rhs); }
|
||||
inline bool operator==(TNodeLinkList::iterator lhs, TNodeLinkList::iterator rhs) { return lhs.p_ == rhs.p_; }
|
||||
inline bool operator!=(TNodeLinkList::iterator lhs, TNodeLinkList::iterator rhs) { return !(lhs == rhs); }
|
||||
|
||||
bool operator==(TNodeLinkList::const_iterator lhs, TNodeLinkList::const_iterator rhs) { return lhs.p_ == rhs.p_; }
|
||||
bool operator!=(TNodeLinkList::const_iterator lhs, TNodeLinkList::const_iterator rhs) { return !(lhs == rhs); }
|
||||
inline bool operator==(TNodeLinkList::const_iterator lhs, TNodeLinkList::const_iterator rhs) { return lhs.p_ == rhs.p_; }
|
||||
inline bool operator!=(TNodeLinkList::const_iterator lhs, TNodeLinkList::const_iterator rhs) { return !(lhs == rhs); }
|
||||
|
||||
/* TODO: TLinkList has not been matched and should be verified */
|
||||
|
||||
template <typename T, int O>
|
||||
class TLinkList : public TNodeLinkList {
|
||||
class iterator {
|
||||
public:
|
||||
iterator iterator(TNodeLinkList::iterator it) : mIt(it) { }
|
||||
iterator(TNodeLinkList::iterator it) : mIt(it) { }
|
||||
|
||||
bool operator==(iterator other) { return (mIt == other.mIt); }
|
||||
bool operator!=(iterator other) { return !(*this == other); }
|
||||
@@ -173,7 +203,7 @@ class TLinkList : public TNodeLinkList {
|
||||
|
||||
class const_iterator {
|
||||
public:
|
||||
const_iterator iterator(TNodeLinkList::const_iterator it) : mIt(it) { }
|
||||
const_iterator(TNodeLinkList::const_iterator it) : mIt(it) { }
|
||||
|
||||
bool operator==(const_iterator other) { return (mIt == other.mIt); }
|
||||
bool operator!=(const_iterator other) { return !(*this == other); }
|
||||
|
||||
@@ -5,22 +5,15 @@
|
||||
|
||||
namespace std {
|
||||
|
||||
struct input_iterator_tag {};
|
||||
/* TODO: these should be properly implemented */
|
||||
|
||||
template<class Iterator>
|
||||
struct iterator_traits {
|
||||
typedef typename Iterator::difference_type difference_type;
|
||||
typedef typename Iterator::value_type value_type;
|
||||
typedef typename Iterator::pointer pointer;
|
||||
typedef typename Iterator::reference reference;
|
||||
typedef typename Iterator::iterator_category iterator_category;
|
||||
};
|
||||
struct input_iterator_tag {};
|
||||
|
||||
template <class InputIterator>
|
||||
inline
|
||||
typename iterator_traits<InputIterator>::difference_type
|
||||
s32
|
||||
__distance(InputIterator first, InputIterator last, input_iterator_tag) {
|
||||
typename iterator_traits<InputIterator>::difference_type result = 0;
|
||||
s32 result = 0;
|
||||
for (; first != last; ++first)
|
||||
++result;
|
||||
return result;
|
||||
@@ -28,9 +21,10 @@ __distance(InputIterator first, InputIterator last, input_iterator_tag) {
|
||||
|
||||
template <class InputIterator>
|
||||
inline
|
||||
typename iterator_traits<InputIterator>::difference_type
|
||||
s32
|
||||
distance(InputIterator first, InputIterator last) {
|
||||
return __distance(first, last, typename iterator_traits<InputIterator>::iterator_category());
|
||||
input_iterator_tag tag;
|
||||
return __distance(first, last, tag);
|
||||
}
|
||||
|
||||
} // namespace std
|
||||
|
||||
@@ -6,16 +6,12 @@
|
||||
namespace JGadget {
|
||||
|
||||
TNodeLinkList::~TNodeLinkList() {
|
||||
#ifdef DEBUG
|
||||
Confirm();
|
||||
clear();
|
||||
#endif
|
||||
JGADGET_ASSERTWARN(empty());
|
||||
this->oNode_.clear_();
|
||||
}
|
||||
|
||||
void TNodeLinkList::Initialize_() {
|
||||
this->size_ = 0;
|
||||
this->oNode_.pNext_ = &this->oNode_;
|
||||
this->oNode_.pPrev_ = &this->oNode_;
|
||||
//this->oNode_.clear_();
|
||||
}
|
||||
|
||||
TNodeLinkList::iterator TNodeLinkList::erase(iterator it, iterator itEnd) {
|
||||
@@ -82,11 +78,14 @@ void TNodeLinkList::splice(TNodeLinkList::iterator it, TNodeLinkList& rSrc, TNod
|
||||
iterator itSrcNext = itSrc;
|
||||
++itSrcNext;
|
||||
|
||||
if (((it == itSrc) || (it == itSrcNext)) == false) {
|
||||
TLinkListNode& node = *itSrc;
|
||||
if ((it == itSrc) || (it == itSrcNext)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
TLinkListNode* const node = &*itSrc;
|
||||
|
||||
rSrc.Erase(&node);
|
||||
this->Insert(it, &node);
|
||||
rSrc.Erase(node);
|
||||
this->Insert(it, node);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +139,7 @@ TNodeLinkList::iterator TNodeLinkList::Erase(TLinkListNode* p) {
|
||||
JUT_ASSERT(pPrev!=0);
|
||||
pPrev->pNext_ = pNext;
|
||||
this->size_--;
|
||||
p->clear_();
|
||||
//p->clear_();
|
||||
return pNext;
|
||||
}
|
||||
|
||||
@@ -148,22 +147,6 @@ void TNodeLinkList::Remove(TLinkListNode* node) {
|
||||
this->remove_if(TPRIsEqual_pointer_<TLinkListNode>(node));
|
||||
}
|
||||
|
||||
template<typename Predicate>
|
||||
void TNodeLinkList::Remove_if(Predicate predicate, TNodeLinkList& tList) {
|
||||
iterator it = this->begin();
|
||||
|
||||
while(!Iterator_isEnd_(it)) {
|
||||
if (predicate(*it)) {
|
||||
iterator itPrev = it;
|
||||
++it;
|
||||
tList.splice(tList.end(), *this, itPrev);
|
||||
}
|
||||
else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TNodeLinkList::Confirm() const {
|
||||
u32 u = 0;
|
||||
const_iterator itEnd = this->end();
|
||||
|
||||
Reference in New Issue
Block a user