summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
diff options
context:
space:
mode:
authorKonstantin Tokarev <annulen@yandex.ru>2016-08-25 19:20:41 +0300
committerKonstantin Tokarev <annulen@yandex.ru>2017-02-02 12:30:55 +0000
commit6882a04fb36642862b11efe514251d32070c3d65 (patch)
treeb7959826000b061fd5ccc7512035c7478742f7b0 /Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
parentab6df191029eeeb0b0f16f127d553265659f739e (diff)
downloadqtwebkit-6882a04fb36642862b11efe514251d32070c3d65.tar.gz
Imported QtWebKit TP3 (git b57bc6801f1876c3220d5a4bfea33d620d477443)
Change-Id: I3b1d8a2808782c9f34d50240000e20cb38d3680f Reviewed-by: Konstantin Tokarev <annulen@yandex.ru>
Diffstat (limited to 'Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h')
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h46
1 files changed, 36 insertions, 10 deletions
diff --git a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
index d5dbdf029..24a45afd4 100644
--- a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
+++ b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
@@ -26,8 +26,12 @@
#ifndef WKRetainPtr_h
#define WKRetainPtr_h
-#include <WebKit2/WKType.h>
+#include <WebKit/WKType.h>
#include <algorithm>
+#include <wtf/GetPtr.h>
+#include <wtf/HashFunctions.h>
+#include <wtf/HashTraits.h>
+#include <wtf/RefPtr.h>
namespace WebKit {
@@ -68,7 +72,6 @@ public:
WKRetain(ptr);
}
-#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename U> WKRetainPtr(WKRetainPtr<U>&& o)
: m_ptr(o.leakRef())
{
@@ -78,7 +81,6 @@ public:
: m_ptr(o.leakRef())
{
}
-#endif
~WKRetainPtr()
{
@@ -86,6 +88,15 @@ public:
WKRelease(ptr);
}
+ // Hash table deleted values, which are only constructed and never copied or destroyed.
+ WKRetainPtr(WTF::HashTableDeletedValueType)
+ : m_ptr(hashTableDeletedValue())
+ {
+ }
+
+ bool isHashTableDeletedValue() const { return m_ptr == hashTableDeletedValue(); }
+ constexpr static T hashTableDeletedValue() { return reinterpret_cast<T>(-1); }
+
PtrType get() const { return m_ptr; }
void clear()
@@ -115,10 +126,8 @@ public:
WKRetainPtr& operator=(PtrType);
template<typename U> WKRetainPtr& operator=(U*);
-#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
WKRetainPtr& operator=(WKRetainPtr&&);
template<typename U> WKRetainPtr& operator=(WKRetainPtr<U>&&);
-#endif
void adopt(PtrType);
void swap(WKRetainPtr&);
@@ -173,7 +182,6 @@ template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>:
return *this;
}
-#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
template<typename T> inline WKRetainPtr<T>& WKRetainPtr<T>::operator=(WKRetainPtr<T>&& o)
{
adopt(o.leakRef());
@@ -185,7 +193,6 @@ template<typename T> template<typename U> inline WKRetainPtr<T>& WKRetainPtr<T>:
adopt(o.leakRef());
return *this;
}
-#endif
template<typename T> inline void WKRetainPtr<T>::adopt(PtrType optr)
{
@@ -235,9 +242,8 @@ template<typename T, typename U> inline bool operator!=(T* a, const WKRetainPtr<
return a != b.get();
}
-template<typename T> inline WKRetainPtr<T> adoptWK(T) WARN_UNUSED_RETURN;
-
-template<typename T> inline WKRetainPtr<T> adoptWK(T o)
+template<typename T> inline WKRetainPtr<T> adoptWK(T) __attribute__((warn_unused_result));
+template<typename T> inline WKRetainPtr<T> adoptWK(T o)
{
return WKRetainPtr<T>(AdoptWK, o);
}
@@ -248,4 +254,24 @@ using WebKit::WKRetainPtr;
using WebKit::AdoptWK;
using WebKit::adoptWK;
+namespace WTF {
+
+template <typename T> struct IsSmartPtr<WKRetainPtr<T>> {
+ static const bool value = true;
+};
+
+template<typename P> struct DefaultHash<WKRetainPtr<P>> {
+ typedef PtrHash<WKRetainPtr<P>> Hash;
+};
+
+template<typename P> struct HashTraits<WKRetainPtr<P>> : SimpleClassHashTraits<WKRetainPtr<P>> {
+ static P emptyValue() { return nullptr; }
+
+ typedef P PeekType;
+ static PeekType peek(const WKRetainPtr<P>& value) { return value.get(); }
+ static PeekType peek(P value) { return value; }
+};
+
+} // namespace WTF
+
#endif // WKRetainPtr_h