diff options
Diffstat (limited to 'core/src/fxcrt')
-rw-r--r-- | core/src/fxcrt/extension.h | 112 | ||||
-rw-r--r-- | core/src/fxcrt/fx_arabic.cpp | 12 | ||||
-rw-r--r-- | core/src/fxcrt/fx_arabic.h | 8 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_array.cpp | 44 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_bstring.cpp | 4 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_buffer.cpp | 48 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_coords.cpp | 36 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_gcc.cpp | 4 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_maps.cpp | 52 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_util.cpp | 80 | ||||
-rw-r--r-- | core/src/fxcrt/fx_basic_wstring.cpp | 4 | ||||
-rw-r--r-- | core/src/fxcrt/fx_extension.cpp | 28 | ||||
-rw-r--r-- | core/src/fxcrt/fx_unicode.cpp | 12 | ||||
-rw-r--r-- | core/src/fxcrt/fx_xml_parser.cpp | 102 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_platforms.cpp | 40 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_platforms.h | 8 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_posix.cpp | 38 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_posix.h | 8 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_windows.cpp | 40 | ||||
-rw-r--r-- | core/src/fxcrt/fxcrt_windows.h | 8 | ||||
-rw-r--r-- | core/src/fxcrt/xml_int.h | 38 |
21 files changed, 363 insertions, 363 deletions
diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index ba42916599..2d7f3ae220 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -14,8 +14,8 @@ class IFXCRT_FileAccess { public: virtual ~IFXCRT_FileAccess() {} - virtual FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) = 0; - virtual FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) = 0; + virtual bool Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) = 0; + virtual bool Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) = 0; virtual void Close() = 0; virtual void Release() = 0; virtual FX_FILESIZE GetSize() const = 0; @@ -25,14 +25,14 @@ public: virtual size_t Write(const void* pBuffer, size_t szBuffer) = 0; virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) = 0; virtual size_t WritePos(const void* pBuffer, size_t szBuffer, FX_FILESIZE pos) = 0; - virtual FX_BOOL Flush() = 0; - virtual FX_BOOL Truncate(FX_FILESIZE szFile) = 0; + virtual bool Flush() = 0; + virtual bool Truncate(FX_FILESIZE szFile) = 0; }; IFXCRT_FileAccess* FXCRT_FileAccess_Create(); class CFX_CRTFileStream final : public IFX_FileStream { public: - CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1), m_bUseRange(FALSE), m_nOffset(0), m_nSize(0) {} + CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1), m_bUseRange(false), m_nOffset(0), m_nSize(0) {} ~CFX_CRTFileStream() { if (m_pFile) { @@ -55,7 +55,7 @@ public: { return m_bUseRange ? m_nSize : m_pFile->GetSize(); } - virtual FX_BOOL IsEOF() override + virtual bool IsEOF() override { return GetPosition() >= GetSize(); } @@ -67,42 +67,42 @@ public: } return pos; } - virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) override + virtual bool SetRange(FX_FILESIZE offset, FX_FILESIZE size) override { if (offset < 0 || size < 0) { - return FALSE; + return false; } FX_SAFE_FILESIZE pos = size; pos += offset; if (!pos.IsValid() || pos.ValueOrDie() > m_pFile->GetSize()) { - return FALSE; + return false; } m_nOffset = offset, m_nSize = size; - m_bUseRange = TRUE; + m_bUseRange = true; m_pFile->SetPosition(m_nOffset); - return TRUE; + return true; } virtual void ClearRange() override { - m_bUseRange = FALSE; + m_bUseRange = false; } - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override + virtual bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (m_bUseRange && offset < 0) { - return FALSE; + return false; } FX_SAFE_FILESIZE pos = offset; if (m_bUseRange) { pos += m_nOffset; if (!pos.IsValid() || pos.ValueOrDie() > (size_t)GetSize()) { - return FALSE; + return false; } } - return (FX_BOOL)m_pFile->ReadPos(buffer, size, pos.ValueOrDie()); + return (bool)m_pFile->ReadPos(buffer, size, pos.ValueOrDie()); } virtual size_t ReadBlock(void* buffer, size_t size) override { @@ -114,20 +114,20 @@ public: } return m_pFile->Read(buffer, size); } - virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override + virtual bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override { if (m_bUseRange) { offset += m_nOffset; } - return (FX_BOOL)m_pFile->WritePos(buffer, size, offset); + return (bool)m_pFile->WritePos(buffer, size, offset); } - virtual FX_BOOL Flush() override + virtual bool Flush() override { return m_pFile->Flush(); } IFXCRT_FileAccess* m_pFile; FX_DWORD m_dwCount; - FX_BOOL m_bUseRange; + bool m_bUseRange; FX_FILESIZE m_nOffset; FX_FILESIZE m_nSize; }; @@ -137,23 +137,23 @@ public: class CFX_MemoryStream final : public IFX_MemoryStream { public: - CFX_MemoryStream(FX_BOOL bConsecutive) + CFX_MemoryStream(bool bConsecutive) : m_dwCount(1) , m_nTotalSize(0) , m_nCurSize(0) , m_nCurPos(0) , m_nGrowSize(FX_MEMSTREAM_BlockSize) - , m_bUseRange(FALSE) + , m_bUseRange(false) { m_dwFlags = FX_MEMSTREAM_TakeOver | (bConsecutive ? FX_MEMSTREAM_Consecutive : 0); } - CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver) + CFX_MemoryStream(uint8_t* pBuffer, size_t nSize, bool bTakeOver) : m_dwCount(1) , m_nTotalSize(nSize) , m_nCurSize(nSize) , m_nCurPos(0) , m_nGrowSize(FX_MEMSTREAM_BlockSize) - , m_bUseRange(FALSE) + , m_bUseRange(false) { m_Blocks.Add(pBuffer); m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0); @@ -184,7 +184,7 @@ public: { return m_bUseRange ? (FX_FILESIZE) m_nSize : (FX_FILESIZE)m_nCurSize; } - virtual FX_BOOL IsEOF() override + virtual bool IsEOF() override { return m_nCurPos >= (size_t)GetSize(); } @@ -196,30 +196,30 @@ public: } return pos; } - virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) override + virtual bool SetRange(FX_FILESIZE offset, FX_FILESIZE size) override { if (offset < 0 || size < 0) { - return FALSE; + return false; } FX_SAFE_FILESIZE range = size; range += offset; if (!range.IsValid() || range.ValueOrDie() > m_nCurSize) { - return FALSE; + return false; } m_nOffset = (size_t)offset, m_nSize = (size_t)size; - m_bUseRange = TRUE; + m_bUseRange = true; m_nCurPos = m_nOffset; - return TRUE; + return true; } virtual void ClearRange() override { - m_bUseRange = FALSE; + m_bUseRange = false; } - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override + virtual bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override { if (!buffer || !size) { - return FALSE; + return false; } FX_SAFE_FILESIZE safeOffset = offset; @@ -228,7 +228,7 @@ public: } if (!safeOffset.IsValid()) { - return FALSE; + return false; } offset = safeOffset.ValueOrDie(); @@ -236,13 +236,13 @@ public: FX_SAFE_SIZE_T newPos = size; newPos += offset; if (!newPos.IsValid() || newPos.ValueOrDefault(0) == 0 || newPos.ValueOrDie() > m_nCurSize) { - return FALSE; + return false; } m_nCurPos = newPos.ValueOrDie(); if (m_dwFlags & FX_MEMSTREAM_Consecutive) { FXSYS_memcpy(buffer, (uint8_t*)m_Blocks[0] + (size_t)offset, size); - return TRUE; + return true; } size_t nStartBlock = (size_t)offset / m_nGrowSize; offset -= (FX_FILESIZE)(nStartBlock * m_nGrowSize); @@ -257,7 +257,7 @@ public: nStartBlock ++; offset = 0; } - return TRUE; + return true; } virtual size_t ReadBlock(void* buffer, size_t size) override { @@ -276,10 +276,10 @@ public: } return nRead; } - virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override + virtual bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override { if (!buffer || !size) { - return FALSE; + return false; } if (m_bUseRange) { offset += (FX_FILESIZE)m_nOffset; @@ -288,7 +288,7 @@ public: FX_SAFE_SIZE_T newPos = size; newPos += offset; if (!newPos.IsValid()) - return FALSE; + return false; m_nCurPos = newPos.ValueOrDie(); if (m_nCurPos > m_nTotalSize) { @@ -301,24 +301,24 @@ public: } if (!m_Blocks[0]) { m_Blocks.RemoveAll(); - return FALSE; + return false; } } FXSYS_memcpy((uint8_t*)m_Blocks[0] + (size_t)offset, buffer, size); if (m_nCurSize < m_nCurPos) { m_nCurSize = m_nCurPos; } - return TRUE; + return true; } FX_SAFE_SIZE_T newPos = size; newPos += offset; if (!newPos.IsValid()) { - return FALSE; + return false; } if (!ExpandBlocks(newPos.ValueOrDie())) { - return FALSE; + return false; } m_nCurPos = newPos.ValueOrDie(); size_t nStartBlock = (size_t)offset / m_nGrowSize; @@ -334,13 +334,13 @@ public: nStartBlock ++; offset = 0; } - return TRUE; + return true; } - virtual FX_BOOL Flush() override + virtual bool Flush() override { - return TRUE; + return true; } - virtual FX_BOOL IsConsecutive() const override + virtual bool IsConsecutive() const override { return m_dwFlags & FX_MEMSTREAM_Consecutive; } @@ -360,7 +360,7 @@ public: { return m_Blocks.GetSize() ? (uint8_t*)m_Blocks[0] : NULL; } - virtual void AttachBuffer(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) override + virtual void AttachBuffer(uint8_t* pBuffer, size_t nSize, bool bTakeOver = false) override { if (!(m_dwFlags & FX_MEMSTREAM_Consecutive)) { return; @@ -390,16 +390,16 @@ protected: size_t m_nCurPos; size_t m_nGrowSize; FX_DWORD m_dwFlags; - FX_BOOL m_bUseRange; + bool m_bUseRange; size_t m_nOffset; size_t m_nSize; - FX_BOOL ExpandBlocks(size_t size) + bool ExpandBlocks(size_t size) { if (m_nCurSize < size) { m_nCurSize = size; } if (size <= m_nTotalSize) { - return TRUE; + return true; } int32_t iCount = m_Blocks.GetSize(); size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize; @@ -409,7 +409,7 @@ protected: m_Blocks.SetAt(iCount ++, pBlock); m_nTotalSize += m_nGrowSize; } - return TRUE; + return true; } }; #ifdef __cplusplus @@ -424,15 +424,15 @@ typedef struct _FX_MTRANDOMCONTEXT { _FX_MTRANDOMCONTEXT() { mti = MT_N + 1; - bHaveSeed = FALSE; + bHaveSeed = false; } FX_DWORD mti; - FX_BOOL bHaveSeed; + bool bHaveSeed; FX_DWORD mt[MT_N]; } FX_MTRANDOMCONTEXT, * FX_LPMTRANDOMCONTEXT; typedef FX_MTRANDOMCONTEXT const * FX_LPCMTRANDOMCONTEXT; #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount); +bool FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount); #endif #ifdef __cplusplus } diff --git a/core/src/fxcrt/fx_arabic.cpp b/core/src/fxcrt/fx_arabic.cpp index 3cb2fd067a..497c1bab4f 100644 --- a/core/src/fxcrt/fx_arabic.cpp +++ b/core/src/fxcrt/fx_arabic.cpp @@ -13,7 +13,7 @@ IFX_BidiChar* IFX_BidiChar::Create() return new CFX_BidiChar; } CFX_BidiChar::CFX_BidiChar() - : m_bSeparateNeutral(TRUE) + : m_bSeparateNeutral(true) , m_iCurStart(0) , m_iCurCount(0) , m_iCurBidi(0) @@ -22,12 +22,12 @@ CFX_BidiChar::CFX_BidiChar() , m_iLastCount(0) { } -void CFX_BidiChar::SetPolicy(FX_BOOL bSeparateNeutral) +void CFX_BidiChar::SetPolicy(bool bSeparateNeutral) { m_bSeparateNeutral = bSeparateNeutral; } -FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) +bool CFX_BidiChar::AppendChar(FX_WCHAR wch) { FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; @@ -43,10 +43,10 @@ FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) iContext = 2; break; } - FX_BOOL bRet = FALSE; + bool bRet = false; if (iContext != m_iCurBidi) { if (m_bSeparateNeutral) { - bRet = TRUE; + bRet = true; } else { if (m_iCurBidi == 0) { bRet = (m_iCurCount > 0); @@ -67,7 +67,7 @@ FX_BOOL CFX_BidiChar::AppendChar(FX_WCHAR wch) m_iCurCount ++; return bRet; } -FX_BOOL CFX_BidiChar::EndChar() +bool CFX_BidiChar::EndChar() { m_iLastBidi = m_iCurBidi; m_iLastStart = m_iCurStart; diff --git a/core/src/fxcrt/fx_arabic.h b/core/src/fxcrt/fx_arabic.h index e4c1ddacf2..10a16afa63 100644 --- a/core/src/fxcrt/fx_arabic.h +++ b/core/src/fxcrt/fx_arabic.h @@ -15,14 +15,14 @@ public: CFX_BidiChar(); ~CFX_BidiChar() override {} - void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) override; - FX_BOOL AppendChar(FX_WCHAR wch) override; - FX_BOOL EndChar() override; + void SetPolicy(bool bSeparateNeutral = true) override; + bool AppendChar(FX_WCHAR wch) override; + bool EndChar() override; int32_t GetBidiInfo(int32_t &iStart, int32_t &iCount) override; void Reset() override; private: - FX_BOOL m_bSeparateNeutral; + bool m_bSeparateNeutral; int32_t m_iCurStart; int32_t m_iCurCount; int32_t m_iCurBidi; diff --git a/core/src/fxcrt/fx_basic_array.cpp b/core/src/fxcrt/fx_basic_array.cpp index 4ab34bb022..f139365740 100644 --- a/core/src/fxcrt/fx_basic_array.cpp +++ b/core/src/fxcrt/fx_basic_array.cpp @@ -22,7 +22,7 @@ CFX_BasicArray::~CFX_BasicArray() { FX_Free(m_pData); } -FX_BOOL CFX_BasicArray::SetSize(int nNewSize) +bool CFX_BasicArray::SetSize(int nNewSize) { if (nNewSize <= 0) { FX_Free(m_pData); @@ -36,7 +36,7 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize) totalSize *= m_nUnitSize; if (!totalSize.IsValid()) { m_nSize = m_nMaxSize = 0; - return FALSE; + return false; } m_pData = FX_Alloc(uint8_t, totalSize.ValueOrDie()); m_nSize = m_nMaxSize = nNewSize; @@ -50,38 +50,38 @@ FX_BOOL CFX_BasicArray::SetSize(int nNewSize) pdfium::base::CheckedNumeric<int> totalSize = nNewMax; totalSize *= m_nUnitSize; if (!totalSize.IsValid() || nNewMax < m_nSize) { - return FALSE; + return false; } uint8_t* pNewData = FX_Realloc(uint8_t, m_pData, totalSize.ValueOrDie()); if (pNewData == NULL) { - return FALSE; + return false; } FXSYS_memset(pNewData + m_nSize * m_nUnitSize, 0, (nNewMax - m_nSize) * m_nUnitSize); m_pData = pNewData; m_nSize = nNewSize; m_nMaxSize = nNewMax; } - return TRUE; + return true; } -FX_BOOL CFX_BasicArray::Append(const CFX_BasicArray& src) +bool CFX_BasicArray::Append(const CFX_BasicArray& src) { int nOldSize = m_nSize; pdfium::base::CheckedNumeric<int> newSize = m_nSize; newSize += src.m_nSize; if (m_nUnitSize != src.m_nUnitSize || !newSize.IsValid() || !SetSize(newSize.ValueOrDie())) { - return FALSE; + return false; } FXSYS_memcpy(m_pData + nOldSize * m_nUnitSize, src.m_pData, src.m_nSize * m_nUnitSize); - return TRUE; + return true; } -FX_BOOL CFX_BasicArray::Copy(const CFX_BasicArray& src) +bool CFX_BasicArray::Copy(const CFX_BasicArray& src) { if (!SetSize(src.m_nSize)) { - return FALSE; + return false; } FXSYS_memcpy(m_pData, src.m_pData, src.m_nSize * m_nUnitSize); - return TRUE; + return true; } uint8_t* CFX_BasicArray::InsertSpaceAt(int nIndex, int nCount) { @@ -103,31 +103,31 @@ uint8_t* CFX_BasicArray::InsertSpaceAt(int nIndex, int nCount) } return m_pData + nIndex * m_nUnitSize; } -FX_BOOL CFX_BasicArray::RemoveAt(int nIndex, int nCount) +bool CFX_BasicArray::RemoveAt(int nIndex, int nCount) { if (nIndex < 0 || nCount <= 0 || m_nSize < nIndex + nCount) { - return FALSE; + return false; } int nMoveCount = m_nSize - (nIndex + nCount); if (nMoveCount) { FXSYS_memmove(m_pData + nIndex * m_nUnitSize, m_pData + (nIndex + nCount) * m_nUnitSize, nMoveCount * m_nUnitSize); } m_nSize -= nCount; - return TRUE; + return true; } -FX_BOOL CFX_BasicArray::InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) +bool CFX_BasicArray::InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) { if (pNewArray == NULL) { - return FALSE; + return false; } if (pNewArray->m_nSize == 0) { - return TRUE; + return true; } if (!InsertSpaceAt(nStartIndex, pNewArray->m_nSize)) { - return FALSE; + return false; } FXSYS_memcpy(m_pData + nStartIndex * m_nUnitSize, pNewArray->m_pData, pNewArray->m_nSize * m_nUnitSize); - return TRUE; + return true; } const void* CFX_BasicArray::GetDataPtr(int index) const { @@ -260,7 +260,7 @@ void** CFX_BaseSegmentedArray::GetIndex(int seg_index) const } return pSpot; } -void* CFX_BaseSegmentedArray::IterateSegment(const uint8_t* pSegment, int count, FX_BOOL (*callback)(void* param, void* pData), void* param) const +void* CFX_BaseSegmentedArray::IterateSegment(const uint8_t* pSegment, int count, bool (*callback)(void* param, void* pData), void* param) const { for (int i = 0; i < count; i ++) { if (!callback(param, (void*)(pSegment + i * m_UnitSize))) { @@ -269,7 +269,7 @@ void* CFX_BaseSegmentedArray::IterateSegment(const uint8_t* pSegment, int count, } return NULL; } -void* CFX_BaseSegmentedArray::IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*callback)(void* param, void* pData), void* param) const +void* CFX_BaseSegmentedArray::IterateIndex(int level, int& start, void** pIndex, bool (*callback)(void* param, void* pData), void* param) const { if (level == 0) { int count = m_DataSize - start; @@ -290,7 +290,7 @@ void* CFX_BaseSegmentedArray::IterateIndex(int level, int& start, void** pIndex, } return NULL; } -void* CFX_BaseSegmentedArray::Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const +void* CFX_BaseSegmentedArray::Iterate(bool (*callback)(void* param, void* pData), void* param) const { if (m_pIndex == NULL) { return NULL; diff --git a/core/src/fxcrt/fx_basic_bstring.cpp b/core/src/fxcrt/fx_basic_bstring.cpp index 5eeb33b049..47c1c5b6b2 100644 --- a/core/src/fxcrt/fx_basic_bstring.cpp +++ b/core/src/fxcrt/fx_basic_bstring.cpp @@ -1086,9 +1086,9 @@ FX_STRSIZE FX_ftoa(FX_FLOAT d, FX_CHAR* buf) if (d == 0.0f) { return 1; } - FX_BOOL bNegative = FALSE; + bool bNegative = false; if (d < 0) { - bNegative = TRUE; + bNegative = true; d = -d; } int scale = 1; diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp index 9fc400e183..d7c1a1ad7b 100644 --- a/core/src/fxcrt/fx_basic_buffer.cpp +++ b/core/src/fxcrt/fx_basic_buffer.cpp @@ -321,7 +321,7 @@ CFX_ArchiveLoader::CFX_ArchiveLoader(const uint8_t* pData, FX_DWORD dwSize) m_LoadingPos = 0; m_LoadingSize = dwSize; } -FX_BOOL CFX_ArchiveLoader::IsEOF() +bool CFX_ArchiveLoader::IsEOF() { return m_LoadingPos >= m_LoadingSize; } @@ -372,14 +372,14 @@ CFX_ArchiveLoader& CFX_ArchiveLoader::operator >> (CFX_WideString& str) str = CFX_WideString::FromUTF16LE((const unsigned short*)encoded.c_str(), encoded.GetLength()); return *this; } -FX_BOOL CFX_ArchiveLoader::Read(void* pBuf, FX_DWORD dwSize) +bool CFX_ArchiveLoader::Read(void* pBuf, FX_DWORD dwSize) { if (m_LoadingPos + dwSize > m_LoadingSize) { - return FALSE; + return false; } FXSYS_memcpy(pBuf, m_pLoadingBuf + m_LoadingPos, dwSize); m_LoadingPos += dwSize; - return TRUE; + return true; } void CFX_BitStream::Init(const uint8_t* pData, FX_DWORD dwSize) { @@ -441,9 +441,9 @@ void IFX_BufferArchive::Clear() m_pBuffer = NULL; } } -FX_BOOL IFX_BufferArchive::Flush() +bool IFX_BufferArchive::Flush() { - FX_BOOL bRet = DoWork(m_pBuffer, m_Length); + bool bRet = DoWork(m_pBuffer, m_Length); m_Length = 0; return bRet; } @@ -488,7 +488,7 @@ int32_t IFX_BufferArchive::AppendString(const CFX_ByteStringC& lpsz) CFX_FileBufferArchive::CFX_FileBufferArchive(FX_STRSIZE size) : IFX_BufferArchive(size) , m_pFile(NULL) - , m_bTakeover(FALSE) + , m_bTakeover(false) { } CFX_FileBufferArchive::~CFX_FileBufferArchive() @@ -501,58 +501,58 @@ void CFX_FileBufferArchive::Clear() m_pFile->Release(); } m_pFile = NULL; - m_bTakeover = FALSE; + m_bTakeover = false; IFX_BufferArchive::Clear(); } -FX_BOOL CFX_FileBufferArchive::AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover ) +bool CFX_FileBufferArchive::AttachFile(IFX_StreamWrite *pFile, bool bTakeover ) { if (!pFile) { - return FALSE; + return false; } if (m_pFile && m_bTakeover) { m_pFile->Release(); } m_pFile = pFile; m_bTakeover = bTakeover; - return TRUE; + return true; } -FX_BOOL CFX_FileBufferArchive::AttachFile(const FX_WCHAR* filename) +bool CFX_FileBufferArchive::AttachFile(const FX_WCHAR* filename) { if (!filename) { - return FALSE; + return false; } if (m_pFile && m_bTakeover) { m_pFile->Release(); } m_pFile = FX_CreateFileWrite(filename); if (!m_pFile) { - return FALSE; + return false; } - m_bTakeover = TRUE; - return TRUE; + m_bTakeover = true; + return true; } -FX_BOOL CFX_FileBufferArchive::AttachFile(const FX_CHAR* filename) +bool CFX_FileBufferArchive::AttachFile(const FX_CHAR* filename) { if (!filename) { - return FALSE; + return false; } if (m_pFile && m_bTakeover) { m_pFile->Release(); } m_pFile = FX_CreateFileWrite(filename); if (!m_pFile) { - return FALSE; + return false; } - m_bTakeover = TRUE; - return TRUE; + m_bTakeover = true; + return true; } -FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) +bool CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) { if (!m_pFile) { - return FALSE; + return false; } if (!pBuf || size < 1) { - return TRUE; + return true; } return m_pFile->WriteBlock(pBuf, size); } diff --git a/core/src/fxcrt/fx_basic_coords.cpp b/core/src/fxcrt/fx_basic_coords.cpp index 2e830809b8..22b9bd4715 100644 --- a/core/src/fxcrt/fx_basic_coords.cpp +++ b/core/src/fxcrt/fx_basic_coords.cpp @@ -45,15 +45,15 @@ void FX_RECT::Union(const FX_RECT& other_rect) bottom = bottom > other.bottom ? bottom : other.bottom; top = top < other.top ? top : other.top; } -FX_BOOL GetIntersection(FX_FLOAT low1, FX_FLOAT high1, FX_FLOAT low2, FX_FLOAT high2, +bool GetIntersection(FX_FLOAT low1, FX_FLOAT high1, FX_FLOAT low2, FX_FLOAT high2, FX_FLOAT& interlow, FX_FLOAT& interhigh) { if (low1 >= high2 || low2 >= high1) { - return FALSE; + return false; } interlow = low1 > low2 ? low1 : low2; interhigh = high1 > high2 ? high2 : high1; - return TRUE; + return true; } extern "C" int FXSYS_round(FX_FLOAT d) { @@ -198,18 +198,18 @@ FX_RECT CFX_FloatRect::GetClosestRect() const rect.Normalize(); return rect; } -FX_BOOL CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const +bool CFX_FloatRect::Contains(const CFX_FloatRect& other_rect) const { CFX_FloatRect n1 = *this; n1.Normalize(); CFX_FloatRect n2 = other_rect; n2.Normalize(); if (n2.left >= n1.left && n2.right <= n1.right && n2.bottom >= n1.bottom && n2.top <= n1.top) { - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const +bool CFX_FloatRect::Contains(FX_FLOAT x, FX_FLOAT y) const { CFX_FloatRect n1 = *this; n1.Normalize(); @@ -299,13 +299,13 @@ static void FXCRT_Matrix_Concat(CFX_Matrix &m, const CFX_Matrix &m1, const CFX_M FX_FLOAT ff = m1.e * m2.b + m1.f * m2.d + m2.f; m.a = aa, m.b = bb, m.c = cc, m.d = dd, m.e = ee, m.f = ff; } -void CFX_Matrix::Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended) +void CFX_Matrix::Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, bool bPrepended) { CFX_Matrix m; m.Set(a, b, c, d, e, f); Concat(m, bPrepended); } -void CFX_Matrix::Concat(const CFX_Matrix &m, FX_BOOL bPrepended) +void CFX_Matrix::Concat(const CFX_Matrix &m, bool bPrepended) { if (bPrepended) { FXCRT_Matrix_Concat(*this, m, *this); @@ -313,25 +313,25 @@ void CFX_Matrix::Concat(const CFX_Matrix &m, FX_BOOL bPrepended) FXCRT_Matrix_Concat(*this, *this, m); } } -void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, FX_BOOL bPrepended) +void CFX_Matrix::ConcatInverse(const CFX_Matrix& src, bool bPrepended) { CFX_Matrix m; m.SetReverse(src); Concat(m, bPrepended); } -FX_BOOL CFX_Matrix::IsInvertible() const +bool CFX_Matrix::IsInvertible() const { return FXSYS_fabs(a * d - b * c) >= 0.0001f; } -FX_BOOL CFX_Matrix::Is90Rotated() const +bool CFX_Matrix::Is90Rotated() const { return FXSYS_fabs(a * 1000) < FXSYS_fabs(b) && FXSYS_fabs(d * 1000) < FXSYS_fabs(c); } -FX_BOOL CFX_Matrix::IsScaled() const +bool CFX_Matrix::IsScaled() const { return FXSYS_fabs(b * 1000) < FXSYS_fabs(a) && FXSYS_fabs(c * 1000) < FXSYS_fabs(d); } -void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended) +void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended) { if (bPrepended) { e += x * a + y * c; @@ -340,7 +340,7 @@ void CFX_Matrix::Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended) e += x, f += y; } } -void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended) +void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended) { a *= sx, d *= sy; if (bPrepended) { @@ -353,7 +353,7 @@ void CFX_Matrix::Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended) f *= sy; } } -void CFX_Matrix::Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended) +void CFX_Matrix::Rotate(FX_FLOAT fRadian, bool bPrepended) { FX_FLOAT cosValue = FXSYS_cos(fRadian); FX_FLOAT sinValue = FXSYS_sin(fRadian); @@ -365,13 +365,13 @@ void CFX_Matrix::Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended) FXCRT_Matrix_Concat(*this, *this, m); } } -void CFX_Matrix::RotateAt(FX_FLOAT fRadian, FX_FLOAT dx, FX_FLOAT dy, FX_BOOL bPrepended) +void CFX_Matrix::RotateAt(FX_FLOAT fRadian, FX_FLOAT dx, FX_FLOAT dy, bool bPrepended) { Translate(dx, dy, bPrepended); Rotate(fRadian, bPrepended); Translate(-dx, -dy, bPrepended); } -void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended) +void CFX_Matrix::Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, bool bPrepended) { CFX_Matrix m; m.Set(1, FXSYS_tan(fAlphaRadian), FXSYS_tan(fBetaRadian), 1, 0, 0); diff --git a/core/src/fxcrt/fx_basic_gcc.cpp b/core/src/fxcrt/fx_basic_gcc.cpp index 2497c74a8e..562f741d41 100644 --- a/core/src/fxcrt/fx_basic_gcc.cpp +++ b/core/src/fxcrt/fx_basic_gcc.cpp @@ -12,12 +12,12 @@ template <class T, class STR_T> T FXSYS_StrToInt(STR_T str) { - FX_BOOL neg = FALSE; + bool neg = false; if (str == NULL) { return 0; } if (*str == '-') { - neg = TRUE; + neg = true; str ++; } T num = 0; diff --git a/core/src/fxcrt/fx_basic_maps.cpp b/core/src/fxcrt/fx_basic_maps.cpp index e34acb088d..7de7b614f4 100644 --- a/core/src/fxcrt/fx_basic_maps.cpp +++ b/core/src/fxcrt/fx_basic_maps.cpp @@ -69,15 +69,15 @@ void CFX_MapPtrToPtr::GetNextAssoc(FX_POSITION& rNextPosition, void*& rKey, void rKey = pAssocRet->key; rValue = pAssocRet->value; } -FX_BOOL CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const +bool CFX_MapPtrToPtr::Lookup(void* key, void*& rValue) const { FX_DWORD nHash; CAssoc* pAssoc = GetAssocAt(key, nHash); if (pAssoc == NULL) { - return FALSE; + return false; } rValue = pAssoc->value; - return TRUE; + return true; } void* CFX_MapPtrToPtr::GetValueAt(void* key) const { @@ -140,7 +140,7 @@ CFX_MapPtrToPtr::NewAssoc() return pAssoc; } void CFX_MapPtrToPtr::InitHashTable( - FX_DWORD nHashSize, FX_BOOL bAllocNow) + FX_DWORD nHashSize, bool bAllocNow) { ASSERT(m_nCount == 0); ASSERT(nHashSize > 0); @@ -153,10 +153,10 @@ void CFX_MapPtrToPtr::InitHashTable( } m_nHashTableSize = nHashSize; } -FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) +bool CFX_MapPtrToPtr::RemoveKey(void* key) { if (m_pHashTable == NULL) { - return FALSE; + return false; } CAssoc** ppAssocPrev; ppAssocPrev = &m_pHashTable[HashKey(key) % m_nHashTableSize]; @@ -165,11 +165,11 @@ FX_BOOL CFX_MapPtrToPtr::RemoveKey(void* key) if (pAssoc->key == key) { *ppAssocPrev = pAssoc->pNext; FreeAssoc(pAssoc); - return TRUE; + return true; } ppAssocPrev = &pAssoc->pNext; } - return FALSE; + return false; } void CFX_MapPtrToPtr::FreeAssoc(CFX_MapPtrToPtr::CAssoc* pAssoc) { @@ -325,18 +325,18 @@ CFX_MapByteStringToPtr::GetAssocAt(const CFX_ByteStringC& key, FX_DWORD& nHash) } return NULL; } -FX_BOOL CFX_MapByteStringToPtr::Lookup(const CFX_ByteStringC& key, void*& rValue) const +bool CFX_MapByteStringToPtr::Lookup(const CFX_ByteStringC& key, void*& rValue) const { FX_DWORD nHash; CAssoc* pAssoc = GetAssocAt(key, nHash); if (pAssoc == NULL) { - return FALSE; + return false; } rValue = pAssoc->value; - return TRUE; + return true; } void CFX_MapByteStringToPtr::InitHashTable( - FX_DWORD nHashSize, FX_BOOL bAllocNow) + FX_DWORD nHashSize, bool bAllocNow) { ASSERT(m_nCount == 0); ASSERT(nHashSize > 0); @@ -359,10 +359,10 @@ inline FX_DWORD CFX_MapByteStringToPtr::HashKey(const CFX_ByteStringC& key) cons } return nHash; } -FX_BOOL CFX_MapByteStringToPtr::RemoveKey(const CFX_ByteStringC& key) +bool CFX_MapByteStringToPtr::RemoveKey(const CFX_ByteStringC& key) { if (m_pHashTable == NULL) { - return FALSE; + return false; } CAssoc** ppAssocPrev; ppAssocPrev = &m_pHashTable[HashKey(key) % m_nHashTableSize]; @@ -371,11 +371,11 @@ FX_BOOL CFX_MapByteStringToPtr::RemoveKey(const CFX_ByteStringC& key) if (pAssoc->key == key) { *ppAssocPrev = pAssoc->pNext; FreeAssoc(pAssoc); - return TRUE; + return true; } ppAssocPrev = &pAssoc->pNext; } - return FALSE; + return false; } struct _CompactString { uint8_t m_CompactLen; @@ -390,16 +390,16 @@ static void _CompactStringRelease(_CompactString* pCompact) FX_Free(pCompact->m_pBuffer); } } -static FX_BOOL _CompactStringSame(_CompactString* pCompact, const uint8_t* pStr, int len) +static bool _CompactStringSame(_CompactString* pCompact, const uint8_t* pStr, int len) { if (len < sizeof(_CompactString)) { if (pCompact->m_CompactLen != len) { - return FALSE; + return false; } return FXSYS_memcmp(&pCompact->m_LenHigh, pStr, len) == 0; } if (pCompact->m_CompactLen != 0xff || pCompact->m_LenHigh * 256 + pCompact->m_LenLow != len) { - return FALSE; + return false; } return FXSYS_memcmp(pCompact->m_pBuffer, pStr, len) == 0; } @@ -497,18 +497,18 @@ void* CFX_CMapByteStringToPtr::GetNextValue(FX_POSITION& rNextPosition) const rNextPosition = NULL; return rValue; } -FX_BOOL _CMapLookupCallback(void* param, void* pData) +bool _CMapLookupCallback(void* param, void* pData) { return !_CompactStringSame((_CompactString*)pData, ((CFX_ByteStringC*)param)->GetPtr(), ((CFX_ByteStringC*)param)->GetLength()); } -FX_BOOL CFX_CMapByteStringToPtr::Lookup(const CFX_ByteStringC& key, void*& rValue) const +bool CFX_CMapByteStringToPtr::Lookup(const CFX_ByteStringC& key, void*& rValue) const { void* p = m_Buffer.Iterate(_CMapLookupCallback, (void*)&key); if (!p) { - return FALSE; + return false; } rValue = *(void**)((_CompactString*)p + 1); - return TRUE; + return true; } void CFX_CMapByteStringToPtr::SetAt(const CFX_ByteStringC& key, void* value) { @@ -579,15 +579,15 @@ struct _DWordPair { FX_DWORD key; FX_DWORD value; }; -FX_BOOL CFX_CMapDWordToDWord::Lookup(FX_DWORD key, FX_DWORD& value) const +bool CFX_CMapDWordToDWord::Lookup(FX_DWORD key, FX_DWORD& value) const { void* pResult = FXSYS_bsearch(&key, m_Buffer.GetBuffer(), m_Buffer.GetSize() / sizeof(_DWordPair), sizeof(_DWordPair), _CompareDWord); if (pResult == NULL) { - return FALSE; + return false; } value = ((FX_DWORD*)pResult)[1]; - return TRUE; + return true; } FX_POSITION CFX_CMapDWordToDWord::GetStartPosition() const { diff --git a/core/src/fxcrt/fx_basic_util.cpp b/core/src/fxcrt/fx_basic_util.cpp index 26eeacce1b..1343374111 100644 --- a/core/src/fxcrt/fx_basic_util.cpp +++ b/core/src/fxcrt/fx_basic_util.cpp @@ -26,7 +26,7 @@ void FX_PRIVATEDATA::FreeData() m_pCallback(m_pData); } } -void CFX_PrivateData::AddData(void* pModuleId, void* pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct) +void CFX_PrivateData::AddData(void* pModuleId, void* pData, PD_CALLBACK_FREEDATA callback, bool bSelfDestruct) { if (pModuleId == NULL) { return; @@ -46,26 +46,26 @@ void CFX_PrivateData::AddData(void* pModuleId, void* pData, PD_CALLBACK_FREEDATA } void CFX_PrivateData::SetPrivateData(void* pModuleId, void* pData, PD_CALLBACK_FREEDATA callback) { - AddData(pModuleId, pData, callback, FALSE); + AddData(pModuleId, pData, callback, false); } void CFX_PrivateData::SetPrivateObj(void* pModuleId, CFX_DestructObject* pObj) { - AddData(pModuleId, pObj, NULL, TRUE); + AddData(pModuleId, pObj, NULL, true); } -FX_BOOL CFX_PrivateData::RemovePrivateData(void* pModuleId) +bool CFX_PrivateData::RemovePrivateData(void* pModuleId) { if (pModuleId == NULL) { - return FALSE; + return false; } FX_PRIVATEDATA* pList = m_DataList.GetData(); int count = m_DataList.GetSize(); for (int i = 0; i < count; i ++) { if (pList[i].m_pModuleId == pModuleId) { m_DataList.RemoveAt(i); - return TRUE; + return true; } } - return FALSE; + return false; } void* CFX_PrivateData::GetPrivateData(void* pModuleId) { @@ -90,18 +90,18 @@ void CFX_PrivateData::ClearAll() } m_DataList.RemoveAll(); } -void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) +void FX_atonum(const CFX_ByteStringC& strc, bool& bInteger, void* pData) { if (FXSYS_memchr(strc.GetPtr(), '.', strc.GetLength()) == NULL) { - bInteger = TRUE; + bInteger = true; int cc = 0, integer = 0; const FX_CHAR* str = strc.GetCStr(); int len = strc.GetLength(); - FX_BOOL bNegative = FALSE; + bool bNegative = false; if (str[0] == '+') { cc++; } else if (str[0] == '-') { - bNegative = TRUE; + bNegative = true; cc++; } while (cc < len) { @@ -119,7 +119,7 @@ void FX_atonum(const CFX_ByteStringC& strc, FX_BOOL& bInteger, void* pData) } *(int*)pData = integer; } else { - bInteger = FALSE; + bInteger = false; *(FX_FLOAT*)pData = FX_atof(strc); } } @@ -129,13 +129,13 @@ FX_FLOAT FX_atof(const CFX_ByteStringC& strc) return 0.0; } int cc = 0; - FX_BOOL bNegative = FALSE; + bool bNegative = false; const FX_CHAR* str = strc.GetCStr(); int len = strc.GetLength(); if (str[0] == '+') { cc++; } else if (str[0] == '-') { - bNegative = TRUE; + bNegative = true; cc++; } while (cc < len) { @@ -187,13 +187,13 @@ void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap) } #endif // _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 -static FX_BOOL FX_IsDigit(uint8_t ch) +static bool FX_IsDigit(uint8_t ch) { - return (ch >= '0' && ch <= '9') ? TRUE : FALSE; + return (ch >= '0' && ch <= '9') ? true : false; } -static FX_BOOL FX_IsXDigit(uint8_t ch) +static bool FX_IsXDigit(uint8_t ch) { - return (FX_IsDigit(ch) || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) ? TRUE : FALSE; + return (FX_IsDigit(ch) || (ch >= 'A' && ch <= 'F') || (ch >= 'a' && ch <= 'f')) ? true : false; } static uint8_t FX_MakeUpper(uint8_t ch) { @@ -299,7 +299,7 @@ class CFindFileData public: virtual ~CFindFileData() {} HANDLE m_Handle; - FX_BOOL m_bEnd; + bool m_bEnd; }; class CFindFileDataA : public CFindFileData { @@ -332,7 +332,7 @@ void* FX_OpenFolder(const FX_CHAR* path) delete pData; return NULL; } - pData->m_bEnd = FALSE; + pData->m_bEnd = false; return pData; #else DIR* dir = opendir(path); @@ -352,82 +352,82 @@ void* FX_OpenFolder(const FX_WCHAR* path) delete pData; return NULL; } - pData->m_bEnd = FALSE; + pData->m_bEnd = false; return pData; #else DIR* dir = opendir(CFX_ByteString::FromUnicode(path)); return dir; #endif } -FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder) +bool FX_GetNextFile(void* handle, CFX_ByteString& filename, bool& bFolder) { if (handle == NULL) { - return FALSE; + return false; } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ #ifndef _WIN32_WCE CFindFileDataA* pData = (CFindFileDataA*)handle; if (pData->m_bEnd) { - return FALSE; + return false; } filename = pData->m_FindData.cFileName; bFolder = pData->m_FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; if (!FindNextFileA(pData->m_Handle, &pData->m_FindData)) { - pData->m_bEnd = TRUE; + pData->m_bEnd = true; } - return TRUE; + return true; #else CFindFileDataW* pData = (CFindFileDataW*)handle; if (pData->m_bEnd) { - return FALSE; + return false; } filename = CFX_ByteString::FromUnicode(pData->m_FindData.cFileName); bFolder = pData->m_FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; if (!FindNextFileW(pData->m_Handle, &pData->m_FindData)) { - pData->m_bEnd = TRUE; + pData->m_bEnd = true; } - return TRUE; + return true; #endif #elif defined(__native_client__) abort(); - return FALSE; + return false; #else struct dirent *de = readdir((DIR*)handle); if (de == NULL) { - return FALSE; + return false; } filename = de->d_name; bFolder = de->d_type == DT_DIR; - return TRUE; + return true; #endif } -FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder) +bool FX_GetNextFile(void* handle, CFX_WideString& filename, bool& bFolder) { if (handle == NULL) { - return FALSE; + return false; } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ CFindFileDataW* pData = (CFindFileDataW*)handle; if (pData->m_bEnd) { - return FALSE; + return false; } filename = pData->m_FindData.cFileName; bFolder = pData->m_FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY; if (!FindNextFileW(pData->m_Handle, &pData->m_FindData)) { - pData->m_bEnd = TRUE; + pData->m_bEnd = true; } - return TRUE; + return true; #elif defined(__native_client__) abort(); - return FALSE; + return false; #else struct dirent *de = readdir((DIR*)handle); if (de == NULL) { - return FALSE; + return false; } filename = CFX_WideString::FromLocal(de->d_name); bFolder = de->d_type == DT_DIR; - return TRUE; + return true; #endif } void FX_CloseFolder(void* handle) diff --git a/core/src/fxcrt/fx_basic_wstring.cpp b/core/src/fxcrt/fx_basic_wstring.cpp index b6b595588d..bb236ac21b 100644 --- a/core/src/fxcrt/fx_basic_wstring.cpp +++ b/core/src/fxcrt/fx_basic_wstring.cpp @@ -980,11 +980,11 @@ FX_FLOAT FX_wtof(const FX_WCHAR* str, int len) return 0.0; } int cc = 0; - FX_BOOL bNegative = FALSE; + bool bNegative = false; if (str[0] == '+') { cc++; } else if (str[0] == '-') { - bNegative = TRUE; + bNegative = true; cc++; } int integer = 0; diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp index 4662e8f893..fe6f29f6a2 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -72,12 +72,12 @@ size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szBuffer, FX FXSYS_assert(hFile != NULL); return ((IFXCRT_FileAccess*)hFile)->WritePos(pBuffer, szBuffer, pos); } -FX_BOOL FX_File_Flush(FX_HFILE hFile) +bool FX_File_Flush(FX_HFILE hFile) { FXSYS_assert(hFile != NULL); return ((IFXCRT_FileAccess*)hFile)->Flush(); } -FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile) +bool FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile) { FXSYS_assert(hFile != NULL); return ((IFXCRT_FileAccess*)hFile)->Truncate(szFile); @@ -122,11 +122,11 @@ IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename) { return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); } -IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, size_t dwSize, FX_BOOL bTakeOver) +IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, size_t dwSize, bool bTakeOver) { return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); } -IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) +IFX_MemoryStream* FX_CreateMemoryStream(bool bConsecutive) { return new CFX_MemoryStream(bConsecutive); } @@ -160,10 +160,10 @@ FX_FLOAT FXSYS_wcstof(const FX_WCHAR* pwsStr, int32_t iLength, int32_t *pUsedLen return 0.0f; } int32_t iUsedLen = 0; - FX_BOOL bNegtive = FALSE; + bool bNegtive = false; switch (pwsStr[iUsedLen]) { case '-': - bNegtive = TRUE; + bNegtive = true; case '+': iUsedLen++; break; @@ -230,7 +230,7 @@ int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count) } return ch1 - ch2; } -FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase) +FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, bool bIgnoreCase) { FXSYS_assert(pStr != NULL); if (iLength < 0) { @@ -249,7 +249,7 @@ FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, FX_BOOL b } return dwHashCode; } -FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase) +FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, bool bIgnoreCase) { FXSYS_assert(pStr != NULL); if (iLength < 0) { @@ -283,7 +283,7 @@ void* FX_Random_MT_Start(FX_DWORD dwSeed) for (i = 1; i < MT_N; i ++) { pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); } - pContext->bHaveSeed = TRUE; + pContext->bHaveSeed = true; return pContext; } FX_DWORD FX_Random_MT_Generate(void* pContext) @@ -347,8 +347,8 @@ void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount) do { ::GetSystemTime(&st2); } while (FXSYS_memcmp(&st1, &st2, sizeof(SYSTEMTIME)) == 0); - FX_DWORD dwHash1 = FX_HashCode_String_GetA((const FX_CHAR*)&st1, sizeof(st1), TRUE); - FX_DWORD dwHash2 = FX_HashCode_String_GetA((const FX_CHAR*)&st2, sizeof(st2), TRUE); + FX_DWORD dwHash1 = FX_HashCode_String_GetA((const FX_CHAR*)&st1, sizeof(st1), true); + FX_DWORD dwHash2 = FX_HashCode_String_GetA((const FX_CHAR*)&st2, sizeof(st2), true); ::srand((dwHash1 << 16) | (FX_DWORD)dwHash2); #else time_t tmLast = time(NULL), tmCur; @@ -360,15 +360,15 @@ void FX_Random_GenerateBase(FX_DWORD* pBuffer, int32_t iCount) } } #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -FX_BOOL FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) +bool FX_GenerateCryptoRandom(FX_DWORD* pBuffer, int32_t iCount) { HCRYPTPROV hCP = NULL; if (!::CryptAcquireContext(&hCP, NULL, NULL, PROV_RSA_FULL, 0) || hCP == NULL) { - return FALSE; + return false; } ::CryptGenRandom(hCP, iCount * sizeof(FX_DWORD), (uint8_t*)pBuffer); ::CryptReleaseContext(hCP, 0); - return TRUE; + return true; } #endif void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) diff --git a/core/src/fxcrt/fx_unicode.cpp b/core/src/fxcrt/fx_unicode.cpp index d66a58a9b3..1d63da93aa 100644 --- a/core/src/fxcrt/fx_unicode.cpp +++ b/core/src/fxcrt/fx_unicode.cpp @@ -13,27 +13,27 @@ FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch) { return gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; } -FX_BOOL FX_IsCtrlCode(FX_WCHAR ch) +bool FX_IsCtrlCode(FX_WCHAR ch) { FX_DWORD dwRet = (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & FX_CHARTYPEBITSMASK); return dwRet == FX_CHARTYPE_Tab || dwRet == FX_CHARTYPE_Control; } -FX_BOOL FX_IsRotationCode(FX_WCHAR ch) +bool FX_IsRotationCode(FX_WCHAR ch) { return (gs_FX_TextLayout_CodeProperties[(FX_WORD)ch] & 0x8000) != 0; } -FX_BOOL FX_IsCombinationChar(FX_WCHAR wch) +bool FX_IsCombinationChar(FX_WCHAR wch) { FX_DWORD dwProps = (gs_FX_TextLayout_CodeProperties[(FX_WORD)wch] & FX_CHARTYPEBITSMASK); return dwProps == FX_CHARTYPE_Combination; } -FX_BOOL FX_IsBidiChar(FX_WCHAR wch) +bool FX_IsBidiChar(FX_WCHAR wch) { FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; int32_t iBidiCls = (dwProps & FX_BIDICLASSBITSMASK) >> FX_BIDICLASSBITS; return (FX_BIDICLASS_R == iBidiCls || FX_BIDICLASS_AL == iBidiCls); } -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical) +FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical) { FX_DWORD dwProps = gs_FX_TextLayout_CodeProperties[(FX_WORD)wch]; FX_DWORD dwTemp = (dwProps & 0xFF800000); @@ -49,7 +49,7 @@ FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical) } return wch; } -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_DWORD dwProps, FX_BOOL bRTL, FX_BOOL bVertical) +FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_DWORD dwProps, bool bRTL, bool bVertical) { FX_DWORD dwTemp = (dwProps & 0xFF800000); if (bRTL && dwTemp < 0xFF800000) { diff --git a/core/src/fxcrt/fx_xml_parser.cpp b/core/src/fxcrt/fx_xml_parser.cpp index dcf91d1a97..73695a6ec8 100644 --- a/core/src/fxcrt/fx_xml_parser.cpp +++ b/core/src/fxcrt/fx_xml_parser.cpp @@ -12,34 +12,34 @@ CXML_Parser::~CXML_Parser() m_pDataAcc->Release(); } } -FX_BOOL CXML_Parser::Init(uint8_t* pBuffer, size_t size) +bool CXML_Parser::Init(uint8_t* pBuffer, size_t size) { m_pDataAcc = new CXML_DataBufAcc(pBuffer, size); - return Init(TRUE); + return Init(true); } -FX_BOOL CXML_Parser::Init(IFX_FileRead *pFileRead) +bool CXML_Parser::Init(IFX_FileRead *pFileRead) { m_pDataAcc = new CXML_DataStmAcc(pFileRead); - return Init(TRUE); + return Init(true); } -FX_BOOL CXML_Parser::Init(IFX_BufferRead *pBuffer) +bool CXML_Parser::Init(IFX_BufferRead *pBuffer) { if (!pBuffer) { - return FALSE; + return false; } m_pDataAcc = pBuffer; - return Init(FALSE); + return Init(false); } -FX_BOOL CXML_Parser::Init(FX_BOOL bOwndedStream) +bool CXML_Parser::Init(bool bOwndedStream) { m_bOwnedStream = bOwndedStream; m_nOffset = 0; return ReadNextBlock(); } -FX_BOOL CXML_Parser::ReadNextBlock() +bool CXML_Parser::ReadNextBlock() { if (!m_pDataAcc->ReadNextBlock()) { - return FALSE; + return false; } m_pBuffer = m_pDataAcc->GetBlockBuffer(); m_dwBufferSize = m_pDataAcc->GetBlockSize(); @@ -47,10 +47,10 @@ FX_BOOL CXML_Parser::ReadNextBlock() m_dwIndex = 0; return m_dwBufferSize > 0; } -FX_BOOL CXML_Parser::IsEOF() +bool CXML_Parser::IsEOF() { if (!m_pDataAcc->IsEOF()) { - return FALSE; + return false; } return m_dwIndex >= m_dwBufferSize; } @@ -82,27 +82,27 @@ uint8_t g_FXCRT_XML_ByteTypes[256] = { 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x01, 0x01, }; -FX_BOOL g_FXCRT_XML_IsWhiteSpace(uint8_t ch) +bool g_FXCRT_XML_IsWhiteSpace(uint8_t ch) { return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_SpaceChar) != 0; } -FX_BOOL g_FXCRT_XML_IsLetter(uint8_t ch) +bool g_FXCRT_XML_IsLetter(uint8_t ch) { return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Letter) != 0; } -FX_BOOL g_FXCRT_XML_IsDigital(uint8_t ch) +bool g_FXCRT_XML_IsDigital(uint8_t ch) { return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_Digital) != 0; } -FX_BOOL g_FXCRT_XML_IsNameIntro(uint8_t ch) +bool g_FXCRT_XML_IsNameIntro(uint8_t ch) { return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameIntro) != 0; } -FX_BOOL g_FXCRT_XML_IsNameChar(uint8_t ch) +bool g_FXCRT_XML_IsNameChar(uint8_t ch) { return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_NameChar) != 0; } -FX_BOOL g_FXCRT_XML_IsHexChar(uint8_t ch) +bool g_FXCRT_XML_IsHexChar(uint8_t ch) { return (g_FXCRT_XML_ByteTypes[ch] & FXCRTM_XML_CHARTYPE_HexChar) != 0; } @@ -310,13 +310,13 @@ void CXML_Parser::GetAttrValue(CFX_WideString &value) } while (ReadNextBlock()); value = decoder.GetResult(); } -void CXML_Parser::GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOOL &bEndTag, FX_BOOL bStartTag) +void CXML_Parser::GetTagName(CFX_ByteString &space, CFX_ByteString &name, bool &bEndTag, bool bStartTag) { m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (IsEOF()) { return; } - bEndTag = FALSE; + bEndTag = false; uint8_t ch; int32_t iState = bStartTag ? 1 : 0; do { @@ -345,10 +345,10 @@ void CXML_Parser::GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOO if (ch == '/') { m_dwIndex ++; GetName(space, name); - bEndTag = TRUE; + bEndTag = true; } else { GetName(space, name); - bEndTag = FALSE; + bEndTag = false; } return; } @@ -359,14 +359,14 @@ void CXML_Parser::GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOO } } while (ReadNextBlock()); } -CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, FX_BOOL bStartTag) +CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, bool bStartTag) { m_nOffset = m_nBufferOffset + (FX_FILESIZE)m_dwIndex; if (IsEOF()) { return NULL; } CFX_ByteString tag_name, tag_space; - FX_BOOL bEndTag; + bool bEndTag; GetTagName(tag_space, tag_name, bEndTag, bStartTag); if (tag_name.IsEmpty() || bEndTag) { return NULL; @@ -427,7 +427,7 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, FX_BOOL bStartTag } CFX_UTF8Decoder decoder; CFX_WideTextBuf content; - FX_BOOL bCDATA = FALSE; + bool bCDATA = false; int32_t iState = 0; do { while (m_dwIndex < m_dwBufferSize) { @@ -465,10 +465,10 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, FX_BOOL bStartTag InsertContentSegment(bCDATA, dataStr, pElement); content.Clear(); decoder.Clear(); - bCDATA = FALSE; + bCDATA = false; iState = 0; m_dwIndex --; - CXML_Element* pSubElement = ParseElement(pElement, TRUE); + CXML_Element* pSubElement = ParseElement(pElement, true); if (pSubElement == NULL) { break; } @@ -509,10 +509,10 @@ CXML_Element* CXML_Parser::ParseElement(CXML_Element* pParent, FX_BOOL bStartTag InsertContentSegment(bCDATA, dataStr, pElement); content.Clear(); decoder.Clear(); - bCDATA = FALSE; + bCDATA = false; return pElement; } -void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, const CFX_WideStringC& content, CXML_Element* pElement) +void CXML_Parser::InsertContentSegment(bool bCDATA, const CFX_WideStringC& content, CXML_Element* pElement) { if (content.IsEmpty()) { return; @@ -522,16 +522,16 @@ void CXML_Parser::InsertContentSegment(FX_BOOL bCDATA, const CFX_WideStringC& co pElement->m_Children.Add((void*)CXML_Element::Content); pElement->m_Children.Add(pContent); } -static CXML_Element* XML_ContinueParse(CXML_Parser &parser, FX_BOOL bSaveSpaceChars, FX_FILESIZE* pParsedSize) +static CXML_Element* XML_ContinueParse(CXML_Parser &parser, bool bSaveSpaceChars, FX_FILESIZE* pParsedSize) { parser.m_bSaveSpaceChars = bSaveSpaceChars; - CXML_Element* pElement = parser.ParseElement(NULL, FALSE); + CXML_Element* pElement = parser.ParseElement(NULL, false); if (pParsedSize) { *pParsedSize = parser.m_nOffset; } return pElement; } -CXML_Element* CXML_Element::Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars, FX_FILESIZE* pParsedSize) +CXML_Element* CXML_Element::Parse(const void* pBuffer, size_t size, bool bSaveSpaceChars, FX_FILESIZE* pParsedSize) { CXML_Parser parser; if (!parser.Init((uint8_t*)pBuffer, size)) { @@ -539,7 +539,7 @@ CXML_Element* CXML_Element::Parse(const void* pBuffer, size_t size, FX_BOOL bSav } return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); } -CXML_Element* CXML_Element::Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars, FX_FILESIZE* pParsedSize) +CXML_Element* CXML_Element::Parse(IFX_FileRead *pFile, bool bSaveSpaceChars, FX_FILESIZE* pParsedSize) { CXML_Parser parser; if (!parser.Init(pFile)) { @@ -547,7 +547,7 @@ CXML_Element* CXML_Element::Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars, } return XML_ContinueParse(parser, bSaveSpaceChars, pParsedSize); } -CXML_Element* CXML_Element::Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars, FX_FILESIZE* pParsedSize) +CXML_Element* CXML_Element::Parse(IFX_BufferRead *pBuffer, bool bSaveSpaceChars, FX_FILESIZE* pParsedSize) { CXML_Parser parser; if (!parser.Init(pBuffer)) { @@ -600,7 +600,7 @@ void CXML_Element::RemoveChildren() } m_Children.RemoveAll(); } -CFX_ByteString CXML_Element::GetTagName(FX_BOOL bQualified) const +CFX_ByteString CXML_Element::GetTagName(bool bQualified) const { if (!bQualified || m_QSpaceName.IsEmpty()) { return m_TagName; @@ -610,7 +610,7 @@ CFX_ByteString CXML_Element::GetTagName(FX_BOOL bQualified) const bsTag += m_TagName; return bsTag; } -CFX_ByteString CXML_Element::GetNamespace(FX_BOOL bQualified) const +CFX_ByteString CXML_Element::GetNamespace(bool bQualified) const { if (bQualified) { return m_QSpaceName; @@ -644,61 +644,61 @@ void CXML_Element::GetAttrByIndex(int index, CFX_ByteString& space, CFX_ByteStri name = item.m_AttrName; value = item.m_Value; } -FX_BOOL CXML_Element::HasAttr(const CFX_ByteStringC& name) const +bool CXML_Element::HasAttr(const CFX_ByteStringC& name) const { CFX_ByteStringC bsSpace, bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); return m_AttrMap.Lookup(bsSpace, bsName) != NULL; } -FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const +bool CXML_Element::GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const { CFX_ByteStringC bsSpace, bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); return GetAttrValue(bsSpace, bsName, attribute); } -FX_BOOL CXML_Element::GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const +bool CXML_Element::GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const { const CFX_WideString* pValue = m_AttrMap.Lookup(space, name); if (pValue) { attribute = *pValue; - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const +bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const { CFX_ByteStringC bsSpace, bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); const CFX_WideString* pwsValue = m_AttrMap.Lookup(bsSpace, bsName); if (pwsValue) { attribute = pwsValue->GetInteger(); - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name, int& attribute) const +bool CXML_Element::GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name, int& attribute) const { const CFX_WideString* pwsValue = m_AttrMap.Lookup(space, name); if (pwsValue) { attribute = pwsValue->GetInteger(); - return TRUE; + return true; } - return FALSE; + return false; } -FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const +bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const { CFX_ByteStringC bsSpace, bsName; FX_XML_SplitQualifiedName(name, bsSpace, bsName); return GetAttrFloat(bsSpace, bsName, attribute); } -FX_BOOL CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const +bool CXML_Element::GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const { const CFX_WideString* pValue = m_AttrMap.Lookup(space, name); if (pValue) { attribute = pValue->GetFloat(); - return TRUE; + return true; } - return FALSE; + return false; } FX_DWORD CXML_Element::CountChildren() const { diff --git a/core/src/fxcrt/fxcrt_platforms.cpp b/core/src/fxcrt/fxcrt_platforms.cpp index e7182943be..813af02ce4 100644 --- a/core/src/fxcrt/fxcrt_platforms.cpp +++ b/core/src/fxcrt/fxcrt_platforms.cpp @@ -40,20 +40,20 @@ CFXCRT_FileAccess_CRT::~CFXCRT_FileAccess_CRT() { Close(); } -FX_BOOL CFXCRT_FileAccess_CRT::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) +bool CFXCRT_FileAccess_CRT::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) { if (m_hFile) { - return FALSE; + return false; } CFX_ByteString strMode; FXCRT_GetFileModeString(dwMode, strMode); m_hFile = FXSYS_fopen(fileName.GetCStr(), strMode.c_str()); return m_hFile != NULL; } -FX_BOOL CFXCRT_FileAccess_CRT::Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) +bool CFXCRT_FileAccess_CRT::Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) { if (m_hFile) { - return FALSE; + return false; } CFX_WideString strMode; FXCRT_GetFileModeString(dwMode, strMode); @@ -128,45 +128,45 @@ size_t CFXCRT_FileAccess_CRT::WritePos(const void* pBuffer, size_t szBuffer, FX_ FXSYS_fseek(m_hFile, pos, FXSYS_SEEK_SET); return FXSYS_fwrite(pBuffer, 1, szBuffer, m_hFile); } -FX_BOOL CFXCRT_FileAccess_CRT::Flush() +bool CFXCRT_FileAccess_CRT::Flush() { if (!m_hFile) { - return FALSE; + return false; } return !FXSYS_fflush(m_hFile); } -FX_BOOL CFXCRT_FileAccess_CRT::Truncate(FX_FILESIZE szFile) +bool CFXCRT_FileAccess_CRT::Truncate(FX_FILESIZE szFile) { - return FALSE; + return false; } -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName) +bool FX_File_Exist(const CFX_ByteStringC& fileName) { return access(fileName.GetCStr(), F_OK) > -1; } -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName) +bool FX_File_Exist(const CFX_WideStringC& fileName) { return FX_File_Exist(FX_UTF8Encode(fileName)); } -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName) +bool FX_File_Delete(const CFX_ByteStringC& fileName) { return remove(fileName.GetCStr()) > -1; } -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName) +bool FX_File_Delete(const CFX_WideStringC& fileName) { return FX_File_Delete(FX_UTF8Encode(fileName)); } -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) +bool FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { CFXCRT_FileAccess_CRT src, dst; if (!src.Open(fileNameSrc, FX_FILEMODE_ReadOnly)) { - return FALSE; + return false; } FX_FILESIZE size = src.GetSize(); if (!size) { - return FALSE; + return false; } if (!dst.Open(fileNameDst, FX_FILEMODE_Truncate)) { - return FALSE; + return false; } FX_FILESIZE num = 0; uint8_t* pBuffer = FX_Alloc(uint8_t, 32768); @@ -176,17 +176,17 @@ FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& } } FX_Free(pBuffer); - return TRUE; + return true; } -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) +bool FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) { return FX_File_Copy(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); } -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) +bool FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); } -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) +bool FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) { return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); } diff --git a/core/src/fxcrt/fxcrt_platforms.h b/core/src/fxcrt/fxcrt_platforms.h index 4fd0588c94..d95ae4f376 100644 --- a/core/src/fxcrt/fxcrt_platforms.h +++ b/core/src/fxcrt/fxcrt_platforms.h @@ -17,8 +17,8 @@ class CFXCRT_FileAccess_CRT : public IFXCRT_FileAccess public: CFXCRT_FileAccess_CRT(); virtual ~CFXCRT_FileAccess_CRT(); - virtual FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); - virtual FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); + virtual bool Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); + virtual bool Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); virtual void Close(); virtual void Release(); virtual FX_FILESIZE GetSize() const; @@ -28,8 +28,8 @@ public: virtual size_t Write(const void* pBuffer, size_t szBuffer); virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos); virtual size_t WritePos(const void* pBuffer, size_t szBuffer, FX_FILESIZE pos); - virtual FX_BOOL Flush(); - virtual FX_BOOL Truncate(FX_FILESIZE szFile); + virtual bool Flush(); + virtual bool Truncate(FX_FILESIZE szFile); protected: FXSYS_FILE* m_hFile; }; diff --git a/core/src/fxcrt/fxcrt_posix.cpp b/core/src/fxcrt/fxcrt_posix.cpp index 84646efd5c..eb7213e5b0 100644 --- a/core/src/fxcrt/fxcrt_posix.cpp +++ b/core/src/fxcrt/fxcrt_posix.cpp @@ -34,17 +34,17 @@ CFXCRT_FileAccess_Posix::~CFXCRT_FileAccess_Posix() { Close(); } -FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) +bool CFXCRT_FileAccess_Posix::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) { if (m_nFD > -1) { - return FALSE; + return false; } int32_t nFlags, nMasks; FXCRT_Posix_GetFileMode(dwMode, nFlags, nMasks); m_nFD = open(fileName.GetCStr(), nFlags, nMasks); return m_nFD > -1; } -FX_BOOL CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) +bool CFXCRT_FileAccess_Posix::Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) { return Open(FX_UTF8Encode(fileName), dwMode); } @@ -121,48 +121,48 @@ size_t CFXCRT_FileAccess_Posix::WritePos(const void* pBuffer, size_t szBuffer, F } return Write(pBuffer, szBuffer); } -FX_BOOL CFXCRT_FileAccess_Posix::Flush() +bool CFXCRT_FileAccess_Posix::Flush() { if (m_nFD < 0) { - return FALSE; + return false; } return fsync(m_nFD) > -1; } -FX_BOOL CFXCRT_FileAccess_Posix::Truncate(FX_FILESIZE szFile) +bool CFXCRT_FileAccess_Posix::Truncate(FX_FILESIZE szFile) { if (m_nFD < 0) { - return FALSE; + return false; } return !ftruncate(m_nFD, szFile); } -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName) +bool FX_File_Exist(const CFX_ByteStringC& fileName) { return access(fileName.GetCStr(), F_OK) > -1; } -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName) +bool FX_File_Exist(const CFX_WideStringC& fileName) { return FX_File_Exist(FX_UTF8Encode(fileName)); } -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName) +bool FX_File_Delete(const CFX_ByteStringC& fileName) { return remove(fileName.GetCStr()) > -1; } -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName) +bool FX_File_Delete(const CFX_WideStringC& fileName) { return FX_File_Delete(FX_UTF8Encode(fileName)); } -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) +bool FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { CFXCRT_FileAccess_Posix src, dst; if (!src.Open(fileNameSrc, FX_FILEMODE_ReadOnly)) { - return FALSE; + return false; } FX_FILESIZE size = src.GetSize(); if (!size) { - return FALSE; + return false; } if (!dst.Open(fileNameDst, FX_FILEMODE_Truncate)) { - return FALSE; + return false; } size_t num = 0; uint8_t* pBuffer = FX_Alloc(uint8_t, 32768); @@ -174,17 +174,17 @@ FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& num = src.Read(pBuffer, 32768); } FX_Free(pBuffer); - return TRUE; + return true; } -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) +bool FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) { return FX_File_Copy(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); } -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) +bool FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { return rename(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); } -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) +bool FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) { return FX_File_Move(FX_UTF8Encode(fileNameSrc), FX_UTF8Encode(fileNameDst)); } diff --git a/core/src/fxcrt/fxcrt_posix.h b/core/src/fxcrt/fxcrt_posix.h index 39df1c8507..653a150aa8 100644 --- a/core/src/fxcrt/fxcrt_posix.h +++ b/core/src/fxcrt/fxcrt_posix.h @@ -15,8 +15,8 @@ class CFXCRT_FileAccess_Posix : public IFXCRT_FileAccess public: CFXCRT_FileAccess_Posix(); virtual ~CFXCRT_FileAccess_Posix(); - virtual FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); - virtual FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); + virtual bool Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); + virtual bool Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); virtual void Close(); virtual void Release(); virtual FX_FILESIZE GetSize() const; @@ -26,8 +26,8 @@ public: virtual size_t Write(const void* pBuffer, size_t szBuffer); virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos); virtual size_t WritePos(const void* pBuffer, size_t szBuffer, FX_FILESIZE pos); - virtual FX_BOOL Flush(); - virtual FX_BOOL Truncate(FX_FILESIZE szFile); + virtual bool Flush(); + virtual bool Truncate(FX_FILESIZE szFile); protected: int32_t m_nFD; }; diff --git a/core/src/fxcrt/fxcrt_windows.cpp b/core/src/fxcrt/fxcrt_windows.cpp index d4e3830cf2..7effab6919 100644 --- a/core/src/fxcrt/fxcrt_windows.cpp +++ b/core/src/fxcrt/fxcrt_windows.cpp @@ -8,19 +8,19 @@ #include "fxcrt_windows.h" #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName) +bool FX_File_Exist(const CFX_ByteStringC& fileName) { FX_DWORD dwAttri = ::GetFileAttributesA(fileName.GetCStr()); if (dwAttri == -1) { - return FALSE; + return false; } return (dwAttri & FILE_ATTRIBUTE_DIRECTORY) == 0; } -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName) +bool FX_File_Exist(const CFX_WideStringC& fileName) { FX_DWORD dwAttri = ::GetFileAttributesW((LPCWSTR)fileName.GetPtr()); if (dwAttri == -1) { - return FALSE; + return false; } return (dwAttri & FILE_ATTRIBUTE_DIRECTORY) == 0; } @@ -55,10 +55,10 @@ CFXCRT_FileAccess_Win64::~CFXCRT_FileAccess_Win64() { Close(); } -FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) +bool CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) { if (m_hFile) { - return FALSE; + return false; } FX_DWORD dwAccess, dwShare, dwCreation; FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); @@ -68,10 +68,10 @@ FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, FX_DWORD } return m_hFile != NULL; } -FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) +bool CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) { if (m_hFile) { - return FALSE; + return false; } FX_DWORD dwAccess, dwShare, dwCreation; FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); @@ -174,41 +174,41 @@ size_t CFXCRT_FileAccess_Win64::WritePos(const void* pBuffer, size_t szBuffer, F } return Write(pBuffer, szBuffer); } -FX_BOOL CFXCRT_FileAccess_Win64::Flush() +bool CFXCRT_FileAccess_Win64::Flush() { if (!m_hFile) { - return FALSE; + return false; } return ::FlushFileBuffers(m_hFile); } -FX_BOOL CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) +bool CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) { if (SetPosition(szFile) == (FX_FILESIZE) - 1) { - return FALSE; + return false; } return ::SetEndOfFile(m_hFile); } -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName) +bool FX_File_Delete(const CFX_ByteStringC& fileName) { return ::DeleteFileA(fileName.GetCStr()); } -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName) +bool FX_File_Delete(const CFX_WideStringC& fileName) { return ::DeleteFileW((LPCWSTR)fileName.GetPtr()); } -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) +bool FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { - return ::CopyFileA(fileNameSrc.GetCStr(), fileNameDst.GetCStr(), FALSE); + return ::CopyFileA(fileNameSrc.GetCStr(), fileNameDst.GetCStr(), false); } -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) +bool FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) { - return ::CopyFileW((LPCWSTR)fileNameSrc.GetPtr(), (LPCWSTR)fileNameDst.GetPtr(), FALSE); + return ::CopyFileW((LPCWSTR)fileNameSrc.GetPtr(), (LPCWSTR)fileNameDst.GetPtr(), false); } -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) +bool FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst) { return ::MoveFileA(fileNameSrc.GetCStr(), fileNameDst.GetCStr()); } -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) +bool FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst) { return ::MoveFileW((LPCWSTR)fileNameSrc.GetPtr(), (LPCWSTR)fileNameDst.GetPtr()); } diff --git a/core/src/fxcrt/fxcrt_windows.h b/core/src/fxcrt/fxcrt_windows.h index 8dd2cddc82..414b863a50 100644 --- a/core/src/fxcrt/fxcrt_windows.h +++ b/core/src/fxcrt/fxcrt_windows.h @@ -15,8 +15,8 @@ class CFXCRT_FileAccess_Win64 : public IFXCRT_FileAccess public: CFXCRT_FileAccess_Win64(); virtual ~CFXCRT_FileAccess_Win64(); - virtual FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); - virtual FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); + virtual bool Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode); + virtual bool Open(const CFX_WideStringC& fileName, FX_DWORD dwMode); virtual void Close(); virtual void Release(); virtual FX_FILESIZE GetSize() const; @@ -26,8 +26,8 @@ public: virtual size_t Write(const void* pBuffer, size_t szBuffer); virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos); virtual size_t WritePos(const void* pBuffer, size_t szBuffer, FX_FILESIZE pos); - virtual FX_BOOL Flush(); - virtual FX_BOOL Truncate(FX_FILESIZE szFile); + virtual bool Flush(); + virtual bool Truncate(FX_FILESIZE szFile); protected: void* m_hFile; }; diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h index 109c7a43d2..ec8bdc2850 100644 --- a/core/src/fxcrt/xml_int.h +++ b/core/src/fxcrt/xml_int.h @@ -23,7 +23,7 @@ public: { delete this; } - virtual FX_BOOL IsEOF() + virtual bool IsEOF() { return m_dwCurPos >= m_dwSize; } @@ -35,16 +35,16 @@ public: { return 0; } - virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) + virtual bool ReadNextBlock(bool bRestart = false) { if (bRestart) { m_dwCurPos = 0; } if (m_dwCurPos < m_dwSize) { m_dwCurPos = m_dwSize; - return TRUE; + return true; } - return FALSE; + return false; } virtual const uint8_t* GetBlockBuffer() { @@ -85,7 +85,7 @@ public: { delete this; } - virtual FX_BOOL IsEOF() + virtual bool IsEOF() { return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize(); } @@ -97,7 +97,7 @@ public: { return 0; } - virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) + virtual bool ReadNextBlock(bool bRestart = false) { if (bRestart) { m_nStart = 0; @@ -105,7 +105,7 @@ public: FX_FILESIZE nLength = m_pFileRead->GetSize(); m_nStart += (FX_FILESIZE)m_dwSize; if (m_nStart >= nLength) { - return FALSE; + return false; } m_dwSize = (size_t)FX_MIN(FX_XMLDATASTREAM_BufferSize, nLength - m_nStart); if (!m_pBuffer) { @@ -136,28 +136,28 @@ class CXML_Parser public: ~CXML_Parser(); IFX_BufferRead* m_pDataAcc; - FX_BOOL m_bOwnedStream; + bool m_bOwnedStream; FX_FILESIZE m_nOffset; - FX_BOOL m_bSaveSpaceChars; + bool m_bSaveSpaceChars; const uint8_t* m_pBuffer; size_t m_dwBufferSize; FX_FILESIZE m_nBufferOffset; size_t m_dwIndex; - FX_BOOL Init(uint8_t* pBuffer, size_t size); - FX_BOOL Init(IFX_FileRead *pFileRead); - FX_BOOL Init(IFX_BufferRead *pBuffer); - FX_BOOL Init(FX_BOOL bOwndedStream); - FX_BOOL ReadNextBlock(); - FX_BOOL IsEOF(); - FX_BOOL HaveAvailData(); + bool Init(uint8_t* pBuffer, size_t size); + bool Init(IFX_FileRead *pFileRead); + bool Init(IFX_BufferRead *pBuffer); + bool Init(bool bOwndedStream); + bool ReadNextBlock(); + bool IsEOF(); + bool HaveAvailData(); void SkipWhiteSpaces(); void GetName(CFX_ByteString& space, CFX_ByteString& name); void GetAttrValue(CFX_WideString &value); FX_DWORD GetCharRef(); - void GetTagName(CFX_ByteString &space, CFX_ByteString &name, FX_BOOL &bEndTag, FX_BOOL bStartTag = FALSE); + void GetTagName(CFX_ByteString &space, CFX_ByteString &name, bool &bEndTag, bool bStartTag = false); void SkipLiterals(const CFX_ByteStringC& str); - CXML_Element* ParseElement(CXML_Element* pParent, FX_BOOL bStartTag = FALSE); - void InsertContentSegment(FX_BOOL bCDATA, const CFX_WideStringC& content, CXML_Element* pElement); + CXML_Element* ParseElement(CXML_Element* pParent, bool bStartTag = false); + void InsertContentSegment(bool bCDATA, const CFX_WideStringC& content, CXML_Element* pElement); void InsertCDATASegment(CFX_UTF8Decoder& decoder, CXML_Element* pElement); }; void FX_XML_SplitQualifiedName(const CFX_ByteStringC& bsFullName, CFX_ByteStringC &bsSpace, CFX_ByteStringC &bsName); |