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

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

Issue 1172793002: Merge to XFA: Use stdint.h types throughout PDFium. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
1421 T *m_pObj; 1421 T *m_pObj;
1422 }; 1422 };
1423 #define FX_DATALIST_LENGTH 1024 1423 #define FX_DATALIST_LENGTH 1024
1424 template<size_t unit> 1424 template<size_t unit>
1425 class CFX_SortListArray 1425 class CFX_SortListArray
1426 { 1426 {
1427 protected: 1427 protected:
1428 1428
1429 struct DataList { 1429 struct DataList {
1430 1430
1431 FX_INT32» start; 1431 int32_t»start;
1432 1432
1433 FX_INT32» count; 1433 int32_t»count;
1434 FX_LPBYTE data; 1434 FX_LPBYTE data;
1435 }; 1435 };
1436 public: 1436 public:
1437 1437
1438 CFX_SortListArray() : m_CurList(0) {} 1438 CFX_SortListArray() : m_CurList(0) {}
1439 1439
1440 ~CFX_SortListArray() 1440 ~CFX_SortListArray()
1441 { 1441 {
1442 Clear(); 1442 Clear();
1443 } 1443 }
1444 1444
1445 1445
1446 void Clear() 1446 void Clear()
1447 { 1447 {
1448 for (FX_INT32 i = m_DataLists.GetUpperBound(); i >= 0; i--) { 1448 for (int32_t i = m_DataLists.GetUpperBound(); i >= 0; i--) {
1449 DataList list = m_DataLists.ElementAt(i); 1449 DataList list = m_DataLists.ElementAt(i);
1450 if (list.data) { 1450 if (list.data) {
1451 FX_Free(list.data); 1451 FX_Free(list.data);
1452 } 1452 }
1453 } 1453 }
1454 m_DataLists.RemoveAll(); 1454 m_DataLists.RemoveAll();
1455 m_CurList = 0; 1455 m_CurList = 0;
1456 } 1456 }
1457 1457
1458 void» » » Append(FX_INT32 nStart, FX_INT32 nCount) 1458 void» » » Append(int32_t nStart, int32_t nCount)
1459 { 1459 {
1460 if (nStart < 0) { 1460 if (nStart < 0) {
1461 return; 1461 return;
1462 } 1462 }
1463 while (nCount > 0) { 1463 while (nCount > 0) {
1464 FX_INT32 temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH); 1464 int32_t temp_count = FX_MIN(nCount, FX_DATALIST_LENGTH);
1465 DataList list; 1465 DataList list;
1466 list.data = FX_Alloc2D(FX_BYTE, temp_count, unit); 1466 list.data = FX_Alloc2D(uint8_t, temp_count, unit);
1467 list.start = nStart; 1467 list.start = nStart;
1468 list.count = temp_count; 1468 list.count = temp_count;
1469 Append(list); 1469 Append(list);
1470 nCount -= temp_count; 1470 nCount -= temp_count;
1471 nStart += temp_count; 1471 nStart += temp_count;
1472 } 1472 }
1473 } 1473 }
1474 1474
1475 FX_LPBYTE» » GetAt(FX_INT32 nIndex) 1475 FX_LPBYTE» » GetAt(int32_t nIndex)
1476 { 1476 {
1477 if (nIndex < 0) { 1477 if (nIndex < 0) {
1478 return NULL; 1478 return NULL;
1479 } 1479 }
1480 if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) { 1480 if (m_CurList < 0 || m_CurList >= m_DataLists.GetSize()) {
1481 return NULL; 1481 return NULL;
1482 } 1482 }
1483 DataList *pCurList = m_DataLists.GetDataPtr(m_CurList); 1483 DataList *pCurList = m_DataLists.GetDataPtr(m_CurList);
1484 if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) { 1484 if (!pCurList || nIndex < pCurList->start || nIndex >= pCurList->start + pCurList->count) {
1485 pCurList = NULL; 1485 pCurList = NULL;
1486 FX_INT32 iStart = 0; 1486 int32_t iStart = 0;
1487 FX_INT32 iEnd = m_DataLists.GetUpperBound(); 1487 int32_t iEnd = m_DataLists.GetUpperBound();
1488 FX_INT32 iMid = 0; 1488 int32_t iMid = 0;
1489 while (iStart <= iEnd) { 1489 while (iStart <= iEnd) {
1490 iMid = (iStart + iEnd) / 2; 1490 iMid = (iStart + iEnd) / 2;
1491 DataList* list = m_DataLists.GetDataPtr(iMid); 1491 DataList* list = m_DataLists.GetDataPtr(iMid);
1492 if (nIndex < list->start) { 1492 if (nIndex < list->start) {
1493 iEnd = iMid - 1; 1493 iEnd = iMid - 1;
1494 } else if (nIndex >= list->start + list->count) { 1494 } else if (nIndex >= list->start + list->count) {
1495 iStart = iMid + 1; 1495 iStart = iMid + 1;
1496 } else { 1496 } else {
1497 pCurList = list; 1497 pCurList = list;
1498 m_CurList = iMid; 1498 m_CurList = iMid;
1499 break; 1499 break;
1500 } 1500 }
1501 } 1501 }
1502 } 1502 }
1503 return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : N ULL; 1503 return pCurList ? pCurList->data + (nIndex - pCurList->start) * unit : N ULL;
1504 } 1504 }
1505 protected: 1505 protected:
1506 void Append(const DataList& list) 1506 void Append(const DataList& list)
1507 { 1507 {
1508 FX_INT32 iStart = 0; 1508 int32_t iStart = 0;
1509 FX_INT32 iEnd = m_DataLists.GetUpperBound(); 1509 int32_t iEnd = m_DataLists.GetUpperBound();
1510 FX_INT32 iFind = 0; 1510 int32_t iFind = 0;
1511 while (iStart <= iEnd) { 1511 while (iStart <= iEnd) {
1512 FX_INT32 iMid = (iStart + iEnd) / 2; 1512 int32_t iMid = (iStart + iEnd) / 2;
1513 DataList* cur_list = m_DataLists.GetDataPtr(iMid); 1513 DataList* cur_list = m_DataLists.GetDataPtr(iMid);
1514 if (list.start < cur_list->start + cur_list->count) { 1514 if (list.start < cur_list->start + cur_list->count) {
1515 iEnd = iMid - 1; 1515 iEnd = iMid - 1;
1516 } else { 1516 } else {
1517 if (iMid == iEnd) { 1517 if (iMid == iEnd) {
1518 iFind = iMid + 1; 1518 iFind = iMid + 1;
1519 break; 1519 break;
1520 } 1520 }
1521 DataList* next_list = m_DataLists.GetDataPtr(iMid + 1); 1521 DataList* next_list = m_DataLists.GetDataPtr(iMid + 1);
1522 if (list.start < next_list->start) { 1522 if (list.start < next_list->start) {
1523 iFind = iMid + 1; 1523 iFind = iMid + 1;
1524 break; 1524 break;
1525 } else { 1525 } else {
1526 iStart = iMid + 1; 1526 iStart = iMid + 1;
1527 } 1527 }
1528 } 1528 }
1529 } 1529 }
1530 m_DataLists.InsertAt(iFind, list); 1530 m_DataLists.InsertAt(iFind, list);
1531 } 1531 }
1532 FX_INT32» » m_CurList; 1532 int32_t» » m_CurList;
1533 CFX_ArrayTemplate<DataList> m_DataLists; 1533 CFX_ArrayTemplate<DataList> m_DataLists;
1534 }; 1534 };
1535 template<typename T1, typename T2> 1535 template<typename T1, typename T2>
1536 class CFX_ListArrayTemplate 1536 class CFX_ListArrayTemplate
1537 { 1537 {
1538 public: 1538 public:
1539 1539
1540 void Clear() 1540 void Clear()
1541 { 1541 {
1542 m_Data.Clear(); 1542 m_Data.Clear();
1543 } 1543 }
1544 1544
1545 void» » » Add(FX_INT32 nStart, FX_INT32 nCount) 1545 void» » » Add(int32_t nStart, int32_t nCount)
1546 { 1546 {
1547 m_Data.Append(nStart, nCount); 1547 m_Data.Append(nStart, nCount);
1548 } 1548 }
1549 1549
1550 T2&»» » » operator [] (FX_INT32 nIndex) 1550 T2&»» » » operator [] (int32_t nIndex)
1551 { 1551 {
1552 FX_LPBYTE data = m_Data.GetAt(nIndex); 1552 FX_LPBYTE data = m_Data.GetAt(nIndex);
1553 FXSYS_assert(data != NULL); 1553 FXSYS_assert(data != NULL);
1554 return (T2&)(*(volatile T2*)data); 1554 return (T2&)(*(volatile T2*)data);
1555 } 1555 }
1556 1556
1557 T2*»» » » GetPtrAt(FX_INT32 nIndex) 1557 T2*»» » » GetPtrAt(int32_t nIndex)
1558 { 1558 {
1559 return (T2*)m_Data.GetAt(nIndex); 1559 return (T2*)m_Data.GetAt(nIndex);
1560 } 1560 }
1561 protected: 1561 protected:
1562 T1 m_Data; 1562 T1 m_Data;
1563 }; 1563 };
1564 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, FX_FILESIZ E> CFX_FileSizeListArray; 1564 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_FILESIZE)>, FX_FILESIZ E> CFX_FileSizeListArray;
1565 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD> CFX_DWordListArray; 1565 typedef CFX_ListArrayTemplate<CFX_SortListArray<sizeof(FX_DWORD)>, FX_DWORD> CFX_DWordListArray;
1566 typedef enum { 1566 typedef enum {
1567 Ready, 1567 Ready,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1620 FX_FLOAT c; 1620 FX_FLOAT c;
1621 FX_FLOAT d; 1621 FX_FLOAT d;
1622 FX_FLOAT e; 1622 FX_FLOAT e;
1623 FX_FLOAT f; 1623 FX_FLOAT f;
1624 FX_FLOAT g; 1624 FX_FLOAT g;
1625 FX_FLOAT h; 1625 FX_FLOAT h;
1626 FX_FLOAT i; 1626 FX_FLOAT i;
1627 }; 1627 };
1628 1628
1629 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ 1629 #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