@@ -13,17 +13,17 @@ * file. */ #import "OFValue.h" #import "OFBytesValue.h" -#import "OFDimensionValue.h" #import "OFMethodSignature.h" #import "OFNonretainedObjectValue.h" #import "OFPointValue.h" #import "OFPointerValue.h" #import "OFRangeValue.h" -#import "OFRectangleValue.h" +#import "OFRectValue.h" +#import "OFSizeValue.h" #import "OFString.h" #import "OFOutOfMemoryException.h" @implementation OFValue @@ -51,30 +51,28 @@ { return [[[OFNonretainedObjectValue alloc] initWithNonretainedObject: object] autorelease]; } -+ (instancetype)valueWithRange: (of_range_t)range ++ (instancetype)valueWithRange: (OFRange)range { return [[[OFRangeValue alloc] initWithRange: range] autorelease]; } -+ (instancetype)valueWithPoint: (of_point_t)point ++ (instancetype)valueWithPoint: (OFPoint)point { return [[[OFPointValue alloc] initWithPoint: point] autorelease]; } -+ (instancetype)valueWithDimension: (of_dimension_t)dimension ++ (instancetype)valueWithSize: (OFSize)size { - return [[[OFDimensionValue alloc] - initWithDimension: dimension] autorelease]; + return [[[OFSizeValue alloc] initWithSize: size] autorelease]; } -+ (instancetype)valueWithRectangle: (of_rectangle_t)rectangle ++ (instancetype)valueWithRect: (OFRect)rect { - return [[[OFRectangleValue alloc] - initWithRectangle: rectangle] autorelease]; + return [[[OFRectValue alloc] initWithRect: rect] autorelease]; } - (instancetype)initWithBytes: (const void *)bytes objCType: (const char *)objCType { @@ -97,50 +95,50 @@ objCType = self.objCType; if (strcmp([object objCType], objCType) != 0) return false; - size = of_sizeof_type_encoding(objCType); + size = OFSizeOfTypeEncoding(objCType); - value = of_alloc(1, size); + value = OFAllocMemory(1, size); @try { - otherValue = of_alloc(1, size); + otherValue = OFAllocMemory(1, size); } @catch (id e) { - free(value); + OFFreeMemory(value); @throw e; } @try { [self getValue: value size: size]; [object getValue: otherValue size: size]; ret = (memcmp(value, otherValue, size) == 0); } @finally { - free(value); - free(otherValue); + OFFreeMemory(value); + OFFreeMemory(otherValue); } return ret; } - (unsigned long)hash { - size_t size = of_sizeof_type_encoding(self.objCType); + size_t size = OFSizeOfTypeEncoding(self.objCType); unsigned char *value; - uint32_t hash; + unsigned long hash; - value = of_alloc(1, size); + value = OFAllocMemory(1, size); @try { [self getValue: value size: size]; - OF_HASH_INIT(hash); + OFHashInit(&hash); for (size_t i = 0; i < size; i++) - OF_HASH_ADD(hash, value[i]); + OFHashAdd(&hash, value[i]); - OF_HASH_FINALIZE(hash); + OFHashFinalize(&hash); } @finally { - free(value); + OFFreeMemory(value); } return hash; } @@ -171,46 +169,46 @@ id ret; [self getValue: &ret size: sizeof(ret)]; return ret; } -- (of_range_t)rangeValue +- (OFRange)rangeValue +{ + OFRange ret; + [self getValue: &ret size: sizeof(ret)]; + return ret; +} + +- (OFPoint)pointValue { - of_range_t ret; + OFPoint ret; [self getValue: &ret size: sizeof(ret)]; return ret; } -- (of_point_t)pointValue +- (OFSize)sizeValue { - of_point_t ret; + OFSize ret; [self getValue: &ret size: sizeof(ret)]; return ret; } -- (of_dimension_t)dimensionValue -{ - of_dimension_t ret; - [self getValue: &ret size: sizeof(ret)]; - return ret; -} - -- (of_rectangle_t)rectangleValue -{ - of_rectangle_t ret; +- (OFRect)rectValue +{ + OFRect ret; [self getValue: &ret size: sizeof(ret)]; return ret; } - (OFString *)description { OFMutableString *ret = [OFMutableString stringWithString: @" 0) @@ -217,14 +215,14 @@ [ret appendString: @" "]; [ret appendFormat: @"%02x", value[i]]; } } @finally { - free(value); + OFFreeMemory(value); } [ret appendString: @">"]; [ret makeImmutable]; return ret; } @end