diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/JavaScriptCore/heap/Weak.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/JavaScriptCore/heap/Weak.h')
-rw-r--r-- | Source/JavaScriptCore/heap/Weak.h | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/Source/JavaScriptCore/heap/Weak.h b/Source/JavaScriptCore/heap/Weak.h index 80cdbd82c..2d7b38bb1 100644 --- a/Source/JavaScriptCore/heap/Weak.h +++ b/Source/JavaScriptCore/heap/Weak.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,11 +23,13 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef Weak_h -#define Weak_h +#pragma once +#include "JSExportMacros.h" #include <cstddef> +#include <wtf/HashTraits.h> #include <wtf/Noncopyable.h> +#include <wtf/VectorTraits.h> namespace JSC { @@ -50,35 +52,33 @@ public: { } - Weak(T*, WeakHandleOwner* = 0, void* context = 0); + inline Weak(T*, WeakHandleOwner* = 0, void* context = 0); enum HashTableDeletedValueTag { HashTableDeletedValue }; - bool isHashTableDeletedValue() const; - Weak(HashTableDeletedValueTag); + inline bool isHashTableDeletedValue() const; + inline Weak(HashTableDeletedValueTag); - Weak(Weak&&); + inline Weak(Weak&&); ~Weak() { clear(); } - void swap(Weak&); + inline void swap(Weak&); - Weak& operator=(Weak&&); + inline Weak& operator=(Weak&&); - bool operator!() const; - T* operator->() const; - T& operator*() const; - T* get() const; + inline bool operator!() const; + inline T* operator->() const; + inline T& operator*() const; + inline T* get() const; - bool was(T*) const; + inline bool was(T*) const; - // This conversion operator allows implicit conversion to bool but not to other integer types. - typedef void* (Weak::*UnspecifiedBoolType); - operator UnspecifiedBoolType*() const; + inline explicit operator bool() const; - WeakImpl* leakImpl() WARN_UNUSED_RETURN; + inline WeakImpl* leakImpl() WARN_UNUSED_RETURN; void clear() { if (!m_impl) @@ -87,11 +87,28 @@ public: } private: - static WeakImpl* hashTableDeletedValue(); + static inline WeakImpl* hashTableDeletedValue(); WeakImpl* m_impl; }; } // namespace JSC -#endif // Weak_h +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 |