OLD | NEW |
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 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 m_Location = location; | 1078 m_Location = location; |
1079 m_OldValue = *location; | 1079 m_OldValue = *location; |
1080 } | 1080 } |
1081 ~CFX_AutoRestorer() { *m_Location = m_OldValue; } | 1081 ~CFX_AutoRestorer() { *m_Location = m_OldValue; } |
1082 | 1082 |
1083 private: | 1083 private: |
1084 T* m_Location; | 1084 T* m_Location; |
1085 T m_OldValue; | 1085 T m_OldValue; |
1086 }; | 1086 }; |
1087 | 1087 |
| 1088 // Used with nonstd::unique_ptr to Release() objects that can't be deleted. |
| 1089 template <class T> |
| 1090 struct ReleaseDeleter { |
| 1091 inline void operator()(T* ptr) const { ptr->Release(); } |
| 1092 }; |
| 1093 |
| 1094 // TODO(thestig) Remove in favor of nonstd::unique_ptr. |
1088 template <class T> | 1095 template <class T> |
1089 class CFX_SmartPointer { | 1096 class CFX_SmartPointer { |
1090 public: | 1097 public: |
1091 CFX_SmartPointer(T* pObj) : m_pObj(pObj) {} | 1098 CFX_SmartPointer(T* pObj) : m_pObj(pObj) {} |
1092 ~CFX_SmartPointer() { m_pObj->Release(); } | 1099 ~CFX_SmartPointer() { m_pObj->Release(); } |
1093 T* Get(void) { return m_pObj; } | 1100 T* Get(void) { return m_pObj; } |
1094 T& operator*(void) { return *m_pObj; } | 1101 T& operator*(void) { return *m_pObj; } |
1095 T* operator->(void) { return m_pObj; } | 1102 T* operator->(void) { return m_pObj; } |
1096 | 1103 |
1097 protected: | 1104 protected: |
1098 T* m_pObj; | 1105 T* m_pObj; |
1099 }; | 1106 }; |
| 1107 |
1100 #define FX_DATALIST_LENGTH 1024 | 1108 #define FX_DATALIST_LENGTH 1024 |
1101 template <size_t unit> | 1109 template <size_t unit> |
1102 class CFX_SortListArray { | 1110 class CFX_SortListArray { |
1103 protected: | 1111 protected: |
1104 struct DataList { | 1112 struct DataList { |
1105 int32_t start; | 1113 int32_t start; |
1106 | 1114 |
1107 int32_t count; | 1115 int32_t count; |
1108 uint8_t* data; | 1116 uint8_t* data; |
1109 }; | 1117 }; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1284 FX_FLOAT c; | 1292 FX_FLOAT c; |
1285 FX_FLOAT d; | 1293 FX_FLOAT d; |
1286 FX_FLOAT e; | 1294 FX_FLOAT e; |
1287 FX_FLOAT f; | 1295 FX_FLOAT f; |
1288 FX_FLOAT g; | 1296 FX_FLOAT g; |
1289 FX_FLOAT h; | 1297 FX_FLOAT h; |
1290 FX_FLOAT i; | 1298 FX_FLOAT i; |
1291 }; | 1299 }; |
1292 | 1300 |
1293 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1301 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
OLD | NEW |