From ff46aaf499edcf153ee2f57c7016587aa96dcfa0 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 27 Jul 2015 11:55:29 -0700 Subject: FX Bool considered harmful, part 3 Try to reland this patch after fixing underlying issues that caused it to be reverted. fx_system.h is the only manual edit. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1258093002 . --- core/include/fxcrt/fx_arb.h | 6 +- core/include/fxcrt/fx_basic.h | 118 ++++++++++++++++++------------------ core/include/fxcrt/fx_coordinates.h | 70 ++++++++++----------- core/include/fxcrt/fx_ext.h | 8 +-- core/include/fxcrt/fx_stream.h | 66 ++++++++++---------- core/include/fxcrt/fx_string.h | 4 +- core/include/fxcrt/fx_system.h | 9 --- core/include/fxcrt/fx_ucd.h | 12 ++-- core/include/fxcrt/fx_xml.h | 30 ++++----- 9 files changed, 157 insertions(+), 166 deletions(-) (limited to 'core/include/fxcrt') diff --git a/core/include/fxcrt/fx_arb.h b/core/include/fxcrt/fx_arb.h index 7ce21e5086..5c4173822e 100644 --- a/core/include/fxcrt/fx_arb.h +++ b/core/include/fxcrt/fx_arb.h @@ -15,9 +15,9 @@ public: static IFX_BidiChar* Create(); virtual ~IFX_BidiChar() {} - virtual void SetPolicy(FX_BOOL bSeparateNeutral = TRUE) = 0; - virtual FX_BOOL AppendChar(FX_WCHAR wch) = 0; - virtual FX_BOOL EndChar() = 0; + virtual void SetPolicy(bool bSeparateNeutral = true) = 0; + virtual bool AppendChar(FX_WCHAR wch) = 0; + virtual bool EndChar() = 0; virtual int32_t GetBidiInfo(int32_t &iStart, int32_t &iCount) = 0; virtual void Reset() = 0; }; diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index d575df6e67..c272eb54ec 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -218,9 +218,9 @@ public: CFX_ArchiveLoader& operator >> (CFX_WideString& wstr); - FX_BOOL IsEOF(); + bool IsEOF(); - FX_BOOL Read(void* pBuf, FX_DWORD dwSize); + bool Read(void* pBuf, FX_DWORD dwSize); protected: FX_DWORD m_LoadingPos; @@ -239,7 +239,7 @@ public: virtual void Clear(); - FX_BOOL Flush(); + bool Flush(); int32_t AppendBlock(const void* pBuf, size_t size); @@ -252,7 +252,7 @@ public: protected: - virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0; + virtual bool DoWork(const void* pBuf, size_t size) = 0; FX_STRSIZE m_BufSize; @@ -269,18 +269,18 @@ public: void Clear() override; - FX_BOOL AttachFile(IFX_StreamWrite *pFile, FX_BOOL bTakeover = FALSE); + bool AttachFile(IFX_StreamWrite *pFile, bool bTakeover = false); - FX_BOOL AttachFile(const FX_WCHAR* filename); + bool AttachFile(const FX_WCHAR* filename); - FX_BOOL AttachFile(const FX_CHAR* filename); + bool AttachFile(const FX_CHAR* filename); private: - FX_BOOL DoWork(const void* pBuf, size_t size) override; + bool DoWork(const void* pBuf, size_t size) override; IFX_StreamWrite* m_pFile; - FX_BOOL m_bTakeover; + bool m_bTakeover; }; struct CFX_CharMap { @@ -362,17 +362,17 @@ protected: ~CFX_BasicArray(); - FX_BOOL SetSize(int nNewSize); + bool SetSize(int nNewSize); - FX_BOOL Append(const CFX_BasicArray& src); + bool Append(const CFX_BasicArray& src); - FX_BOOL Copy(const CFX_BasicArray& src); + bool Copy(const CFX_BasicArray& src); uint8_t* InsertSpaceAt(int nIndex, int nCount); - FX_BOOL RemoveAt(int nIndex, int nCount); + bool RemoveAt(int nIndex, int nCount); - FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray); + bool InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray); const void* GetDataPtr(int index) const; protected: @@ -401,7 +401,7 @@ public: return m_nSize - 1; } - FX_BOOL SetSize(int nNewSize) + bool SetSize(int nNewSize) { return CFX_BasicArray::SetSize(nNewSize); } @@ -419,13 +419,13 @@ public: return ((const TYPE*)m_pData)[nIndex]; } - FX_BOOL SetAt(int nIndex, TYPE newElement) + bool SetAt(int nIndex, TYPE newElement) { if (nIndex < 0 || nIndex >= m_nSize) { - return FALSE; + return false; } ((TYPE*)m_pData)[nIndex] = newElement; - return TRUE; + return true; } TYPE& ElementAt(int nIndex) @@ -446,36 +446,36 @@ public: return (TYPE*)m_pData; } - FX_BOOL SetAtGrow(int nIndex, TYPE newElement) + bool SetAtGrow(int nIndex, TYPE newElement) { if (nIndex < 0) { - return FALSE; + return false; } if (nIndex >= m_nSize) if (!SetSize(nIndex + 1)) { - return FALSE; + return false; } ((TYPE*)m_pData)[nIndex] = newElement; - return TRUE; + return true; } - FX_BOOL Add(TYPE newElement) + bool Add(TYPE newElement) { if (m_nSize < m_nMaxSize) { m_nSize ++; } else if (!SetSize(m_nSize + 1)) { - return FALSE; + return false; } ((TYPE*)m_pData)[m_nSize - 1] = newElement; - return TRUE; + return true; } - FX_BOOL Append(const CFX_ArrayTemplate& src) + bool Append(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Append(src); } - FX_BOOL Copy(const CFX_ArrayTemplate& src) + bool Copy(const CFX_ArrayTemplate& src) { return CFX_BasicArray::Copy(src); } @@ -511,23 +511,23 @@ public: return ((TYPE*)m_pData)[nIndex]; } - FX_BOOL InsertAt(int nIndex, TYPE newElement, int nCount = 1) + bool InsertAt(int nIndex, TYPE newElement, int nCount = 1) { if (!InsertSpaceAt(nIndex, nCount)) { - return FALSE; + return false; } while (nCount--) { ((TYPE*)m_pData)[nIndex++] = newElement; } - return TRUE; + return true; } - FX_BOOL RemoveAt(int nIndex, int nCount = 1) + bool RemoveAt(int nIndex, int nCount = 1) { return CFX_BasicArray::RemoveAt(nIndex, nCount); } - FX_BOOL InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) + bool InsertAt(int nStartIndex, const CFX_BasicArray* pNewArray) { return CFX_BasicArray::InsertAt(nStartIndex, pNewArray); } @@ -700,7 +700,7 @@ public: return m_UnitSize; } - void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* param) const; + void* Iterate(bool (*callback)(void* param, void* pData), void* param) const; private: int m_UnitSize; @@ -715,8 +715,8 @@ private: void* m_pIndex; void** GetIndex(int seg_index) const; - void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*callback)(void* param, void* pData), void* param) const; - void* IterateSegment(const uint8_t* pSegment, int count, FX_BOOL (*callback)(void* param, void* pData), void* param) const; + void* IterateIndex(int level, int& start, void** pIndex, bool (*callback)(void* param, void* pData), void* param) const; + void* IterateSegment(const uint8_t* pSegment, int count, bool (*callback)(void* param, void* pData), void* param) const; }; template class CFX_SegmentedArray : public CFX_BaseSegmentedArray @@ -798,12 +798,12 @@ public: return m_nCount; } - FX_BOOL IsEmpty() const + bool IsEmpty() const { return m_nCount == 0; } - FX_BOOL Lookup(void* key, void*& rValue) const; + bool Lookup(void* key, void*& rValue) const; void* GetValueAt(void* key) const; @@ -814,7 +814,7 @@ public: (*this)[key] = newValue; } - FX_BOOL RemoveKey(void* key); + bool RemoveKey(void* key); void RemoveAll(); @@ -830,7 +830,7 @@ public: return m_nHashTableSize; } - void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); + void InitHashTable(FX_DWORD hashSize, bool bAllocNow = true); protected: CAssoc** m_pHashTable; @@ -858,7 +858,7 @@ class CFX_CMapDWordToDWord { public: - FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const; + bool Lookup(FX_DWORD key, FX_DWORD& value) const; void SetAt(FX_DWORD key, FX_DWORD value); @@ -893,12 +893,12 @@ public: return m_nCount; } - FX_BOOL IsEmpty() const + bool IsEmpty() const { return m_nCount == 0; } - FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const; + bool Lookup(const CFX_ByteStringC& key, void*& rValue) const; void*& operator[](const CFX_ByteStringC& key); @@ -907,7 +907,7 @@ public: (*this)[key] = newValue; } - FX_BOOL RemoveKey(const CFX_ByteStringC& key); + bool RemoveKey(const CFX_ByteStringC& key); void RemoveAll(); @@ -925,7 +925,7 @@ public: return m_nHashTableSize; } - void InitHashTable(FX_DWORD hashSize, FX_BOOL bAllocNow = TRUE); + void InitHashTable(FX_DWORD hashSize, bool bAllocNow = true); FX_DWORD HashKey(const CFX_ByteStringC& key) const; protected: @@ -966,7 +966,7 @@ public: void* GetNextValue(FX_POSITION& rNextPosition) const; - FX_BOOL Lookup(const CFX_ByteStringC& key, void*& rValue) const; + bool Lookup(const CFX_ByteStringC& key, void*& rValue) const; void SetAt(const CFX_ByteStringC& key, void* value); @@ -1090,7 +1090,7 @@ struct FX_PRIVATEDATA { PD_CALLBACK_FREEDATA m_pCallback; - FX_BOOL m_bSelfDestruct; + bool m_bSelfDestruct; }; class CFX_PrivateData { @@ -1106,27 +1106,27 @@ public: void* GetPrivateData(void* module_id); - FX_BOOL LookupPrivateData(void* module_id, void* &pData) const + bool LookupPrivateData(void* module_id, void* &pData) const { if (!module_id) { - return FALSE; + return false; } FX_DWORD nCount = m_DataList.GetSize(); for (FX_DWORD n = 0; n < nCount; n ++) { if (m_DataList[n].m_pModuleId == module_id) { pData = m_DataList[n].m_pData; - return TRUE; + return true; } } - return FALSE; + return false; } - FX_BOOL RemovePrivateData(void* module_id); + bool RemovePrivateData(void* module_id); protected: CFX_ArrayTemplate m_DataList; - void AddData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback, FX_BOOL bSelfDestruct); + void AddData(void* module_id, void* pData, PD_CALLBACK_FREEDATA callback, bool bSelfDestruct); }; class CFX_BitStream { @@ -1139,7 +1139,7 @@ public: void ByteAlign(); - FX_BOOL IsEOF() + bool IsEOF() { return m_BitPos >= m_BitSize; } @@ -1252,12 +1252,12 @@ public: return m_pObject; } - FX_BOOL IsNull() const + bool IsNull() const { return m_pObject == NULL; } - FX_BOOL NotNull() const + bool NotNull() const { return m_pObject != NULL; } @@ -1288,7 +1288,7 @@ public: m_pObject = NULL; } - FX_BOOL operator == (const Ref& ref) const + bool operator == (const Ref& ref) const { return m_pObject == ref.m_pObject; } @@ -1300,7 +1300,7 @@ class IFX_Pause { public: virtual ~IFX_Pause() { } - virtual FX_BOOL NeedToPauseNow() = 0; + virtual bool NeedToPauseNow() = 0; }; class CFX_DataFilter { @@ -1310,7 +1310,7 @@ public: void SetDestFilter(CFX_DataFilter* pFilter); - FX_BOOL IsEOF() const + bool IsEOF() const { return m_bEOF; } @@ -1330,7 +1330,7 @@ protected: virtual void v_FilterFinish(CFX_BinaryBuf& dest_buf) = 0; void ReportEOF(FX_DWORD left_input); - FX_BOOL m_bEOF; + bool m_bEOF; FX_DWORD m_SrcPos; diff --git a/core/include/fxcrt/fx_coordinates.h b/core/include/fxcrt/fx_coordinates.h index 3689a4b270..6edaf53f0b 100644 --- a/core/include/fxcrt/fx_coordinates.h +++ b/core/include/fxcrt/fx_coordinates.h @@ -68,11 +68,11 @@ public: y /= lamda; return *this; } - friend FX_BOOL operator == (const FXT_PSV &obj1, const FXT_PSV &obj2) + friend bool operator == (const FXT_PSV &obj1, const FXT_PSV &obj2) { return obj1.x == obj2.x && obj1.y == obj2.y; } - friend FX_BOOL operator != (const FXT_PSV &obj1, const FXT_PSV &obj2) + friend bool operator != (const FXT_PSV &obj1, const FXT_PSV &obj2) { return obj1.x != obj2.x || obj1.y != obj2.y; } @@ -174,21 +174,21 @@ public: { return FXT_PSV::x * v.x + FXT_PSV::y * v.y; } - FX_BOOL IsParallel(baseType otherx, baseType othery) const + bool IsParallel(baseType otherx, baseType othery) const { baseType t = FXT_PSV::x * othery - FXT_PSV::y * otherx; return FXSYS_fabs(t) < 0x0001f; } - FX_BOOL IsParallel(const FXT_VECTOR &v) const + bool IsParallel(const FXT_VECTOR &v) const { return IsParallel(v.x, v.y); } - FX_BOOL IsPerpendicular(baseType otherx, baseType othery) const + bool IsPerpendicular(baseType otherx, baseType othery) const { baseType t = DotProduct(otherx, othery); return FXSYS_fabs(t) < 0x0001f; } - FX_BOOL IsPerpendicular(const FXT_VECTOR &v) const + bool IsPerpendicular(const FXT_VECTOR &v) const { return IsPerpendicular(v.x, v.y); } @@ -340,11 +340,11 @@ public: { Deflate(rt.left, rt.top, rt.top + rt.width, rt.top + rt.height); } - FX_BOOL IsEmpty() const + bool IsEmpty() const { return width <= 0 || height <= 0; } - FX_BOOL IsEmpty(FX_FLOAT fEpsilon) const + bool IsEmpty(FX_FLOAT fEpsilon) const { return width <= fEpsilon || height <= fEpsilon; } @@ -352,15 +352,15 @@ public: { width = height = 0; } - FX_BOOL Contains(baseType x, baseType y) const + bool Contains(baseType x, baseType y) const { return x >= left && x < left + width && y >= top && y < top + height; } - FX_BOOL Contains(const FXT_POINT &p) const + bool Contains(const FXT_POINT &p) const { return Contains(p.x, p.y); } - FX_BOOL Contains(const FXT_RECT &rt) const + bool Contains(const FXT_RECT &rt) const { return rt.left >= left && rt.right() <= right() && rt.top >= top && rt.bottom() <= bottom(); } @@ -501,23 +501,23 @@ public: width = r - left; height = b - top; } - FX_BOOL IntersectWith(const FXT_RECT &rt) const + bool IntersectWith(const FXT_RECT &rt) const { FXT_RECT rect = rt; rect.Intersect(*this); return !rect.IsEmpty(); } - FX_BOOL IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const + bool IntersectWith(const FXT_RECT &rt, FX_FLOAT fEpsilon) const { FXT_RECT rect = rt; rect.Intersect(*this); return !rect.IsEmpty(fEpsilon); } - friend FX_BOOL operator == (const FXT_RECT &rc1, const FXT_RECT &rc2) + friend bool operator == (const FXT_RECT &rc1, const FXT_RECT &rc2) { return rc1.left == rc2.left && rc1.top == rc2.top && rc1.width == rc2.width && rc1.height == rc2.height; } - friend FX_BOOL operator != (const FXT_RECT &rc1, const FXT_RECT &rc2) + friend bool operator != (const FXT_RECT &rc1, const FXT_RECT &rc2) { return rc1.left != rc2.left || rc1.top != rc2.top || rc1.width != rc2.width || rc1.height != rc2.height; } @@ -561,7 +561,7 @@ struct FX_RECT { return bottom - top; } - FX_BOOL IsEmpty() const + bool IsEmpty() const { return right <= left || bottom <= top; } @@ -577,7 +577,7 @@ struct FX_RECT { void Union(const FX_RECT& other_rect); - FX_BOOL operator == (const FX_RECT& src) const + bool operator == (const FX_RECT& src) const { return left == src.left && right == src.right && top == src.top && bottom == src.bottom; } @@ -590,12 +590,12 @@ struct FX_RECT { bottom += dy; } - FX_BOOL Contains(const FX_RECT& other_rect) const + bool Contains(const FX_RECT& other_rect) const { return other_rect.left >= left && other_rect.right <= right && other_rect.top >= top && other_rect.bottom <= bottom; } - FX_BOOL Contains(int x, int y) const + bool Contains(int x, int y) const { return x >= left && x < right && y >= top && y < bottom; } @@ -637,7 +637,7 @@ public: CFX_FloatRect(const FX_RECT& rect); - FX_BOOL IsEmpty() const + bool IsEmpty() const { return left >= right || bottom >= top; } @@ -649,9 +649,9 @@ public: left = right = bottom = top = 0; } - FX_BOOL Contains(const CFX_FloatRect& other_rect) const; + bool Contains(const CFX_FloatRect& other_rect) const; - FX_BOOL Contains(FX_FLOAT x, FX_FLOAT y) const; + bool Contains(FX_FLOAT x, FX_FLOAT y) const; void Transform(const CFX_Matrix* pMatrix); @@ -786,11 +786,11 @@ public: void SetReverse(const CFX_Matrix &m); - void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, FX_BOOL bPrepended = FALSE); + void Concat(FX_FLOAT a, FX_FLOAT b, FX_FLOAT c, FX_FLOAT d, FX_FLOAT e, FX_FLOAT f, bool bPrepended = false); - void Concat(const CFX_Matrix &m, FX_BOOL bPrepended = FALSE); + void Concat(const CFX_Matrix &m, bool bPrepended = false); - void ConcatInverse(const CFX_Matrix& m, FX_BOOL bPrepended = FALSE); + void ConcatInverse(const CFX_Matrix& m, bool bPrepended = false); void Reset() { SetIdentity(); @@ -801,30 +801,30 @@ public: *this = m; } - FX_BOOL IsIdentity() const + bool IsIdentity() const { return a == 1 && b == 0 && c == 0 && d == 1 && e == 0 && f == 0; } - FX_BOOL IsInvertible() const; + bool IsInvertible() const; - FX_BOOL Is90Rotated() const; + bool Is90Rotated() const; - FX_BOOL IsScaled() const; + bool IsScaled() const; - void Translate(FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE); + void Translate(FX_FLOAT x, FX_FLOAT y, bool bPrepended = false); - void TranslateI(int32_t x, int32_t y, FX_BOOL bPrepended = FALSE) + void TranslateI(int32_t x, int32_t y, bool bPrepended = false) { Translate((FX_FLOAT)x, (FX_FLOAT)y, bPrepended); } - void Scale(FX_FLOAT sx, FX_FLOAT sy, FX_BOOL bPrepended = FALSE); + void Scale(FX_FLOAT sx, FX_FLOAT sy, bool bPrepended = false); - void Rotate(FX_FLOAT fRadian, FX_BOOL bPrepended = FALSE); + void Rotate(FX_FLOAT fRadian, bool bPrepended = false); - void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, FX_BOOL bPrepended = FALSE); + void RotateAt(FX_FLOAT fRadian, FX_FLOAT x, FX_FLOAT y, bool bPrepended = false); - void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, FX_BOOL bPrepended = FALSE); + void Shear(FX_FLOAT fAlphaRadian, FX_FLOAT fBetaRadian, bool bPrepended = false); void MatchRect(const CFX_FloatRect &dest, const CFX_FloatRect &src); diff --git a/core/include/fxcrt/fx_ext.h b/core/include/fxcrt/fx_ext.h index f24f4549a3..a04fc529be 100644 --- a/core/include/fxcrt/fx_ext.h +++ b/core/include/fxcrt/fx_ext.h @@ -21,11 +21,11 @@ FX_WCHAR* FXSYS_wcsncpy(FX_WCHAR* dstStr, const FX_WCHAR* srcStr, size_t count) int32_t FXSYS_wcsnicmp(const FX_WCHAR* s1, const FX_WCHAR* s2, size_t count); int32_t FXSYS_strnicmp(const FX_CHAR* s1, const FX_CHAR* s2, size_t count); -inline FX_BOOL FXSYS_islower(int32_t ch) +inline bool FXSYS_islower(int32_t ch) { return ch >= 'a' && ch <= 'z'; } -inline FX_BOOL FXSYS_isupper(int32_t ch) +inline bool FXSYS_isupper(int32_t ch) { return ch >= 'A' && ch <= 'Z'; } @@ -38,8 +38,8 @@ inline int32_t FXSYS_toupper(int32_t ch) return ch < 'a' || ch > 'z' ? ch : (ch - 0x20); } -FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE); -FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, FX_BOOL bIgnoreCase = FALSE); +FX_DWORD FX_HashCode_String_GetA(const FX_CHAR* pStr, int32_t iLength, bool bIgnoreCase = false); +FX_DWORD FX_HashCode_String_GetW(const FX_WCHAR* pStr, int32_t iLength, bool bIgnoreCase = false); #ifdef __cplusplus } diff --git a/core/include/fxcrt/fx_stream.h b/core/include/fxcrt/fx_stream.h index fdd7b11fee..b05e84d83c 100644 --- a/core/include/fxcrt/fx_stream.h +++ b/core/include/fxcrt/fx_stream.h @@ -11,8 +11,8 @@ void* FX_OpenFolder(const FX_CHAR* path); void* FX_OpenFolder(const FX_WCHAR* path); -FX_BOOL FX_GetNextFile(void* handle, CFX_ByteString& filename, FX_BOOL& bFolder); -FX_BOOL FX_GetNextFile(void* handle, CFX_WideString& filename, FX_BOOL& bFolder); +bool FX_GetNextFile(void* handle, CFX_ByteString& filename, bool& bFolder); +bool FX_GetNextFile(void* handle, CFX_WideString& filename, bool& bFolder); void FX_CloseFolder(void* handle); FX_WCHAR FX_GetFolderSeparator(); typedef struct FX_HFILE_ { @@ -53,23 +53,23 @@ size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer); size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESIZE pos); size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuffer); size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szBuffer, FX_FILESIZE pos); -FX_BOOL FX_File_Flush(FX_HFILE hFile); -FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile); -FX_BOOL FX_File_Exist(const CFX_ByteStringC& fileName); -FX_BOOL FX_File_Exist(const CFX_WideStringC& fileName); -FX_BOOL FX_File_Delete(const CFX_ByteStringC& fileName); -FX_BOOL FX_File_Delete(const CFX_WideStringC& fileName); -FX_BOOL FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst); -FX_BOOL FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst); -FX_BOOL FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst); -FX_BOOL FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst); +bool FX_File_Flush(FX_HFILE hFile); +bool FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile); +bool FX_File_Exist(const CFX_ByteStringC& fileName); +bool FX_File_Exist(const CFX_WideStringC& fileName); +bool FX_File_Delete(const CFX_ByteStringC& fileName); +bool FX_File_Delete(const CFX_WideStringC& fileName); +bool FX_File_Copy(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst); +bool FX_File_Copy(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst); +bool FX_File_Move(const CFX_ByteStringC& fileNameSrc, const CFX_ByteStringC& fileNameDst); +bool FX_File_Move(const CFX_WideStringC& fileNameSrc, const CFX_WideStringC& fileNameDst); class IFX_StreamWrite { public: virtual ~IFX_StreamWrite() { } virtual void Release() = 0; - virtual FX_BOOL WriteBlock(const void* pData, size_t size) = 0; + virtual bool WriteBlock(const void* pData, size_t size) = 0; }; class IFX_FileWrite : public IFX_StreamWrite { @@ -79,10 +79,10 @@ public: virtual FX_FILESIZE GetSize() = 0; - virtual FX_BOOL Flush() = 0; + virtual bool Flush() = 0; - virtual FX_BOOL WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0; - virtual FX_BOOL WriteBlock(const void* pData, size_t size) + virtual bool WriteBlock(const void* pData, FX_FILESIZE offset, size_t size) = 0; + virtual bool WriteBlock(const void* pData, size_t size) { return WriteBlock(pData, GetSize(), size); } @@ -96,7 +96,7 @@ public: virtual void Release() = 0; - virtual FX_BOOL IsEOF() = 0; + virtual bool IsEOF() = 0; virtual FX_FILESIZE GetPosition() = 0; @@ -109,9 +109,9 @@ public: virtual FX_FILESIZE GetSize() = 0; - virtual FX_BOOL IsEOF() + virtual bool IsEOF() { - return FALSE; + return false; } virtual FX_FILESIZE GetPosition() @@ -119,14 +119,14 @@ public: return 0; } - virtual FX_BOOL SetRange(FX_FILESIZE offset, FX_FILESIZE size) + virtual bool SetRange(FX_FILESIZE offset, FX_FILESIZE size) { - return FALSE; + return false; } virtual void ClearRange() {} - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; + virtual bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; virtual size_t ReadBlock(void* buffer, size_t size) { @@ -145,21 +145,21 @@ public: virtual FX_FILESIZE GetSize() = 0; - virtual FX_BOOL IsEOF() = 0; + virtual bool IsEOF() = 0; virtual FX_FILESIZE GetPosition() = 0; - virtual FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; + virtual bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) = 0; virtual size_t ReadBlock(void* buffer, size_t size) = 0; - virtual FX_BOOL WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0; - virtual FX_BOOL WriteBlock(const void* buffer, size_t size) + virtual bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) = 0; + virtual bool WriteBlock(const void* buffer, size_t size) { return WriteBlock(buffer, GetSize(), size); } - virtual FX_BOOL Flush() = 0; + virtual bool Flush() = 0; }; IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes); IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, FX_DWORD dwModes); @@ -167,31 +167,31 @@ class IFX_MemoryStream : public IFX_FileStream { public: - virtual FX_BOOL IsConsecutive() const = 0; + virtual bool IsConsecutive() const = 0; virtual void EstimateSize(size_t nInitSize, size_t nGrowSize) = 0; virtual uint8_t* GetBuffer() const = 0; - virtual void AttachBuffer(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE) = 0; + virtual void AttachBuffer(uint8_t* pBuffer, size_t nSize, bool bTakeOver = false) = 0; virtual void DetachBuffer() = 0; }; -IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, size_t nSize, FX_BOOL bTakeOver = FALSE); -IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive = FALSE); +IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, size_t nSize, bool bTakeOver = false); +IFX_MemoryStream* FX_CreateMemoryStream(bool bConsecutive = false); class IFX_BufferRead : public IFX_StreamRead { public: virtual void Release() = 0; - virtual FX_BOOL IsEOF() = 0; + virtual bool IsEOF() = 0; virtual FX_FILESIZE GetPosition() = 0; virtual size_t ReadBlock(void* buffer, size_t size) = 0; - virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) = 0; + virtual bool ReadNextBlock(bool bRestart = false) = 0; virtual const uint8_t* GetBlockBuffer() = 0; diff --git a/core/include/fxcrt/fx_string.h b/core/include/fxcrt/fx_string.h index 8d73555814..736aa32239 100644 --- a/core/include/fxcrt/fx_string.h +++ b/core/include/fxcrt/fx_string.h @@ -670,7 +670,7 @@ public: void Empty(); - FX_BOOL IsEmpty() const + bool IsEmpty() const { return !GetLength(); } @@ -895,7 +895,7 @@ inline bool operator!= (const CFX_WideStringC& lhs, const CFX_WideString& rhs) { return rhs != lhs; } FX_FLOAT FX_atof(const CFX_ByteStringC& str); -void FX_atonum(const CFX_ByteStringC& str, FX_BOOL& bInteger, void* pData); +void FX_atonum(const CFX_ByteStringC& str, bool& bInteger, void* pData); FX_STRSIZE FX_ftoa(FX_FLOAT f, FX_CHAR* buf); CFX_ByteString FX_UTF8Encode(const FX_WCHAR* pwsStr, FX_STRSIZE len); inline CFX_ByteString FX_UTF8Encode(const CFX_WideStringC& wsStr) diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h index 8bc2b4ab2a..9fcaf171bc 100644 --- a/core/include/fxcrt/fx_system.h +++ b/core/include/fxcrt/fx_system.h @@ -71,7 +71,6 @@ typedef void* FX_POSITION; // Keep until fxcrt containers gone typedef unsigned short FX_WORD; // Keep - "an efficient small type" typedef unsigned int FX_DWORD; // Keep - "an efficient type" typedef float FX_FLOAT; // Keep, allow upgrade to doubles. -typedef int FX_BOOL; // Keep, sadly not always 0 or 1. typedef char FX_CHAR; // Keep, questionable signedness. typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars. @@ -84,14 +83,6 @@ typedef int FX_STRSIZE; #define _DEBUG #endif -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - #ifndef NULL #define NULL 0 #endif diff --git a/core/include/fxcrt/fx_ucd.h b/core/include/fxcrt/fx_ucd.h index 7b730bb81a..d9b57811c6 100644 --- a/core/include/fxcrt/fx_ucd.h +++ b/core/include/fxcrt/fx_ucd.h @@ -92,11 +92,11 @@ enum FX_CHARTYPE { FX_CHARTYPE_Arabic = (12 << FX_CHARTYPEBITS), }; FX_DWORD FX_GetUnicodeProperties(FX_WCHAR wch); -FX_BOOL FX_IsCtrlCode(FX_WCHAR ch); -FX_BOOL FX_IsRotationCode(FX_WCHAR ch); -FX_BOOL FX_IsCombinationChar(FX_WCHAR wch); -FX_BOOL FX_IsBidiChar(FX_WCHAR wch); -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_BOOL bRTL, FX_BOOL bVertical); -FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_DWORD dwProps, FX_BOOL bRTL, FX_BOOL bVertical); +bool FX_IsCtrlCode(FX_WCHAR ch); +bool FX_IsRotationCode(FX_WCHAR ch); +bool FX_IsCombinationChar(FX_WCHAR wch); +bool FX_IsBidiChar(FX_WCHAR wch); +FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, bool bRTL, bool bVertical); +FX_WCHAR FX_GetMirrorChar(FX_WCHAR wch, FX_DWORD dwProps, bool bRTL, bool bVertical); #endif // CORE_INCLUDE_FXCRT_FX_UCD_H_ diff --git a/core/include/fxcrt/fx_xml.h b/core/include/fxcrt/fx_xml.h index ba33b2083a..233a8f9bb6 100644 --- a/core/include/fxcrt/fx_xml.h +++ b/core/include/fxcrt/fx_xml.h @@ -38,21 +38,21 @@ public: class CXML_Content { public: - CXML_Content() : m_bCDATA(FALSE), m_Content() {} - void Set(FX_BOOL bCDATA, const CFX_WideStringC& content) + CXML_Content() : m_bCDATA(false), m_Content() {} + void Set(bool bCDATA, const CFX_WideStringC& content) { m_bCDATA = bCDATA; m_Content = content; } - FX_BOOL m_bCDATA; + bool m_bCDATA; CFX_WideString m_Content; }; class CXML_Element { public: - static CXML_Element* Parse(const void* pBuffer, size_t size, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL); - static CXML_Element* Parse(IFX_FileRead *pFile, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL); - static CXML_Element* Parse(IFX_BufferRead *pBuffer, FX_BOOL bSaveSpaceChars = FALSE, FX_FILESIZE* pParsedSize = NULL); + static CXML_Element* Parse(const void* pBuffer, size_t size, bool bSaveSpaceChars = false, FX_FILESIZE* pParsedSize = NULL); + static CXML_Element* Parse(IFX_FileRead *pFile, bool bSaveSpaceChars = false, FX_FILESIZE* pParsedSize = NULL); + static CXML_Element* Parse(IFX_BufferRead *pBuffer, bool bSaveSpaceChars = false, FX_FILESIZE* pParsedSize = NULL); CXML_Element(const CFX_ByteStringC& qSpace, const CFX_ByteStringC& tagName); CXML_Element(const CFX_ByteStringC& qTagName); CXML_Element(); @@ -63,9 +63,9 @@ public: - CFX_ByteString GetTagName(FX_BOOL bQualified = FALSE) const; + CFX_ByteString GetTagName(bool bQualified = false) const; - CFX_ByteString GetNamespace(FX_BOOL bQualified = FALSE) const; + CFX_ByteString GetNamespace(bool bQualified = false) const; CFX_ByteString GetNamespaceURI(const CFX_ByteStringC& qName) const; @@ -81,9 +81,9 @@ public: void GetAttrByIndex(int index, CFX_ByteString &space, CFX_ByteString &name, CFX_WideString &value) const; - FX_BOOL HasAttr(const CFX_ByteStringC& qName) const; + bool HasAttr(const CFX_ByteStringC& qName) const; - FX_BOOL GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const; + bool GetAttrValue(const CFX_ByteStringC& name, CFX_WideString& attribute) const; CFX_WideString GetAttrValue(const CFX_ByteStringC& name) const { CFX_WideString attr; @@ -91,7 +91,7 @@ public: return attr; } - FX_BOOL GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const; + bool GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name, CFX_WideString& attribute) const; CFX_WideString GetAttrValue(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const { CFX_WideString attr; @@ -99,7 +99,7 @@ public: return attr; } - FX_BOOL GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const; + bool GetAttrInteger(const CFX_ByteStringC& name, int& attribute) const; int GetAttrInteger(const CFX_ByteStringC& name) const { int attr = 0; @@ -107,7 +107,7 @@ public: return attr; } - FX_BOOL GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name, int& attribute) const; + bool GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name, int& attribute) const; int GetAttrInteger(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const { int attr = 0; @@ -115,7 +115,7 @@ public: return attr; } - FX_BOOL GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const; + bool GetAttrFloat(const CFX_ByteStringC& name, FX_FLOAT& attribute) const; FX_FLOAT GetAttrFloat(const CFX_ByteStringC& name) const { FX_FLOAT attr = 0; @@ -123,7 +123,7 @@ public: return attr; } - FX_BOOL GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const; + bool GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name, FX_FLOAT& attribute) const; FX_FLOAT GetAttrFloat(const CFX_ByteStringC& space, const CFX_ByteStringC& name) const { FX_FLOAT attr = 0; -- cgit v1.2.3