Attempt to fix block definitions for blocks without arguments in GCC

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35003 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
thebeing 2012-03-27 09:30:12 +00:00
parent d7944d62d3
commit 9963a2e83a
3 changed files with 22 additions and 2 deletions

View file

@ -1,3 +1,9 @@
2012-03-26 Niels Grewe <niels.grewe@halbordnung.de>
* Headers/Foundation/NSOperation.h
* Headers/GNUstepBase/GSBlocks.h:
Fix definitions of blocks without arguments for GCC.
2012-03-27 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSXMLElement.m,

View file

@ -151,7 +151,7 @@ typedef NSInteger NSOperationQueuePriority;
- (void) setThreadPriority: (double)prio;
DEFINE_BLOCK_TYPE(GSOperationCompletionBlock, void, void);
DEFINE_BLOCK_TYPE_NO_ARGS(GSOperationCompletionBlock, void);
/**
* Sets the block that will be executed when the operation has finished.

View file

@ -30,12 +30,17 @@
#if __has_feature(blocks)
#define BLOCK_SCOPE __block
/**
* Defines a block type. Will work whether or not the compiler natively
* supports blocks.
*/
#define DEFINE_BLOCK_TYPE(name, retTy, argTys, ...) \
typedef retTy(^name)(argTys, ## __VA_ARGS__)
#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \
typedef retTy(^name)()
/**
* Calls a block. Works irrespective of whether the compiler supports blocks.
*/
@ -73,8 +78,17 @@ typedef retTy(^name)(argTys, ## __VA_ARGS__)
retTy (*invoke)(void*, argTys, args);\
} *name
#define CALL_BLOCK(block, args...) block->invoke(block, args)
#define DEFINE_BLOCK_TYPE_NO_ARGS(name, retTy) \
typedef struct {\
void *isa;\
int flags;\
int reserved;\
retTy (*invoke)(void*);\
} *name
#define CALL_BLOCK(block, args...) block->invoke(block, args)
#define BLOCK_SCOPE
#endif /* GCC_VERSION >= 3000 */
#endif /* __has_feature(blocks) */