Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (88476 => 88477)
--- trunk/Source/_javascript_Core/ChangeLog 2011-06-09 20:24:59 UTC (rev 88476)
+++ trunk/Source/_javascript_Core/ChangeLog 2011-06-09 20:29:02 UTC (rev 88477)
@@ -1,3 +1,13 @@
+2011-06-09 Dan Bernstein <[email protected]>
+
+ Reviewed by Anders Carlsson.
+
+ Add Vector::reverse()
+ https://bugs.webkit.org/show_bug.cgi?id=62393
+
+ * wtf/Vector.h:
+ (WTF::Vector::reverse): Added
+
2011-06-08 Geoffrey Garen <[email protected]>
Reviewed by Oliver Hunt.
Modified: trunk/Source/_javascript_Core/wtf/Vector.h (88476 => 88477)
--- trunk/Source/_javascript_Core/wtf/Vector.h 2011-06-09 20:24:59 UTC (rev 88476)
+++ trunk/Source/_javascript_Core/wtf/Vector.h 2011-06-09 20:29:02 UTC (rev 88477)
@@ -619,6 +619,8 @@
m_buffer.swap(other.m_buffer);
}
+ void reverse();
+
void checkConsistency();
private:
@@ -1097,6 +1099,13 @@
}
template<typename T, size_t inlineCapacity>
+ inline void Vector<T, inlineCapacity>::reverse()
+ {
+ for (size_t i = 0; i < m_size / 2; ++i)
+ std::swap(at(i), at(m_size - 1 - i));
+ }
+
+ template<typename T, size_t inlineCapacity>
inline T* Vector<T, inlineCapacity>::releaseBuffer()
{
T* buffer = m_buffer.releaseBuffer();
Modified: trunk/Tools/ChangeLog (88476 => 88477)
--- trunk/Tools/ChangeLog 2011-06-09 20:24:59 UTC (rev 88476)
+++ trunk/Tools/ChangeLog 2011-06-09 20:29:02 UTC (rev 88477)
@@ -1,3 +1,15 @@
+2011-06-09 Dan Bernstein <[email protected]>
+
+ Reviewed by Anders Carlsson.
+
+ Added a test for Vector::reverse()
+ https://bugs.webkit.org/show_bug.cgi?id=62393
+
+ * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+ * TestWebKitAPI/Tests/WTF/VectorReverse.cpp: Added.
+ (TestWebKitAPI::TEST):
+ * TestWebKitAPI/win/TestWebKitAPI.vcproj:
+
2011-06-09 Martin Robinson <[email protected]>
Reviewed by Andreas Kling.
Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (88476 => 88477)
--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2011-06-09 20:24:59 UTC (rev 88476)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj 2011-06-09 20:29:02 UTC (rev 88477)
@@ -16,6 +16,7 @@
33BE5AF5137B5A6C00705813 /* MouseMoveAfterCrash.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */; };
33BE5AF9137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */; };
33E79E06137B5FD900E32D99 /* mouse-move-listener.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */; };
+ 37200B9213A16230007A4FAD /* VectorReverse.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37200B9113A16230007A4FAD /* VectorReverse.cpp */; };
4BFDFFA71314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */; };
4BFDFFA9131477770061F24B /* HitTestResultNodeHandle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BFDFFA8131477770061F24B /* HitTestResultNodeHandle.cpp */; };
BC131885117114B600B69727 /* PlatformUtilitiesMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC131884117114B600B69727 /* PlatformUtilitiesMac.mm */; };
@@ -115,6 +116,7 @@
33BE5AF4137B5A6C00705813 /* MouseMoveAfterCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash.cpp; sourceTree = "<group>"; };
33BE5AF8137B5AAE00705813 /* MouseMoveAfterCrash_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MouseMoveAfterCrash_Bundle.cpp; sourceTree = "<group>"; };
33E79E05137B5FCE00E32D99 /* mouse-move-listener.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "mouse-move-listener.html"; sourceTree = "<group>"; };
+ 37200B9113A16230007A4FAD /* VectorReverse.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VectorReverse.cpp; path = WTF/VectorReverse.cpp; sourceTree = "<group>"; };
4BFDFFA61314776C0061F24B /* HitTestResultNodeHandle_Bundle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResultNodeHandle_Bundle.cpp; sourceTree = "<group>"; };
4BFDFFA8131477770061F24B /* HitTestResultNodeHandle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HitTestResultNodeHandle.cpp; sourceTree = "<group>"; };
8DD76FA10486AA7600D96B5E /* TestWebKitAPI */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = TestWebKitAPI; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -318,6 +320,7 @@
isa = PBXGroup;
children = (
BC90964B125561BF00083756 /* VectorBasic.cpp */,
+ 37200B9113A16230007A4FAD /* VectorReverse.cpp */,
);
name = WTF;
sourceTree = "<group>";
@@ -467,6 +470,7 @@
F6F3F29113342FEB00A6BF19 /* CookieManager.cpp in Sources */,
33BE5AF5137B5A6C00705813 /* MouseMoveAfterCrash.cpp in Sources */,
C045F9451385C2EA00C0F3CD /* DownloadDecideDestinationCrash.cpp in Sources */,
+ 37200B9213A16230007A4FAD /* VectorReverse.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Added: trunk/Tools/TestWebKitAPI/Tests/WTF/VectorReverse.cpp (0 => 88477)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/VectorReverse.cpp (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/VectorReverse.cpp 2011-06-09 20:29:02 UTC (rev 88477)
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2011 Apple 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 "Test.h"
+
+#include <_javascript_Core/Vector.h>
+
+namespace TestWebKitAPI {
+
+TEST(WTF, VectorReverse)
+{
+ Vector<int> intVector;
+ intVector.append(10);
+ intVector.append(11);
+ intVector.append(12);
+ intVector.append(13);
+ intVector.reverse();
+
+ EXPECT_EQ(13, intVector[0]);
+ EXPECT_EQ(12, intVector[1]);
+ EXPECT_EQ(11, intVector[2]);
+ EXPECT_EQ(10, intVector[3]);
+
+ intVector.append(9);
+ intVector.reverse();
+
+ EXPECT_EQ(9, intVector[0]);
+ EXPECT_EQ(10, intVector[1]);
+ EXPECT_EQ(11, intVector[2]);
+ EXPECT_EQ(12, intVector[3]);
+ EXPECT_EQ(13, intVector[4]);
+}
+
+} // namespace TestWebKitAPI
Modified: trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj (88476 => 88477)
--- trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj 2011-06-09 20:24:59 UTC (rev 88476)
+++ trunk/Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj 2011-06-09 20:29:02 UTC (rev 88477)
@@ -591,6 +591,10 @@
RelativePath="..\Tests\WTF\VectorBasic.cpp"
>
</File>
+ <File
+ RelativePath="..\Tests\WTF\VectorReverse.cpp"
+ >
+ </File>
</Filter>
</Filter>
<File