[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
thakis at chromium.org
thakis at chromium.org
Wed Dec 22 14:10:25 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 7403709634a07a134c225fecd80d2b832fd099a3
Author: thakis at chromium.org <thakis at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Tue Oct 5 06:10:04 2010 +0000
2010-10-04 Nico Weber <thakis at chromium.org>
Reviewed by Kenneth Russell.
Fix broken C++ in PODInterval and PODIntervalTree
https://bugs.webkit.org/show_bug.cgi?id=47063
See http://clang.llvm.org/compatibility.html#dep_lookup . Since
valueToString needs to work with non-class types, it needs to be
declared before it's used. And since it needs to handle many types, it
needs to be a template function, for which clients will need to
provide specializations for the types they care about. Partial template
specialization is only supported for structs, so wrap the function in
a struct, too.
* platform/graphics/gpu/PODInterval.h:
(WebCore::PODInterval::toString):
* platform/graphics/gpu/PODIntervalTree.h:
(WebCore::PODIntervalTree::checkInvariantsFromNode):
* platform/graphics/gpu/PODRedBlackTree.h:
(WebCore::PODRedBlackTree::dumpFromNode):
2010-10-04 Nico Weber <thakis at chromium.org>
Reviewed by Kenneth Russell.
Fix broken C++ in PODInterval and PODIntervalTree
https://bugs.webkit.org/show_bug.cgi?id=47063
Change functions to be template specializations, like it's now required
by PODIntervalTree and friends.
* tests/PODIntervalTreeTest.cpp:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69081 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f008e63..0f057f8 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-10-04 Nico Weber <thakis at chromium.org>
+
+ Reviewed by Kenneth Russell.
+
+ Fix broken C++ in PODInterval and PODIntervalTree
+ https://bugs.webkit.org/show_bug.cgi?id=47063
+
+ See http://clang.llvm.org/compatibility.html#dep_lookup . Since
+ valueToString needs to work with non-class types, it needs to be
+ declared before it's used. And since it needs to handle many types, it
+ needs to be a template function, for which clients will need to
+ provide specializations for the types they care about. Partial template
+ specialization is only supported for structs, so wrap the function in
+ a struct, too.
+
+ * platform/graphics/gpu/PODInterval.h:
+ (WebCore::PODInterval::toString):
+ * platform/graphics/gpu/PODIntervalTree.h:
+ (WebCore::PODIntervalTree::checkInvariantsFromNode):
+ * platform/graphics/gpu/PODRedBlackTree.h:
+ (WebCore::PODRedBlackTree::dumpFromNode):
+
2010-10-04 Yael Aharon <yael.aharon at nokia.com>
Reviewed by Antonio Gomes.
diff --git a/WebCore/platform/graphics/gpu/PODInterval.h b/WebCore/platform/graphics/gpu/PODInterval.h
index 9df69ba..12a4420 100644
--- a/WebCore/platform/graphics/gpu/PODInterval.h
+++ b/WebCore/platform/graphics/gpu/PODInterval.h
@@ -57,14 +57,24 @@ namespace WebCore {
// constructor and assignment operator.
//
// In debug mode, printing of intervals and the data they contain is
-// enabled. This requires the following functions to be available:
+// enabled. This requires the following template specializations to be
+// available:
//
-// String valueToString(const T&);
-// String valueToString(const UserData&);
+// template<> struct WebCore::ValueToString<T> {
+// static String string(const T& t);
+// };
+// template<> struct WebCore::ValueToString<UserData> {
+// static String string(const UserData& t);
+// };
//
// Note that this class requires a copy constructor and assignment
// operator in order to be stored in the red-black tree.
+#ifndef NDEBUG
+template<class T>
+struct ValueToString;
+#endif
+
template<class T, class UserData = void*>
class PODInterval {
public:
@@ -131,13 +141,13 @@ public:
{
StringBuilder builder;
builder.append("[PODInterval (");
- builder.append(valueToString(low()));
+ builder.append(ValueToString<T>::string(low()));
builder.append(", ");
- builder.append(valueToString(high()));
+ builder.append(ValueToString<T>::string(high()));
builder.append("), data=");
- builder.append(valueToString(data()));
+ builder.append(ValueToString<UserData>::string(data()));
builder.append(", maxHigh=");
- builder.append(valueToString(maxHigh()));
+ builder.append(ValueToString<T>::string(maxHigh()));
builder.append("]");
return builder.toString();
}
diff --git a/WebCore/platform/graphics/gpu/PODIntervalTree.h b/WebCore/platform/graphics/gpu/PODIntervalTree.h
index c0a86aa..320ce60 100644
--- a/WebCore/platform/graphics/gpu/PODIntervalTree.h
+++ b/WebCore/platform/graphics/gpu/PODIntervalTree.h
@@ -35,6 +35,11 @@
namespace WebCore {
+#ifndef NDEBUG
+template<class T>
+struct ValueToString;
+#endif
+
// An interval tree, which is a form of augmented red-black tree. It
// supports efficient (O(lg n)) insertion, removal and querying of
// intervals in the tree.
@@ -191,7 +196,7 @@ private:
localMaxValue = node->data().high();
if (!(localMaxValue == node->data().maxHigh())) {
#ifndef NDEBUG
- String localMaxValueString = valueToString(localMaxValue);
+ String localMaxValueString = ValueToString<T>::string(localMaxValue);
LOG_ERROR("PODIntervalTree verification failed at node 0x%p: localMaxValue=%s and data=%s",
node, localMaxValueString.utf8().data(), node->data().toString().utf8().data());
#endif
@@ -206,10 +211,12 @@ private:
#ifndef NDEBUG
// Support for printing PODIntervals at the PODRedBlackTree level.
template<class T, class UserData>
-String valueToString(const PODInterval<T, UserData>& interval)
-{
- return interval.toString();
-}
+struct ValueToString<PODInterval<T, UserData> > {
+ static String string(const PODInterval<T, UserData>& interval)
+ {
+ return interval.toString();
+ }
+};
#endif
} // namespace WebCore
diff --git a/WebCore/platform/graphics/gpu/PODRedBlackTree.h b/WebCore/platform/graphics/gpu/PODRedBlackTree.h
index 9b02037..7898628 100644
--- a/WebCore/platform/graphics/gpu/PODRedBlackTree.h
+++ b/WebCore/platform/graphics/gpu/PODRedBlackTree.h
@@ -42,9 +42,11 @@
// the "<" and "==" operators.
//
// In debug mode, printing of the data contained in the tree is
-// enabled. This requires the following function to be available:
+// enabled. This requires the template specialization to be available:
//
-// String valueToString(const T&);
+// template<> struct WebCore::ValueToString<T> {
+// static String string(const T& t);
+// };
//
// Note that when complex types are stored in this red/black tree, it
// is possible that single invocations of the "<" and "==" operators
@@ -83,6 +85,11 @@
namespace WebCore {
+#ifndef NDEBUG
+template<class T>
+struct ValueToString;
+#endif
+
template<class T>
class PODRedBlackTree {
public:
@@ -723,7 +730,7 @@ private:
builder.append("-");
if (node) {
builder.append(" ");
- builder.append(valueToString(node->data()));
+ builder.append(ValueToString<T>::string(node->data()));
builder.append((node->color() == Black) ? " (black)" : " (red)");
}
LOG_ERROR("%s", builder.toString().ascii().data());
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index b037061..bc8477c 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,15 @@
+2010-10-04 Nico Weber <thakis at chromium.org>
+
+ Reviewed by Kenneth Russell.
+
+ Fix broken C++ in PODInterval and PODIntervalTree
+ https://bugs.webkit.org/show_bug.cgi?id=47063
+
+ Change functions to be template specializations, like it's now required
+ by PODIntervalTree and friends.
+
+ * tests/PODIntervalTreeTest.cpp:
+
2010-10-04 Matt Mueller <mattm at chromium.org>
Reviewed by Darin Fisher.
diff --git a/WebKit/chromium/tests/PODIntervalTreeTest.cpp b/WebKit/chromium/tests/PODIntervalTreeTest.cpp
index 3a8a245..8241a89 100644
--- a/WebKit/chromium/tests/PODIntervalTreeTest.cpp
+++ b/WebKit/chromium/tests/PODIntervalTreeTest.cpp
@@ -41,15 +41,20 @@ using TreeTestHelpers::generateSeed;
using TreeTestHelpers::initRandom;
using TreeTestHelpers::nextRandom;
-inline String valueToString(const float& value)
-{
- return String::number(value);
-}
+#ifndef NDEBUG
+template<>
+struct ValueToString<float> {
+ static String string(const float& value) { return String::number(value); }
+};
-inline String valueToString(void* const& value)
-{
- return String::format("0x%p", value);
-}
+template<>
+struct ValueToString<void*> {
+ static String string(void* const& value)
+ {
+ return String::format("0x%p", value);
+ }
+};
+#endif
TEST(PODIntervalTreeTest, TestInsertion)
{
@@ -82,6 +87,16 @@ TEST(PODIntervalTreeTest, TestQueryAgainstZeroSizeInterval)
EXPECT_EQ(4, result[0].high());
}
+#ifndef NDEBUG
+template<>
+struct ValueToString<int*> {
+ static String string(int* const& value)
+ {
+ return String::format("0x%p", value);
+ }
+};
+#endif
+
TEST(PODIntervalTreeTest, TestDuplicateElementInsertion)
{
PODIntervalTree<float, int*> tree;
@@ -113,13 +128,18 @@ public:
int b;
};
-inline String valueToString(const UserData1& value)
-{
- return String("[UserData1 a=") + String::number(value.a) + " b=" + String::number(value.b) + "]";
-}
-
} // anonymous namespace
+#ifndef NDEBUG
+template<>
+struct ValueToString<UserData1> {
+ static String string(const UserData1& value)
+ {
+ return String("[UserData1 a=") + String::number(value.a) + " b=" + String::number(value.b) + "]";
+ }
+};
+#endif
+
TEST(PODIntervalTreeTest, TestInsertionOfComplexUserData)
{
PODIntervalTree<float, UserData1> tree;
@@ -165,13 +185,18 @@ private:
bool operator!=(const EndpointType1& other);
};
-inline String valueToString(const EndpointType1& value)
-{
- return String("[EndpointType1 value=") + String::number(value.value()) + "]";
-}
-
} // anonymous namespace
+#ifndef NDEBUG
+template<>
+struct ValueToString<EndpointType1> {
+ static String string(const EndpointType1& value)
+ {
+ return String("[EndpointType1 value=") + String::number(value.value()) + "]";
+ }
+};
+#endif
+
TEST(PODIntervalTreeTest, TestTreeDoesNotRequireMostOperators)
{
PODIntervalTree<EndpointType1> tree;
@@ -179,9 +204,17 @@ TEST(PODIntervalTreeTest, TestTreeDoesNotRequireMostOperators)
ASSERT_TRUE(tree.checkInvariants());
}
-// Uncomment to debug a failure of the insertion and deletion test.
+// Uncomment to debug a failure of the insertion and deletion test. Won't work
+// in release builds.
// #define DEBUG_INSERTION_AND_DELETION_TEST
+#ifndef NDEBUG
+template<>
+struct ValueToString<int> {
+ static String string(const int& value) { return String::number(value); }
+};
+#endif
+
namespace {
void InsertionAndDeletionTest(int32_t seed, int treeSize)
@@ -198,7 +231,7 @@ void InsertionAndDeletionTest(int32_t seed, int treeSize)
PODInterval<int> interval(left, left + length);
tree.add(interval);
#ifdef DEBUG_INSERTION_AND_DELETION_TEST
- LOG_ERROR("*** Adding element %s", valueToString(interval).ascii().data());
+ LOG_ERROR("*** Adding element %s", ValueToString<PODInterval<int> >::string(interval).ascii().data());
#endif
addedElements.append(interval);
}
@@ -207,7 +240,7 @@ void InsertionAndDeletionTest(int32_t seed, int treeSize)
for (int i = 0; i < treeSize / 2; i++) {
int index = nextRandom(addedElements.size());
#ifdef DEBUG_INSERTION_AND_DELETION_TEST
- LOG_ERROR("*** Removing element %s", valueToString(addedElements[index]).ascii().data());
+ LOG_ERROR("*** Removing element %s", ValueToString<PODInterval<int> >::string(addedElements[index]).ascii().data());
#endif
ASSERT_TRUE(tree.contains(addedElements[index])) << "Test failed for seed " << seed;
tree.remove(addedElements[index]);
@@ -227,7 +260,7 @@ void InsertionAndDeletionTest(int32_t seed, int treeSize)
if (add) {
int index = nextRandom(removedElements.size());
#ifdef DEBUG_INSERTION_AND_DELETION_TEST
- LOG_ERROR("*** Adding element %s", valueToString(removedElements[index]).ascii().data());
+ LOG_ERROR("*** Adding element %s", ValueToString<PODInterval<int> >::string(removedElements[index]).ascii().data());
#endif
tree.add(removedElements[index]);
addedElements.append(removedElements[index]);
@@ -235,7 +268,7 @@ void InsertionAndDeletionTest(int32_t seed, int treeSize)
} else {
int index = nextRandom(addedElements.size());
#ifdef DEBUG_INSERTION_AND_DELETION_TEST
- LOG_ERROR("*** Removing element %s", valueToString(addedElements[index]).ascii().data());
+ LOG_ERROR("*** Removing element %s", ValueToString<PODInterval<int> >::string(addedElements[index]).ascii().data());
#endif
ASSERT_TRUE(tree.contains(addedElements[index])) << "Test failed for seed " << seed;
ASSERT_TRUE(tree.remove(addedElements[index])) << "Test failed for seed " << seed;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list