Add a very bare-bones implementation of bind and Function to WTF
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Dec 2011 03:12:15 +0000 (03:12 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 14 Dec 2011 03:12:15 +0000 (03:12 +0000)
commit6ebf2f65679c566959f86966d332cf90500f900e
treec9fd410854e88b545df7dd65e8c807e7f2cb5687
parentb5a10bc3a20e44eb46de76e6ed83d9619005e317
Add a very bare-bones implementation of bind and Function to WTF
https://bugs.webkit.org/show_bug.cgi?id=74462

Reviewed by Sam Weinig.

Source/JavaScriptCore:

In order to make it easier to package up function calls and send them across
threads, add a (currently very simple) implementation of WTF::bind and WTF::Function to a new
wtf/Functional.h header.

Currently, all bind can do is bind a nullary function and return a Function object that can be called and copied,
but I'll add more as the need arises.

* GNUmakefile.list.am:
* JavaScriptCore.gypi:
* JavaScriptCore.vcproj/WTF/WTF.vcproj:
* JavaScriptCore.xcodeproj/project.pbxproj:
* wtf/Functional.h: Added.
(WTF::R):
(WTF::FunctionImplBase::~FunctionImplBase):
(WTF::FunctionWrapper::ResultType):
(WTF::FunctionBase::isNull):
(WTF::FunctionBase::FunctionBase):
(WTF::FunctionBase::impl):
(WTF::bind):
* wtf/MainThread.cpp:
(WTF::callFunctionObject):
(WTF::callOnMainThread):
* wtf/MainThread.h:
* wtf/wtf.pro:

Source/WebCore:

Add a forwarding header for Functional.h.

* ForwardingHeaders/wtf/Functional.h: Added.

Tools:

Add basic tests for WTF::Function and WTF::bind.

* TestWebKitAPI/TestWebKitAPI.gypi:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/Functional.cpp: Added.
(TestWebKitAPI::returnFortyTwo):
(TestWebKitAPI::TEST):
* TestWebKitAPI/win/TestWebKitAPI.vcproj:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@102730 268f45cc-cd09-0410-ab3c-d52691b4dbfc
16 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/GNUmakefile.list.am
Source/JavaScriptCore/JavaScriptCore.gypi
Source/JavaScriptCore/JavaScriptCore.vcproj/WTF/WTF.vcproj
Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
Source/JavaScriptCore/wtf/Functional.h [new file with mode: 0644]
Source/JavaScriptCore/wtf/MainThread.cpp
Source/JavaScriptCore/wtf/MainThread.h
Source/JavaScriptCore/wtf/wtf.pro
Source/WebCore/ChangeLog
Source/WebCore/ForwardingHeaders/wtf/Functional.h [new file with mode: 0644]
Tools/ChangeLog
Tools/TestWebKitAPI/TestWebKitAPI.gypi
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WTF/Functional.cpp [new file with mode: 0644]
Tools/TestWebKitAPI/win/TestWebKitAPI.vcproj