summaryrefslogtreecommitdiff
path: root/core/fxcrt
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-09-21 16:53:58 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-09-21 21:25:26 +0000
commitaee0db0e6a12bdaacebeb8fb791f4e0d45e18a0d (patch)
tree1e14d60adcffeb0791a0a6c8792d3e9c0109384e /core/fxcrt
parent8e9e3d8975eeea3429c3b3ea703f04ac34e20e28 (diff)
downloadpdfium-aee0db0e6a12bdaacebeb8fb791f4e0d45e18a0d.tar.xz
Move CFX_UnownedPtr to UnownedPtr
This CL moves CFX_UnownedPtr to UnownedPtr and places in the fxcrt namespace. Bug: pdfium:898 Change-Id: I6d1fa463f365e5cb3aafa8c8a7a5f7eff62ed8e0 Reviewed-on: https://pdfium-review.googlesource.com/14620 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt')
-rw-r--r--core/fxcrt/cfx_bitstream.h4
-rw-r--r--core/fxcrt/string_view_template.h4
-rw-r--r--core/fxcrt/unowned_ptr.h (renamed from core/fxcrt/cfx_unowned_ptr.h)42
-rw-r--r--core/fxcrt/unowned_ptr_unittest.cpp (renamed from core/fxcrt/cfx_unowned_ptr_unittest.cpp)41
-rw-r--r--core/fxcrt/xml/cxml_element.h2
5 files changed, 50 insertions, 43 deletions
diff --git a/core/fxcrt/cfx_bitstream.h b/core/fxcrt/cfx_bitstream.h
index 1829f23b92..168760ddd8 100644
--- a/core/fxcrt/cfx_bitstream.h
+++ b/core/fxcrt/cfx_bitstream.h
@@ -9,7 +9,7 @@
#include <stdint.h>
-#include "core/fxcrt/cfx_unowned_ptr.h"
+#include "core/fxcrt/unowned_ptr.h"
class CFX_BitStream {
public:
@@ -32,7 +32,7 @@ class CFX_BitStream {
private:
uint32_t m_BitPos;
uint32_t m_BitSize;
- CFX_UnownedPtr<const uint8_t> m_pData;
+ UnownedPtr<const uint8_t> m_pData;
};
#endif // CORE_FXCRT_CFX_BITSTREAM_H_
diff --git a/core/fxcrt/string_view_template.h b/core/fxcrt/string_view_template.h
index 21426acaeb..31c2c1e2af 100644
--- a/core/fxcrt/string_view_template.h
+++ b/core/fxcrt/string_view_template.h
@@ -13,8 +13,8 @@
#include <utility>
#include <vector>
-#include "core/fxcrt/cfx_unowned_ptr.h"
#include "core/fxcrt/fx_system.h"
+#include "core/fxcrt/unowned_ptr.h"
#include "third_party/base/optional.h"
#include "third_party/base/stl_util.h"
@@ -216,7 +216,7 @@ class StringViewTemplate {
}
protected:
- CFX_UnownedPtr<const UnsignedType> m_Ptr;
+ UnownedPtr<const UnsignedType> m_Ptr;
FX_STRSIZE m_Length;
private:
diff --git a/core/fxcrt/cfx_unowned_ptr.h b/core/fxcrt/unowned_ptr.h
index 5376781d6a..012af3ddf7 100644
--- a/core/fxcrt/cfx_unowned_ptr.h
+++ b/core/fxcrt/unowned_ptr.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CORE_FXCRT_CFX_UNOWNED_PTR_H_
-#define CORE_FXCRT_CFX_UNOWNED_PTR_H_
+#ifndef CORE_FXCRT_UNOWNED_PTR_H_
+#define CORE_FXCRT_UNOWNED_PTR_H_
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>
-// CFX_UnownedPtr is a smart pointer class that behaves very much like a
+// UnownedPtr is a smart pointer class that behaves very much like a
// standard C-style pointer. The advantages of using it over raw
// pointers are:
//
@@ -34,39 +34,39 @@
// because an unowned ptr expresses a one to one relationship with some
// other heap object.
+namespace fxcrt {
+
template <class T>
-class CFX_UnownedPtr {
+class UnownedPtr {
public:
- CFX_UnownedPtr() {}
- CFX_UnownedPtr(const CFX_UnownedPtr& that) : CFX_UnownedPtr(that.Get()) {}
+ UnownedPtr() {}
+ UnownedPtr(const UnownedPtr& that) : UnownedPtr(that.Get()) {}
template <typename U>
- explicit CFX_UnownedPtr(U* pObj) : m_pObj(pObj) {}
+ explicit UnownedPtr(U* pObj) : m_pObj(pObj) {}
// Deliberately implicit to allow returning nullptrs.
// NOLINTNEXTLINE(runtime/explicit)
- CFX_UnownedPtr(std::nullptr_t ptr) {}
+ UnownedPtr(std::nullptr_t ptr) {}
- ~CFX_UnownedPtr() { ProbeForLowSeverityLifetimeIssue(); }
+ ~UnownedPtr() { ProbeForLowSeverityLifetimeIssue(); }
- CFX_UnownedPtr& operator=(T* that) {
+ UnownedPtr& operator=(T* that) {
ProbeForLowSeverityLifetimeIssue();
m_pObj = that;
return *this;
}
- CFX_UnownedPtr& operator=(const CFX_UnownedPtr& that) {
+ UnownedPtr& operator=(const UnownedPtr& that) {
ProbeForLowSeverityLifetimeIssue();
if (*this != that)
m_pObj = that.Get();
return *this;
}
- bool operator==(const CFX_UnownedPtr& that) const {
- return Get() == that.Get();
- }
- bool operator!=(const CFX_UnownedPtr& that) const { return !(*this == that); }
- bool operator<(const CFX_UnownedPtr& that) const {
+ bool operator==(const UnownedPtr& that) const { return Get() == that.Get(); }
+ bool operator!=(const UnownedPtr& that) const { return !(*this == that); }
+ bool operator<(const UnownedPtr& that) const {
return std::less<T*>()(Get(), that.Get());
}
@@ -105,13 +105,17 @@ class CFX_UnownedPtr {
};
template <typename T, typename U>
-inline bool operator==(const U* lhs, const CFX_UnownedPtr<T>& rhs) {
+inline bool operator==(const U* lhs, const UnownedPtr<T>& rhs) {
return rhs == lhs;
}
template <typename T, typename U>
-inline bool operator!=(const U* lhs, const CFX_UnownedPtr<T>& rhs) {
+inline bool operator!=(const U* lhs, const UnownedPtr<T>& rhs) {
return rhs != lhs;
}
-#endif // CORE_FXCRT_CFX_UNOWNED_PTR_H_
+} // namespace fxcrt
+
+using fxcrt::UnownedPtr;
+
+#endif // CORE_FXCRT_UNOWNED_PTR_H_
diff --git a/core/fxcrt/cfx_unowned_ptr_unittest.cpp b/core/fxcrt/unowned_ptr_unittest.cpp
index 46230e7ebd..3fc5308e46 100644
--- a/core/fxcrt/cfx_unowned_ptr_unittest.cpp
+++ b/core/fxcrt/unowned_ptr_unittest.cpp
@@ -2,18 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "core/fxcrt/cfx_unowned_ptr.h"
+#include "core/fxcrt/unowned_ptr.h"
#include <utility>
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
+namespace fxcrt {
namespace {
class Clink {
public:
- CFX_UnownedPtr<Clink> next_ = nullptr;
+ UnownedPtr<Clink> next_ = nullptr;
};
void DeleteDangling() {
@@ -44,7 +45,7 @@ void ReleaseDangling() {
} // namespace
-TEST(fxcrt, UnownedPtrOk) {
+TEST(UnownedPtr, PtrOk) {
Clink* ptr1 = new Clink();
Clink* ptr2 = new Clink();
ptr2->next_ = ptr1;
@@ -52,7 +53,7 @@ TEST(fxcrt, UnownedPtrOk) {
delete ptr1;
}
-TEST(fxcrt, UnownedPtrNotOk) {
+TEST(UnownedPtr, PtrNotOk) {
#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
EXPECT_DEATH(DeleteDangling(), "");
#else
@@ -60,7 +61,7 @@ TEST(fxcrt, UnownedPtrNotOk) {
#endif
}
-TEST(fxcrt, UnownedAssignOk) {
+TEST(UnownedPtr, AssignOk) {
Clink* ptr1 = new Clink();
Clink* ptr2 = new Clink();
ptr2->next_ = ptr1;
@@ -69,7 +70,7 @@ TEST(fxcrt, UnownedAssignOk) {
delete ptr1;
}
-TEST(fxcrt, UnownedAssignNotOk) {
+TEST(UnownedPtr, AssignNotOk) {
#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
EXPECT_DEATH(AssignDangling(), "");
#else
@@ -77,7 +78,7 @@ TEST(fxcrt, UnownedAssignNotOk) {
#endif
}
-TEST(fxcrt, UnownedReleaseOk) {
+TEST(UnownedPtr, ReleaseOk) {
Clink* ptr1 = new Clink();
Clink* ptr2 = new Clink();
ptr2->next_ = ptr1;
@@ -86,7 +87,7 @@ TEST(fxcrt, UnownedReleaseOk) {
delete ptr2;
}
-TEST(fxcrt, UnownedReleaseNotOk) {
+TEST(UnownedPtr, ReleaseNotOk) {
#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
EXPECT_DEATH(ReleaseDangling(), "");
#else
@@ -94,15 +95,15 @@ TEST(fxcrt, UnownedReleaseNotOk) {
#endif
}
-TEST(fxcrt, UnownedOperatorEQ) {
+TEST(UnownedPtr, OperatorEQ) {
int foo;
- CFX_UnownedPtr<int> ptr1;
+ UnownedPtr<int> ptr1;
EXPECT_TRUE(ptr1 == ptr1);
- CFX_UnownedPtr<int> ptr2;
+ UnownedPtr<int> ptr2;
EXPECT_TRUE(ptr1 == ptr2);
- CFX_UnownedPtr<int> ptr3(&foo);
+ UnownedPtr<int> ptr3(&foo);
EXPECT_TRUE(&foo == ptr3);
EXPECT_TRUE(ptr3 == &foo);
EXPECT_FALSE(ptr1 == ptr3);
@@ -111,15 +112,15 @@ TEST(fxcrt, UnownedOperatorEQ) {
EXPECT_TRUE(ptr1 == ptr3);
}
-TEST(fxcrt, UnownedOperatorNE) {
+TEST(UnownedPtr, OperatorNE) {
int foo;
- CFX_UnownedPtr<int> ptr1;
+ UnownedPtr<int> ptr1;
EXPECT_FALSE(ptr1 != ptr1);
- CFX_UnownedPtr<int> ptr2;
+ UnownedPtr<int> ptr2;
EXPECT_FALSE(ptr1 != ptr2);
- CFX_UnownedPtr<int> ptr3(&foo);
+ UnownedPtr<int> ptr3(&foo);
EXPECT_FALSE(&foo != ptr3);
EXPECT_FALSE(ptr3 != &foo);
EXPECT_TRUE(ptr1 != ptr3);
@@ -128,12 +129,14 @@ TEST(fxcrt, UnownedOperatorNE) {
EXPECT_FALSE(ptr1 != ptr3);
}
-TEST(fxcrt, UnownedOperatorLT) {
+TEST(UnownedPtr, OperatorLT) {
int foos[2];
- CFX_UnownedPtr<int> ptr1(&foos[0]);
- CFX_UnownedPtr<int> ptr2(&foos[1]);
+ UnownedPtr<int> ptr1(&foos[0]);
+ UnownedPtr<int> ptr2(&foos[1]);
EXPECT_FALSE(ptr1 < ptr1);
EXPECT_TRUE(ptr1 < ptr2);
EXPECT_FALSE(ptr2 < ptr1);
}
+
+} // namespace fxcrt
diff --git a/core/fxcrt/xml/cxml_element.h b/core/fxcrt/xml/cxml_element.h
index 91ac731021..40ebe385b7 100644
--- a/core/fxcrt/xml/cxml_element.h
+++ b/core/fxcrt/xml/cxml_element.h
@@ -102,7 +102,7 @@ class CXML_Element : public CXML_Object {
friend class CXML_Parser;
friend class CXML_Composer;
- CFX_UnownedPtr<const CXML_Element> const m_pParent;
+ UnownedPtr<const CXML_Element> const m_pParent;
ByteString m_QSpaceName;
ByteString m_TagName;
CXML_AttrMap m_AttrMap;