Index: src/OFBlock.h ================================================================== --- src/OFBlock.h +++ src/OFBlock.h @@ -7,17 +7,11 @@ * This file is part of ObjFW. It may be distributed under the terms of the * Q Public License 1.0, which can be found in the file LICENSE included in * the packaging of this file. */ -#import "objfw-defs.h" - -#ifdef OF_OBJFW_RUNTIME -# import -#else -# import -#endif +#import "OFObject.h" /// \cond internal typedef struct __of_block_literal { Class isa; int flags; @@ -67,18 +61,11 @@ #ifndef Block_release # define Block_release(x) _Block_release((const void*)(x)) #endif /// \cond internal -@interface OFBlock -{ - Class isa; -} - -+ (Class)class; -- copy; -- (void)release; +@interface OFBlock: OFObject @end @interface OFStackBlock: OFBlock @end Index: src/OFBlock.m ================================================================== --- src/OFBlock.m +++ src/OFBlock.m @@ -230,28 +230,94 @@ } #endif /// \cond internal @implementation OFBlock -+ (void)initialize ++ alloc +{ + @throw [OFNotImplementedException newWithClass: self + selector: _cmd]; +} + +- init +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +} + +- (void)addMemoryToPool: (void*)ptr +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +} + +- (void*)allocMemoryWithSize: (size_t)size +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +} + +- (void*)allocMemoryForNItems: (size_t)nitems + withSize: (size_t)size +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +} + +- (void*)resizeMemory: (void*)ptr + toSize: (size_t)size +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +} + +- (void*)resizeMemory: (void*)ptr + toNItems: (size_t)nitems + withSize: (size_t)size +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +} + +- (void)freeMemory: (void*)ptr { + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; } -+ (Class)class +- retain { + if (isa == (Class)&_NSConcreteMallocBlock) + return Block_copy(self); + return self; } - copy { return Block_copy(self); } + +- (size_t)retainCount +{ + if (isa == (Class)&_NSConcreteMallocBlock) + return ((of_block_literal_t*)self)->reserved; + + return SIZE_MAX; +} - (void)release { Block_release(self); } + +- (void)dealloc +{ + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; + [super dealloc]; /* Get rid of a stupid warning */ +} @end #if !defined(OF_GNU_RUNTIME) && !defined(OF_OBJFW_RUNTIME) @implementation OFStackBlock @end