summaryrefslogtreecommitdiff
path: root/core/fxcrt/include/cfx_count_ref.h
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-08-26 16:52:33 -0700
committerCommit bot <commit-bot@chromium.org>2016-08-26 16:52:33 -0700
commitc10c23a2b1999b1cb0354fd4db9837dc63a3d833 (patch)
tree2f5b9f35d372de26476411295120146baa93f5fb /core/fxcrt/include/cfx_count_ref.h
parent9ed91376d562f3c6e7ca0a99035a74502f648776 (diff)
downloadpdfium-c10c23a2b1999b1cb0354fd4db9837dc63a3d833.tar.xz
Add -> operators to CFX_CountRef.chromium/2842
Allows CFX_CountRefs to behave more like pointers. Rename SetNull() to Clear() for consistency with other ptrs. Change GetPrivateCopy() into MakePrivateCopy() with no return, since the -> operators are clearer than getting an object pointer. Review-Url: https://codereview.chromium.org/2283113002
Diffstat (limited to 'core/fxcrt/include/cfx_count_ref.h')
-rw-r--r--core/fxcrt/include/cfx_count_ref.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/core/fxcrt/include/cfx_count_ref.h b/core/fxcrt/include/cfx_count_ref.h
index 817ce95add..0837894c66 100644
--- a/core/fxcrt/include/cfx_count_ref.h
+++ b/core/fxcrt/include/cfx_count_ref.h
@@ -29,17 +29,16 @@ class CFX_CountRef {
return *this;
}
- void SetNull() { m_pObject.Reset(); }
+ void Clear() { m_pObject.Reset(); }
ObjClass* GetObject() { return m_pObject.Get(); }
const ObjClass* GetObject() const { return m_pObject.Get(); }
template <typename... Args>
- ObjClass* GetPrivateCopy(Args... params) {
+ void MakePrivateCopy(Args... params) {
if (!m_pObject)
- return New(params...);
- if (!m_pObject->HasOneRef())
+ m_pObject.Reset(new CountedObj(params...));
+ else if (!m_pObject->HasOneRef())
m_pObject.Reset(new CountedObj(*m_pObject));
- return m_pObject.Get();
}
bool operator==(const CFX_CountRef& that) const {
@@ -47,6 +46,8 @@ class CFX_CountRef {
}
bool operator!=(const CFX_CountRef& that) const { return !(*this == that); }
operator bool() const { return m_pObject; }
+ ObjClass& operator*() const { return *m_pObject.Get(); }
+ ObjClass* operator->() const { return m_pObject.Get(); }
private:
class CountedObj : public ObjClass {