diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-05-07 11:21:11 +0200 |
commit | 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch) | |
tree | 988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/JavaScriptCore/heap/Strong.h | |
parent | dd91e772430dc294e3bf478c119ef8d43c0a3358 (diff) | |
download | qtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz |
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/JavaScriptCore/heap/Strong.h')
-rw-r--r-- | Source/JavaScriptCore/heap/Strong.h | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/Source/JavaScriptCore/heap/Strong.h b/Source/JavaScriptCore/heap/Strong.h index d2f2a2278..7fafaeab5 100644 --- a/Source/JavaScriptCore/heap/Strong.h +++ b/Source/JavaScriptCore/heap/Strong.h @@ -28,7 +28,7 @@ #include <wtf/Assertions.h> #include "Handle.h" -#include "HandleHeap.h" +#include "HandleSet.h" namespace JSC { @@ -56,7 +56,7 @@ public: { if (!other.slot()) return; - setSlot(HandleHeap::heapFor(other.slot())->allocate()); + setSlot(HandleSet::heapFor(other.slot())->allocate()); set(other.get()); } @@ -65,7 +65,7 @@ public: { if (!other.slot()) return; - setSlot(HandleHeap::heapFor(other.slot())->allocate()); + setSlot(HandleSet::heapFor(other.slot())->allocate()); set(other.get()); } @@ -81,11 +81,19 @@ public: clear(); } + bool operator!() const { return !slot() || !*slot(); } + + // This conversion operator allows implicit conversion to bool but not to other integer types. + typedef JSValue (HandleBase::*UnspecifiedBoolType); + operator UnspecifiedBoolType*() const { return !!*this ? reinterpret_cast<UnspecifiedBoolType*>(1) : 0; } + void swap(Strong& other) { Handle<T>::swap(other); } + ExternalType get() const { return HandleTypes<T>::getFromSlot(this->slot()); } + void set(JSGlobalData&, ExternalType); template <typename U> Strong& operator=(const Strong<U>& other) @@ -95,7 +103,7 @@ public: return *this; } - set(*HandleHeap::heapFor(other.slot())->globalData(), other.get()); + set(*HandleSet::heapFor(other.slot())->globalData(), other.get()); return *this; } @@ -106,7 +114,7 @@ public: return *this; } - set(*HandleHeap::heapFor(other.slot())->globalData(), other.get()); + set(*HandleSet::heapFor(other.slot())->globalData(), other.get()); return *this; } @@ -114,7 +122,7 @@ public: { if (!slot()) return; - HandleHeap::heapFor(slot())->deallocate(slot()); + HandleSet::heapFor(slot())->deallocate(slot()); setSlot(0); } @@ -125,7 +133,7 @@ private: { ASSERT(slot()); JSValue value = HandleTypes<T>::toJSValue(externalType); - HandleHeap::heapFor(slot())->writeBarrier(slot(), value); + HandleSet::heapFor(slot())->writeBarrier(slot(), value); *slot() = value; } }; |