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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
982 m_pObject->m_RefCount--; | 982 m_pObject->m_RefCount--; |
983 if (m_pObject->m_RefCount <= 0) { | 983 if (m_pObject->m_RefCount <= 0) { |
984 delete m_pObject; | 984 delete m_pObject; |
985 } | 985 } |
986 } | 986 } |
987 m_pObject = ref.m_pObject; | 987 m_pObject = ref.m_pObject; |
988 } | 988 } |
989 | 989 |
990 void operator=(void* p) { | 990 void operator=(void* p) { |
991 FXSYS_assert(p == 0); | 991 FXSYS_assert(p == 0); |
992 if (m_pObject == NULL) { | 992 if (!m_pObject) { |
993 return; | 993 return; |
994 } | 994 } |
995 m_pObject->m_RefCount--; | 995 m_pObject->m_RefCount--; |
996 if (m_pObject->m_RefCount <= 0) { | 996 if (m_pObject->m_RefCount <= 0) { |
997 delete m_pObject; | 997 delete m_pObject; |
998 } | 998 } |
999 m_pObject = NULL; | 999 m_pObject = NULL; |
1000 } | 1000 } |
1001 | 1001 |
1002 const ObjClass* GetObject() const { return m_pObject; } | 1002 const ObjClass* GetObject() const { return m_pObject; } |
1003 | 1003 |
1004 operator const ObjClass*() const { return m_pObject; } | 1004 operator const ObjClass*() const { return m_pObject; } |
1005 | 1005 |
1006 FX_BOOL IsNull() const { return m_pObject == NULL; } | 1006 FX_BOOL IsNull() const { return !m_pObject; } |
1007 | 1007 |
1008 FX_BOOL NotNull() const { return m_pObject != NULL; } | 1008 FX_BOOL NotNull() const { return !IsNull(); } |
1009 | 1009 |
1010 ObjClass* GetModify() { | 1010 ObjClass* GetModify() { |
1011 if (m_pObject == NULL) { | 1011 if (!m_pObject) { |
1012 m_pObject = new CountedObj; | 1012 m_pObject = new CountedObj; |
1013 m_pObject->m_RefCount = 1; | 1013 m_pObject->m_RefCount = 1; |
1014 } else if (m_pObject->m_RefCount > 1) { | 1014 } else if (m_pObject->m_RefCount > 1) { |
1015 m_pObject->m_RefCount--; | 1015 m_pObject->m_RefCount--; |
1016 CountedObj* pOldObject = m_pObject; | 1016 CountedObj* pOldObject = m_pObject; |
1017 m_pObject = new CountedObj(*pOldObject); | 1017 m_pObject = new CountedObj(*pOldObject); |
1018 m_pObject->m_RefCount = 1; | 1018 m_pObject->m_RefCount = 1; |
1019 } | 1019 } |
1020 return m_pObject; | 1020 return m_pObject; |
1021 } | 1021 } |
1022 | 1022 |
1023 void SetNull() { | 1023 void SetNull() { |
1024 if (m_pObject == NULL) { | 1024 if (!m_pObject) { |
1025 return; | 1025 return; |
1026 } | 1026 } |
1027 m_pObject->m_RefCount--; | 1027 m_pObject->m_RefCount--; |
1028 if (m_pObject->m_RefCount <= 0) { | 1028 if (m_pObject->m_RefCount <= 0) { |
1029 delete m_pObject; | 1029 delete m_pObject; |
1030 } | 1030 } |
1031 m_pObject = NULL; | 1031 m_pObject = NULL; |
1032 } | 1032 } |
1033 | 1033 |
1034 FX_BOOL operator==(const Ref& ref) const { | 1034 FX_BOOL operator==(const Ref& ref) const { |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1255 FX_FLOAT c; | 1255 FX_FLOAT c; |
1256 FX_FLOAT d; | 1256 FX_FLOAT d; |
1257 FX_FLOAT e; | 1257 FX_FLOAT e; |
1258 FX_FLOAT f; | 1258 FX_FLOAT f; |
1259 FX_FLOAT g; | 1259 FX_FLOAT g; |
1260 FX_FLOAT h; | 1260 FX_FLOAT h; |
1261 FX_FLOAT i; | 1261 FX_FLOAT i; |
1262 }; | 1262 }; |
1263 | 1263 |
1264 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1264 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
OLD | NEW |