Title: [140857] trunk/Source/WTF
Revision
140857
Author
[email protected]
Date
2013-01-25 12:18:58 -0800 (Fri, 25 Jan 2013)

Log Message

Support 4 and 5 argument bound static functions
https://bugs.webkit.org/show_bug.cgi?id=107973

Reviewed by Anders Carlsson.

Yummy copy/paste template code!
I'm about to use this in a BackgroundHTMLParser patch, but figured this should be landed separately.

* wtf/Functional.h:
(WTF):
(WTF::R):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (140856 => 140857)


--- trunk/Source/WTF/ChangeLog	2013-01-25 20:13:32 UTC (rev 140856)
+++ trunk/Source/WTF/ChangeLog	2013-01-25 20:18:58 UTC (rev 140857)
@@ -1,3 +1,17 @@
+2013-01-25  Eric Seidel  <[email protected]>
+
+        Support 4 and 5 argument bound static functions
+        https://bugs.webkit.org/show_bug.cgi?id=107973
+
+        Reviewed by Anders Carlsson.
+
+        Yummy copy/paste template code!
+        I'm about to use this in a BackgroundHTMLParser patch, but figured this should be landed separately.
+
+        * wtf/Functional.h:
+        (WTF):
+        (WTF::R):
+
 2013-01-24  Martin Robinson  <[email protected]>
 
         Abstract the logic for appending a UChar32 onto StringBuilder

Modified: trunk/Source/WTF/wtf/Functional.h (140856 => 140857)


--- trunk/Source/WTF/wtf/Functional.h	2013-01-25 20:13:32 UTC (rev 140856)
+++ trunk/Source/WTF/wtf/Functional.h	2013-01-25 20:18:58 UTC (rev 140857)
@@ -78,6 +78,8 @@
 template<typename>
 class FunctionWrapper;
 
+// Bound static functions:
+
 template<typename R>
 class FunctionWrapper<R (*)()> {
 public:
@@ -158,6 +160,48 @@
     R (*m_function)(P1, P2, P3);
 };
 
+template<typename R, typename P1, typename P2, typename P3, typename P4>
+class FunctionWrapper<R (*)(P1, P2, P3, P4)> {
+public:
+    typedef R ResultType;
+    static const bool shouldRefFirstParameter = false;
+
+    explicit FunctionWrapper(R (*function)(P1, P2, P3, P4))
+        : m_function(function)
+    {
+    }
+
+    R operator()(P1 p1, P2 p2, P3 p3, P4 p4)
+    {
+        return m_function(p1, p2, p3, p4);
+    }
+
+private:
+    R (*m_function)(P1, P2, P3, P4);
+};
+
+template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
+class FunctionWrapper<R (*)(P1, P2, P3, P4, P5)> {
+public:
+    typedef R ResultType;
+    static const bool shouldRefFirstParameter = false;
+
+    explicit FunctionWrapper(R (*function)(P1, P2, P3, P4, P5))
+        : m_function(function)
+    {
+    }
+
+    R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
+    {
+        return m_function(p1, p2, p3, p4, p5);
+    }
+
+private:
+    R (*m_function)(P1, P2, P3, P4, P5);
+};
+
+// Bound member functions:
+
 template<typename R, typename C>
 class FunctionWrapper<R (C::*)()> {
 public:
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to