summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/heap/WeakInlines.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/heap/WeakInlines.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/JavaScriptCore/heap/WeakInlines.h')
-rw-r--r--Source/JavaScriptCore/heap/WeakInlines.h44
1 files changed, 12 insertions, 32 deletions
diff --git a/Source/JavaScriptCore/heap/WeakInlines.h b/Source/JavaScriptCore/heap/WeakInlines.h
index 8cfd50153..d53cc54b6 100644
--- a/Source/JavaScriptCore/heap/WeakInlines.h
+++ b/Source/JavaScriptCore/heap/WeakInlines.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009, 2012, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2009, 2012, 2013, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -23,13 +23,11 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WeakInlines_h
-#define WeakInlines_h
+#pragma once
#include "JSCell.h"
#include "WeakSetInlines.h"
#include <wtf/Assertions.h>
-#include <wtf/HashTraits.h>
namespace JSC {
@@ -65,7 +63,7 @@ template<typename T> inline void Weak<T>::swap(Weak& other)
template<typename T> inline auto Weak<T>::operator=(Weak&& other) -> Weak&
{
- Weak weak = std::move(other);
+ Weak weak = WTFMove(other);
swap(weak);
return *this;
}
@@ -73,20 +71,23 @@ template<typename T> inline auto Weak<T>::operator=(Weak&& other) -> Weak&
template<typename T> inline T* Weak<T>::operator->() const
{
ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
- return jsCast<T*>(m_impl->jsValue().asCell());
+ // We can't use jsCast here since we could be called in a finalizer.
+ return static_cast<T*>(m_impl->jsValue().asCell());
}
template<typename T> inline T& Weak<T>::operator*() const
{
ASSERT(m_impl && m_impl->state() == WeakImpl::Live);
- return *jsCast<T*>(m_impl->jsValue().asCell());
+ // We can't use jsCast here since we could be called in a finalizer.
+ return *static_cast<T*>(m_impl->jsValue().asCell());
}
template<typename T> inline T* Weak<T>::get() const
{
if (!m_impl || m_impl->state() != WeakImpl::Live)
- return 0;
- return jsCast<T*>(m_impl->jsValue().asCell());
+ return nullptr;
+ // We can't use jsCast here since we could be called in a finalizer.
+ return static_cast<T*>(m_impl->jsValue().asCell());
}
template<typename T> inline bool Weak<T>::was(T* other) const
@@ -99,9 +100,9 @@ template<typename T> inline bool Weak<T>::operator!() const
return !m_impl || !m_impl->jsValue() || m_impl->state() != WeakImpl::Live;
}
-template<typename T> inline Weak<T>::operator UnspecifiedBoolType*() const
+template<typename T> inline Weak<T>::operator bool() const
{
- return reinterpret_cast<UnspecifiedBoolType*>(!!*this);
+ return !!*this;
}
template<typename T> inline WeakImpl* Weak<T>::leakImpl()
@@ -148,24 +149,3 @@ template<typename T> inline void weakClear(Weak<T>& weak, T* cell)
}
} // namespace JSC
-
-namespace WTF {
-
-template<typename T> struct VectorTraits<JSC::Weak<T>> : SimpleClassVectorTraits {
- static const bool canCompareWithMemcmp = false;
-};
-
-template<typename T> struct HashTraits<JSC::Weak<T>> : SimpleClassHashTraits<JSC::Weak<T>> {
- typedef JSC::Weak<T> StorageType;
-
- typedef std::nullptr_t EmptyValueType;
- static EmptyValueType emptyValue() { return nullptr; }
-
- typedef T* PeekType;
- static PeekType peek(const StorageType& value) { return value.get(); }
- static PeekType peek(EmptyValueType) { return PeekType(); }
-};
-
-} // namespace WTF
-
-#endif // WeakInlines_h