// When Blocks or Block_byrefs hold objects their destroy helper routines call this entry point // to help dispose of the contents // Used initially only for __attribute__((NSObject)) marked pointers. void _Block_object_dispose(const void *object, const int flags) { //printf("_Block_object_dispose(%p, %x)\n", object, flags); if (flags & BLOCK_FIELD_IS_BYREF) { // get rid of the __block data structure held in a Block _Block_byref_release(object); } else if ((flags & (BLOCK_FIELD_IS_BLOCK|BLOCK_BYREF_CALLER)) == BLOCK_FIELD_IS_BLOCK) { // get rid of a referenced Block held by this Block // (ignore __block Block variables, compiler doesn't need to call us) _Block_destroy(object); } else if ((flags & (BLOCK_FIELD_IS_WEAK|BLOCK_FIELD_IS_BLOCK|BLOCK_BYREF_CALLER)) == BLOCK_FIELD_IS_OBJECT) { // get rid of a referenced object held by this Block // (ignore __block object variables, compiler doesn't need to call us) _Block_release_object(object); } }
// When Blocks or Block_byrefs hold objects their destroy helper routines call this entry point // to help dispose of the contents // Used initially only for __attribute__((NSObject)) marked pointers. void _Block_object_dispose(const void *object, const int flags) { switch (osx_assumes(flags & BLOCK_ALL_COPY_DISPOSE_FLAGS)) { case BLOCK_FIELD_IS_BYREF | BLOCK_FIELD_IS_WEAK: case BLOCK_FIELD_IS_BYREF: // get rid of the __block data structure held in a Block _Block_byref_release(object); break; case BLOCK_FIELD_IS_BLOCK: _Block_destroy(object); break; case BLOCK_FIELD_IS_OBJECT: _Block_release_object(object); break; case BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_OBJECT: case BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_BLOCK: case BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_OBJECT | BLOCK_FIELD_IS_WEAK: case BLOCK_BYREF_CALLER | BLOCK_FIELD_IS_BLOCK | BLOCK_FIELD_IS_WEAK: break; default: break; } }