Overview
Comment: | Add some #ifdefs to make OFBlocks.m compile with the Apple runtime. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
0c55736c5dfd4080b692f065964a6e0b |
User & Date: | js on 2010-09-08 09:58:21 |
Other Links: | manifest | tags |
Context
2010-09-08
| ||
10:02 | Move -[replaceObjectsUsingBlock:] test to the right place. check-in: ea3c419495 user: js tags: trunk | |
09:58 | Add some #ifdefs to make OFBlocks.m compile with the Apple runtime. check-in: 0c55736c5d user: js tags: trunk | |
2010-09-07
| ||
09:45 | More compatibility with Apple's Blocks runtime. check-in: 3e8d3a2668 user: js tags: trunk | |
Changes
Modified src/OFBlock.h from [383899c068] to [8a28a2dbc7].
︙ | ︙ | |||
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | enum { OF_BLOCK_FIELD_IS_OBJECT = 3, OF_BLOCK_FIELD_IS_BLOCK = 7, OF_BLOCK_FIELD_IS_BYREF = 8, OF_BLOCK_FIELD_IS_WEAK = 16, OF_BLOCK_BYREF_CALLER = 128, }; @interface OFBlock { Class isa; } - copy; - (void)release; - autorelease; @end | > > > > > > > > > > | | | < | | | | | 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | enum { OF_BLOCK_FIELD_IS_OBJECT = 3, OF_BLOCK_FIELD_IS_BLOCK = 7, OF_BLOCK_FIELD_IS_BYREF = 8, OF_BLOCK_FIELD_IS_WEAK = 16, OF_BLOCK_BYREF_CALLER = 128, }; extern void* _Block_copy(const void*); extern void _Block_release(const void*); #ifndef Block_copy # define Block_copy(x) ((__typeof__(x))_Block_copy((const void*)(x))) #endif #ifndef Block_release # define Block_release(x) _Block_release((const void*)(x)) #endif @interface OFBlock { Class isa; } - copy; - (void)release; - autorelease; @end @interface OFStackBlock: OFBlock @end @interface OFGlobalBlock: OFBlock @end @interface OFMallocBlock: OFBlock @end |
Modified src/OFBlock.m from [0cb72d5e21] to [8b59b6b4ef].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <stdio.h> #include <stdlib.h> #include <string.h> #import "OFBlock.h" #import "OFAutoreleasePool.h" struct objc_abi_class { struct objc_abi_class *metaclass; const char *superclass, *name; unsigned long version, info, instance_size; void *ivars, *methodlist, *dtable, *subclass_list, *sibling_class; void *protocols, *gc_object_type; long abi_version; void *ivar_offsets, *properties; }; enum objc_abi_class_info { OBJC_CLASS_INFO_CLASS = 0x01, OBJC_CLASS_INFO_METACLASS = 0x02 }; extern void __objc_exec_class(void*); /* Begin of ObjC module */ static struct objc_abi_class _NSConcreteStackBlock_metaclass = { | > | | | | | | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | #include <stdio.h> #include <stdlib.h> #include <string.h> #import "OFBlock.h" #import "OFAutoreleasePool.h" #if defined(OF_GNU_RUNTIME) || defined(OF_OBJFW_RUNTIME) struct objc_abi_class { struct objc_abi_class *metaclass; const char *superclass, *name; unsigned long version, info, instance_size; void *ivars, *methodlist, *dtable, *subclass_list, *sibling_class; void *protocols, *gc_object_type; long abi_version; void *ivar_offsets, *properties; }; enum objc_abi_class_info { OBJC_CLASS_INFO_CLASS = 0x01, OBJC_CLASS_INFO_METACLASS = 0x02 }; extern void __objc_exec_class(void*); /* Begin of ObjC module */ static struct objc_abi_class _NSConcreteStackBlock_metaclass = { &_NSConcreteStackBlock_metaclass, "OFBlock", "OFStackBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(struct objc_class), NULL, NULL }; struct objc_abi_class _NSConcreteStackBlock = { &_NSConcreteStackBlock_metaclass, "OFBlock", "OFStackBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t), NULL, NULL }; static struct objc_abi_class _NSConcreteGlobalBlock_metaclass = { &_NSConcreteGlobalBlock_metaclass, "OFBlock", "OFGlobalBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(struct objc_class), NULL, NULL }; struct objc_abi_class _NSConcreteGlobalBlock = { &_NSConcreteGlobalBlock_metaclass, "OFBlock", "OFGlobalBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t), NULL, NULL }; static struct objc_abi_class _NSConcreteMallocBlock_metaclass = { &_NSConcreteMallocBlock_metaclass, "OFBlock", "OFMallocBlock", 8, OBJC_CLASS_INFO_METACLASS, sizeof(struct objc_class), NULL, NULL }; struct objc_abi_class _NSConcreteMallocBlock = { &_NSConcreteMallocBlock_metaclass, "OFBlock", "OFMallocBlock", 8, OBJC_CLASS_INFO_CLASS, sizeof(of_block_literal_t), NULL, NULL }; static struct { unsigned int unknown; struct objc_abi_selector *sel_refs; uint16_t cls_def_cnt, cat_def_cnt; |
︙ | ︙ | |||
83 84 85 86 87 88 89 | } module = { 8, sizeof(module), NULL, &symtab }; static void __attribute__((constructor)) __objc_gnu_init() { __objc_exec_class(&module); } | | > > > > > > | > | | | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | } module = { 8, sizeof(module), NULL, &symtab }; static void __attribute__((constructor)) __objc_gnu_init() { __objc_exec_class(&module); } /* End of ObjC module */ #else void *_NSConcreteStackBlock; void *_NSConcreteGlobalBlock; void *_NSConcreteMallocBlock; #endif void* _Block_copy(const void *block_) { of_block_literal_t *block = (of_block_literal_t*)block_; if (block->isa == (Class)&_NSConcreteStackBlock) { of_block_literal_t *copy; if ((copy = malloc(block->descriptor->size)) == NULL) { fputs("Not enough memory to copy block!\n", stderr); exit(1); } |
︙ | ︙ | |||
113 114 115 116 117 118 119 | if (block->isa == (Class)&_NSConcreteMallocBlock) block->reserved++; return block; } void | > > | | | | | | | | | | | | | | | | | | | | | | | | | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | if (block->isa == (Class)&_NSConcreteMallocBlock) block->reserved++; return block; } void _Block_release(const void *block_) { of_block_literal_t *block = (of_block_literal_t*)block_; if (block->isa != (Class)&_NSConcreteMallocBlock) return; if (--block->reserved == 0) { if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE) block->descriptor->dispose_helper(block); free(block); } } void _Block_object_assign(void *dst_, void *src_, int flags) { flags &= OF_BLOCK_FIELD_IS_BLOCK | OF_BLOCK_FIELD_IS_OBJECT | OF_BLOCK_FIELD_IS_BYREF; switch (flags) { case OF_BLOCK_FIELD_IS_BLOCK: *(of_block_literal_t**)dst_ = _Block_copy(src_); break; case OF_BLOCK_FIELD_IS_OBJECT: *(id*)dst_ = [(id)src_ retain]; break; case OF_BLOCK_FIELD_IS_BYREF:; of_block_byref_t *src = src_; of_block_byref_t **dst = dst_; if ((src->flags & ~OF_BLOCK_HAS_COPY_DISPOSE) == 0) { if ((*dst = malloc(src->size)) == NULL) { fputs("Not enough memory for block " "variables!\n", stderr); exit(1); } if (src->forwarding == src) src->forwarding = *dst; memcpy(*dst, src, src->size); if (src->size >= sizeof(of_block_byref_t)) src->byref_keep(*dst, src); } else *dst = src; (*dst)->flags++; break; } } void _Block_object_dispose(void *obj_, int flags) { flags &= OF_BLOCK_FIELD_IS_BLOCK | OF_BLOCK_FIELD_IS_OBJECT | OF_BLOCK_FIELD_IS_BYREF; switch (flags) { case OF_BLOCK_FIELD_IS_BLOCK: _Block_release(obj_); break; case OF_BLOCK_FIELD_IS_OBJECT: [(id)obj_ release]; break; case OF_BLOCK_FIELD_IS_BYREF:; of_block_byref_t *obj = obj_; if ((--obj->flags & ~OF_BLOCK_HAS_COPY_DISPOSE) == 0) { if (obj->size >= sizeof(of_block_byref_t)) obj->byref_dispose(obj); free(obj); } break; } } static Class autoreleasepool = Nil; |
︙ | ︙ |