[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Blocks
From: |
David Chisnall |
Subject: |
Blocks |
Date: |
Sun, 27 Dec 2009 15:37:21 +0000 |
Hi Everyone,
I've just added a couple of macros to GNUstep that let us use blocks
(but not create) without requiring the compiler to support them. This
means that we can implement any of the 10.6 methods that take blocks
as arguments, without breaking GCC compatibility.
Blocks are basically structures with one field pointing to a function
with a hidden first argument (sound familiar?) that is used to pass
the block in. If you use the DECLARE_BLOCK_TYPE macro then it will
define a block type if one is supported by your compiler. If not,
then it will define a structure with the same layout as a block. The
CALL_BLOCK macro either calls the function in the structure, or lets
the compiler call the block.
To show how to use these, I've implemented NSArray's -
enumerateObjectsUsingBlock: method from 10.6.
Let me know if you've got any questions,
David
P.S. Creating blocks requires clang and a blocks runtime, such as the
one in libobjc2.
-- Sent from my Difference Engine
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Blocks,
David Chisnall <=