Differences From Artifact [d9ed74f314]:
- File
src/OFBlock.m
— part of check-in
[19a677b596]
at
2012-06-11 20:50:09
on branch runtime
— Merge branch 'master' into runtime
* master: (6 commits)
Improve -[OFNumber description].
... (user: js, size: 11689) [annotate] [blame] [check-ins using] [more...]
To Artifact [badbea4cd4]:
- File src/OFBlock.m — part of check-in [8892ae9fcc] at 2012-07-12 01:28:46 on branch trunk — Don't access isa directly. (user: js, size: 11921) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
172 173 174 175 176 177 178 | #endif void* _Block_copy(const void *block_) { of_block_literal_t *block = (of_block_literal_t*)block_; | | | | | | | | 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 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 | #endif void* _Block_copy(const void *block_) { of_block_literal_t *block = (of_block_literal_t*)block_; if (object_getClass((id)block) == (Class)&_NSConcreteStackBlock) { of_block_literal_t *copy; if ((copy = malloc(block->descriptor->size)) == NULL) { object_setClass((id)&alloc_failed_exception, [OFAllocFailedException class]); @throw (OFAllocFailedException*)&alloc_failed_exception; } memcpy(copy, block, block->descriptor->size); object_setClass((id)copy, (Class)&_NSConcreteMallocBlock); copy->flags++; if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE) block->descriptor->copy_helper(copy, block); return copy; } if (object_getClass((id)block) == (Class)&_NSConcreteMallocBlock) { #if defined(OF_ATOMIC_OPS) of_atomic_inc_int(&block->flags); #else unsigned hash = SPINLOCK_HASH(block); assert(of_spinlock_lock(&spinlocks[hash])); block->flags++; assert(of_spinlock_unlock(&spinlocks[hash])); #endif } return block; } void _Block_release(const void *block_) { of_block_literal_t *block = (of_block_literal_t*)block_; if (object_getClass((id)block) != (Class)&_NSConcreteMallocBlock) return; #ifdef OF_ATOMIC_OPS if ((of_atomic_dec_int(&block->flags) & OF_BLOCK_REFCOUNT_MASK) == 0) { if (block->flags & OF_BLOCK_HAS_COPY_DISPOSE) block->descriptor->dispose_helper(block); |
︙ | ︙ | |||
264 265 266 267 268 269 270 | break; case OF_BLOCK_FIELD_IS_BYREF:; of_block_byref_t *src = (of_block_byref_t*)src_; of_block_byref_t **dst = (of_block_byref_t**)dst_; if ((src->flags & OF_BLOCK_REFCOUNT_MASK) == 0) { if ((*dst = malloc(src->size)) == NULL) { | | | | 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 | break; case OF_BLOCK_FIELD_IS_BYREF:; of_block_byref_t *src = (of_block_byref_t*)src_; of_block_byref_t **dst = (of_block_byref_t**)dst_; if ((src->flags & OF_BLOCK_REFCOUNT_MASK) == 0) { if ((*dst = malloc(src->size)) == NULL) { object_setClass((id)&alloc_failed_exception, [OFAllocFailedException class]); @throw (OFAllocFailedException*) &alloc_failed_exception; } if (src->forwarding == src) (*dst)->forwarding = *dst; |
︙ | ︙ | |||
372 373 374 375 376 377 378 | { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } - init { | | | | | | | | | | | | | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 | { @throw [OFNotImplementedException exceptionWithClass: self selector: _cmd]; } - init { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (void*)allocMemoryWithSize: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (void*)allocMemoryWithSize: (size_t)size count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (void*)resizeMemory: (void*)ptr size: (size_t)size { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (void*)resizeMemory: (void*)ptr size: (size_t)size count: (size_t)count { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - (void)freeMemory: (void*)ptr { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; } - retain { if (object_getClass(self) == (Class)&_NSConcreteMallocBlock) return Block_copy(self); return self; } - copy { return Block_copy(self); } - autorelease { if (object_getClass(self) == (Class)&_NSConcreteMallocBlock) return [super autorelease]; return self; } - (unsigned int)retainCount { if (object_getClass(self) == (Class)&_NSConcreteMallocBlock) return ((of_block_literal_t*)self)->flags & OF_BLOCK_REFCOUNT_MASK; return OF_RETAIN_COUNT_MAX; } - (void)release { if (object_getClass(self) == (Class)&_NSConcreteMallocBlock) Block_release(self); } - (void)dealloc { @throw [OFNotImplementedException exceptionWithClass: [self class] selector: _cmd]; [super dealloc]; /* Get rid of a stupid warning */ } @end #if defined(OF_APPLE_RUNTIME) && defined(__OBJC2__) @implementation OFStackBlock |
︙ | ︙ |