ObjFW
 All Classes Functions Variables
OFBlock.h
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012
3  * Jonathan Schleifer <js@webkeks.org>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 
19 typedef struct of_block_literal_t {
20  Class isa;
21  int flags;
22  int reserved;
23  void (*invoke)(void *, ...);
24  struct of_block_descriptor_t {
25  unsigned long reserved;
26  unsigned long size;
27  void (*copy_helper)(void *dest, void *src);
28  void (*dispose_helper)(void *src);
29  const char *signature;
30  } *descriptor;
31 } of_block_literal_t;
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 extern void* _Block_copy(const void*);
37 extern void _Block_release(const void*);
38 #ifdef __cplusplus
39 }
40 #endif
41 
42 #ifndef Block_copy
43 # define Block_copy(x) ((__typeof__(x))_Block_copy((const void*)(x)))
44 #endif
45 #ifndef Block_release
46 # define Block_release(x) _Block_release((const void*)(x))
47 #endif
48 
52 @interface OFBlock: OFObject
53 @end
54 
55 @interface OFStackBlock: OFBlock
56 @end
57 
58 @interface OFGlobalBlock: OFBlock
59 @end
60 
61 @interface OFMallocBlock: OFBlock
62 @end