Title: [101446] trunk
Revision
101446
Author
[email protected]
Date
2011-11-29 21:36:03 -0800 (Tue, 29 Nov 2011)

Log Message

Add a way to revert a variable to its previous value after leaving a scope.
https://bugs.webkit.org/show_bug.cgi?id=73371

Reviewed by Adam Barth.

Source/_javascript_Core:

In case anyone from Chromium sees this, it is nearly identical to AutoReset
but if the same name were used, it causes unnecessary ambiguity.

* _javascript_Core.xcodeproj/project.pbxproj:
* wtf/TemporarilyChange.h: Added.
(WTF::TemporarilyChange::TemporarilyChange):
(WTF::TemporarilyChange::~TemporarilyChange):

Source/_javascript_Glue:

* ForwardingHeaders/wtf/TemporarilyChange.h: Added.

Source/WebCore:

* ForwardingHeaders/wtf/TemporarilyChange.h: Added.

Source/WebKit/mac:

* ForwardingHeaders/wtf/TemporarilyChange.h: Added.

Tools:

* DumpRenderTree/ForwardingHeaders/wtf/TemporarilyChange.h: Added.
* TestWebKitAPI/TestWebKitAPI.gypi: Added test file to the build.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Ditto.
* TestWebKitAPI/win/TestWebKitAPI.vcproj: Ditto.
* TestWebKitAPI/Tests/WTF/TemporarilyChange.cpp: Added.
(TestWebKitAPI::TEST): Added a test for TemporarilyChange.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (101445 => 101446)


--- trunk/Source/_javascript_Core/ChangeLog	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Source/_javascript_Core/ChangeLog	2011-11-30 05:36:03 UTC (rev 101446)
@@ -1,3 +1,18 @@
+2011-11-29  David Levin  <[email protected]>
+
+        Add a way to revert a variable to its previous value after leaving a scope.
+        https://bugs.webkit.org/show_bug.cgi?id=73371
+
+        Reviewed by Adam Barth.
+
+        In case anyone from Chromium sees this, it is nearly identical to AutoReset
+        but if the same name were used, it causes unnecessary ambiguity.
+
+        * _javascript_Core.xcodeproj/project.pbxproj:
+        * wtf/TemporarilyChange.h: Added.
+        (WTF::TemporarilyChange::TemporarilyChange):
+        (WTF::TemporarilyChange::~TemporarilyChange):
+
 2011-11-29  Sam Weinig  <[email protected]>
 
         Add COMPILER_SUPPORTS macro to allow for compiler feature testing

Modified: trunk/Source/_javascript_Core/_javascript_Core.gypi (101445 => 101446)


--- trunk/Source/_javascript_Core/_javascript_Core.gypi	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Source/_javascript_Core/_javascript_Core.gypi	2011-11-30 05:36:03 UTC (rev 101446)
@@ -207,6 +207,7 @@
             'wtf/StdLibExtras.h',
             'wtf/StringExtras.h',
             'wtf/StringHasher.h',
+            'wtf/TemporarilyChange.h',
             'wtf/ThreadSafeRefCounted.h',
             'wtf/ThreadSpecific.h',
             'wtf/ThreadRestrictionVerifier.h',

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/WTF/WTF.vcproj (101445 => 101446)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/WTF/WTF.vcproj	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/WTF/WTF.vcproj	2011-11-30 05:36:03 UTC (rev 101446)
@@ -1153,6 +1153,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\wtf\TemporarilyChange.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\wtf\Threading.cpp"
 			>
 		</File>

Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (101445 => 101446)


--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj	2011-11-30 05:36:03 UTC (rev 101446)
@@ -46,6 +46,7 @@
 		0B330C270F38C62300692DE3 /* TypeTraits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0B330C260F38C62300692DE3 /* TypeTraits.cpp */; };
 		0B4D7E630F319AC800AD7E58 /* TypeTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B4D7E620F319AC800AD7E58 /* TypeTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0BAC94A01338728400CF135B /* ThreadRestrictionVerifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BAC949E1338728400CF135B /* ThreadRestrictionVerifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		0BCD83571485845200EA2003 /* TemporarilyChange.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BCD83541485841200EA2003 /* TemporarilyChange.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0BDFFAE10FC6193100D69EF4 /* OwnFastMallocPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		0BF28A2911A33DC300638F84 /* SizeLimits.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BF28A2811A33DC300638F84 /* SizeLimits.cpp */; };
 		0F16D726142C39C000CF784A /* BitVector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0F16D724142C39A200CF784A /* BitVector.cpp */; };
@@ -822,6 +823,7 @@
 		0B330C260F38C62300692DE3 /* TypeTraits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TypeTraits.cpp; sourceTree = "<group>"; };
 		0B4D7E620F319AC800AD7E58 /* TypeTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypeTraits.h; sourceTree = "<group>"; };
 		0BAC949E1338728400CF135B /* ThreadRestrictionVerifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ThreadRestrictionVerifier.h; sourceTree = "<group>"; };
+		0BCD83541485841200EA2003 /* TemporarilyChange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TemporarilyChange.h; sourceTree = "<group>"; };
 		0BDFFAD10FC616EC00D69EF4 /* OwnFastMallocPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OwnFastMallocPtr.h; sourceTree = "<group>"; };
 		0BF28A2811A33DC300638F84 /* SizeLimits.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SizeLimits.cpp; sourceTree = "<group>"; };
 		0F16D724142C39A200CF784A /* BitVector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BitVector.cpp; sourceTree = "<group>"; };
@@ -2026,6 +2028,7 @@
 				6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */,
 				6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */,
 				6541BD7108E80A17002CBEE7 /* TCSystemAlloc.h */,
+				0BCD83541485841200EA2003 /* TemporarilyChange.h */,
 				8656573E115BE35200291F40 /* text */,
 				18BAB52710DADFCD000D945B /* ThreadIdentifierDataPthreads.cpp */,
 				18BAB52810DADFCD000D945B /* ThreadIdentifierDataPthreads.h */,
@@ -2872,6 +2875,7 @@
 				BC18C46C0E16F5CD00B34460 /* TCPackedCache.h in Headers */,
 				BC18C46D0E16F5CD00B34460 /* TCPageMap.h in Headers */,
 				BC18C46F0E16F5CD00B34460 /* TCSystemAlloc.h in Headers */,
+				0BCD83571485845200EA2003 /* TemporarilyChange.h in Headers */,
 				971EDEA61169E0D3005E4262 /* Terminator.h in Headers */,
 				F3BD31ED126735770065467F /* TextPosition.h in Headers */,
 				18BAB55410DAE066000D945B /* ThreadIdentifierDataPthreads.h in Headers */,

Added: trunk/Source/_javascript_Core/wtf/TemporarilyChange.h (0 => 101446)


--- trunk/Source/_javascript_Core/wtf/TemporarilyChange.h	                        (rev 0)
+++ trunk/Source/_javascript_Core/wtf/TemporarilyChange.h	2011-11-30 05:36:03 UTC (rev 101446)
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef TemporarilyChange_h
+#define TemporarilyChange_h
+
+#include "Noncopyable.h"
+
+namespace WTF {
+
+// TemporarilyChange<> is useful for setting a variable to a new value only within a
+// particular scope. An TemporarilyChange<> object changes a variable to its original
+// value upon destruction, making it an alternative to writing "var = false;"
+// or "var = oldVal;" at all of a block's exit points.
+//
+// This should be obvious, but note that an TemporarilyChange<> instance should have a
+// shorter lifetime than its scopedVariable, to prevent invalid memory writes
+// when the TemporarilyChange<> object is destroyed.
+
+template<typename T>
+class TemporarilyChange {
+    WTF_MAKE_NONCOPYABLE(TemporarilyChange);
+public:
+    TemporarilyChange(T& scopedVariable, T newValue)
+        : m_scopedVariable(scopedVariable)
+        , m_originalValue(scopedVariable)
+    {
+        m_scopedVariable = newValue;
+    }
+
+    ~TemporarilyChange()
+    {
+        m_scopedVariable = m_originalValue;
+    }
+
+
+private:
+    T& m_scopedVariable;
+    T m_originalValue;
+};
+
+}
+
+using WTF::TemporarilyChange;
+
+#endif
Property changes on: trunk/Source/_javascript_Core/wtf/TemporarilyChange.h
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/_javascript_Glue/ChangeLog (101445 => 101446)


--- trunk/Source/_javascript_Glue/ChangeLog	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Source/_javascript_Glue/ChangeLog	2011-11-30 05:36:03 UTC (rev 101446)
@@ -1,3 +1,12 @@
+2011-11-29  David Levin  <[email protected]>
+
+        Add a way to revert a variable to its previous value after leaving a scope.
+        https://bugs.webkit.org/show_bug.cgi?id=73371
+
+        Reviewed by Adam Barth.
+
+        * ForwardingHeaders/wtf/TemporarilyChange.h: Added.
+
 2011-11-11  Mark Hahnenberg  <[email protected]>
 
         Add jsCast to replace static_cast

Added: trunk/Source/_javascript_Glue/ForwardingHeaders/wtf/TemporarilyChange.h (0 => 101446)


--- trunk/Source/_javascript_Glue/ForwardingHeaders/wtf/TemporarilyChange.h	                        (rev 0)
+++ trunk/Source/_javascript_Glue/ForwardingHeaders/wtf/TemporarilyChange.h	2011-11-30 05:36:03 UTC (rev 101446)
@@ -0,0 +1 @@
+#include <_javascript_Core/TemporarilyChange.h>
Property changes on: trunk/Source/_javascript_Glue/ForwardingHeaders/wtf/TemporarilyChange.h
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (101445 => 101446)


--- trunk/Source/WebCore/ChangeLog	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Source/WebCore/ChangeLog	2011-11-30 05:36:03 UTC (rev 101446)
@@ -1,3 +1,12 @@
+2011-11-29  David Levin  <[email protected]>
+
+        Add a way to revert a variable to its previous value after leaving a scope.
+        https://bugs.webkit.org/show_bug.cgi?id=73371
+
+        Reviewed by Adam Barth.
+
+        * ForwardingHeaders/wtf/TemporarilyChange.h: Added.
+
 2011-11-28  Kentaro Hara  <[email protected]>
 
         Implement [Supplemental] IDL and support it in run-bindings-tests

Added: trunk/Source/WebCore/ForwardingHeaders/wtf/TemporarilyChange.h (0 => 101446)


--- trunk/Source/WebCore/ForwardingHeaders/wtf/TemporarilyChange.h	                        (rev 0)
+++ trunk/Source/WebCore/ForwardingHeaders/wtf/TemporarilyChange.h	2011-11-30 05:36:03 UTC (rev 101446)
@@ -0,0 +1,4 @@
+#ifndef WebCore_FWD_TemporarilyChange_h
+#define WebCore_FWD_TemporarilyChange_h
+#include <_javascript_Core/TemporarilyChange.h>
+#endif
Property changes on: trunk/Source/WebCore/ForwardingHeaders/wtf/TemporarilyChange.h
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Source/WebKit/mac/ChangeLog (101445 => 101446)


--- trunk/Source/WebKit/mac/ChangeLog	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Source/WebKit/mac/ChangeLog	2011-11-30 05:36:03 UTC (rev 101446)
@@ -1,3 +1,12 @@
+2011-11-29  David Levin  <[email protected]>
+
+        Add a way to revert a variable to its previous value after leaving a scope.
+        https://bugs.webkit.org/show_bug.cgi?id=73371
+
+        Reviewed by Adam Barth.
+
+        * ForwardingHeaders/wtf/TemporarilyChange.h: Added.
+
 2011-11-29  Jessie Berlin  <[email protected]>
 
         WKKeyValueStorageManagerGetKeyValueStorageOrigins may not report the correct list of origins

Added: trunk/Source/WebKit/mac/ForwardingHeaders/wtf/TemporarilyChange.h (0 => 101446)


--- trunk/Source/WebKit/mac/ForwardingHeaders/wtf/TemporarilyChange.h	                        (rev 0)
+++ trunk/Source/WebKit/mac/ForwardingHeaders/wtf/TemporarilyChange.h	2011-11-30 05:36:03 UTC (rev 101446)
@@ -0,0 +1 @@
+#include <_javascript_Core/TemporarilyChange.h>
Property changes on: trunk/Source/WebKit/mac/ForwardingHeaders/wtf/TemporarilyChange.h
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Tools/ChangeLog (101445 => 101446)


--- trunk/Tools/ChangeLog	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Tools/ChangeLog	2011-11-30 05:36:03 UTC (rev 101446)
@@ -1,3 +1,17 @@
+2011-11-29  David Levin  <[email protected]>
+
+        Add a way to revert a variable to its previous value after leaving a scope.
+        https://bugs.webkit.org/show_bug.cgi?id=73371
+
+        Reviewed by Adam Barth.
+
+        * DumpRenderTree/ForwardingHeaders/wtf/TemporarilyChange.h: Added.
+        * TestWebKitAPI/TestWebKitAPI.gypi: Added test file to the build.
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj: Ditto.
+        * TestWebKitAPI/win/TestWebKitAPI.vcproj: Ditto.
+        * TestWebKitAPI/Tests/WTF/TemporarilyChange.cpp: Added.
+        (TestWebKitAPI::TEST): Added a test for TemporarilyChange.
+
 2011-11-28  Kentaro Hara  <[email protected]>
 
         Implement [Supplemental] IDL and support it in run-bindings-tests

Added: trunk/Tools/DumpRenderTree/ForwardingHeaders/wtf/TemporarilyChange.h (0 => 101446)


--- trunk/Tools/DumpRenderTree/ForwardingHeaders/wtf/TemporarilyChange.h	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/ForwardingHeaders/wtf/TemporarilyChange.h	2011-11-30 05:36:03 UTC (rev 101446)
@@ -0,0 +1 @@
+#include <_javascript_Core/TemporarilyChange.h>
Property changes on: trunk/Tools/DumpRenderTree/ForwardingHeaders/wtf/TemporarilyChange.h
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.gypi (101445 => 101446)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.gypi	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.gypi	2011-11-30 05:36:03 UTC (rev 101446)
@@ -35,6 +35,7 @@
             'Tests/WTF/RedBlackTree.cpp',
             'Tests/WTF/StringBuilder.cpp',
             'Tests/WTF/StringOperators.cpp',
+            'Tests/WTF/TemporarilyChange.cpp',
             'Tests/WTF/VectorBasic.cpp',
             'Tests/WTF/VectorReverse.cpp',
         ],

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (101445 => 101446)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2011-11-30 05:36:03 UTC (rev 101446)
@@ -7,6 +7,7 @@
 	objects = {
 
 /* Begin PBXBuildFile section */
+		0BCD856A1485C98B00EA2003 /* TemporarilyChange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0BCD85691485C98B00EA2003 /* TemporarilyChange.cpp */; };
 		0FC6C4CC141027E0005B7F0C /* RedBlackTree.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */; };
 		0FC6C4CF141034AD005B7F0C /* MetaAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */; };
 		1A02C84F125D4A8400E3F4BD /* Find.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A02C84E125D4A8400E3F4BD /* Find.cpp */; };
@@ -145,6 +146,7 @@
 /* End PBXCopyFilesBuildPhase section */
 
 /* Begin PBXFileReference section */
+		0BCD85691485C98B00EA2003 /* TemporarilyChange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TemporarilyChange.cpp; path = WTF/TemporarilyChange.cpp; sourceTree = "<group>"; };
 		0FC6C4CB141027E0005B7F0C /* RedBlackTree.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = RedBlackTree.cpp; path = WTF/RedBlackTree.cpp; sourceTree = "<group>"; };
 		0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = MetaAllocator.cpp; path = WTF/MetaAllocator.cpp; sourceTree = "<group>"; };
 		1A02C84B125D4A5E00E3F4BD /* find.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = find.html; sourceTree = "<group>"; };
@@ -416,6 +418,7 @@
 				A7A966DA140ECCC8005EF9B4 /* CheckedArithmeticOperations.cpp */,
 				81B50192140F232300D9EB58 /* StringBuilder.cpp */,
 				C01363C713C3997300EF3964 /* StringOperators.cpp */,
+				0BCD85691485C98B00EA2003 /* TemporarilyChange.cpp */,
 				BC90964B125561BF00083756 /* VectorBasic.cpp */,
 				37200B9113A16230007A4FAD /* VectorReverse.cpp */,
 			);
@@ -660,6 +663,7 @@
 				BC3C4C7F14587AA60025FB62 /* WKBrowsingContextGroupTest.mm in Sources */,
 				C0C5D3BE14598B6F00A802A6 /* GetBackingScaleFactor.mm in Sources */,
 				3722C8691461E03E00C45D00 /* RenderedImageFromDOMRange.mm in Sources */,
+				0BCD856A1485C98B00EA2003 /* TemporarilyChange.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Tools/TestWebKitAPI/Tests/WTF/TemporarilyChange.cpp (0 => 101446)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/TemporarilyChange.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/TemporarilyChange.cpp	2011-11-30 05:36:03 UTC (rev 101446)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2011 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#include <wtf/TemporarilyChange.h>
+
+namespace TestWebKitAPI {
+
+TEST(WTF, TemporarilyChangeNested)
+{
+    bool originallyFalse = false;
+    {
+        TemporarilyChange<bool> change1OriginallyFalse(originallyFalse, true);
+        EXPECT_TRUE(originallyFalse);
+        {
+            TemporarilyChange<bool> change2OriginallyFalse(originallyFalse, false);
+            EXPECT_FALSE(originallyFalse);
+        }
+        EXPECT_TRUE(originallyFalse);
+    }
+    EXPECT_FALSE(originallyFalse);
+}
+
+} // namespace TestWebKitAPI
Property changes on: trunk/Tools/TestWebKitAPI/Tests/WTF/TemporarilyChange.cpp
___________________________________________________________________

Added: svn:eol-style

Modified: trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj (101445 => 101446)


--- trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj	2011-11-30 04:35:47 UTC (rev 101445)
+++ trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj	2011-11-30 05:36:03 UTC (rev 101446)
@@ -640,6 +640,10 @@
 					>
 				</File>
 				<File
+					RelativePath="..\Tests\WTF\TemporarilyChange.cpp"
+					>
+				</File>
+				<File
 					RelativePath="..\Tests\WTF\VectorBasic.cpp"
 					>
 				</File>
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to