Title: [115662] trunk/Source/WTF
- Revision
- 115662
- Author
- [email protected]
- Date
- 2012-04-30 14:02:39 -0700 (Mon, 30 Apr 2012)
Log Message
WTF::bind should work with blocks
https://bugs.webkit.org/show_bug.cgi?id=85227
Reviewed by Sam Weinig.
Add a block type FunctionWrapper specialization.
* wtf/Functional.h:
Modified Paths
Diff
Modified: trunk/Source/WTF/ChangeLog (115661 => 115662)
--- trunk/Source/WTF/ChangeLog 2012-04-30 20:27:35 UTC (rev 115661)
+++ trunk/Source/WTF/ChangeLog 2012-04-30 21:02:39 UTC (rev 115662)
@@ -1,3 +1,14 @@
+2012-04-30 Anders Carlsson <[email protected]>
+
+ WTF::bind should work with blocks
+ https://bugs.webkit.org/show_bug.cgi?id=85227
+
+ Reviewed by Sam Weinig.
+
+ Add a block type FunctionWrapper specialization.
+
+ * wtf/Functional.h:
+
2012-04-28 Emil A Eklund <[email protected]>
Add ENABLE_SUBPIXEL_LAYOUT controlling FractionalLayoutUnit denominator
Modified: trunk/Source/WTF/wtf/Functional.h (115661 => 115662)
--- trunk/Source/WTF/wtf/Functional.h 2012-04-30 20:27:35 UTC (rev 115661)
+++ trunk/Source/WTF/wtf/Functional.h 2012-04-30 21:02:39 UTC (rev 115662)
@@ -32,6 +32,7 @@
#include <wtf/ThreadSafeRefCounted.h>
#if PLATFORM(MAC) && COMPILER_SUPPORTS(BLOCKS)
+#include <Block.h>
#include <objc/objc-runtime.h>
#endif
@@ -276,6 +277,38 @@
R (C::*m_function)(P1, P2, P3, P4, P5);
};
+#if PLATFORM(MAC) && COMPILER_SUPPORTS(BLOCKS)
+template<typename R>
+class FunctionWrapper<R (^)()> {
+public:
+ typedef R ResultType;
+ static const bool shouldRefFirstParameter = false;
+
+ explicit FunctionWrapper(R (^block)())
+ : m_block(Block_copy(block))
+ {
+ }
+
+ FunctionWrapper(const FunctionWrapper& other)
+ : m_block(Block_copy(other.m_block))
+ {
+ }
+
+ ~FunctionWrapper()
+ {
+ Block_release(m_block);
+ }
+
+ R operator()()
+ {
+ return m_block();
+ }
+
+private:
+ R (^m_block)();
+};
+#endif
+
template<typename T, bool shouldRefAndDeref> struct RefAndDeref {
static void ref(T) { }
static void deref(T) { }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes