From 62b2e912dc2a508972fbf01b25f7449c39ff1543 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Fri, 14 Aug 2015 21:49:19 -0700 Subject: Merge to XFA: Use override in more classes in core/ R=tsepez@chromium.org Review URL: https://codereview.chromium.org/1292613003 . (cherry picked from commit c2c3f7b5f0396409451a9d344f35ec1929a76e9f) Review URL: https://codereview.chromium.org/1296043002 . --- core/src/fxcrt/extension.h | 27 ++++++++++++++---------- core/src/fxcrt/fxcrt_platforms.h | 34 ++++++++++++++++--------------- core/src/fxcrt/fxcrt_posix.h | 34 ++++++++++++++++--------------- core/src/fxcrt/fxcrt_windows.h | 34 ++++++++++++++++--------------- core/src/fxcrt/xml_int.h | 44 ++++++++++++++++++++++++---------------- 5 files changed, 96 insertions(+), 77 deletions(-) (limited to 'core/src/fxcrt') diff --git a/core/src/fxcrt/extension.h b/core/src/fxcrt/extension.h index 0fdf8ab7bf..9960c03349 100644 --- a/core/src/fxcrt/extension.h +++ b/core/src/fxcrt/extension.h @@ -30,40 +30,43 @@ class IFXCRT_FileAccess { virtual FX_BOOL Truncate(FX_FILESIZE szFile) = 0; }; IFXCRT_FileAccess* FXCRT_FileAccess_Create(); + class CFX_CRTFileAccess : public IFX_FileAccess { public: CFX_CRTFileAccess() : m_RefCount(0) {} - virtual void Release() { + // IFX_FileAccess + void Release() override { if (--m_RefCount == 0) delete this; } - IFX_FileAccess* Retain() { + IFX_FileAccess* Retain() override { m_RefCount++; return (IFX_FileAccess*)this; } - virtual FX_BOOL Init(const CFX_WideStringC& wsPath) { + void GetPath(CFX_WideString& wsPath) override { wsPath = m_path; } + + IFX_FileStream* CreateFileStream(FX_DWORD dwModes) override { + return FX_CreateFileStream(m_path, dwModes); + } + + FX_BOOL Init(const CFX_WideStringC& wsPath) { m_path = wsPath; m_RefCount = 1; return TRUE; } - virtual void GetPath(CFX_WideString& wsPath) { wsPath = m_path; } - - virtual IFX_FileStream* CreateFileStream(FX_DWORD dwModes) { - return FX_CreateFileStream(m_path, dwModes); - } - protected: CFX_WideString m_path; FX_DWORD m_RefCount; }; + class CFX_CRTFileStream final : public IFX_FileStream { public: CFX_CRTFileStream(IFXCRT_FileAccess* pFA) : m_pFile(pFA), m_dwCount(1) {} - ~CFX_CRTFileStream() { + ~CFX_CRTFileStream() override { if (m_pFile) { m_pFile->Release(); } @@ -100,6 +103,7 @@ class CFX_CRTFileStream final : public IFX_FileStream { IFXCRT_FileAccess* m_pFile; FX_DWORD m_dwCount; }; + #define FX_MEMSTREAM_BlockSize (64 * 1024) #define FX_MEMSTREAM_Consecutive 0x01 #define FX_MEMSTREAM_TakeOver 0x02 @@ -124,7 +128,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { m_dwFlags = FX_MEMSTREAM_Consecutive | (bTakeOver ? FX_MEMSTREAM_TakeOver : 0); } - ~CFX_MemoryStream() { + ~CFX_MemoryStream() override { if (m_dwFlags & FX_MEMSTREAM_TakeOver) { for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { FX_Free((uint8_t*)m_Blocks[i]); @@ -317,6 +321,7 @@ class CFX_MemoryStream final : public IFX_MemoryStream { return TRUE; } }; + #ifdef __cplusplus extern "C" { #endif diff --git a/core/src/fxcrt/fxcrt_platforms.h b/core/src/fxcrt/fxcrt_platforms.h index 5870c76469..393df694eb 100644 --- a/core/src/fxcrt/fxcrt_platforms.h +++ b/core/src/fxcrt/fxcrt_platforms.h @@ -15,22 +15,24 @@ void FXCRT_GetFileModeString(FX_DWORD dwModes, CFX_WideString& wsMode); 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 void Close(); - virtual void Release(); - virtual FX_FILESIZE GetSize() const; - virtual FX_FILESIZE GetPosition() const; - virtual FX_FILESIZE SetPosition(FX_FILESIZE pos); - virtual size_t Read(void* pBuffer, size_t szBuffer); - 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); + ~CFXCRT_FileAccess_CRT() override; + + // IFXCRT_FileAccess + FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) override; + FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) override; + void Close() override; + void Release() override; + FX_FILESIZE GetSize() const override; + FX_FILESIZE GetPosition() const override; + FX_FILESIZE SetPosition(FX_FILESIZE pos) override; + size_t Read(void* pBuffer, size_t szBuffer) override; + size_t Write(const void* pBuffer, size_t szBuffer) override; + size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) override; + size_t WritePos(const void* pBuffer, + size_t szBuffer, + FX_FILESIZE pos) override; + FX_BOOL Flush() override; + FX_BOOL Truncate(FX_FILESIZE szFile) override; protected: FXSYS_FILE* m_hFile; diff --git a/core/src/fxcrt/fxcrt_posix.h b/core/src/fxcrt/fxcrt_posix.h index 19e11da4a8..b24721dddd 100644 --- a/core/src/fxcrt/fxcrt_posix.h +++ b/core/src/fxcrt/fxcrt_posix.h @@ -15,22 +15,24 @@ 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 void Close(); - virtual void Release(); - virtual FX_FILESIZE GetSize() const; - virtual FX_FILESIZE GetPosition() const; - virtual FX_FILESIZE SetPosition(FX_FILESIZE pos); - virtual size_t Read(void* pBuffer, size_t szBuffer); - 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); + ~CFXCRT_FileAccess_Posix() override; + + // IFXCRT_FileAccess + FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) override; + FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) override; + void Close() override; + void Release() override; + FX_FILESIZE GetSize() const override; + FX_FILESIZE GetPosition() const override; + FX_FILESIZE SetPosition(FX_FILESIZE pos) override; + size_t Read(void* pBuffer, size_t szBuffer) override; + size_t Write(const void* pBuffer, size_t szBuffer) override; + size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) override; + size_t WritePos(const void* pBuffer, + size_t szBuffer, + FX_FILESIZE pos) override; + FX_BOOL Flush() override; + FX_BOOL Truncate(FX_FILESIZE szFile) override; protected: int32_t m_nFD; diff --git a/core/src/fxcrt/fxcrt_windows.h b/core/src/fxcrt/fxcrt_windows.h index bb00410e19..b3a20a91e5 100644 --- a/core/src/fxcrt/fxcrt_windows.h +++ b/core/src/fxcrt/fxcrt_windows.h @@ -13,22 +13,24 @@ 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 void Close(); - virtual void Release(); - virtual FX_FILESIZE GetSize() const; - virtual FX_FILESIZE GetPosition() const; - virtual FX_FILESIZE SetPosition(FX_FILESIZE pos); - virtual size_t Read(void* pBuffer, size_t szBuffer); - 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); + ~CFXCRT_FileAccess_Win64() override; + + // IFXCRT_FileAccess + FX_BOOL Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) override; + FX_BOOL Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) override; + void Close() override; + void Release() override; + FX_FILESIZE GetSize() const override; + FX_FILESIZE GetPosition() const override; + FX_FILESIZE SetPosition(FX_FILESIZE pos) override; + size_t Read(void* pBuffer, size_t szBuffer) override; + size_t Write(const void* pBuffer, size_t szBuffer) override; + size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) override; + size_t WritePos(const void* pBuffer, + size_t szBuffer, + FX_FILESIZE pos) override; + FX_BOOL Flush() override; + FX_BOOL Truncate(FX_FILESIZE szFile) override; protected: void* m_hFile; diff --git a/core/src/fxcrt/xml_int.h b/core/src/fxcrt/xml_int.h index 1008436c84..6020f45819 100644 --- a/core/src/fxcrt/xml_int.h +++ b/core/src/fxcrt/xml_int.h @@ -13,12 +13,14 @@ class CXML_DataBufAcc : public IFX_BufferRead { public: CXML_DataBufAcc(const uint8_t* pBuffer, size_t size) : m_pBuffer(pBuffer), m_dwSize(size), m_dwCurPos(0) {} - virtual ~CXML_DataBufAcc() {} - virtual void Release() { delete this; } - virtual FX_BOOL IsEOF() { return m_dwCurPos >= m_dwSize; } - virtual FX_FILESIZE GetPosition() { return (FX_FILESIZE)m_dwCurPos; } - virtual size_t ReadBlock(void* buffer, size_t size) { return 0; } - virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) { + ~CXML_DataBufAcc() override {} + + // IFX_BufferRead + void Release() override { delete this; } + FX_BOOL IsEOF() override { return m_dwCurPos >= m_dwSize; } + FX_FILESIZE GetPosition() override { return (FX_FILESIZE)m_dwCurPos; } + size_t ReadBlock(void* buffer, size_t size) override { return 0; } + FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override { if (bRestart) { m_dwCurPos = 0; } @@ -28,15 +30,16 @@ class CXML_DataBufAcc : public IFX_BufferRead { } return FALSE; } - virtual const uint8_t* GetBlockBuffer() { return m_pBuffer; } - virtual size_t GetBlockSize() { return m_dwSize; } - virtual FX_FILESIZE GetBlockOffset() { return 0; } + const uint8_t* GetBlockBuffer() override { return m_pBuffer; } + size_t GetBlockSize() override { return m_dwSize; } + FX_FILESIZE GetBlockOffset() override { return 0; } protected: const uint8_t* m_pBuffer; size_t m_dwSize; size_t m_dwCurPos; }; + #define FX_XMLDATASTREAM_BufferSize (32 * 1024) class CXML_DataStmAcc : public IFX_BufferRead { public: @@ -44,18 +47,21 @@ class CXML_DataStmAcc : public IFX_BufferRead { : m_pFileRead(pFileRead), m_pBuffer(NULL), m_nStart(0), m_dwSize(0) { FXSYS_assert(m_pFileRead != NULL); } - virtual ~CXML_DataStmAcc() { + ~CXML_DataStmAcc() override { if (m_pBuffer) { FX_Free(m_pBuffer); } } - virtual void Release() { delete this; } - virtual FX_BOOL IsEOF() { + + void Release() override { delete this; } + FX_BOOL IsEOF() override { return m_nStart + (FX_FILESIZE)m_dwSize >= m_pFileRead->GetSize(); } - virtual FX_FILESIZE GetPosition() { return m_nStart + (FX_FILESIZE)m_dwSize; } - virtual size_t ReadBlock(void* buffer, size_t size) { return 0; } - virtual FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) { + FX_FILESIZE GetPosition() override { + return m_nStart + (FX_FILESIZE)m_dwSize; + } + size_t ReadBlock(void* buffer, size_t size) override { return 0; } + FX_BOOL ReadNextBlock(FX_BOOL bRestart = FALSE) override { if (bRestart) { m_nStart = 0; } @@ -70,9 +76,9 @@ class CXML_DataStmAcc : public IFX_BufferRead { } return m_pFileRead->ReadBlock(m_pBuffer, m_nStart, m_dwSize); } - virtual const uint8_t* GetBlockBuffer() { return (const uint8_t*)m_pBuffer; } - virtual size_t GetBlockSize() { return m_dwSize; } - virtual FX_FILESIZE GetBlockOffset() { return m_nStart; } + const uint8_t* GetBlockBuffer() override { return (const uint8_t*)m_pBuffer; } + size_t GetBlockSize() override { return m_dwSize; } + FX_FILESIZE GetBlockOffset() override { return m_nStart; } protected: IFX_FileRead* m_pFileRead; @@ -80,6 +86,7 @@ class CXML_DataStmAcc : public IFX_BufferRead { FX_FILESIZE m_nStart; size_t m_dwSize; }; + class CXML_Parser { public: ~CXML_Parser(); @@ -113,6 +120,7 @@ class CXML_Parser { 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); -- cgit v1.2.3