Title: [222764] trunk
Revision
222764
Author
[email protected]
Date
2017-10-02 17:42:05 -0700 (Mon, 02 Oct 2017)

Log Message

WeakPtr should have a move constructor
https://bugs.webkit.org/show_bug.cgi?id=177789

Reviewed by Chris Dumez.

Source/WTF:

* wtf/WeakPtr.h: Now that we just have a RefPtr data member,
the default operators are sufficient.

Tools:

Chris made me write an API test. It wasn't that painful.

* TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
(TestWebKitAPI::TEST):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (222763 => 222764)


--- trunk/Source/WTF/ChangeLog	2017-10-03 00:37:50 UTC (rev 222763)
+++ trunk/Source/WTF/ChangeLog	2017-10-03 00:42:05 UTC (rev 222764)
@@ -1,5 +1,15 @@
 2017-10-02  Geoffrey Garen  <[email protected]>
 
+        WeakPtr should have a move constructor
+        https://bugs.webkit.org/show_bug.cgi?id=177789
+
+        Reviewed by Chris Dumez.
+
+        * wtf/WeakPtr.h: Now that we just have a RefPtr data member,
+        the default operators are sufficient.
+
+2017-10-02  Geoffrey Garen  <[email protected]>
+
         NULL WeakPtr should not malloc!
         https://bugs.webkit.org/show_bug.cgi?id=177773
 

Modified: trunk/Source/WTF/wtf/WeakPtr.h (222763 => 222764)


--- trunk/Source/WTF/wtf/WeakPtr.h	2017-10-03 00:37:50 UTC (rev 222763)
+++ trunk/Source/WTF/wtf/WeakPtr.h	2017-10-03 00:42:05 UTC (rev 222764)
@@ -67,13 +67,11 @@
 public:
     WeakPtr() { }
     WeakPtr(std::nullptr_t) { }
-    WeakPtr(const WeakPtr& o) : m_ref(o.m_ref) { }
     WeakPtr(Ref<WeakReference<T>>&& ref) : m_ref(std::forward<Ref<WeakReference<T>>>(ref)) { }
 
     T* get() const { return m_ref ? m_ref->get() : nullptr; }
     operator bool() const { return m_ref && m_ref->get(); }
 
-    WeakPtr& operator=(const WeakPtr& o) { m_ref = o.m_ref; return *this; }
     WeakPtr& operator=(std::nullptr_t) { m_ref = nullptr; return *this; }
 
     T* operator->() const { return m_ref->get(); }

Modified: trunk/Tools/ChangeLog (222763 => 222764)


--- trunk/Tools/ChangeLog	2017-10-03 00:37:50 UTC (rev 222763)
+++ trunk/Tools/ChangeLog	2017-10-03 00:42:05 UTC (rev 222764)
@@ -1,3 +1,15 @@
+2017-10-02  Geoffrey Garen  <[email protected]>
+
+        WeakPtr should have a move constructor
+        https://bugs.webkit.org/show_bug.cgi?id=177789
+
+        Reviewed by Chris Dumez.
+
+        Chris made me write an API test. It wasn't that painful.
+
+        * TestWebKitAPI/Tests/WTF/WeakPtr.cpp:
+        (TestWebKitAPI::TEST):
+
 2017-10-02  Filip Pizlo  <[email protected]>
 
         WSL ^ should be *

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp (222763 => 222764)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp	2017-10-03 00:37:50 UTC (rev 222763)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WeakPtr.cpp	2017-10-03 00:42:05 UTC (rev 222764)
@@ -116,6 +116,24 @@
     weakPtr->bar();
 }
 
+TEST(WTF_WeakPtr, Operators)
+{
+    Foo f;
+    WeakPtrFactory<Foo> factory;
+    WeakPtr<Foo> weakPtr = factory.createWeakPtr(f);
+
+    WeakPtr<Foo> weakPtr2 = weakPtr;
+    EXPECT_EQ(weakPtr2.get(), &f);
+
+    WeakPtr<Foo> weakPtr3;
+    weakPtr3 = weakPtr;
+    EXPECT_EQ(weakPtr3.get(), &f);
+
+    WeakPtr<Foo> weakPtr4 = WTFMove(weakPtr);
+    EXPECT_EQ(weakPtr4.get(), &f);
+    EXPECT_FALSE(weakPtr);
+}
+
 TEST(WTF_WeakPtr, Forget)
 {
     int dummy = 5;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to