summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h')
-rw-r--r--Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h54
1 files changed, 42 insertions, 12 deletions
diff --git a/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h b/Source/WebKit2/UIProcess/API/cpp/WKRetainPtr.h
index 6915dd334..19ae5943c 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 {
@@ -84,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()
@@ -229,25 +242,42 @@ template<typename T, typename U> inline bool operator!=(T* a, const WKRetainPtr<
return a != b.get();
}
-#if defined(__GNUC__) && !(defined(__CC_ARM) || defined(__ARMCC__))
-#define WK_WARN_UNUSED_RETURN __attribute__((warn_unused_result))
-#else
-#define WK_WARN_UNUSED_RETURN
-#endif
-
-template<typename T> inline WKRetainPtr<T> adoptWK(T) WK_WARN_UNUSED_RETURN;
-
-#undef WK_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);
}
+template<typename T> inline WKRetainPtr<T> retainWK(T ptr)
+{
+ return ptr;
+}
+
} // namespace WebKit
using WebKit::WKRetainPtr;
using WebKit::AdoptWK;
using WebKit::adoptWK;
+using WebKit::retainWK;
+
+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