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 929 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 m_Location = location; | 940 m_Location = location; |
941 m_OldValue = *location; | 941 m_OldValue = *location; |
942 } | 942 } |
943 ~CFX_AutoRestorer() { *m_Location = m_OldValue; } | 943 ~CFX_AutoRestorer() { *m_Location = m_OldValue; } |
944 | 944 |
945 private: | 945 private: |
946 T* m_Location; | 946 T* m_Location; |
947 T m_OldValue; | 947 T m_OldValue; |
948 }; | 948 }; |
949 | 949 |
| 950 // Used with nonstd::unique_ptr to Release() objects that can't be deleted. |
| 951 template <class T> |
| 952 struct ReleaseDeleter { |
| 953 inline void operator()(T* ptr) const { ptr->Release(); } |
| 954 }; |
| 955 |
| 956 // TODO(thestig) Remove in favor of nonstd::unique_ptr. |
950 template <class T> | 957 template <class T> |
951 class CFX_SmartPointer { | 958 class CFX_SmartPointer { |
952 public: | 959 public: |
953 CFX_SmartPointer(T* pObj) : m_pObj(pObj) {} | 960 CFX_SmartPointer(T* pObj) : m_pObj(pObj) {} |
954 ~CFX_SmartPointer() { m_pObj->Release(); } | 961 ~CFX_SmartPointer() { m_pObj->Release(); } |
955 T* Get(void) { return m_pObj; } | 962 T* Get(void) { return m_pObj; } |
956 T& operator*(void) { return *m_pObj; } | 963 T& operator*(void) { return *m_pObj; } |
957 T* operator->(void) { return m_pObj; } | 964 T* operator->(void) { return m_pObj; } |
958 | 965 |
959 protected: | 966 protected: |
960 T* m_pObj; | 967 T* m_pObj; |
961 }; | 968 }; |
| 969 |
962 #define FX_DATALIST_LENGTH 1024 | 970 #define FX_DATALIST_LENGTH 1024 |
963 template <size_t unit> | 971 template <size_t unit> |
964 class CFX_SortListArray { | 972 class CFX_SortListArray { |
965 protected: | 973 protected: |
966 struct DataList { | 974 struct DataList { |
967 int32_t start; | 975 int32_t start; |
968 | 976 |
969 int32_t count; | 977 int32_t count; |
970 uint8_t* data; | 978 uint8_t* data; |
971 }; | 979 }; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 FX_FLOAT c; | 1147 FX_FLOAT c; |
1140 FX_FLOAT d; | 1148 FX_FLOAT d; |
1141 FX_FLOAT e; | 1149 FX_FLOAT e; |
1142 FX_FLOAT f; | 1150 FX_FLOAT f; |
1143 FX_FLOAT g; | 1151 FX_FLOAT g; |
1144 FX_FLOAT h; | 1152 FX_FLOAT h; |
1145 FX_FLOAT i; | 1153 FX_FLOAT i; |
1146 }; | 1154 }; |
1147 | 1155 |
1148 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1156 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
OLD | NEW |