From 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c Mon Sep 17 00:00:00 2001 From: Lorry Tar Creator Date: Tue, 27 Jun 2017 06:07:23 +0000 Subject: webkitgtk-2.16.5 --- Source/JavaScriptCore/heap/WeakInlines.h | 44 +++++++++----------------------- 1 file changed, 12 insertions(+), 32 deletions(-) (limited to 'Source/JavaScriptCore/heap/WeakInlines.h') 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 -#include namespace JSC { @@ -65,7 +63,7 @@ template inline void Weak::swap(Weak& other) template inline auto Weak::operator=(Weak&& other) -> Weak& { - Weak weak = std::move(other); + Weak weak = WTFMove(other); swap(weak); return *this; } @@ -73,20 +71,23 @@ template inline auto Weak::operator=(Weak&& other) -> Weak& template inline T* Weak::operator->() const { ASSERT(m_impl && m_impl->state() == WeakImpl::Live); - return jsCast(m_impl->jsValue().asCell()); + // We can't use jsCast here since we could be called in a finalizer. + return static_cast(m_impl->jsValue().asCell()); } template inline T& Weak::operator*() const { ASSERT(m_impl && m_impl->state() == WeakImpl::Live); - return *jsCast(m_impl->jsValue().asCell()); + // We can't use jsCast here since we could be called in a finalizer. + return *static_cast(m_impl->jsValue().asCell()); } template inline T* Weak::get() const { if (!m_impl || m_impl->state() != WeakImpl::Live) - return 0; - return jsCast(m_impl->jsValue().asCell()); + return nullptr; + // We can't use jsCast here since we could be called in a finalizer. + return static_cast(m_impl->jsValue().asCell()); } template inline bool Weak::was(T* other) const @@ -99,9 +100,9 @@ template inline bool Weak::operator!() const return !m_impl || !m_impl->jsValue() || m_impl->state() != WeakImpl::Live; } -template inline Weak::operator UnspecifiedBoolType*() const +template inline Weak::operator bool() const { - return reinterpret_cast(!!*this); + return !!*this; } template inline WeakImpl* Weak::leakImpl() @@ -148,24 +149,3 @@ template inline void weakClear(Weak& weak, T* cell) } } // namespace JSC - -namespace WTF { - -template struct VectorTraits> : SimpleClassVectorTraits { - static const bool canCompareWithMemcmp = false; -}; - -template struct HashTraits> : SimpleClassHashTraits> { - typedef JSC::Weak 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 -- cgit v1.2.1