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 860 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
871 m_pObject->m_RefCount--; | 871 m_pObject->m_RefCount--; |
872 if (m_pObject->m_RefCount <= 0) { | 872 if (m_pObject->m_RefCount <= 0) { |
873 delete m_pObject; | 873 delete m_pObject; |
874 } | 874 } |
875 } | 875 } |
876 m_pObject = ref.m_pObject; | 876 m_pObject = ref.m_pObject; |
877 } | 877 } |
878 | 878 |
879 void operator=(void* p) { | 879 void operator=(void* p) { |
880 FXSYS_assert(p == 0); | 880 FXSYS_assert(p == 0); |
881 if (m_pObject == NULL) { | 881 if (!m_pObject) { |
882 return; | 882 return; |
883 } | 883 } |
884 m_pObject->m_RefCount--; | 884 m_pObject->m_RefCount--; |
885 if (m_pObject->m_RefCount <= 0) { | 885 if (m_pObject->m_RefCount <= 0) { |
886 delete m_pObject; | 886 delete m_pObject; |
887 } | 887 } |
888 m_pObject = NULL; | 888 m_pObject = NULL; |
889 } | 889 } |
890 | 890 |
891 const ObjClass* GetObject() const { return m_pObject; } | 891 const ObjClass* GetObject() const { return m_pObject; } |
892 | 892 |
893 operator const ObjClass*() const { return m_pObject; } | 893 operator const ObjClass*() const { return m_pObject; } |
894 | 894 |
895 FX_BOOL IsNull() const { return m_pObject == NULL; } | 895 FX_BOOL IsNull() const { return !m_pObject; } |
896 | 896 |
897 FX_BOOL NotNull() const { return m_pObject != NULL; } | 897 FX_BOOL NotNull() const { return !IsNull(); } |
Lei Zhang
2015/12/12 02:31:44
or leave it as is?
| |
898 | 898 |
899 ObjClass* GetModify() { | 899 ObjClass* GetModify() { |
900 if (m_pObject == NULL) { | 900 if (!m_pObject) { |
901 m_pObject = new CountedObj; | 901 m_pObject = new CountedObj; |
902 m_pObject->m_RefCount = 1; | 902 m_pObject->m_RefCount = 1; |
903 } else if (m_pObject->m_RefCount > 1) { | 903 } else if (m_pObject->m_RefCount > 1) { |
904 m_pObject->m_RefCount--; | 904 m_pObject->m_RefCount--; |
905 CountedObj* pOldObject = m_pObject; | 905 CountedObj* pOldObject = m_pObject; |
906 m_pObject = new CountedObj(*pOldObject); | 906 m_pObject = new CountedObj(*pOldObject); |
907 m_pObject->m_RefCount = 1; | 907 m_pObject->m_RefCount = 1; |
908 } | 908 } |
909 return m_pObject; | 909 return m_pObject; |
910 } | 910 } |
911 | 911 |
912 void SetNull() { | 912 void SetNull() { |
913 if (m_pObject == NULL) { | 913 if (!m_pObject) { |
914 return; | 914 return; |
915 } | 915 } |
916 m_pObject->m_RefCount--; | 916 m_pObject->m_RefCount--; |
917 if (m_pObject->m_RefCount <= 0) { | 917 if (m_pObject->m_RefCount <= 0) { |
918 delete m_pObject; | 918 delete m_pObject; |
919 } | 919 } |
920 m_pObject = NULL; | 920 m_pObject = NULL; |
921 } | 921 } |
922 | 922 |
923 FX_BOOL operator==(const Ref& ref) const { | 923 FX_BOOL operator==(const Ref& ref) const { |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1135 FX_FLOAT c; | 1135 FX_FLOAT c; |
1136 FX_FLOAT d; | 1136 FX_FLOAT d; |
1137 FX_FLOAT e; | 1137 FX_FLOAT e; |
1138 FX_FLOAT f; | 1138 FX_FLOAT f; |
1139 FX_FLOAT g; | 1139 FX_FLOAT g; |
1140 FX_FLOAT h; | 1140 FX_FLOAT h; |
1141 FX_FLOAT i; | 1141 FX_FLOAT i; |
1142 }; | 1142 }; |
1143 | 1143 |
1144 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ | 1144 #endif // CORE_INCLUDE_FXCRT_FX_BASIC_H_ |
OLD | NEW |