From 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 7 May 2012 11:21:11 +0200 Subject: Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286) --- Source/JavaScriptCore/heap/Strong.h | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'Source/JavaScriptCore/heap/Strong.h') 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 #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(1) : 0; } + void swap(Strong& other) { Handle::swap(other); } + ExternalType get() const { return HandleTypes::getFromSlot(this->slot()); } + void set(JSGlobalData&, ExternalType); template Strong& operator=(const Strong& 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::toJSValue(externalType); - HandleHeap::heapFor(slot())->writeBarrier(slot(), value); + HandleSet::heapFor(slot())->writeBarrier(slot(), value); *slot() = value; } }; -- cgit v1.2.1