From a4d2179378a79cbdcacc8e8a1ddcfe92f0eaa8cd Mon Sep 17 00:00:00 2001 From: disinvite Date: Wed, 13 Mar 2024 20:52:43 -0400 Subject: [PATCH] Naming fix --- LEGO1/omni/include/mxbitset.h | 53 ++++++++++++++++--------------- LEGO1/omni/include/mxmemorypool.h | 16 +++++----- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/LEGO1/omni/include/mxbitset.h b/LEGO1/omni/include/mxbitset.h index 1185004a..a1f36248 100644 --- a/LEGO1/omni/include/mxbitset.h +++ b/LEGO1/omni/include/mxbitset.h @@ -11,83 +11,84 @@ template class MxBitset { public: - MxBitset() { _Tidy(); } + MxBitset() { Tidy(); } - class reference { + class Reference { friend class MxBitset; public: - reference& flip() + Reference& Flip() { - m_bitset->flip(m_offset); + m_bitset->Flip(m_offset); return (*this); } - bool operator~() const { return (!m_bitset->test(m_offset)); } - operator bool() const { return (m_bitset->test(m_offset)); } + bool operator~() const { return (!m_bitset->Test(m_offset)); } + operator bool() const { return (m_bitset->Test(m_offset)); } private: - reference(MxBitset& _X, size_t _P) : m_bitset(&_X), m_offset(_P) {} + Reference(MxBitset& p_bitset, size_t p_offset) : m_bitset(&p_bitset), m_offset(p_offset) {} MxBitset* m_bitset; size_t m_offset; }; - reference operator[](size_t p_bit) { return (reference(*this, p_bit)); } + Reference operator[](size_t p_bit) { return (Reference(*this, p_bit)); } - MxBitset& flip(size_t p_bit) + MxBitset& Flip(size_t p_bit) { if (N <= p_bit) { - _Xran(); + Xran(); } - m_blocks[p_bit / _bits_per_block] ^= 1 << p_bit % _bits_per_block; + m_blocks[p_bit / e_bitsPerBlock] ^= 1 << p_bit % e_bitsPerBlock; return (*this); } - size_t count() + size_t Count() { // debug only return 0; } - bool test(MxU32 p_bit) + bool Test(MxU32 p_bit) { if (p_bit >= N) { - _Xran(); + Xran(); } - return (m_blocks[p_bit / _bits_per_block] & (1 << p_bit % _bits_per_block)) != 0; + return (m_blocks[p_bit / e_bitsPerBlock] & (1 << p_bit % e_bitsPerBlock)) != 0; } - MxU32 size() const { return N; } + MxU32 Size() const { return N; } private: - void _Tidy(MxU32 p_value = 0) + void Tidy(MxU32 p_value = 0) { - for (MxS32 i = _blocks_required; i >= 0; --i) { + for (MxS32 i = e_blocksRequired; i >= 0; --i) { m_blocks[i] = p_value; } // No need to trim if all bits were zeroed out if (p_value != 0) { - _Trim(); + Trim(); } } // Apply bit mask to most significant block - void _Trim() + void Trim() { - if (N % _bits_per_block != 0) { - m_blocks[_blocks_required] &= ((1 << (N % _bits_per_block)) - 1); + if (N % e_bitsPerBlock != 0) { + m_blocks[e_blocksRequired] &= ((1 << (N % e_bitsPerBlock)) - 1); } } - void _Xran() { assert("invalid MxBitset position" == NULL); } + void Xran() { assert("invalid MxBitset position" == NULL); } + // Not a real enum. This is how STL BITSET defines these constants. enum { - _bits_per_block = CHAR_BIT * sizeof(MxU32), - _blocks_required = N == 0 ? 0 : (N - 1) / _bits_per_block + e_bitsPerBlock = CHAR_BIT * sizeof(MxU32), + e_blocksRequired = N == 0 ? 0 : (N - 1) / e_bitsPerBlock }; - MxU32 m_blocks[_blocks_required + 1]; // 0x0 + MxU32 m_blocks[e_blocksRequired + 1]; // 0x0 }; #endif // MXBITSET_H diff --git a/LEGO1/omni/include/mxmemorypool.h b/LEGO1/omni/include/mxmemorypool.h index 8916c63a..6085c670 100644 --- a/LEGO1/omni/include/mxmemorypool.h +++ b/LEGO1/omni/include/mxmemorypool.h @@ -17,7 +17,7 @@ class MxMemoryPool { MxU8* Get(); void Release(MxU8*); - MxU32 GetPoolSize() const { return m_blockRef.size(); } + MxU32 GetPoolSize() const { return m_blockRef.Size(); } private: MxU8* m_pool; @@ -30,7 +30,7 @@ MxResult MxMemoryPool::Allocate() { assert(m_pool == NULL); assert(m_blockSize); - assert(m_blockRef.size()); + assert(m_blockRef.Size()); m_pool = new MxU8[GetPoolSize() * m_blockSize * 1024]; assert(m_pool); @@ -43,16 +43,16 @@ MxU8* MxMemoryPool::Get() { assert(m_pool != NULL); assert(m_blockSize); - assert(m_blockRef.size()); + assert(m_blockRef.Size()); for (MxU32 i = 0; i < GetPoolSize(); i++) { if (!m_blockRef[i]) { - m_blockRef[i].flip(); + m_blockRef[i].Flip(); #ifdef _DEBUG // TODO: This is actually some debug print function, but // we just need any func with variatic args to eliminate diff noise. - printf("Get> %d pool: busy %d blocks\n", m_blockSize, m_blockRef.count()); + printf("Get> %d pool: busy %d blocks\n", m_blockSize, m_blockRef.Count()); #endif return &m_pool[i * m_blockSize * 1024]; @@ -67,7 +67,7 @@ void MxMemoryPool::Release(MxU8* p_buf) { assert(m_pool != NULL); assert(m_blockSize); - assert(m_blockRef.size()); + assert(m_blockRef.Size()); MxU32 i = (MxU32) (p_buf - m_pool) / (m_blockSize * 1024); @@ -75,11 +75,11 @@ void MxMemoryPool::Release(MxU8* p_buf) assert(m_blockRef[i]); if (m_blockRef[i]) { - m_blockRef[i].flip(); + m_blockRef[i].Flip(); } #ifdef _DEBUG - printf("Release> %d pool: busy %d blocks\n", m_blockSize, m_blockRef.count()); + printf("Release> %d pool: busy %d blocks\n", m_blockSize, m_blockRef.Count()); #endif }