mirror of
https://github.com/Atmosphere-NX/Atmosphere.git
synced 2025-06-01 07:18:22 -04:00
exo/vapours: refactor member variables to m_ over this->
This commit is contained in:
parent
5a38311ebf
commit
67a45c97ef
55 changed files with 846 additions and 847 deletions
|
@ -27,9 +27,9 @@ namespace ams::util {
|
|||
static constexpr size_t AlignedSize = ((Size + Alignment - 1) / Alignment) * Alignment;
|
||||
static_assert(AlignedSize % Alignment == 0);
|
||||
private:
|
||||
u8 buffer[Alignment + AlignedSize];
|
||||
u8 m_buffer[Alignment + AlignedSize];
|
||||
public:
|
||||
ALWAYS_INLINE operator u8 *() { return reinterpret_cast<u8 *>(util::AlignUp(reinterpret_cast<uintptr_t>(this->buffer), Alignment)); }
|
||||
ALWAYS_INLINE operator u8 *() { return reinterpret_cast<u8 *>(util::AlignUp(reinterpret_cast<uintptr_t>(m_buffer), Alignment)); }
|
||||
};
|
||||
|
||||
}
|
|
@ -111,17 +111,17 @@ namespace ams::util {
|
|||
class Reference {
|
||||
friend struct BitFlagSet<N, T>;
|
||||
private:
|
||||
BitFlagSet<N, T> *set;
|
||||
s32 idx;
|
||||
BitFlagSet<N, T> *m_set;
|
||||
s32 m_idx;
|
||||
private:
|
||||
constexpr ALWAYS_INLINE Reference() : set(nullptr), idx(0) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE Reference(BitFlagSet<N, T> &s, s32 i) : set(std::addressof(s)), idx(i) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE Reference() : m_set(nullptr), m_idx(0) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE Reference(BitFlagSet<N, T> &s, s32 i) : m_set(std::addressof(s)), m_idx(i) { /* ... */ }
|
||||
public:
|
||||
constexpr ALWAYS_INLINE Reference &operator=(bool en) { this->set->Set(this->idx, en); return *this; }
|
||||
constexpr ALWAYS_INLINE Reference &operator=(const Reference &r) { this->set->Set(this->idx, r); return *this; }
|
||||
constexpr ALWAYS_INLINE Reference &Negate() { this->set->Negate(this->idx); return *this; }
|
||||
constexpr ALWAYS_INLINE operator bool() const { return this->set->Test(this->idx); }
|
||||
constexpr ALWAYS_INLINE bool operator~() const { return !this->set->Test(this->idx); }
|
||||
constexpr ALWAYS_INLINE Reference &operator=(bool en) { m_set->Set(m_idx, en); return *this; }
|
||||
constexpr ALWAYS_INLINE Reference &operator=(const Reference &r) { m_set->Set(m_idx, r); return *this; }
|
||||
constexpr ALWAYS_INLINE Reference &Negate() { m_set->Negate(m_idx); return *this; }
|
||||
constexpr ALWAYS_INLINE operator bool() const { return m_set->Test(m_idx); }
|
||||
constexpr ALWAYS_INLINE bool operator~() const { return !m_set->Test(m_idx); }
|
||||
};
|
||||
|
||||
template<s32 _Index>
|
||||
|
|
|
@ -40,22 +40,22 @@ namespace ams::util {
|
|||
return Storage(1) << (FlagsPerWord - 1 - bit);
|
||||
}
|
||||
private:
|
||||
Storage words[NumWords];
|
||||
Storage m_words[NumWords];
|
||||
public:
|
||||
constexpr ALWAYS_INLINE BitSet() : words() { /* ... */ }
|
||||
constexpr ALWAYS_INLINE BitSet() : m_words() { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE void SetBit(size_t i) {
|
||||
this->words[i / FlagsPerWord] |= GetBitMask(i % FlagsPerWord);
|
||||
m_words[i / FlagsPerWord] |= GetBitMask(i % FlagsPerWord);
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE void ClearBit(size_t i) {
|
||||
this->words[i / FlagsPerWord] &= ~GetBitMask(i % FlagsPerWord);
|
||||
m_words[i / FlagsPerWord] &= ~GetBitMask(i % FlagsPerWord);
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE size_t CountLeadingZero() const {
|
||||
for (size_t i = 0; i < NumWords; i++) {
|
||||
if (this->words[i]) {
|
||||
return FlagsPerWord * i + CountLeadingZeroImpl(this->words[i]);
|
||||
if (m_words[i]) {
|
||||
return FlagsPerWord * i + CountLeadingZeroImpl(m_words[i]);
|
||||
}
|
||||
}
|
||||
return FlagsPerWord * NumWords;
|
||||
|
@ -63,7 +63,7 @@ namespace ams::util {
|
|||
|
||||
constexpr ALWAYS_INLINE size_t GetNextSet(size_t n) const {
|
||||
for (size_t i = (n + 1) / FlagsPerWord; i < NumWords; i++) {
|
||||
Storage word = this->words[i];
|
||||
Storage word = m_words[i];
|
||||
if (!util::IsAligned(n + 1, FlagsPerWord)) {
|
||||
word &= GetBitMask(n % FlagsPerWord) - 1;
|
||||
}
|
||||
|
|
|
@ -37,32 +37,32 @@ namespace ams::util {
|
|||
return __builtin_ctzll(static_cast<u64>(v));
|
||||
}
|
||||
|
||||
T value;
|
||||
T m_value;
|
||||
public:
|
||||
/* Note: GCC has a bug in constant-folding here. Workaround: wrap entire caller with constexpr. */
|
||||
constexpr ALWAYS_INLINE BitsOf(T value = T(0u)) : value(value) {
|
||||
constexpr ALWAYS_INLINE BitsOf(T value = T(0u)) : m_value(value) {
|
||||
/* ... */
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE bool operator==(const BitsOf &other) const {
|
||||
return this->value == other.value;
|
||||
return m_value == other.m_value;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE bool operator!=(const BitsOf &other) const {
|
||||
return this->value != other.value;
|
||||
return m_value != other.m_value;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE int operator*() const {
|
||||
return GetLsbPos(this->value);
|
||||
return GetLsbPos(m_value);
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE BitsOf &operator++() {
|
||||
this->value &= ~(T(1u) << GetLsbPos(this->value));
|
||||
m_value &= ~(T(1u) << GetLsbPos(m_value));
|
||||
return *this;
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE BitsOf &operator++(int) {
|
||||
BitsOf ret(this->value);
|
||||
BitsOf ret(m_value);
|
||||
++(*this);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -24,20 +24,20 @@ namespace ams::util {
|
|||
template<class Key, class Value, size_t N>
|
||||
class BoundedMap {
|
||||
private:
|
||||
std::array<util::optional<Key>, N> keys;
|
||||
std::array<TypedStorage<Value>, N> values;
|
||||
std::array<util::optional<Key>, N> m_keys;
|
||||
std::array<TypedStorage<Value>, N> m_values;
|
||||
private:
|
||||
ALWAYS_INLINE void FreeEntry(size_t i) {
|
||||
this->keys[i].reset();
|
||||
DestroyAt(this->values[i]);
|
||||
m_keys[i].reset();
|
||||
DestroyAt(m_values[i]);
|
||||
}
|
||||
public:
|
||||
constexpr BoundedMap() : keys(), values() { /* ... */ }
|
||||
constexpr BoundedMap() : m_keys(), m_values() { /* ... */ }
|
||||
|
||||
Value *Find(const Key &key) {
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (this->keys[i] && this->keys[i].value() == key) {
|
||||
return GetPointer(this->values[i]);
|
||||
if (m_keys[i] && m_keys[i].value() == key) {
|
||||
return GetPointer(m_values[i]);
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
@ -45,7 +45,7 @@ namespace ams::util {
|
|||
|
||||
void Remove(const Key &key) {
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (this->keys[i] && this->keys[i].value() == key) {
|
||||
if (m_keys[i] && m_keys[i].value() == key) {
|
||||
this->FreeEntry(i);
|
||||
break;
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ namespace ams::util {
|
|||
|
||||
bool IsFull() {
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (!this->keys[i]) {
|
||||
if (!m_keys[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ namespace ams::util {
|
|||
|
||||
/* Find a free value. */
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (!this->keys[i]) {
|
||||
this->keys[i] = key;
|
||||
ConstructAt(this->values[i], std::forward<Value>(value));
|
||||
if (!m_keys[i]) {
|
||||
m_keys[i] = key;
|
||||
ConstructAt(m_values[i], std::forward<Value>(value));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -89,17 +89,17 @@ namespace ams::util {
|
|||
bool InsertOrAssign(const Key &key, Value &&value) {
|
||||
/* Try to find and assign an existing value. */
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (this->keys[i] && this->keys[i].value() == key) {
|
||||
GetReference(this->values[i]) = std::forward<Value>(value);
|
||||
if (m_keys[i] && m_keys[i].value() == key) {
|
||||
GetReference(m_values[i]) = std::forward<Value>(value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Find a free value. */
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (!this->keys[i]) {
|
||||
this->keys[i] = key;
|
||||
ConstructAt(this->values[i], std::move(value));
|
||||
if (!m_keys[i]) {
|
||||
m_keys[i] = key;
|
||||
ConstructAt(m_values[i], std::move(value));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -116,9 +116,9 @@ namespace ams::util {
|
|||
|
||||
/* Find a free value. */
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
if (!this->keys[i]) {
|
||||
this->keys[i] = key;
|
||||
ConstructAt(this->values[i], std::forward<Args>(args)...);
|
||||
if (!m_keys[i]) {
|
||||
m_keys[i] = key;
|
||||
ConstructAt(m_values[i], std::forward<Args>(args)...);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -119,22 +119,22 @@ namespace ams::util {
|
|||
private:
|
||||
friend class ConstIterator;
|
||||
private:
|
||||
const FixedTree *m_this;
|
||||
const FixedTree *m_tree;
|
||||
int m_index;
|
||||
protected:
|
||||
constexpr ALWAYS_INLINE IteratorBase(const FixedTree *tree, int index) : m_this(tree), m_index(index) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE IteratorBase(const FixedTree *tree, int index) : m_tree(tree), m_index(index) { /* ... */ }
|
||||
|
||||
constexpr bool IsEqualImpl(const IteratorBase &rhs) const {
|
||||
/* Validate pre-conditions. */
|
||||
AMS_ASSERT(m_this);
|
||||
AMS_ASSERT(m_tree);
|
||||
|
||||
/* Check for tree equality. */
|
||||
if (m_this != rhs.m_this) {
|
||||
if (m_tree != rhs.m_tree) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check for nil. */
|
||||
if (m_this->IsNil(m_index) && m_this->IsNil(rhs.m_index)) {
|
||||
if (m_tree->IsNil(m_index) && m_tree->IsNil(rhs.m_index)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -144,19 +144,19 @@ namespace ams::util {
|
|||
|
||||
constexpr IteratorMember &DereferenceImpl() const {
|
||||
/* Validate pre-conditions. */
|
||||
AMS_ASSERT(m_this);
|
||||
AMS_ASSERT(m_tree);
|
||||
|
||||
if (!m_this->IsNil(m_index)) {
|
||||
return m_this->m_nodes[m_index].m_data;
|
||||
if (!m_tree->IsNil(m_index)) {
|
||||
return m_tree->m_nodes[m_index].m_data;
|
||||
} else {
|
||||
AMS_ASSERT(false);
|
||||
return m_this->GetNode(std::numeric_limits<int>::max())->m_data;
|
||||
return m_tree->GetNode(std::numeric_limits<int>::max())->m_data;
|
||||
}
|
||||
}
|
||||
|
||||
constexpr ALWAYS_INLINE IteratorBase &IncrementImpl() {
|
||||
/* Validate pre-conditions. */
|
||||
AMS_ASSERT(m_this);
|
||||
AMS_ASSERT(m_tree);
|
||||
|
||||
this->OperateIndex(true);
|
||||
return *this;
|
||||
|
@ -164,7 +164,7 @@ namespace ams::util {
|
|||
|
||||
constexpr ALWAYS_INLINE IteratorBase &DecrementImpl() {
|
||||
/* Validate pre-conditions. */
|
||||
AMS_ASSERT(m_this);
|
||||
AMS_ASSERT(m_tree);
|
||||
|
||||
this->OperateIndex(false);
|
||||
return *this;
|
||||
|
@ -176,18 +176,18 @@ namespace ams::util {
|
|||
if (m_index == Index_BeforeBegin) {
|
||||
m_index = 0;
|
||||
} else {
|
||||
m_index = m_this->UncheckedPP(m_index);
|
||||
if (m_this->IsNil(m_index)) {
|
||||
m_index = m_tree->UncheckedPP(m_index);
|
||||
if (m_tree->IsNil(m_index)) {
|
||||
m_index = Index_AfterEnd;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* We're decrementing. */
|
||||
if (m_index == Index_AfterEnd) {
|
||||
m_index = static_cast<int>(m_this->size()) - 1;
|
||||
m_index = static_cast<int>(m_tree->size()) - 1;
|
||||
} else {
|
||||
m_index = m_this->UncheckedMM(m_index);
|
||||
if (m_this->IsNil(m_index)) {
|
||||
m_index = m_tree->UncheckedMM(m_index);
|
||||
if (m_tree->IsNil(m_index)) {
|
||||
m_index = Index_BeforeBegin;
|
||||
}
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ namespace ams::util {
|
|||
constexpr ALWAYS_INLINE ConstIterator(const FixedTree &tree, int index) : IteratorBase(std::addressof(tree), index) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE ConstIterator(const ConstIterator &rhs) = default;
|
||||
constexpr ALWAYS_INLINE ConstIterator(const Iterator &rhs) : IteratorBase(rhs.m_this, rhs.m_index) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE ConstIterator(const Iterator &rhs) : IteratorBase(rhs.m_tree, rhs.m_index) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE bool operator==(const ConstIterator &rhs) const {
|
||||
return this->IsEqualImpl(rhs);
|
||||
|
|
|
@ -36,13 +36,13 @@ namespace ams::util {
|
|||
private:
|
||||
friend class impl::IntrusiveListImpl;
|
||||
|
||||
IntrusiveListNode *prev;
|
||||
IntrusiveListNode *next;
|
||||
IntrusiveListNode *m_prev;
|
||||
IntrusiveListNode *m_next;
|
||||
public:
|
||||
constexpr ALWAYS_INLINE IntrusiveListNode() : prev(this), next(this) { /* ... */ }
|
||||
constexpr ALWAYS_INLINE IntrusiveListNode() : m_prev(this), m_next(this) { /* ... */ }
|
||||
|
||||
constexpr ALWAYS_INLINE bool IsLinked() const {
|
||||
return this->next != this;
|
||||
return m_next != this;
|
||||
}
|
||||
private:
|
||||
ALWAYS_INLINE void LinkPrev(IntrusiveListNode *node) {
|
||||
|
@ -53,11 +53,11 @@ namespace ams::util {
|
|||
|
||||
ALWAYS_INLINE void SplicePrev(IntrusiveListNode *first, IntrusiveListNode *last) {
|
||||
/* Splice a range into the list. */
|
||||
auto last_prev = last->prev;
|
||||
first->prev = this->prev;
|
||||
this->prev->next = first;
|
||||
last_prev->next = this;
|
||||
this->prev = last_prev;
|
||||
auto last_prev = last->m_prev;
|
||||
first->m_prev = m_prev;
|
||||
last_prev->m_next = this;
|
||||
m_prev->m_next = first;
|
||||
m_prev = last_prev;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void LinkNext(IntrusiveListNode *node) {
|
||||
|
@ -68,40 +68,40 @@ namespace ams::util {
|
|||
|
||||
ALWAYS_INLINE void SpliceNext(IntrusiveListNode *first, IntrusiveListNode *last) {
|
||||
/* Splice a range into the list. */
|
||||
auto last_prev = last->prev;
|
||||
first->prev = this;
|
||||
last_prev->next = next;
|
||||
this->next->prev = last_prev;
|
||||
this->next = first;
|
||||
auto last_prev = last->m_prev;
|
||||
first->m_prev = this;
|
||||
last_prev->m_next = m_next;
|
||||
m_next->m_prev = last_prev;
|
||||
m_next = first;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void Unlink() {
|
||||
this->Unlink(this->next);
|
||||
this->Unlink(m_next);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void Unlink(IntrusiveListNode *last) {
|
||||
/* Unlink a node from a next node. */
|
||||
auto last_prev = last->prev;
|
||||
this->prev->next = last;
|
||||
last->prev = this->prev;
|
||||
last_prev->next = this;
|
||||
this->prev = last_prev;
|
||||
auto last_prev = last->m_prev;
|
||||
m_prev->m_next = last;
|
||||
last->m_prev = m_prev;
|
||||
last_prev->m_next = this;
|
||||
m_prev = last_prev;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE IntrusiveListNode *GetPrev() {
|
||||
return this->prev;
|
||||
return m_prev;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const IntrusiveListNode *GetPrev() const {
|
||||
return this->prev;
|
||||
return m_prev;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE IntrusiveListNode *GetNext() {
|
||||
return this->next;
|
||||
return m_next;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const IntrusiveListNode *GetNext() const {
|
||||
return this->next;
|
||||
return m_next;
|
||||
}
|
||||
};
|
||||
/* DEPRECATED: static_assert(std::is_literal_type<IntrusiveListNode>::value); */
|
||||
|
@ -111,7 +111,7 @@ namespace ams::util {
|
|||
class IntrusiveListImpl {
|
||||
NON_COPYABLE(IntrusiveListImpl);
|
||||
private:
|
||||
IntrusiveListNode root_node;
|
||||
IntrusiveListNode m_root_node;
|
||||
public:
|
||||
template<bool Const>
|
||||
class Iterator;
|
||||
|
@ -137,12 +137,12 @@ namespace ams::util {
|
|||
using pointer = typename std::conditional<Const, IntrusiveListImpl::const_pointer, IntrusiveListImpl::pointer>::type;
|
||||
using reference = typename std::conditional<Const, IntrusiveListImpl::const_reference, IntrusiveListImpl::reference>::type;
|
||||
private:
|
||||
pointer node;
|
||||
pointer m_node;
|
||||
public:
|
||||
ALWAYS_INLINE explicit Iterator(pointer n) : node(n) { /* ... */ }
|
||||
ALWAYS_INLINE explicit Iterator(pointer n) : m_node(n) { /* ... */ }
|
||||
|
||||
ALWAYS_INLINE bool operator==(const Iterator &rhs) const {
|
||||
return this->node == rhs.node;
|
||||
return m_node == rhs.m_node;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool operator!=(const Iterator &rhs) const {
|
||||
|
@ -150,20 +150,20 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE pointer operator->() const {
|
||||
return this->node;
|
||||
return m_node;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE reference operator*() const {
|
||||
return *this->node;
|
||||
return *m_node;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Iterator &operator++() {
|
||||
this->node = this->node->next;
|
||||
m_node = m_node->m_next;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Iterator &operator--() {
|
||||
this->node = this->node->prev;
|
||||
m_node = m_node->m_prev;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -180,31 +180,31 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE operator Iterator<true>() const {
|
||||
return Iterator<true>(this->node);
|
||||
return Iterator<true>(m_node);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Iterator<false> GetNonConstIterator() const {
|
||||
return Iterator<false>(const_cast<IntrusiveListImpl::pointer>(this->node));
|
||||
return Iterator<false>(const_cast<IntrusiveListImpl::pointer>(m_node));
|
||||
}
|
||||
};
|
||||
public:
|
||||
constexpr ALWAYS_INLINE IntrusiveListImpl() : root_node() { /* ... */ }
|
||||
constexpr ALWAYS_INLINE IntrusiveListImpl() : m_root_node() { /* ... */ }
|
||||
|
||||
/* Iterator accessors. */
|
||||
ALWAYS_INLINE iterator begin() {
|
||||
return iterator(this->root_node.GetNext());
|
||||
return iterator(m_root_node.GetNext());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator begin() const {
|
||||
return const_iterator(this->root_node.GetNext());
|
||||
return const_iterator(m_root_node.GetNext());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE iterator end() {
|
||||
return iterator(std::addressof(this->root_node));
|
||||
return iterator(std::addressof(m_root_node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator end() const {
|
||||
return const_iterator(std::addressof(this->root_node));
|
||||
return const_iterator(std::addressof(m_root_node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE iterator iterator_to(reference v) {
|
||||
|
@ -221,7 +221,7 @@ namespace ams::util {
|
|||
|
||||
/* Content management. */
|
||||
ALWAYS_INLINE bool empty() const {
|
||||
return !this->root_node.IsLinked();
|
||||
return !m_root_node.IsLinked();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE size_type size() const {
|
||||
|
@ -229,35 +229,35 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE reference back() {
|
||||
return *this->root_node.GetPrev();
|
||||
return *m_root_node.GetPrev();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_reference back() const {
|
||||
return *this->root_node.GetPrev();
|
||||
return *m_root_node.GetPrev();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE reference front() {
|
||||
return *this->root_node.GetNext();
|
||||
return *m_root_node.GetNext();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_reference front() const {
|
||||
return *this->root_node.GetNext();
|
||||
return *m_root_node.GetNext();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void push_back(reference node) {
|
||||
this->root_node.LinkPrev(std::addressof(node));
|
||||
m_root_node.LinkPrev(std::addressof(node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void push_front(reference node) {
|
||||
this->root_node.LinkNext(std::addressof(node));
|
||||
m_root_node.LinkNext(std::addressof(node));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void pop_back() {
|
||||
this->root_node.GetPrev()->Unlink();
|
||||
m_root_node.GetPrev()->Unlink();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void pop_front() {
|
||||
this->root_node.GetNext()->Unlink();
|
||||
m_root_node.GetNext()->Unlink();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE iterator insert(const_iterator pos, reference node) {
|
||||
|
@ -315,7 +315,7 @@ namespace ams::util {
|
|||
class IntrusiveList {
|
||||
NON_COPYABLE(IntrusiveList);
|
||||
private:
|
||||
impl::IntrusiveListImpl impl;
|
||||
impl::IntrusiveListImpl m_impl;
|
||||
public:
|
||||
template<bool Const>
|
||||
class Iterator;
|
||||
|
@ -345,16 +345,16 @@ namespace ams::util {
|
|||
using pointer = typename std::conditional<Const, IntrusiveList::const_pointer, IntrusiveList::pointer>::type;
|
||||
using reference = typename std::conditional<Const, IntrusiveList::const_reference, IntrusiveList::reference>::type;
|
||||
private:
|
||||
ImplIterator iterator;
|
||||
ImplIterator m_iterator;
|
||||
private:
|
||||
explicit ALWAYS_INLINE Iterator(ImplIterator it) : iterator(it) { /* ... */ }
|
||||
explicit ALWAYS_INLINE Iterator(ImplIterator it) : m_iterator(it) { /* ... */ }
|
||||
|
||||
ALWAYS_INLINE ImplIterator GetImplIterator() const {
|
||||
return this->iterator;
|
||||
return m_iterator;
|
||||
}
|
||||
public:
|
||||
ALWAYS_INLINE bool operator==(const Iterator &rhs) const {
|
||||
return this->iterator == rhs.iterator;
|
||||
return m_iterator == rhs.m_iterator;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE bool operator!=(const Iterator &rhs) const {
|
||||
|
@ -362,37 +362,37 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE pointer operator->() const {
|
||||
return std::addressof(Traits::GetParent(*this->iterator));
|
||||
return std::addressof(Traits::GetParent(*m_iterator));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE reference operator*() const {
|
||||
return Traits::GetParent(*this->iterator);
|
||||
return Traits::GetParent(*m_iterator);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Iterator &operator++() {
|
||||
++this->iterator;
|
||||
++m_iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Iterator &operator--() {
|
||||
--this->iterator;
|
||||
--m_iterator;
|
||||
return *this;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Iterator operator++(int) {
|
||||
const Iterator it{*this};
|
||||
++this->iterator;
|
||||
++m_iterator;
|
||||
return it;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE Iterator operator--(int) {
|
||||
const Iterator it{*this};
|
||||
--this->iterator;
|
||||
--m_iterator;
|
||||
return it;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE operator Iterator<true>() const {
|
||||
return Iterator<true>(this->iterator);
|
||||
return Iterator<true>(m_iterator);
|
||||
}
|
||||
};
|
||||
private:
|
||||
|
@ -412,23 +412,23 @@ namespace ams::util {
|
|||
return Traits::GetParent(node);
|
||||
}
|
||||
public:
|
||||
constexpr ALWAYS_INLINE IntrusiveList() : impl() { /* ... */ }
|
||||
constexpr ALWAYS_INLINE IntrusiveList() : m_impl() { /* ... */ }
|
||||
|
||||
/* Iterator accessors. */
|
||||
ALWAYS_INLINE iterator begin() {
|
||||
return iterator(this->impl.begin());
|
||||
return iterator(m_impl.begin());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator begin() const {
|
||||
return const_iterator(this->impl.begin());
|
||||
return const_iterator(m_impl.begin());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE iterator end() {
|
||||
return iterator(this->impl.end());
|
||||
return iterator(m_impl.end());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator end() const {
|
||||
return const_iterator(this->impl.end());
|
||||
return const_iterator(m_impl.end());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator cbegin() const {
|
||||
|
@ -464,82 +464,82 @@ namespace ams::util {
|
|||
}
|
||||
|
||||
ALWAYS_INLINE iterator iterator_to(reference v) {
|
||||
return iterator(this->impl.iterator_to(GetNode(v)));
|
||||
return iterator(m_impl.iterator_to(GetNode(v)));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_iterator iterator_to(const_reference v) const {
|
||||
return const_iterator(this->impl.iterator_to(GetNode(v)));
|
||||
return const_iterator(m_impl.iterator_to(GetNode(v)));
|
||||
}
|
||||
|
||||
/* Content management. */
|
||||
ALWAYS_INLINE bool empty() const {
|
||||
return this->impl.empty();
|
||||
return m_impl.empty();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE size_type size() const {
|
||||
return this->impl.size();
|
||||
return m_impl.size();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE reference back() {
|
||||
AMS_ASSERT(!this->impl.empty());
|
||||
return GetParent(this->impl.back());
|
||||
AMS_ASSERT(!m_impl.empty());
|
||||
return GetParent(m_impl.back());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_reference back() const {
|
||||
AMS_ASSERT(!this->impl.empty());
|
||||
return GetParent(this->impl.back());
|
||||
AMS_ASSERT(!m_impl.empty());
|
||||
return GetParent(m_impl.back());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE reference front() {
|
||||
AMS_ASSERT(!this->impl.empty());
|
||||
return GetParent(this->impl.front());
|
||||
AMS_ASSERT(!m_impl.empty());
|
||||
return GetParent(m_impl.front());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const_reference front() const {
|
||||
AMS_ASSERT(!this->impl.empty());
|
||||
return GetParent(this->impl.front());
|
||||
AMS_ASSERT(!m_impl.empty());
|
||||
return GetParent(m_impl.front());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void push_back(reference ref) {
|
||||
this->impl.push_back(GetNode(ref));
|
||||
m_impl.push_back(GetNode(ref));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void push_front(reference ref) {
|
||||
this->impl.push_front(GetNode(ref));
|
||||
m_impl.push_front(GetNode(ref));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void pop_back() {
|
||||
AMS_ASSERT(!this->impl.empty());
|
||||
this->impl.pop_back();
|
||||
AMS_ASSERT(!m_impl.empty());
|
||||
m_impl.pop_back();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void pop_front() {
|
||||
AMS_ASSERT(!this->impl.empty());
|
||||
this->impl.pop_front();
|
||||
AMS_ASSERT(!m_impl.empty());
|
||||
m_impl.pop_front();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE iterator insert(const_iterator pos, reference ref) {
|
||||
return iterator(this->impl.insert(pos.GetImplIterator(), GetNode(ref)));
|
||||
return iterator(m_impl.insert(pos.GetImplIterator(), GetNode(ref)));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void splice(const_iterator pos, IntrusiveList &o) {
|
||||
this->impl.splice(pos.GetImplIterator(), o.impl);
|
||||
m_impl.splice(pos.GetImplIterator(), o.m_impl);
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void splice(const_iterator pos, IntrusiveList &o, const_iterator first) {
|
||||
this->impl.splice(pos.GetImplIterator(), o.impl, first.GetImplIterator());
|
||||
m_impl.splice(pos.GetImplIterator(), o.m_impl, first.GetImplIterator());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void splice(const_iterator pos, IntrusiveList &o, const_iterator first, const_iterator last) {
|
||||
this->impl.splice(pos.GetImplIterator(), o.impl, first.GetImplIterator(), last.GetImplIterator());
|
||||
m_impl.splice(pos.GetImplIterator(), o.m_impl, first.GetImplIterator(), last.GetImplIterator());
|
||||
}
|
||||
|
||||
ALWAYS_INLINE iterator erase(const_iterator pos) {
|
||||
return iterator(this->impl.erase(pos.GetImplIterator()));
|
||||
return iterator(m_impl.erase(pos.GetImplIterator()));
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void clear() {
|
||||
this->impl.clear();
|
||||
m_impl.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -51,20 +51,20 @@ namespace ams::util {
|
|||
return value ^ (value >> 30);
|
||||
}
|
||||
private:
|
||||
State state;
|
||||
State m_state;
|
||||
private:
|
||||
/* Internal API. */
|
||||
void FinalizeInitialization() {
|
||||
const u32 state0 = this->state.data[0] & TopBitmask;
|
||||
const u32 state1 = this->state.data[1];
|
||||
const u32 state2 = this->state.data[2];
|
||||
const u32 state3 = this->state.data[3];
|
||||
const u32 state0 = m_state.data[0] & TopBitmask;
|
||||
const u32 state1 = m_state.data[1];
|
||||
const u32 state2 = m_state.data[2];
|
||||
const u32 state3 = m_state.data[3];
|
||||
|
||||
if (state0 == 0 && state1 == 0 && state2 == 0 && state3 == 0) {
|
||||
this->state.data[0] = 'T';
|
||||
this->state.data[1] = 'I';
|
||||
this->state.data[2] = 'N';
|
||||
this->state.data[3] = 'Y';
|
||||
m_state.data[0] = 'T';
|
||||
m_state.data[1] = 'I';
|
||||
m_state.data[2] = 'N';
|
||||
m_state.data[3] = 'Y';
|
||||
}
|
||||
|
||||
for (int i = 0; i < NumDiscardedInitOutputs; i++) {
|
||||
|
@ -102,42 +102,42 @@ namespace ams::util {
|
|||
state2 ^= y;
|
||||
}
|
||||
public:
|
||||
constexpr TinyMT() : state() { /* ... */ }
|
||||
constexpr TinyMT() : m_state() { /* ... */ }
|
||||
|
||||
/* Public API. */
|
||||
|
||||
/* Initialization. */
|
||||
void Initialize(u32 seed) {
|
||||
this->state.data[0] = seed;
|
||||
this->state.data[1] = ParamMat1;
|
||||
this->state.data[2] = ParamMat2;
|
||||
this->state.data[3] = ParamTmat;
|
||||
m_state.data[0] = seed;
|
||||
m_state.data[1] = ParamMat1;
|
||||
m_state.data[2] = ParamMat2;
|
||||
m_state.data[3] = ParamTmat;
|
||||
|
||||
for (int i = 1; i < MinimumInitIterations; i++) {
|
||||
const u32 mixed = XorByShifted30(this->state.data[(i - 1) % NumStateWords]);
|
||||
this->state.data[i % NumStateWords] ^= mixed * ParamMult + i;
|
||||
const u32 mixed = XorByShifted30(m_state.data[(i - 1) % NumStateWords]);
|
||||
m_state.data[i % NumStateWords] ^= mixed * ParamMult + i;
|
||||
}
|
||||
|
||||
this->FinalizeInitialization();
|
||||
}
|
||||
|
||||
void Initialize(const u32 *seed, int seed_count) {
|
||||
this->state.data[0] = 0;
|
||||
this->state.data[1] = ParamMat1;
|
||||
this->state.data[2] = ParamMat2;
|
||||
this->state.data[3] = ParamTmat;
|
||||
m_state.data[0] = 0;
|
||||
m_state.data[1] = ParamMat1;
|
||||
m_state.data[2] = ParamMat2;
|
||||
m_state.data[3] = ParamTmat;
|
||||
|
||||
{
|
||||
const int num_init_iterations = std::max(seed_count + 1, MinimumInitIterations) - 1;
|
||||
|
||||
GenerateInitialValuePlus(std::addressof(this->state), 0, seed_count);
|
||||
GenerateInitialValuePlus(std::addressof(m_state), 0, seed_count);
|
||||
|
||||
for (int i = 0; i < num_init_iterations; i++) {
|
||||
GenerateInitialValuePlus(std::addressof(this->state), (i + 1) % NumStateWords, (i < seed_count) ? seed[i] : 0);
|
||||
GenerateInitialValuePlus(std::addressof(m_state), (i + 1) % NumStateWords, (i < seed_count) ? seed[i] : 0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < static_cast<int>(NumStateWords); i++) {
|
||||
GenerateInitialValueXor(std::addressof(this->state), (i + 1 + num_init_iterations) % NumStateWords);
|
||||
GenerateInitialValueXor(std::addressof(m_state), (i + 1 + num_init_iterations) % NumStateWords);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,11 +146,11 @@ namespace ams::util {
|
|||
|
||||
/* State management. */
|
||||
void GetState(TinyMT::State *out) const {
|
||||
std::memcpy(out->data, this->state.data, sizeof(this->state));
|
||||
std::memcpy(out->data, m_state.data, sizeof(m_state));
|
||||
}
|
||||
|
||||
void SetState(const TinyMT::State *state) {
|
||||
std::memcpy(this->state.data, state->data, sizeof(this->state));
|
||||
std::memcpy(m_state.data, state->data, sizeof(m_state));
|
||||
}
|
||||
|
||||
/* Random generation. */
|
||||
|
@ -185,13 +185,13 @@ namespace ams::util {
|
|||
|
||||
NOINLINE u32 GenerateRandomU32() {
|
||||
/* Advance state. */
|
||||
const u32 x0 = (this->state.data[0] & TopBitmask) ^ this->state.data[1] ^ this->state.data[2];
|
||||
const u32 y0 = this->state.data[3];
|
||||
const u32 x0 = (m_state.data[0] & TopBitmask) ^ m_state.data[1] ^ m_state.data[2];
|
||||
const u32 y0 = m_state.data[3];
|
||||
const u32 x1 = x0 ^ (x0 << 1);
|
||||
const u32 y1 = y0 ^ (y0 >> 1) ^ x1;
|
||||
|
||||
const u32 state0 = this->state.data[1];
|
||||
u32 state1 = this->state.data[2];
|
||||
const u32 state0 = m_state.data[1];
|
||||
u32 state1 = m_state.data[2];
|
||||
u32 state2 = x1 ^ (y1 << 10);
|
||||
const u32 state3 = y1;
|
||||
|
||||
|
@ -200,10 +200,10 @@ namespace ams::util {
|
|||
state2 ^= ParamMat2;
|
||||
}
|
||||
|
||||
this->state.data[0] = state0;
|
||||
this->state.data[1] = state1;
|
||||
this->state.data[2] = state2;
|
||||
this->state.data[3] = state3;
|
||||
m_state.data[0] = state0;
|
||||
m_state.data[1] = state1;
|
||||
m_state.data[2] = state2;
|
||||
m_state.data[3] = state3;
|
||||
|
||||
/* Temper. */
|
||||
const u32 t1 = state0 + (state2 >> 8);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue