Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(137)

Side by Side Diff: xfa/fgas/crt/fgas_stream.cpp

Issue 1821043003: Remove FX_WORD in favor of uint16_t. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Use stdint.h directly, bitfield minefield. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fgas/crt/fgas_stream.h ('k') | xfa/fgas/crt/fgas_utils.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "xfa/fgas/crt/fgas_stream.h" 7 #include "xfa/fgas/crt/fgas_stream.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize); 194 virtual int32_t ReadData(uint8_t* pBuffer, int32_t iBufferSize);
195 virtual int32_t ReadString(FX_WCHAR* pStr, 195 virtual int32_t ReadString(FX_WCHAR* pStr,
196 int32_t iMaxLength, 196 int32_t iMaxLength,
197 FX_BOOL& bEOS, 197 FX_BOOL& bEOS,
198 int32_t const* pByteSize = NULL); 198 int32_t const* pByteSize = NULL);
199 virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); 199 virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize);
200 virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); 200 virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength);
201 virtual void Flush(); 201 virtual void Flush();
202 virtual FX_BOOL SetLength(int32_t iLength); 202 virtual FX_BOOL SetLength(int32_t iLength);
203 virtual int32_t GetBOM(uint8_t bom[4]) const; 203 virtual int32_t GetBOM(uint8_t bom[4]) const;
204 virtual FX_WORD GetCodePage() const; 204 virtual uint16_t GetCodePage() const;
205 virtual FX_WORD SetCodePage(FX_WORD wCodePage); 205 virtual uint16_t SetCodePage(uint16_t wCodePage);
206 virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, 206 virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess,
207 int32_t iOffset, 207 int32_t iOffset,
208 int32_t iLength); 208 int32_t iLength);
209 209
210 protected: 210 protected:
211 FX_STREAMTYPE m_eStreamType; 211 FX_STREAMTYPE m_eStreamType;
212 CFX_StreamImp* m_pStreamImp; 212 CFX_StreamImp* m_pStreamImp;
213 FX_DWORD m_dwAccess; 213 FX_DWORD m_dwAccess;
214 int32_t m_iTotalSize; 214 int32_t m_iTotalSize;
215 int32_t m_iPosition; 215 int32_t m_iPosition;
(...skipping 19 matching lines...) Expand all
235 virtual int32_t ReadString(FX_WCHAR* pStr, 235 virtual int32_t ReadString(FX_WCHAR* pStr,
236 int32_t iMaxLength, 236 int32_t iMaxLength,
237 FX_BOOL& bEOS, 237 FX_BOOL& bEOS,
238 int32_t const* pByteSize = NULL); 238 int32_t const* pByteSize = NULL);
239 virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize); 239 virtual int32_t WriteData(const uint8_t* pBuffer, int32_t iBufferSize);
240 virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength); 240 virtual int32_t WriteString(const FX_WCHAR* pStr, int32_t iLength);
241 virtual void Flush(); 241 virtual void Flush();
242 virtual FX_BOOL SetLength(int32_t iLength); 242 virtual FX_BOOL SetLength(int32_t iLength);
243 243
244 virtual int32_t GetBOM(uint8_t bom[4]) const; 244 virtual int32_t GetBOM(uint8_t bom[4]) const;
245 virtual FX_WORD GetCodePage() const; 245 virtual uint16_t GetCodePage() const;
246 virtual FX_WORD SetCodePage(FX_WORD wCodePage); 246 virtual uint16_t SetCodePage(uint16_t wCodePage);
247 247
248 virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess, 248 virtual IFX_Stream* CreateSharedStream(FX_DWORD dwAccess,
249 int32_t iOffset, 249 int32_t iOffset,
250 int32_t iLength); 250 int32_t iLength);
251 251
252 protected: 252 protected:
253 FX_WORD m_wCodePage; 253 uint16_t m_wCodePage;
254 int32_t m_wBOMLength; 254 int32_t m_wBOMLength;
255 FX_DWORD m_dwBOM; 255 FX_DWORD m_dwBOM;
256 uint8_t* m_pBuf; 256 uint8_t* m_pBuf;
257 int32_t m_iBufSize; 257 int32_t m_iBufSize;
258 FX_BOOL m_bDelStream; 258 FX_BOOL m_bDelStream;
259 IFX_Stream* m_pStreamImp; 259 IFX_Stream* m_pStreamImp;
260 int32_t m_iRefCount; 260 int32_t m_iRefCount;
261 void InitStream(); 261 void InitStream();
262 }; 262 };
263 263
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 } 1008 }
1009 int32_t CFX_TextStream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) { 1009 int32_t CFX_TextStream::WriteData(const uint8_t* pBuffer, int32_t iBufferSize) {
1010 return m_pStreamImp->WriteData(pBuffer, iBufferSize); 1010 return m_pStreamImp->WriteData(pBuffer, iBufferSize);
1011 } 1011 }
1012 void CFX_TextStream::Flush() { 1012 void CFX_TextStream::Flush() {
1013 m_pStreamImp->Flush(); 1013 m_pStreamImp->Flush();
1014 } 1014 }
1015 FX_BOOL CFX_TextStream::SetLength(int32_t iLength) { 1015 FX_BOOL CFX_TextStream::SetLength(int32_t iLength) {
1016 return m_pStreamImp->SetLength(iLength); 1016 return m_pStreamImp->SetLength(iLength);
1017 } 1017 }
1018 FX_WORD CFX_TextStream::GetCodePage() const { 1018 uint16_t CFX_TextStream::GetCodePage() const {
1019 return m_wCodePage; 1019 return m_wCodePage;
1020 } 1020 }
1021 IFX_Stream* CFX_TextStream::CreateSharedStream(FX_DWORD dwAccess, 1021 IFX_Stream* CFX_TextStream::CreateSharedStream(FX_DWORD dwAccess,
1022 int32_t iOffset, 1022 int32_t iOffset,
1023 int32_t iLength) { 1023 int32_t iLength) {
1024 IFX_Stream* pSR = 1024 IFX_Stream* pSR =
1025 m_pStreamImp->CreateSharedStream(dwAccess, iOffset, iLength); 1025 m_pStreamImp->CreateSharedStream(dwAccess, iOffset, iLength);
1026 if (pSR == NULL) { 1026 if (pSR == NULL) {
1027 return NULL; 1027 return NULL;
1028 } 1028 }
1029 if (dwAccess & FX_STREAMACCESS_Text) { 1029 if (dwAccess & FX_STREAMACCESS_Text) {
1030 return new CFX_TextStream(pSR, TRUE); 1030 return new CFX_TextStream(pSR, TRUE);
1031 } 1031 }
1032 return pSR; 1032 return pSR;
1033 } 1033 }
1034 int32_t CFX_TextStream::GetBOM(uint8_t bom[4]) const { 1034 int32_t CFX_TextStream::GetBOM(uint8_t bom[4]) const {
1035 if (m_wBOMLength < 1) { 1035 if (m_wBOMLength < 1) {
1036 return 0; 1036 return 0;
1037 } 1037 }
1038 *(FX_DWORD*)bom = m_dwBOM; 1038 *(FX_DWORD*)bom = m_dwBOM;
1039 return m_wBOMLength; 1039 return m_wBOMLength;
1040 } 1040 }
1041 FX_WORD CFX_TextStream::SetCodePage(FX_WORD wCodePage) { 1041 uint16_t CFX_TextStream::SetCodePage(uint16_t wCodePage) {
1042 if (m_wBOMLength > 0) { 1042 if (m_wBOMLength > 0) {
1043 return m_wCodePage; 1043 return m_wCodePage;
1044 } 1044 }
1045 FX_WORD v = m_wCodePage; 1045 uint16_t v = m_wCodePage;
1046 m_wCodePage = wCodePage; 1046 m_wCodePage = wCodePage;
1047 return v; 1047 return v;
1048 } 1048 }
1049 int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr, 1049 int32_t CFX_TextStream::ReadString(FX_WCHAR* pStr,
1050 int32_t iMaxLength, 1050 int32_t iMaxLength,
1051 FX_BOOL& bEOS, 1051 FX_BOOL& bEOS,
1052 int32_t const* pByteSize) { 1052 int32_t const* pByteSize) {
1053 FXSYS_assert(pStr != NULL && iMaxLength > 0); 1053 FXSYS_assert(pStr != NULL && iMaxLength > 0);
1054 if (m_pStreamImp == NULL) { 1054 if (m_pStreamImp == NULL) {
1055 return -1; 1055 return -1;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 return FALSE; 1414 return FALSE;
1415 } 1415 }
1416 return m_pStreamImp->SetLength(iLength); 1416 return m_pStreamImp->SetLength(iLength);
1417 } 1417 }
1418 int32_t CFX_Stream::GetBOM(uint8_t bom[4]) const { 1418 int32_t CFX_Stream::GetBOM(uint8_t bom[4]) const {
1419 if (m_pStreamImp == NULL) { 1419 if (m_pStreamImp == NULL) {
1420 return -1; 1420 return -1;
1421 } 1421 }
1422 return 0; 1422 return 0;
1423 } 1423 }
1424 FX_WORD CFX_Stream::GetCodePage() const { 1424 uint16_t CFX_Stream::GetCodePage() const {
1425 #if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ 1425 #if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_
1426 return FX_CODEPAGE_UTF16LE; 1426 return FX_CODEPAGE_UTF16LE;
1427 #else 1427 #else
1428 return FX_CODEPAGE_UTF16BE; 1428 return FX_CODEPAGE_UTF16BE;
1429 #endif 1429 #endif
1430 } 1430 }
1431 FX_WORD CFX_Stream::SetCodePage(FX_WORD wCodePage) { 1431 uint16_t CFX_Stream::SetCodePage(uint16_t wCodePage) {
1432 #if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_ 1432 #if _FX_ENDIAN_ == _FX_LITTLE_ENDIAN_
1433 return FX_CODEPAGE_UTF16LE; 1433 return FX_CODEPAGE_UTF16LE;
1434 #else 1434 #else
1435 return FX_CODEPAGE_UTF16BE; 1435 return FX_CODEPAGE_UTF16BE;
1436 #endif 1436 #endif
1437 } 1437 }
1438 IFX_Stream* CFX_Stream::CreateSharedStream(FX_DWORD dwAccess, 1438 IFX_Stream* CFX_Stream::CreateSharedStream(FX_DWORD dwAccess,
1439 int32_t iOffset, 1439 int32_t iOffset,
1440 int32_t iLength) { 1440 int32_t iLength) {
1441 FXSYS_assert(iLength > 0); 1441 FXSYS_assert(iLength > 0);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1617 return m_pStream->WriteData((const uint8_t*)pData, (int32_t)size) == 1617 return m_pStream->WriteData((const uint8_t*)pData, (int32_t)size) ==
1618 (int32_t)size; 1618 (int32_t)size;
1619 } 1619 }
1620 FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData, 1620 FX_BOOL CFGAS_FileWrite::WriteBlock(const void* pData,
1621 FX_FILESIZE offset, 1621 FX_FILESIZE offset,
1622 size_t size) { 1622 size_t size) {
1623 m_pStream->Seek(FX_STREAMSEEK_Begin, offset); 1623 m_pStream->Seek(FX_STREAMSEEK_Begin, offset);
1624 int32_t iLen = m_pStream->WriteData((uint8_t*)pData, (int32_t)size); 1624 int32_t iLen = m_pStream->WriteData((uint8_t*)pData, (int32_t)size);
1625 return iLen == (int32_t)size; 1625 return iLen == (int32_t)size;
1626 } 1626 }
OLDNEW
« no previous file with comments | « xfa/fgas/crt/fgas_stream.h ('k') | xfa/fgas/crt/fgas_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698