Changeset 140857 in webkit


Ignore:
Timestamp:
Jan 25, 2013 12:18:58 PM (11 years ago)
Author:
eric@webkit.org
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):

Location:
trunk/Source/WTF
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r140731 r140857  
     12013-01-25  Eric Seidel  <eric@webkit.org>
     2
     3        Support 4 and 5 argument bound static functions
     4        https://bugs.webkit.org/show_bug.cgi?id=107973
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Yummy copy/paste template code!
     9        I'm about to use this in a BackgroundHTMLParser patch, but figured this should be landed separately.
     10
     11        * wtf/Functional.h:
     12        (WTF):
     13        (WTF::R):
     14
    1152013-01-24  Martin Robinson  <mrobinson@igalia.com>
    216
  • trunk/Source/WTF/wtf/Functional.h

    r140589 r140857  
    7979class FunctionWrapper;
    8080
     81// Bound static functions:
     82
    8183template<typename R>
    8284class FunctionWrapper<R (*)()> {
     
    158160    R (*m_function)(P1, P2, P3);
    159161};
     162
     163template<typename R, typename P1, typename P2, typename P3, typename P4>
     164class FunctionWrapper<R (*)(P1, P2, P3, P4)> {
     165public:
     166    typedef R ResultType;
     167    static const bool shouldRefFirstParameter = false;
     168
     169    explicit FunctionWrapper(R (*function)(P1, P2, P3, P4))
     170        : m_function(function)
     171    {
     172    }
     173
     174    R operator()(P1 p1, P2 p2, P3 p3, P4 p4)
     175    {
     176        return m_function(p1, p2, p3, p4);
     177    }
     178
     179private:
     180    R (*m_function)(P1, P2, P3, P4);
     181};
     182
     183template<typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
     184class FunctionWrapper<R (*)(P1, P2, P3, P4, P5)> {
     185public:
     186    typedef R ResultType;
     187    static const bool shouldRefFirstParameter = false;
     188
     189    explicit FunctionWrapper(R (*function)(P1, P2, P3, P4, P5))
     190        : m_function(function)
     191    {
     192    }
     193
     194    R operator()(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5)
     195    {
     196        return m_function(p1, p2, p3, p4, p5);
     197    }
     198
     199private:
     200    R (*m_function)(P1, P2, P3, P4, P5);
     201};
     202
     203// Bound member functions:
    160204
    161205template<typename R, typename C>
Note: See TracChangeset for help on using the changeset viewer.