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

Side by Side Diff: core/include/fxcrt/fx_basic.h

Issue 1177483002: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 5 years, 6 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 | « core/include/fxcrt/fx_arb.h ('k') | core/include/fxcrt/fx_coordinates.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 #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_ 7 #ifndef CORE_INCLUDE_FXCRT_FX_BASIC_H_
8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_ 8 #define CORE_INCLUDE_FXCRT_FX_BASIC_H_
9 9
10 #include "fx_memory.h" 10 #include "fx_memory.h"
(...skipping 23 matching lines...) Expand all
34 CFX_BinaryBuf(FX_STRSIZE size); 34 CFX_BinaryBuf(FX_STRSIZE size);
35 35
36 ~CFX_BinaryBuf(); 36 ~CFX_BinaryBuf();
37 37
38 void Clear(); 38 void Clear();
39 39
40 void EstimateSize(FX_STRSIZE size, FX _STRSIZE alloc_step = 0); 40 void EstimateSize(FX_STRSIZE size, FX _STRSIZE alloc_step = 0);
41 41
42 void AppendBlock(const void* pBuf, FX _STRSIZE size); 42 void AppendBlock(const void* pBuf, FX _STRSIZE size);
43 43
44 void» » » » » AppendFill(FX_BYTE byte, FX_STRS IZE count); 44 void» » » » » AppendFill(uint8_t byte, FX_STRS IZE count);
45 45
46 void AppendString(FX_BSTR str) 46 void AppendString(FX_BSTR str)
47 { 47 {
48 AppendBlock(str.GetPtr(), str.GetLength()); 48 AppendBlock(str.GetPtr(), str.GetLength());
49 } 49 }
50 50
51 inline void»» » » AppendByte(FX_BYTE byte) 51 inline void»» » » AppendByte(uint8_t byte)
52 { 52 {
53 if (m_AllocSize <= m_DataSize) { 53 if (m_AllocSize <= m_DataSize) {
54 ExpandBuf(1); 54 ExpandBuf(1);
55 } 55 }
56 m_pBuffer[m_DataSize++] = byte; 56 m_pBuffer[m_DataSize++] = byte;
57 } 57 }
58 58
59 void InsertBlock(FX_STRSIZE pos, cons t void* pBuf, FX_STRSIZE size); 59 void InsertBlock(FX_STRSIZE pos, cons t void* pBuf, FX_STRSIZE size);
60 60
61 void AttachData(void* pBuf, FX_STRSIZ E size); 61 void AttachData(void* pBuf, FX_STRSIZ E size);
(...skipping 30 matching lines...) Expand all
92 void ExpandBuf(FX_STRSIZE size); 92 void ExpandBuf(FX_STRSIZE size);
93 }; 93 };
94 class CFX_ByteTextBuf : public CFX_BinaryBuf 94 class CFX_ByteTextBuf : public CFX_BinaryBuf
95 { 95 {
96 public: 96 public:
97 97
98 void operator = (FX_BSTR str); 98 void operator = (FX_BSTR str);
99 99
100 void AppendChar(int ch) 100 void AppendChar(int ch)
101 { 101 {
102 AppendByte((FX_BYTE)ch); 102 AppendByte((uint8_t)ch);
103 } 103 }
104 104
105 CFX_ByteTextBuf& operator << (int i); 105 CFX_ByteTextBuf& operator << (int i);
106 106
107 CFX_ByteTextBuf& operator << (FX_DWORD i); 107 CFX_ByteTextBuf& operator << (FX_DWORD i);
108 108
109 CFX_ByteTextBuf& operator << (double f); 109 CFX_ByteTextBuf& operator << (double f);
110 110
111 CFX_ByteTextBuf& operator << (FX_BSTR lpsz); 111 CFX_ByteTextBuf& operator << (FX_BSTR lpsz);
112 112
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_ WCHAR)); 153 CFX_BinaryBuf::Delete(start_index * sizeof(FX_WCHAR), count * sizeof(FX_ WCHAR));
154 } 154 }
155 155
156 CFX_WideStringC GetWideString() const; 156 CFX_WideStringC GetWideString() const;
157 }; 157 };
158 class CFX_ArchiveSaver 158 class CFX_ArchiveSaver
159 { 159 {
160 public: 160 public:
161 CFX_ArchiveSaver() : m_pStream(NULL) {} 161 CFX_ArchiveSaver() : m_pStream(NULL) {}
162 162
163 CFX_ArchiveSaver&» » operator << (FX_BYTE i); 163 CFX_ArchiveSaver&» » operator << (uint8_t i);
164 164
165 CFX_ArchiveSaver& operator << (int i); 165 CFX_ArchiveSaver& operator << (int i);
166 166
167 CFX_ArchiveSaver& operator << (FX_DWORD i); 167 CFX_ArchiveSaver& operator << (FX_DWORD i);
168 168
169 CFX_ArchiveSaver& operator << (FX_FLOAT i); 169 CFX_ArchiveSaver& operator << (FX_FLOAT i);
170 170
171 CFX_ArchiveSaver& operator << (double i); 171 CFX_ArchiveSaver& operator << (double i);
172 172
173 CFX_ArchiveSaver& operator << (FX_BSTR bstr); 173 CFX_ArchiveSaver& operator << (FX_BSTR bstr);
174 174
175 CFX_ArchiveSaver& operator << (FX_LPCWSTR bstr); 175 CFX_ArchiveSaver& operator << (FX_LPCWSTR bstr);
176 176
177 CFX_ArchiveSaver& operator << (const CFX_WideString& wstr); 177 CFX_ArchiveSaver& operator << (const CFX_WideString& wstr);
178 178
179 void Write(const void* pData, FX_STRS IZE dwSize); 179 void Write(const void* pData, FX_STRS IZE dwSize);
180 180
181 FX_INTPTR» » » » GetLength() 181 intptr_t» » » » GetLength()
182 { 182 {
183 return m_SavingBuf.GetSize(); 183 return m_SavingBuf.GetSize();
184 } 184 }
185 185
186 FX_LPCBYTE GetBuffer() 186 FX_LPCBYTE GetBuffer()
187 { 187 {
188 return m_SavingBuf.GetBuffer(); 188 return m_SavingBuf.GetBuffer();
189 } 189 }
190 190
191 void SetStream(IFX_FileStream* pStrea m) 191 void SetStream(IFX_FileStream* pStrea m)
192 { 192 {
193 m_pStream = pStream; 193 m_pStream = pStream;
194 } 194 }
195 protected: 195 protected:
196 196
197 CFX_BinaryBuf m_SavingBuf; 197 CFX_BinaryBuf m_SavingBuf;
198 198
199 IFX_FileStream* m_pStream; 199 IFX_FileStream* m_pStream;
200 }; 200 };
201 class CFX_ArchiveLoader 201 class CFX_ArchiveLoader
202 { 202 {
203 public: 203 public:
204 204
205 CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize); 205 CFX_ArchiveLoader(FX_LPCBYTE pData, FX_DWORD dwSize);
206 206
207 CFX_ArchiveLoader&» » operator >> (FX_BYTE& i); 207 CFX_ArchiveLoader&» » operator >> (uint8_t& i);
208 208
209 CFX_ArchiveLoader& operator >> (int& i); 209 CFX_ArchiveLoader& operator >> (int& i);
210 210
211 CFX_ArchiveLoader& operator >> (FX_DWORD& i); 211 CFX_ArchiveLoader& operator >> (FX_DWORD& i);
212 212
213 CFX_ArchiveLoader& operator >> (FX_FLOAT& i); 213 CFX_ArchiveLoader& operator >> (FX_FLOAT& i);
214 214
215 CFX_ArchiveLoader& operator >> (double& i); 215 CFX_ArchiveLoader& operator >> (double& i);
216 216
217 CFX_ArchiveLoader& operator >> (CFX_ByteString& bstr); 217 CFX_ArchiveLoader& operator >> (CFX_ByteString& bstr);
(...skipping 16 matching lines...) Expand all
234 public: 234 public:
235 IFX_BufferArchive(FX_STRSIZE size); 235 IFX_BufferArchive(FX_STRSIZE size);
236 virtual ~IFX_BufferArchive() { } 236 virtual ~IFX_BufferArchive() { }
237 237
238 virtual void Clear(); 238 virtual void Clear();
239 239
240 240
241 FX_BOOL Flush(); 241 FX_BOOL Flush();
242 242
243 243
244 FX_INT32» » » » AppendBlock(const void* pBuf, size_t siz e); 244 int32_t» » » » AppendBlock(const void* pBuf, size_t siz e);
245 245
246 FX_INT32» » » » AppendByte(FX_BYTE byte); 246 int32_t» » » » AppendByte(uint8_t byte);
247 247
248 FX_INT32» » » » AppendDWord(FX_DWORD i); 248 int32_t» » » » AppendDWord(FX_DWORD i);
249 249
250 250
251 FX_INT32» » » » AppendString(FX_BSTR lpsz); 251 int32_t» » » » AppendString(FX_BSTR lpsz);
252 252
253 protected: 253 protected:
254 254
255 virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0; 255 virtual FX_BOOL DoWork(const void* pBuf, size_t size) = 0;
256 256
257 FX_STRSIZE m_BufSize; 257 FX_STRSIZE m_BufSize;
258 258
259 FX_LPBYTE m_pBuffer; 259 FX_LPBYTE m_pBuffer;
260 260
261 FX_STRSIZE m_Length; 261 FX_STRSIZE m_Length;
(...skipping 13 matching lines...) Expand all
275 private: 275 private:
276 276
277 virtual FX_BOOL DoWork(const void* pBuf, size_t size); 277 virtual FX_BOOL DoWork(const void* pBuf, size_t size);
278 278
279 IFX_StreamWrite *m_pFile; 279 IFX_StreamWrite *m_pFile;
280 280
281 FX_BOOL m_bTakeover; 281 FX_BOOL m_bTakeover;
282 }; 282 };
283 struct CFX_CharMap { 283 struct CFX_CharMap {
284 284
285 static CFX_CharMap*»» GetDefaultMapper(FX_INT32 codepage = 0); 285 static CFX_CharMap*»» GetDefaultMapper(int32_t codepage = 0);
286 286
287 287
288 CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteStri ng& bstr); 288 CFX_WideString (*m_GetWideString)(CFX_CharMap* pMap, const CFX_ByteStri ng& bstr);
289 289
290 CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideStri ng& wstr); 290 CFX_ByteString (*m_GetByteString)(CFX_CharMap* pMap, const CFX_WideStri ng& wstr);
291 291
292 FX_INT32» » (*m_GetCodePage)(); 292 int32_t» » (*m_GetCodePage)();
293 }; 293 };
294 class CFX_UTF8Decoder 294 class CFX_UTF8Decoder
295 { 295 {
296 public: 296 public:
297 CFX_UTF8Decoder() 297 CFX_UTF8Decoder()
298 { 298 {
299 m_PendingBytes = 0; 299 m_PendingBytes = 0;
300 } 300 }
301 301
302 void Clear(); 302 void Clear();
303 303
304 void» » » Input(FX_BYTE byte); 304 void» » » Input(uint8_t byte);
305 305
306 void AppendChar(FX_DWORD ch); 306 void AppendChar(FX_DWORD ch);
307 307
308 void ClearStatus() 308 void ClearStatus()
309 { 309 {
310 m_PendingBytes = 0; 310 m_PendingBytes = 0;
311 } 311 }
312 312
313 CFX_WideStringC GetResult() const 313 CFX_WideStringC GetResult() const
314 { 314 {
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 if (iStart < 0) { 534 if (iStart < 0) {
535 return -1; 535 return -1;
536 } 536 }
537 for (; iStart < (int)m_nSize; iStart ++) 537 for (; iStart < (int)m_nSize; iStart ++)
538 if (((TYPE*)m_pData)[iStart] == data) { 538 if (((TYPE*)m_pData)[iStart] == data) {
539 return iStart; 539 return iStart;
540 } 540 }
541 return -1; 541 return -1;
542 } 542 }
543 }; 543 };
544 typedef CFX_ArrayTemplate<FX_BYTE>» » CFX_ByteArray; 544 typedef CFX_ArrayTemplate<uint8_t>» » CFX_ByteArray;
545 typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray; 545 typedef CFX_ArrayTemplate<FX_WORD> CFX_WordArray;
546 typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray; 546 typedef CFX_ArrayTemplate<FX_DWORD> CFX_DWordArray;
547 typedef CFX_ArrayTemplate<void*> CFX_PtrArray; 547 typedef CFX_ArrayTemplate<void*> CFX_PtrArray;
548 typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray; 548 typedef CFX_ArrayTemplate<FX_FILESIZE> CFX_FileSizeArray;
549 typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray; 549 typedef CFX_ArrayTemplate<FX_FLOAT> CFX_FloatArray;
550 typedef CFX_ArrayTemplate<FX_INT32>» » CFX_Int32Array; 550 typedef CFX_ArrayTemplate<int32_t>» » CFX_Int32Array;
551 template <class ObjectClass> 551 template <class ObjectClass>
552 class CFX_ObjectArray : public CFX_BasicArray 552 class CFX_ObjectArray : public CFX_BasicArray
553 { 553 {
554 public: 554 public:
555 CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {} 555 CFX_ObjectArray() : CFX_BasicArray(sizeof(ObjectClass)) {}
556 556
557 ~CFX_ObjectArray() 557 ~CFX_ObjectArray()
558 { 558 {
559 RemoveAll(); 559 RemoveAll();
560 } 560 }
561 561
562 void Add(const ObjectClass& data) 562 void Add(const ObjectClass& data)
563 { 563 {
564 new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data); 564 new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClass(data);
565 } 565 }
566 566
567 ObjectClass& Add() 567 ObjectClass& Add()
568 { 568 {
569 return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClas s(); 569 return *(ObjectClass*) new ((void*)InsertSpaceAt(m_nSize, 1)) ObjectClas s();
570 } 570 }
571 571
572 void* AddSpace() 572 void* AddSpace()
573 { 573 {
574 return InsertSpaceAt(m_nSize, 1); 574 return InsertSpaceAt(m_nSize, 1);
575 } 575 }
576 576
577 FX_INT32» » Append(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX_INT32 nCount = -1) 577 int32_t» » Append(const CFX_ObjectArray& src, int32_t nStart = 0, i nt32_t nCount = -1)
578 { 578 {
579 if (nCount == 0) { 579 if (nCount == 0) {
580 return 0; 580 return 0;
581 } 581 }
582 FX_INT32 nSize = src.GetSize(); 582 int32_t nSize = src.GetSize();
583 if (!nSize) { 583 if (!nSize) {
584 return 0; 584 return 0;
585 } 585 }
586 FXSYS_assert(nStart > -1 && nStart < nSize); 586 FXSYS_assert(nStart > -1 && nStart < nSize);
587 if (nCount < 0) { 587 if (nCount < 0) {
588 nCount = nSize; 588 nCount = nSize;
589 } 589 }
590 if (nStart + nCount > nSize) { 590 if (nStart + nCount > nSize) {
591 nCount = nSize - nStart; 591 nCount = nSize - nStart;
592 } 592 }
593 if (nCount < 1) { 593 if (nCount < 1) {
594 return 0; 594 return 0;
595 } 595 }
596 nSize = m_nSize; 596 nSize = m_nSize;
597 InsertSpaceAt(m_nSize, nCount); 597 InsertSpaceAt(m_nSize, nCount);
598 ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize); 598 ObjectClass* pStartObj = (ObjectClass*)GetDataPtr(nSize);
599 nSize = nStart + nCount; 599 nSize = nStart + nCount;
600 for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) { 600 for (int32_t i = nStart; i < nSize; i ++, pStartObj++) {
601 new ((void*)pStartObj) ObjectClass(src[i]); 601 new ((void*)pStartObj) ObjectClass(src[i]);
602 } 602 }
603 return nCount; 603 return nCount;
604 } 604 }
605 605
606 FX_INT32» » Copy(const CFX_ObjectArray& src, FX_INT32 nStart = 0, FX _INT32 nCount = -1) 606 int32_t» » Copy(const CFX_ObjectArray& src, int32_t nStart = 0, int 32_t nCount = -1)
607 { 607 {
608 if (nCount == 0) { 608 if (nCount == 0) {
609 return 0; 609 return 0;
610 } 610 }
611 FX_INT32 nSize = src.GetSize(); 611 int32_t nSize = src.GetSize();
612 if (!nSize) { 612 if (!nSize) {
613 return 0; 613 return 0;
614 } 614 }
615 FXSYS_assert(nStart > -1 && nStart < nSize); 615 FXSYS_assert(nStart > -1 && nStart < nSize);
616 if (nCount < 0) { 616 if (nCount < 0) {
617 nCount = nSize; 617 nCount = nSize;
618 } 618 }
619 if (nStart + nCount > nSize) { 619 if (nStart + nCount > nSize) {
620 nCount = nSize - nStart; 620 nCount = nSize - nStart;
621 } 621 }
622 if (nCount < 1) { 622 if (nCount < 1) {
623 return 0; 623 return 0;
624 } 624 }
625 RemoveAll(); 625 RemoveAll();
626 SetSize(nCount); 626 SetSize(nCount);
627 ObjectClass* pStartObj = (ObjectClass*)m_pData; 627 ObjectClass* pStartObj = (ObjectClass*)m_pData;
628 nSize = nStart + nCount; 628 nSize = nStart + nCount;
629 for (FX_INT32 i = nStart; i < nSize; i ++, pStartObj++) { 629 for (int32_t i = nStart; i < nSize; i ++, pStartObj++) {
630 new ((void*)pStartObj) ObjectClass(src[i]); 630 new ((void*)pStartObj) ObjectClass(src[i]);
631 } 631 }
632 return nCount; 632 return nCount;
633 } 633 }
634 634
635 int GetSize() const 635 int GetSize() const
636 { 636 {
637 return m_nSize; 637 return m_nSize;
638 } 638 }
639 639
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
697 return m_UnitSize; 697 return m_UnitSize;
698 } 698 }
699 699
700 void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* par am) const; 700 void* Iterate(FX_BOOL (*callback)(void* param, void* pData), void* par am) const;
701 private: 701 private:
702 702
703 int m_UnitSize; 703 int m_UnitSize;
704 704
705 short m_SegmentSize; 705 short m_SegmentSize;
706 706
707 FX_BYTE» » » m_IndexSize; 707 uint8_t» » » m_IndexSize;
708 708
709 FX_BYTE» » » m_IndexDepth; 709 uint8_t» » » m_IndexDepth;
710 710
711 int m_DataSize; 711 int m_DataSize;
712 712
713 void* m_pIndex; 713 void* m_pIndex;
714 void** GetIndex(int seg_index) const; 714 void** GetIndex(int seg_index) const;
715 void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*cal lback)(void* param, void* pData), void* param) const; 715 void* IterateIndex(int level, int& start, void** pIndex, FX_BOOL (*cal lback)(void* param, void* pData), void* param) const;
716 void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callbac k)(void* param, void* pData), void* param) const; 716 void* IterateSegment(FX_LPCBYTE pSegment, int count, FX_BOOL (*callbac k)(void* param, void* pData), void* param) const;
717 }; 717 };
718 template <class ElementType> 718 template <class ElementType>
719 class CFX_SegmentedArray : public CFX_BaseSegmentedArray 719 class CFX_SegmentedArray : public CFX_BaseSegmentedArray
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 }; 852 };
853 template <class KeyType, class ValueType> 853 template <class KeyType, class ValueType>
854 class CFX_MapPtrTemplate : public CFX_MapPtrToPtr 854 class CFX_MapPtrTemplate : public CFX_MapPtrToPtr
855 { 855 {
856 public: 856 public:
857 CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {} 857 CFX_MapPtrTemplate() : CFX_MapPtrToPtr(10) {}
858 858
859 FX_BOOL Lookup(KeyType key, ValueType& rValue) const 859 FX_BOOL Lookup(KeyType key, ValueType& rValue) const
860 { 860 {
861 FX_LPVOID pValue = NULL; 861 FX_LPVOID pValue = NULL;
862 if (!CFX_MapPtrToPtr::Lookup((void*)(FX_UINTPTR)key, pValue)) { 862 if (!CFX_MapPtrToPtr::Lookup((void*)(uintptr_t)key, pValue)) {
863 return FALSE; 863 return FALSE;
864 } 864 }
865 rValue = (ValueType)(FX_UINTPTR)pValue; 865 rValue = (ValueType)(uintptr_t)pValue;
866 return TRUE; 866 return TRUE;
867 } 867 }
868 868
869 ValueType& operator[](KeyType key) 869 ValueType& operator[](KeyType key)
870 { 870 {
871 return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(FX_UINTPTR)key); 871 return (ValueType&)CFX_MapPtrToPtr::operator []((void*)(uintptr_t)key);
872 } 872 }
873 873
874 void SetAt(KeyType key, ValueType newValue) 874 void SetAt(KeyType key, ValueType newValue)
875 { 875 {
876 CFX_MapPtrToPtr::SetAt((void*)(FX_UINTPTR)key, (void*)(FX_UINTPTR)newVal ue); 876 CFX_MapPtrToPtr::SetAt((void*)(uintptr_t)key, (void*)(uintptr_t)newValue );
877 } 877 }
878 878
879 FX_BOOL RemoveKey(KeyType key) 879 FX_BOOL RemoveKey(KeyType key)
880 { 880 {
881 return CFX_MapPtrToPtr::RemoveKey((void*)(FX_UINTPTR)key); 881 return CFX_MapPtrToPtr::RemoveKey((void*)(uintptr_t)key);
882 } 882 }
883 883
884 void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rVal ue) const 884 void GetNextAssoc(FX_POSITION& rNextPosition, KeyType& rKey, ValueType& rVal ue) const
885 { 885 {
886 void* pKey = NULL; 886 void* pKey = NULL;
887 void* pValue = NULL; 887 void* pValue = NULL;
888 CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue); 888 CFX_MapPtrToPtr::GetNextAssoc(rNextPosition, pKey, pValue);
889 rKey = (KeyType)(FX_UINTPTR)pKey; 889 rKey = (KeyType)(uintptr_t)pKey;
890 rValue = (ValueType)(FX_UINTPTR)pValue; 890 rValue = (ValueType)(uintptr_t)pValue;
891 } 891 }
892 }; 892 };
893 class CFX_CMapDWordToDWord 893 class CFX_CMapDWordToDWord
894 { 894 {
895 public: 895 public:
896 896
897 FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const; 897 FX_BOOL Lookup(FX_DWORD key, FX_DWORD& value) const;
898 898
899 void SetAt(FX_DWORD key, FX_DWORD value); 899 void SetAt(FX_DWORD key, FX_DWORD value);
900 900
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 T *m_pObj; 1412 T *m_pObj;
1413 }; 1413 };
1414 #define FX_DATALIST_LENGTH 1024 1414 #define FX_DATALIST_LENGTH 1024
1415 template<size_t unit> 1415 template<size_t unit>
1416 class CFX_SortListArray 1416 class CFX_SortListArray
1417 { 1417 {
1418 protected: 1418 protected:
1419 1419
1420 struct DataList { 1420 struct DataList {
1421 1421
1422 FX_INT32» start; 1422 int32_t»start;
1423 1423
1424 FX_INT32» count; 1424 int32_t»count;
1425 FX_LPBYTE data; 1425 FX_LPBYTE data;
1426 }; 1426 };
1427 public: 1427 public:
1428 1428
1429 CFX_SortListArray() : m_CurList(0) {} 1429 CFX_SortListArray() : m_CurList(0) {}
1430 1430
1431 ~CFX_SortListArray() 1431 ~CFX_SortListArray()
1432 { 1432 {
1433 Clear(); 1433 Clear();
1434 } 1434 }
1435 1435
1436 1436
1437 void Clear() 1437 void Clear()
1438 { 1438 {
1439 for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) { 1439 for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) {
1440 DataList list = m_DataLists.ElementAt(i); 1440 DataList list = m_DataLists.ElementAt(i);
1441 if (list.data) { 1441 if (list.data) {
1442 FX_Free(list.data); 1442 FX_Free(list.data);
1443 } 1443 }
1444 } 1444 }
1445 m_DataLists.RemoveAll(); 1445 m_DataLists.RemoveAll();
1446 m_CurList = 0; 1446 m_CurList = 0;
1447 } 1447 }
1448 1448
1449 void» » » Append(FX_INT32 nStart, FX_INT32 nCount) 1449 void» » » Append(int32_t nStart, int32_t nCount)
1450 { 1450 {
1451 if (nStart < 0) { 1451 if (nStart < 0) {
1452 return; 1452 return;
1453 } 1453 }
1454 while (nCount > 0) { 1454 while (nCount > 0) {
1455 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH); 1455 int32_t temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
1456 DataList list; 1456 DataList list;
1457 list.data = FX_Alloc2D(FX_BYTE, temp_count, unit); 1457 list.data = FX_Alloc2D(uint8_t, temp_count, unit);
1458 list.start = nStart; 1458 list.start = nStart;
1459 list.count = temp_count; 1459 list.count = temp_count;
1460 Append(list); 1460 Append(list);
1461 nCount -= temp_count; 1461 nCount -= temp_count;
1462 nStart += temp_count; 1462 nStart += temp_count;
1463 } 1463 }
1464 } 1464 }
1465 1465
1466 FX_LPBYTE» » GetAt(FX_INT32 nIndex) 1466 FX_LPBYTE» » GetAt(int32_t nIndex)
1467 { 1467 {
1468 if (nIndex < 0) { 1468 if (nIndex < 0) {
1469 return NULL; 1469 return NULL;
1470 } 1470 }
1471 if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) { 1471 if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) {
1472 return NULL; 1472 return NULL;
1473 } 1473 }
1474 DataList *pCurList = m_DataLists.GetDataPtr(m_CurList); 1474 DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
1475 if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) { 1475 if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) {
1476 pCurList = NULL; 1476 pCurList = NULL;
1477 FX_INT32 iStart = 0; 1477 int32_t iStart = 0;
1478 FX_INT32 iEnd = m_DataLists.GetUpperBound(); 1478 int32_t iEnd = m_DataLists.GetUpperBound();
1479 FX_INT32 iMid = 0; 1479 int32_t iMid = 0;
1480 while (iStart <= iEnd) { 1480 while (iStart <= iEnd) {
1481 iMid = (iStart + iEnd) / 2; 1481 iMid = (iStart + iEnd) / 2;
1482 DataList* list = m_DataLists.GetDataPtr(iMid); 1482 DataList* list = m_DataLists.GetDataPtr(iMid);
1483 if (nIndex < list->start) { 1483 if (nIndex < list->start) {
1484 iEnd = iMid - 1; 1484 iEnd = iMid - 1;
1485 } else if (nIndex >= list->start + list->count) { 1485 } else if (nIndex >= list->start + list->count) {
1486 iStart = iMid + 1; 1486 iStart = iMid + 1;
1487 } else { 1487 } else {
1488 pCurList = list; 1488 pCurList = list;
1489 m_CurList = iMid; 1489 m_CurList = iMid;
1490 break; 1490 break;
1491 } 1491 }
1492 } 1492 }
1493 } 1493 }
1494 return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : N ULL; 1494 return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : N ULL;
1495 } 1495 }
1496 protected: 1496 protected:
1497 void Append(const DataList& list) 1497 void Append(const DataList& list)
1498 { 1498 {
1499 FX_INT32 iStart = 0; 1499 int32_t iStart = 0;
1500 FX_INT32 iEnd = m_DataLists.GetUpperBound(); 1500 int32_t iEnd = m_DataLists.GetUpperBound();
1501 FX_INT32 iFind = 0; 1501 int32_t iFind = 0;
1502 while (iStart <= iEnd) { 1502 while (iStart <= iEnd) {
1503 FX_INT32 iMid = (iStart + iEnd) / 2; 1503 int32_t iMid = (iStart + iEnd) / 2;
1504 DataList* cur_list = m_DataLists.GetDataPtr(iMid); 1504 DataList* cur_list = m_DataLists.GetDataPtr(iMid);
1505 if (list.start < cur_list->start + cur_list->count) { 1505 if (list.start < cur_list->start + cur_list->count) {
1506 iEnd = iMid - 1; 1506 iEnd = iMid - 1;
1507 } else { 1507 } else {
1508 if (iMid == iEnd) { 1508 if (iMid == iEnd) {
1509 iFind = iMid + 1; 1509 iFind = iMid + 1;
1510 break; 1510 break;
1511 } 1511 }
1512 DataList* next_list = m_DataLists.GetDataPtr(iMid + 1); 1512 DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
1513 if (list.start < next_list->start) { 1513 if (list.start < next_list->start) {
1514 iFind = iMid + 1; 1514 iFind = iMid + 1;
1515 break; 1515 break;
1516 } else { 1516 } else {
1517 iStart = iMid + 1; 1517 iStart = iMid + 1;
1518 } 1518 }
1519 } 1519 }
1520 } 1520 }
1521 m_DataLists.InsertAt(iFind, list); 1521 m_DataLists.InsertAt(iFind, list);
1522 } 1522 }
1523 FX_INT32» » m_CurList; 1523 int32_t» » m_CurList;
1524 CFX_ArrayTemplate<DataList> m_DataLists; 1524 CFX_ArrayTemplate<DataList> m_DataLists;
1525 }; 1525 };
1526 template<typename T1, typename T2> 1526 template<typename T1, typename T2>
1527 class CFX_ListArrayTemplate 1527 class CFX_ListArrayTemplate
1528 { 1528 {
1529 public: 1529 public:
1530 1530
1531 void Clear() 1531 void Clear()
1532 { 1532 {
1533 m_Data.Clear(); 1533 m_Data.Clear();
1534 } 1534 }
1535 1535
1536 void» » » Add(FX_INT32 nStart, FX_INT32 nCount) 1536 void» » » Add(int32_t nStart, int32_t nCount)
1537 { 1537 {
1538 m_Data.Append(nStart, nCount); 1538 m_Data.Append(nStart, nCount);
1539 } 1539 }
1540 1540
1541 T2&»» » » operator [] (FX_INT32 nIndex) 1541 T2&»» » » operator [] (int32_t nIndex)
1542 { 1542 {
1543 FX_LPBYTE data = m_Data.GetAt(nIndex); 1543 FX_LPBYTE data = m_Data.GetAt(nIndex);
1544 FXSYS_assert(data != NULL); 1544 FXSYS_assert(data != NULL);
1545 return (T2&)(*(volatile T2*)data); 1545 return (T2&)(*(volatile T2*)data);
1546 } 1546 }
1547 1547
1548 T2*»» » » GetPtrAt(FX_INT32 nIndex) 1548 T2*»» » » GetPtrAt(int32_t nIndex)
1549 { 1549 {
1550 return (T2*)m_Data.GetAt(nIndex); 1550 return (T2*)m_Data.GetAt(nIndex);
1551 } 1551 }
1552 protected: 1552 protected:
1553 T1 m_Data; 1553 T1 m_Data;
1554 }; 1554 };
1555 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, FX_FILESIZ E> CFX_FileSizeListArray; 1555 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, FX_FILESIZ E> CFX_FileSizeListArray;
1556 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD> CFX_DWordListArray; 1556 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD> CFX_DWordListArray;
1557 typedef enum { 1557 typedef enum {
1558 Ready, 1558 Ready,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1604 FX_FLOAT c; 1604 FX_FLOAT c;
1605 FX_FLOAT d; 1605 FX_FLOAT d;
1606 FX_FLOAT e; 1606 FX_FLOAT e;
1607 FX_FLOAT f; 1607 FX_FLOAT f;
1608 FX_FLOAT g; 1608 FX_FLOAT g;
1609 FX_FLOAT h; 1609 FX_FLOAT h;
1610 FX_FLOAT i; 1610 FX_FLOAT i;
1611 }; 1611 };
1612 1612
1613 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ 1613 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_
OLDNEW
« no previous file with comments | « core/include/fxcrt/fx_arb.h ('k') | core/include/fxcrt/fx_coordinates.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698