From cc5b58ef68ada23449abb21acef4283cc7679b1d Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Sun, 23 Dec 2012 17:21:38 -0500 Subject: [PATCH] Copied bitvec fixes for GCC from hl2sdk-swarm. --- public/bitvec.h | 74 ++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/public/bitvec.h b/public/bitvec.h index c14a4105..d391b669 100644 --- a/public/bitvec.h +++ b/public/bitvec.h @@ -574,8 +574,8 @@ inline CBitVecAccessor CBitVecT::operator[](int i) template inline void CBitVecT::Init( int val ) { - if ( CBitVecT::Base() ) - memset( CBitVecT::Base(), ( val ) ? 0xff : 0, CBitVecT::GetNumDWords() * sizeof(int) ); + if ( this->Base() ) + memset( this->Base(), ( val ) ? 0xff : 0, this->GetNumDWords() * sizeof(int) ); } //----------------------------------------------------------------------------- @@ -636,7 +636,7 @@ inline void CBitVecT::Clear(int bitNum) template inline void CBitVecT::Set( int bitNum, bool bNewVal ) { - uint32 *pInt = CBitVecT::Base() + BitVec_Int( bitNum ); + uint32 *pInt = this->Base() + BitVec_Int( bitNum ); uint32 bitMask = BitVec_Bit( bitNum ); if ( bNewVal ) { @@ -653,7 +653,7 @@ inline void CBitVecT::Set( int bitNum, bool bNewVal ) template inline void CBitVecT::Set( uint32 offset, uint32 mask ) { - uint32 *pInt = CBitVecT::Base() + offset; + uint32 *pInt = this->Base() + offset; *pInt |= mask; } @@ -662,7 +662,7 @@ inline void CBitVecT::Set( uint32 offset, uint32 mask ) template inline void CBitVecT::Clear( uint32 offset, uint32 mask ) { - uint32 *pInt = CBitVecT::Base() + offset; + uint32 *pInt = this->Base() + offset; *pInt &= ~mask; } @@ -671,7 +671,7 @@ inline void CBitVecT::Clear( uint32 offset, uint32 mask ) template inline uint32 CBitVecT::Get( uint32 offset, uint32 mask ) { - uint32 *pInt = CBitVecT::Base() + offset; + uint32 *pInt = this->Base() + offset; return ( *pInt & mask ); } @@ -687,10 +687,10 @@ inline void CBitVecT::And(const CBitVecT &addStr, CBitVecT *out) const ValidateOperand( *out ); uint32 * pDest = out->Base(); - const uint32 *pOperand1 = CBitVecT::Base(); + const uint32 *pOperand1 = this->Base(); const uint32 *pOperand2 = addStr.Base(); - for (int i = CBitVecT::GetNumDWords() - 1; i >= 0 ; --i) + for (int i = this->GetNumDWords() - 1; i >= 0 ; --i) { pDest[i] = pOperand1[i] & pOperand2[i]; } @@ -708,10 +708,10 @@ inline void CBitVecT::Or(const CBitVecT &orStr, CBitVecT *out) const ValidateOperand( *out ); uint32 * pDest = out->Base(); - const uint32 *pOperand1 = CBitVecT::Base(); + const uint32 *pOperand1 = this->Base(); const uint32 *pOperand2 = orStr.Base(); - for (int i = CBitVecT::GetNumDWords() - 1; i >= 0; --i) + for (int i = this->GetNumDWords() - 1; i >= 0; --i) { pDest[i] = pOperand1[i] | pOperand2[i]; } @@ -726,10 +726,10 @@ template inline void CBitVecT::Xor(const CBitVecT &xorStr, CBitVecT *out) const { uint32 * pDest = out->Base(); - const uint32 *pOperand1 = CBitVecT::Base(); + const uint32 *pOperand1 = this->Base(); const uint32 *pOperand2 = xorStr.Base(); - for (int i = CBitVecT::GetNumDWords() - 1; i >= 0; --i) + for (int i = this->GetNumDWords() - 1; i >= 0; --i) { pDest[i] = pOperand1[i] ^ pOperand2[i]; } @@ -746,9 +746,9 @@ inline void CBitVecT::Not(CBitVecT *out) const ValidateOperand( *out ); uint32 * pDest = out->Base(); - const uint32 *pOperand = CBitVecT::Base(); + const uint32 *pOperand = this->Base(); - for (int i = CBitVecT::GetNumDWords() - 1; i >= 0; --i) + for (int i = this->GetNumDWords() - 1; i >= 0; --i) { pDest[i] = ~(pOperand[i]); } @@ -762,12 +762,12 @@ inline void CBitVecT::Not(CBitVecT *out) const template inline void CBitVecT::CopyTo(CBitVecT *out) const { - out->Resize( CBitVecT::GetNumBits() ); + out->Resize( this->GetNumBits() ); ValidateOperand( *out ); Assert( out != this ); - memcpy( out->Base(), CBitVecT::Base(), CBitVecT::GetNumDWords() * sizeof( int ) ); + memcpy( out->Base(), this->Base(), this->GetNumDWords() * sizeof( int ) ); } //----------------------------------------------------------------------------- @@ -781,11 +781,11 @@ inline bool CBitVecT::IsAllClear(void) const // Number of available bits may be more than the number // actually used, so make sure to mask out unused bits // before testing for zero - (const_cast(this))->Base()[CBitVecT::GetNumDWords()-1] &= CBitVecT::GetEndMask(); // external semantics of const retained + (const_cast(this))->Base()[this->GetNumDWords()-1] &= CBitVecT::GetEndMask(); // external semantics of const retained - for (int i = CBitVecT::GetNumDWords() - 1; i >= 0; --i) + for (int i = this->GetNumDWords() - 1; i >= 0; --i) { - if ( CBitVecT::Base()[i] !=0 ) + if ( this->Base()[i] !=0 ) { return false; } @@ -804,11 +804,11 @@ inline bool CBitVecT::IsAllSet(void) const // Number of available bits may be more than the number // actually used, so make sure to mask out unused bits // before testing for set bits - (const_cast(this))->Base()[CBitVecT::GetNumDWords()-1] |= ~CBitVecT::GetEndMask(); // external semantics of const retained + (const_cast(this))->Base()[this->GetNumDWords()-1] |= ~CBitVecT::GetEndMask(); // external semantics of const retained - for (int i = CBitVecT::GetNumDWords() - 1; i >= 0; --i) + for (int i = this->GetNumDWords() - 1; i >= 0; --i) { - if ( CBitVecT::Base()[i] != ~0 ) + if ( this->Base()[i] != ~0 ) { return false; } @@ -824,8 +824,8 @@ inline bool CBitVecT::IsAllSet(void) const template inline void CBitVecT::SetAll(void) { - if ( CBitVecT::Base() ) - memset( CBitVecT::Base(), 0xff, CBitVecT::GetNumDWords() * sizeof(int) ); + if ( this->Base() ) + memset( this->Base(), 0xff, this->GetNumDWords() * sizeof(int) ); } //----------------------------------------------------------------------------- @@ -836,8 +836,8 @@ inline void CBitVecT::SetAll(void) template inline void CBitVecT::ClearAll(void) { - if ( CBitVecT::Base() ) - memset( CBitVecT::Base(), 0, CBitVecT::GetNumDWords() * sizeof(int) ); + if ( this->Base() ) + memset( this->Base(), 0, this->GetNumDWords() * sizeof(int) ); } //----------------------------------------------------------------------------- @@ -849,12 +849,12 @@ inline void CBitVecT::Copy( const CBitVecT &other, int nBits nBits = other.GetNumBits(); } - CBitVecT::Resize( nBits ); + this->Resize( nBits ); ValidateOperand( other ); Assert( &other != this ); - memcpy( CBitVecT::Base(), other.Base(), CBitVecT::GetNumDWords() * sizeof( uint32 ) ); + memcpy( this->Base(), other.Base(), this->GetNumDWords() * sizeof( uint32 ) ); } //----------------------------------------------------------------------------- @@ -863,7 +863,7 @@ inline bool CBitVecT::Compare( const CBitVecT &other, int nB { if ( nBits == - 1 ) { - if ( other.GetNumBits() != CBitVecT::GetNumBits() ) + if ( other.GetNumBits() != this->GetNumBits() ) { return false; } @@ -871,33 +871,33 @@ inline bool CBitVecT::Compare( const CBitVecT &other, int nB nBits = other.GetNumBits(); } - if ( nBits > other.GetNumBits() || nBits > CBitVecT::GetNumBits() ) + if ( nBits > other.GetNumBits() || nBits > this->GetNumBits() ) { return false; } - (const_cast(this))->Base()[CBitVecT::GetNumDWords()-1] &= CBitVecT::GetEndMask(); // external semantics of const retained - (const_cast(&other))->Base()[CBitVecT::GetNumDWords()-1] &= other.CBitVecT::GetEndMask(); // external semantics of const retained + (const_cast(this))->Base()[this->GetNumDWords()-1] &= CBitVecT::GetEndMask(); // external semantics of const retained + (const_cast(&other))->Base()[this->GetNumDWords()-1] &= other.CBitVecT::GetEndMask(); // external semantics of const retained int nBytes = PAD_NUMBER( nBits, 8 ) >> 3; - return ( memcmp( CBitVecT::Base(), other.Base(), nBytes ) == 0 ); + return ( memcmp( this->Base(), other.Base(), nBytes ) == 0 ); } //----------------------------------------------------------------------------- template inline uint32 CBitVecT::GetDWord(int i) const { - Assert(i >= 0 && i < CBitVecT::GetNumDWords()); - return CBitVecT::Base()[i]; + Assert(i >= 0 && i < this->GetNumDWords()); + return this->Base()[i]; } //----------------------------------------------------------------------------- template inline void CBitVecT::SetDWord(int i, uint32 val) { - Assert(i >= 0 && i < CBitVecT::GetNumDWords()); - CBitVecT::Base()[i] = val; + Assert(i >= 0 && i < this->GetNumDWords()); + this->Base()[i] = val; } //-----------------------------------------------------------------------------