Index: src/OFASN1BitString.m ================================================================== --- src/OFASN1BitString.m +++ src/OFASN1BitString.m @@ -41,11 +41,11 @@ bitStringLength: (size_t)bitStringLength { self = [super init]; @try { - if ([bitStringValue count] * [bitStringValue itemSize] != + if (bitStringValue.count * bitStringValue.itemSize != bitStringLength / 8) @throw [OFInvalidFormatException exception]; _bitStringValue = [bitStringValue copy]; _bitStringLength = bitStringLength; @@ -66,17 +66,17 @@ OFData *bitStringValue; size_t bitStringLength; @try { unsigned char lastByteBits; - size_t count = [DEREncodedContents count]; + size_t count = DEREncodedContents.count; if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_BIT_STRING || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1 || count == 0) + if (DEREncodedContents.itemSize != 1 || count == 0) @throw [OFInvalidFormatException exception]; lastByteBits = *(unsigned char *)[DEREncodedContents itemAtIndex: 0]; @@ -132,14 +132,14 @@ return true; } - (uint32_t)hash { - return [_bitStringValue hash] + (uint32_t)_bitStringLength; + return _bitStringValue.hash + (uint32_t)_bitStringLength; } - (OFString *)description { return [OFString stringWithFormat: @"", _bitStringValue, _bitStringLength]; } @end Index: src/OFASN1Boolean.m ================================================================== --- src/OFASN1Boolean.m +++ src/OFASN1Boolean.m @@ -51,12 +51,12 @@ @try { if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_BOOLEAN || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1 || - [DEREncodedContents count] != 1) + if (DEREncodedContents.itemSize != 1 || + DEREncodedContents.count != 1) @throw [OFInvalidFormatException exception]; value = *(unsigned char *)[DEREncodedContents itemAtIndex: 0]; if (value != 0 && value != 0xFF) Index: src/OFASN1Enumerated.m ================================================================== --- src/OFASN1Enumerated.m +++ src/OFASN1Enumerated.m @@ -53,15 +53,15 @@ @try { if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_ENUMERATED || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; integerValue = of_asn1_der_integer_parse( - [DEREncodedContents items], [DEREncodedContents count]); + DEREncodedContents.items, DEREncodedContents.count); } @catch (id e) { [self release]; @throw e; } Index: src/OFASN1IA5String.m ================================================================== --- src/OFASN1IA5String.m +++ src/OFASN1IA5String.m @@ -56,17 +56,17 @@ @try { if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_IA5_STRING || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; IA5StringValue = [OFString - stringWithCString: [DEREncodedContents items] + stringWithCString: DEREncodedContents.items encoding: OF_STRING_ENCODING_ASCII - length: [DEREncodedContents count]]; + length: DEREncodedContents.count]; } @catch (id e) { [self release]; @throw e; } @@ -89,11 +89,11 @@ [super dealloc]; } - (OFString *)stringValue { - return [self IA5StringValue]; + return self.IA5StringValue; } - (bool)isEqual: (id)object { OFASN1IA5String *IA5String; @@ -109,14 +109,14 @@ return true; } - (uint32_t)hash { - return [_IA5StringValue hash]; + return _IA5StringValue.hash; } - (OFString *)description { return [OFString stringWithFormat: @"", _IA5StringValue]; } @end Index: src/OFASN1Integer.m ================================================================== --- src/OFASN1Integer.m +++ src/OFASN1Integer.m @@ -75,15 +75,15 @@ @try { if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_INTEGER || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; integerValue = of_asn1_der_integer_parse( - [DEREncodedContents items], [DEREncodedContents count]); + DEREncodedContents.items, DEREncodedContents.count); } @catch (id e) { [self release]; @throw e; } Index: src/OFASN1NumericString.m ================================================================== --- src/OFASN1NumericString.m +++ src/OFASN1NumericString.m @@ -36,12 +36,12 @@ { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); - const char *cString = [stringValue UTF8String]; - size_t length = [stringValue UTF8StringLength]; + const char *cString = stringValue.UTF8String; + size_t length = stringValue.UTF8StringLength; for (size_t i = 0; i < length; i++) if (!of_ascii_isdigit(cString[i]) && cString[i] != ' ') @throw [OFInvalidEncodingException exception]; @@ -68,17 +68,17 @@ if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_NUMERIC_STRING || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; numericStringValue = [OFString - stringWithCString: [DEREncodedContents items] + stringWithCString: DEREncodedContents.items encoding: OF_STRING_ENCODING_ASCII - length: [DEREncodedContents count]]; + length: DEREncodedContents.count]; } @catch (id e) { [self release]; @throw e; } @@ -101,11 +101,11 @@ [super dealloc]; } - (OFString *)stringValue { - return [self numericStringValue]; + return self.numericStringValue; } - (bool)isEqual: (id)object { OFASN1NumericString *numericString; @@ -121,14 +121,14 @@ return true; } - (uint32_t)hash { - return [_numericStringValue hash]; + return _numericStringValue.hash; } - (OFString *)description { return [OFString stringWithFormat: @"", _numericStringValue]; } @end Index: src/OFASN1ObjectIdentifier.m ================================================================== --- src/OFASN1ObjectIdentifier.m +++ src/OFASN1ObjectIdentifier.m @@ -41,11 +41,11 @@ (OFArray OF_GENERIC(OFNumber *) *)subidentifiers { self = [super init]; @try { - if ([subidentifiers count] < 1) + if (subidentifiers.count < 1) @throw [OFInvalidFormatException exception]; switch ([[subidentifiers objectAtIndex: 0] intMaxValue]) { case 0: case 1: @@ -71,21 +71,21 @@ { void *pool = objc_autoreleasePoolPush(); OFMutableArray OF_GENERIC(OFNumber *) *subidentifiers; @try { - const unsigned char *items = [DEREncodedContents items]; - size_t count = [DEREncodedContents count]; + const unsigned char *items = DEREncodedContents.items; + size_t count = DEREncodedContents.count; uintmax_t value = 0; uint_fast8_t bits = 0; if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1 || count == 0) + if (DEREncodedContents.itemSize != 1 || count == 0) @throw [OFInvalidArgumentException exception]; subidentifiers = [OFMutableArray array]; for (size_t i = 0; i < count; i++) { @@ -99,11 +99,11 @@ @throw [OFOutOfRangeException exception]; if (items[i] & 0x80) continue; - if ([subidentifiers count] == 0) { + if (subidentifiers.count == 0) { if (value < 40) [subidentifiers addObject: [OFNumber numberWithUIntMax: 0]]; else if (value < 80) { [subidentifiers addObject: @@ -166,15 +166,15 @@ return true; } - (uint32_t)hash { - return [_subidentifiers hash]; + return _subidentifiers.hash; } - (OFString *)description { return [OFString stringWithFormat: @"", [_subidentifiers componentsJoinedByString: @"."]]; } @end Index: src/OFASN1OctetString.m ================================================================== --- src/OFASN1OctetString.m +++ src/OFASN1OctetString.m @@ -55,11 +55,11 @@ if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_OCTET_STRING || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } @@ -94,14 +94,14 @@ return true; } - (uint32_t)hash { - return [_octetStringValue hash]; + return _octetStringValue.hash; } - (OFString *)description { return [OFString stringWithFormat: @"", _octetStringValue]; } @end Index: src/OFASN1PrintableString.m ================================================================== --- src/OFASN1PrintableString.m +++ src/OFASN1PrintableString.m @@ -36,12 +36,12 @@ { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); - const char *cString = [stringValue UTF8String]; - size_t length = [stringValue UTF8StringLength]; + const char *cString = stringValue.UTF8String; + size_t length = stringValue.UTF8StringLength; for (size_t i = 0; i < length; i++) { if (of_ascii_isalnum(cString[i])) continue; @@ -87,17 +87,17 @@ if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_PRINTABLE_STRING || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; printableStringValue = [OFString - stringWithCString: [DEREncodedContents items] + stringWithCString: DEREncodedContents.items encoding: OF_STRING_ENCODING_ASCII - length: [DEREncodedContents count]]; + length: DEREncodedContents.count]; } @catch (id e) { [self release]; @throw e; } @@ -120,11 +120,11 @@ [super dealloc]; } - (OFString *)stringValue { - return [self printableStringValue]; + return self.printableStringValue; } - (bool)isEqual: (id)object { OFASN1PrintableString *printableString; @@ -141,14 +141,14 @@ return true; } - (uint32_t)hash { - return [_printableStringValue hash]; + return _printableStringValue.hash; } - (OFString *)description { return [OFString stringWithFormat: @"", _printableStringValue]; } @end Index: src/OFASN1UTF8String.m ================================================================== --- src/OFASN1UTF8String.m +++ src/OFASN1UTF8String.m @@ -56,16 +56,16 @@ @try { if (tagClass != OF_ASN1_TAG_CLASS_UNIVERSAL || tagNumber != OF_ASN1_TAG_NUMBER_UTF8_STRING || constructed) @throw [OFInvalidArgumentException exception]; - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidArgumentException exception]; UTF8StringValue = [OFString - stringWithUTF8String: [DEREncodedContents items] - length: [DEREncodedContents count]]; + stringWithUTF8String: DEREncodedContents.items + length: DEREncodedContents.count]; } @catch (id e) { [self release]; @throw e; } @@ -88,11 +88,11 @@ [super dealloc]; } - (OFString *)stringValue { - return [self UTF8StringValue]; + return self.UTF8StringValue; } - (bool)isEqual: (id)object { OFASN1UTF8String *UTF8String; @@ -108,14 +108,14 @@ return true; } - (uint32_t)hash { - return [_UTF8StringValue hash]; + return _UTF8StringValue.hash; } - (OFString *)description { return [OFString stringWithFormat: @"", _UTF8StringValue]; } @end Index: src/OFASN1Value.m ================================================================== --- src/OFASN1Value.m +++ src/OFASN1Value.m @@ -46,11 +46,11 @@ DEREncodedContents: (OFData *)DEREncodedContents { self = [super init]; @try { - if ([DEREncodedContents itemSize] != 1) + if (DEREncodedContents.itemSize != 1) @throw [OFInvalidFormatException exception]; _tagClass = tagClass; _tagNumber = tagNumber; _constructed = constructed; @@ -103,11 +103,11 @@ OF_HASH_INIT(hash); OF_HASH_ADD(hash, _tagClass & 0xFF); OF_HASH_ADD(hash, _tagNumber & 0xFF); OF_HASH_ADD(hash, _constructed); - OF_HASH_ADD_HASH(hash, [_DEREncodedContents hash]); + OF_HASH_ADD_HASH(hash, _DEREncodedContents.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -120,8 +120,8 @@ @"\tTag number = %x\n" @"\tConstructed = %u\n" @"\tDER-encoded contents = %@\n" @">", _tagClass, _tagNumber, _constructed, - [_DEREncodedContents description]]; + _DEREncodedContents.description]; } @end Index: src/OFApplication.m ================================================================== --- src/OFApplication.m +++ src/OFApplication.m @@ -96,11 +96,11 @@ static OFApplication *app = nil; static void atexitHandler(void) { - id delegate = [app delegate]; + id delegate = app.delegate; if ([delegate respondsToSelector: @selector(applicationWillTerminate)]) [delegate applicationWillTerminate]; [delegate release]; @@ -145,11 +145,11 @@ __wgetmainargs(&wargc, &wargv, &wenvp, _CRT_glob, &si); [app of_setArgumentCount: wargc andWideArgumentValues: wargv]; #endif - [app setDelegate: delegate]; + app.delegate = delegate; [app of_run]; [delegate release]; @@ -169,21 +169,21 @@ return app; } + (OFString *)programName { - return [app programName]; + return app.programName; } + (OFArray *)arguments { - return [app arguments]; + return app.arguments; } + (OFDictionary *)environment { - return [app environment]; + return app.environment; } + (void)terminate { [self terminateWithStatus: EXIT_SUCCESS]; @@ -261,11 +261,11 @@ continue; } key = [tmp substringWithRange: of_range(0, pos)]; value = [tmp substringWithRange: - of_range(pos + 1, [tmp length] - pos - 1)]; + of_range(pos + 1, tmp.length - pos - 1)]; [_environment setObject: value forKey: key]; objc_autoreleasePoolPop(pool); @@ -575,18 +575,18 @@ [runLoop run]; } - (void)terminate { - [[self class] terminate]; + [self.class terminate]; OF_UNREACHABLE } - (void)terminateWithStatus: (int)status { - [[self class] terminateWithStatus: status]; + [self.class terminateWithStatus: status]; OF_UNREACHABLE } #ifdef OF_HAVE_SANDBOX @@ -600,19 +600,19 @@ const char *promises; if (_activeSandbox != nil && sandbox != _activeSandbox) @throw [OFInvalidArgumentException exception]; - unveiledPaths = [sandbox unveiledPaths]; - unveiledPathsCount = [unveiledPaths count]; + unveiledPaths = sandbox.unveiledPaths; + unveiledPathsCount = unveiledPaths.count; for (size_t i = sandbox->_unveiledPathsIndex; i < unveiledPathsCount; i++) { of_sandbox_unveil_path_t unveiledPath = [unveiledPaths objectAtIndex: i]; - OFString *path = [unveiledPath firstObject]; - OFString *permissions = [unveiledPath secondObject]; + OFString *path = unveiledPath.firstObject; + OFString *permissions = unveiledPath.secondObject; if (path == nil || permissions == nil) @throw [OFInvalidArgumentException exception]; unveil([path cStringWithEncoding: encoding], @@ -619,11 +619,11 @@ [permissions cStringWithEncoding: encoding]); } sandbox->_unveiledPathsIndex = unveiledPathsCount; - promises = [[sandbox pledgeString] cStringWithEncoding: encoding]; + promises = [sandbox.pledgeString cStringWithEncoding: encoding]; if (pledge(promises, NULL) != 0) @throw [OFSandboxActivationFailedException exceptionWithSandbox: sandbox errNo: errno]; @@ -642,14 +642,14 @@ const char *promises; if (_activeExecSandbox != nil && sandbox != _activeExecSandbox) @throw [OFInvalidArgumentException exception]; - if ([[sandbox unveiledPaths] count] != 0) + if (sandbox.unveiledPaths.count != 0) @throw [OFInvalidArgumentException exception]; - promises = [[sandbox pledgeString] + promises = [sandbox.pledgeString cStringWithEncoding: [OFLocale encoding]]; if (pledge(NULL, promises) != 0) @throw [OFSandboxActivationFailedException exceptionWithSandbox: sandbox Index: src/OFArray.m ================================================================== --- src/OFArray.m +++ src/OFArray.m @@ -242,13 +242,13 @@ OFObject *container; size_t count; id *buffer; container = [[[OFObject alloc] init] autorelease]; - count = [self count]; + count = self.count; buffer = [container allocMemoryWithSize: sizeof(*buffer) - count: [self count]]; + count: count]; [self getObjects: buffer inRange: of_range(0, count)]; return buffer; @@ -279,19 +279,19 @@ id ret; if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - key = [key substringWithRange: of_range(1, [key length] - 1)]; + key = [key substringWithRange: of_range(1, key.length - 1)]; ret = [[super valueForKey: key] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - ret = [OFMutableArray arrayWithCapacity: [self count]]; + ret = [OFMutableArray arrayWithCapacity: self.count]; for (id object in self) { id value = [object valueForKey: key]; if (value == nil) @@ -309,11 +309,11 @@ forKey: (OFString *)key { if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - key = [key substringWithRange: of_range(1, [key length] - 1)]; + key = [key substringWithRange: of_range(1, key.length - 1)]; [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; @@ -368,19 +368,19 @@ return ([self indexOfObjectIdenticalTo: object] != OF_NOT_FOUND); } - (id)firstObject { - if ([self count] > 0) + if (self.count > 0) return [self objectAtIndex: 0]; return nil; } - (id)lastObject { - size_t count = [self count]; + size_t count = self.count; if (count > 0) return [self objectAtIndex: count - 1]; return nil; @@ -390,11 +390,11 @@ { OFArray *ret; id *buffer; if (range.length > SIZE_MAX - range.location || - range.location + range.length < [self count]) + range.location + range.length < self.count) @throw [OFOutOfRangeException exception]; if (![self isKindOfClass: [OFMutableArray class]]) return [OFArray_subarray arrayWithArray: self range: range]; @@ -445,14 +445,14 @@ OFMutableString *ret; if (separator == nil) @throw [OFInvalidArgumentException exception]; - if ([self count] == 0) + if (self.count == 0) return @""; - if ([self count] == 1) { + if (self.count == 1) { OFString *component = [[self firstObject] performSelector: selector]; if (component == nil) @throw [OFInvalidArgumentException exception]; @@ -469,12 +469,12 @@ [object performSelector: selector]; if (component == nil) @throw [OFInvalidArgumentException exception]; - if ([component length] > 0) { - if ([ret length] > 0) + if (component.length > 0) { + if (ret.length > 0) [ret appendString: separator]; [ret appendString: component]; } objc_autoreleasePoolPop(pool); @@ -518,13 +518,13 @@ if (![object isKindOfClass: [OFArray class]]) return false; otherArray = object; - count = [self count]; + count = self.count; - if (count != [otherArray count]) + if (count != otherArray.count) return false; for (size_t i = 0; i < count; i++) if (![[self objectAtIndex: i] isEqual: [otherArray objectAtIndex: i]]) @@ -550,11 +550,11 @@ - (OFString *)description { void *pool; OFMutableString *ret; - if ([self count] == 0) + if (self.count == 0) return @"()"; pool = objc_autoreleasePoolPush(); ret = [[self componentsJoinedByString: @",\n"] mutableCopy]; @@ -585,14 +585,14 @@ namespace: OF_SERIALIZATION_NS]; else element = [OFXMLElement elementWithName: @"OFArray" namespace: OF_SERIALIZATION_NS]; - for (id object in self) { + for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); - [element addChild: [object XMLElementBySerializing]]; + [element addChild: object.XMLElementBySerializing]; objc_autoreleasePoolPop(pool2); } [element retain]; @@ -617,11 +617,11 @@ - (OFString *)of_JSONRepresentationWithOptions: (int)options depth: (size_t)depth { OFMutableString *JSON = [OFMutableString stringWithString: @"["]; void *pool = objc_autoreleasePoolPush(); - size_t i, count = [self count]; + size_t i, count = self.count; if (options & OF_JSON_REPRESENTATION_PRETTY) { OFMutableString *indentation = [OFMutableString string]; for (i = 0; i < depth; i++) @@ -677,11 +677,11 @@ OFMutableData *data; size_t i, count; void *pool; data = [OFMutableData data]; - count = [self count]; + count = self.count; if (count <= 15) { uint8_t tmp = 0x90 | ((uint8_t)count & 0xF); [data addItem: &tmp]; } else if (count <= UINT16_MAX) { @@ -709,12 +709,12 @@ OFData *child; i++; child = [object messagePackRepresentation]; - [data addItems: [child items] - count: [child count]]; + [data addItems: child.items + count: child.count]; objc_autoreleasePoolPop(pool2); } assert(i == count); @@ -797,12 +797,12 @@ of_range_t range = of_range(state->state, count); if (range.length > SIZE_MAX - range.location) @throw [OFOutOfRangeException exception]; - if (range.location + range.length > [self count]) - range.length = [self count] - range.location; + if (range.location + range.length > self.count) + range.length = self.count - range.location; [self getObjects: objects inRange: range]; if (range.location + range.length > ULONG_MAX) @@ -873,11 +873,11 @@ #ifdef OF_HAVE_BLOCKS - (OFArray *)mappedArrayUsingBlock: (of_array_map_block_t)block { OFArray *ret; - size_t count = [self count]; + size_t count = self.count; id *tmp = [self allocMemoryWithSize: sizeof(id) count: count]; @try { [self enumerateObjectsUsingBlock: ^ (id object, size_t idx, @@ -895,11 +895,11 @@ } - (OFArray *)filteredArrayUsingBlock: (of_array_filter_block_t)block { OFArray *ret; - size_t count = [self count]; + size_t count = self.count; id *tmp = [self allocMemoryWithSize: sizeof(id) count: count]; @try { __block size_t i = 0; @@ -919,11 +919,11 @@ return ret; } - (id)foldUsingBlock: (of_array_fold_block_t)block { - size_t count = [self count]; + size_t count = self.count; __block id current; if (count == 0) return nil; if (count == 1) Index: src/OFArray_adjacent.m ================================================================== --- src/OFArray_adjacent.m +++ src/OFArray_adjacent.m @@ -95,12 +95,12 @@ if (array == nil) return self; @try { - objects = [array objects]; - count = [array count]; + objects = array.objects; + count = array.count; _array = [[OFMutableData alloc] initWithItemSize: sizeof(id) capacity: count]; } @catch (id e) { [self release]; @@ -164,21 +164,21 @@ self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); - if ((![[element name] isEqual: @"OFArray"] && - ![[element name] isEqual: @"OFMutableArray"]) || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if ((![element.name isEqual: @"OFArray"] && + ![element.name isEqual: @"OFMutableArray"]) || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *child in [element elementsForNamespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); id object; - object = [child objectByDeserializing]; + object = child.objectByDeserializing; [_array addItem: &object]; [object retain]; objc_autoreleasePoolPop(pool2); } @@ -192,16 +192,16 @@ return self; } - (size_t)count { - return [_array count]; + return _array.count; } - (id const *)objects { - return [_array items]; + return _array.items; } - (id)objectAtIndex: (size_t)idx { return *((id *)[_array itemAtIndex: idx]); @@ -213,12 +213,12 @@ } - (void)getObjects: (id *)buffer inRange: (of_range_t)range { - id *objects = [_array items]; - size_t count = [_array count]; + id const *objects = _array.items; + size_t count = _array.count; if (range.length > SIZE_MAX - range.location || range.location + range.length > count) @throw [OFOutOfRangeException exception]; @@ -226,18 +226,18 @@ buffer[i] = objects[range.location + i]; } - (size_t)indexOfObject: (id)object { - id *objects; + id const *objects; size_t count; if (object == nil) return OF_NOT_FOUND; - objects = [_array items]; - count = [_array count]; + objects = _array.items; + count = _array.count; for (size_t i = 0; i < count; i++) if ([objects[i] isEqual: object]) return i; @@ -244,18 +244,18 @@ return OF_NOT_FOUND; } - (size_t)indexOfObjectIdenticalTo: (id)object { - id *objects; + id const *objects; size_t count; if (object == nil) return OF_NOT_FOUND; - objects = [_array items]; - count = [_array count]; + objects = _array.items; + count = _array.count; for (size_t i = 0; i < count; i++) if (objects[i] == object) return i; @@ -264,16 +264,16 @@ - (OFArray *)objectsInRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || - range.location + range.length > [_array count]) + range.location + range.length > _array.count) @throw [OFOutOfRangeException exception]; if ([self isKindOfClass: [OFMutableArray class]]) return [OFArray - arrayWithObjects: (id *)[_array items] + range.location + arrayWithObjects: (id *)_array.items + range.location count: range.length]; return [OFArray_adjacentSubarray arrayWithArray: self range: range]; } @@ -291,17 +291,17 @@ ![object isKindOfClass: [OFMutableArray_adjacent class]]) return [super isEqual: object]; otherArray = object; - count = [_array count]; + count = _array.count; - if (count != [otherArray count]) + if (count != otherArray.count) return false; - objects = [_array items]; - otherObjects = [otherArray objects]; + objects = _array.items; + otherObjects = otherArray.objects; for (size_t i = 0; i < count; i++) if (![objects[i] isEqual: otherObjects[i]]) return false; @@ -308,12 +308,12 @@ return true; } - (uint32_t)hash { - id *objects = [_array items]; - size_t count = [_array count]; + id const *objects = _array.items; + size_t count = _array.count; uint32_t hash; OF_HASH_INIT(hash); for (size_t i = 0; i < count; i++) @@ -326,11 +326,11 @@ - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state objects: (id *)objects count: (int)count_ { - size_t count = [_array count]; + size_t count = _array.count; if (count > INT_MAX) /* * Use the implementation from OFArray, which is slower, but can * enumerate in chunks. @@ -341,36 +341,36 @@ if (state->state >= count) return 0; state->state = (unsigned long)count; - state->itemsPtr = [_array items]; + state->itemsPtr = _array.items; state->mutationsPtr = (unsigned long *)self; return (int)count; } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { - id *objects = [_array items]; - size_t count = [_array count]; + id const *objects = _array.items; + size_t count = _array.count; bool stop = false; for (size_t i = 0; i < count && !stop; i++) block(objects[i], i, &stop); } #endif - (void)dealloc { - id *objects = [_array items]; - size_t count = [_array count]; + id const *objects = _array.items; + size_t count = _array.count; for (size_t i = 0; i < count; i++) [objects[i] release]; [_array release]; [super dealloc]; } @end Index: src/OFArray_adjacentSubarray.m ================================================================== --- src/OFArray_adjacentSubarray.m +++ src/OFArray_adjacentSubarray.m @@ -22,11 +22,11 @@ #import "OFMutableArray_adjacent.h" @implementation OFArray_adjacentSubarray - (const id *)objects { - return [_array objects] + _range.location; + return _array.objects + _range.location; } - (bool)isEqual: (id)object { OFArray *otherArray; @@ -39,15 +39,15 @@ ![object isKindOfClass: [OFMutableArray_adjacent class]]) return [super isEqual: object]; otherArray = object; - if (_range.length != [otherArray count]) + if (_range.length != otherArray.count) return false; - objects = [self objects]; - otherObjects = [otherArray objects]; + objects = self.objects; + otherObjects = otherArray.objects; for (size_t i = 0; i < _range.length; i++) if (![objects[i] isEqual: otherObjects[i]]) return false; @@ -55,13 +55,13 @@ } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { - id const *objects = [self objects]; + id const *objects = self.objects; bool stop = false; for (size_t i = 0; i < _range.length && !stop; i++) block(objects[i], i, &stop); } #endif @end Index: src/OFCharacterSet_bitset.m ================================================================== --- src/OFCharacterSet_bitset.m +++ src/OFCharacterSet_bitset.m @@ -32,12 +32,12 @@ { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [string characters]; - size_t length = [string length]; + const of_unichar_t *characters = string.characters; + size_t length = string.length; for (size_t i = 0; i < length; i++) { of_unichar_t c = characters[i]; if (c / 8 >= _size) { Index: src/OFCondition.m ================================================================== --- src/OFCondition.m +++ src/OFCondition.m @@ -35,11 +35,11 @@ - (instancetype)init { self = [super init]; if (!of_condition_new(&_condition)) { - Class c = [self class]; + Class c = self.class; [self release]; @throw [OFInitializationFailedException exceptionWithClass: c]; } _conditionInitialized = true; @@ -70,11 +70,11 @@ } - (bool)waitUntilDate: (OFDate *)date { return of_condition_timed_wait(&_condition, &_mutex, - [date timeIntervalSinceNow]); + date.timeIntervalSinceNow); } - (void)signal { if (!of_condition_signal(&_condition)) Index: src/OFConstantString.m ================================================================== --- src/OFConstantString.m +++ src/OFConstantString.m @@ -262,26 +262,26 @@ - (uint32_t)hash { [self finishInitialization]; - return [self hash]; + return self.hash; } - (OFString *)description { [self finishInitialization]; - return [self description]; + return self.description; } /* From OFString */ - (const char *)UTF8String { [self finishInitialization]; - return [self UTF8String]; + return self.UTF8String; } - (size_t)getCString: (char *)cString_ maxLength: (size_t)maxLength encoding: (of_string_encoding_t)encoding @@ -302,18 +302,18 @@ - (size_t)length { [self finishInitialization]; - return [self length]; + return self.length; } - (size_t)UTF8StringLength { [self finishInitialization]; - return [self UTF8StringLength]; + return self.UTF8StringLength; } - (size_t)cStringLengthWithEncoding: (of_string_encoding_t)encoding { [self finishInitialization]; @@ -466,46 +466,46 @@ - (OFString *)uppercaseString { [self finishInitialization]; - return [self uppercaseString]; + return self.uppercaseString; } - (OFString *)lowercaseString { [self finishInitialization]; - return [self lowercaseString]; + return self.lowercaseString; } - (OFString *)capitalizedString { [self finishInitialization]; - return [self capitalizedString]; + return self.capitalizedString; } - (OFString *)stringByDeletingLeadingWhitespaces { [self finishInitialization]; - return [self stringByDeletingLeadingWhitespaces]; + return self.stringByDeletingLeadingWhitespaces; } - (OFString *)stringByDeletingTrailingWhitespaces { [self finishInitialization]; - return [self stringByDeletingTrailingWhitespaces]; + return self.stringByDeletingTrailingWhitespaces; } - (OFString *)stringByDeletingEnclosingWhitespaces { [self finishInitialization]; - return [self stringByDeletingEnclosingWhitespaces]; + return self.stringByDeletingEnclosingWhitespaces; } - (bool)hasPrefix: (OFString *)prefix { [self finishInitialization]; @@ -556,74 +556,74 @@ - (OFArray *)pathComponents { [self finishInitialization]; - return [self pathComponents]; + return self.pathComponents; } - (OFString *)lastPathComponent { [self finishInitialization]; - return [self lastPathComponent]; + return self.lastPathComponent; } - (OFString *)stringByDeletingLastPathComponent { [self finishInitialization]; - return [self stringByDeletingLastPathComponent]; + return self.stringByDeletingLastPathComponent; } - (intmax_t)decimalValue { [self finishInitialization]; - return [self decimalValue]; + return self.decimalValue; } - (uintmax_t)hexadecimalValue { [self finishInitialization]; - return [self hexadecimalValue]; + return self.hexadecimalValue; } - (uintmax_t)octalValue { [self finishInitialization]; - return [self octalValue]; + return self.octalValue; } - (float)floatValue { [self finishInitialization]; - return [self floatValue]; + return self.floatValue; } - (double)doubleValue { [self finishInitialization]; - return [self doubleValue]; + return self.doubleValue; } - (const of_unichar_t *)characters { [self finishInitialization]; - return [self characters]; + return self.characters; } - (const of_char16_t *)UTF16String { [self finishInitialization]; - return [self UTF16String]; + return self.UTF16String; } - (const of_char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder { [self finishInitialization]; @@ -633,18 +633,18 @@ - (size_t)UTF16StringLength { [self finishInitialization]; - return [self UTF16StringLength]; + return self.UTF16StringLength; } - (const of_char32_t *)UTF32String { [self finishInitialization]; - return [self UTF32String]; + return self.UTF32String; } - (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder { [self finishInitialization]; @@ -662,18 +662,18 @@ #ifdef OF_HAVE_UNICODE_TABLES - (OFString *)decomposedStringWithCanonicalMapping { [self finishInitialization]; - return [self decomposedStringWithCanonicalMapping]; + return self.decomposedStringWithCanonicalMapping; } - (OFString *)decomposedStringWithCompatibilityMapping { [self finishInitialization]; - return [self decomposedStringWithCompatibilityMapping]; + return self.decomposedStringWithCompatibilityMapping; } #endif #ifdef OF_HAVE_FILES - (void)writeToFile: (OFString *)path Index: src/OFCountedSet.m ================================================================== --- src/OFCountedSet.m +++ src/OFCountedSet.m @@ -139,11 +139,11 @@ - (OFString *)description { OFMutableString *ret; void *pool; - size_t i, count = [self count]; + size_t i, count = self.count; if (count == 0) return @"{()}"; ret = [OFMutableString stringWithString: @"{(\n"]; @@ -204,11 +204,11 @@ objectElement = [OFXMLElement elementWithName: @"object" namespace: OF_SERIALIZATION_NS]; [objectElement addAttributeWithName: @"count" stringValue: count]; - [objectElement addChild: [object XMLElementBySerializing]]; + [objectElement addChild: object.XMLElementBySerializing]; [element addChild: objectElement]; objc_autoreleasePoolPop(pool2); } Index: src/OFCountedSet_hashtable.m ================================================================== --- src/OFCountedSet_hashtable.m +++ src/OFCountedSet_hashtable.m @@ -70,12 +70,12 @@ - (instancetype)initWithArray: (OFArray *)array { self = [self init]; @try { - id const *objects = [array objects]; - size_t count = [array count]; + id const *objects = array.objects; + size_t count = array.count; for (size_t i = 0; i < count; i++) [self addObject: objects[i]]; } @catch (id e) { [self release]; @@ -126,12 +126,12 @@ self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: @"OFCountedSet"] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: @"OFCountedSet"] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *objectElement in [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]) { @@ -139,29 +139,29 @@ OFXMLElement *object; OFXMLAttribute *countAttribute; intmax_t signedCount; uintmax_t count; - object = [[objectElement elementsForNamespace: - OF_SERIALIZATION_NS] firstObject]; + object = [objectElement elementsForNamespace: + OF_SERIALIZATION_NS].firstObject; countAttribute = [objectElement attributeForName: @"count"]; if (object == nil || countAttribute == nil) @throw [OFInvalidFormatException exception]; signedCount = - [[countAttribute stringValue] decimalValue]; + countAttribute.stringValue.decimalValue; if (signedCount < 0) @throw [OFOutOfRangeException exception]; count = signedCount; if (count > SIZE_MAX || count > UINTPTR_MAX) @throw [OFOutOfRangeException exception]; [_mapTable setObject: (void *)(uintptr_t)count - forKey: [object objectByDeserializing]]; + forKey: object.objectByDeserializing]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); Index: src/OFDNSResolver.m ================================================================== --- src/OFDNSResolver.m +++ src/OFDNSResolver.m @@ -197,19 +197,19 @@ - (void)resolver: (OFDNSResolver *)resolver didResolveCNAME: (OFString *)CNAME answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception; - (void)done; - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception; @end @interface OFDNSResolver_ResolveSocketAddressesDelegate: OFObject @@ -290,20 +290,20 @@ if (pos == OF_NOT_FOUND) return nil; return [domain substringWithRange: - of_range(pos + 1, [domain length] - pos - 1)]; + of_range(pos + 1, domain.length - pos - 1)]; } } #endif static bool isFQDN(OFString *host, OFDNSResolverSettings *settings) { - const char *UTF8String = [host UTF8String]; - size_t length = [host UTF8StringLength]; + const char *UTF8String = host.UTF8String; + size_t length = host.UTF8StringLength; unsigned int dots = 0; if ([host hasSuffix: @"."]) return true; @@ -369,11 +369,11 @@ exception]; suffix = parseName(buffer, length, &j, pointerLevel - 1); - if ([components count] == 0) + if (components.count == 0) return suffix; else { [components addObject: suffix]; return [components componentsJoinedByString: @"."]; @@ -759,11 +759,11 @@ queryData = [OFMutableData dataWithCapacity: 512]; /* Header */ - tmp = OF_BSWAP16_IF_LE([ID uInt16Value]); + tmp = OF_BSWAP16_IF_LE(ID.uInt16Value); [queryData addItems: &tmp count: 2]; /* RD */ tmp = OF_BSWAP16_IF_LE(1 << 8); @@ -781,19 +781,19 @@ /* Question */ /* QNAME */ for (OFString *component in [domainName componentsSeparatedByString: @"."]) { - size_t length = [component UTF8StringLength]; + size_t length = component.UTF8StringLength; uint8_t length8; - if (length > 63 || [queryData count] + length > 512) + if (length > 63 || queryData.count + length > 512) @throw [OFOutOfRangeException exception]; length8 = (uint8_t)length; [queryData addItem: &length8]; - [queryData addItems: [component UTF8String] + [queryData addItems: component.UTF8String count: length]; } /* QTYPE */ tmp = OF_BSWAP16_IF_LE(recordType); @@ -870,20 +870,20 @@ recursion: (unsigned int)recursion result: (OFMutableArray *)result { bool found = false; - for (OF_KINDOF(OFDNSResourceRecord *) record in records) { - if ([record recordClass] != OF_DNS_RESOURCE_RECORD_CLASS_IN) + for (OFDNSResourceRecord *record in records) { + if (record.recordClass != OF_DNS_RESOURCE_RECORD_CLASS_IN) continue; - if ([record recordType] == recordType) { + if (record.recordType == recordType) { [result addObject: record]; found = true; - } else if ([record recordType] == + } else if (record.recordType == OF_DNS_RESOURCE_RECORD_TYPE_CNAME) { - [self resolveCNAME: record + [self resolveCNAME: (OFCNAMEDNSResourceRecord *)record answerRecords: answerRecords additionalRecords: additionalRecords recordType: recordType recursion: recursion result: result]; @@ -899,11 +899,11 @@ additionalRecords: (OFDictionary *)additionalRecords recordType: (of_dns_resource_record_type_t)recordType recursion: (unsigned int)recursion result: (OFMutableArray *)result { - OFString *alias = [CNAME alias]; + OFString *alias = CNAME.alias; bool found = false; if (recursion == 0) return; @@ -923,11 +923,11 @@ result: result]) found = true; if (!found) { of_run_loop_mode_t runLoopMode = - [[OFRunLoop currentRunLoop] currentMode]; + [OFRunLoop currentRunLoop].currentMode; OFNumber *recordTypeNumber = [OFNumber numberWithInt: recordType]; _expectedResponses++; @@ -953,19 +953,19 @@ - (void)resolver: (OFDNSResolver *)resolver didResolveCNAME: (OFString *)CNAME answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception { /* * TODO: Error handling could be improved. Ignore error if there are * responses, otherwise propagate error. */ - of_dns_resource_record_type_t recordType = [context unsignedIntValue]; + of_dns_resource_record_type_t recordType = context.unsignedIntValue; bool found = false; OFMutableArray *records; size_t count; OF_ENSURE(resolver == _resolver); @@ -1002,11 +1002,11 @@ [self done]; return; } - count = [_records count]; + count = _records.count; for (size_t i = 0; i < count; i++) { id object = [_records objectAtIndex: i]; if (![object isKindOfClass: [OFPair class]]) continue; @@ -1018,11 +1018,11 @@ continue; [_records removeObjectAtIndex: i]; [_records insertObjectsFromArray: records atIndex: i]; - i += [records count] - 1; + i += records.count - 1; } if (_expectedResponses == 0) [self done]; } @@ -1047,11 +1047,11 @@ } } [addresses makeImmutable]; - if ([addresses count] == 0) + if (addresses.count == 0) exception = [OFResolveHostFailedException exceptionWithHost: _host recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN recordType: 0 error: OF_DNS_RESOLVER_ERROR_UNKNOWN]; @@ -1067,19 +1067,19 @@ - (void)resolver: (OFDNSResolver *)resolver didResolveDomainName: (OFString *)domainName answerRecords: (OFDictionary *)answerRecords authorityRecords: (OFDictionary *)authorityRecords additionalRecords: (OFDictionary *)additionalRecords - context: (id)context + context: (OFNumber *)context exception: (id)exception { /* * TODO: Error handling could be improved. Ignore error if there are * responses, otherwise propagate error. */ - of_dns_resource_record_type_t recordType = [context unsignedIntValue]; + of_dns_resource_record_type_t recordType = context.unsignedIntValue; if (_resolver != nil) OF_ENSURE(resolver == _resolver); else _resolver = [resolver retain]; @@ -1315,18 +1315,18 @@ components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet options: OF_STRING_SKIP_EMPTY]; - if ([components count] < 2) { + if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } - address = [components firstObject]; + address = components.firstObject; hosts = [components objectsInRange: - of_range(1, [components count] - 1)]; + of_range(1, components.count - 1)]; for (OFString *host in hosts) { addresses = [staticHosts objectForKey: host]; if (addresses == nil) { @@ -1388,34 +1388,34 @@ components = [line componentsSeparatedByCharactersInSet: whitespaceCharacterSet options: OF_STRING_SKIP_EMPTY]; - if ([components count] < 2) { + if (components.count < 2) { objc_autoreleasePoolPop(pool2); continue; } - option = [components firstObject]; + option = components.firstObject; arguments = [components objectsInRange: - of_range(1, [components count] - 1)]; + of_range(1, components.count - 1)]; if ([option isEqual: @"nameserver"]) { - if ([arguments count] != 1) { + if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } [nameServers addObject: [arguments firstObject]]; } else if ([option isEqual: @"domain"]) { - if ([arguments count] != 1) { + if (arguments.count != 1) { objc_autoreleasePoolPop(pool2); continue; } [_localDomain release]; - _localDomain = [[arguments firstObject] copy]; + _localDomain = [arguments.firstObject copy]; } else if ([option isEqual: @"search"]) { [_searchDomains release]; _searchDomains = [arguments copy]; } else if ([option isEqual: @"options"]) for (OFString *argument in arguments) @@ -1435,29 +1435,29 @@ - (void)of_parseResolvConfOption: (OFString *)option { @try { if ([option hasPrefix: @"ndots:"]) { option = [option substringWithRange: - of_range(6, [option length] - 6)]; + of_range(6, option.length - 6)]; _minNumberOfDotsInAbsoluteName = - (unsigned int)[option decimalValue]; + (unsigned int)option.decimalValue; } else if ([option hasPrefix: @"timeout:"]) { option = [option substringWithRange: - of_range(8, [option length] - 8)]; + of_range(8, option.length - 8)]; - _timeout = [option decimalValue]; + _timeout = option.decimalValue; } else if ([option hasPrefix: @"attempts:"]) { option = [option substringWithRange: - of_range(9, [option length] - 9)]; + of_range(9, option.length - 9)]; - _maxAttempts = (unsigned int)[option decimalValue]; + _maxAttempts = (unsigned int)option.decimalValue; } else if ([option hasPrefix: @"reload-period:"]) { option = [option substringWithRange: - of_range(14, [option length] - 14)]; + of_range(14, option.length - 14)]; - _configReloadInterval = [option decimalValue]; + _configReloadInterval = option.decimalValue; } else if ([option isEqual: @"tcp"]) _usesTCP = true; } @catch (OFInvalidFormatException *e) { } } @@ -1486,11 +1486,11 @@ for (iter = &fixedInfo->DnsServerList; iter != NULL; iter = iter->Next) [nameServers addObject: [OFString stringWithCString: iter->IpAddress.String encoding: encoding]]; - if ([nameServers count] > 0) { + if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (fixedInfo->DomainName[0] != '\0') @@ -1530,11 +1530,11 @@ } } @finally { ReleaseDomainNameServerList(nameServerList); } - if ([nameServers count] > 0) { + if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } if (GetDefaultDomainName(buffer, sizeof(buffer))) @@ -1577,11 +1577,11 @@ [nameServers addObject: [OFString stringWithFormat: @"%u.%u.%u.%u", (ip >> 24) & 0xFF, (ip >> 16) & 0xFF, (ip >> 8) & 0xFF, ip & 0xFF]]; } - if ([nameServers count] > 0) { + if (nameServers.count > 0) { [nameServers makeImmutable]; _nameServers = [nameServers copy]; } } #endif @@ -1592,11 +1592,11 @@ * TODO: Rather than reparsing every, check what actually changed * (mtime) and only reset those. */ if (_lastConfigReload != nil && _configReloadInterval > 0 && - [_lastConfigReload timeIntervalSinceNow] < _configReloadInterval) + _lastConfigReload.timeIntervalSinceNow < _configReloadInterval) return; [_staticHosts release]; _staticHosts = nil; @@ -1651,11 +1651,11 @@ domainName = [OFString stringWithFormat: @"%@.%@.", host, searchDomain]; } - if ([domainName UTF8StringLength] > 253) + if (domainName.UTF8StringLength > 253) @throw [OFOutOfRangeException exception]; query = [[[OFDNSResolverQuery alloc] initWithHost: host domainName: domainName @@ -1806,12 +1806,12 @@ of_socket_address_parse_ip(@"::", 0); _IPv6Socket = [[OFUDPSocket alloc] init]; [_IPv6Socket of_bindToAddress: &address extraType: SOCK_DNS]; - [_IPv6Socket setBlocking: false]; - [_IPv6Socket setDelegate: self]; + _IPv6Socket.blocking = false; + _IPv6Socket.delegate = self; [_IPv6Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; } sock = _IPv6Socket; @@ -1823,12 +1823,12 @@ of_socket_address_parse_ip(@"0.0.0.0", 0); _IPv4Socket = [[OFUDPSocket alloc] init]; [_IPv4Socket of_bindToAddress: &address extraType: SOCK_DNS]; - [_IPv4Socket setBlocking: false]; - [_IPv4Socket setDelegate: self]; + _IPv4Socket.blocking = false; + _IPv4Socket.delegate = self; [_IPv4Socket asyncReceiveIntoBuffer: _buffer length: BUFFER_LENGTH]; } sock = _IPv4Socket; @@ -1848,22 +1848,22 @@ if (query == nil) return; if (query->_nameServersIndex + 1 < - [query->_settings->_nameServers count]) { + query->_settings->_nameServers.count) { query->_nameServersIndex++; [self of_sendQuery: query - runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; + runLoopMode: [OFRunLoop currentRunLoop].currentMode]; return; } if (query->_attempt < query->_settings->_maxAttempts) { query->_attempt++; query->_nameServersIndex = 0; [self of_sendQuery: query - runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; + runLoopMode: [OFRunLoop currentRunLoop].currentMode]; return; } query = [[query retain] autorelease]; [_queries removeObjectForKey: query->_ID]; @@ -1889,11 +1889,11 @@ callback(query->_target, query->_selector, self, query->_domainName, nil, nil, nil, query->_context, exception); } -- (bool)socket: (OF_KINDOF(OFUDPSocket *))sock +- (bool)socket: (OFUDPSocket *)sock didReceiveIntoBuffer: (void *)buffer_ length: (size_t)length sender: (const of_socket_address_t *)sender exception: (id)exception { @@ -1932,15 +1932,15 @@ uint16_t numAdditionalRecords; if (length < 12) @throw [OFTruncatedDataException exception]; - if ([query->_queryData itemSize] != 1 || - [query->_queryData count] < 12) + if (query->_queryData.itemSize != 1 || + query->_queryData.count < 12) @throw [OFInvalidArgumentException exception]; - queryDataBuffer = [query->_queryData items]; + queryDataBuffer = query->_queryData.items; /* QR */ if ((buffer[2] & 0x80) == 0) @throw [OFInvalidServerReplyException exception]; @@ -1962,13 +1962,13 @@ case 2: error = OF_DNS_RESOLVER_ERROR_SERVER_FAILURE; break; case 3: if (query->_searchDomainsIndex + 1 < - [query->_settings->_searchDomains count]) { + query->_settings->_searchDomains.count) { of_run_loop_mode_t runLoopMode = - [[OFRunLoop currentRunLoop] currentMode]; + [OFRunLoop currentRunLoop].currentMode; query->_searchDomainsIndex++; [self of_resolveHost: query->_host recordClass: query->_recordClass @@ -2127,11 +2127,11 @@ [addresses addItem: &address]; } [addresses makeImmutable]; - if ([addresses count] == 0) { + if (addresses.count == 0) { of_dns_resource_record_type_t recordType = 0; addresses = nil; switch (addressFamily) { Index: src/OFDNSResourceRecord.m ================================================================== --- src/OFDNSResourceRecord.m +++ src/OFDNSResourceRecord.m @@ -74,11 +74,11 @@ OFString *string) { void *pool = objc_autoreleasePoolPush(); of_dns_resource_record_class_t recordClass; - string = [string uppercaseString]; + string = string.uppercaseString; if ([string isEqual: @"IN"]) recordClass = OF_DNS_RESOURCE_RECORD_CLASS_IN; else @throw [OFInvalidArgumentException exception]; @@ -92,11 +92,11 @@ OFString *string) { void *pool = objc_autoreleasePoolPush(); of_dns_resource_record_type_t recordType; - string = [string uppercaseString]; + string = string.uppercaseString; if ([string isEqual: @"A"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_A; else if ([string isEqual: @"NS"]) recordType = OF_DNS_RESOURCE_RECORD_TYPE_NS; @@ -169,11 +169,11 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tType = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), of_dns_resource_record_type_to_string(_recordType), _TTL]; } @end @@ -233,11 +233,11 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_address)); @@ -253,11 +253,11 @@ @"<%@:\n" @"\tName = %@\n" @"\tAddress = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_socket_address_ip_string(&_address, NULL), _TTL]; } @end @implementation OFAAAADNSResourceRecord @@ -316,11 +316,11 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_address)); @@ -336,11 +336,11 @@ @"<%@:\n" @"\tName = %@\n" @"\tAddress = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_socket_address_ip_string(&_address, NULL), _TTL]; } @end @implementation OFCNAMEDNSResourceRecord @@ -410,16 +410,16 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, [_alias hash]); + OF_HASH_ADD_HASH(hash, _alias.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -431,11 +431,11 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tAlias = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _alias, _TTL]; } @end @implementation OFHINFODNSResourceRecord @@ -510,17 +510,17 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, [_CPU hash]); - OF_HASH_ADD_HASH(hash, [_OS hash]); + OF_HASH_ADD_HASH(hash, _CPU.hash); + OF_HASH_ADD_HASH(hash, _OS.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -533,11 +533,11 @@ @"\tClass = %@\n" @"\tCPU = %@\n" @"\tOS = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _CPU, _OS, _TTL]; } @end @@ -613,18 +613,18 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD(hash, _preference >> 8); OF_HASH_ADD(hash, _preference); - OF_HASH_ADD_HASH(hash, [_mailExchange hash]); + OF_HASH_ADD_HASH(hash, _mailExchange.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -637,11 +637,11 @@ @"\tClass = %@\n" @"\tPreference = %" PRIu16 "\n" @"\tMail Exchange = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _preference, _mailExchange, _TTL]; } @end @@ -712,16 +712,16 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, [_authoritativeHost hash]); + OF_HASH_ADD_HASH(hash, _authoritativeHost.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -733,11 +733,11 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tAuthoritative Host = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _authoritativeHost, _TTL]; } @end @@ -808,16 +808,16 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, [_domainName hash]); + OF_HASH_ADD_HASH(hash, _domainName.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -829,11 +829,11 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tDomain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _domainName, _TTL]; } @end @@ -911,17 +911,17 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, [_mailbox hash]); - OF_HASH_ADD_HASH(hash, [_TXTDomainName hash]); + OF_HASH_ADD_HASH(hash, _mailbox.hash); + OF_HASH_ADD_HASH(hash, _TXTDomainName.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -934,11 +934,11 @@ @"\tClass = %@\n" @"\tMailbox = %@\n" @"\tTXT Domain Name = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _mailbox, _TXTDomainName, _TTL]; } @end @@ -1045,17 +1045,17 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, [_primaryNameServer hash]); - OF_HASH_ADD_HASH(hash, [_responsiblePerson hash]); + OF_HASH_ADD_HASH(hash, _primaryNameServer.hash); + OF_HASH_ADD_HASH(hash, _responsiblePerson.hash); OF_HASH_ADD(hash, _serialNumber >> 24); OF_HASH_ADD(hash, _serialNumber >> 16); OF_HASH_ADD(hash, _serialNumber >> 8); OF_HASH_ADD(hash, _serialNumber); OF_HASH_ADD(hash, _refreshInterval >> 24); @@ -1093,11 +1093,11 @@ @"\tRetry Interval = %" PRIu32 "\n" @"\tExpiration Interval = %" PRIu32 "\n" @"\tMinimum TTL = %" PRIu32 "\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _primaryNameServer, _responsiblePerson, _serialNumber, _refreshInterval, _retryInterval, _expirationInterval, _minTTL, _TTL]; } @@ -1185,20 +1185,20 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); OF_HASH_ADD(hash, _priority >> 8); OF_HASH_ADD(hash, _priority); OF_HASH_ADD(hash, _weight >> 8); OF_HASH_ADD(hash, _weight); - OF_HASH_ADD_HASH(hash, [_target hash]); + OF_HASH_ADD_HASH(hash, _target.hash); OF_HASH_ADD(hash, _port >> 8); OF_HASH_ADD(hash, _port); OF_HASH_FINALIZE(hash); @@ -1214,11 +1214,11 @@ @"\tWeight = %" PRIu16 "\n" @"\tTarget = %@\n" @"\tPort = %" PRIu16 "\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, _priority, _weight, _target, _port, _TTL]; + self.className, _name, _priority, _weight, _target, _port, _TTL]; } @end @implementation OFTXTDNSResourceRecord @synthesize textData = _textData; @@ -1287,16 +1287,16 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, _recordClass >> 8); OF_HASH_ADD(hash, _recordClass); OF_HASH_ADD(hash, _recordType >> 8); OF_HASH_ADD(hash, _recordType); - OF_HASH_ADD_HASH(hash, [_textData hash]); + OF_HASH_ADD_HASH(hash, _textData.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -1308,10 +1308,10 @@ @"\tName = %@\n" @"\tClass = %@\n" @"\tText Data = %@\n" @"\tTTL = %" PRIu32 "\n" @">", - [self className], _name, + self.className, _name, of_dns_resource_record_class_to_string(_recordClass), _textData, _TTL]; } @end Index: src/OFData+ASN1DERValue.m ================================================================== --- src/OFData+ASN1DERValue.m +++ src/OFData+ASN1DERValue.m @@ -48,11 +48,11 @@ static OFArray * parseSequence(OFData *contents, size_t depthLimit) { OFMutableArray *ret = [OFMutableArray array]; - size_t count = [contents count]; + size_t count = contents.count; if (depthLimit == 0) @throw [OFOutOfRangeException exception]; while (count > 0) { @@ -75,11 +75,11 @@ static OFSet * parseSet(OFData *contents, size_t depthLimit) { OFMutableSet *ret = [OFMutableSet set]; - size_t count = [contents count]; + size_t count = contents.count; OFData *previousObjectData = nil; if (depthLimit == 0) @throw [OFOutOfRangeException exception]; @@ -112,12 +112,12 @@ } static size_t parseObject(OFData *self, id *object, size_t depthLimit) { - const unsigned char *items = [self items]; - size_t count = [self count]; + const unsigned char *items = self.items; + size_t count = self.count; unsigned char tag; size_t contentsLength, bytesConsumed = 0; Class valueClass; OFData *contents; @@ -175,11 +175,11 @@ break; case OF_ASN1_TAG_NUMBER_NULL: if (tag & ASN1_TAG_CONSTRUCTED_MASK) @throw [OFInvalidFormatException exception]; - if ([contents count] != 0) + if (contents.count != 0) @throw [OFInvalidFormatException exception]; *object = [OFNull null]; return bytesConsumed; case OF_ASN1_TAG_NUMBER_OBJECT_IDENTIFIER: @@ -234,18 +234,18 @@ - (id)ASN1DERValueWithDepthLimit: (size_t)depthLimit { void *pool = objc_autoreleasePoolPush(); id object; - if ([self itemSize] != 1) + if (self.itemSize != 1) @throw [OFInvalidArgumentException exception]; - if (parseObject(self, &object, depthLimit) != [self count]) + if (parseObject(self, &object, depthLimit) != self.count) @throw [OFInvalidFormatException exception]; [object retain]; objc_autoreleasePoolPop(pool); return [object autorelease]; } @end Index: src/OFData+CryptoHashing.m ================================================================== --- src/OFData+CryptoHashing.m +++ src/OFData+CryptoHashing.m @@ -39,11 +39,11 @@ const unsigned char *digest; char cString[digestSize * 2]; [hash updateWithBuffer: _items length: _count * _itemSize]; - digest = [hash digest]; + digest = hash.digest; for (size_t i = 0; i < digestSize; i++) { uint8_t high, low; high = digest[i] >> 4; Index: src/OFData+MessagePackValue.m ================================================================== --- src/OFData+MessagePackValue.m +++ src/OFData+MessagePackValue.m @@ -130,23 +130,23 @@ } static OFDate * createDate(OFData *data) { - switch ([data count]) { + switch (data.count) { case 4: { uint32_t timestamp; - memcpy(×tamp, [data items], 4); + memcpy(×tamp, data.items, 4); timestamp = OF_BSWAP32_IF_LE(timestamp); return [OFDate dateWithTimeIntervalSince1970: timestamp]; } case 8: { uint64_t combined; - memcpy(&combined, [data items], 8); + memcpy(&combined, data.items, 8); combined = OF_BSWAP64_IF_LE(combined); return [OFDate dateWithTimeIntervalSince1970: (double)(combined & 0x3FFFFFFFF) + (double)(combined >> 34) / 1000000000]; @@ -153,12 +153,12 @@ } case 12: { uint32_t nanoseconds; int64_t seconds; - memcpy(&nanoseconds, [data items], 4); - memcpy(&seconds, (char *)[data items] + 4, 8); + memcpy(&nanoseconds, data.items, 4); + memcpy(&seconds, (char *)data.items + 4, 8); nanoseconds = OF_BSWAP32_IF_LE(nanoseconds); seconds = OF_BSWAP64_IF_LE(seconds); return [OFDate dateWithTimeIntervalSince1970: @@ -556,21 +556,21 @@ } - (id)messagePackValueWithDepthLimit: (size_t)depthLimit { void *pool = objc_autoreleasePoolPush(); - size_t count = [self count]; + size_t count = self.count; id object; - if ([self itemSize] != 1) + if (self.itemSize != 1) @throw [OFInvalidArgumentException exception]; - if (parseObject([self items], count, &object, depthLimit) != count) + if (parseObject(self.items, count, &object, depthLimit) != count) @throw [OFInvalidFormatException exception]; [object retain]; objc_autoreleasePoolPop(pool); return [object autorelease]; } @end Index: src/OFData.m ================================================================== --- src/OFData.m +++ src/OFData.m @@ -187,12 +187,12 @@ uintmax_t size; @try { OFFile *file; - size = [[[OFFileManager defaultManager] - attributesOfItemAtPath: path] fileSize]; + size = [[OFFileManager defaultManager] + attributesOfItemAtPath: path].fileSize; # if UINTMAX_MAX > SIZE_MAX if (size > SIZE_MAX) @throw [OFOutOfRangeException exception]; # endif @@ -251,11 +251,11 @@ _count = 0; pageSize = [OFSystemInfo pageSize]; buffer = [self allocMemoryWithSize: pageSize]; - while (![stream isAtEndOfStream]) { + while (!stream.atEndOfStream) { size_t length = [stream readIntoBuffer: buffer length: pageSize]; if (SIZE_MAX - _count < length) @throw [OFOutOfRangeException exception]; @@ -336,11 +336,11 @@ if (!mutable) { [self release]; self = [OFMutableData alloc]; } - self = [(OFMutableData *)self initWithCapacity: [string length] / 3]; + self = [(OFMutableData *)self initWithCapacity: string.length / 3]; @try { if (!of_base64_decode((OFMutableData *)self, [string cStringWithEncoding: OF_STRING_ENCODING_ASCII], [string cStringLengthWithEncoding: @@ -361,15 +361,15 @@ { void *pool = objc_autoreleasePoolPush(); OFString *stringValue; @try { - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - stringValue = [element stringValue]; + stringValue = element.stringValue; } @catch (id e) { [self release]; @throw e; } @@ -446,13 +446,13 @@ if (![object isKindOfClass: [OFData class]]) return false; data = object; - if ([data count] != _count || [data itemSize] != _itemSize) + if (data.count != _count || data.itemSize != _itemSize) return false; - if (memcmp([data items], _items, _count * _itemSize) != 0) + if (memcmp(data.items, _items, _count * _itemSize) != 0) return false; return true; } @@ -465,17 +465,17 @@ if (![(id)object isKindOfClass: [OFData class]]) @throw [OFInvalidArgumentException exception]; data = (OFData *)object; - if ([data itemSize] != _itemSize) + if (data.itemSize != _itemSize) @throw [OFInvalidArgumentException exception]; - count = [data count]; + count = data.count; minCount = (_count > count ? count : _count); - if ((comparison = memcmp(_items, [data items], + if ((comparison = memcmp(_items, data.items, minCount * _itemSize)) == 0) { if (_count > count) return OF_ORDERED_DESCENDING; if (_count < count) return OF_ORDERED_ASCENDING; @@ -564,20 +564,20 @@ if (range.length > SIZE_MAX - range.location || range.location + range.length > _count) @throw [OFOutOfRangeException exception]; - if (data == nil || [data itemSize] != _itemSize) + if (data == nil || data.itemSize != _itemSize) @throw [OFInvalidArgumentException exception]; - if ((searchLength = [data count]) == 0) + if ((searchLength = data.count) == 0) return of_range(0, 0); if (searchLength > range.length) return of_range(OF_NOT_FOUND, 0); - search = [data items]; + search = data.items; if (options & OF_DATA_SEARCH_BACKWARDS) { for (size_t i = range.length - searchLength;; i--) { if (memcmp(_items + i * _itemSize, search, searchLength * _itemSize) == 0) @@ -637,11 +637,11 @@ if (_itemSize != 1) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); element = [OFXMLElement - elementWithName: [self className] + elementWithName: self.className namespace: OF_SERIALIZATION_NS stringValue: of_base64_encode(_items, _count * _itemSize)]; [element retain]; Index: src/OFDate.m ================================================================== --- src/OFDate.m +++ src/OFDate.m @@ -274,18 +274,18 @@ format: (OFString *)format { self = [super init]; @try { - const char *UTF8String = [string UTF8String]; + const char *UTF8String = string.UTF8String; struct tm tm = { 0 }; int16_t tz = 0; tm.tm_isdst = -1; - if (of_strptime(UTF8String, [format UTF8String], - &tm, &tz) != UTF8String + [string UTF8StringLength]) + if (of_strptime(UTF8String, format.UTF8String, + &tm, &tz) != UTF8String + string.UTF8StringLength) @throw [OFInvalidFormatException exception]; _seconds = tmAndTzToTime(&tm, &tz); } @catch (id e) { [self release]; @@ -299,11 +299,11 @@ format: (OFString *)format { self = [super init]; @try { - const char *UTF8String = [string UTF8String]; + const char *UTF8String = string.UTF8String; struct tm tm = { 0 }; /* * of_strptime() can never set this to INT16_MAX, no matter * what is passed to it, so this is a safe way to figure out if * the date contains a time zone. @@ -310,12 +310,12 @@ */ int16_t tz = INT16_MAX; tm.tm_isdst = -1; - if (of_strptime(UTF8String, [format UTF8String], - &tm, &tz) != UTF8String + [string UTF8StringLength]) + if (of_strptime(UTF8String, format.UTF8String, + &tm, &tz) != UTF8String + string.UTF8StringLength) @throw [OFInvalidFormatException exception]; if (tz == INT16_MAX) { #ifndef OF_WINDOWS if ((_seconds = mktime(&tm)) == -1) @@ -343,15 +343,15 @@ union { double d; uint64_t u; } d; - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - d.u = OF_BSWAP64_IF_LE((uint64_t)[element hexadecimalValue]); + d.u = OF_BSWAP64_IF_LE((uint64_t)element.hexadecimalValue); _seconds = OF_BSWAP_DOUBLE_IF_LE(d.d); objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @@ -433,16 +433,16 @@ union { double d; uint64_t u; } d; - element = [OFXMLElement elementWithName: [self className] + element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; d.d = OF_BSWAP_DOUBLE_IF_LE(_seconds); - [element setStringValue: - [OFString stringWithFormat: @"%016" PRIx64, OF_BSWAP64_IF_LE(d.u)]]; + element.stringValue = + [OFString stringWithFormat: @"%016" PRIx64, OF_BSWAP64_IF_LE(d.u)]; [element retain]; objc_autoreleasePoolPop(pool); @@ -624,17 +624,17 @@ pageSize = [OFSystemInfo pageSize]; buffer = [self allocMemoryWithSize: pageSize]; @try { #ifndef OF_WINDOWS - if (strftime(buffer, pageSize, [format UTF8String], &tm) == 0) + if (strftime(buffer, pageSize, format.UTF8String, &tm) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; #else if (wcsftime(buffer, pageSize / sizeof(wchar_t), - [format UTF16String], &tm) == 0) + format.UTF16String, &tm) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF16String: buffer]; #endif } @finally { @@ -684,17 +684,17 @@ pageSize = [OFSystemInfo pageSize]; buffer = [self allocMemoryWithSize: pageSize]; @try { #ifndef OF_WINDOWS - if (strftime(buffer, pageSize, [format UTF8String], &tm) == 0) + if (strftime(buffer, pageSize, format.UTF8String, &tm) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF8String: buffer]; #else if (wcsftime(buffer, pageSize / sizeof(wchar_t), - [format UTF16String], &tm) == 0) + format.UTF16String, &tm) == 0) @throw [OFOutOfRangeException exception]; ret = [OFString stringWithUTF16String: buffer]; #endif } @finally { Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -288,17 +288,17 @@ { id const *objects, *keys; size_t count; @try { - count = [objects_ count]; + count = objects_.count; - if (count != [keys_ count]) + if (count != keys_.count) @throw [OFInvalidArgumentException exception]; - objects = [objects_ objects]; - keys = [keys_ objects]; + objects = objects_.objects; + keys = keys_.objects; } @catch (id e) { [self release]; @throw e; } @@ -352,11 +352,11 @@ { if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); id ret; - key = [key substringWithRange: of_range(1, [key length] - 1)]; + key = [key substringWithRange: of_range(1, key.length - 1)]; ret = [[super valueForKey: key] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; @@ -369,11 +369,11 @@ forKey: (OFString *)key { if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - key = [key substringWithRange: of_range(1, [key length] - 1)]; + key = [key substringWithRange: of_range(1, key.length - 1)]; [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; @@ -416,11 +416,11 @@ if (![object isKindOfClass: [OFDictionary class]]) return false; otherDictionary = object; - if ([otherDictionary count] != [self count]) + if (otherDictionary.count != self.count) return false; pool = objc_autoreleasePoolPush(); keyEnumerator = [self keyEnumerator]; @@ -488,11 +488,11 @@ return false; } - (OFArray *)allKeys { - OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]]; + OFMutableArray *ret = [OFMutableArray arrayWithCapacity: self.count]; for (id key in self) [ret addObject: key]; [ret makeImmutable]; @@ -500,11 +500,11 @@ return ret; } - (OFArray *)allObjects { - OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]]; + OFMutableArray *ret = [OFMutableArray arrayWithCapacity: self.count]; void *pool = objc_autoreleasePoolPush(); OFEnumerator *enumerator = [self objectEnumerator]; id object; while ((object = [enumerator nextObject]) != nil) @@ -603,12 +603,12 @@ - (OFString *)description { OFMutableString *ret; void *pool; OFEnumerator *keyEnumerator, *objectEnumerator; - id key, object; - size_t i, count = [self count]; + OFObject *key, *object; + size_t i, count = self.count; if (count == 0) return @"{}"; ret = [OFMutableString stringWithString: @"{\n"]; @@ -619,13 +619,13 @@ i = 0; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); - [ret appendString: [key description]]; + [ret appendString: key.description]; [ret appendString: @" = "]; - [ret appendString: [object description]]; + [ret appendString: object.description]; if (++i < count) [ret appendString: @";\n"]; objc_autoreleasePoolPop(pool2); @@ -648,23 +648,23 @@ OFEnumerator *keyEnumerator = [self keyEnumerator]; OFEnumerator *objectEnumerator = [self objectEnumerator]; OFCharacterSet *allowed = [OFCharacterSet_URLQueryPartAllowed URLQueryPartAllowedCharacterSet]; bool first = true; - id key, object; + OFObject *key, *object; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { if OF_UNLIKELY (first) first = false; else [ret appendString: @"&"]; - [ret appendString: [[key description] + [ret appendString: [key.description stringByURLEncodingWithAllowedCharacters: allowed]]; [ret appendString: @"="]; - [ret appendString: [[object description] + [ret appendString: [object.description stringByURLEncodingWithAllowedCharacters: allowed]]; } [ret makeImmutable]; @@ -695,16 +695,16 @@ OFXMLElement *keyElement, *objectElement; keyElement = [OFXMLElement elementWithName: @"key" namespace: OF_SERIALIZATION_NS]; - [keyElement addChild: [key XMLElementBySerializing]]; + [keyElement addChild: key.XMLElementBySerializing]; objectElement = [OFXMLElement elementWithName: @"object" namespace: OF_SERIALIZATION_NS]; - [objectElement addChild: [object XMLElementBySerializing]]; + [objectElement addChild: object.XMLElementBySerializing]; [element addChild: keyElement]; [element addChild: objectElement]; objc_autoreleasePoolPop(pool2); @@ -734,11 +734,11 @@ { OFMutableString *JSON = [OFMutableString stringWithString: @"{"]; void *pool = objc_autoreleasePoolPush(); OFEnumerator *keyEnumerator = [self keyEnumerator]; OFEnumerator *objectEnumerator = [self objectEnumerator]; - size_t i, count = [self count]; + size_t i, count = self.count; id key, object; if (options & OF_JSON_REPRESENTATION_PRETTY) { OFMutableString *indentation = [OFMutableString string]; @@ -814,14 +814,14 @@ { OFMutableData *data; size_t i, count; void *pool; OFEnumerator *keyEnumerator, *objectEnumerator; - id key, object; + id key, object; data = [OFMutableData data]; - count = [self count]; + count = self.count; if (count <= 15) { uint8_t tmp = 0x80 | ((uint8_t)count & 0xF); [data addItem: &tmp]; } else if (count <= UINT16_MAX) { @@ -851,17 +851,17 @@ void *pool2 = objc_autoreleasePoolPush(); OFData *child; i++; - child = [key messagePackRepresentation]; - [data addItems: [child items] - count: [child count]]; + child = key.messagePackRepresentation; + [data addItems: child.items + count: child.count]; - child = [object messagePackRepresentation]; - [data addItems: [child items] - count: [child count]]; + child = object.messagePackRepresentation; + [data addItems: child.items + count: child.count]; objc_autoreleasePoolPop(pool2); } assert(i == count); Index: src/OFDictionary_hashtable.m ================================================================== --- src/OFDictionary_hashtable.m +++ src/OFDictionary_hashtable.m @@ -120,11 +120,11 @@ return self; } @try { - count = [dictionary count]; + count = dictionary.count; } @catch (id e) { [self release]; @throw e; } @@ -254,35 +254,35 @@ keys = [element elementsForName: @"key" namespace: OF_SERIALIZATION_NS]; objects = [element elementsForName: @"object" namespace: OF_SERIALIZATION_NS]; - if ([keys count] != [objects count]) + if (keys.count != objects.count) @throw [OFInvalidFormatException exception]; _mapTable = [[OFMapTable alloc] initWithKeyFunctions: keyFunctions objectFunctions: objectFunctions - capacity: [keys count]]; + capacity: keys.count]; keyEnumerator = [keys objectEnumerator]; objectEnumerator = [objects objectEnumerator]; while ((keyElement = [keyEnumerator nextObject]) != nil && (objectElement = [objectEnumerator nextObject]) != nil) { void *pool2 = objc_autoreleasePoolPush(); OFXMLElement *key, *object; - key = [[keyElement elementsForNamespace: - OF_SERIALIZATION_NS] firstObject]; - object = [[objectElement elementsForNamespace: - OF_SERIALIZATION_NS] firstObject]; + key = [keyElement elementsForNamespace: + OF_SERIALIZATION_NS].firstObject; + object = [objectElement elementsForNamespace: + OF_SERIALIZATION_NS].firstObject; if (key == nil || object == nil) @throw [OFInvalidFormatException exception]; - [_mapTable setObject: [object objectByDeserializing] - forKey: [key objectByDeserializing]]; + [_mapTable setObject: object.objectByDeserializing + forKey: key.objectByDeserializing]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); @@ -306,11 +306,11 @@ return [_mapTable objectForKey: key]; } - (size_t)count { - return [_mapTable count]; + return _mapTable.count; } - (bool)isEqual: (id)object { OFDictionary_hashtable *dictionary; @@ -341,11 +341,11 @@ { OFArray *ret; id *keys; size_t count; - count = [_mapTable count]; + count = _mapTable.count; keys = [self allocMemoryWithSize: sizeof(*keys) count: count]; @try { void *pool = objc_autoreleasePoolPush(); @@ -376,11 +376,11 @@ { OFArray *ret; id *objects; size_t count; - count = [_mapTable count]; + count = _mapTable.count; objects = [self allocMemoryWithSize: sizeof(*objects) count: count]; @try { void *pool = objc_autoreleasePoolPush(); @@ -446,8 +446,8 @@ } #endif - (uint32_t)hash { - return [_mapTable hash]; + return _mapTable.hash; } @end Index: src/OFEnumerator.h ================================================================== --- src/OFEnumerator.h +++ src/OFEnumerator.h @@ -85,11 +85,11 @@ #ifndef NSINTEGER_DEFINED typedef struct { /*! Arbitrary state information for the enumeration */ unsigned long state; /*! Pointer to a C array of objects to return */ - id __unsafe_unretained _Nullable *_Nullable itemsPtr; + id const __unsafe_unretained _Nullable *_Nullable itemsPtr; /*! Arbitrary state information to detect mutations */ unsigned long *_Nullable mutationsPtr; /*! Additional arbitrary state information */ unsigned long extra[5]; } of_fast_enumeration_state_t; Index: src/OFFile.m ================================================================== --- src/OFFile.m +++ src/OFFile.m @@ -243,17 +243,17 @@ @try { void *pool = objc_autoreleasePoolPush(); int flags; #ifndef OF_AMIGAOS - if ((flags = parseMode([mode UTF8String])) == -1) + if ((flags = parseMode(mode.UTF8String)) == -1) @throw [OFInvalidArgumentException exception]; flags |= O_BINARY | O_CLOEXEC; # if defined(OF_WINDOWS) - if ((handle = _wopen([path UTF16String], flags, + if ((handle = _wopen(path.UTF16String, flags, _S_IREAD | _S_IWRITE)) == -1) # elif defined(OF_HAVE_OFF64_T) if ((handle = open64([path cStringWithEncoding: [OFLocale encoding]], flags, 0666)) == -1) # else @@ -268,11 +268,11 @@ if ((handle = malloc(sizeof(*handle))) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: sizeof(*handle)]; @try { - if ((flags = parseMode([mode UTF8String], + if ((flags = parseMode(mode.UTF8String, &handle->append)) == -1) @throw [OFInvalidArgumentException exception]; if ((handle->handle = Open([path cStringWithEncoding: [OFLocale encoding]], flags)) == 0) { @@ -356,11 +356,11 @@ { void *pool = objc_autoreleasePoolPush(); OFString *fileSystemRepresentation; @try { - fileSystemRepresentation = [URL fileSystemRepresentation]; + fileSystemRepresentation = URL.fileSystemRepresentation; } @catch (id e) { [self release]; @throw e; } Index: src/OFFileManager.m ================================================================== --- src/OFFileManager.m +++ src/OFFileManager.m @@ -181,11 +181,11 @@ - (OFURL *)currentDirectoryURL { void *pool = objc_autoreleasePoolPush(); OFURL *ret; - ret = [OFURL fileURLWithPath: [self currentDirectoryPath]]; + ret = [OFURL fileURLWithPath: self.currentDirectoryPath]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -342,22 +342,22 @@ */ if ([e errNo] != ENOENT) @throw e; } - components = [[URL URLEncodedPath] componentsSeparatedByString: @"/"]; + components = [URL.URLEncodedPath componentsSeparatedByString: @"/"]; for (OFString *component in components) { if (currentPath != nil) currentPath = [currentPath stringByAppendingFormat: @"/%@", component]; else currentPath = component; - [URL setURLEncodedPath: currentPath]; + URL.URLEncodedPath = currentPath; - if ([currentPath length] > 0 && + if (currentPath.length > 0 && ![self directoryExistsAtURL: URL]) [self createDirectoryAtURL: URL]; } objc_autoreleasePoolPop(pool); @@ -414,11 +414,11 @@ { if (path == nil) @throw [OFInvalidArgumentException exception]; #if defined(OF_WINDOWS) - if (_wchdir([path UTF16String]) != 0) + if (_wchdir(path.UTF16String) != 0) @throw [OFChangeCurrentDirectoryPathFailedException exceptionWithPath: path errNo: errno]; #elif defined(OF_AMIGAOS) BPTR lock, oldLock; @@ -463,11 +463,11 @@ - (void)changeCurrentDirectoryURL: (OFURL *)URL { void *pool = objc_autoreleasePoolPush(); - [self changeCurrentDirectoryPath: [URL fileSystemRepresentation]]; + [self changeCurrentDirectoryPath: URL.fileSystemRepresentation]; objc_autoreleasePoolPop(pool); } - (void)copyItemAtPath: (OFString *)source @@ -512,14 +512,14 @@ attributes = [self attributesOfItemAtURL: source]; } @catch (OFRetrieveItemAttributesFailedException *e) { @throw [OFCopyItemFailedException exceptionWithSourceURL: source destinationURL: destination - errNo: [e errNo]]; + errNo: e.errNo]; } - type = [attributes fileType]; + type = attributes.fileType; if ([type isEqual: of_file_type_directory]) { OFArray *contents; @try { @@ -584,11 +584,11 @@ mode: @"r"]; destinationStream = [[OFURLHandler handlerForURL: destination] openItemAtURL: destination mode: @"w"]; - while (![sourceStream isAtEndOfStream]) { + while (!sourceStream.atEndOfStream) { size_t length; length = [sourceStream readIntoBuffer: buffer length: pageSize]; @@ -628,11 +628,11 @@ } #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS } else if ([type isEqual: of_file_type_symbolic_link]) { @try { OFString *linkDestination = - [attributes fileSymbolicLinkDestination]; + attributes.fileSymbolicLinkDestination; [self createSymbolicLinkAtURL: destination withDestinationPath: linkDestination]; } @catch (id e) { /* @@ -688,11 +688,11 @@ @try { if ([URLHandler moveItemAtURL: source toURL: destination]) return; } @catch (OFMoveItemFailedException *e) { - if ([e errNo] != EXDEV) + if (e.errNo != EXDEV) @throw e; } if ([self fileExistsAtURL: destination]) @throw [OFMoveItemFailedException @@ -707,20 +707,20 @@ [self removeItemAtURL: destination]; @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination - errNo: [e errNo]]; + errNo: e.errNo]; } @try { [self removeItemAtURL: source]; } @catch (OFRemoveItemFailedException *e) { @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination - errNo: [e errNo]]; + errNo: e.errNo]; } objc_autoreleasePoolPop(pool); } @@ -753,11 +753,11 @@ OFURLHandler *URLHandler; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; - if (![[destination scheme] isEqual: [source scheme]]) + if (![destination.scheme isEqual: source.scheme]) @throw [OFInvalidArgumentException exception]; URLHandler = [OFURLHandler handlerForURL: source]; if (URLHandler == nil) Index: src/OFGZIPStream.m ================================================================== --- src/OFGZIPStream.m +++ src/OFGZIPStream.m @@ -81,11 +81,11 @@ for (;;) { uint8_t byte; uint32_t CRC32, uncompressedSize; - if ([_stream isAtEndOfStream]) { + if (_stream.atEndOfStream) { if (_state != OF_GZIP_STREAM_ID1) @throw [OFTruncatedDataException exception]; return 0; } @@ -237,11 +237,11 @@ case OF_GZIP_STREAM_DATA: if (_inflateStream == nil) _inflateStream = [[OFInflateStream alloc] initWithStream: _stream]; - if (![_inflateStream isAtEndOfStream]) { + if (!_inflateStream.atEndOfStream) { size_t bytesRead = [_inflateStream readIntoBuffer: buffer length: length]; _CRC32 = of_crc32(_CRC32, buffer, bytesRead); @@ -307,20 +307,20 @@ - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; - return [_stream isAtEndOfStream]; + return _stream.atEndOfStream; } - (bool)hasDataInReadBuffer { if (_state == OF_GZIP_STREAM_DATA) - return ([super hasDataInReadBuffer] || - [_inflateStream hasDataInReadBuffer]); + return (super.hasDataInReadBuffer || + _inflateStream.hasDataInReadBuffer); - return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer]); + return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer); } - (void)close { [_stream release]; Index: src/OFHMAC.m ================================================================== --- src/OFHMAC.m +++ src/OFHMAC.m @@ -60,12 +60,12 @@ { void *pool = objc_autoreleasePoolPush(); size_t blockSize = [_hashClass blockSize]; OFSecureData *outerKeyPad = [OFSecureData dataWithCount: blockSize]; OFSecureData *innerKeyPad = [OFSecureData dataWithCount: blockSize]; - unsigned char *outerKeyPadItems = [outerKeyPad items]; - unsigned char *innerKeyPadItems = [innerKeyPad items]; + unsigned char *outerKeyPadItems = outerKeyPad.mutableItems; + unsigned char *innerKeyPadItems = innerKeyPad.mutableItems; [_outerHash release]; [_innerHash release]; [_outerHashCopy release]; [_innerHashCopy release]; @@ -80,12 +80,12 @@ length = [_hashClass digestSize]; if OF_UNLIKELY (length > blockSize) length = blockSize; - memcpy(outerKeyPadItems, [hash digest], length); - memcpy(innerKeyPadItems, [hash digest], length); + memcpy(outerKeyPadItems, hash.digest, length); + memcpy(innerKeyPadItems, hash.digest, length); } else { memcpy(outerKeyPadItems, key, length); memcpy(innerKeyPadItems, key, length); } @@ -137,17 +137,17 @@ { if (_outerHash == nil || _innerHash == nil) @throw [OFInvalidArgumentException exception]; if (_calculated) - return [_outerHash digest]; + return _outerHash.digest; - [_outerHash updateWithBuffer: [_innerHash digest] + [_outerHash updateWithBuffer: _innerHash.digest length: [_hashClass digestSize]]; _calculated = true; - return [_outerHash digest]; + return _outerHash.digest; } - (size_t)digestSize { return [_hashClass digestSize]; Index: src/OFHTTPClient.h ================================================================== --- src/OFHTTPClient.h +++ src/OFHTTPClient.h @@ -72,11 +72,11 @@ * @param client The OFHTTPClient that created a socket * @param socket The socket created by the OFHTTPClient * @param request The request for which the socket was created */ - (void)client: (OFHTTPClient *)client - didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket + didCreateSocket: (OFTCPSocket *)socket request: (OFHTTPRequest *)request; /*! * @brief A callback which is called when an OFHTTPClient wants to send the * body for a request. Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -108,67 +108,67 @@ static OFString * constructRequestString(OFHTTPRequest *request) { void *pool = objc_autoreleasePoolPush(); - of_http_request_method_t method = [request method]; - OFURL *URL = [request URL]; + of_http_request_method_t method = request.method; + OFURL *URL = request.URL; OFString *path; - OFString *user = [URL user], *password = [URL password]; + OFString *user = URL.user, *password = URL.password; OFMutableString *requestString; OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers; OFEnumerator OF_GENERIC(OFString *) *keyEnumerator, *objectEnumerator; OFString *key, *object; - if ([URL path] != nil) - path = [URL URLEncodedPath]; + if (URL.path != nil) + path = URL.URLEncodedPath; else path = @"/"; requestString = [OFMutableString stringWithFormat: @"%s %@", of_http_request_method_to_string(method), path]; - if ([URL query] != nil) { + if (URL.query != nil) { [requestString appendString: @"?"]; - [requestString appendString: [URL URLEncodedQuery]]; + [requestString appendString: URL.URLEncodedQuery]; } [requestString appendString: @" HTTP/"]; - [requestString appendString: [request protocolVersionString]]; + [requestString appendString: request.protocolVersionString]; [requestString appendString: @"\r\n"]; - headers = [[[request headers] mutableCopy] autorelease]; + headers = [[request.headers mutableCopy] autorelease]; if (headers == nil) headers = [OFMutableDictionary dictionary]; if ([headers objectForKey: @"Host"] == nil) { - OFNumber *port = [URL port]; + OFNumber *port = URL.port; if (port != nil) { OFString *host = [OFString stringWithFormat: - @"%@:%@", [URL URLEncodedHost], port]; + @"%@:%@", URL.URLEncodedHost, port]; [headers setObject: host forKey: @"Host"]; } else [headers setObject: [URL URLEncodedHost] forKey: @"Host"]; } - if (([user length] > 0 || [password length] > 0) && + if ((user.length > 0 || password.length > 0) && [headers objectForKey: @"Authorization"] == nil) { OFMutableData *authorizationData = [OFMutableData data]; OFString *authorization; - [authorizationData addItems: [user UTF8String] - count: [user UTF8StringLength]]; + [authorizationData addItems: user.UTF8String + count: user.UTF8StringLength]; [authorizationData addItem: ":"]; - [authorizationData addItems: [password UTF8String] - count: [password UTF8StringLength]]; + [authorizationData addItems: password.UTF8String + count: password.UTF8StringLength]; authorization = [OFString stringWithFormat: - @"Basic %@", [authorizationData stringByBase64Encoding]]; + @"Basic %@", authorizationData.stringByBase64Encoding]; [headers setObject: authorization forKey: @"Authorization"]; } @@ -175,12 +175,12 @@ if ([headers objectForKey: @"User-Agent"] == nil) [headers setObject: @"Something using ObjFW " @"" forKey: @"User-Agent"]; - if ([request protocolVersion].major == 1 && - [request protocolVersion].minor == 0 && + if (request.protocolVersion.major == 1 && + request.protocolVersion.minor == 0 && [headers objectForKey: @"Connection"] == nil) [headers setObject: @"keep-alive" forKey: @"Connection"]; if ([headers objectForKey: @"Content-Length"] != nil && @@ -289,21 +289,21 @@ request: _request]; } - (void)createResponseWithSocketOrThrow: (OFTCPSocket *)sock { - OFURL *URL = [_request URL]; + OFURL *URL = _request.URL; OFHTTPClientResponse *response; OFString *connectionHeader; bool keepAlive; OFString *location; response = [[[OFHTTPClientResponse alloc] initWithSocket: sock] autorelease]; - [response setProtocolVersionString: _version]; - [response setStatusCode: _status]; - [response setHeaders: _serverHeaders]; + response.protocolVersionString = _version; + response.statusCode = _status; + response.headers = _serverHeaders; connectionHeader = [_serverHeaders objectForKey: @"Connection"]; if ([_version isEqual: @"1.1"]) { if (connectionHeader != nil) keepAlive = ([connectionHeader caseInsensitiveCompare: @@ -317,25 +317,25 @@ else keepAlive = false; } if (keepAlive) { - [response of_setKeepAlive: true]; + response.of_keepAlive = true; _client->_socket = [sock retain]; _client->_lastURL = [URL copy]; _client->_lastWasHEAD = - ([_request method] == OF_HTTP_REQUEST_METHOD_HEAD); + (_request.method == OF_HTTP_REQUEST_METHOD_HEAD); _client->_lastResponse = [response retain]; } /* FIXME: Case-insensitive check of redirect's scheme */ if (_redirects > 0 && (_status == 301 || _status == 302 || _status == 303 || _status == 307) && (location = [_serverHeaders objectForKey: @"Location"]) != nil && (_client->_insecureRedirectsAllowed || - [[URL scheme] isEqual: @"http"] || + [URL.scheme isEqual: @"http"] || [location hasPrefix: @"https://"])) { OFURL *newURL; bool follow; newURL = [OFURL URLWithString: location @@ -347,22 +347,21 @@ shouldFollowRedirect: newURL statusCode: _status request: _request response: response]; else - follow = defaultShouldFollow( - [_request method], _status); + follow = defaultShouldFollow(_request.method, _status); if (follow) { OFDictionary OF_GENERIC(OFString *, OFString *) - *headers = [_request headers]; + *headers = _request.headers; OFHTTPRequest *newRequest = [[_request copy] autorelease]; OFMutableDictionary *newHeaders = [[headers mutableCopy] autorelease]; - if (![[newURL host] isEqual: [URL host]]) + if (![newURL.host isEqual: URL.host]) [newHeaders removeObjectForKey: @"Host"]; /* * 303 means the request should be converted to a GET * request before redirection. This also means stripping @@ -381,16 +380,15 @@ if ([key hasPrefix: @"Content-"] || [key hasPrefix: @"Transfer-"]) [newHeaders removeObjectForKey: key]; - [newRequest setMethod: - OF_HTTP_REQUEST_METHOD_GET]; + newRequest.method = OF_HTTP_REQUEST_METHOD_GET; } - [newRequest setURL: newURL]; - [newRequest setHeaders: newHeaders]; + newRequest.URL = newURL; + newRequest.headers = newHeaders; _client->_inProgress = false; [_client asyncPerformRequest: newRequest redirects: _redirects - 1]; @@ -432,20 +430,20 @@ if (line == nil) { [self closeAndReconnect]; return false; } - if (![line hasPrefix: @"HTTP/"] || [line length] < 9 || + if (![line hasPrefix: @"HTTP/"] || line.length < 9 || [line characterAtIndex: 8] != ' ') @throw [OFInvalidServerReplyException exception]; _version = [[line substringWithRange: of_range(5, 3)] copy]; if (![_version isEqual: @"1.0"] && ![_version isEqual: @"1.1"]) @throw [OFUnsupportedVersionException exceptionWithVersion: _version]; - _status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue]; + _status = (int)[line substringWithRange: of_range(9, 3)].decimalValue; return true; } - (bool)handleServerHeader: (OFString *)line @@ -456,30 +454,30 @@ char *keyC; if (line == nil) @throw [OFInvalidServerReplyException exception]; - if ([line length] == 0) { + if (line.length == 0) { [_serverHeaders makeImmutable]; if ([_client->_delegate respondsToSelector: @selector(client: didReceiveHeaders:statusCode:request:)]) [_client->_delegate client: _client didReceiveHeaders: _serverHeaders statusCode: _status request: _request]; - [sock setDelegate: nil]; + sock.delegate = nil; [self performSelector: @selector(createResponseWithSocket:) withObject: sock afterDelay: 0]; return false; } - lineC = [line UTF8String]; + lineC = line.UTF8String; if ((tmp = strchr(lineC, ':')) == NULL) @throw [OFInvalidServerReplyException exception]; if ((keyC = malloc(tmp - lineC + 1)) == NULL) @@ -512,11 +510,11 @@ forKey: key]; return true; } -- (bool)stream: (OF_KINDOF(OFStream *))sock +- (bool)stream: (OFStream *)sock didReadLine: (OFString *)line exception: (id)exception { bool ret; @@ -533,20 +531,20 @@ if (_firstLine) { _firstLine = false; ret = [self handleFirstLine: line]; } else ret = [self handleServerHeader: line - socket: sock]; + socket: (OFTCPSocket *)sock]; } @catch (id e) { [self raiseException: e]; ret = false; } return ret; } -- (OFString *)stream: (OF_KINDOF(OFStream *))stream +- (OFString *)stream: (OFStream *)stream didWriteString: (OFString *)string encoding: (of_string_encoding_t)encoding bytesWritten: (size_t)bytesWritten exception: (id)exception { @@ -563,16 +561,16 @@ return nil; } _firstLine = true; - if ([[_request headers] objectForKey: @"Content-Length"] != nil) { - [stream setDelegate: nil]; + if ([_request.headers objectForKey: @"Content-Length"] != nil) { + stream.delegate = nil; OFStream *requestBody = [[[OFHTTPClientRequestBodyStream alloc] initWithHandler: self - socket: stream] autorelease]; + socket: (OFTCPSocket *)stream] autorelease]; if ([_client->_delegate respondsToSelector: @selector(client:wantsRequestBody:request:)]) [_client->_delegate client: _client wantsRequestBody: requestBody @@ -600,16 +598,16 @@ [self raiseException: e]; return; } } -- (void)socket: (OF_KINDOF(OFTCPSocket *))sock +- (void)socket: (OFTCPSocket *)sock didConnectToHost: (OFString *)host port: (uint16_t)port exception: (id)exception { - [(OFTCPSocket *)sock setDelegate: self]; + sock.delegate = self; if (exception != nil) { [self raiseException: exception]; return; } @@ -625,20 +623,19 @@ afterDelay: 0]; } - (void)start { - OFURL *URL = [_request URL]; + OFURL *URL = _request.URL; OFTCPSocket *sock; /* Can we reuse the last socket? */ - if (_client->_socket != nil && ![_client->_socket isAtEndOfStream] && - [[_client->_lastURL scheme] isEqual: [URL scheme]] && - [[_client->_lastURL host] isEqual: [URL host]] && - [_client->_lastURL port] == [URL port] && - (_client->_lastWasHEAD || - [_client->_lastResponse isAtEndOfStream])) { + if (_client->_socket != nil && !_client->_socket.atEndOfStream && + [_client->_lastURL.scheme isEqual: URL.scheme] && + [_client->_lastURL.host isEqual: URL.host] && + _client->_lastURL.port == URL.port && + (_client->_lastWasHEAD || _client->_lastResponse.atEndOfStream)) { /* * Set _socket to nil, so that in case of an error it won't be * reused. If everything is successful, we set _socket again * at the end. */ @@ -649,11 +646,11 @@ _client->_lastURL = nil; [_client->_lastResponse release]; _client->_lastResponse = nil; - [sock setDelegate: self]; + sock.delegate = self; [self performSelector: @selector(handleSocket:) withObject: sock afterDelay: 0]; } else @@ -661,18 +658,18 @@ } - (void)closeAndReconnect { @try { - OFURL *URL = [_request URL]; + OFURL *URL = _request.URL; OFTCPSocket *sock; uint16_t port; OFNumber *URLPort; [_client close]; - if ([[URL scheme] isEqual: @"https"]) { + if ([URL.scheme isEqual: @"https"]) { if (of_tls_socket_class == Nil) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; sock = [[[of_tls_socket_class alloc] init] autorelease]; @@ -680,16 +677,16 @@ } else { sock = [OFTCPSocket socket]; port = 80; } - URLPort = [URL port]; + URLPort = URL.port; if (URLPort != nil) - port = [URLPort uInt16Value]; + port = URLPort.uInt16Value; - [sock setDelegate: self]; - [sock asyncConnectToHost: [URL host] + sock.delegate = self; + [sock asyncConnectToHost: URL.host port: port]; } @catch (id e) { [self raiseException: e]; } } @@ -707,17 +704,17 @@ OFString *contentLengthString; _handler = [handler retain]; _socket = [sock retain]; - headers = [_handler->_request headers]; + headers = _handler->_request.headers; contentLengthString = [headers objectForKey: @"Content-Length"]; if (contentLengthString == nil) @throw [OFInvalidArgumentException exception]; - contentLength = [contentLengthString decimalValue]; + contentLength = contentLengthString.decimalValue; if (contentLength < 0) @throw [OFOutOfRangeException exception]; _toWrite = contentLength; @@ -792,20 +789,20 @@ return; if (_toWrite > 0) @throw [OFTruncatedDataException exception]; - [_socket setDelegate: _handler]; + _socket.delegate = _handler; [_socket asyncReadLine]; [_socket release]; _socket = nil; } - (int)fileDescriptorForWriting { - return [_socket fileDescriptorForWriting]; + return _socket.fileDescriptorForWriting; } @end @implementation OFHTTPClientResponse @synthesize of_keepAlive = _keepAlive; @@ -828,21 +825,21 @@ - (void)setHeaders: (OFDictionary *)headers { OFString *contentLength; - [super setHeaders: headers]; + super.headers = headers; _chunked = [[headers objectForKey: @"Transfer-Encoding"] isEqual: @"chunked"]; contentLength = [headers objectForKey: @"Content-Length"]; if (contentLength != nil) { _hasContentLength = true; @try { - intmax_t toRead = [contentLength decimalValue]; + intmax_t toRead = contentLength.decimalValue; if (toRead < 0) @throw [OFInvalidServerReplyException exception]; @@ -864,11 +861,11 @@ if (!_hasContentLength && !_chunked) return [_socket readIntoBuffer: buffer length: length]; - if ([_socket isAtEndOfStream]) + if (_socket.atEndOfStream) @throw [OFTruncatedDataException exception]; /* Content-Length */ if (!_chunked) { size_t ret; @@ -905,11 +902,11 @@ length: length]; _toRead -= length; if (_toRead == 0) - if ([[_socket readLine] length] > 0) + if ([_socket readLine].length > 0) @throw [OFInvalidServerReplyException exception]; return length; } else { @@ -927,11 +924,11 @@ if (range.location != OF_NOT_FOUND) line = [line substringWithRange: of_range(0, range.location)]; @try { - intmax_t toRead = [line hexadecimalValue]; + intmax_t toRead = line.hexadecimalValue; if (toRead < 0) @throw [OFOutOfRangeException exception]; _toRead = toRead; @@ -948,11 +945,11 @@ } @catch (OFInvalidEncodingException *e) { @throw [OFInvalidServerReplyException exception]; } - if ([line length] > 0) + if (line.length > 0) @throw [OFInvalidServerReplyException exception]; } else { [_socket release]; _socket = nil; @@ -972,26 +969,26 @@ if (_socket == nil) @throw [OFNotOpenException exceptionWithObject: self]; if (!_hasContentLength && !_chunked) - return [_socket isAtEndOfStream]; + return _socket.atEndOfStream; return _atEndOfStream; } - (int)fileDescriptorForReading { if (_socket == nil) return -1; - return [_socket fileDescriptorForReading]; + return _socket.fileDescriptorForReading; } - (bool)hasDataInReadBuffer { - return ([super hasDataInReadBuffer] || [_socket hasDataInReadBuffer]); + return (super.hasDataInReadBuffer || _socket.hasDataInReadBuffer); } - (void)close { _atEndOfStream = false; @@ -1008,13 +1005,13 @@ { self = [super init]; @try { _client = [client retain]; - _delegate = [client delegate]; + _delegate = client.delegate; - [_client setDelegate: self]; + _client.delegate = self; } @catch (id e) { [self release]; @throw e; } @@ -1021,11 +1018,11 @@ return self; } - (void)dealloc { - [_client setDelegate: _delegate]; + _client.delegate = _delegate; [_client release]; [super dealloc]; } @@ -1061,17 +1058,17 @@ /* * Restore the delegate - we're giving up, but not reaching the release * of the autorelease pool that contains us, so resetting it via * -[dealloc] might be too late. */ - [_client setDelegate: _delegate]; + _client.delegate = _delegate; @throw exception; } - (void)client: (OFHTTPClient *)client - didCreateSocket: (OF_KINDOF(OFTCPSocket *))sock + didCreateSocket: (OFTCPSocket *)sock request: (OFHTTPRequest *)request { if ([_delegate respondsToSelector: @selector(client:didCreateSocket:request:)]) [_delegate client: client @@ -1115,11 +1112,11 @@ shouldFollowRedirect: URL statusCode: statusCode request: request response: response]; else - return defaultShouldFollow([request method], statusCode); + return defaultShouldFollow(request.method, statusCode); } @end @implementation OFHTTPClient @synthesize delegate = _delegate; @@ -1168,12 +1165,12 @@ - (void)asyncPerformRequest: (OFHTTPRequest *)request redirects: (unsigned int)redirects { void *pool = objc_autoreleasePoolPush(); - OFURL *URL = [request URL]; - OFString *scheme = [URL scheme]; + OFURL *URL = request.URL; + OFString *scheme = URL.scheme; if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"]) @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; if (_inProgress) Index: src/OFHTTPCookie.m ================================================================== --- src/OFHTTPCookie.m +++ src/OFHTTPCookie.m @@ -26,36 +26,36 @@ #import "OFInvalidFormatException.h" static void handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value) { - OFString *lowercaseName = [name lowercaseString]; + OFString *lowercaseName = name.lowercaseString; if (value != nil) { if ([lowercaseName isEqual: @"expires"]) { OFDate *date = [OFDate dateWithDateString: value format: @"%a, %d %b %Y %H:%M:%S %z"]; - [cookie setExpires: date]; + cookie.expires = date; } else if ([lowercaseName isEqual: @"max-age"]) { OFDate *date = [OFDate dateWithTimeIntervalSinceNow: - [value decimalValue]]; - [cookie setExpires: date]; + value.decimalValue]; + cookie.expires = date; } else if ([lowercaseName isEqual: @"domain"]) - [cookie setDomain: value]; + cookie.domain = value; else if ([lowercaseName isEqual: @"path"]) - [cookie setPath: value]; + cookie.path = value; else - [[cookie extensions] addObject: + [cookie.extensions addObject: [OFString stringWithFormat: @"%@=%@", name, value]]; } else { if ([lowercaseName isEqual: @"secure"]) - [cookie setSecure: true]; + cookie.secure = true; else if ([lowercaseName isEqual: @"httponly"]) - [cookie setHTTPOnly: true]; - else if ([name length] > 0) - [[cookie extensions] addObject: name]; + cookie.HTTPOnly = true; + else if (name.length > 0) + [cookie.extensions addObject: name]; } } @implementation OFHTTPCookie @synthesize name = _name, value = _value, domain = _domain, path = _path; @@ -67,13 +67,13 @@ forURL: (OFURL *)URL { OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); OFString *string = [headerFields objectForKey: @"Set-Cookie"]; - OFString *domain = [URL host]; - const of_unichar_t *characters = [string characters]; - size_t length = [string length], last = 0; + OFString *domain = URL.host; + const of_unichar_t *characters = string.characters; + size_t length = string.length, last = 0; enum { STATE_PRE_NAME, STATE_NAME, STATE_EXPECT_VALUE, STATE_VALUE, @@ -164,11 +164,11 @@ } else if (characters[i] == ';' || characters[i] == ',') { name = [string substringWithRange: of_range(last, i - last)]; - handleAttribute([ret lastObject], name, nil); + handleAttribute(ret.lastObject, name, nil); state = (characters[i] == ';' ? STATE_PRE_ATTR_NAME : STATE_PRE_NAME); } @@ -185,21 +185,21 @@ * meaning RFC 6265 contradicts RFC 2616. * Solve this by special casing this. */ if (characters[i] == ',' && [name caseInsensitiveCompare: @"expires"] == - OF_ORDERED_SAME && [value length] == 3 && + OF_ORDERED_SAME && value.length == 3 && ([value isEqual: @"Mon"] || [value isEqual: @"Tue"] || [value isEqual: @"Wed"] || [value isEqual: @"Thu"] || [value isEqual: @"Fri"] || [value isEqual: @"Sat"] || [value isEqual: @"Sun"])) break; - handleAttribute([ret lastObject], name, value); + handleAttribute(ret.lastObject, name, value); state = (characters[i] == ';' ? STATE_PRE_ATTR_NAME : STATE_PRE_NAME); } break; @@ -231,18 +231,18 @@ case STATE_ATTR_NAME: if (last != length) { name = [string substringWithRange: of_range(last, length - last)]; - handleAttribute([ret lastObject], name, nil); + handleAttribute(ret.lastObject, name, nil); } break; case STATE_ATTR_VALUE: value = [string substringWithRange: of_range(last, length - last)]; - handleAttribute([ret lastObject], name, value); + handleAttribute(ret.lastObject, name, value); break; } objc_autoreleasePoolPop(pool); @@ -256,11 +256,11 @@ OFDictionary OF_GENERIC(OFString *, OFString *) *ret; void *pool; OFMutableString *cookieString; bool first = true; - if ([cookies count] == 0) + if (cookies.count == 0) return [OFDictionary dictionary]; pool = objc_autoreleasePoolPush(); cookieString = [OFMutableString string]; @@ -268,13 +268,13 @@ if OF_UNLIKELY (first) first = false; else [cookieString appendString: @"; "]; - [cookieString appendString: [cookie name]]; + [cookieString appendString: cookie.name]; [cookieString appendString: @"="]; - [cookieString appendString: [cookie value]]; + [cookieString appendString: cookie.value]; } ret = [[OFDictionary alloc] initWithObject: cookieString forKey: @"Cookie"]; @@ -366,18 +366,18 @@ - (uint32_t)hash { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); - OF_HASH_ADD_HASH(hash, [_value hash]); - OF_HASH_ADD_HASH(hash, [_domain hash]); - OF_HASH_ADD_HASH(hash, [_path hash]); - OF_HASH_ADD_HASH(hash, [_expires hash]); + OF_HASH_ADD_HASH(hash, _name.hash); + OF_HASH_ADD_HASH(hash, _value.hash); + OF_HASH_ADD_HASH(hash, _domain.hash); + OF_HASH_ADD_HASH(hash, _path.hash); + OF_HASH_ADD_HASH(hash, _expires.hash); OF_HASH_ADD(hash, _secure); OF_HASH_ADD(hash, _HTTPOnly); - OF_HASH_ADD_HASH(hash, [_extensions hash]); + OF_HASH_ADD_HASH(hash, _extensions.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -418,11 +418,11 @@ [ret appendString: @"; Secure"]; if (_HTTPOnly) [ret appendString: @"; HTTPOnly"]; - if ([_extensions count] > 0) + if (_extensions.count > 0) [ret appendFormat: @"; %@", [_extensions componentsJoinedByString: @"; "]]; objc_autoreleasePoolPop(pool); Index: src/OFHTTPCookieManager.m ================================================================== --- src/OFHTTPCookieManager.m +++ src/OFHTTPCookieManager.m @@ -60,22 +60,22 @@ { void *pool = objc_autoreleasePoolPush(); OFString *cookieDomain, *URLHost; size_t i; - if (![[cookie path] hasPrefix: @"/"]) - [cookie setPath: @"/"]; + if (![cookie.path hasPrefix: @"/"]) + cookie.path = @"/"; - if ([cookie isSecure] && ![[URL scheme] isEqual: @"https"]) { + if (cookie.secure && ![URL.scheme isEqual: @"https"]) { objc_autoreleasePoolPop(pool); return; } - cookieDomain = [[cookie domain] lowercaseString]; - [cookie setDomain: cookieDomain]; + cookieDomain = cookie.domain.lowercaseString; + cookie.domain = cookieDomain; - URLHost = [[URL host] lowercaseString]; + URLHost = URL.host.lowercaseString; if (![cookieDomain isEqual: URLHost]) { URLHost = [@"." stringByAppendingString: URLHost]; if (![cookieDomain hasSuffix: URLHost]) { objc_autoreleasePoolPop(pool); @@ -83,13 +83,13 @@ } } i = 0; for (OFHTTPCookie *iter in _cookies) { - if ([[iter name] isEqual: [cookie name]] && - [[iter domain] isEqual: [cookie domain]] && - [[iter path] isEqual: [cookie path]]) { + if ([iter.name isEqual: cookie.name] && + [iter.domain isEqual: cookie.domain] && + [iter.path isEqual: cookie.path]) { [_cookies replaceObjectAtIndex: i withObject: cookie]; objc_autoreleasePoolPop(pool); return; @@ -119,27 +119,27 @@ void *pool; OFDate *expires; OFString *cookieDomain, *URLHost, *cookiePath, *URLPath; bool match; - expires = [cookie expires]; - if (expires != nil && [expires timeIntervalSinceNow] <= 0) + expires = cookie.expires; + if (expires != nil && expires.timeIntervalSinceNow <= 0) continue; - if ([cookie isSecure] && ![[URL scheme] isEqual: @"https"]) + if (cookie.secure && ![URL.scheme isEqual: @"https"]) continue; pool = objc_autoreleasePoolPush(); - cookieDomain = [[cookie domain] lowercaseString]; - URLHost = [[URL host] lowercaseString]; + cookieDomain = cookie.domain.lowercaseString; + URLHost = URL.host.lowercaseString; if ([cookieDomain hasPrefix: @"."]) { if ([URLHost hasSuffix: cookieDomain]) match = true; else { cookieDomain = [cookieDomain substringWithRange: - of_range(1, [cookieDomain length] - 1)]; + of_range(1, cookieDomain.length - 1)]; match = [cookieDomain isEqual: URLHost]; } } else match = [cookieDomain isEqual: URLHost]; @@ -147,12 +147,12 @@ if (!match) { objc_autoreleasePoolPop(pool); continue; } - cookiePath = [cookie path]; - URLPath = [URL path]; + cookiePath = cookie.path; + URLPath = URL.path; if (![cookiePath isEqual: @"/"]) { if ([cookiePath isEqual: URLPath]) match = true; else { if (![cookiePath hasSuffix: @"/"]) @@ -176,18 +176,18 @@ return ret; } - (void)purgeExpiredCookies { - for (size_t i = 0, count = [_cookies count]; i < count; i++) { + for (size_t i = 0, count = _cookies.count; i < count; i++) { OFDate *expires = [[_cookies objectAtIndex: i] expires]; - if (expires != nil && [expires timeIntervalSinceNow] <= 0) { + if (expires != nil && expires.timeIntervalSinceNow <= 0) { [_cookies removeObjectAtIndex: i]; i--; count--; continue; } } } @end Index: src/OFHTTPRequest.m ================================================================== --- src/OFHTTPRequest.m +++ src/OFHTTPRequest.m @@ -139,13 +139,13 @@ OFHTTPRequest *copy = [[OFHTTPRequest alloc] init]; @try { copy->_method = _method; copy->_protocolVersion = _protocolVersion; - [copy setURL: _URL]; - [copy setHeaders: _headers]; - [copy setRemoteAddress: &_remoteAddress]; + copy.URL = _URL; + copy.headers = _headers; + copy.remoteAddress = &_remoteAddress; } @catch (id e) { [copy release]; @throw e; } @@ -182,12 +182,12 @@ OF_HASH_INIT(hash); OF_HASH_ADD(hash, _method); OF_HASH_ADD(hash, _protocolVersion.major); OF_HASH_ADD(hash, _protocolVersion.minor); - OF_HASH_ADD_HASH(hash, [_URL hash]); - OF_HASH_ADD_HASH(hash, [_headers hash]); + OF_HASH_ADD_HASH(hash, _URL.hash); + OF_HASH_ADD_HASH(hash, _headers.hash); OF_HASH_ADD_HASH(hash, of_socket_address_hash(&_remoteAddress)); OF_HASH_FINALIZE(hash); return hash; @@ -214,23 +214,23 @@ void *pool = objc_autoreleasePoolPush(); OFArray *components = [string componentsSeparatedByString: @"."]; intmax_t major, minor; of_http_request_protocol_version_t protocolVersion; - if ([components count] != 2) + if (components.count != 2) @throw [OFInvalidFormatException exception]; - major = [[components firstObject] decimalValue]; - minor = [[components lastObject] decimalValue]; + major = [components.firstObject decimalValue]; + minor = [components.lastObject decimalValue]; if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX) @throw [OFOutOfRangeException exception]; protocolVersion.major = (uint8_t)major; protocolVersion.minor = (uint8_t)minor; - [self setProtocolVersion: protocolVersion]; + self.protocolVersion = protocolVersion; objc_autoreleasePoolPop(pool); } - (OFString *)protocolVersionString @@ -244,23 +244,23 @@ { void *pool = objc_autoreleasePoolPush(); const char *method = of_http_request_method_to_string(_method); OFString *indentedHeaders, *ret; - indentedHeaders = [[_headers description] + indentedHeaders = [_headers.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; ret = [[OFString alloc] initWithFormat: @"<%@:\n\tURL = %@\n" @"\tMethod = %s\n" @"\tHeaders = %@\n" @"\tRemote address = %@\n" @">", - [self class], _URL, method, indentedHeaders, + self.class, _URL, method, indentedHeaders, of_socket_address_ip_string(&_remoteAddress, NULL)]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end Index: src/OFHTTPResponse.m ================================================================== --- src/OFHTTPResponse.m +++ src/OFHTTPResponse.m @@ -30,12 +30,12 @@ #import "OFUnsupportedVersionException.h" static of_string_encoding_t encodingForContentType(OFString *contentType) { - const char *UTF8String = [contentType UTF8String]; - size_t last, length = [contentType UTF8StringLength]; + const char *UTF8String = contentType.UTF8String; + size_t last, length = contentType.UTF8StringLength; enum { STATE_TYPE, STATE_BEFORE_PARAM_NAME, STATE_PARAM_NAME, STATE_PARAM_VALUE_OR_QUOTE, @@ -85,12 +85,12 @@ case STATE_PARAM_VALUE: if (UTF8String[i] == ';') { value = [OFString stringWithUTF8String: UTF8String + last length: i - last]; - value = [value - stringByDeletingTrailingWhitespaces]; + value = + value.stringByDeletingTrailingWhitespaces; if ([name isEqual: @"charset"]) charset = value; state = STATE_BEFORE_PARAM_NAME; @@ -119,11 +119,11 @@ } } if (state == STATE_PARAM_VALUE) { value = [OFString stringWithUTF8String: UTF8String + last length: length - last]; - value = [value stringByDeletingTrailingWhitespaces]; + value = value.stringByDeletingTrailingWhitespaces; if ([name isEqual: @"charset"]) charset = value; } @@ -183,23 +183,23 @@ void *pool = objc_autoreleasePoolPush(); OFArray *components = [string componentsSeparatedByString: @"."]; intmax_t major, minor; of_http_request_protocol_version_t protocolVersion; - if ([components count] != 2) + if (components.count != 2) @throw [OFInvalidFormatException exception]; - major = [[components firstObject] decimalValue]; - minor = [[components lastObject] decimalValue]; + major = [components.firstObject decimalValue]; + minor = [components.lastObject decimalValue]; if (major < 0 || major > UINT8_MAX || minor < 0 || minor > UINT8_MAX) @throw [OFOutOfRangeException exception]; protocolVersion.major = (uint8_t)major; protocolVersion.minor = (uint8_t)minor; - [self setProtocolVersion: protocolVersion]; + self.protocolVersion = protocolVersion; objc_autoreleasePoolPop(pool); } - (OFString *)protocolVersionString @@ -228,16 +228,16 @@ encoding = OF_STRING_ENCODING_UTF_8; data = [self readDataUntilEndOfStream]; if ((contentLength = [_headers objectForKey: @"Content-Length"]) != nil) - if ([data count] != (size_t)[contentLength decimalValue]) + if (data.count != (size_t)contentLength.decimalValue) @throw [OFTruncatedDataException exception]; - ret = [[OFString alloc] initWithCString: (char *)[data items] + ret = [[OFString alloc] initWithCString: (char *)data.items encoding: encoding - length: [data count]]; + length: data.count]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -245,21 +245,21 @@ - (OFString *)description { void *pool = objc_autoreleasePoolPush(); OFString *indentedHeaders, *ret; - indentedHeaders = [[_headers description] + indentedHeaders = [_headers.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; ret = [[OFString alloc] initWithFormat: @"<%@:\n" @"\tStatus code = %d\n" @"\tHeaders = %@\n" @">", - [self class], _statusCode, indentedHeaders]; + self.class, _statusCode, indentedHeaders]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end Index: src/OFHTTPServer.h ================================================================== --- src/OFHTTPServer.h +++ src/OFHTTPServer.h @@ -97,11 +97,11 @@ bool _usesTLS; OFString *_Nullable _certificateFile, *_Nullable _privateKeyFile; const char *_Nullable _privateKeyPassphrase; id _Nullable _delegate; OFString *_Nullable _name; - OF_KINDOF(OFTCPSocket *) _Nullable _listeningSocket; + OFTCPSocket *_Nullable _listeningSocket; #ifdef OF_HAVE_THREADS size_t _numberOfThreads, _nextThreadIndex; OFArray *_threadPool; #endif } Index: src/OFHTTPServer.m ================================================================== --- src/OFHTTPServer.m +++ src/OFHTTPServer.m @@ -55,25 +55,25 @@ @interface OFHTTPServer () @end @interface OFHTTPServerResponse: OFHTTPResponse { - OF_KINDOF(OFTCPSocket *) _socket; + OFTCPSocket *_socket; OFHTTPServer *_server; OFHTTPRequest *_request; bool _chunked, _headersSent; } -- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock +- (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server request: (OFHTTPRequest *)request; @end @interface OFHTTPServer_Connection: OFObject { @public - OF_KINDOF(OFTCPSocket *) _socket; + OFTCPSocket *_socket; OFHTTPServer *_server; OFTimer *_timer; enum { AWAITING_PROLOG, PARSING_HEADERS, @@ -86,26 +86,26 @@ OFMutableDictionary *_headers; size_t _contentLength; OFStream *_requestBody; } -- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock +- (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server; - (bool)parseProlog: (OFString *)line; - (bool)parseHeaders: (OFString *)line; - (bool)sendErrorAndClose: (short)statusCode; - (void)createResponse; @end @interface OFHTTPServerRequestBodyStream: OFStream { - OF_KINDOF(OFTCPSocket *) _socket; + OFTCPSocket *_socket; uintmax_t _toRead; bool _atEndOfStream; } -- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock +- (instancetype)initWithSocket: (OFTCPSocket *)sock contentLength: (uintmax_t)contentLength; @end #ifdef OF_HAVE_THREADS @interface OFHTTPServerThread: OFThread @@ -203,17 +203,17 @@ } static OF_INLINE OFString * normalizedKey(OFString *key) { - char *cString = of_strdup([key UTF8String]); + char *cString = of_strdup(key.UTF8String); unsigned char *tmp = (unsigned char *)cString; bool firstLetter = true; if (cString == NULL) @throw [OFOutOfMemoryException - exceptionWithRequestedSize: strlen([key UTF8String])]; + exceptionWithRequestedSize: strlen(key.UTF8String)]; while (*tmp != '\0') { if (!of_ascii_isalpha(*tmp)) { firstLetter = true; tmp++; @@ -231,11 +231,11 @@ return [OFString stringWithUTF8StringNoCopy: cString freeWhenDone: true]; } @implementation OFHTTPServerResponse -- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock +- (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server request: (OFHTTPRequest *)request { self = [super init]; @@ -264,11 +264,11 @@ OFMutableDictionary OF_GENERIC(OFString *, OFString *) *headers; OFEnumerator *keyEnumerator, *valueEnumerator; OFString *key, *value; [_socket writeFormat: @"HTTP/%@ %d %s\r\n", - [self protocolVersionString], _statusCode, + self.protocolVersionString, _statusCode, statusCodeToString(_statusCode)]; headers = [[_headers mutableCopy] autorelease]; if ([headers objectForKey: @"Date"] == nil) { @@ -278,11 +278,11 @@ [headers setObject: date forKey: @"Date"]; } if ([headers objectForKey: @"Server"] == nil) { - OFString *name = [_server name]; + OFString *name = _server.name; if (name != nil) [headers setObject: name forKey: @"Server"]; } @@ -342,11 +342,11 @@ if (_chunked) [_socket writeBuffer: "0\r\n\r\n" length: 5]; } @catch (OFWriteFailedException *e) { - id delegate = [_server delegate]; + id delegate = _server.delegate; if ([delegate respondsToSelector: @selector(server: didReceiveExceptionForResponse:request:exception:)]) [delegate server: _server didReceiveExceptionForResponse: self @@ -363,16 +363,16 @@ - (int)fileDescriptorForWriting { if (_socket == nil) return -1; - return [_socket fileDescriptorForWriting]; + return _socket.fileDescriptorForWriting; } @end @implementation OFHTTPServer_Connection -- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock +- (instancetype)initWithSocket: (OFTCPSocket *)sock server: (OFHTTPServer *)server { self = [super init]; @try { @@ -407,11 +407,11 @@ [_requestBody release]; [super dealloc]; } -- (bool)stream: (OF_KINDOF(OFStream *))sock +- (bool)stream: (OFStream *)sock didReadLine: (OFString *)line exception: (id)exception { if (line == nil || exception != nil) return false; @@ -438,11 +438,11 @@ OFMutableString *path; size_t pos; @try { OFString *version = [line - substringWithRange: of_range([line length] - 9, 9)]; + substringWithRange: of_range(line.length - 9, 9)]; of_unichar_t tmp; if (![version hasPrefix: @" HTTP/1."]) return [self sendErrorAndClose: 505]; @@ -459,18 +459,17 @@ if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; method = [line substringWithRange: of_range(0, pos)]; @try { - _method = of_http_request_method_from_string( - [method UTF8String]); + _method = of_http_request_method_from_string(method.UTF8String); } @catch (OFInvalidFormatException *e) { return [self sendErrorAndClose: 405]; } @try { - of_range_t range = of_range(pos + 1, [line length] - pos - 10); + of_range_t range = of_range(pos + 1, line.length - pos - 10); path = [[[line substringWithRange: range] mutableCopy] autorelease]; } @catch (OFOutOfRangeException *e) { return [self sendErrorAndClose: 400]; @@ -492,20 +491,20 @@ - (bool)parseHeaders: (OFString *)line { OFString *key, *value, *old; size_t pos; - if ([line length] == 0) { + if (line.length == 0) { OFString *contentLengthString; if ((contentLengthString = [_headers objectForKey: @"Content-Length"]) != nil) { intmax_t contentLength; @try { contentLength = - [contentLengthString decimalValue]; + contentLengthString.decimalValue; } @catch (OFInvalidFormatException *e) { return [self sendErrorAndClose: 400]; } @@ -533,14 +532,14 @@ if (pos == OF_NOT_FOUND) return [self sendErrorAndClose: 400]; key = [line substringWithRange: of_range(0, pos)]; value = [line substringWithRange: - of_range(pos + 1, [line length] - pos - 1)]; + of_range(pos + 1, line.length - pos - 1)]; - key = normalizedKey([key stringByDeletingTrailingWhitespaces]); - value = [value stringByDeletingLeadingWhitespaces]; + key = normalizedKey(key.stringByDeletingTrailingWhitespaces); + value = value.stringByDeletingLeadingWhitespaces; old = [_headers objectForKey: key]; if (old != nil) value = [old stringByAppendingFormat: @",%@", value]; @@ -557,13 +556,13 @@ _host = [[value substringWithRange: of_range(0, pos)] retain]; @try { of_range_t range = - of_range(pos + 1, [value length] - pos - 1); - intmax_t portTmp = [[value - substringWithRange: range] decimalValue]; + of_range(pos + 1, value.length - pos - 1); + intmax_t portTmp = [value + substringWithRange: range].decimalValue; if (portTmp < 1 || portTmp > UINT16_MAX) return [self sendErrorAndClose: 400]; _port = (uint16_t)portTmp; @@ -588,11 +587,11 @@ [_socket writeFormat: @"HTTP/1.1 %d %s\r\n" @"Date: %@\r\n" @"Server: %@\r\n" @"\r\n", statusCode, statusCodeToString(statusCode), - date, [_server name]]; + date, _server.name]; return false; } - (void)createResponse @@ -612,57 +611,57 @@ [self sendErrorAndClose: 400]; return; } [_host release]; - _host = [[_server host] retain]; + _host = [_server.host copy]; _port = [_server port]; } URL = [OFMutableURL URL]; - [URL setScheme: @"http"]; - [URL setHost: _host]; + URL.scheme = @"http"; + URL.host = _host; if (_port != 80) - [URL setPort: [OFNumber numberWithUInt16: _port]]; + URL.port = [OFNumber numberWithUInt16: _port]; if ((pos = [_path rangeOfString: @"?"].location) != OF_NOT_FOUND) { OFString *path, *query; path = [_path substringWithRange: of_range(0, pos)]; query = [_path substringWithRange: - of_range(pos + 1, [_path length] - pos - 1)]; + of_range(pos + 1, _path.length - pos - 1)]; - [URL setURLEncodedPath: path]; - [URL setURLEncodedQuery: query]; + URL.URLEncodedPath = path; + URL.URLEncodedQuery = query; } else - [URL setURLEncodedPath: _path]; + URL.URLEncodedPath = _path; [URL makeImmutable]; request = [OFHTTPRequest requestWithURL: URL]; - [request setMethod: _method]; - [request setProtocolVersion: - (of_http_request_protocol_version_t){ 1, _HTTPMinorVersion }]; - [request setHeaders: _headers]; - [request setRemoteAddress: [_socket remoteAddress]]; + request.method = _method; + request.protocolVersion = + (of_http_request_protocol_version_t){ 1, _HTTPMinorVersion }; + request.headers = _headers; + request.remoteAddress = _socket.remoteAddress; response = [[[OFHTTPServerResponse alloc] initWithSocket: _socket server: _server request: request] autorelease]; - [[_server delegate] server: _server - didReceiveRequest: request - requestBody: _requestBody - response: response]; + [_server.delegate server: _server + didReceiveRequest: request + requestBody: _requestBody + response: response]; objc_autoreleasePoolPop(pool); } @end @implementation OFHTTPServerRequestBodyStream -- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock +- (instancetype)initWithSocket: (OFTCPSocket *)sock contentLength: (uintmax_t)contentLength { self = [super init]; @try { @@ -709,16 +708,16 @@ return ret; } - (bool)hasDataInReadBuffer { - return ([super hasDataInReadBuffer] || [_socket hasDataInReadBuffer]); + return (super.hasDataInReadBuffer || _socket.hasDataInReadBuffer); } - (int)fileDescriptorForReading { - return [_socket fileDescriptorForReading]; + return _socket.fileDescriptorForReading; } - (void)close { [_socket release]; @@ -857,19 +856,19 @@ { return _privateKeyPassphrase; } #ifdef OF_HAVE_THREADS -- (void)setNumberOfThreads: (size_t)numberOfThreadas +- (void)setNumberOfThreads: (size_t)numberOfThreads { - if (numberOfThreadas == 0) + if (numberOfThreads == 0) @throw [OFInvalidArgumentException exception]; if (_listeningSocket != nil) @throw [OFAlreadyConnectedException exception]; - _numberOfThreads = numberOfThreadas; + _numberOfThreads = numberOfThreads; } - (size_t)numberOfThreads { return _numberOfThreads; @@ -885,22 +884,21 @@ if (_listeningSocket != nil) @throw [OFAlreadyConnectedException exception]; if (_usesTLS) { - id listeningSocket; + OFTCPSocket *TLSSocket; if (of_tls_socket_class == Nil) @throw [OFUnsupportedProtocolException exception]; - _listeningSocket = [[of_tls_socket_class alloc] init]; + TLSSocket = [[of_tls_socket_class alloc] init]; + _listeningSocket = TLSSocket; - listeningSocket = _listeningSocket; - [listeningSocket setCertificateFile: _certificateFile]; - [listeningSocket setPrivateKeyFile: _privateKeyFile]; - [listeningSocket - setPrivateKeyPassphrase: _privateKeyPassphrase]; + TLSSocket.certificateFile = _certificateFile; + TLSSocket.privateKeyFile = _privateKeyFile; + TLSSocket.privateKeyPassphrase = _privateKeyPassphrase; } else _listeningSocket = [[OFTCPSocket alloc] init]; _port = [_listeningSocket bindToHost: _host port: _port]; @@ -922,11 +920,11 @@ [threads makeImmutable]; _threadPool = [threads copy]; } #endif - [(OFTCPSocket *)_listeningSocket setDelegate: self]; + ((OFTCPSocket *)_listeningSocket).delegate = self; [_listeningSocket asyncAccept]; objc_autoreleasePoolPop(pool); } @@ -943,22 +941,22 @@ [_threadPool release]; _threadPool = nil; #endif } -- (void)of_handleAcceptedSocket: (OF_KINDOF(OFTCPSocket *))acceptedSocket +- (void)of_handleAcceptedSocket: (OFTCPSocket *)acceptedSocket { OFHTTPServer_Connection *connection = [[[OFHTTPServer_Connection alloc] initWithSocket: acceptedSocket server: self] autorelease]; - [(OFTCPSocket *)acceptedSocket setDelegate: connection]; + acceptedSocket.delegate = connection; [acceptedSocket asyncReadLine]; } -- (bool)socket: (OF_KINDOF(OFTCPSocket *))sock - didAcceptSocket: (OF_KINDOF(OFTCPSocket *))acceptedSocket +- (bool)socket: (OFTCPSocket *)sock + didAcceptSocket: (OFTCPSocket *)acceptedSocket exception: (id)exception { if (exception != nil) { if (![_delegate respondsToSelector: @selector(server:didReceiveExceptionOnListeningSocket:)]) Index: src/OFINICategory.m ================================================================== --- src/OFINICategory.m +++ src/OFINICategory.m @@ -79,11 +79,11 @@ OFMutableString *mutableString; if (![string hasPrefix: @"\""] || ![string hasSuffix: @"\""]) return string; - string = [string substringWithRange: of_range(1, [string length] - 2)]; + string = [string substringWithRange: of_range(1, string.length - 2)]; mutableString = [[string mutableCopy] autorelease]; [mutableString replaceOccurrencesOfString: @"\\f" withString: @"\f"]; [mutableString replaceOccurrencesOfString: @"\\r" @@ -161,14 +161,14 @@ if ((pos = [line rangeOfString: @"="].location) == OF_NOT_FOUND) @throw [OFInvalidFormatException exception]; key = [line substringWithRange: of_range(0, pos)]; value = [line substringWithRange: - of_range(pos + 1, [line length] - pos - 1)]; + of_range(pos + 1, line.length - pos - 1)]; - key = [key stringByDeletingEnclosingWhitespaces]; - value = [value stringByDeletingEnclosingWhitespaces]; + key = key.stringByDeletingEnclosingWhitespaces; + value = value.stringByDeletingEnclosingWhitespaces; key = unescapeString(key); value = unescapeString(value); pair->_key = [key copy]; @@ -217,13 +217,13 @@ defaultValue: nil]; intmax_t ret; if (value != nil) { if ([value hasPrefix: @"0x"] || [value hasPrefix: @"$"]) - ret = [value hexadecimalValue]; + ret = value.hexadecimalValue; else - ret = [value decimalValue]; + ret = value.decimalValue; } else ret = defaultValue; objc_autoreleasePoolPop(pool); @@ -260,11 +260,11 @@ OFString *value = [self stringForKey: key defaultValue: nil]; float ret; if (value != nil) - ret = [value floatValue]; + ret = value.floatValue; else ret = defaultValue; objc_autoreleasePoolPop(pool); @@ -278,11 +278,11 @@ OFString *value = [self stringForKey: key defaultValue: nil]; double ret; if (value != nil) - ret = [value doubleValue]; + ret = value.doubleValue; else ret = defaultValue; objc_autoreleasePoolPop(pool); @@ -401,18 +401,18 @@ OFMutableArray *pairs; id const *lines; size_t count; bool replaced; - if ([array count] == 0) { + if (array.count == 0) { [self removeValueForKey: key]; return; } pool = objc_autoreleasePoolPush(); - pairs = [OFMutableArray arrayWithCapacity: [array count]]; + pairs = [OFMutableArray arrayWithCapacity: array.count]; for (id object in array) { OFINICategory_Pair *pair; if (![object isKindOfClass: [OFString class]]) @@ -423,12 +423,12 @@ pair->_value = [object copy]; [pairs addObject: pair]; } - lines = [_lines objects]; - count = [_lines count]; + lines = _lines.objects; + count = _lines.count; replaced = false; for (size_t i = 0; i < count; i++) { OFINICategory_Pair *pair; @@ -444,16 +444,16 @@ [_lines insertObjectsFromArray: pairs atIndex: i]; replaced = true; /* Continue after inserted pairs */ - i += [array count] - 1; + i += array.count - 1; } else i--; /* Continue at same position */ - lines = [_lines objects]; - count = [_lines count]; + lines = _lines.objects; + count = _lines.count; continue; } } @@ -464,12 +464,12 @@ } - (void)removeValueForKey: (OFString *)key { void *pool = objc_autoreleasePoolPush(); - id const *lines = [_lines objects]; - size_t count = [_lines count]; + id const *lines = _lines.objects; + size_t count = _lines.count; for (size_t i = 0; i < count; i++) { OFINICategory_Pair *pair; if (![lines[i] isKindOfClass: [OFINICategory_Pair class]]) @@ -478,12 +478,12 @@ pair = lines[i]; if ([pair->_key isEqual: key]) { [_lines removeObjectAtIndex: i]; - lines = [_lines objects]; - count = [_lines count]; + lines = _lines.objects; + count = _lines.count; i--; /* Continue at same position */ continue; } } @@ -493,11 +493,11 @@ - (bool)of_writeToStream: (OFStream *)stream encoding: (of_string_encoding_t)encoding first: (bool)first { - if ([_lines count] == 0) + if (_lines.count == 0) return false; if (first) [stream writeFormat: @"[%@]\r\n", _name]; else Index: src/OFINIFile.m ================================================================== --- src/OFINIFile.m +++ src/OFINIFile.m @@ -35,12 +35,12 @@ @end static bool isWhitespaceLine(OFString *line) { - const char *cString = [line UTF8String]; - size_t length = [line UTF8StringLength]; + const char *cString = line.UTF8String; + size_t length = line.UTF8StringLength; for (size_t i = 0; i < length; i++) if (!of_ascii_isspace(cString[i])) return false; @@ -100,11 +100,11 @@ { void *pool = objc_autoreleasePoolPush(); OFINICategory *category; for (category in _categories) - if ([[category name] isEqual: name]) + if ([category.name isEqual: name]) return category; category = [[[OFINICategory alloc] of_initWithName: name] autorelease]; [_categories addObject: category]; @@ -124,11 +124,11 @@ @try { file = [OFFile fileWithPath: path mode: @"r"]; } @catch (OFOpenItemFailedException *e) { /* Handle missing file like an empty file */ - if ([e errNo] == ENOENT) + if (e.errNo == ENOENT) return; @throw e; } @@ -141,11 +141,11 @@ if (![line hasSuffix: @"]"]) @throw [OFInvalidFormatException exception]; categoryName = [line substringWithRange: - of_range(1, [line length] - 2)]; + of_range(1, line.length - 2)]; category = [[[OFINICategory alloc] of_initWithName: categoryName] autorelease]; [_categories addObject: category]; } else { Index: src/OFInflate64Stream.h ================================================================== --- src/OFInflate64Stream.h +++ src/OFInflate64Stream.h @@ -34,11 +34,11 @@ @interface OFInflate64Stream: OFStream { #ifdef OF_INFLATE64_STREAM_M @public #endif - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; unsigned char _buffer[OF_INFLATE64_STREAM_BUFFER_SIZE]; uint16_t _bufferIndex, _bufferLength; uint8_t _byte; uint8_t _bitIndex, _savedBitsLength; uint16_t _savedBits; @@ -79,11 +79,11 @@ * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A new, autoreleased OFInflate64Stream */ -+ (instancetype)streamWithStream: (OF_KINDOF(OFStream *))stream; ++ (instancetype)streamWithStream: (OFStream *)stream; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFInflate64Stream with the specified @@ -91,10 +91,9 @@ * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A initialized OFInflate64Stream */ -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream - OF_DESIGNATED_INITIALIZER; +- (instancetype)initWithStream: (OFStream *)stream OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/OFInflateStream.h ================================================================== --- src/OFInflateStream.h +++ src/OFInflateStream.h @@ -34,11 +34,11 @@ @interface OFInflateStream: OFStream { #ifdef OF_INFLATE_STREAM_M @public #endif - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; unsigned char _buffer[OF_INFLATE_STREAM_BUFFER_SIZE]; uint16_t _bufferIndex, _bufferLength; uint8_t _byte; uint8_t _bitIndex, _savedBitsLength; uint16_t _savedBits; @@ -79,11 +79,11 @@ * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A new, autoreleased OFInflateStream */ -+ (instancetype)streamWithStream: (OF_KINDOF(OFStream *))stream; ++ (instancetype)streamWithStream: (OFStream *)stream; - (instancetype)init OF_UNAVAILABLE; /*! * @brief Initializes an already allocated OFInflateStream with the specified @@ -91,10 +91,9 @@ * * @param stream The underlying stream to which compressed data is written or * from which compressed data is read * @return A initialized OFInflateStream */ -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream - OF_DESIGNATED_INITIALIZER; +- (instancetype)initWithStream: (OFStream *)stream OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/OFInflateStream.m ================================================================== --- src/OFInflateStream.m +++ src/OFInflateStream.m @@ -170,21 +170,21 @@ lengths[i] = 5; fixedDistTree = of_huffman_tree_construct(lengths, 32); } -+ (instancetype)streamWithStream: (OF_KINDOF(OFStream *))stream ++ (instancetype)streamWithStream: (OFStream *)stream { return [[[self alloc] initWithStream: stream] autorelease]; } - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)initWithStream: (OFStream *)stream { self = [super init]; @try { _stream = [stream retain]; @@ -666,16 +666,17 @@ return _atEndOfStream; } - (int)fileDescriptorForReading { - return [_stream fileDescriptorForReading]; + return ((id )_stream) + .fileDescriptorForReading; } - (bool)hasDataInReadBuffer { - return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer] || + return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer || _bufferLength - _bufferIndex > 0); } - (void)close { Index: src/OFIntrospection.m ================================================================== --- src/OFIntrospection.m +++ src/OFIntrospection.m @@ -79,11 +79,11 @@ } - (OFString *)description { return [OFString stringWithFormat: @"<%@: %@ [%s]>", - [self class], _name, _typeEncoding]; + self.class, _name, _typeEncoding]; } - (bool)isEqual: (id)object { OFMethod *method; @@ -117,11 +117,11 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); if (_typeEncoding != NULL) { size_t length = strlen(_typeEncoding); for (size_t i = 0; i < length; i++) @@ -177,11 +177,11 @@ _name = [[OFString alloc] initWithUTF8String: property_getName(property)]; if ((attributes = property_getAttributes(property)) == NULL) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; while (*attributes != '\0') { const char *start; switch (*attributes) { @@ -209,11 +209,11 @@ case 'G': start = ++attributes; if (_getter != nil) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; while (*attributes != ',' && *attributes != '\0') attributes++; @@ -225,11 +225,11 @@ case 'S': start = ++attributes; if (_setter != nil) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; while (*attributes != ',' && *attributes != '\0') attributes++; @@ -252,11 +252,11 @@ case 'V': start = ++attributes; if (_iVar != nil) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; while (*attributes != ',' && *attributes != '\0') attributes++; @@ -265,16 +265,16 @@ length: attributes - start]; break; default: @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } if (*attributes != ',' && *attributes != '\0') @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; if (*attributes != '\0') attributes++; } @@ -332,12 +332,12 @@ @"\tAttributes = 0x%03X\n" @"\tGetter = %@\n" @"\tSetter = %@\n" @"\tiVar = %@\n" @">", - [self class], _name, _attributes, - _getter, _setter, _iVar]; + self.class, _name, _attributes, _getter, _setter, + _iVar]; } - (bool)isEqual: (id)object { OFProperty *otherProperty; @@ -366,15 +366,15 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); + OF_HASH_ADD_HASH(hash, _name.hash); OF_HASH_ADD(hash, (_attributes & 0xFF00) >> 8); OF_HASH_ADD(hash, _attributes & 0xFF); - OF_HASH_ADD_HASH(hash, [_getter hash]); - OF_HASH_ADD_HASH(hash, [_setter hash]); + OF_HASH_ADD_HASH(hash, _getter.hash); + OF_HASH_ADD_HASH(hash, _setter.hash); OF_HASH_FINALIZE(hash); return hash; } Index: src/OFInvocation.m ================================================================== --- src/OFInvocation.m +++ src/OFInvocation.m @@ -40,11 +40,11 @@ { self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); - size_t numberOfArguments = [signature numberOfArguments]; + size_t numberOfArguments = signature.numberOfArguments; const char *typeEncoding; size_t typeSize; _methodSignature = [signature retain]; _arguments = [[OFMutableArray alloc] init]; @@ -60,11 +60,11 @@ capacity: 1]; [data increaseCountBy: 1]; [_arguments addObject: data]; } - typeEncoding = [_methodSignature methodReturnType]; + typeEncoding = _methodSignature.methodReturnType; typeSize = of_sizeof_type_encoding(typeEncoding); if (typeSize > 0) { _returnValue = [[OFMutableData alloc] initWithItemSize: typeSize @@ -93,33 +93,33 @@ - (void)setArgument: (const void *)buffer atIndex: (size_t)idx { OFMutableData *data = [_arguments objectAtIndex: idx]; - memcpy([data items], buffer, [data itemSize]); + memcpy(data.mutableItems, buffer, data.itemSize); } - (void)getArgument: (void *)buffer atIndex: (size_t)idx { OFData *data = [_arguments objectAtIndex: idx]; - memcpy(buffer, [data items], [data itemSize]); + memcpy(buffer, data.items, data.itemSize); } - (void)setReturnValue: (const void *)buffer { - memcpy([_returnValue items], buffer, [_returnValue itemSize]); + memcpy(_returnValue.mutableItems, buffer, _returnValue.itemSize); } - (void)getReturnValue: (void *)buffer { - memcpy(buffer, [_returnValue items], [_returnValue itemSize]); + memcpy(buffer, _returnValue.items, _returnValue.itemSize); } #ifdef OF_INVOCATION_CAN_INVOKE - (void)invoke { of_invocation_invoke(self); } #endif @end Index: src/OFKernelEventObserver.m ================================================================== --- src/OFKernelEventObserver.m +++ src/OFKernelEventObserver.m @@ -112,17 +112,17 @@ _writeObjects = [[OFMutableArray alloc] init]; #ifdef OF_HAVE_PIPE if (pipe(_cancelFD)) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; #else _cancelFD[0] = _cancelFD[1] = socket(AF_INET, SOCK_DGRAM, 0); if (_cancelFD[0] == INVALID_SOCKET) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; _cancelAddr.sin_family = AF_INET; _cancelAddr.sin_port = 0; _cancelAddr.sin_addr.s_addr = inet_addr((const void *)"127.0.0.1"); @@ -132,17 +132,17 @@ # if !defined(OF_WII) && !defined(OF_NINTENDO_3DS) if (bind(_cancelFD[0], (struct sockaddr *)&_cancelAddr, sizeof(_cancelAddr)) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; cancelAddrLen = sizeof(_cancelAddr); if (of_getsockname(_cancelFD[0], (struct sockaddr *)&_cancelAddr, &cancelAddrLen) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; # else for (;;) { uint16_t rnd = 0; int ret; @@ -157,11 +157,11 @@ if (ret == 0) break; if (of_socket_errno() != EADDRINUSE) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } # endif #endif #ifdef OF_HAVE_THREADS @@ -306,15 +306,15 @@ #ifdef OF_HAVE_THREADS [_mutex lock]; @try { #endif - int *queueActions = [_queueActions items]; - id const *queueObjects = [_queueObjects objects]; - size_t count = [_queueActions count]; + const int *queueActions = _queueActions.items; + id const *queueObjects = _queueObjects.objects; + size_t count = _queueActions.count; - OF_ENSURE([_queueObjects count] == count); + OF_ENSURE(_queueObjects.count == count); for (size_t i = 0; i < count; i++) { int action = queueActions[i]; id object = queueObjects[i]; @@ -410,11 +410,11 @@ OF_UNRECOGNIZED_SELECTOR } - (void)observeUntilDate: (OFDate *)date { - [self observeForTimeInterval: [date timeIntervalSinceNow]]; + [self observeForTimeInterval: date.timeIntervalSinceNow]; } - (void)cancel { #ifdef OF_HAVE_PIPE Index: src/OFKernelEventObserver_epoll.m ================================================================== --- src/OFKernelEventObserver_epoll.m +++ src/OFKernelEventObserver_epoll.m @@ -53,17 +53,17 @@ struct epoll_event event; #ifdef HAVE_EPOLL_CREATE1 if ((_epfd = epoll_create1(EPOLL_CLOEXEC)) == -1) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; #else int flags; if ((_epfd = epoll_create(1)) == -1) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; if ((flags = fcntl(_epfd, F_GETFD, 0)) != -1) fcntl(_epfd, F_SETFD, flags | FD_CLOEXEC); #endif @@ -75,11 +75,11 @@ event.events = EPOLLIN; event.data.ptr = [OFNull null]; if (epoll_ctl(_epfd, EPOLL_CTL_ADD, _cancelFD[0], &event) == -1) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } @catch (id e) { [self release]; @throw e; } @@ -153,32 +153,32 @@ } - (void)of_addObjectForReading: (id )object { [self of_addObject: object - fileDescriptor: [object fileDescriptorForReading] + fileDescriptor: object.fileDescriptorForReading events: EPOLLIN]; } - (void)of_addObjectForWriting: (id )object { [self of_addObject: object - fileDescriptor: [object fileDescriptorForWriting] + fileDescriptor: object.fileDescriptorForWriting events: EPOLLOUT]; } - (void)of_removeObjectForReading: (id )object { [self of_removeObject: object - fileDescriptor: [object fileDescriptorForReading] + fileDescriptor: object.fileDescriptorForReading events: EPOLLIN]; } - (void)of_removeObjectForWriting: (id )object { [self of_removeObject: object - fileDescriptor: [object fileDescriptorForWriting] + fileDescriptor: object.fileDescriptorForWriting events: EPOLLOUT]; } - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { Index: src/OFKernelEventObserver_kqueue.m ================================================================== --- src/OFKernelEventObserver_kqueue.m +++ src/OFKernelEventObserver_kqueue.m @@ -53,27 +53,27 @@ struct kevent event; #ifdef HAVE_KQUEUE1 if ((_kernelQueue = kqueue1(O_CLOEXEC)) == -1) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; #else int flags; if ((_kernelQueue = kqueue()) == -1) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; if ((flags = fcntl(_kernelQueue, F_GETFD, 0)) != -1) fcntl(_kernelQueue, F_SETFD, flags | FD_CLOEXEC); #endif EV_SET(&event, _cancelFD[0], EVFILT_READ, EV_ADD, 0, 0, 0); if (kevent(_kernelQueue, &event, 1, NULL, 0, NULL) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } @catch (id e) { [self release]; @throw e; } @@ -90,11 +90,11 @@ - (void)of_addObjectForReading: (id )object { struct kevent event; memset(&event, 0, sizeof(event)); - event.ident = [object fileDescriptorForReading]; + event.ident = object.fileDescriptorForReading; event.filter = EVFILT_READ; event.flags = EV_ADD; #ifndef OF_NETBSD event.udata = object; #else @@ -109,11 +109,11 @@ - (void)of_addObjectForWriting: (id )object { struct kevent event; memset(&event, 0, sizeof(event)); - event.ident = [object fileDescriptorForWriting]; + event.ident = object.fileDescriptorForWriting; event.filter = EVFILT_WRITE; event.flags = EV_ADD; #ifndef OF_NETBSD event.udata = object; #else @@ -128,11 +128,11 @@ - (void)of_removeObjectForReading: (id )object { struct kevent event; memset(&event, 0, sizeof(event)); - event.ident = [object fileDescriptorForReading]; + event.ident = object.fileDescriptorForReading; event.filter = EVFILT_READ; event.flags = EV_DELETE; if (kevent(_kernelQueue, &event, 1, NULL, 0, NULL) != 0) @throw [OFObserveFailedException exceptionWithObserver: self @@ -142,11 +142,11 @@ - (void)of_removeObjectForWriting: (id )object { struct kevent event; memset(&event, 0, sizeof(event)); - event.ident = [object fileDescriptorForWriting]; + event.ident = object.fileDescriptorForWriting; event.filter = EVFILT_WRITE; event.flags = EV_DELETE; if (kevent(_kernelQueue, &event, 1, NULL, 0, NULL) != 0) @throw [OFObserveFailedException exceptionWithObserver: self Index: src/OFKernelEventObserver_poll.m ================================================================== --- src/OFKernelEventObserver_poll.m +++ src/OFKernelEventObserver_poll.m @@ -73,12 +73,12 @@ - (void)of_addObject: (id)object fileDescriptor: (int)fd events: (short)events { - struct pollfd *FDs = [_FDs items]; - size_t count = [_FDs count]; + struct pollfd *FDs = _FDs.mutableItems; + size_t count = _FDs.count; bool found = false; for (size_t i = 0; i < count; i++) { if (FDs[i].fd == fd) { FDs[i].events |= events; @@ -104,12 +104,12 @@ - (void)of_removeObject: (id)object fileDescriptor: (int)fd events: (short)events { - struct pollfd *FDs = [_FDs items]; - size_t nFDs = [_FDs count]; + struct pollfd *FDs = _FDs.mutableItems; + size_t nFDs = _FDs.count; for (size_t i = 0; i < nFDs; i++) { if (FDs[i].fd == fd) { FDs[i].events &= ~events; @@ -127,32 +127,32 @@ } - (void)of_addObjectForReading: (id )object { [self of_addObject: object - fileDescriptor: [object fileDescriptorForReading] + fileDescriptor: object.fileDescriptorForReading events: POLLIN]; } - (void)of_addObjectForWriting: (id )object { [self of_addObject: object - fileDescriptor: [object fileDescriptorForWriting] + fileDescriptor: object.fileDescriptorForWriting events: POLLOUT]; } - (void)of_removeObjectForReading: (id )object { [self of_removeObject: object - fileDescriptor: [object fileDescriptorForReading] + fileDescriptor: object.fileDescriptorForReading events: POLLIN]; } - (void)of_removeObjectForWriting: (id )object { [self of_removeObject: object - fileDescriptor: [object fileDescriptorForWriting] + fileDescriptor: object.fileDescriptorForWriting events: POLLOUT]; } - (void)observeForTimeInterval: (of_time_interval_t)timeInterval { @@ -163,12 +163,12 @@ [self of_processQueue]; if ([self of_processReadBuffers]) return; - FDs = [_FDs items]; - nFDs = [_FDs count]; + FDs = _FDs.mutableItems; + nFDs = _FDs.count; #ifdef OPEN_MAX if (nFDs > OPEN_MAX) @throw [OFOutOfRangeException exception]; #endif Index: src/OFKernelEventObserver_select.m ================================================================== --- src/OFKernelEventObserver_select.m +++ src/OFKernelEventObserver_select.m @@ -49,11 +49,11 @@ self = [super init]; #ifndef OF_WINDOWS if (_cancelFD[0] >= (int)FD_SETSIZE) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; #endif FD_ZERO(&_readFDs); FD_ZERO(&_writeFDs); FD_SET(_cancelFD[0], &_readFDs); @@ -66,11 +66,11 @@ return self; } - (void)of_addObjectForReading: (id )object { - int fd = [object fileDescriptorForReading]; + int fd = object.fileDescriptorForReading; if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS @@ -84,11 +84,11 @@ FD_SET((of_socket_t)fd, &_readFDs); } - (void)of_addObjectForWriting: (id )object { - int fd = [object fileDescriptorForWriting]; + int fd = object.fileDescriptorForWriting; if (fd < 0 || fd > INT_MAX - 1) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS @@ -104,11 +104,11 @@ - (void)of_removeObjectForReading: (id )object { /* TODO: Adjust _maxFD */ - int fd = [object fileDescriptorForReading]; + int fd = object.fileDescriptorForReading; if (fd < 0) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS @@ -121,11 +121,11 @@ - (void)of_removeObjectForWriting: (id )object { /* TODO: Adjust _maxFD */ - int fd = [object fileDescriptorForWriting]; + int fd = object.fileDescriptorForWriting; if (fd < 0) @throw [OFOutOfRangeException exception]; #ifndef OF_WINDOWS @@ -187,12 +187,12 @@ OF_ENSURE(recvfrom(_cancelFD[0], (void *)&buffer, 1, 0, NULL, NULL) == 1); #endif } - objects = [_readObjects objects]; - count = [_readObjects count]; + objects = _readObjects.objects; + count = _readObjects.count; for (size_t i = 0; i < count; i++) { void *pool = objc_autoreleasePoolPush(); int fd = [objects[i] fileDescriptorForReading]; @@ -202,12 +202,12 @@ [_delegate objectIsReadyForReading: objects[i]]; objc_autoreleasePoolPop(pool); } - objects = [_writeObjects objects]; - count = [_writeObjects count]; + objects = _writeObjects.objects; + count = _writeObjects.count; for (size_t i = 0; i < count; i++) { void *pool = objc_autoreleasePoolPush(); int fd = [objects[i] fileDescriptorForWriting]; Index: src/OFLHAArchive.h ================================================================== --- src/OFLHAArchive.h +++ src/OFLHAArchive.h @@ -29,18 +29,18 @@ * * @brief A class for accessing and manipulating LHA files. */ @interface OFLHAArchive: OFObject { - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; enum { OF_LHA_ARCHIVE_MODE_READ, OF_LHA_ARCHIVE_MODE_WRITE, OF_LHA_ARCHIVE_MODE_APPEND } _mode; of_string_encoding_t _encoding; - OF_KINDOF(OFStream *) _Nullable _lastReturnedStream; + OFStream *_Nullable _lastReturnedStream; } /*! * @brief The encoding to use for the archive. Defaults to ISO 8859-1. */ @@ -65,11 +65,11 @@ * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFLHAArchive */ -+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; #ifdef OF_HAVE_FILES /*! * @brief Creates a new OFLHAArchive object with the specified file. @@ -95,11 +95,11 @@ * @param mode The mode for the LHA file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFLHAArchive */ -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; #ifdef OF_HAVE_FILES /*! * @brief Initializes an already allocated OFLHAArchive object with the Index: src/OFLHAArchive.m ================================================================== --- src/OFLHAArchive.m +++ src/OFLHAArchive.m @@ -38,42 +38,42 @@ #import "OFTruncatedDataException.h" #import "OFWriteFailedException.h" @interface OFLHAArchive_FileReadStream: OFStream { - OF_KINDOF(OFStream *) _stream; - OF_KINDOF(OFStream *) _decompressedStream; + OFStream *_stream; + OFStream *_decompressedStream; OFLHAArchiveEntry *_entry; uint32_t _toRead, _bytesConsumed; uint16_t _CRC16; bool _atEndOfStream, _skipped; } -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFStream *)stream entry: (OFLHAArchiveEntry *)entry; - (void)of_skip; @end @interface OFLHAArchive_FileWriteStream: OFStream { OFMutableLHAArchiveEntry *_entry; of_string_encoding_t _encoding; - OF_KINDOF(OFStream *) _stream; + OFSeekableStream *_stream; of_offset_t _headerOffset; uint32_t _bytesWritten; uint16_t _CRC16; } -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFSeekableStream *)stream entry: (OFLHAArchiveEntry *)entry encoding: (of_string_encoding_t)encoding; @end @implementation OFLHAArchive @synthesize encoding = _encoding; -+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } @@ -90,11 +90,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { @@ -113,12 +113,12 @@ _mode == OF_LHA_ARCHIVE_MODE_APPEND) && ![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; if (_mode == OF_LHA_ARCHIVE_MODE_APPEND) - [_stream seekToOffset: 0 - whence: SEEK_END]; + [(OFSeekableStream *)_stream seekToOffset: 0 + whence: SEEK_END]; _encoding = OF_STRING_ENCODING_ISO_8859_1; } @catch (id e) { [self release]; @throw e; @@ -165,17 +165,17 @@ size_t headerLen; if (_mode != OF_LHA_ARCHIVE_MODE_READ) @throw [OFInvalidArgumentException exception]; - [_lastReturnedStream of_skip]; + [(OFLHAArchive_FileReadStream *)_lastReturnedStream of_skip]; [_lastReturnedStream close]; [_lastReturnedStream release]; _lastReturnedStream = nil; for (headerLen = 0; headerLen < 21;) { - if ([_stream isAtEndOfStream]) { + if (_stream.atEndOfStream) { if (headerLen == 0) return nil; if (headerLen == 1 && header[0] == 0) return nil; @@ -205,11 +205,12 @@ @throw [OFInvalidArgumentException exception]; if (_lastReturnedStream == nil) @throw [OFInvalidArgumentException exception]; - return [[_lastReturnedStream retain] autorelease]; + return [[(OFLHAArchive_FileReadStream *)_lastReturnedStream + retain] autorelease]; } - (OFStream *) streamForWritingEntry: (OFLHAArchiveEntry *)entry { @@ -217,11 +218,11 @@ if (_mode != OF_LHA_ARCHIVE_MODE_WRITE && _mode != OF_LHA_ARCHIVE_MODE_APPEND) @throw [OFInvalidArgumentException exception]; - compressionMethod = [entry compressionMethod]; + compressionMethod = entry.compressionMethod; if (![compressionMethod isEqual: @"-lh0-"] && ![compressionMethod isEqual: @"-lhd-"]) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; @@ -229,15 +230,16 @@ [_lastReturnedStream close]; [_lastReturnedStream release]; _lastReturnedStream = nil; _lastReturnedStream = [[OFLHAArchive_FileWriteStream alloc] - of_initWithStream: _stream + of_initWithStream: (OFSeekableStream *)_stream entry: entry encoding: _encoding]; - return [[_lastReturnedStream retain] autorelease]; + return [[(OFLHAArchive_FileWriteStream *)_lastReturnedStream + retain] autorelease]; } - (void)close { if (_stream == nil) @@ -251,21 +253,21 @@ _stream = nil; } @end @implementation OFLHAArchive_FileReadStream -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFStream *)stream entry: (OFLHAArchiveEntry *)entry { self = [super init]; @try { OFString *compressionMethod; _stream = [stream retain]; - compressionMethod = [entry compressionMethod]; + compressionMethod = entry.compressionMethod; if ([compressionMethod isEqual: @"-lh4-"] || [compressionMethod isEqual: @"-lh5-"]) _decompressedStream = [[OFLHAArchive_LHStream alloc] of_initWithStream: stream @@ -283,11 +285,11 @@ dictionaryBits: 17]; else _decompressedStream = [stream retain]; _entry = [entry copy]; - _toRead = [entry uncompressedSize]; + _toRead = entry.uncompressedSize; } @catch (id e) { [self release]; @throw e; } @@ -322,12 +324,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; - if ([_stream isAtEndOfStream] && - ![_decompressedStream hasDataInReadBuffer]) + if (_stream.atEndOfStream && !_decompressedStream.hasDataInReadBuffer) @throw [OFTruncatedDataException exception]; if (length > _toRead) length = _toRead; @@ -338,15 +339,15 @@ _CRC16 = of_crc16(_CRC16, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; - if (_CRC16 != [_entry CRC16]) { + if (_CRC16 != _entry.CRC16) { OFString *actualChecksum = [OFString stringWithFormat: @"%04" PRIX16, _CRC16]; OFString *expectedChecksum = [OFString stringWithFormat: - @"%04" PRIX16, [_entry CRC16]]; + @"%04" PRIX16, _entry.CRC16]; @throw [OFChecksumMismatchException exceptionWithActualChecksum: actualChecksum expectedChecksum: expectedChecksum]; } @@ -355,22 +356,23 @@ return ret; } - (bool)hasDataInReadBuffer { - return ([super hasDataInReadBuffer] || - [_decompressedStream hasDataInReadBuffer]); + return (super.hasDataInReadBuffer || + _decompressedStream.hasDataInReadBuffer); } - (int)fileDescriptorForReading { - return [_decompressedStream fileDescriptorForReading]; + return ((id )_decompressedStream) + .fileDescriptorForReading; } - (void)of_skip { - OF_KINDOF(OFStream *) stream; + OFStream *stream; uint32_t toRead; if (_stream == nil || _skipped) return; @@ -381,22 +383,23 @@ * Get the number of consumed bytes and directly read from the * compressed stream, to make skipping much faster. */ if ([_decompressedStream isKindOfClass: [OFLHAArchive_LHStream class]]) { - OFLHAArchive_LHStream *LHStream = _decompressedStream; + OFLHAArchive_LHStream *LHStream = + (OFLHAArchive_LHStream *)_decompressedStream; [LHStream close]; - toRead = [_entry compressedSize] - LHStream->_bytesConsumed; + toRead = _entry.compressedSize - LHStream->_bytesConsumed; stream = _stream; } if ([stream isKindOfClass: [OFSeekableStream class]] && (sizeof(of_offset_t) > 4 || toRead < INT32_MAX)) - [stream seekToOffset: (of_offset_t)toRead - whence: SEEK_CUR]; + [(OFSeekableStream *)stream seekToOffset: (of_offset_t)toRead + whence: SEEK_CUR]; else { while (toRead > 0) { char buffer[512]; size_t min = toRead; @@ -425,11 +428,11 @@ [super close]; } @end @implementation OFLHAArchive_FileWriteStream -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFSeekableStream *)stream entry: (OFLHAArchiveEntry *)entry encoding: (of_string_encoding_t)encoding { self = [super init]; @@ -477,12 +480,12 @@ @try { bytesWritten = (uint32_t)[_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { - _bytesWritten += [e bytesWritten]; - _CRC16 = of_crc16(_CRC16, buffer, [e bytesWritten]); + _bytesWritten += e.bytesWritten; + _CRC16 = of_crc16(_CRC16, buffer, e.bytesWritten); @throw e; } _bytesWritten += (uint32_t)bytesWritten; @@ -494,28 +497,29 @@ - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; - return [_stream isAtEndOfStream]; + return _stream.atEndOfStream; } - (int)fileDescriptorForWriting { - return [_stream fileDescriptorForWriting]; + return ((id )_stream) + .fileDescriptorForWriting; } - (void)close { of_offset_t offset; if (_stream == nil) return; - [_entry setUncompressedSize: _bytesWritten]; - [_entry setCompressedSize: _bytesWritten]; - [_entry setCRC16: _CRC16]; + _entry.uncompressedSize = _bytesWritten; + _entry.compressedSize = _bytesWritten; + _entry.CRC16 = _CRC16; offset = [_stream seekToOffset: 0 whence:SEEK_CUR]; [_stream seekToOffset: _headerOffset whence: SEEK_SET]; Index: src/OFLHAArchiveEntry.m ================================================================== --- src/OFLHAArchiveEntry.m +++ src/OFLHAArchiveEntry.m @@ -62,11 +62,11 @@ { [entry->_fileName release]; entry->_fileName = nil; entry->_fileName = [[OFString alloc] - initWithCString: (char *)[extension items] + 1 + initWithCString: (char *)extension.items + 1 encoding: encoding length: [extension count] - 1]; } static void @@ -73,12 +73,12 @@ parseDirectoryNameExtension(OFLHAArchiveEntry *entry, OFData *extension, of_string_encoding_t encoding) { void *pool = objc_autoreleasePoolPush(); OFMutableData *data = [[extension mutableCopy] autorelease]; - char *items = [data items]; - size_t count = [data count]; + char *items = data.mutableItems; + size_t count = data.count; OFMutableString *directoryName; for (size_t i = 1; i < count; i++) if (items[i] == '\xFF') items[i] = '/'; @@ -106,25 +106,25 @@ { [entry->_fileComment release]; entry->_fileComment = nil; entry->_fileComment = [[OFString alloc] - initWithCString: (char *)[extension items] + 1 + initWithCString: (char *)extension.items + 1 encoding: encoding - length: [extension count] - 1]; + length: extension.count - 1]; } static void parsePermissionsExtension(OFLHAArchiveEntry *entry, OFData *extension, of_string_encoding_t encoding) { uint16_t mode; - if ([extension count] != 3) + if (extension.count != 3) @throw [OFInvalidFormatException exception]; - memcpy(&mode, (char *)[extension items] + 1, 2); + memcpy(&mode, (char *)extension.items + 1, 2); mode = OF_BSWAP16_IF_BE(mode); [entry->_mode release]; entry->_mode = nil; @@ -135,17 +135,17 @@ parseGIDUIDExtension(OFLHAArchiveEntry *entry, OFData *extension, of_string_encoding_t encoding) { uint16_t UID, GID; - if ([extension count] != 5) + if (extension.count != 5) @throw [OFInvalidFormatException exception]; - memcpy(&GID, (char *)[extension items] + 1, 2); + memcpy(&GID, (char *)extension.items + 1, 2); GID = OF_BSWAP16_IF_BE(GID); - memcpy(&UID, (char *)[extension items] + 3, 2); + memcpy(&UID, (char *)extension.items + 3, 2); UID = OF_BSWAP16_IF_BE(UID); [entry->_GID release]; entry->_GID = nil; @@ -162,13 +162,13 @@ { [entry->_group release]; entry->_group = nil; entry->_group = [[OFString alloc] - initWithCString: (char *)[extension items] + 1 + initWithCString: (char *)extension.items + 1 encoding: encoding - length: [extension count] - 1]; + length: extension.count - 1]; } static void parseOwnerExtension(OFLHAArchiveEntry *entry, OFData *extension, of_string_encoding_t encoding) @@ -175,25 +175,25 @@ { [entry->_owner release]; entry->_owner = nil; entry->_owner = [[OFString alloc] - initWithCString: (char *)[extension items] + 1 + initWithCString: (char *)extension.items + 1 encoding: encoding - length: [extension count] - 1]; + length: extension.count - 1]; } static void parseModificationDateExtension(OFLHAArchiveEntry *entry, OFData *extension, of_string_encoding_t encoding) { uint32_t modificationDate; - if ([extension count] != 5) + if (extension.count != 5) @throw [OFInvalidFormatException exception]; - memcpy(&modificationDate, (char *)[extension items] + 1, 4); + memcpy(&modificationDate, (char *)extension.items + 1, 4); modificationDate = OF_BSWAP32_IF_BE(modificationDate); [entry->_modificationDate release]; entry->_modificationDate = nil; @@ -289,12 +289,12 @@ count: [entry->_directoryName cStringLengthWithEncoding: encoding]]; [data addItems: [entry->_fileName cStringWithEncoding: encoding] count: [entry->_fileName cStringLengthWithEncoding: encoding]]; - cString = [data items]; - length = [data count]; + cString = data.mutableItems; + length = data.count; pos = 0; for (size_t i = 0; i < length; i++) { if (cString[i] == '/' || cString[i] == '\\') { cString[i] = '\xFF'; @@ -593,11 +593,11 @@ tmp32 = OF_BSWAP32_IF_BE(_uncompressedSize); [data addItems: &tmp32 count: sizeof(tmp32)]; - tmp32 = OF_BSWAP32_IF_BE((uint32_t)[_date timeIntervalSince1970]); + tmp32 = OF_BSWAP32_IF_BE((uint32_t)_date.timeIntervalSince1970); [data addItems: &tmp32 count: sizeof(tmp32)]; /* Reserved */ [data increaseCountBy: 1]; @@ -655,11 +655,11 @@ tmp16 = OF_BSWAP16_IF_BE(5); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x50"]; - tmp16 = OF_BSWAP16_IF_BE([_mode uInt16Value]); + tmp16 = OF_BSWAP16_IF_BE(_mode.uInt16Value); [data addItems: &tmp16 count: sizeof(tmp16)]; } if (_UID != nil || _GID != nil) { @@ -669,15 +669,15 @@ tmp16 = OF_BSWAP16_IF_BE(7); [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x51"]; - tmp16 = OF_BSWAP16_IF_BE([_GID uInt16Value]); + tmp16 = OF_BSWAP16_IF_BE(_GID.uInt16Value); [data addItems: &tmp16 count: sizeof(tmp16)]; - tmp16 = OF_BSWAP16_IF_BE([_UID uInt16Value]); + tmp16 = OF_BSWAP16_IF_BE(_UID.uInt16Value); [data addItems: &tmp16 count: sizeof(tmp16)]; } if (_group != nil) { @@ -715,58 +715,58 @@ [data addItems: &tmp16 count: sizeof(tmp16)]; [data addItem: "\x54"]; tmp32 = OF_BSWAP32_IF_BE( - (uint32_t)[_modificationDate timeIntervalSince1970]); + (uint32_t)_modificationDate.timeIntervalSince1970); [data addItems: &tmp32 count: sizeof(tmp32)]; } for (OFData *extension in _extensions) { - size_t extensionLength = [extension count]; + size_t extensionLength = extension.count; - if ([extension itemSize] != 1) + if (extension.itemSize != 1) @throw [OFInvalidArgumentException exception]; if (extensionLength > UINT16_MAX - 2) @throw [OFOutOfRangeException exception]; tmp16 = OF_BSWAP16_IF_BE((uint16_t)extensionLength + 2); [data addItems: &tmp16 count: sizeof(tmp16)]; - [data addItems: [extension items] - count: [extension count]]; + [data addItems: extension.items + count: extension.count]; } /* Zero-length extension to terminate */ [data increaseCountBy: 2]; - headerSize = [data count]; + headerSize = data.count; if (headerSize > UINT16_MAX) @throw [OFOutOfRangeException exception]; /* Now fill in the size and CRC16 for the entire header */ tmp16 = OF_BSWAP16_IF_BE(headerSize); - memcpy([data itemAtIndex: 0], &tmp16, sizeof(tmp16)); + memcpy([data mutableItemAtIndex: 0], &tmp16, sizeof(tmp16)); - tmp16 = OF_BSWAP16_IF_BE(of_crc16(0, [data items], [data count])); - memcpy([data itemAtIndex: 27], &tmp16, sizeof(tmp16)); + tmp16 = of_crc16(0, data.items, data.count); + tmp16 = OF_BSWAP16_IF_BE(tmp16); + memcpy([data mutableItemAtIndex: 27], &tmp16, sizeof(tmp16)); [stream writeData: data]; objc_autoreleasePoolPop(pool); } - (OFString *)description { void *pool = objc_autoreleasePoolPush(); - OFString *mode = (_mode == nil - ? nil - : [OFString stringWithFormat: @"%" PRIo16, [_mode uInt16Value]]); - OFString *extensions = [[_extensions description] + OFString *mode = (_mode == nil ? nil + : [OFString stringWithFormat: @"%" PRIo16, _mode.uInt16Value]); + OFString *extensions = [_extensions.description stringByReplacingOccurrencesOfString: @"\n" withString: @"\n\t"]; OFString *ret = [OFString stringWithFormat: @"<%@:\n" @"\tFile name = %@\n" @@ -784,11 +784,11 @@ @"\tOwner = %@\n" @"\tGroup = %@\n" @"\tModification date = %@\n" @"\tExtensions: %@" @">", - [self class], [self fileName], _compressionMethod, _compressedSize, + self.class, self.fileName, _compressionMethod, _compressedSize, _uncompressedSize, _date, _headerLevel, _CRC16, _operatingSystemIdentifier, _fileComment, mode, _UID, _GID, _owner, _group, _modificationDate, extensions]; [ret retain]; Index: src/OFLHAArchive_LHStream.h ================================================================== --- src/OFLHAArchive_LHStream.h +++ src/OFLHAArchive_LHStream.h @@ -22,11 +22,11 @@ #define OF_LHA_ARCHIVE_LHSTREAM_BUFFER_SIZE 4096 @interface OFLHAArchive_LHStream: OFStream { @public - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; uint8_t _distanceBits, _dictionaryBits; unsigned char _buffer[OF_LHA_ARCHIVE_LHSTREAM_BUFFER_SIZE]; uint32_t _bytesConsumed; uint16_t _bufferIndex, _bufferLength; uint8_t _byte; @@ -43,11 +43,11 @@ uint8_t *_Nullable _codesLengths; uint16_t _length; uint32_t _distance; } -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFStream *)stream distanceBits: (uint8_t)distanceBits dictionaryBits: (uint8_t)dictionaryBits; @end OF_ASSUME_NONNULL_END Index: src/OFLHAArchive_LHStream.m ================================================================== --- src/OFLHAArchive_LHStream.m +++ src/OFLHAArchive_LHStream.m @@ -88,11 +88,11 @@ return true; } @implementation OFLHAArchive_LHStream -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFStream *)stream distanceBits: (uint8_t)distanceBits dictionaryBits: (uint8_t)dictionaryBits { self = [super init]; @@ -139,11 +139,11 @@ size_t bytesWritten = 0; if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; - if ([_stream isAtEndOfStream] && _bufferLength - _bufferIndex == 0 && + if (_stream.atEndOfStream && _bufferLength - _bufferIndex == 0 && _state == STATE_BLOCK_HEADER) return 0; start: switch ((enum state)_state) { @@ -492,22 +492,23 @@ - (bool)lowlevelIsAtEndOfStream { if (_stream == nil) @throw [OFNotOpenException exceptionWithObject: self]; - return ([_stream isAtEndOfStream] && + return (_stream.atEndOfStream && _bufferLength - _bufferIndex == 0 && _state == STATE_BLOCK_HEADER); } - (int)fileDescriptorForReading { - return [_stream fileDescriptorForReading]; + return ((id )_stream) + .fileDescriptorForReading; } - (bool)hasDataInReadBuffer { - return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer] || + return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer || _bufferLength - _bufferIndex > 0); } - (void)close { Index: src/OFList.m ================================================================== --- src/OFList.m +++ src/OFList.m @@ -42,19 +42,19 @@ self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *child in [element elementsForNamespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); - [self appendObject: [child objectByDeserializing]]; + [self appendObject: child.objectByDeserializing]; objc_autoreleasePoolPop(pool2); } objc_autoreleasePoolPop(pool); @@ -214,14 +214,14 @@ if (![object isKindOfClass: [OFList class]]) return false; list = object; - if ([list count] != _count) + if (list.count != _count) return false; - for (iter = _firstListObject, iter2 = [list firstListObject]; + for (iter = _firstListObject, iter2 = list.firstListObject; iter != NULL && iter2 != NULL; iter = iter->next, iter2 = iter2->next) if (![iter->object isEqual: iter2->object]) return false; @@ -354,11 +354,11 @@ } - (OFXMLElement *)XMLElementBySerializing { OFXMLElement *element = - [OFXMLElement elementWithName: [self className] + [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; for (of_list_object_t *iter = _firstListObject; iter != NULL; iter = iter->next) { void *pool = objc_autoreleasePoolPush(); @@ -413,11 +413,11 @@ mutationsPointer: (unsigned long *)mutationsPtr { self = [super init]; _list = [list retain]; - _current = [list firstListObject]; + _current = _list.firstListObject; _mutations = *mutationsPtr; _mutationsPtr = mutationsPtr; return self; } @@ -450,8 +450,8 @@ { if (*_mutationsPtr != _mutations) @throw [OFEnumerationMutationException exceptionWithObject: _list]; - _current = [_list firstListObject]; + _current = _list.firstListObject; } @end Index: src/OFLocale.m ================================================================== --- src/OFLocale.m +++ src/OFLocale.m @@ -147,26 +147,26 @@ return currentLocale; } + (OFString *)language { - return [currentLocale language]; + return currentLocale.language; } + (OFString *)territory { - return [currentLocale territory]; + return currentLocale.territory; } + (of_string_encoding_t)encoding { - return [currentLocale encoding]; + return currentLocale.encoding; } + (OFString *)decimalPoint { - return [currentLocale decimalPoint]; + return currentLocale.decimalPoint; } #ifdef OF_HAVE_FILES + (void)addLanguageDirectory: (OFString *)path { @@ -182,11 +182,11 @@ #ifndef OF_AMIGAOS char *locale, *messagesLocale = NULL; if (currentLocale != nil) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; _encoding = OF_STRING_ENCODING_UTF_8; _decimalPoint = @"."; _localizedStrings = [[OFMutableArray alloc] init]; @@ -321,20 +321,19 @@ } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } - language = [_language lowercaseString]; - territory = [_territory lowercaseString]; + language = _language.lowercaseString; + territory = _territory.lowercaseString; if (territory == nil) territory = @""; languageFile = [[map objectForKey: language] objectForKey: territory]; if (languageFile == nil) - languageFile = [[map objectForKey: language] - objectForKey: @""]; + languageFile = [[map objectForKey: language] objectForKey: @""]; if (languageFile == nil) { objc_autoreleasePoolPop(pool); return; } @@ -387,12 +386,12 @@ UTF8StringLength = [string UTF8StringLength]; break; } if (UTF8String == NULL) { - UTF8String = [fallback UTF8String]; - UTF8StringLength = [fallback UTF8StringLength]; + UTF8String = fallback.UTF8String; + UTF8StringLength = fallback.UTF8StringLength; } state = 0; last = 0; for (size_t i = 0; i < UTF8StringLength; i++) { Index: src/OFMD5Hash.m ================================================================== --- src/OFMD5Hash.m +++ src/OFMD5Hash.m @@ -142,11 +142,11 @@ self = [super init]; @try { _iVarsData = [[OFSecureData alloc] initWithCount: sizeof(*_iVars)]; - _iVars = [_iVarsData items]; + _iVars = _iVarsData.mutableItems; [self of_resetState]; } @catch (id e) { [self release]; @throw e; @@ -170,11 +170,11 @@ - (id)copy { OFMD5Hash *copy = [[OFMD5Hash alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; - copy->_iVars = [copy->_iVarsData items]; + copy->_iVars = copy->_iVarsData.mutableItems; copy->_calculated = _calculated; return copy; } Index: src/OFMessagePackExtension.m ================================================================== --- src/OFMessagePackExtension.m +++ src/OFMessagePackExtension.m @@ -42,11 +42,11 @@ data: (OFData *)data { self = [super init]; @try { - if (data == nil || [data itemSize] != 1) + if (data == nil || data.itemSize != 1) @throw [OFInvalidArgumentException exception]; _type = type; _data = [data copy]; } @catch (id e) { @@ -66,11 +66,11 @@ - (OFData *)messagePackRepresentation { OFMutableData *ret; uint8_t prefix; - size_t count = [_data count]; + size_t count = _data.count; if (count == 1) { ret = [OFMutableData dataWithCapacity: 3]; prefix = 0xD4; @@ -143,12 +143,12 @@ count: 4]; [ret addItem: &_type]; } - [ret addItems: [_data items] - count: [_data count]]; + [ret addItems: _data.items + count: _data.count]; [ret makeImmutable]; return ret; } @@ -182,11 +182,11 @@ uint32_t hash; OF_HASH_INIT(hash); OF_HASH_ADD(hash, (uint8_t)_type); - OF_HASH_ADD_HASH(hash, [_data hash]); + OF_HASH_ADD_HASH(hash, _data.hash); OF_HASH_FINALIZE(hash); return hash; } Index: src/OFMethodSignature.m ================================================================== --- src/OFMethodSignature.m +++ src/OFMethodSignature.m @@ -677,21 +677,21 @@ [super dealloc]; } - (size_t)numberOfArguments { - return [_typesPointers count] - 1; + return _typesPointers.count - 1; } - (const char *)methodReturnType { - return *(const char **)[_typesPointers firstItem]; + return *(const char **)_typesPointers.firstItem; } - (size_t)frameLength { - return *(size_t *)[_offsets firstItem]; + return *(size_t *)_offsets.firstItem; } - (const char *)argumentTypeAtIndex: (size_t)idx { return *(const char **)[_typesPointers itemAtIndex: idx + 1]; Index: src/OFMutableArray.m ================================================================== --- src/OFMutableArray.m +++ src/OFMutableArray.m @@ -258,17 +258,17 @@ } - (void)addObject: (id)object { [self insertObject: object - atIndex: [self count]]; + atIndex: self.count]; } - (void)addObjectsFromArray: (OFArray *)array { [self insertObjectsFromArray: array - atIndex: [self count]]; + atIndex: self.count]; } - (void)insertObject: (id)object atIndex: (size_t)idx { @@ -304,11 +304,11 @@ size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; - count = [self count]; + count = self.count; for (size_t i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: oldObject]) { [self replaceObjectAtIndex: i withObject: newObject]; @@ -323,11 +323,11 @@ size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; - count = [self count]; + count = self.count; for (size_t i = 0; i < count; i++) { if ([self objectAtIndex: i] == oldObject) { [self replaceObjectAtIndex: i withObject: newObject]; @@ -347,11 +347,11 @@ size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; - count = [self count]; + count = self.count; for (size_t i = 0; i < count; i++) { if ([[self objectAtIndex: i] isEqual: object]) { [self removeObjectAtIndex: i]; @@ -365,11 +365,11 @@ size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; - count = [self count]; + count = self.count; for (size_t i = 0; i < count; i++) { if ([self objectAtIndex: i] == object) { [self removeObjectAtIndex: i]; @@ -384,21 +384,21 @@ [self removeObjectAtIndex: range.location]; } - (void)removeLastObject { - size_t count = [self count]; + size_t count = self.count; if (count == 0) return; [self removeObjectAtIndex: count - 1]; } - (void)removeAllObjects { - [self removeObjectsInRange: of_range(0, [self count])]; + [self removeObjectsInRange: of_range(0, self.count)]; } #ifdef OF_HAVE_BLOCKS - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block { @@ -437,11 +437,11 @@ } - (void)sortUsingSelector: (SEL)selector options: (int)options { - size_t count = [self count]; + size_t count = self.count; if (count == 0 || count == 1) return; quicksort(self, 0, count - 1, selector, options); @@ -449,11 +449,11 @@ #ifdef OF_HAVE_BLOCKS - (void)sortUsingComparator: (of_comparator_t)comparator options: (int)options { - size_t count = [self count]; + size_t count = self.count; if (count == 0 || count == 1) return; quicksortWithBlock(self, 0, count - 1, comparator, options); @@ -460,11 +460,11 @@ } #endif - (void)reverse { - size_t i, j, count = [self count]; + size_t i, j, count = self.count; if (count == 0 || count == 1) return; for (i = 0, j = count - 1; i < j; i++, j--) Index: src/OFMutableArray_adjacent.m ================================================================== --- src/OFMutableArray_adjacent.m +++ src/OFMutableArray_adjacent.m @@ -78,12 +78,12 @@ } - (void)insertObjectsFromArray: (OFArray *)array atIndex: (size_t)idx { - id const *objects = [array objects]; - size_t count = [array count]; + id const *objects = array.objects; + size_t count = array.count; @try { [_array insertItems: objects atIndex: idx count: count]; @@ -104,12 +104,12 @@ size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; - objects = [_array items]; - count = [_array count]; + objects = _array.mutableItems; + count = _array.count; for (size_t i = 0; i < count; i++) { if ([objects[i] isEqual: oldObject]) { [newObject retain]; [objects[i] release]; @@ -127,13 +127,13 @@ id oldObject; if (object == nil) @throw [OFInvalidArgumentException exception]; - objects = [_array items]; + objects = _array.mutableItems; - if (idx >= [_array count]) + if (idx >= _array.count) @throw [OFOutOfRangeException exception]; oldObject = objects[idx]; objects[idx] = [object retain]; [oldObject release]; @@ -146,12 +146,12 @@ size_t count; if (oldObject == nil || newObject == nil) @throw [OFInvalidArgumentException exception]; - objects = [_array items]; - count = [_array count]; + objects = _array.mutableItems; + count = _array.count; for (size_t i = 0; i < count; i++) { if (objects[i] == oldObject) { [newObject retain]; [objects[i] release]; @@ -162,18 +162,18 @@ } } - (void)removeObject: (id)object { - id *objects; + id const *objects; size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; - objects = [_array items]; - count = [_array count]; + objects = _array.items; + count = _array.count; for (size_t i = 0; i < count; i++) { if ([objects[i] isEqual: object]) { object = objects[i]; @@ -187,18 +187,18 @@ } } - (void)removeObjectIdenticalTo: (id)object { - id *objects; + id const *objects; size_t count; if (object == nil) @throw [OFInvalidArgumentException exception]; - objects = [_array items]; - count = [_array count]; + objects = _array.items; + count = _array.count; for (size_t i = 0; i < count; i++) { if (objects[i] == object) { [_array removeItemAtIndex: i]; _mutations++; @@ -221,23 +221,24 @@ #endif } - (void)removeAllObjects { - id *objects = [_array items]; - size_t count = [_array count]; + id const *objects = _array.items; + size_t count = _array.count; for (size_t i = 0; i < count; i++) [objects[i] release]; [_array removeAllItems]; } - (void)removeObjectsInRange: (of_range_t)range { - id *objects = [_array items], *copy; - size_t count = [_array count]; + id const *objects = _array.items; + size_t count = _array.count; + id *copy; if (range.length > SIZE_MAX - range.location || range.location >= count || range.length > count - range.location) @throw [OFOutOfRangeException exception]; @@ -257,11 +258,11 @@ } - (void)removeLastObject { #ifndef __clang_analyzer__ - size_t count = [_array count]; + size_t count = _array.count; id object; if (count == 0) return; @@ -274,12 +275,12 @@ } - (void)exchangeObjectAtIndex: (size_t)idx1 withObjectAtIndex: (size_t)idx2 { - id *objects = [_array items]; - size_t count = [_array count]; + id *objects = _array.mutableItems; + size_t count = _array.count; id tmp; if (idx1 >= count || idx2 >= count) @throw [OFOutOfRangeException exception]; @@ -288,12 +289,12 @@ objects[idx2] = tmp; } - (void)reverse { - id *objects = [_array items]; - size_t i, j, count = [_array count]; + id *objects = _array.mutableItems; + size_t i, j, count = _array.count; if (count == 0 || count == 1) return; for (i = 0, j = count - 1; i < j; i++, j--) { @@ -305,11 +306,11 @@ - (int)countByEnumeratingWithState: (of_fast_enumeration_state_t *)state objects: (id *)objects count: (int)count_ { - size_t count = [_array count]; + size_t count = _array.count; if (count > INT_MAX) { /* * Use the implementation from OFArray (OFMutableArray does not * have one), which is slower, but can enumerate in chunks, and @@ -324,11 +325,11 @@ if (state->state >= count) return 0; state->state = (unsigned long)count; - state->itemsPtr = [_array items]; + state->itemsPtr = _array.items; state->mutationsPtr = &_mutations; return (int)count; } @@ -340,12 +341,12 @@ } #ifdef OF_HAVE_BLOCKS - (void)enumerateObjectsUsingBlock: (of_array_enumeration_block_t)block { - id *objects = [_array items]; - size_t count = [_array count]; + id const *objects = _array.items; + size_t count = _array.count; bool stop = false; unsigned long mutations = _mutations; for (size_t i = 0; i < count && !stop; i++) { if (_mutations != mutations) @@ -356,12 +357,12 @@ } } - (void)replaceObjectsUsingBlock: (of_array_replace_block_t)block { - id *objects = [_array items]; - size_t count = [_array count]; + id *objects = _array.mutableItems; + size_t count = _array.count; unsigned long mutations = _mutations; for (size_t i = 0; i < count; i++) { id new; Index: src/OFMutableData.h ================================================================== --- src/OFMutableData.h +++ src/OFMutableData.h @@ -30,10 +30,20 @@ @interface OFMutableData: OFData { size_t _capacity; } +/*! + * @brief All items of the OFMutableData as a C array. + * + * @warning The pointer is only valid until the OFMutableData is changed! + * + * Modifying the returned array directly is allowed and will change the contents + * of the data. + */ +@property (readonly, nonatomic) void *mutableItems OF_RETURNS_INNER_POINTER; + /*! * @brief Creates a new OFMutableData with an item size of 1. * * @return A new autoreleased OFMutableData */ @@ -104,10 +114,21 @@ * @return An initialized OFMutableData */ - (instancetype)initWithItemSize: (size_t)itemSize capacity: (size_t)capacity; +/*! + * @brief Returns a specific item of the OFMutableData. + * + * Modifying the returned item directly is allowed and will change the contents + * of the data. + * + * @param index The number of the item to return + * @return The specified item of the OFMutableData + */ +- (void *)mutableItemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER; + /*! * @brief Adds an item to the OFMutableData. * * @param item A pointer to an arbitrary item */ @@ -178,54 +199,6 @@ * @brief Converts the mutable URL to an immutable URL. */ - (void)makeImmutable; @end -@interface OFMutableData (MutableRetrieving) -/* GCC does not like overriding properties with a different type. */ -#if defined(__clang__) || defined(DOXYGEN) -/*! - * @brief All items of the OFMutableData as a C array. - * - * @warning The pointer is only valid until the OFMutableData is changed! - * - * Modifying the returned array directly is allowed and will change the contents - * of the data. - */ -@property (readonly, nonatomic) void *items OF_RETURNS_INNER_POINTER; - -/*! - * @brief The first item of the OFMutableData or `NULL`. - * - * Modifying the returned item directly is allowed and will change the contents - * of the data. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *firstItem - OF_RETURNS_INNER_POINTER; - -/*! - * @brief Last item of the OFMutableData or `NULL`. - * - * Modifying the returned item directly is allowed and will change the contents - * of the data. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *lastItem - OF_RETURNS_INNER_POINTER; -#else -- (void *)items; -- (nullable void *)firstItem; -- (nullable void *)lastItem; -#endif - -/*! - * @brief Returns a specific item of the OFMutableData. - * - * Modifying the returned item directly is allowed and will change the contents - * of the data. - * - * @param index The number of the item to return - * @return The specified item of the OFMutableData - */ -- (void *)itemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER; -@end - OF_ASSUME_NONNULL_END Index: src/OFMutableData.m ================================================================== --- src/OFMutableData.m +++ src/OFMutableData.m @@ -139,10 +139,23 @@ _capacity = _count; return self; } + +- (void *)mutableItems +{ + return _items; +} + +- (void *)mutableItemAtIndex: (size_t)idx +{ + if (idx >= _count) + @throw [OFOutOfRangeException exception]; + + return _items + idx * _itemSize; +} - (OFData *)subdataWithRange: (of_range_t)range { if (range.length > SIZE_MAX - range.location || range.location + range.length > _count) Index: src/OFMutableDictionary.m ================================================================== --- src/OFMutableDictionary.m +++ src/OFMutableDictionary.m @@ -185,11 +185,11 @@ - (void)removeAllObjects { void *pool = objc_autoreleasePoolPush(); - for (id key in [self allKeys]) + for (id key in self.allKeys) [self removeObjectForKey: key]; objc_autoreleasePoolPop(pool); } Index: src/OFMutableSet.m ================================================================== --- src/OFMutableSet.m +++ src/OFMutableSet.m @@ -167,11 +167,11 @@ } - (void)intersectSet: (OFSet *)set { void *pool = objc_autoreleasePoolPush(); - size_t count = [self count]; + size_t count = self.count; id *cArray; cArray = [self allocMemoryWithSize: sizeof(id) count: count]; Index: src/OFMutableString.m ================================================================== --- src/OFMutableString.m +++ src/OFMutableString.m @@ -237,18 +237,18 @@ return [super alloc]; } #ifdef OF_HAVE_UNICODE_TABLES -- (void)of_convertWithWordStartTable: (const of_unichar_t *const[])startTable - wordMiddleTable: (const of_unichar_t *const[])middleTable +- (void)of_convertWithWordStartTable: (const of_unichar_t *const [])startTable + wordMiddleTable: (const of_unichar_t *const [])middleTable wordStartTableSize: (size_t)startTableSize wordMiddleTableSize: (size_t)middleTableSize { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t length = [self length]; + const of_unichar_t *characters = self.characters; + size_t length = self.length; bool isStart = true; for (size_t i = 0; i < length; i++) { const of_unichar_t *const *table; size_t tableSize; @@ -274,12 +274,12 @@ #else - (void)of_convertWithWordStartFunction: (char (*)(char))startFunction wordMiddleFunction: (char (*)(char))middleFunction { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t length = [self length]; + const of_unichar_t *characters = self.characters; + size_t length = self.length; bool isStart = true; for (size_t i = 0; i < length; i++) { char (*function)(char) = (isStart ? startFunction : middleFunction); @@ -312,11 +312,11 @@ } - (void)appendString: (OFString *)string { [self insertString: string - atIndex: [self length]]; + atIndex: self.length]; } - (void)appendCharacters: (const of_unichar_t *)characters length: (size_t)length { @@ -389,11 +389,11 @@ int UTF8StringLength; if (format == nil) @throw [OFInvalidArgumentException exception]; - if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String], + if ((UTF8StringLength = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { [self appendUTF8String: UTF8String @@ -409,11 +409,11 @@ atIndex: 0]; } - (void)reverse { - size_t i, j, length = [self length]; + size_t i, j, length = self.length; for (i = 0, j = length - 1; i < length / 2; i++, j--) { of_unichar_t tmp = [self characterAtIndex: j]; [self setCharacter: [self characterAtIndex: i] atIndex: j]; @@ -489,38 +489,38 @@ withString: (OFString *)replacement { [self replaceOccurrencesOfString: string withString: replacement options: 0 - range: of_range(0, [self length])]; + range: of_range(0, self.length)]; } - (void)replaceOccurrencesOfString: (OFString *)string withString: (OFString *)replacement options: (int)options range: (of_range_t)range { void *pool = objc_autoreleasePoolPush(), *pool2; const of_unichar_t *characters; - const of_unichar_t *searchCharacters = [string characters]; - size_t searchLength = [string length]; - size_t replacementLength = [replacement length]; + const of_unichar_t *searchCharacters = string.characters; + size_t searchLength = string.length; + size_t replacementLength = replacement.length; if (string == nil || replacement == nil) @throw [OFInvalidArgumentException exception]; if (range.length > SIZE_MAX - range.location || - range.location + range.length > [self length]) + range.location + range.length > self.length) @throw [OFOutOfRangeException exception]; if (searchLength > range.length) { objc_autoreleasePoolPop(pool); return; } pool2 = objc_autoreleasePoolPush(); - characters = [self characters]; + characters = self.characters; for (size_t i = range.location; i <= range.length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t)) != 0) continue; @@ -534,21 +534,21 @@ i += replacementLength - 1; objc_autoreleasePoolPop(pool2); pool2 = objc_autoreleasePoolPush(); - characters = [self characters]; + characters = self.characters; } objc_autoreleasePoolPop(pool); } - (void)deleteLeadingWhitespaces { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t i, length = [self length]; + const of_unichar_t *characters = self.characters; + size_t i, length = self.length; for (i = 0; i < length; i++) { of_unichar_t c = characters[i]; if (!of_ascii_isspace(c)) @@ -564,17 +564,17 @@ { void *pool; const of_unichar_t *characters, *p; size_t length, d; - length = [self length]; + length = self.length; if (length == 0) return; pool = objc_autoreleasePoolPush(); - characters = [self characters]; + characters = self.characters; d = 0; for (p = characters + length - 1; p >= characters; p--) { if (!of_ascii_isspace(*p)) break; Index: src/OFMutableString_UTF8.m ================================================================== --- src/OFMutableString_UTF8.m +++ src/OFMutableString_UTF8.m @@ -102,11 +102,11 @@ } return; } - unicodeLen = [self length]; + unicodeLen = self.length; unicodeString = [self allocMemoryWithSize: sizeof(of_unichar_t) count: unicodeLen]; i = j = 0; newCStringLength = 0; @@ -358,21 +358,21 @@ size_t UTF8StringLength; if (string == nil) @throw [OFInvalidArgumentException exception]; - UTF8StringLength = [string UTF8StringLength]; + UTF8StringLength = string.UTF8StringLength; _s->hashed = false; _s->cString = [self resizeMemory: _s->cString size: _s->cStringLength + UTF8StringLength + 1]; - memcpy(_s->cString + _s->cStringLength, [string UTF8String], + memcpy(_s->cString + _s->cStringLength, string.UTF8String, UTF8StringLength); _s->cStringLength += UTF8StringLength; - _s->length += [string length]; + _s->length += string.length; _s->cString[_s->cStringLength] = 0; if ([string isKindOfClass: [OFString_UTF8 class]] || [string isKindOfClass: [OFMutableString_UTF8 class]]) { @@ -429,11 +429,11 @@ int UTF8StringLength; if (format == nil) @throw [OFInvalidArgumentException exception]; - if ((UTF8StringLength = of_vasprintf(&UTF8String, [format UTF8String], + if ((UTF8StringLength = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { [self appendUTF8String: UTF8String @@ -533,23 +533,23 @@ if (_s->isUTF8) idx = of_string_utf8_get_position(_s->cString, idx, _s->cStringLength); - newCStringLength = _s->cStringLength + [string UTF8StringLength]; + newCStringLength = _s->cStringLength + string.UTF8StringLength; _s->hashed = false; _s->cString = [self resizeMemory: _s->cString size: newCStringLength + 1]; - memmove(_s->cString + idx + [string UTF8StringLength], + memmove(_s->cString + idx + string.UTF8StringLength, _s->cString + idx, _s->cStringLength - idx); - memcpy(_s->cString + idx, [string UTF8String], - [string UTF8StringLength]); + memcpy(_s->cString + idx, string.UTF8String, + string.UTF8StringLength); _s->cString[newCStringLength] = '\0'; _s->cStringLength = newCStringLength; - _s->length += [string length]; + _s->length += string.length; if ([string isKindOfClass: [OFString_UTF8 class]] || [string isKindOfClass: [OFMutableString_UTF8 class]]) { if (((OFString_UTF8 *)string)->_s->isUTF8) _s->isUTF8 = true; @@ -598,21 +598,21 @@ @throw [OFInvalidArgumentException exception]; if (range.length > SIZE_MAX - range.location || end > _s->length) @throw [OFOutOfRangeException exception]; - newLength = _s->length - range.length + [replacement length]; + newLength = _s->length - range.length + replacement.length; if (_s->isUTF8) { start = of_string_utf8_get_position(_s->cString, start, _s->cStringLength); end = of_string_utf8_get_position(_s->cString, end, _s->cStringLength); } newCStringLength = _s->cStringLength - (end - start) + - [replacement UTF8StringLength]; + replacement.UTF8StringLength; _s->hashed = false; /* * If the new string is bigger, we need to resize it first so we can * memmove() the rest of the string to the end. @@ -623,14 +623,14 @@ */ if (newCStringLength > _s->cStringLength) _s->cString = [self resizeMemory: _s->cString size: newCStringLength + 1]; - memmove(_s->cString + start + [replacement UTF8StringLength], + memmove(_s->cString + start + replacement.UTF8StringLength, _s->cString + end, _s->cStringLength - end); - memcpy(_s->cString + start, [replacement UTF8String], - [replacement UTF8StringLength]); + memcpy(_s->cString + start, replacement.UTF8String, + replacement.UTF8StringLength); _s->cString[newCStringLength] = '\0'; /* * If the new string is smaller, we can safely resize it now as we're * done with memmove(). @@ -653,22 +653,22 @@ - (void)replaceOccurrencesOfString: (OFString *)string withString: (OFString *)replacement options: (int)options range: (of_range_t)range { - const char *searchString = [string UTF8String]; - const char *replacementString = [replacement UTF8String]; - size_t searchLength = [string UTF8StringLength]; - size_t replacementLength = [replacement UTF8StringLength]; + const char *searchString = string.UTF8String; + const char *replacementString = replacement.UTF8String; + size_t searchLength = string.UTF8StringLength; + size_t replacementLength = replacement.UTF8StringLength; size_t last, newCStringLength, newLength; char *newCString; if (string == nil || replacement == nil) @throw [OFInvalidArgumentException exception]; if (range.length > SIZE_MAX - range.location || - range.location + range.length > [self length]) + range.location + range.length > self.length) @throw [OFOutOfRangeException exception]; if (_s->isUTF8) { range.location = of_string_utf8_get_position(_s->cString, range.location, _s->cStringLength); @@ -675,11 +675,11 @@ range.length = of_string_utf8_get_position( _s->cString + range.location, range.length, _s->cStringLength - range.location); } - if ([string UTF8StringLength] > range.length) + if (string.UTF8StringLength > range.length) return; newCString = NULL; newCStringLength = 0; newLength = _s->length; @@ -688,14 +688,14 @@ for (size_t i = range.location; i <= range.length - searchLength; i++) { if (memcmp(_s->cString + i, searchString, searchLength) != 0) continue; @try { - newCString = [self - resizeMemory: newCString - size: newCStringLength + i - last + - replacementLength + 1]; + newCString = [self resizeMemory: newCString + size: newCStringLength + + i - last + + replacementLength + 1]; } @catch (id e) { [self freeMemory: newCString]; @throw e; } memcpy(newCString + newCStringLength, _s->cString + last, @@ -702,11 +702,11 @@ i - last); memcpy(newCString + newCStringLength + i - last, replacementString, replacementLength); newCStringLength += i - last + replacementLength; - newLength = newLength - [string length] + [replacement length]; + newLength = newLength - string.length + replacement.length; i += searchLength - 1; last = i + 1; } Index: src/OFMutableURL.m ================================================================== --- src/OFMutableURL.m +++ src/OFMutableURL.m @@ -177,21 +177,21 @@ - (void)setPathComponents: (OFArray *)components { void *pool = objc_autoreleasePoolPush(); if (components == nil) { - [self setPath: nil]; + self.path = nil; return; } - if ([components count] == 0) + if (components.count == 0) @throw [OFInvalidFormatException exception]; - if ([[components firstObject] length] != 0) + if ([components.firstObject length] != 0) @throw [OFInvalidFormatException exception]; - [self setPath: [components componentsJoinedByString: @"/"]]; + self.path = [components componentsJoinedByString: @"/"]; objc_autoreleasePoolPop(pool); } - (void)setQuery: (OFString *)query @@ -269,33 +269,33 @@ pool = objc_autoreleasePoolPush(); array = [[[_URLEncodedPath componentsSeparatedByString: @"/"] mutableCopy] autorelease]; - if ([[array firstObject] length] != 0) + if ([array.firstObject length] != 0) @throw [OFInvalidFormatException exception]; - endsWithEmpty = ([[array lastObject] length] == 0); + endsWithEmpty = ([array.lastObject length] == 0); while (!done) { - size_t length = [array count]; + size_t length = array.count; done = true; for (size_t i = 0; i < length; i++) { - id object = [array objectAtIndex: i]; - id parent = + OFString *current = [array objectAtIndex: i]; + OFString *parent = (i > 0 ? [array objectAtIndex: i - 1] : nil); - if ([object isEqual: @"."] || [object length] == 0) { + if ([current isEqual: @"."] || current.length == 0) { [array removeObjectAtIndex: i]; done = false; break; } - if ([object isEqual: @".."] && parent != nil && + if ([current isEqual: @".."] && parent != nil && ![parent isEqual: @".."]) { [array removeObjectsInRange: of_range(i - 1, 2)]; done = false; @@ -308,11 +308,11 @@ atIndex: 0]; if (endsWithEmpty) [array addObject: @""]; path = [array componentsJoinedByString: @"/"]; - if ([path length] == 0) + if (path.length == 0) path = @"/"; [self setURLEncodedPath: path]; objc_autoreleasePoolPop(pool); Index: src/OFMutableZIPArchiveEntry.m ================================================================== --- src/OFMutableZIPArchiveEntry.m +++ src/OFMutableZIPArchiveEntry.m @@ -44,11 +44,11 @@ - (void)setFileName: (OFString *)fileName { void *pool = objc_autoreleasePoolPush(); OFString *old; - if ([fileName UTF8StringLength] > UINT16_MAX) + if (fileName.UTF8StringLength > UINT16_MAX) @throw [OFOutOfRangeException exception]; old = _fileName; _fileName = [fileName copy]; [old release]; @@ -59,11 +59,11 @@ - (void)setFileComment: (OFString *)fileComment { void *pool = objc_autoreleasePoolPush(); OFString *old; - if ([fileComment UTF8StringLength] > UINT16_MAX) + if (fileComment.UTF8StringLength > UINT16_MAX) @throw [OFOutOfRangeException exception]; old = _fileComment; _fileComment = [fileComment copy]; [old release]; @@ -74,14 +74,14 @@ - (void)setExtraField: (OFData *)extraField { void *pool = objc_autoreleasePoolPush(); OFData *old; - if ([extraField itemSize] != 1) + if (extraField.itemSize != 1) @throw [OFInvalidArgumentException exception]; - if ([extraField count] > UINT16_MAX) + if (extraField.count > UINT16_MAX) @throw [OFOutOfRangeException exception]; old = _extraField; _extraField = [extraField copy]; [old release]; @@ -101,15 +101,15 @@ - (void)setModificationDate: (OFDate *)date { void *pool = objc_autoreleasePoolPush(); - _lastModifiedFileDate = ((([date localYear] - 1980) & 0xFF) << 9) | - (([date localMonthOfYear] & 0x0F) << 5) | - ([date localDayOfMonth] & 0x1F); - _lastModifiedFileTime = (([date localHour] & 0x1F) << 11) | - (([date localMinute] & 0x3F) << 5) | (([date second] >> 1) & 0x0F); + _lastModifiedFileDate = (((date.localYear - 1980) & 0xFF) << 9) | + ((date.localMonthOfYear & 0x0F) << 5) | + (date.localDayOfMonth & 0x1F); + _lastModifiedFileTime = ((date.localHour & 0x1F) << 11) | + ((date.localMinute & 0x3F) << 5) | ((date.second >> 1) & 0x0F); objc_autoreleasePoolPop(pool); } - (void)setCompressionMethod: (uint16_t)compressionMethod Index: src/OFMutex.m ================================================================== --- src/OFMutex.m +++ src/OFMutex.m @@ -36,11 +36,11 @@ - (instancetype)init { self = [super init]; if (!of_mutex_new(&_mutex)) { - Class c = [self class]; + Class c = self.class; [self release]; @throw [OFInitializationFailedException exceptionWithClass: c]; } _initialized = true; @@ -77,11 +77,10 @@ } - (OFString *)description { if (_name == nil) - return [super description]; + return super.description; - return [OFString stringWithFormat: @"<%@: %@>", - [self className], _name]; + return [OFString stringWithFormat: @"<%@: %@>", self.className, _name]; } @end Index: src/OFNull.m ================================================================== --- src/OFNull.m +++ src/OFNull.m @@ -48,12 +48,12 @@ [self release]; pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; objc_autoreleasePoolPop(pool); return [OFNull null]; @@ -72,11 +72,11 @@ - (OFXMLElement *)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; - element = [OFXMLElement elementWithName: [self className] + element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; [element retain]; objc_autoreleasePoolPop(pool); Index: src/OFNumber.m ================================================================== --- src/OFNumber.m +++ src/OFNumber.m @@ -530,15 +530,15 @@ @try { void *pool = objc_autoreleasePoolPush(); OFString *typeString; - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - typeString = [[element attributeForName: @"type"] stringValue]; + typeString = [element attributeForName: @"type"].stringValue; if ([typeString isEqual: @"boolean"]) { _type = OF_NUMBER_TYPE_BOOL; if ([[element stringValue] isEqual: @"true"]) @@ -551,22 +551,22 @@ /* * FIXME: This will fail if the value is bigger than * INTMAX_MAX! */ _type = OF_NUMBER_TYPE_UINTMAX; - _value.uIntMax = [element decimalValue]; + _value.uIntMax = element.decimalValue; } else if ([typeString isEqual: @"signed"]) { _type = OF_NUMBER_TYPE_INTMAX; - _value.intMax = [element decimalValue]; + _value.intMax = element.decimalValue; } else if ([typeString isEqual: @"float"]) { union { float f; uint32_t u; } f; f.u = OF_BSWAP32_IF_LE( - (uint32_t)[element hexadecimalValue]); + (uint32_t)element.hexadecimalValue); _type = OF_NUMBER_TYPE_FLOAT; _value.float_ = OF_BSWAP_FLOAT_IF_LE(f.f); } else if ([typeString isEqual: @"double"]) { union { @@ -573,11 +573,11 @@ double d; uint64_t u; } d; d.u = OF_BSWAP64_IF_LE( - (uint64_t)[element hexadecimalValue]); + (uint64_t)element.hexadecimalValue); _type = OF_NUMBER_TYPE_DOUBLE; _value.double_ = OF_BSWAP_DOUBLE_IF_LE(d.d); } else @throw [OFInvalidArgumentException exception]; @@ -984,12 +984,12 @@ number = object; if (_type & OF_NUMBER_TYPE_FLOAT || number->_type & OF_NUMBER_TYPE_FLOAT) { - double value1 = [number doubleValue]; - double value2 = [self doubleValue]; + double value1 = number.doubleValue; + double value2 = self.doubleValue; if (isnan(value1) && isnan(value2)) return true; if (isnan(value1) || isnan(value2)) return false; @@ -997,13 +997,13 @@ return (value1 == value2); } if (_type & OF_NUMBER_TYPE_SIGNED || number->_type & OF_NUMBER_TYPE_SIGNED) - return ([number intMaxValue] == [self intMaxValue]); + return (number.intMaxValue == self.intMaxValue); - return ([number uIntMaxValue] == [self uIntMaxValue]); + return (number.uIntMaxValue == self.uIntMaxValue); } - (of_comparison_result_t)compare: (id )object { OFNumber *number; @@ -1013,33 +1013,33 @@ number = (OFNumber *)object; if (_type & OF_NUMBER_TYPE_FLOAT || number->_type & OF_NUMBER_TYPE_FLOAT) { - double double1 = [self doubleValue]; - double double2 = [number doubleValue]; + double double1 = self.doubleValue; + double double2 = number.doubleValue; if (double1 > double2) return OF_ORDERED_DESCENDING; if (double1 < double2) return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; } else if (_type & OF_NUMBER_TYPE_SIGNED || number->_type & OF_NUMBER_TYPE_SIGNED) { - intmax_t int1 = [self intMaxValue]; - intmax_t int2 = [number intMaxValue]; + intmax_t int1 = self.intMaxValue; + intmax_t int2 = number.intMaxValue; if (int1 > int2) return OF_ORDERED_DESCENDING; if (int1 < int2) return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; } else { - uintmax_t uint1 = [self uIntMaxValue]; - uintmax_t uint2 = [number uIntMaxValue]; + uintmax_t uint1 = self.uIntMaxValue; + uintmax_t uint2 = number.uIntMaxValue; if (uint1 > uint2) return OF_ORDERED_DESCENDING; if (uint1 < uint2) return OF_ORDERED_ASCENDING; @@ -1052,24 +1052,24 @@ { of_number_type_t type = _type; uint32_t hash; /* Do we really need signed to represent this number? */ - if (type & OF_NUMBER_TYPE_SIGNED && [self intMaxValue] >= 0) + if (type & OF_NUMBER_TYPE_SIGNED && self.intMaxValue >= 0) type &= ~OF_NUMBER_TYPE_SIGNED; /* Do we really need floating point to represent this number? */ if (type & OF_NUMBER_TYPE_FLOAT) { - double v = [self doubleValue]; + double v = self.doubleValue; if (v < 0) { - if (v == [self intMaxValue]) { + if (v == self.intMaxValue) { type &= ~OF_NUMBER_TYPE_FLOAT; type |= OF_NUMBER_TYPE_SIGNED; } } else { - if (v == [self uIntMaxValue]) + if (v == self.uIntMaxValue) type &= ~OF_NUMBER_TYPE_FLOAT; } } OF_HASH_INIT(hash); @@ -1078,28 +1078,28 @@ union { double d; uint8_t b[sizeof(double)]; } d; - if (isnan([self doubleValue])) + if (isnan(self.doubleValue)) return 0; - d.d = OF_BSWAP_DOUBLE_IF_BE([self doubleValue]); + d.d = OF_BSWAP_DOUBLE_IF_BE(self.doubleValue); for (uint_fast8_t i = 0; i < sizeof(double); i++) OF_HASH_ADD(hash, d.b[i]); } else if (type & OF_NUMBER_TYPE_SIGNED) { - intmax_t v = [self intMaxValue] * -1; + intmax_t v = self.intMaxValue * -1; while (v != 0) { OF_HASH_ADD(hash, v & 0xFF); v >>= 8; } OF_HASH_ADD(hash, 1); } else { - uintmax_t v = [self uIntMaxValue]; + uintmax_t v = self.uIntMaxValue; while (v != 0) { OF_HASH_ADD(hash, v & 0xFF); v >>= 8; } @@ -1132,11 +1132,11 @@ case OF_NUMBER_TYPE_UINT32: case OF_NUMBER_TYPE_UINT64: case OF_NUMBER_TYPE_SIZE: case OF_NUMBER_TYPE_UINTMAX: case OF_NUMBER_TYPE_UINTPTR: - return [OFString stringWithFormat: @"%ju", [self uIntMaxValue]]; + return [OFString stringWithFormat: @"%ju", self.uIntMaxValue]; case OF_NUMBER_TYPE_CHAR: case OF_NUMBER_TYPE_SHORT: case OF_NUMBER_TYPE_INT: case OF_NUMBER_TYPE_LONG: case OF_NUMBER_TYPE_LONGLONG: @@ -1146,11 +1146,11 @@ case OF_NUMBER_TYPE_INT64: case OF_NUMBER_TYPE_SSIZE: case OF_NUMBER_TYPE_INTMAX: case OF_NUMBER_TYPE_PTRDIFF: case OF_NUMBER_TYPE_INTPTR: - return [OFString stringWithFormat: @"%jd", [self intMaxValue]]; + return [OFString stringWithFormat: @"%jd", self.intMaxValue]; case OF_NUMBER_TYPE_FLOAT: ret = [OFMutableString stringWithFormat: @"%g", _value.float_]; if (![ret containsString: @"."]) [ret appendString: @".0"]; @@ -1175,13 +1175,13 @@ - (OFXMLElement *)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; - element = [OFXMLElement elementWithName: [self className] + element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS - stringValue: [self description]]; + stringValue: self.description]; switch (_type) { case OF_NUMBER_TYPE_BOOL: [element addAttributeWithName: @"type" stringValue: @"boolean"]; @@ -1225,13 +1225,13 @@ f.f = OF_BSWAP_FLOAT_IF_LE(_value.float_); [element addAttributeWithName: @"type" stringValue: @"float"]; - [element setStringValue: + element.stringValue = [OFString stringWithFormat: @"%08" PRIx32, - OF_BSWAP32_IF_LE(f.u)]]; + OF_BSWAP32_IF_LE(f.u)]; break; case OF_NUMBER_TYPE_DOUBLE:; union { double d; @@ -1240,13 +1240,13 @@ d.d = OF_BSWAP_DOUBLE_IF_LE(_value.double_); [element addAttributeWithName: @"type" stringValue: @"double"]; - [element setStringValue: + element.stringValue = [OFString stringWithFormat: @"%016" PRIx64, - OF_BSWAP64_IF_LE(d.u)]]; + OF_BSWAP64_IF_LE(d.u)]; break; default: @throw [OFInvalidFormatException exception]; } @@ -1276,11 +1276,11 @@ double doubleValue; if (_type == OF_NUMBER_TYPE_BOOL) return (_value.bool_ ? @"true" : @"false"); - doubleValue = [self doubleValue]; + doubleValue = self.doubleValue; if (isinf(doubleValue)) { if (options & OF_JSON_REPRESENTATION_JSON5) { if (doubleValue > 0) return @"Infinity"; else @@ -1287,11 +1287,11 @@ return @"-Infinity"; } else @throw [OFInvalidArgumentException exception]; } - return [self description]; + return self.description; } - (OFData *)messagePackRepresentation { OFMutableData *data; @@ -1320,11 +1320,11 @@ [data addItem: &type]; [data addItems: &tmp count: sizeof(tmp)]; } else if (_type & OF_NUMBER_TYPE_SIGNED) { - intmax_t value = [self intMaxValue]; + intmax_t value = self.intMaxValue; if (value >= -32 && value < 0) { uint8_t tmp = 0xE0 | ((uint8_t)(value - 32) & 0x1F); data = [OFMutableData dataWithItems: &tmp @@ -1369,11 +1369,11 @@ [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; } else { - uintmax_t value = [self uIntMaxValue]; + uintmax_t value = self.uIntMaxValue; if (value <= 127) { uint8_t tmp = ((uint8_t)value & 0x7F); data = [OFMutableData dataWithItems: &tmp Index: src/OFObject+KeyValueCoding.m ================================================================== --- src/OFObject+KeyValueCoding.m +++ src/OFObject+KeyValueCoding.m @@ -32,29 +32,29 @@ int _OFObject_KeyValueCoding_reference; @implementation OFObject (KeyValueCoding) - (id)valueForKey: (OFString *)key { - SEL selector = sel_registerName([key UTF8String]); + SEL selector = sel_registerName(key.UTF8String); OFMethodSignature *methodSignature = [self methodSignatureForSelector: selector]; id ret; if (methodSignature == nil) { size_t keyLength; char *name; - if ((keyLength = [key UTF8StringLength]) < 1) + if ((keyLength = key.UTF8StringLength) < 1) return [self valueForUndefinedKey: key]; if ((name = malloc(keyLength + 3)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: keyLength + 3]; @try { memcpy(name, "is", 2); - memcpy(name + 2, [key UTF8String], keyLength); + memcpy(name + 2, key.UTF8String, keyLength); name[keyLength + 2] = '\0'; name[2] = of_ascii_toupper(name[2]); selector = sel_registerName(name); @@ -65,23 +65,23 @@ methodSignature = [self methodSignatureForSelector: selector]; if (methodSignature == NULL) return [self valueForUndefinedKey: key]; - switch (*[methodSignature methodReturnType]) { + switch (*methodSignature.methodReturnType) { case '@': case '#': return [self valueForUndefinedKey: key]; } } - if ([methodSignature numberOfArguments] != 2 || + if (methodSignature.numberOfArguments != 2 || *[methodSignature argumentTypeAtIndex: 0] != '@' || *[methodSignature argumentTypeAtIndex: 1] != ':') return [self valueForUndefinedKey: key]; - switch (*[methodSignature methodReturnType]) { + switch (*methodSignature.methodReturnType) { case '@': case '#': ret = [self performSelector: selector]; break; #define CASE(encoding, type, method) \ @@ -126,11 +126,11 @@ char *name; SEL selector; OFMethodSignature *methodSignature; const char *valueType; - if ((keyLength = [key UTF8StringLength]) < 1) { + if ((keyLength = key.UTF8StringLength) < 1) { [self setValue: value forUndefinedKey: key]; return; } @@ -138,11 +138,11 @@ @throw [OFOutOfMemoryException exceptionWithRequestedSize: keyLength + 5]; @try { memcpy(name, "set", 3); - memcpy(name + 3, [key UTF8String], keyLength); + memcpy(name + 3, key.UTF8String, keyLength); memcpy(name + keyLength + 3, ":", 2); name[3] = of_ascii_toupper(name[3]); selector = sel_registerName(name); @@ -151,12 +151,12 @@ } methodSignature = [self methodSignatureForSelector: selector]; if (methodSignature == nil || - [methodSignature numberOfArguments] != 3 || - *[methodSignature methodReturnType] != 'v' || + methodSignature.numberOfArguments != 3 || + *methodSignature.methodReturnType != 'v' || *[methodSignature argumentTypeAtIndex: 0] != '@' || *[methodSignature argumentTypeAtIndex: 1] != ':') { [self setValue: value forUndefinedKey: key]; return; Index: src/OFObject+Serialization.m ================================================================== --- src/OFObject+Serialization.m +++ src/OFObject+Serialization.m @@ -39,11 +39,11 @@ [self doesNotRecognizeSelector: _cmd]; abort(); } pool = objc_autoreleasePoolPush(); - element = [(id)self XMLElementBySerializing]; + element = ((id )self).XMLElementBySerializing; root = [OFXMLElement elementWithName: @"serialization" namespace: OF_SERIALIZATION_NS]; [root addAttributeWithName: @"version" stringValue: @"1"]; Index: src/OFObject.m ================================================================== --- src/OFObject.m +++ src/OFObject.m @@ -674,11 +674,11 @@ void *pool = objc_autoreleasePoolPush(); OFTimer *timer = [OFTimer timerWithTimeInterval: 0 target: self selector: selector repeats: false]; - [[thread runLoop] addTimer: timer]; + [thread.runLoop addTimer: timer]; if (waitUntilDone) [timer waitUntilDone]; objc_autoreleasePoolPop(pool); @@ -693,11 +693,11 @@ OFTimer *timer = [OFTimer timerWithTimeInterval: 0 target: self selector: selector object: object repeats: false]; - [[thread runLoop] addTimer: timer]; + [thread.runLoop addTimer: timer]; if (waitUntilDone) [timer waitUntilDone]; objc_autoreleasePoolPop(pool); @@ -714,11 +714,11 @@ target: self selector: selector object: object1 object: object2 repeats: false]; - [[thread runLoop] addTimer: timer]; + [thread.runLoop addTimer: timer]; if (waitUntilDone) [timer waitUntilDone]; objc_autoreleasePoolPop(pool); @@ -737,11 +737,11 @@ selector: selector object: object1 object: object2 object: object3 repeats: false]; - [[thread runLoop] addTimer: timer]; + [thread.runLoop addTimer: timer]; if (waitUntilDone) [timer waitUntilDone]; objc_autoreleasePoolPop(pool); @@ -762,11 +762,11 @@ object: object1 object: object2 object: object3 object: object4 repeats: false]; - [[thread runLoop] addTimer: timer]; + [thread.runLoop addTimer: timer]; if (waitUntilDone) [timer waitUntilDone]; objc_autoreleasePoolPop(pool); @@ -876,14 +876,14 @@ onThread: (OFThread *)thread afterDelay: (of_time_interval_t)delay { void *pool = objc_autoreleasePoolPush(); - [[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay - target: self - selector: selector - repeats: false]]; + [thread.runLoop addTimer: [OFTimer timerWithTimeInterval: delay + target: self + selector: selector + repeats: false]]; objc_autoreleasePoolPop(pool); } - (void)performSelector: (SEL)selector @@ -891,15 +891,15 @@ withObject: (id)object afterDelay: (of_time_interval_t)delay { void *pool = objc_autoreleasePoolPush(); - [[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay - target: self - selector: selector - object: object - repeats: false]]; + [thread.runLoop addTimer: [OFTimer timerWithTimeInterval: delay + target: self + selector: selector + object: object + repeats: false]]; objc_autoreleasePoolPop(pool); } - (void)performSelector: (SEL)selector @@ -908,16 +908,16 @@ withObject: (id)object2 afterDelay: (of_time_interval_t)delay { void *pool = objc_autoreleasePoolPush(); - [[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay - target: self - selector: selector - object: object1 - object: object2 - repeats: false]]; + [thread.runLoop addTimer: [OFTimer timerWithTimeInterval: delay + target: self + selector: selector + object: object1 + object: object2 + repeats: false]]; objc_autoreleasePoolPop(pool); } - (void)performSelector: (SEL)selector @@ -927,17 +927,17 @@ withObject: (id)object3 afterDelay: (of_time_interval_t)delay { void *pool = objc_autoreleasePoolPush(); - [[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay - target: self - selector: selector - object: object1 - object: object2 - object: object3 - repeats: false]]; + [thread.runLoop addTimer: [OFTimer timerWithTimeInterval: delay + target: self + selector: selector + object: object1 + object: object2 + object: object3 + repeats: false]]; objc_autoreleasePoolPop(pool); } - (void)performSelector: (SEL)selector @@ -948,18 +948,18 @@ withObject: (id)object4 afterDelay: (of_time_interval_t)delay { void *pool = objc_autoreleasePoolPush(); - [[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay - target: self - selector: selector - object: object1 - object: object2 - object: object3 - object: object4 - repeats: false]]; + [thread.runLoop addTimer: [OFTimer timerWithTimeInterval: delay + target: self + selector: selector + object: object1 + object: object2 + object: object3 + object: object4 + repeats: false]]; objc_autoreleasePoolPop(pool); } #endif @@ -998,11 +998,11 @@ - (OFString *)description { /* Classes containing data should reimplement this! */ - return [OFString stringWithFormat: @"<%@>", [self className]]; + return [OFString stringWithFormat: @"<%@>", self.className]; } - (void *)allocMemoryWithSize: (size_t)size { void *pointer; Index: src/OFOptionsParser.m ================================================================== --- src/OFOptionsParser.m +++ src/OFOptionsParser.m @@ -25,11 +25,11 @@ #import "OFInvalidArgumentException.h" static uint32_t stringHash(void *object) { - return [(OFString *)object hash]; + return ((OFString *)object).hash; } static bool stringEqual(void *object1, void *object2) { @@ -163,11 +163,11 @@ - (of_unichar_t)nextOption { of_options_parser_option_t *iter; OFString *argument; - if (_done || _index >= [_arguments count]) + if (_done || _index >= _arguments.count) return '\0'; [_lastLongOption release]; [_argument release]; _lastLongOption = nil; @@ -174,11 +174,11 @@ _argument = nil; argument = [_arguments objectAtIndex: _index]; if (_subIndex == 0) { - if ([argument length] < 2 || + if (argument.length < 2 || [argument characterAtIndex: 0] != '-') { _done = true; return '\0'; } @@ -197,15 +197,15 @@ _index++; if ((pos = [argument rangeOfString: @"="].location) != OF_NOT_FOUND) { of_range_t range = of_range(pos + 1, - [argument length] - pos - 1); + argument.length - pos - 1); _argument = [[argument substringWithRange: range] copy]; } else - pos = [argument length]; + pos = argument.length; _lastLongOption = [[argument substringWithRange: of_range(2, pos - 2)] copy]; objc_autoreleasePoolPop(pool); @@ -234,11 +234,11 @@ _subIndex = 1; } _lastOption = [argument characterAtIndex: _subIndex++]; - if (_subIndex >= [argument length]) { + if (_subIndex >= argument.length) { _index++; _subIndex = 0; } for (iter = _options; @@ -249,16 +249,16 @@ *iter->isSpecifiedPtr = true; return _lastOption; } - if (_index >= [_arguments count]) + if (_index >= _arguments.count) return ':'; argument = [_arguments objectAtIndex: _index]; argument = [argument substringWithRange: - of_range(_subIndex, [argument length] - _subIndex)]; + of_range(_subIndex, argument.length - _subIndex)]; _argument = [argument copy]; if (iter->isSpecifiedPtr != NULL) *iter->isSpecifiedPtr = true; @@ -277,8 +277,8 @@ } - (OFArray *)remainingArguments { return [_arguments objectsInRange: - of_range(_index, [_arguments count] - _index)]; + of_range(_index, _arguments.count - _index)]; } @end Index: src/OFPlugin.m ================================================================== --- src/OFPlugin.m +++ src/OFPlugin.m @@ -40,11 +40,11 @@ return dlopen([path cStringWithEncoding: [OFLocale encoding]], flags); #else if (path == nil) return GetModuleHandle(NULL); - return LoadLibraryW([path UTF16String]); + return LoadLibraryW(path.UTF16String); #endif } void * of_dlsym(of_plugin_handle_t handle, const char *symbol) @@ -85,14 +85,14 @@ init_plugin_t initPlugin; OFPlugin *plugin; #if defined(OF_MACOS) path = [path stringByAppendingFormat: @".bundle/Contents/MacOS/%@", - [path lastPathComponent]]; + path.lastPathComponent]; #elif defined(OF_IOS) path = [path stringByAppendingFormat: @".bundle/%@", - [path lastPathComponent]]; + path.lastPathComponent]; #else path = [path stringByAppendingString: @PLUGIN_SUFFIX]; #endif if ((handle = of_dlopen(path, OF_RTLD_LAZY)) == NULL) Index: src/OFProcess.m ================================================================== --- src/OFProcess.m +++ src/OFProcess.m @@ -141,11 +141,11 @@ const char *path; char **argv; if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; path = [program cStringWithEncoding: [OFLocale encoding]]; [self of_getArgv: &argv forProgramName: programName andArguments: arguments]; @@ -157,17 +157,17 @@ posix_spawn_file_actions_t actions; posix_spawnattr_t attr; if (posix_spawn_file_actions_init(&actions) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; if (posix_spawnattr_init(&attr) != 0) { posix_spawn_file_actions_destroy(&actions); @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } @try { if (posix_spawn_file_actions_addclose(&actions, _readPipe[0]) != 0 || @@ -176,23 +176,23 @@ posix_spawn_file_actions_adddup2(&actions, _writePipe[0], 0) != 0 || posix_spawn_file_actions_adddup2(&actions, _readPipe[1], 1) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; # ifdef POSIX_SPAWN_CLOEXEC_DEFAULT if (posix_spawnattr_setflags(&attr, POSIX_SPAWN_CLOEXEC_DEFAULT) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; # endif if (posix_spawnp(&_pid, path, &actions, &attr, argv, env) != 0) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } @finally { posix_spawn_file_actions_destroy(&actions); posix_spawnattr_destroy(&attr); } # else @@ -208,11 +208,11 @@ _exit(EXIT_FAILURE); } if (_pid == -1) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; # endif } @finally { close(_readPipe[1]); close(_writePipe[0]); [self freeMemory: argv]; @@ -232,24 +232,24 @@ sa.bInheritHandle = TRUE; sa.lpSecurityDescriptor = NULL; if (!CreatePipe(&_readPipe[0], &_readPipe[1], &sa, 0)) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; if (!SetHandleInformation(_readPipe[0], HANDLE_FLAG_INHERIT, 0)) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; if (!CreatePipe(&_writePipe[0], &_writePipe[1], &sa, 0)) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; if (!SetHandleInformation(_writePipe[1], HANDLE_FLAG_INHERIT, 0)) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; memset(&pi, 0, sizeof(pi)); memset(&si, 0, sizeof(si)); si.cb = sizeof(si); @@ -291,23 +291,23 @@ if (containsSpaces) [argumentsString appendString: @"\""]; } - length = [argumentsString UTF16StringLength]; + length = argumentsString.UTF16StringLength; argumentsCopy = [self allocMemoryWithSize: sizeof(of_char16_t) count: length + 1]; - memcpy(argumentsCopy, [argumentsString UTF16String], - ([argumentsString UTF16StringLength] + 1) * 2); + memcpy(argumentsCopy, argumentsString.UTF16String, + (argumentsString.UTF16StringLength + 1) * 2); @try { - if (!CreateProcessW([program UTF16String], + if (!CreateProcessW(program.UTF16String, argumentsCopy, NULL, NULL, TRUE, CREATE_UNICODE_ENVIRONMENT, [self of_environmentForDictionary: environment], NULL, &si, &pi)) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } @finally { [self freeMemory: argumentsCopy]; } objc_autoreleasePoolPop(pool); @@ -336,12 +336,12 @@ #ifndef OF_WINDOWS - (void)of_getArgv: (char ***)argv forProgramName: (OFString *)programName andArguments: (OFArray *)arguments { - OFString *const *objects = [arguments objects]; - size_t i, count = [arguments count]; + OFString *const *objects = arguments.objects; + size_t i, count = arguments.count; of_string_encoding_t encoding; *argv = [self allocMemoryWithSize: sizeof(char *) count: count + 2]; @@ -366,11 +366,11 @@ if (environment == nil) return NULL; encoding = [OFLocale encoding]; - count = [environment count]; + count = environment.count; envp = [self allocMemoryWithSize: sizeof(char *) count: count + 1]; keyEnumerator = [environment keyEnumerator]; objectEnumerator = [environment objectEnumerator]; @@ -415,23 +415,23 @@ keyEnumerator = [environment keyEnumerator]; objectEnumerator = [environment objectEnumerator]; while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) { - [env addItems: [key UTF16String] - count: [key UTF16StringLength]]; + [env addItems: key.UTF16String + count: key.UTF16StringLength]; [env addItems: &equal count: 1]; - [env addItems: [object UTF16String] - count: [object UTF16StringLength]]; + [env addItems: object.UTF16String + count: object.UTF16StringLength]; [env addItems: &zero count: 1]; } [env addItems: zero count: 2]; - return [env items]; + return env.items; } #endif - (bool)lowlevelIsAtEndOfStream { Index: src/OFRIPEMD160Hash.m ================================================================== --- src/OFRIPEMD160Hash.m +++ src/OFRIPEMD160Hash.m @@ -156,11 +156,11 @@ self = [super init]; @try { _iVarsData = [[OFSecureData alloc] initWithCount: sizeof(*_iVars)]; - _iVars = [_iVarsData items]; + _iVars = _iVarsData.mutableItems; [self of_resetState]; } @catch (id e) { [self release]; @throw e; @@ -184,11 +184,11 @@ - (id)copy { OFRIPEMD160Hash *copy = [[OFRIPEMD160Hash alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; - copy->_iVars = [copy->_iVarsData items]; + copy->_iVars = copy->_iVarsData.mutableItems; copy->_calculated = _calculated; return copy; } Index: src/OFRecursiveMutex.m ================================================================== --- src/OFRecursiveMutex.m +++ src/OFRecursiveMutex.m @@ -36,11 +36,11 @@ - (instancetype)init { self = [super init]; if (!of_rmutex_new(&_rmutex)) { - Class c = [self class]; + Class c = self.class; [self release]; @throw [OFInitializationFailedException exceptionWithClass: c]; } _initialized = true; @@ -77,11 +77,10 @@ } - (OFString *)description { if (_name == nil) - return [super description]; + return super.description; - return [OFString stringWithFormat: @"<%@: %@>", - [self className], _name]; + return [OFString stringWithFormat: @"<%@: %@>", self.className, _name]; } @end Index: src/OFRunLoop+Private.h ================================================================== --- src/OFRunLoop+Private.h +++ src/OFRunLoop+Private.h @@ -26,11 +26,11 @@ @class OFRunLoop_State; #ifdef OF_HAVE_SOCKETS @protocol OFTCPSocketDelegate_Private -- (void)of_socketDidConnect: (OF_KINDOF(OFTCPSocket *))socket +- (void)of_socketDidConnect: (OFTCPSocket *)socket exception: (nullable id)exception; @end #endif @interface OFRunLoop () Index: src/OFRunLoop.m ================================================================== --- src/OFRunLoop.m +++ src/OFRunLoop.m @@ -181,11 +181,11 @@ @try { _timersQueue = [[OFSortedList alloc] init]; #if defined(OF_HAVE_SOCKETS) _kernelEventObserver = [[OFKernelEventObserver alloc] init]; - [_kernelEventObserver setDelegate: self]; + _kernelEventObserver.delegate = self; _readQueues = [[OFMutableDictionary alloc] init]; _writeQueues = [[OFMutableDictionary alloc] init]; #elif defined(OF_HAVE_THREADS) _condition = [[OFCondition alloc] init]; @@ -223,12 +223,12 @@ [[_readQueues objectForKey: object] retain]; assert(queue != nil); @try { - if (![[queue firstObject] handleObject: object]) { - of_list_object_t *listObject = [queue firstListObject]; + if (![queue.firstObject handleObject: object]) { + of_list_object_t *listObject = queue.firstListObject; /* * The handler might have called -[cancelAsyncRequests] * so that our queue is now empty, in which case we * should do nothing. @@ -242,11 +242,11 @@ */ [[listObject->object retain] autorelease]; [queue removeListObject: listObject]; - if ([queue count] == 0) { + if (queue.count == 0) { [_kernelEventObserver removeObjectForReading: object]; [_readQueues removeObjectForKey: object]; } @@ -266,12 +266,12 @@ OFList *queue = [[_writeQueues objectForKey: object] retain]; assert(queue != nil); @try { - if (![[queue firstObject] handleObject: object]) { - of_list_object_t *listObject = [queue firstListObject]; + if (![queue.firstObject handleObject: object]) { + of_list_object_t *listObject = queue.firstListObject; /* * The handler might have called -[cancelAsyncRequests] * so that our queue is now empty, in which case we * should do nothing. @@ -285,11 +285,11 @@ */ [[listObject->object retain] autorelease]; [queue removeListObject: listObject]; - if ([queue count] == 0) { + if (queue.count == 0) { [_kernelEventObserver removeObjectForWriting: object]; [_writeQueues removeObjectForKey: object]; } @@ -461,15 +461,15 @@ @implementation OFRunLoop_WriteDataQueueItem - (bool)handleObject: (id)object { size_t length; id exception = nil; - size_t dataLength = [_data count] * [_data itemSize]; + size_t dataLength = _data.count * _data.itemSize; OFData *newData, *oldData; @try { - const char *dataItems = [_data items]; + const char *dataItems = _data.items; length = [object writeBuffer: dataItems + _writtenLength length: dataLength - _writtenLength]; } @catch (id e) { length = 0; @@ -718,12 +718,12 @@ { id exception = nil; OFData *newData, *oldData; @try { - [object sendBuffer: [_data items] - length: [_data count] * [_data itemSize] + [object sendBuffer: _data.items + length: _data.count * _data.itemSize receiver: &_receiver]; } @catch (id e) { exception = e; } @@ -784,11 +784,11 @@ } + (OFRunLoop *)currentRunLoop { #ifdef OF_HAVE_THREADS - return [[OFThread currentThread] runLoop]; + return [OFThread currentThread].runLoop; #else return [self mainRunLoop]; #endif } @@ -807,14 +807,14 @@ type *queueItem; \ \ if (queue == nil) { \ queue = [OFList list]; \ [state->_readQueues setObject: queue \ - forKey: object]; \ + forKey: object]; \ } \ \ - if ([queue count] == 0) \ + if (queue.count == 0) \ [state->_kernelEventObserver \ addObjectForReading: object]; \ \ queueItem = [[[type alloc] init] autorelease]; # define NEW_WRITE(type, object, mode) \ @@ -829,11 +829,11 @@ queue = [OFList list]; \ [state->_writeQueues setObject: queue \ forKey: object]; \ } \ \ - if ([queue count] == 0) \ + if (queue.count == 0) \ [state->_kernelEventObserver \ addObjectForWriting: object]; \ \ queueItem = [[[type alloc] init] autorelease]; #define QUEUE_ITEM \ @@ -1036,11 +1036,11 @@ if (state == nil) return; if ((queue = [state->_writeQueues objectForKey: object]) != nil) { - assert([queue count] > 0); + assert(queue.count > 0); /* * Clear the queue now, in case this has been called from a * handler, as otherwise, we'd do the cleanups below twice. */ @@ -1049,11 +1049,11 @@ [state->_kernelEventObserver removeObjectForWriting: object]; [state->_writeQueues removeObjectForKey: object]; } if ((queue = [state->_readQueues objectForKey: object]) != nil) { - assert([queue count] > 0); + assert(queue.count > 0); /* * Clear the queue now, in case this has been called from a * handler, as otherwise, we'd do the cleanups below twice. */ @@ -1180,11 +1180,11 @@ [state->_timersQueueMutex lock]; @try { #endif of_list_object_t *iter; - for (iter = [state->_timersQueue firstListObject]; iter != NULL; + for (iter = state->_timersQueue.firstListObject; iter != NULL; iter = iter->next) { if ([iter->object isEqual: timer]) { [state->_timersQueue removeListObject: iter]; break; } @@ -1204,11 +1204,11 @@ - (void)runUntilDate: (OFDate *)deadline { _stop = false; while (!_stop && - (deadline == nil || [deadline timeIntervalSinceNow] >= 0)) + (deadline == nil || deadline.timeIntervalSinceNow >= 0)) [self runMode: of_run_loop_mode_default beforeDate: deadline]; } - (void)runMode: (of_run_loop_mode_t)mode @@ -1232,14 +1232,14 @@ #ifdef OF_HAVE_THREADS [state->_timersQueueMutex lock]; @try { #endif of_list_object_t *listObject = - [state->_timersQueue firstListObject]; + state->_timersQueue.firstListObject; - if (listObject != NULL && [[listObject->object - fireDate] timeIntervalSinceNow] <= 0) { + if (listObject != NULL && [listObject->object + fireDate].timeIntervalSinceNow <= 0) { timer = [[listObject->object retain] autorelease]; [state->_timersQueue removeListObject: listObject]; @@ -1252,11 +1252,11 @@ } @finally { [state->_timersQueueMutex unlock]; } #endif - if ([timer isValid]) { + if (timer.valid) { [timer fire]; return; } } @@ -1275,26 +1275,26 @@ /* Watch for I/O events until the next timer is due */ if (nextTimer != nil || deadline != nil) { of_time_interval_t timeout; if (nextTimer != nil && deadline == nil) - timeout = [nextTimer timeIntervalSinceNow]; + timeout = nextTimer.timeIntervalSinceNow; else if (nextTimer == nil && deadline != nil) - timeout = [deadline timeIntervalSinceNow]; + timeout = deadline.timeIntervalSinceNow; else - timeout = [[nextTimer earlierDate: deadline] - timeIntervalSinceNow]; + timeout = [nextTimer earlierDate: deadline] + .timeIntervalSinceNow; if (timeout < 0) timeout = 0; #if defined(OF_HAVE_SOCKETS) @try { [state->_kernelEventObserver observeForTimeInterval: timeout]; } @catch (OFObserveFailedException *e) { - if ([e errNo] != EINTR) + if (e.errNo != EINTR) @throw e; } #elif defined(OF_HAVE_THREADS) [state->_condition lock]; [state->_condition waitForTimeInterval: timeout]; @@ -1310,11 +1310,11 @@ */ #if defined(OF_HAVE_SOCKETS) @try { [state->_kernelEventObserver observe]; } @catch (OFObserveFailedException *e) { - if ([e errNo] != EINTR) + if (e.errNo != EINTR) @throw e; } #elif defined(OF_HAVE_THREADS) [state->_condition lock]; [state->_condition wait]; Index: src/OFSHA1Hash.m ================================================================== --- src/OFSHA1Hash.m +++ src/OFSHA1Hash.m @@ -116,11 +116,11 @@ self = [super init]; @try { _iVarsData = [[OFSecureData alloc] initWithCount: sizeof(*_iVars)]; - _iVars = [_iVarsData items]; + _iVars = _iVarsData.mutableItems; [self of_resetState]; } @catch (id e) { [self release]; @throw e; @@ -144,11 +144,11 @@ - (id)copy { OFSHA1Hash *copy = [[OFSHA1Hash alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; - copy->_iVars = [copy->_iVarsData items]; + copy->_iVars = copy->_iVarsData.mutableItems; copy->_calculated = _calculated; return copy; } Index: src/OFSHA224Or256Hash.m ================================================================== --- src/OFSHA224Or256Hash.m +++ src/OFSHA224Or256Hash.m @@ -138,13 +138,13 @@ self = [super init]; @try { _iVarsData = [[OFSecureData alloc] initWithCount: sizeof(*_iVars)]; - _iVars = [_iVarsData items]; + _iVars = _iVarsData.mutableItems; - if ([self class] == [OFSHA224Or256Hash class]) { + if (self.class == [OFSHA224Or256Hash class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } [self of_resetState]; @@ -171,11 +171,11 @@ - (id)copy { OFSHA224Or256Hash *copy = [[[self class] alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; - copy->_iVars = [copy->_iVarsData items]; + copy->_iVars = copy->_iVarsData.mutableItems; copy->_calculated = _calculated; return copy; } Index: src/OFSHA384Or512Hash.m ================================================================== --- src/OFSHA384Or512Hash.m +++ src/OFSHA384Or512Hash.m @@ -149,13 +149,13 @@ self = [super init]; @try { _iVarsData = [[OFSecureData alloc] initWithCount: sizeof(*_iVars)]; - _iVars = [_iVarsData items]; + _iVars = _iVarsData.mutableItems; - if ([self class] == [OFSHA384Or512Hash class]) { + if (self.class == [OFSHA384Or512Hash class]) { [self doesNotRecognizeSelector: _cmd]; abort(); } [self of_resetState]; @@ -182,11 +182,11 @@ - (id)copy { OFSHA384Or512Hash *copy = [[[self class] alloc] of_init]; copy->_iVarsData = [_iVarsData copy]; - copy->_iVars = [copy->_iVarsData items]; + copy->_iVars = copy->_iVarsData.mutableItems; copy->_calculated = _calculated; return copy; } Index: src/OFSecureData.h ================================================================== --- src/OFSecureData.h +++ src/OFSecureData.h @@ -35,10 +35,18 @@ #ifdef OF_HAVE_CLASS_PROPERTIES @property (class, readonly, nonatomic, getter=isSecure) bool secure; #endif +/*! + * @brief All items of the OFSecureData as a C array. + * + * Modifying the returned array directly is allowed and will change the contents + * of the data. + */ +@property (readonly, nonatomic) void *mutableItems OF_RETURNS_INNER_POINTER; + /*! * @brief Whether OFSecureData is secure, meaning preventing the data from * being swapped out is supported. */ + (bool)isSecure; @@ -103,10 +111,21 @@ * @return An initialized OFSecureData */ - (instancetype)initWithItemSize: (size_t)itemSize count: (size_t)count; +/*! + * @brief Returns a specific item of the OFSecureData. + * + * Modifying the returned item directly is allowed and will change the contents + * of the data array. + * + * @param index The number of the item to return + * @return The specified item of the OFSecureData + */ +- (void *)mutableItemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER; + /*! * @brief Checks the OFSecureData for equality to another object. * * If the specified object is a subclass of @ref OFData, the comparison is * performed in constant time. @@ -136,52 +155,6 @@ - (void)writeToURL: (OFURL *)URL OF_UNAVAILABLE; - (OFXMLElement *)XMLElementBySerializing OF_UNAVAILABLE; - (OFData *)messagePackRepresentation OF_UNAVAILABLE; @end -@interface OFSecureData (MutableRetrieving) -/* GCC does not like overriding properties with a different type. */ -#if defined(__clang__) || defined(DOXYGEN) -/*! - * @brief All items of the OFSecureData as a C array. - * - * Modifying the returned array directly is allowed and will change the contents - * of the data. - */ -@property (readonly, nonatomic) void *items OF_RETURNS_INNER_POINTER; - -/*! - * @brief The first item of the OFSecureData or `NULL`. - * - * Modifying the returned item directly is allowed and will change the contents - * of the data. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *firstItem - OF_RETURNS_INNER_POINTER; - -/*! - * @brief Last item of the OFSecureData or `NULL`. - * - * Modifying the returned item directly is allowed and will change the contents - * of the data. - */ -@property OF_NULLABLE_PROPERTY (readonly, nonatomic) void *lastItem - OF_RETURNS_INNER_POINTER; -#else -- (void *)items; -- (nullable void *)firstItem; -- (nullable void *)lastItem; -#endif - -/*! - * @brief Returns a specific item of the OFSecureData. - * - * Modifying the returned item directly is allowed and will change the contents - * of the data array. - * - * @param index The number of the item to return - * @return The specified item of the OFSecureData - */ -- (void *)itemAtIndex: (size_t)index OF_RETURNS_INNER_POINTER; -@end - OF_ASSUME_NONNULL_END Index: src/OFSecureData.m ================================================================== --- src/OFSecureData.m +++ src/OFSecureData.m @@ -506,10 +506,23 @@ removePageIfEmpty(_page); } [super dealloc]; } + +- (void *)mutableItems +{ + return _items; +} + +- (void *)mutableItemAtIndex: (size_t)idx +{ + if (idx >= _count) + @throw [OFOutOfRangeException exception]; + + return _items + idx * _itemSize; +} - (void)zero { of_explicit_memset(_items, 0, _count * _itemSize); } Index: src/OFSet.m ================================================================== --- src/OFSet.m +++ src/OFSet.m @@ -217,19 +217,19 @@ id ret; if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - key = [key substringWithRange: of_range(1, [key length] - 1)]; + key = [key substringWithRange: of_range(1, key.length - 1)]; ret = [[super valueForKey: key] retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - ret = [OFMutableSet setWithCapacity: [self count]]; + ret = [OFMutableSet setWithCapacity: self.count]; for (id object in self) { id value = [object valueForKey: key]; if (value != nil) @@ -245,11 +245,11 @@ forKey: (OFString *)key { if ([key hasPrefix: @"@"]) { void *pool = objc_autoreleasePoolPush(); - key = [key substringWithRange: of_range(1, [key length] - 1)]; + key = [key substringWithRange: of_range(1, key.length - 1)]; [super setValue: value forKey: key]; objc_autoreleasePoolPop(pool); return; @@ -287,11 +287,11 @@ if (![object isKindOfClass: [OFSet class]]) return false; set = object; - if ([set count] != [self count]) + if (set.count != self.count) return false; return [set isSubsetOfSet: self]; } @@ -310,11 +310,11 @@ - (OFString *)description { void *pool; OFMutableString *ret; - size_t i, count = [self count]; + size_t i, count = self.count; if (count == 0) return @"{()}"; ret = [OFMutableString stringWithString: @"{(\n"]; @@ -384,11 +384,11 @@ namespace: OF_SERIALIZATION_NS]; for (id object in self) { void *pool2 = objc_autoreleasePoolPush(); - [element addChild: [object XMLElementBySerializing]]; + [element addChild: object.XMLElementBySerializing]; objc_autoreleasePoolPop(pool2); } [element retain]; Index: src/OFSet_hashtable.m ================================================================== --- src/OFSet_hashtable.m +++ src/OFSet_hashtable.m @@ -90,11 +90,11 @@ if (set == nil) return [self init]; @try { - count = [set count]; + count = set.count; } @catch (id e) { [self release]; @throw e; } @@ -118,11 +118,11 @@ if (array == nil) return self; @try { - count = [array count]; + count = array.count; } @catch (id e) { [self release]; @throw e; } @@ -195,13 +195,13 @@ self = [self init]; @try { void *pool = objc_autoreleasePoolPush(); - if ((![[element name] isEqual: @"OFSet"] && - ![[element name] isEqual: @"OFMutableSet"]) || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if ((![element.name isEqual: @"OFSet"] && + ![element.name isEqual: @"OFMutableSet"]) || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; for (OFXMLElement *child in [element elementsForNamespace: OF_SERIALIZATION_NS]) { void *pool2 = objc_autoreleasePoolPush(); Index: src/OFSettings_INIFile.m ================================================================== --- src/OFSettings_INIFile.m +++ src/OFSettings_INIFile.m @@ -67,11 +67,11 @@ return; } *category = [path substringWithRange: of_range(0, pos)]; *key = [path substringWithRange: - of_range(pos + 1, [path length] - pos - 1)]; + of_range(pos + 1, path.length - pos - 1)]; } - (void)setString: (OFString *)string forPath: (OFString *)path { Index: src/OFStdIOStream.m ================================================================== --- src/OFStdIOStream.m +++ src/OFStdIOStream.m @@ -97,11 +97,11 @@ va_list arguments; date = [OFDate date]; dateString = [date localDateStringWithFormat: @"%Y-%m-%d %H:%M:%S"]; #ifdef OF_HAVE_FILES - me = [[OFApplication programName] lastPathComponent]; + me = [OFApplication programName].lastPathComponent; #else me = [OFApplication programName]; #endif va_start(arguments, format); @@ -108,11 +108,11 @@ msg = [[[OFString alloc] initWithFormat: format arguments: arguments] autorelease]; va_end(arguments); [of_stderr writeFormat: @"[%@.%03d %@(%d)] %@\n", dateString, - [date microsecond] / 1000, me, getpid(), msg]; + date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } @implementation OFStdIOStream Index: src/OFStdIOStream_Win32Console.m ================================================================== --- src/OFStdIOStream_Win32Console.m +++ src/OFStdIOStream_Win32Console.m @@ -166,12 +166,12 @@ if (UTF16Len <= i + 1) { _incompleteUTF16Surrogate = c; if (rest != nil) { - char *items = [rest items]; - size_t count = [rest count]; + char *items = rest.items; + size_t count = rest.count; [self unreadFromBuffer: items length: count]; } @@ -206,12 +206,12 @@ count: UTF8Len]; } } if (rest != nil) - [self unreadFromBuffer: [rest items] - length: [rest count]]; + [self unreadFromBuffer: rest.items + length: rest.count]; } @finally { [self freeMemory: UTF16]; } objc_autoreleasePoolPop(pool); Index: src/OFStream.h ================================================================== --- src/OFStream.h +++ src/OFStream.h @@ -48,13 +48,12 @@ * @param length The length of the data that has been read * @param exception An exception which occurred while reading or `nil` on * success * @return A bool whether the same block should be used for the next read */ -typedef bool (^of_stream_async_read_block_t)( - OF_KINDOF(OFStream *) _Nonnull stream, void *_Nonnull buffer, - size_t length, id _Nullable exception); +typedef bool (^of_stream_async_read_block_t)(OFStream *_Nonnull stream, + void *_Nonnull buffer, size_t length, id _Nullable exception); /*! * @brief A block which is called when a line was read asynchronously from a * stream. * @@ -63,13 +62,12 @@ * occurred * @param exception An exception which occurred while reading or `nil` on * success * @return A bool whether the same block should be used for the next read */ -typedef bool (^of_stream_async_read_line_block_t)( - OF_KINDOF(OFStream *) _Nonnull stream, OFString *_Nullable line, - id _Nullable exception); +typedef bool (^of_stream_async_read_line_block_t)(OFStream *_Nonnull stream, + OFString *_Nullable line, id _Nullable exception); /*! * @brief A block which is called when data was written asynchronously to a * stream. * @@ -80,11 +78,11 @@ * @param exception An exception which occurred while writing or `nil` on * success * @return The data to repeat the write with or nil if it should not repeat */ typedef OFData *_Nullable (^of_stream_async_write_data_block_t)( - OF_KINDOF(OFStream *) _Nonnull stream, OFData *_Nonnull data, + OFStream *_Nonnull stream, OFData *_Nonnull data, size_t bytesWritten, id _Nullable exception); /*! * @brief A block which is called when a string was written asynchronously to a * stream. @@ -97,11 +95,11 @@ * @param exception An exception which occurred while writing or `nil` on * success * @return The string to repeat the write with or nil if it should not repeat */ typedef OFString *_Nullable (^of_stream_async_write_string_block_t)( - OF_KINDOF(OFStream *) _Nonnull stream, OFString *_Nonnull string, + OFStream *_Nonnull stream, OFString *_Nonnull string, of_string_encoding_t encoding, size_t bytesWritten, id _Nullable exception); #endif /*! * @protocol OFStreamDelegate OFStream.h ObjFW/OFStream.h @@ -118,11 +116,11 @@ * @param buffer A buffer with the data that has been read * @param length The length of the data that has been read * @param exception An exception that occurred while reading, or nil on success * @return A bool whether the read should be repeated */ -- (bool)stream: (OF_KINDOF(OFStream *))stream +- (bool)stream: (OFStream *)stream didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (nullable id)exception; /*! @@ -133,11 +131,11 @@ * @param line The line which has been read or `nil` when the end of stream * occurred * @param exception An exception that occurred while reading, or nil on success * @return A bool whether the read should be repeated */ -- (bool)stream: (OF_KINDOF(OFStream *))stream +- (bool)stream: (OFStream *)stream didReadLine: (nullable OFString *)line exception: (nullable id)exception; /*! * @brief This method is called when data was written asynchronously to a @@ -149,11 +147,11 @@ * matches the length of the specified data on the * asynchronous write if no exception was encountered. * @param exception An exception that occurred while writing, or nil on success * @return The data to repeat the write with or nil if it should not repeat */ -- (nullable OFData *)stream: (OF_KINDOF(OFStream *))stream +- (nullable OFData *)stream: (OFStream *)stream didWriteData: (OFData *)data bytesWritten: (size_t)bytesWritten exception: (nullable id)exception; /*! @@ -167,11 +165,11 @@ * matches the length of the specified data on the * asynchronous write if no exception was encountered. * @param exception An exception that occurred while writing, or nil on success * @return The string to repeat the write with or nil if it should not repeat */ -- (nullable OFString *)stream: (OF_KINDOF(OFStream *))stream +- (nullable OFString *)stream: (OFStream *)stream didWriteString: (OFString *)string encoding: (of_string_encoding_t)encoding bytesWritten: (size_t)bytesWritten exception: (nullable id)exception; @end Index: src/OFStream.m ================================================================== --- src/OFStream.m +++ src/OFStream.m @@ -184,11 +184,11 @@ exactLength: (size_t)length { size_t readLength = 0; while (readLength < length) { - if ([self isAtEndOfStream]) + if (self.atEndOfStream) @throw [OFTruncatedDataException exception]; readLength += [self readIntoBuffer: (char *)buffer + readLength length: length - readLength]; } @@ -660,11 +660,11 @@ OFMutableData *data = [OFMutableData data]; size_t pageSize = [OFSystemInfo pageSize]; char *buffer = [self allocMemoryWithSize: pageSize]; @try { - while (![self isAtEndOfStream]) { + while (!self.atEndOfStream) { size_t length; length = [self readIntoBuffer: buffer length: pageSize]; [data addItems: buffer @@ -865,11 +865,11 @@ - (OFString *)readLineWithEncoding: (of_string_encoding_t)encoding { OFString *line = nil; while ((line = [self tryReadLineWithEncoding: encoding]) == nil) - if ([self isAtEndOfStream]) + if (self.atEndOfStream) return nil; return line; } @@ -1112,14 +1112,13 @@ - (OFString *)readTillDelimiter: (OFString *)delimiter encoding: (of_string_encoding_t)encoding { OFString *ret = nil; - while ((ret = [self tryReadTillDelimiter: delimiter encoding: encoding]) == nil) - if ([self isAtEndOfStream]) + if (self.atEndOfStream) return nil; return ret; } @@ -1694,13 +1693,13 @@ if (data == nil) @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); - length = [data count] * [data itemSize]; + length = data.count * data.itemSize; - [self writeBuffer: [data items] + [self writeBuffer: data.items length: length]; objc_autoreleasePoolPop(pool); return length; @@ -1780,11 +1779,11 @@ int length; if (format == nil) @throw [OFInvalidArgumentException exception]; - if ((length = of_vasprintf(&UTF8String, [format UTF8String], + if ((length = of_vasprintf(&UTF8String, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; @try { [self writeBuffer: UTF8String @@ -1812,12 +1811,12 @@ bool readImplemented = false, writeImplemented = false; @try { int readFlags; - readFlags = - fcntl([(id)self fileDescriptorForReading], F_GETFL, 0); + readFlags = fcntl(((id )self) + .fileDescriptorForReading, F_GETFL, 0); readImplemented = true; if (readFlags == -1) @throw [OFSetOptionFailedException @@ -1827,23 +1826,23 @@ if (enable) readFlags &= ~O_NONBLOCK; else readFlags |= O_NONBLOCK; - if (fcntl([(id)self fileDescriptorForReading], F_SETFL, - readFlags) == -1) + if (fcntl(((id )self) + .fileDescriptorForReading, F_SETFL, readFlags) == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; } @catch (OFNotImplementedException *e) { } @try { int writeFlags; - writeFlags = - fcntl([(id)self fileDescriptorForWriting], F_GETFL, 0); + writeFlags = fcntl(((id )self) + .fileDescriptorForWriting, F_GETFL, 0); writeImplemented = true; if (writeFlags == -1) @throw [OFSetOptionFailedException @@ -1853,12 +1852,12 @@ if (enable) writeFlags &= ~O_NONBLOCK; else writeFlags |= O_NONBLOCK; - if (fcntl([(id)self fileDescriptorForWriting], F_SETFL, - writeFlags) == -1) + if (fcntl(((id )self) + .fileDescriptorForWriting, F_SETFL, writeFlags) == -1) @throw [OFSetOptionFailedException exceptionWithObject: self errNo: errno]; } @catch (OFNotImplementedException *e) { } Index: src/OFString+CryptoHashing.m ================================================================== --- src/OFString+CryptoHashing.m +++ src/OFString+CryptoHashing.m @@ -36,13 +36,13 @@ id hash = [class cryptoHash]; size_t digestSize = [class digestSize]; const unsigned char *digest; char cString[digestSize * 2]; - [hash updateWithBuffer: [self UTF8String] - length: [self UTF8StringLength]]; - digest = [hash digest]; + [hash updateWithBuffer: self.UTF8String + length: self.UTF8StringLength]; + digest = hash.digest; for (size_t i = 0; i < digestSize; i++) { uint8_t high, low; high = digest[i] >> 4; Index: src/OFString+JSONValue.m ================================================================== --- src/OFString+JSONValue.m +++ src/OFString+JSONValue.m @@ -554,21 +554,21 @@ *pointer += i; @try { if (hasDecimal) number = [OFNumber numberWithDouble: - [string doubleValue]]; + string.doubleValue]; else if (isHex) number = [OFNumber numberWithIntMax: - [string hexadecimalValue]]; + string.hexadecimalValue]; else if ([string isEqual: @"Infinity"]) number = [OFNumber numberWithDouble: INFINITY]; else if ([string isEqual: @"-Infinity"]) number = [OFNumber numberWithDouble: -INFINITY]; else number = [OFNumber numberWithIntMax: - [string decimalValue]]; + string.decimalValue]; } @finally { [string release]; } return number; @@ -648,12 +648,12 @@ } - (id)JSONValueWithDepthLimit: (size_t)depthLimit { void *pool = objc_autoreleasePoolPush(); - const char *pointer = [self UTF8String]; - const char *stop = pointer + [self UTF8StringLength]; + const char *pointer = self.UTF8String; + const char *stop = pointer + self.UTF8StringLength; id object; size_t line = 1; #ifdef __clang_analyzer__ assert(pointer != NULL); Index: src/OFString+PathAdditions_AmigaOS.m ================================================================== --- src/OFString+PathAdditions_AmigaOS.m +++ src/OFString+PathAdditions_AmigaOS.m @@ -30,11 +30,11 @@ OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); bool firstAfterDevice = true; for (OFString *component in components) { - if ([component length] == 0) + if (component.length == 0) continue; if (!firstAfterDevice) [ret appendString: @"/"]; @@ -58,12 +58,12 @@ - (OFArray *)pathComponents { OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); - const char *cString = [self UTF8String]; - size_t i, last = 0, cStringLength = [self UTF8StringLength]; + const char *cString = self.UTF8String; + size_t i, last = 0, cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return ret; } @@ -103,11 +103,11 @@ * AmigaOS needs the full parsing to determine the last path component. * This could be optimized by not creating the temporary objects, * though. */ void *pool = objc_autoreleasePoolPush(); - OFString *ret = [[self pathComponents] lastObject]; + OFString *ret = self.pathComponents.lastObject; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -116,20 +116,20 @@ { void *pool = objc_autoreleasePoolPush(); OFString *ret, *fileName; size_t pos; - fileName = [self lastPathComponent]; + fileName = self.lastPathComponent; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); return @""; } ret = [fileName substringWithRange: - of_range(pos + 1, [fileName length] - pos - 1)]; + of_range(pos + 1, fileName.length - pos - 1)]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -139,27 +139,27 @@ /* * AmigaOS needs the full parsing to delete the last path component. * This could be optimized, though. */ void *pool = objc_autoreleasePoolPush(); - OFArray OF_GENERIC(OFString *) *components = [self pathComponents]; - size_t count = [components count]; + OFArray OF_GENERIC(OFString *) *components = self.pathComponents; + size_t count = components.count; OFString *ret; if (count < 2) { - if ([[components firstObject] hasSuffix: @":"]) { - ret = [[components firstObject] retain]; + if ([components.firstObject hasSuffix: @":"]) { + ret = [components.firstObject retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } objc_autoreleasePoolPop(pool); return @""; } components = [components objectsInRange: - of_range(0, [components count] - 1)]; + of_range(0, components.count - 1)]; ret = [OFString pathWithComponents: components]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; @@ -170,26 +170,26 @@ void *pool; OFMutableArray OF_GENERIC(OFString *) *components; OFString *ret, *fileName; size_t pos; - if ([self length] == 0) + if (self.length == 0) return [[self copy] autorelease]; pool = objc_autoreleasePoolPush(); - components = [[[self pathComponents] mutableCopy] autorelease]; - fileName = [components lastObject]; + components = [[self.pathComponents mutableCopy] autorelease]; + fileName = components.lastObject; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); return [[self copy] autorelease]; } fileName = [fileName substringWithRange: of_range(0, pos)]; - [components replaceObjectAtIndex: [components count] - 1 + [components replaceObjectAtIndex: components.count - 1 withObject: fileName]; ret = [OFString pathWithComponents: components]; [ret retain]; @@ -203,33 +203,33 @@ OFArray OF_GENERIC(OFString *) *components; OFMutableArray OF_GENERIC(OFString *) *array; OFString *ret; bool done = false; - if ([self length] == 0) + if (self.length == 0) return @""; - components = [self pathComponents]; + components = self.pathComponents; - if ([components count] == 1) { + if (components.count == 1) { objc_autoreleasePoolPop(pool); return [[self copy] autorelease]; } array = [[components mutableCopy] autorelease]; while (!done) { - size_t length = [array count]; + size_t length = array.count; done = true; for (size_t i = 0; i < length; i++) { OFString *component = [array objectAtIndex: i]; OFString *parent = (i > 0 ? [array objectAtIndex: i - 1] : 0); - if ([component length] == 0) { + if (component.length == 0) { [array removeObjectAtIndex: i]; done = false; break; } Index: src/OFString+PathAdditions_DOS.m ================================================================== --- src/OFString+PathAdditions_DOS.m +++ src/OFString+PathAdditions_DOS.m @@ -30,11 +30,11 @@ OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); bool first = true; for (OFString *component in components) { - if ([component length] == 0) + if (component.length == 0) continue; if ([component isEqual: @"\\"] || [component isEqual: @"/"]) continue; @@ -63,12 +63,12 @@ - (OFArray *)pathComponents { OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); - const char *cString = [self UTF8String]; - size_t i, last = 0, cStringLength = [self UTF8StringLength]; + const char *cString = self.UTF8String; + size_t i, last = 0, cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return ret; } @@ -103,12 +103,12 @@ OFString *ret; if ([self hasSuffix: @":\\"] || [self hasSuffix: @":/"]) return self; - cString = [self UTF8String]; - cStringLength = [self UTF8StringLength]; + cString = self.UTF8String; + cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return @""; } @@ -151,20 +151,20 @@ { void *pool = objc_autoreleasePoolPush(); OFString *ret, *fileName; size_t pos; - fileName = [self lastPathComponent]; + fileName = self.lastPathComponent; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); return @""; } ret = [fileName substringWithRange: - of_range(pos + 1, [fileName length] - pos - 1)]; + of_range(pos + 1, fileName.length - pos - 1)]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -177,12 +177,12 @@ OFString *ret; if ([self hasSuffix: @":\\"] || [self hasSuffix: @":/"]) return self; - cString = [self UTF8String]; - cStringLength = [self UTF8StringLength]; + cString = self.UTF8String; + cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return @""; } @@ -217,26 +217,26 @@ void *pool; OFMutableArray OF_GENERIC(OFString *) *components; OFString *ret, *fileName; size_t pos; - if ([self length] == 0) + if (self.length == 0) return [[self copy] autorelease]; pool = objc_autoreleasePoolPush(); - components = [[[self pathComponents] mutableCopy] autorelease]; - fileName = [components lastObject]; + components = [[self.pathComponents mutableCopy] autorelease]; + fileName = components.lastObject; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); return [[self copy] autorelease]; } fileName = [fileName substringWithRange: of_range(0, pos)]; - [components replaceObjectAtIndex: [components count] - 1 + [components replaceObjectAtIndex: components.count - 1 withObject: fileName]; ret = [OFString pathWithComponents: components]; [ret retain]; @@ -250,34 +250,34 @@ OFArray OF_GENERIC(OFString *) *components; OFMutableArray OF_GENERIC(OFString *) *array; OFString *ret; bool done = false; - if ([self length] == 0) + if (self.length == 0) return @""; - components = [self pathComponents]; + components = self.pathComponents; - if ([components count] == 1) { + if (components.count == 1) { objc_autoreleasePoolPop(pool); return [[self copy] autorelease]; } array = [[components mutableCopy] autorelease]; while (!done) { - size_t length = [array count]; + size_t length = array.count; done = true; for (size_t i = 0; i < length; i++) { OFString *component = [array objectAtIndex: i]; OFString *parent = (i > 0 ? [array objectAtIndex: i - 1] : 0); if ([component isEqual: @"."] || - [component length] == 0) { + component.length == 0) { [array removeObjectAtIndex: i]; done = false; break; } Index: src/OFString+PathAdditions_UNIX.m ================================================================== --- src/OFString+PathAdditions_UNIX.m +++ src/OFString+PathAdditions_UNIX.m @@ -30,11 +30,11 @@ OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); bool first = true; for (OFString *component in components) { - if ([component length] == 0) + if (component.length == 0) continue; if (!first && [component isEqual: @"/"]) continue; @@ -60,12 +60,12 @@ - (OFArray *)pathComponents { OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); - const char *cString = [self UTF8String]; - size_t i, last = 0, cStringLength = [self UTF8StringLength]; + const char *cString = self.UTF8String; + size_t i, last = 0, cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return ret; } @@ -94,12 +94,12 @@ } - (OFString *)lastPathComponent { void *pool = objc_autoreleasePoolPush(); - const char *cString = [self UTF8String]; - size_t cStringLength = [self UTF8StringLength]; + const char *cString = self.UTF8String; + size_t cStringLength = self.UTF8StringLength; ssize_t i; OFString *ret; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); @@ -143,31 +143,31 @@ { void *pool = objc_autoreleasePoolPush(); OFString *ret, *fileName; size_t pos; - fileName = [self lastPathComponent]; + fileName = self.lastPathComponent; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); return @""; } ret = [fileName substringWithRange: - of_range(pos + 1, [fileName length] - pos - 1)]; + of_range(pos + 1, fileName.length - pos - 1)]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } - (OFString *)stringByDeletingLastPathComponent { void *pool = objc_autoreleasePoolPush(); - const char *cString = [self UTF8String]; - size_t cStringLength = [self UTF8StringLength]; + const char *cString = self.UTF8String; + size_t cStringLength = self.UTF8StringLength; OFString *ret; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return @""; @@ -207,16 +207,16 @@ void *pool; OFMutableArray OF_GENERIC(OFString *) *components; OFString *ret, *fileName; size_t pos; - if ([self length] == 0) + if (self.length == 0) return [[self copy] autorelease]; pool = objc_autoreleasePoolPush(); - components = [[[self pathComponents] mutableCopy] autorelease]; - fileName = [components lastObject]; + components = [[self.pathComponents mutableCopy] autorelease]; + fileName = components.lastObject; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); @@ -240,16 +240,16 @@ OFArray OF_GENERIC(OFString *) *components; OFMutableArray OF_GENERIC(OFString *) *array; OFString *ret; bool done = false, startsWithSlash; - if ([self length] == 0) + if (self.length == 0) return @""; - components = [self pathComponents]; + components = self.pathComponents; - if ([components count] == 1) { + if (components.count == 1) { objc_autoreleasePoolPop(pool); return [[self copy] autorelease]; } array = [[components mutableCopy] autorelease]; @@ -257,21 +257,21 @@ if (startsWithSlash) [array removeObjectAtIndex: 0]; while (!done) { - size_t length = [array count]; + size_t length = array.count; done = true; for (size_t i = 0; i < length; i++) { OFString *component = [array objectAtIndex: i]; OFString *parent = (i > 0 ? [array objectAtIndex: i - 1] : 0); if ([component isEqual: @"."] || - [component length] == 0) { + component.length == 0) { [array removeObjectAtIndex: i]; done = false; break; } Index: src/OFString+PathAdditions_libfat.m ================================================================== --- src/OFString+PathAdditions_libfat.m +++ src/OFString+PathAdditions_libfat.m @@ -30,11 +30,11 @@ OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); bool first = true; for (OFString *component in components) { - if ([component length] == 0) + if (component.length == 0) continue; if ([component isEqual: @"/"]) continue; @@ -63,12 +63,12 @@ - (OFArray *)pathComponents { OFMutableArray OF_GENERIC(OFString *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); - const char *cString = [self UTF8String]; - size_t i, last = 0, cStringLength = [self UTF8StringLength]; + const char *cString = self.UTF8String; + size_t i, last = 0, cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return ret; } @@ -103,12 +103,12 @@ OFString *ret; if ([self hasSuffix: @":/"]) return self; - cString = [self UTF8String]; - cStringLength = [self UTF8StringLength]; + cString = self.UTF8String; + cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return @""; } @@ -150,20 +150,20 @@ { void *pool = objc_autoreleasePoolPush(); OFString *ret, *fileName; size_t pos; - fileName = [self lastPathComponent]; + fileName = self.lastPathComponent; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); return @""; } ret = [fileName substringWithRange: - of_range(pos + 1, [fileName length] - pos - 1)]; + of_range(pos + 1, fileName.length - pos - 1)]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -176,12 +176,12 @@ OFString *ret; if ([self hasSuffix: @":/"]) return self; - cString = [self UTF8String]; - cStringLength = [self UTF8StringLength]; + cString = self.UTF8String; + cStringLength = self.UTF8StringLength; if (cStringLength == 0) { objc_autoreleasePoolPop(pool); return @""; } @@ -215,26 +215,26 @@ void *pool; OFMutableArray OF_GENERIC(OFString *) *components; OFString *ret, *fileName; size_t pos; - if ([self length] == 0) + if (self.length == 0) return [[self copy] autorelease]; pool = objc_autoreleasePoolPush(); - components = [[[self pathComponents] mutableCopy] autorelease]; - fileName = [components lastObject]; + components = [[self.pathComponents mutableCopy] autorelease]; + fileName = components.lastObject; pos = [fileName rangeOfString: @"." options: OF_STRING_SEARCH_BACKWARDS].location; if (pos == OF_NOT_FOUND || pos == 0) { objc_autoreleasePoolPop(pool); return [[self copy] autorelease]; } fileName = [fileName substringWithRange: of_range(0, pos)]; - [components replaceObjectAtIndex: [components count] - 1 + [components replaceObjectAtIndex: components.count - 1 withObject: fileName]; ret = [OFString pathWithComponents: components]; [ret retain]; @@ -248,34 +248,34 @@ OFArray OF_GENERIC(OFString *) *components; OFMutableArray OF_GENERIC(OFString *) *array; OFString *ret; bool done = false; - if ([self length] == 0) + if (self.length == 0) return @""; - components = [self pathComponents]; + components = self.pathComponents; - if ([components count] == 1) { + if (components.count == 1) { objc_autoreleasePoolPop(pool); return [[self copy] autorelease]; } array = [[components mutableCopy] autorelease]; while (!done) { - size_t length = [array count]; + size_t length = array.count; done = true; for (size_t i = 0; i < length; i++) { OFString *component = [array objectAtIndex: i]; OFString *parent = (i > 0 ? [array objectAtIndex: i - 1] : 0); if ([component isEqual: @"."] || - [component length] == 0) { + component.length == 0) { [array removeObjectAtIndex: i]; done = false; break; } Index: src/OFString+PropertyListValue.m ================================================================== --- src/OFString+PropertyListValue.m +++ src/OFString+PropertyListValue.m @@ -37,11 +37,11 @@ parseArrayElement(OFXMLElement *element) { OFMutableArray *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); - for (OFXMLElement *child in [element elements]) + for (OFXMLElement *child in element.elements) [ret addObject: parseElement(child)]; [ret makeImmutable]; objc_autoreleasePoolPop(pool); @@ -52,26 +52,26 @@ static OFDictionary * parseDictElement(OFXMLElement *element) { OFMutableDictionary *ret = [OFMutableDictionary dictionary]; void *pool = objc_autoreleasePoolPush(); - OFArray OF_GENERIC(OFXMLElement *) *children = [element elements]; + OFArray OF_GENERIC(OFXMLElement *) *children = element.elements; OFEnumerator OF_GENERIC(OFXMLElement *) *enumerator; OFXMLElement *key, *object; - if ([children count] % 2 != 0) + if (children.count % 2 != 0) @throw [OFInvalidFormatException exception]; enumerator = [children objectEnumerator]; while ((key = [enumerator nextObject]) && (object = [enumerator nextObject])) { - if ([key namespace] != nil || [[key attributes] count] != 0 || - ![[key name] isEqual: @"key"]) + if (key.namespace != nil || key.attributes.count != 0 || + ![key.name isEqual: @"key"]) @throw [OFInvalidFormatException exception]; [ret setObject: parseElement(object) - forKey: [key stringValue]]; + forKey: key.stringValue]; } [ret makeImmutable]; objc_autoreleasePoolPop(pool); @@ -80,67 +80,65 @@ } static OFString * parseStringElement(OFXMLElement *element) { - return [element stringValue]; + return element.stringValue; } static OFData * parseDataElement(OFXMLElement *element) { - return [OFData dataWithBase64EncodedString: [element stringValue]]; + return [OFData dataWithBase64EncodedString: element.stringValue]; } static OFDate * parseDateElement(OFXMLElement *element) { - return [OFDate dateWithDateString: [element stringValue] + return [OFDate dateWithDateString: element.stringValue format: @"%Y-%m-%dT%H:%M:%SZ"]; } static OFNumber * parseTrueElement(OFXMLElement *element) { - if ([[element children] count] != 0) + if (element.children.count != 0) @throw [OFInvalidFormatException exception]; return [OFNumber numberWithBool: true]; } static OFNumber * parseFalseElement(OFXMLElement *element) { - if ([[element children] count] != 0) + if (element.children.count != 0) @throw [OFInvalidFormatException exception]; return [OFNumber numberWithBool: false]; } static OFNumber * parseRealElement(OFXMLElement *element) { - return [OFNumber numberWithDouble: [[element stringValue] doubleValue]]; + return [OFNumber numberWithDouble: element.stringValue.doubleValue]; } static OFNumber * parseIntegerElement(OFXMLElement *element) { - return [OFNumber numberWithIntMax: - [[element stringValue] decimalValue]]; + return [OFNumber numberWithIntMax: element.stringValue.decimalValue]; } static id parseElement(OFXMLElement *element) { OFString *elementName; - if ([element namespace] != nil || - [[element attributes] count] != 0) + if (element.namespace != nil || element.attributes.count != 0) @throw [OFInvalidFormatException exception]; - elementName = [element name]; + elementName = element.name; if ([elementName isEqual: @"array"]) return parseArrayElement(element); else if ([elementName isEqual: @"dict"]) return parseDictElement(element); @@ -169,30 +167,30 @@ OFXMLElement *rootElement = [OFXMLElement elementWithXMLString: self]; OFXMLAttribute *versionAttribute; OFArray OF_GENERIC(OFXMLElement *) *elements; id ret; - if (![[rootElement name] isEqual: @"plist"] || - [rootElement namespace] != nil) + if (![rootElement.name isEqual: @"plist"] || + rootElement.namespace != nil) @throw [OFInvalidFormatException exception]; versionAttribute = [rootElement attributeForName: @"version"]; if (versionAttribute == nil) @throw [OFInvalidFormatException exception]; - if (![[versionAttribute stringValue] isEqual: @"1.0"]) + if (![versionAttribute.stringValue isEqual: @"1.0"]) @throw [OFUnsupportedVersionException exceptionWithVersion: [versionAttribute stringValue]]; - elements = [rootElement elements]; + elements = rootElement.elements; - if ([elements count] != 1) + if (elements.count != 1) @throw [OFInvalidFormatException exception]; - ret = parseElement([elements firstObject]); + ret = parseElement(elements.firstObject); [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @end Index: src/OFString+Serialization.m ================================================================== --- src/OFString+Serialization.m +++ src/OFString+Serialization.m @@ -46,25 +46,25 @@ @throw [OFInvalidArgumentException exception]; } @catch (OFUnboundNamespaceException *e) { @throw [OFInvalidArgumentException exception]; } - version = [[root attributeForName: @"version"] stringValue]; + version = [root attributeForName: @"version"].stringValue; if (version == nil) @throw [OFInvalidArgumentException exception]; - if ([version decimalValue] != 1) + if (version.decimalValue != 1) @throw [OFUnsupportedVersionException exceptionWithVersion: version]; elements = [root elementsForNamespace: OF_SERIALIZATION_NS]; - if ([elements count] != 1) + if (elements.count != 1) @throw [OFInvalidArgumentException exception]; - object = [[[elements firstObject] objectByDeserializing] retain]; + object = [[elements.firstObject objectByDeserializing] retain]; objc_autoreleasePoolPop(pool); return [object autorelease]; } @end Index: src/OFString+URLEncoding.m ================================================================== --- src/OFString+URLEncoding.m +++ src/OFString+URLEncoding.m @@ -34,12 +34,12 @@ - (OFString *)stringByURLEncodingWithAllowedCharacters: (OFCharacterSet *)allowedCharacters { OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t length = [self length]; + const of_unichar_t *characters = self.characters; + size_t length = self.length; bool (*characterIsMember)(id, SEL, of_unichar_t) = (bool (*)(id, SEL, of_unichar_t))[allowedCharacters methodForSelector: @selector(characterIsMember:)]; for (size_t i = 0; i < length; i++) { @@ -80,12 +80,12 @@ } - (OFString *)stringByURLDecoding { void *pool = objc_autoreleasePoolPush(); - const char *string = [self UTF8String]; - size_t length = [self UTF8StringLength]; + const char *string = self.UTF8String; + size_t length = self.UTF8StringLength; char *retCString, *retCString2; char byte = 0; int state = 0; size_t i = 0; Index: src/OFString+XMLEscaping.m ================================================================== --- src/OFString+XMLEscaping.m +++ src/OFString+XMLEscaping.m @@ -35,12 +35,12 @@ const char *string, *append; size_t length, retLength, appendLen; size_t j; OFString *ret; - string = [self UTF8String]; - length = [self UTF8StringLength]; + string = self.UTF8String; + length = self.UTF8StringLength; j = 0; retLength = length; /* Index: src/OFString+XMLUnescaping.m ================================================================== --- src/OFString+XMLUnescaping.m +++ src/OFString+XMLUnescaping.m @@ -86,12 +86,12 @@ ret = [OFMutableString string]; pool = objc_autoreleasePoolPush(); - string = [self UTF8String]; - length = [self UTF8StringLength]; + string = self.UTF8String; + length = self.UTF8StringLength; last = 0; inEntity = false; for (i = 0; i < length; i++) { Index: src/OFString.m ================================================================== --- src/OFString.m +++ src/OFString.m @@ -146,11 +146,11 @@ of_string_parse_encoding(OFString *string) { void *pool = objc_autoreleasePoolPush(); of_string_encoding_t encoding; - string = [string lowercaseString]; + string = string.lowercaseString; if ([string isEqual: @"utf8"] || [string isEqual: @"utf-8"]) encoding = OF_STRING_ENCODING_UTF_8; else if ([string isEqual: @"ascii"] || [string isEqual: @"us-ascii"]) encoding = OF_STRING_ENCODING_ASCII; @@ -338,12 +338,12 @@ static OFString * decomposedString(OFString *self, const char *const *const *table, size_t size) { OFMutableString *ret = [OFMutableString string]; void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t length = [self length]; + const of_unichar_t *characters = self.characters; + size_t length = self.length; for (size_t i = 0; i < length; i++) { of_unichar_t c = characters[i]; const char *const *page; @@ -873,20 +873,20 @@ - (instancetype)initWithData: (OFData *)data encoding: (of_string_encoding_t)encoding { @try { - if ([data itemSize] != 1) + if (data.itemSize != 1) @throw [OFInvalidArgumentException exception]; } @catch (id e) { [self release]; @throw e; } - self = [self initWithCString: [data items] + self = [self initWithCString: data.items encoding: encoding - length: [data count]]; + length: data.count]; return self; } - (instancetype)initWithString: (OFString *)string @@ -995,17 +995,17 @@ @try { void *pool = objc_autoreleasePoolPush(); OFFile *file = nil; @try { - fileSize = [[[OFFileManager defaultManager] - attributesOfItemAtPath: path] fileSize]; + fileSize = [[OFFileManager defaultManager] + attributesOfItemAtPath: path].fileSize; } @catch (OFRetrieveItemAttributesFailedException *e) { @throw [OFOpenItemFailedException exceptionWithPath: path mode: @"r" - errNo: errno]; + errNo: e.errNo]; } objc_autoreleasePoolPop(pool); # if UINTMAX_MAX > SIZE_MAX @@ -1078,13 +1078,13 @@ } @catch (id e) { [self release]; @throw e; } - self = [self initWithCString: [data items] + self = [self initWithCString: data.items encoding: encoding - length: [data count]]; + length: data.count * data.itemSize]; objc_autoreleasePoolPop(pool); return self; } @@ -1093,22 +1093,22 @@ { void *pool = objc_autoreleasePoolPush(); OFString *stringValue; @try { - if (![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; if ([self isKindOfClass: [OFMutableString class]]) { - if (![[element name] isEqual: @"OFMutableString"]) + if (![element.name isEqual: @"OFMutableString"]) @throw [OFInvalidArgumentException exception]; } else { - if (![[element name] isEqual: @"OFString"]) + if (![element.name isEqual: @"OFString"]) @throw [OFInvalidArgumentException exception]; } - stringValue = [element stringValue]; + stringValue = element.stringValue; } @catch (id e) { [self release]; @throw e; } @@ -1122,12 +1122,12 @@ - (size_t)of_getCString: (char *)cString maxLength: (size_t)maxLength encoding: (of_string_encoding_t)encoding lossy: (bool)lossy { - const of_unichar_t *characters = [self characters]; - size_t i, length = [self length]; + const of_unichar_t *characters = self.characters; + size_t i, length = self.length; switch (encoding) { case OF_STRING_ENCODING_UTF_8:; size_t j = 0; @@ -1372,11 +1372,11 @@ - (const char *)of_cStringWithEncoding: (of_string_encoding_t)encoding lossy: (bool)lossy { OFObject *object = [[[OFObject alloc] init] autorelease]; - size_t length = [self length]; + size_t length = self.length; char *cString; switch (encoding) { case OF_STRING_ENCODING_UTF_8:; size_t cStringLength; @@ -1451,12 +1451,12 @@ switch (encoding) { case OF_STRING_ENCODING_UTF_8:; const of_unichar_t *characters; size_t length, UTF8StringLength = 0; - characters = [self characters]; - length = [self length]; + characters = self.characters; + length = self.length; for (size_t i = 0; i < length; i++) { char buffer[4]; size_t len = of_string_utf8_encode(characters[i], buffer); @@ -1479,11 +1479,11 @@ case OF_STRING_ENCODING_CODEPAGE_850: case OF_STRING_ENCODING_CODEPAGE_858: case OF_STRING_ENCODING_MAC_ROMAN: case OF_STRING_ENCODING_KOI8_R: case OF_STRING_ENCODING_KOI8_U: - return [self length]; + return self.length; default: @throw [OFInvalidEncodingException exception]; } } @@ -1516,19 +1516,19 @@ if (![object isKindOfClass: [OFString class]]) return false; otherString = object; - length = [self length]; + length = self.length; - if ([otherString length] != length) + if (otherString.length != length) return false; pool = objc_autoreleasePoolPush(); - characters = [self characters]; - otherCharacters = [otherString characters]; + characters = self.characters; + otherCharacters = otherString.characters; if (memcmp(characters, otherCharacters, length * sizeof(of_unichar_t)) != 0) { objc_autoreleasePoolPop(pool); return false; @@ -1561,17 +1561,17 @@ if (![(id)object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; otherString = (OFString *)object; - minimumLength = ([self length] > [otherString length] - ? [otherString length] : [self length]); + minimumLength = (self.length > otherString.length + ? otherString.length : self.length); pool = objc_autoreleasePoolPush(); - characters = [self characters]; - otherCharacters = [otherString characters]; + characters = self.characters; + otherCharacters = otherString.characters; for (size_t i = 0; i < minimumLength; i++) { if (characters[i] > otherCharacters[i]) { objc_autoreleasePoolPop(pool); return OF_ORDERED_DESCENDING; @@ -1583,13 +1583,13 @@ } } objc_autoreleasePoolPop(pool); - if ([self length] > [otherString length]) + if (self.length > otherString.length) return OF_ORDERED_DESCENDING; - if ([self length] < [otherString length]) + if (self.length < otherString.length) return OF_ORDERED_ASCENDING; return OF_ORDERED_SAME; } @@ -1600,14 +1600,14 @@ size_t length, otherLength, minimumLength; if (otherString == self) return OF_ORDERED_SAME; - characters = [self characters]; - otherCharacters = [otherString characters]; - length = [self length]; - otherLength = [otherString length]; + characters = self.characters; + otherCharacters = otherString.characters; + length = self.length; + otherLength = otherString.length; minimumLength = (length > otherLength ? otherLength : length); for (size_t i = 0; i < minimumLength; i++) { of_unichar_t c = characters[i]; @@ -1653,22 +1653,22 @@ return OF_ORDERED_SAME; } - (uint32_t)hash { - const of_unichar_t *characters = [self characters]; - size_t length = [self length]; + const of_unichar_t *characters = self.characters; + size_t length = self.length; uint32_t hash; OF_HASH_INIT(hash); for (size_t i = 0; i < length; i++) { const of_unichar_t c = characters[i]; OF_HASH_ADD(hash, (c & 0xFF0000) >> 16); - OF_HASH_ADD(hash, (c & 0x00FF00) >> 8); - OF_HASH_ADD(hash, c & 0x0000FF); + OF_HASH_ADD(hash, (c & 0x00FF00) >> 8); + OF_HASH_ADD(hash, c & 0x0000FF); } OF_HASH_FINALIZE(hash); return hash; @@ -1735,11 +1735,11 @@ if (options & OF_JSON_REPRESENTATION_JSON5) { [JSON replaceOccurrencesOfString: @"\n" withString: @"\\\n"]; if (options & OF_JSON_REPRESENTATION_IDENTIFIER) { - const char *cString = [self UTF8String]; + const char *cString = self.UTF8String; if ((!of_ascii_isalpha(cString[0]) && cString[0] != '_' && cString[0] != '$') || strpbrk(cString, " \n\r\t\b\f\\\"'") != NULL) { [JSON prependString: @"\""]; @@ -1765,11 +1765,11 @@ - (OFData *)messagePackRepresentation { OFMutableData *data; size_t length; - length = [self UTF8StringLength]; + length = self.UTF8StringLength; if (length <= 31) { uint8_t tmp = 0xA0 | ((uint8_t)length & 0x1F); data = [OFMutableData dataWithItemSize: 1 @@ -1806,29 +1806,29 @@ [data addItems: &tmp count: sizeof(tmp)]; } else @throw [OFOutOfRangeException exception]; - [data addItems: [self UTF8String] + [data addItems: self.UTF8String count: length]; return data; } - (of_range_t)rangeOfString: (OFString *)string { return [self rangeOfString: string options: 0 - range: of_range(0, [self length])]; + range: of_range(0, self.length)]; } - (of_range_t)rangeOfString: (OFString *)string options: (int)options { return [self rangeOfString: string options: options - range: of_range(0, [self length])]; + range: of_range(0, self.length)]; } - (of_range_t)rangeOfString: (OFString *)string options: (int)options range: (of_range_t)range @@ -1836,11 +1836,11 @@ void *pool; const of_unichar_t *searchCharacters; of_unichar_t *characters; size_t searchLength; - if ((searchLength = [string length]) == 0) + if ((searchLength = string.length) == 0) return of_range(0, 0); if (searchLength > range.length) return of_range(OF_NOT_FOUND, 0); @@ -1847,11 +1847,11 @@ if (range.length > SIZE_MAX / sizeof(of_unichar_t)) @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); - searchCharacters = [string characters]; + searchCharacters = string.characters; if ((characters = malloc(range.length * sizeof(of_unichar_t))) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: range.length * sizeof(of_unichar_t)]; @@ -1894,19 +1894,19 @@ - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet { return [self indexOfCharacterFromSet: characterSet options: 0 - range: of_range(0, [self length])]; + range: of_range(0, self.length)]; } - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet options: (int)options { return [self indexOfCharacterFromSet: characterSet options: options - range: of_range(0, [self length])]; + range: of_range(0, self.length)]; } - (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet options: (int)options range: (of_range_t)range @@ -1959,20 +1959,20 @@ { void *pool; const of_unichar_t *characters, *searchCharacters; size_t length, searchLength; - if ((searchLength = [string length]) == 0) + if ((searchLength = string.length) == 0) return true; - if (searchLength > (length = [self length])) + if (searchLength > (length = self.length)) return false; pool = objc_autoreleasePoolPush(); - characters = [self characters]; - searchCharacters = [string characters]; + characters = self.characters; + searchCharacters = string.characters; for (size_t i = 0; i <= length - searchLength; i++) { if (memcmp(characters + i, searchCharacters, searchLength * sizeof(of_unichar_t)) == 0) { objc_autoreleasePoolPop(pool); @@ -1989,16 +1989,16 @@ { void *pool; OFString *ret; if (range.length > SIZE_MAX - range.location || - range.location + range.length > [self length]) + range.location + range.length > self.length) @throw [OFOutOfRangeException exception]; pool = objc_autoreleasePoolPush(); ret = [[OFString alloc] - initWithCharacters: [self characters] + range.location + initWithCharacters: self.characters + range.location length: range.length]; objc_autoreleasePoolPop(pool); return [ret autorelease]; } @@ -2150,15 +2150,14 @@ } - (bool)hasPrefix: (OFString *)prefix { of_unichar_t *tmp; - const of_unichar_t *prefixCharacters; size_t prefixLength; bool hasPrefix; - if ((prefixLength = [prefix length]) > [self length]) + if ((prefixLength = prefix.length) > self.length) return false; tmp = [self allocMemoryWithSize: sizeof(of_unichar_t) count: prefixLength]; @try { @@ -2165,12 +2164,11 @@ void *pool = objc_autoreleasePoolPush(); [self getCharacters: tmp inRange: of_range(0, prefixLength)]; - prefixCharacters = [prefix characters]; - hasPrefix = (memcmp(tmp, prefixCharacters, + hasPrefix = (memcmp(tmp, prefix.characters, prefixLength * sizeof(of_unichar_t)) == 0); objc_autoreleasePoolPop(pool); } @finally { [self freeMemory: tmp]; @@ -2184,14 +2182,14 @@ of_unichar_t *tmp; const of_unichar_t *suffixCharacters; size_t length, suffixLength; bool hasSuffix; - if ((suffixLength = [suffix length]) > [self length]) + if ((suffixLength = suffix.length) > self.length) return false; - length = [self length]; + length = self.length; tmp = [self allocMemoryWithSize: sizeof(of_unichar_t) count: suffixLength]; @try { void *pool = objc_autoreleasePoolPush(); @@ -2198,11 +2196,11 @@ [self getCharacters: tmp inRange: of_range(length - suffixLength, suffixLength)]; - suffixCharacters = [suffix characters]; + suffixCharacters = suffix.characters; hasSuffix = (memcmp(tmp, suffixCharacters, suffixLength * sizeof(of_unichar_t)) == 0); objc_autoreleasePoolPop(pool); } @finally { @@ -2223,19 +2221,19 @@ { void *pool; OFMutableArray *array = [OFMutableArray array]; const of_unichar_t *characters, *delimiterCharacters; bool skipEmpty = (options & OF_STRING_SKIP_EMPTY); - size_t length = [self length]; - size_t delimiterLength = [delimiter length]; + size_t length = self.length; + size_t delimiterLength = delimiter.length; size_t last; OFString *component; pool = objc_autoreleasePoolPush(); - characters = [self characters]; - delimiterCharacters = [delimiter characters]; + characters = self.characters; + delimiterCharacters = delimiter.characters; if (delimiterLength > length) { [array addObject: [[self copy] autorelease]]; [array makeImmutable]; @@ -2249,18 +2247,18 @@ if (memcmp(characters + i, delimiterCharacters, delimiterLength * sizeof(of_unichar_t)) != 0) continue; component = [self substringWithRange: of_range(last, i - last)]; - if (!skipEmpty || [component length] > 0) + if (!skipEmpty || component.length > 0) [array addObject: component]; i += delimiterLength - 1; last = i + 1; } component = [self substringWithRange: of_range(last, length - last)]; - if (!skipEmpty || [component length] > 0) + if (!skipEmpty || component.length > 0) [array addObject: component]; [array makeImmutable]; objc_autoreleasePoolPop(pool); @@ -2280,12 +2278,12 @@ options: (int)options { OFMutableArray *array = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); bool skipEmpty = (options & OF_STRING_SKIP_EMPTY); - const of_unichar_t *characters = [self characters]; - size_t length = [self length]; + const of_unichar_t *characters = self.characters; + size_t length = self.length; bool (*characterIsMember)(id, SEL, of_unichar_t) = (bool (*)(id, SEL, of_unichar_t))[characterSet methodForSelector: @selector(characterIsMember:)]; size_t last; @@ -2316,12 +2314,12 @@ } - (intmax_t)decimalValue { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t i = 0, length = [self length]; + const of_unichar_t *characters = self.characters; + size_t i = 0, length = self.length; intmax_t value = 0; bool expectWhitespace = false; while (length > 0 && of_ascii_isspace(*characters)) { characters++; @@ -2365,12 +2363,12 @@ } - (uintmax_t)hexadecimalValue { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t i = 0, length = [self length]; + const of_unichar_t *characters = self.characters; + size_t i = 0, length = self.length; uintmax_t value = 0; bool expectWhitespace = false, foundValue = false; while (length > 0 && of_ascii_isspace(*characters)) { characters++; @@ -2428,12 +2426,12 @@ } - (uintmax_t)octalValue { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t i = 0, length = [self length]; + const of_unichar_t *characters = self.characters; + size_t i = 0, length = self.length; uintmax_t value = 0; bool expectWhitespace = false; while (length > 0 && of_ascii_isspace(*characters)) { characters++; @@ -2477,11 +2475,11 @@ - (float)floatValue { void *pool = objc_autoreleasePoolPush(); #if defined(OF_AMIGAOS_M68K) || defined(OF_MORPHOS) - OFString *stripped = [self stringByDeletingEnclosingWhitespaces]; + OFString *stripped = self.stringByDeletingEnclosingWhitespaces; if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME || [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME) return INFINITY; if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME || @@ -2488,20 +2486,20 @@ [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME) return -INFINITY; #endif #ifdef HAVE_STRTOF_L - const char *UTF8String = [self UTF8String]; + const char *UTF8String = self.UTF8String; #else /* * If we have no strtof_l, we have no other choice but to replace "." * with the locale's decimal point. */ OFString *decimalPoint = [OFLocale decimalPoint]; - const char *UTF8String = [[self + const char *UTF8String = [self stringByReplacingOccurrencesOfString: @"." - withString: decimalPoint] UTF8String]; + withString: decimalPoint].UTF8String; #endif char *endPointer = NULL; float value; while (of_ascii_isspace(*UTF8String)) @@ -2527,11 +2525,11 @@ - (double)doubleValue { void *pool = objc_autoreleasePoolPush(); #if defined(OF_AMIGAOS_M68K) || defined(OF_MORPHOS) - OFString *stripped = [self stringByDeletingEnclosingWhitespaces]; + OFString *stripped = self.stringByDeletingEnclosingWhitespaces; if ([stripped caseInsensitiveCompare: @"INF"] == OF_ORDERED_SAME || [stripped caseInsensitiveCompare: @"INFINITY"] == OF_ORDERED_SAME) return INFINITY; if ([stripped caseInsensitiveCompare: @"-INF"] == OF_ORDERED_SAME || @@ -2538,20 +2536,20 @@ [stripped caseInsensitiveCompare: @"-INFINITY"] == OF_ORDERED_SAME) return -INFINITY; #endif #ifdef HAVE_STRTOD_L - const char *UTF8String = [self UTF8String]; + const char *UTF8String = self.UTF8String; #else /* * If we have no strtod_l, we have no other choice but to replace "." * with the locale's decimal point. */ OFString *decimalPoint = [OFLocale decimalPoint]; - const char *UTF8String = [[self + const char *UTF8String = [self stringByReplacingOccurrencesOfString: @"." - withString: decimalPoint] UTF8String]; + withString: decimalPoint].UTF8String; #endif char *endPointer = NULL; double value; while (of_ascii_isspace(*UTF8String)) @@ -2575,11 +2573,11 @@ } - (const of_unichar_t *)characters { OFObject *object = [[[OFObject alloc] init] autorelease]; - size_t length = [self length]; + size_t length = self.length; of_unichar_t *ret; ret = [object allocMemoryWithSize: sizeof(of_unichar_t) count: length]; [self getCharacters: ret @@ -2595,12 +2593,12 @@ - (const of_char16_t *)UTF16StringWithByteOrder: (of_byte_order_t)byteOrder { OFObject *object = [[[OFObject alloc] init] autorelease]; void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t length = [self length]; + const of_unichar_t *characters = self.characters; + size_t length = self.length; of_char16_t *ret; size_t j; bool swap = (byteOrder != OF_BYTE_ORDER_NATIVE); /* Allocate memory for the worst case */ @@ -2645,14 +2643,14 @@ return ret; } - (size_t)UTF16StringLength { - const of_unichar_t *characters = [self characters]; + const of_unichar_t *characters = self.characters; size_t length, UTF16StringLength; - length = UTF16StringLength = [self length]; + length = UTF16StringLength = self.length; for (size_t i = 0; i < length; i++) if (characters[i] > 0xFFFF) UTF16StringLength++; @@ -2665,11 +2663,11 @@ } - (const of_char32_t *)UTF32StringWithByteOrder: (of_byte_order_t)byteOrder { OFObject *object = [[[OFObject alloc] init] autorelease]; - size_t length = [self length]; + size_t length = self.length; of_char32_t *ret; ret = [object allocMemoryWithSize: sizeof(of_char32_t) count: length + 1]; [self getCharacters: ret @@ -2759,12 +2757,12 @@ #ifdef OF_HAVE_BLOCKS - (void)enumerateLinesUsingBlock: (of_string_line_enumeration_block_t)block { void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; - size_t i, last = 0, length = [self length]; + const of_unichar_t *characters = self.characters; + size_t i, last = 0, length = self.length; bool stop = false, lastCarriageReturn = false; for (i = 0; i < length && !stop; i++) { if (lastCarriageReturn && characters[i] == '\n') { lastCarriageReturn = false; Index: src/OFString_UTF8.m ================================================================== --- src/OFString_UTF8.m +++ src/OFString_UTF8.m @@ -448,22 +448,22 @@ self = [super init]; @try { _s = &_storage; - _s->cStringLength = [string UTF8StringLength]; + _s->cStringLength = string.UTF8StringLength; if ([string isKindOfClass: [OFString_UTF8 class]] || [string isKindOfClass: [OFMutableString_UTF8 class]]) _s->isUTF8 = ((OFString_UTF8 *)string)->_s->isUTF8; else _s->isUTF8 = true; - _s->length = [string length]; + _s->length = string.length; _s->cString = [self allocMemoryWithSize: _s->cStringLength + 1]; - memcpy(_s->cString, [string UTF8String], _s->cStringLength + 1); + memcpy(_s->cString, string.UTF8String, _s->cStringLength + 1); } @catch (id e) { [self release]; @throw e; } @@ -678,11 +678,11 @@ if (format == nil) @throw [OFInvalidArgumentException exception]; _s = &_storage; - if ((cStringLength = of_vasprintf(&tmp, [format UTF8String], + if ((cStringLength = of_vasprintf(&tmp, format.UTF8String, arguments)) == -1) @throw [OFInvalidFormatException exception]; _s->cStringLength = cStringLength; @@ -791,21 +791,21 @@ if (![object isKindOfClass: [OFString class]]) return false; otherString = object; - if ([otherString UTF8StringLength] != _s->cStringLength || - [otherString length] != _s->length) + if (otherString.UTF8StringLength != _s->cStringLength || + otherString.length != _s->length) return false; if (([otherString isKindOfClass: [OFString_UTF8 class]] || [otherString isKindOfClass: [OFMutableString_UTF8 class]]) && _s->hashed && otherString->_s->hashed && _s->hash != otherString->_s->hash) return false; - if (strcmp(_s->cString, [otherString UTF8String]) != 0) + if (strcmp(_s->cString, otherString.UTF8String) != 0) return false; return true; } @@ -820,15 +820,15 @@ if (![(id)object isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; otherString = (OFString *)object; - otherCStringLength = [otherString UTF8StringLength]; + otherCStringLength = otherString.UTF8StringLength; minimumCStringLength = (_s->cStringLength > otherCStringLength ? otherCStringLength : _s->cStringLength); - if ((compare = memcmp(_s->cString, [otherString UTF8String], + if ((compare = memcmp(_s->cString, otherString.UTF8String, minimumCStringLength)) == 0) { if (_s->cStringLength > otherCStringLength) return OF_ORDERED_DESCENDING; if (_s->cStringLength < otherCStringLength) return OF_ORDERED_ASCENDING; @@ -854,12 +854,12 @@ return OF_ORDERED_SAME; if (![otherString isKindOfClass: [OFString class]]) @throw [OFInvalidArgumentException exception]; - otherCString = [otherString UTF8String]; - otherCStringLength = [otherString UTF8StringLength]; + otherCString = otherString.UTF8String; + otherCStringLength = otherString.UTF8StringLength; #ifdef OF_HAVE_UNICODE_TABLES if (!_s->isUTF8) { #endif minimumCStringLength = (_s->cStringLength > otherCStringLength @@ -945,12 +945,12 @@ if ((length = of_string_utf8_decode(_s->cString + i, _s->cStringLength - i, &c)) <= 0) @throw [OFInvalidEncodingException exception]; OF_HASH_ADD(hash, (c & 0xFF0000) >> 16); - OF_HASH_ADD(hash, (c & 0x00FF00) >> 8); - OF_HASH_ADD(hash, c & 0x0000FF); + OF_HASH_ADD(hash, (c & 0x00FF00) >> 8); + OF_HASH_ADD(hash, c & 0x0000FF); i += length - 1; } OF_HASH_FINALIZE(hash); @@ -983,11 +983,11 @@ - (void)getCharacters: (of_unichar_t *)buffer inRange: (of_range_t)range { /* TODO: Could be slightly optimized */ void *pool = objc_autoreleasePoolPush(); - const of_unichar_t *characters = [self characters]; + const of_unichar_t *characters = self.characters; if (range.length > SIZE_MAX - range.location || range.location + range.length > _s->length) @throw [OFOutOfRangeException exception]; @@ -999,12 +999,12 @@ - (of_range_t)rangeOfString: (OFString *)string options: (int)options range: (of_range_t)range { - const char *cString = [string UTF8String]; - size_t cStringLength = [string UTF8StringLength]; + const char *cString = string.UTF8String; + size_t cStringLength = string.UTF8StringLength; size_t rangeLocation, rangeLength; if (range.length > SIZE_MAX - range.location || range.location + range.length > _s->length) @throw [OFOutOfRangeException exception]; @@ -1030,11 +1030,11 @@ for (size_t i = rangeLength - cStringLength;; i--) { if (memcmp(_s->cString + rangeLocation + i, cString, cStringLength) == 0) { range.location += of_string_utf8_get_index( _s->cString + rangeLocation, i); - range.length = [string length]; + range.length = string.length; return range; } /* Did not match and we're at the last char */ @@ -1045,11 +1045,11 @@ for (size_t i = 0; i <= rangeLength - cStringLength; i++) { if (memcmp(_s->cString + rangeLocation + i, cString, cStringLength) == 0) { range.location += of_string_utf8_get_index( _s->cString + rangeLocation, i); - range.length = [string length]; + range.length = string.length; return range; } } } @@ -1057,12 +1057,12 @@ return of_range(OF_NOT_FOUND, 0); } - (bool)containsString: (OFString *)string { - const char *cString = [string UTF8String]; - size_t cStringLength = [string UTF8StringLength]; + const char *cString = string.UTF8String; + size_t cStringLength = string.UTF8StringLength; if (cStringLength == 0) return true; if (cStringLength > _s->cStringLength) @@ -1094,36 +1094,36 @@ length: end - start]; } - (bool)hasPrefix: (OFString *)prefix { - size_t cStringLength = [prefix UTF8StringLength]; + size_t cStringLength = prefix.UTF8StringLength; if (cStringLength > _s->cStringLength) return false; - return (memcmp(_s->cString, [prefix UTF8String], cStringLength) == 0); + return (memcmp(_s->cString, prefix.UTF8String, cStringLength) == 0); } - (bool)hasSuffix: (OFString *)suffix { - size_t cStringLength = [suffix UTF8StringLength]; + size_t cStringLength = suffix.UTF8StringLength; if (cStringLength > _s->cStringLength) return false; return (memcmp(_s->cString + (_s->cStringLength - cStringLength), - [suffix UTF8String], cStringLength) == 0); + suffix.UTF8String, cStringLength) == 0); } - (OFArray *)componentsSeparatedByString: (OFString *)delimiter options: (int)options { void *pool; OFMutableArray *array; - const char *cString = [delimiter UTF8String]; - size_t cStringLength = [delimiter UTF8StringLength]; + const char *cString = delimiter.UTF8String; + size_t cStringLength = delimiter.UTF8StringLength; bool skipEmpty = (options & OF_STRING_SKIP_EMPTY); size_t last; OFString *component; array = [OFMutableArray array]; @@ -1141,18 +1141,18 @@ if (memcmp(_s->cString + i, cString, cStringLength) != 0) continue; component = [OFString stringWithUTF8String: _s->cString + last length: i - last]; - if (!skipEmpty || [component length] > 0) + if (!skipEmpty || component.length > 0) [array addObject: component]; i += cStringLength - 1; last = i + 1; } component = [OFString stringWithUTF8String: _s->cString + last]; - if (!skipEmpty || [component length] > 0) + if (!skipEmpty || component.length > 0) [array addObject: component]; [array makeImmutable]; objc_autoreleasePoolPop(pool); Index: src/OFSystemInfo.m ================================================================== --- src/OFSystemInfo.m +++ src/OFSystemInfo.m @@ -147,14 +147,15 @@ #if defined(OF_IOS) || defined(OF_MACOS) # ifdef OF_HAVE_FILES void *pool = objc_autoreleasePoolPush(); @try { - OFString *propertyList = [OFString stringWithContentsOfFile: - @"/System/Library/CoreServices/SystemVersion.plist"]; + OFDictionary *propertyList = [OFString stringWithContentsOfFile: + @"/System/Library/CoreServices/SystemVersion.plist"] + .propertyListValue; - operatingSystemVersion = [[[propertyList propertyListValue] + operatingSystemVersion = [[propertyList objectForKey: @"ProductVersion"] copy]; } @finally { objc_autoreleasePoolPop(pool); } # endif @@ -175,12 +176,12 @@ return; systemDirString = [OFString stringWithUTF16String: systemDir length: systemDirLen]; - path = [[systemDirString stringByAppendingPathComponent: - @"kernel32.dll"] UTF16String]; + path = [systemDirString stringByAppendingPathComponent: + @"kernel32.dll"].UTF16String; if ((bufferLen = GetFileVersionInfoSizeW(path, NULL)) == 0) return; if ((buffer = malloc(bufferLen)) == 0) return; @@ -435,11 +436,11 @@ OFDictionary *env = [OFApplication environment]; OFString *var; void *pool; if ((var = [env objectForKey: @"XDG_DATA_HOME"]) != nil && - [var length] > 0) + var.length > 0) return var; if ((var = [env objectForKey: @"HOME"]) == nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; @@ -528,11 +529,11 @@ # else OFDictionary *env = [OFApplication environment]; OFString *var; if ((var = [env objectForKey: @"XDG_CONFIG_HOME"]) != nil && - [var length] > 0) + var.length > 0) return var; if ((var = [env objectForKey: @"HOME"]) == nil) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; Index: src/OFTCPSocket.h ================================================================== --- src/OFTCPSocket.h +++ src/OFTCPSocket.h @@ -33,12 +33,12 @@ * * @param socket The socket which connected * @param exception An exception which occurred while connecting the socket or * `nil` on success */ -typedef void (^of_tcp_socket_async_connect_block_t)( - OF_KINDOF(OFTCPSocket *) socket, id _Nullable exception); +typedef void (^of_tcp_socket_async_connect_block_t)(OFTCPSocket *socket, + id _Nullable exception); /*! * @brief A block which is called when the socket accepted a connection. * * @param socket The socket which accepted the connection @@ -46,13 +46,12 @@ * @param exception An exception which occurred while accepting the socket or * `nil` on success * @return A bool whether the same block should be used for the next incoming * connection */ -typedef bool (^of_tcp_socket_async_accept_block_t)( - OF_KINDOF(OFTCPSocket *) socket, OF_KINDOF(OFTCPSocket *) acceptedSocket, - id _Nullable exception); +typedef bool (^of_tcp_socket_async_accept_block_t)(OFTCPSocket *socket, + OFTCPSocket *acceptedSocket, id _Nullable exception); #endif /*! * @protocol OFTCPSocketDelegate OFTCPSocket.h ObjFW/OFTCPSocket.h * @@ -67,11 +66,11 @@ * @param host The host connected to * @param port The port on the host connected to * @param exception An exception that occurred while connecting, or nil on * success */ -- (void)socket: (OF_KINDOF(OFTCPSocket *))socket +- (void)socket: (OFTCPSocket *)socket didConnectToHost: (OFString *)host port: (uint16_t)port exception: (nullable id)exception; /*! @@ -81,12 +80,12 @@ * @param acceptedSocket The socket which has been accepted * @param exception An exception that occurred while accepting, or nil on * success * @return A bool whether to accept the next incoming connection */ -- (bool)socket: (OF_KINDOF(OFTCPSocket *))socket - didAcceptSocket: (OF_KINDOF(OFTCPSocket *))acceptedSocket +- (bool)socket: (OFTCPSocket *)socket + didAcceptSocket: (OFTCPSocket *)acceptedSocket exception: (nullable id)exception; @end /*! * @class OFTCPSocket OFTCPSocket.h ObjFW/OFTCPSocket.h Index: src/OFTCPSocket.m ================================================================== --- src/OFTCPSocket.m +++ src/OFTCPSocket.m @@ -136,11 +136,11 @@ _port = port; _SOCKS5Host = [SOCKS5Host copy]; _SOCKS5Port = SOCKS5Port; _delegate = [delegate retain]; - [_socket setDelegate: self]; + _socket.delegate = self; } @catch (id e) { [self release]; @throw e; } @@ -174,14 +174,14 @@ #endif - (void)dealloc { #ifdef OF_HAVE_BLOCKS - if (_block != NULL) + if (_block == NULL) #endif - if ([_socket delegate] == self) - [_socket setDelegate: _delegate]; + if (_socket.delegate == self) + _socket.delegate = _delegate; [_socket release]; [_host release]; [_SOCKS5Host release]; [_delegate release]; @@ -196,18 +196,18 @@ } - (void)didConnect { if (_exception == nil) - [_socket setBlocking: true]; + _socket.blocking = true; #ifdef OF_HAVE_BLOCKS if (_block != NULL) _block(_socket, _exception); else { #endif - [_socket setDelegate: _delegate]; + _socket.delegate = _delegate; if ([_delegate respondsToSelector: @selector(socket:didConnectToHost:port:exception:)]) [_delegate socket: _socket didConnectToHost: _host @@ -216,20 +216,20 @@ #ifdef OF_HAVE_BLOCKS } #endif } -- (void)of_socketDidConnect: (OF_KINDOF(OFTCPSocket *))sock +- (void)of_socketDidConnect: (OFTCPSocket *)sock exception: (id)exception { if (exception != nil) { - if (_socketAddressesIndex >= [_socketAddresses count]) { + if (_socketAddressesIndex >= _socketAddresses.count) { _exception = [exception retain]; [self didConnect]; } else { [self tryNextAddressWithRunLoopMode: - [[OFRunLoop currentRunLoop] currentMode]]; + [OFRunLoop currentRunLoop].currentMode]; } return; } @@ -250,11 +250,11 @@ else of_socket_address_set_port(&address, _port); if (![_socket of_createSocketForAddress: &address errNo: &errNo]) { - if (_socketAddressesIndex >= [_socketAddresses count]) { + if (_socketAddressesIndex >= _socketAddresses.count) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; @@ -275,13 +275,13 @@ * * So for now, connecting is blocking on Wii and 3DS. * * FIXME: Use a different thread as a work around. */ - [_socket setBlocking: true]; + _socket.blocking = true; #else - [_socket setBlocking: false]; + _socket.blocking = false; #endif if (![_socket of_connectSocketToAddress: &address errNo: &errNo]) { #if !defined(OF_NINTENDO_3DS) && !defined(OF_WII) @@ -292,11 +292,11 @@ return; } else { #endif [_socket of_closeSocket]; - if (_socketAddressesIndex >= [_socketAddresses count]) { + if (_socketAddressesIndex >= _socketAddresses.count) { _exception = [[OFConnectionFailedException alloc] initWithHost: _host port: _port socket: _socket errNo: errNo]; @@ -310,11 +310,11 @@ } #endif } #if defined(OF_NINTENDO_3DS) || defined(OF_WII) - [_socket setBlocking: false]; + _socket.blocking = false; #endif [self didConnect]; } @@ -330,20 +330,20 @@ } _socketAddresses = [socketAddresses copy]; [self tryNextAddressWithRunLoopMode: - [[OFRunLoop currentRunLoop] currentMode]]; + [OFRunLoop currentRunLoop].currentMode]; } - (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode { OFString *host; uint16_t port; if (_SOCKS5Host != nil) { - if ([_host UTF8StringLength] > 255) + if (_host.UTF8StringLength > 255) @throw [OFOutOfRangeException exception]; host = _SOCKS5Host; port = _SOCKS5Port; } else { @@ -377,14 +377,14 @@ OFData *data = [OFData dataWithItems: "\x05\x01\x00" count: 3]; _SOCKS5State = SOCKS5_STATE_SEND_AUTHENTICATION; [_socket asyncWriteData: data - runLoopMode: [[OFRunLoop currentRunLoop] currentMode]]; + runLoopMode: [OFRunLoop currentRunLoop].currentMode]; } -- (bool)stream: (OF_KINDOF(OFStream *))sock +- (bool)stream: (OFStream *)sock didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (id)exception { of_run_loop_mode_t runLoopMode; @@ -397,11 +397,11 @@ _exception = [exception retain]; [self didConnect]; return false; } - runLoopMode = [[OFRunLoop currentRunLoop] currentMode]; + runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { case SOCKS5_STATE_READ_VERSION: SOCKSVersion = buffer; @@ -419,19 +419,19 @@ _request = [[OFMutableData alloc] init]; [_request addItems: "\x05\x01\x00\x03" count: 4]; - hostLength = (uint8_t)[_host UTF8StringLength]; + hostLength = (uint8_t)_host.UTF8StringLength; [_request addItem: &hostLength]; - [_request addItems: [_host UTF8String] + [_request addItems: _host.UTF8String count: hostLength]; port[0] = _port >> 8; port[1] = _port & 0xFF; [_request addItems: port - count: 2]; + count: 2]; _SOCKS5State = SOCKS5_STATE_SEND_REQUEST; [_socket asyncWriteData: _request runLoopMode: runLoopMode]; return false; @@ -533,11 +533,11 @@ assert(0); return false; } } -- (OFData *)stream: (OF_KINDOF(OFStream *))sock +- (OFData *)stream: (OFStream *)sock didWriteData: (OFData *)data bytesWritten: (size_t)bytesWritten exception: (id)exception { of_run_loop_mode_t runLoopMode; @@ -546,11 +546,11 @@ _exception = [exception retain]; [self didConnect]; return nil; } - runLoopMode = [[OFRunLoop currentRunLoop] currentMode]; + runLoopMode = [OFRunLoop currentRunLoop].currentMode; switch (_SOCKS5State) { case SOCKS5_STATE_SEND_AUTHENTICATION: _SOCKS5State = SOCKS5_STATE_READ_VERSION; [_socket asyncReadIntoBuffer: _buffer @@ -579,11 +579,11 @@ [_exception release]; [super dealloc]; } -- (void)socket: (OF_KINDOF(OFTCPSocket *))sock +- (void)socket: (OFTCPSocket *)sock didConnectToHost: (OFString *)host port: (uint16_t)port exception: (id)exception { _done = true; @@ -706,11 +706,11 @@ id delegate = [_delegate retain]; OFTCPSocket_ConnectDelegate *connectDelegate = [[[OFTCPSocket_ConnectDelegate alloc] init] autorelease]; OFRunLoop *runLoop = [OFRunLoop currentRunLoop]; - [self setDelegate: connectDelegate]; + self.delegate = connectDelegate; [self asyncConnectToHost: host port: port runLoopMode: connectRunLoopMode]; while (!connectDelegate->_done) @@ -722,11 +722,11 @@ beforeDate: [OFDate date]]; if (connectDelegate->_exception != nil) @throw connectDelegate->_exception; - [self setDelegate: delegate]; + self.delegate = delegate; objc_autoreleasePoolPop(pool); } - (void)asyncConnectToHost: (OFString *)host Index: src/OFTarArchive.h ================================================================== --- src/OFTarArchive.h +++ src/OFTarArchive.h @@ -29,18 +29,18 @@ * * @brief A class for accessing and manipulating tar archives. */ @interface OFTarArchive: OFObject { - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; enum { OF_TAR_ARCHIVE_MODE_READ, OF_TAR_ARCHIVE_MODE_WRITE, OF_TAR_ARCHIVE_MODE_APPEND } _mode; of_string_encoding_t _encoding; - OF_KINDOF(OFStream *) _Nullable _lastReturnedStream; + OFStream *_Nullable _lastReturnedStream; } /*! * @brief The encoding to use for the archive. Defaults to UTF-8. */ @@ -65,11 +65,11 @@ * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFTarArchive */ -+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; #ifdef OF_HAVE_FILES /*! * @brief Creates a new OFTarArchive object with the specified file. @@ -95,11 +95,11 @@ * @param mode The mode for the tar file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFTarArchive */ -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; #ifdef OF_HAVE_FILES /*! * @brief Initializes an already allocated OFTarArchive object with the Index: src/OFTarArchive.m ================================================================== --- src/OFTarArchive.m +++ src/OFTarArchive.m @@ -18,13 +18,13 @@ #include "config.h" #import "OFTarArchive.h" #import "OFTarArchiveEntry.h" #import "OFTarArchiveEntry+Private.h" -#import "OFStream.h" +#import "OFDate.h" #import "OFSeekableStream.h" -#import "OFDate.h" +#import "OFStream.h" #ifdef OF_HAVE_FILES # import "OFFile.h" #endif #import "OFInvalidArgumentException.h" @@ -35,11 +35,11 @@ #import "OFWriteFailedException.h" @interface OFTarArchive_FileReadStream: OFStream { OFTarArchiveEntry *_entry; - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; uint64_t _toRead; bool _atEndOfStream, _skipped; } - (instancetype)of_initWithStream: (OFStream *)stream @@ -48,22 +48,22 @@ @end @interface OFTarArchive_FileWriteStream: OFStream { OFTarArchiveEntry *_entry; - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; uint64_t _toWrite; } -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFStream *)stream entry: (OFTarArchiveEntry *)entry; @end @implementation OFTarArchive: OFObject @synthesize encoding = _encoding; -+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } @@ -80,11 +80,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { @@ -107,24 +107,24 @@ bool empty = true; if (![_stream isKindOfClass: [OFSeekableStream class]]) @throw [OFInvalidArgumentException exception]; - [_stream seekToOffset: -1024 - whence: SEEK_END]; - [_stream readIntoBuffer: buffer.c + [(OFSeekableStream *)stream seekToOffset: -1024 + whence: SEEK_END]; + [stream readIntoBuffer: buffer.c exactLength: 1024]; for (size_t i = 0; i < 1024 / sizeof(uint32_t); i++) if (buffer.u32[i] != 0) empty = false; if (!empty) @throw [OFInvalidFormatException exception]; - [_stream seekToOffset: -1024 - whence: SEEK_END]; + [(OFSeekableStream *)stream seekToOffset: -1024 + whence: SEEK_END]; } _encoding = OF_STRING_ENCODING_UTF_8; } @catch (id e) { [self release]; @@ -175,16 +175,16 @@ bool empty = true; if (_mode != OF_TAR_ARCHIVE_MODE_READ) @throw [OFInvalidArgumentException exception]; - [_lastReturnedStream of_skip]; + [(OFTarArchive_FileReadStream *)_lastReturnedStream of_skip]; [_lastReturnedStream close]; [_lastReturnedStream release]; _lastReturnedStream = nil; - if ([_stream isAtEndOfStream]) + if (_stream.atEndOfStream) return nil; [_stream readIntoBuffer: buffer.c exactLength: 512]; @@ -220,11 +220,12 @@ @throw [OFInvalidArgumentException exception]; if (_lastReturnedStream == nil) @throw [OFInvalidArgumentException exception]; - return [[_lastReturnedStream retain] autorelease]; + return [[(OFTarArchive_FileReadStream *)_lastReturnedStream + retain] autorelease]; } - (OFStream *) streamForWritingEntry: (OFTarArchiveEntry *)entry { @@ -247,11 +248,12 @@ of_initWithStream: _stream entry: entry]; objc_autoreleasePoolPop(pool); - return [[_lastReturnedStream retain] autorelease]; + return [[(OFTarArchive_FileWriteStream *)_lastReturnedStream + retain] autorelease]; } - (void)close { if (_stream == nil) @@ -281,11 +283,11 @@ self = [super init]; @try { _entry = [entry copy]; _stream = [stream retain]; - _toRead = [entry size]; + _toRead = entry.size; } @catch (id e) { [self release]; @throw e; } @@ -339,16 +341,17 @@ return _atEndOfStream; } - (bool)hasDataInReadBuffer { - return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer]); + return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer); } - (int)fileDescriptorForReading { - return [_stream fileDescriptorForReading]; + return ((id )_stream) + .fileDescriptorForReading; } - (void)close { [self of_skip]; @@ -366,20 +369,21 @@ if ([_stream isKindOfClass: [OFSeekableStream class]] && _toRead <= INT64_MAX && (of_offset_t)_toRead == (int64_t)_toRead) { uint64_t size; - [_stream seekToOffset: (of_offset_t)_toRead - whence: SEEK_CUR]; + [(OFSeekableStream *)_stream seekToOffset: (of_offset_t)_toRead + whence: SEEK_CUR]; _toRead = 0; - size = [_entry size]; + size = _entry.size; if (size % 512 != 0) - [_stream seekToOffset: 512 - (size % 512) - whence: SEEK_CUR]; + [(OFSeekableStream *)_stream + seekToOffset: 512 - (size % 512) + whence: SEEK_CUR]; } else { char buffer[512]; uint64_t size; while (_toRead >= 512) { @@ -392,11 +396,11 @@ [_stream readIntoBuffer: buffer exactLength: (size_t)_toRead]; _toRead = 0; } - size = [_entry size]; + size = _entry.size; if (size % 512 != 0) [_stream readIntoBuffer: buffer exactLength: (size_t)(512 - (size % 512))]; } @@ -404,19 +408,19 @@ _skipped = true; } @end @implementation OFTarArchive_FileWriteStream -- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)of_initWithStream: (OFStream *)stream entry: (OFTarArchiveEntry *)entry { self = [super init]; @try { _entry = [entry copy]; _stream = [stream retain]; - _toWrite = [entry size]; + _toWrite = entry.size; } @catch (id e) { [self release]; @throw e; } @@ -445,11 +449,11 @@ @try { bytesWritten = [_stream writeBuffer: buffer length: length]; } @catch (OFWriteFailedException *e) { - _toWrite -= [e bytesWritten]; + _toWrite -= e.bytesWritten; @throw e; } _toWrite -= bytesWritten; @@ -464,36 +468,37 @@ return (_toWrite == 0); } - (int)fileDescriptorForWriting { - return [_stream fileDescriptorForWriting]; + return ((id )_stream) + .fileDescriptorForWriting; } - (void)close { if (_stream == nil) return; - uint64_t remainder = 512 - [_entry size] % 512; + uint64_t remainder = 512 - _entry.size % 512; if (_toWrite > 0) @throw [OFTruncatedDataException exception]; if (remainder != 512) { - bool wasWriteBuffered = [_stream isWriteBuffered]; + bool wasWriteBuffered = _stream.writeBuffered; [_stream setWriteBuffered: true]; while (remainder--) [_stream writeInt8: 0]; [_stream flushWriteBuffer]; - [_stream setWriteBuffered: wasWriteBuffered]; + _stream.writeBuffered = wasWriteBuffered; } [_stream release]; _stream = nil; [super close]; } @end Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -63,12 +63,12 @@ if (buffer[0] == 0x80) { for (size_t i = 1; i < length; i++) value = (value << 8) | buffer[i]; } else - value = [stringFromBuffer(buffer, length, - OF_STRING_ENCODING_ASCII) octalValue]; + value = stringFromBuffer(buffer, length, + OF_STRING_ENCODING_ASCII).octalValue; if (value > max) @throw [OFOutOfRangeException exception]; return value; @@ -108,11 +108,11 @@ (of_time_interval_t)octalValueFromBuffer( header + 136, 12, UINTMAX_MAX)]; _type = header[156]; targetFileName = stringFromBuffer(header + 157, 100, encoding); - if ([targetFileName length] > 0) + if (targetFileName.length > 0) _targetFileName = [targetFileName copy]; if (_type == '\0') _type = OF_TAR_ARCHIVE_ENTRY_TYPE_FILE; @@ -128,11 +128,11 @@ header + 329, 8, UINT32_MAX); _deviceMinor = (uint32_t)octalValueFromBuffer( header + 337, 8, UINT32_MAX); prefix = stringFromBuffer(header + 345, 155, encoding); - if ([prefix length] > 0) { + if (prefix.length > 0) { OFString *fileName = [OFString stringWithFormat: @"%@/%@", prefix, _fileName]; [_fileName release]; _fileName = [fileName copy]; @@ -278,13 +278,12 @@ @"\tOwner = %@\n" @"\tGroup = %@\n" @"\tDevice major = %" PRIu32 @"\n" @"\tDevice minor = %" PRIu32 @"\n" @">", - [self class], _fileName, _mode, _UID, _GID, _size, - _modificationDate, _type, _targetFileName, _owner, _group, - _deviceMajor, _deviceMinor]; + self.class, _fileName, _mode, _UID, _GID, _size, _modificationDate, + _type, _targetFileName, _owner, _group, _deviceMajor, _deviceMinor]; [ret retain]; objc_autoreleasePoolPop(pool); @@ -309,11 +308,11 @@ [OFString stringWithFormat: @"%06" PRIo16 " ", _GID], 8, OF_STRING_ENCODING_ASCII); stringToBuffer(buffer + 124, [OFString stringWithFormat: @"%011" PRIo64 " ", _size], 12, OF_STRING_ENCODING_ASCII); - modificationDate = [_modificationDate timeIntervalSince1970]; + modificationDate = _modificationDate.timeIntervalSince1970; stringToBuffer(buffer + 136, [OFString stringWithFormat: @"%011" PRIo64 " ", modificationDate], 12, OF_STRING_ENCODING_ASCII); /* Index: src/OFThread.m ================================================================== --- src/OFThread.m +++ src/OFThread.m @@ -120,15 +120,15 @@ OFThread *thread = (OFThread *)object; OFString *name; if (!of_tlskey_set(threadSelfKey, thread)) @throw [OFInitializationFailedException - exceptionWithClass: [thread class]]; + exceptionWithClass: thread.class]; thread->_pool = objc_autoreleasePoolPush(); - name = [thread name]; + name = thread.name; if (name != nil) of_thread_set_name( [name cStringWithEncoding: [OFLocale encoding]]); else of_thread_set_name(object_getClassName(thread)); @@ -296,11 +296,11 @@ #endif } + (void)sleepUntilDate: (OFDate *)date { - [self sleepForTimeInterval: [date timeIntervalSinceNow]]; + [self sleepForTimeInterval: date.timeIntervalSinceNow]; } + (void)yield { #ifdef OF_HAVE_SCHED_YIELD @@ -343,22 +343,22 @@ of_thread_exit(); } + (void)setName: (OFString *)name { - [[OFThread currentThread] setName: name]; + [OFThread currentThread].name = name; if (name != nil) of_thread_set_name( [name cStringWithEncoding: [OFLocale encoding]]); else - of_thread_set_name(class_getName([self class])); + of_thread_set_name(class_getName(self.class)); } + (OFString *)name { - return [[OFThread currentThread] name]; + return [OFThread currentThread].name; } + (void)of_createMainThread { mainThread = [[OFThread alloc] init]; @@ -374,11 +374,11 @@ self = [super init]; @try { if (!of_thread_attr_init(&_attr)) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; } @catch (id e) { [self release]; @throw e; } Index: src/OFThreadPool.m ================================================================== --- src/OFThreadPool.m +++ src/OFThreadPool.m @@ -167,21 +167,21 @@ if (_terminate) { objc_autoreleasePoolPop(pool); return nil; } - listObject = [_queue firstListObject]; + listObject = _queue.firstListObject; while (listObject == NULL) { [_queueCondition wait]; if (_terminate) { objc_autoreleasePoolPop(pool); return nil; } - listObject = [_queue firstListObject]; + listObject = _queue.firstListObject; } job = [[listObject->object retain] autorelease]; [_queue removeListObject: listObject]; } @finally { Index: src/OFTimer.m ================================================================== --- src/OFTimer.m +++ src/OFTimer.m @@ -543,28 +543,28 @@ OF_ENSURE(_arguments <= 4); if (_repeats && _valid) { int64_t missedIntervals = - -[_fireDate timeIntervalSinceNow] / _interval; + -_fireDate.timeIntervalSinceNow / _interval; of_time_interval_t newFireDate; OFRunLoop *runLoop; /* In case the clock was changed backwards */ if (missedIntervals < 0) missedIntervals = 0; - newFireDate = [_fireDate timeIntervalSince1970] + + newFireDate = _fireDate.timeIntervalSince1970 + (missedIntervals + 1) * _interval; [_fireDate release]; _fireDate = [[OFDate alloc] initWithTimeIntervalSince1970: newFireDate]; runLoop = [OFRunLoop currentRunLoop]; [runLoop addTimer: self - forMode: [runLoop currentMode]]; + forMode: runLoop.currentMode]; } else [self invalidate]; #ifdef OF_HAVE_BLOCKS if (_block != NULL) Index: src/OFUDPSocket.h ================================================================== --- src/OFUDPSocket.h +++ src/OFUDPSocket.h @@ -74,11 +74,11 @@ * @param sender The address of the sender of the packet * @param exception An exception that occurred while receiving, or nil on * success * @return A bool whether the same block should be used for the next receive */ -- (bool)socket: (OF_KINDOF(OFUDPSocket *))socket +- (bool)socket: (OFUDPSocket *)socket didReceiveIntoBuffer: (void *)buffer length: (size_t)length sender: (const of_socket_address_t *_Nonnull)sender exception: (nullable id)exception; @@ -89,11 +89,11 @@ * @param data The data which was sent * @param receiver The receiver for the UDP packet * @param exception An exception that occurred while sending, or nil on success * @return The data to repeat the send with or nil if it should not repeat */ -- (nullable OFData *)socket: (OF_KINDOF(OFUDPSocket *))socket +- (nullable OFData *)socket: (OFUDPSocket *)socket didSendData: (OFData *)data receiver: (const of_socket_address_t *_Nonnull)receiver exception: (nullable id)exception; @end Index: src/OFURL.m ================================================================== --- src/OFURL.m +++ src/OFURL.m @@ -70,15 +70,15 @@ withString: @"/"]; path = [path stringByPrependingString: @"/"]; return path; # elif defined(OF_AMIGAOS) - OFArray OF_GENERIC(OFString *) *components = [path pathComponents]; + OFArray OF_GENERIC(OFString *) *components = path.pathComponents; OFMutableString *ret = [OFMutableString string]; for (OFString *component in components) { - if ([component length] == 0) + if (component.length == 0) continue; if ([component isEqual: @"/"]) [ret appendString: @"/.."]; else { @@ -99,23 +99,23 @@ static OFString * URLPathToPath(OFString *path) { # if defined(OF_WINDOWS) || defined(OF_MSDOS) - path = [path substringWithRange: of_range(1, [path length] - 1)]; + path = [path substringWithRange: of_range(1, path.length - 1)]; path = [path stringByReplacingOccurrencesOfString: @"/" withString: @"\\"]; return path; # elif defined(OF_AMIGAOS) OFMutableArray OF_GENERIC(OFString *) *components; size_t count; - path = [path substringWithRange: of_range(1, [path length] - 1)]; + path = [path substringWithRange: of_range(1, path.length - 1)]; components = [[[path componentsSeparatedByString: @"/"] mutableCopy] autorelease]; - count = [components count]; + count = components.count; for (size_t i = 0; i < count; i++) { OFString *component = [components objectAtIndex: i]; if ([component isEqual: @"."]) { @@ -131,11 +131,11 @@ withObject: @"/"]; } return [OFString pathWithComponents: components]; # elif defined(OF_NINTENDO_3DS) || defined(OF_WII) - return [path substringWithRange: of_range(1, [path length] - 1)]; + return [path substringWithRange: of_range(1, path.length - 1)]; # else return path; # endif } #endif @@ -471,14 +471,14 @@ @try { void *pool = objc_autoreleasePoolPush(); char *tmp, *tmp2; - if ((UTF8String2 = of_strdup([string UTF8String])) == NULL) + if ((UTF8String2 = of_strdup(string.UTF8String)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: - [string UTF8StringLength]]; + string.UTF8StringLength]; UTF8String = UTF8String2; if ((tmp = strchr(UTF8String, ':')) == NULL) @throw [OFInvalidFormatException exception]; @@ -540,15 +540,15 @@ _URLEncodedHost = [[OFString alloc] initWithUTF8String: UTF8String]; portString = [OFString stringWithUTF8String: tmp2]; - if ([portString decimalValue] > 65535) + if (portString.decimalValue > 65535) @throw [OFInvalidFormatException exception]; _port = [[OFNumber alloc] initWithUInt16: - (uint16_t)[portString decimalValue]]; + (uint16_t)portString.decimalValue]; } else _URLEncodedHost = [[OFString alloc] initWithUTF8String: UTF8String]; of_url_verify_escaped(_URLEncodedHost, @@ -616,14 +616,14 @@ _URLEncodedHost = [URL->_URLEncodedHost copy]; _port = [URL->_port copy]; _URLEncodedUser = [URL->_URLEncodedUser copy]; _URLEncodedPassword = [URL->_URLEncodedPassword copy]; - if ((UTF8String2 = of_strdup([string UTF8String])) == NULL) + if ((UTF8String2 = of_strdup(string.UTF8String)) == NULL) @throw [OFOutOfMemoryException exceptionWithRequestedSize: - [string UTF8StringLength]]; + string.UTF8StringLength]; UTF8String = UTF8String2; if ((tmp = strchr(UTF8String, '#')) != NULL) { *tmp = '\0'; @@ -667,11 +667,11 @@ if (range.location == OF_NOT_FOUND) @throw [OFInvalidFormatException exception]; range.location++; - range.length = [path length] - range.location; + range.length = path.length - range.location; [path replaceCharactersInRange: range withString: relativePath]; [path makeImmutable]; @@ -732,17 +732,17 @@ self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![path isAbsolutePath]) { - OFString *currentDirectoryPath = [[OFFileManager - defaultManager] currentDirectoryPath]; + if (!path.absolutePath) { + OFString *currentDirectoryPath = [OFFileManager + defaultManager].currentDirectoryPath; path = [currentDirectoryPath stringByAppendingPathComponent: path]; - path = [path stringByStandardizingPath]; + path = path.stringByStandardizingPath; } path = pathToURLPath(path); if (isDirectory && ![path hasSuffix: @"/"]) @@ -767,15 +767,15 @@ { void *pool = objc_autoreleasePoolPush(); OFString *stringValue; @try { - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - stringValue = [element stringValue]; + stringValue = element.stringValue; } @catch (id e) { [self release]; @throw e; } @@ -843,37 +843,37 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_URLEncodedScheme hash]); - OF_HASH_ADD_HASH(hash, [_URLEncodedHost hash]); - OF_HASH_ADD_HASH(hash, [_port hash]); - OF_HASH_ADD_HASH(hash, [_URLEncodedUser hash]); - OF_HASH_ADD_HASH(hash, [_URLEncodedPassword hash]); - OF_HASH_ADD_HASH(hash, [_URLEncodedPath hash]); - OF_HASH_ADD_HASH(hash, [_URLEncodedQuery hash]); - OF_HASH_ADD_HASH(hash, [_URLEncodedFragment hash]); + OF_HASH_ADD_HASH(hash, _URLEncodedScheme.hash); + OF_HASH_ADD_HASH(hash, _URLEncodedHost.hash); + OF_HASH_ADD_HASH(hash, _port.hash); + OF_HASH_ADD_HASH(hash, _URLEncodedUser.hash); + OF_HASH_ADD_HASH(hash, _URLEncodedPassword.hash); + OF_HASH_ADD_HASH(hash, _URLEncodedPath.hash); + OF_HASH_ADD_HASH(hash, _URLEncodedQuery.hash); + OF_HASH_ADD_HASH(hash, _URLEncodedFragment.hash); OF_HASH_FINALIZE(hash); return hash; } - (OFString *)scheme { - return [_URLEncodedScheme stringByURLDecoding]; + return _URLEncodedScheme.stringByURLDecoding; } - (OFString *)URLEncodedScheme { return _URLEncodedScheme; } - (OFString *)host { - return [_URLEncodedHost stringByURLDecoding]; + return _URLEncodedHost.stringByURLDecoding; } - (OFString *)URLEncodedHost { return _URLEncodedHost; @@ -884,47 +884,47 @@ return _port; } - (OFString *)user { - return [_URLEncodedUser stringByURLDecoding]; + return _URLEncodedUser.stringByURLDecoding; } - (OFString *)URLEncodedUser { return _URLEncodedUser; } - (OFString *)password { - return [_URLEncodedPassword stringByURLDecoding]; + return _URLEncodedPassword.stringByURLDecoding; } - (OFString *)URLEncodedPassword { return _URLEncodedPassword; } - (OFString *)path { - return [_URLEncodedPath stringByURLDecoding]; + return _URLEncodedPath.stringByURLDecoding; } - (OFString *)URLEncodedPath { return _URLEncodedPath; } - (OFArray *)pathComponents { - return [[self path] componentsSeparatedByString: @"/"]; + return [self.path componentsSeparatedByString: @"/"]; } - (OFString *)lastPathComponent { void *pool = objc_autoreleasePoolPush(); - OFString *path = [self path]; + OFString *path = self.path; const char *UTF8String, *lastComponent; size_t length; OFString *ret; if (path == nil) { @@ -938,15 +938,14 @@ return @""; } if ([path hasSuffix: @"/"]) - path = [path substringWithRange: - of_range(0, [path length] - 1)]; + path = [path substringWithRange: of_range(0, path.length - 1)]; - UTF8String = lastComponent = [path UTF8String]; - length = [path UTF8StringLength]; + UTF8String = lastComponent = path.UTF8String; + length = path.UTF8StringLength; for (size_t i = 1; i <= length; i++) { if (UTF8String[length - i] == '/') { lastComponent = UTF8String + (length - i) + 1; break; @@ -962,21 +961,21 @@ return [ret autorelease]; } - (OFString *)query { - return [_URLEncodedQuery stringByURLDecoding]; + return _URLEncodedQuery.stringByURLDecoding; } - (OFString *)URLEncodedQuery { return _URLEncodedQuery; } - (OFString *)fragment { - return [_URLEncodedFragment stringByURLDecoding]; + return _URLEncodedFragment.stringByURLDecoding; } - (OFString *)URLEncodedFragment { return _URLEncodedFragment; @@ -1053,15 +1052,14 @@ @throw [OFInvalidArgumentException exception]; if (![_URLEncodedPath hasPrefix: @"/"]) @throw [OFInvalidFormatException exception]; - path = [self path]; + path = self.path; if ([path hasSuffix: @"/"]) - path = [path substringWithRange: - of_range(0, [path length] - 1)]; + path = [path substringWithRange: of_range(0, path.length - 1)]; path = URLPathToPath(path); [path retain]; @@ -1076,25 +1074,25 @@ OFMutableURL *ret = [[self mutableCopy] autorelease]; void *pool; OFMutableString *URLEncodedPath; if ([component hasPrefix: @"/"]) { - [ret setPath: component]; + ret.path = component; return ret; } pool = objc_autoreleasePoolPush(); - URLEncodedPath = [[[self URLEncodedPath] mutableCopy] autorelease]; + URLEncodedPath = [[self.URLEncodedPath mutableCopy] autorelease]; if (![URLEncodedPath hasSuffix: @"/"]) [URLEncodedPath appendString: @"/"]; [URLEncodedPath appendString: [component stringByURLEncodingWithAllowedCharacters: [OFCharacterSet URLPathAllowedCharacterSet]]]; - [ret setURLEncodedPath: URLEncodedPath]; + ret.URLEncodedPath = URLEncodedPath; objc_autoreleasePoolPop(pool); return ret; } @@ -1102,16 +1100,16 @@ - (OFURL *)URLByAppendingPathComponent: (OFString *)component { OFMutableURL *ret = [self of_URLByAppendingPathComponent: component]; #ifdef OF_HAVE_FILES - if ([[ret scheme] isEqual: @"file"]) { + if ([ret.scheme isEqual: @"file"]) { void *pool = objc_autoreleasePoolPush(); if ([[OFFileManager defaultManager] directoryExistsAtURL: ret]) - [ret setURLEncodedPath: [[ret URLEncodedPath] - stringByAppendingString: @"/"]]; + ret.URLEncodedPath = + [ret.URLEncodedPath stringByAppendingString: @"/"]; objc_autoreleasePoolPop(pool); } #endif @@ -1126,12 +1124,12 @@ OFMutableURL *ret = [self of_URLByAppendingPathComponent: component]; if (isDirectory) { void *pool = objc_autoreleasePoolPush(); - [ret setURLEncodedPath: - [[ret URLEncodedPath] stringByAppendingString: @"/"]]; + ret.URLEncodedPath = + [ret.URLEncodedPath stringByAppendingString: @"/"]; objc_autoreleasePoolPop(pool); } [ret makeImmutable]; @@ -1150,24 +1148,24 @@ } - (OFString *)description { return [OFString stringWithFormat: @"<%@: %@>", - [self class], [self string]]; + self.class, self.string]; } - (OFXMLElement *)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; - element = [OFXMLElement elementWithName: [self className] + element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS - stringValue: [self string]]; + stringValue: self.string]; [element retain]; objc_autoreleasePoolPop(pool); return [element autorelease]; } @end Index: src/OFURLHandler.m ================================================================== --- src/OFURLHandler.m +++ src/OFURLHandler.m @@ -141,11 +141,11 @@ { #ifdef OF_HAVE_THREADS [mutex lock]; @try { #endif - return [handlers objectForKey: [URL scheme]]; + return [handlers objectForKey: URL.scheme]; #ifdef OF_HAVE_THREADS } @finally { [mutex unlock]; } #endif Index: src/OFURLHandler_file.m ================================================================== --- src/OFURLHandler_file.m +++ src/OFURLHandler_file.m @@ -136,11 +136,11 @@ static int of_stat(OFString *path, of_stat_t *buffer) { #if defined(OF_WINDOWS) - return _wstat64([path UTF16String], buffer); + return _wstat64(path.UTF16String, buffer); #elif defined(OF_AMIGAOS) BPTR lock; # ifdef OF_AMIGAOS4 struct ExamineData *ed; # else @@ -342,11 +342,11 @@ static void setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes, of_stat_t *s, OFURL *URL) { #ifdef OF_FILE_MANAGER_SUPPORTS_SYMLINKS - OFString *path = [URL fileSystemRepresentation]; + OFString *path = URL.fileSystemRepresentation; # ifndef OF_WINDOWS if (S_ISLNK(s->st_mode)) { of_string_encoding_t encoding = [OFLocale encoding]; char destinationC[PATH_MAX]; @@ -372,17 +372,17 @@ } # else WIN32_FIND_DATAW data; if (func_CreateSymbolicLinkW != NULL && - FindFirstFileW([path UTF16String], &data) && + FindFirstFileW(path.UTF16String, &data) && (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) && data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) { HANDLE handle; OFString *destination; - if ((handle = CreateFileW([path UTF16String], 0, + if ((handle = CreateFileW(path.UTF16String, 0, (FILE_SHARE_READ | FILE_SHARE_WRITE), NULL, OPEN_EXISTING, FILE_FLAG_OPEN_REPARSE_POINT, NULL)) == INVALID_HANDLE_VALUE) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL @@ -496,11 +496,11 @@ - (OFStream *)openItemAtURL: (OFURL *)URL mode: (OFString *)mode { void *pool = objc_autoreleasePoolPush(); OFFile *file = [[OFFile alloc] - initWithPath: [URL fileSystemRepresentation] + initWithPath: URL.fileSystemRepresentation mode: mode]; objc_autoreleasePoolPop(pool); return [file autorelease]; @@ -517,11 +517,11 @@ @throw [OFInvalidArgumentException exception]; if (![[URL scheme] isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - path = [URL fileSystemRepresentation]; + path = URL.fileSystemRepresentation; if (of_lstat(path, &s) == -1) @throw [OFRetrieveItemAttributesFailedException exceptionWithURL: URL errNo: errno]; @@ -549,17 +549,17 @@ - (void)of_setPOSIXPermissions: (OFNumber *)permissions ofItemAtURL: (OFURL *)URL attributes: (of_file_attributes_t)attributes { #ifdef OF_FILE_MANAGER_SUPPORTS_PERMISSIONS - uint16_t mode = [permissions uInt16Value] & 0777; - OFString *path = [URL fileSystemRepresentation]; + uint16_t mode = permissions.uInt16Value & 0777; + OFString *path = URL.fileSystemRepresentation; # ifndef OF_WINDOWS if (chmod([path cStringWithEncoding: [OFLocale encoding]], mode) != 0) # else - if (_wchmod([path UTF16String], mode) != 0) + if (_wchmod(path.UTF16String, mode) != 0) # endif @throw [OFSetItemAttributesFailedException exceptionWithURL: URL attributes: attributes failedAttribute: of_file_attribute_key_posix_permissions @@ -574,11 +574,11 @@ ofItemAtURL: (OFURL *)URL attributeKey: (of_file_attribute_key_t)attributeKey attributes: (of_file_attributes_t)attributes { #ifdef OF_FILE_MANAGER_SUPPORTS_OWNER - OFString *path = [URL fileSystemRepresentation]; + OFString *path = URL.fileSystemRepresentation; uid_t uid = -1; gid_t gid = -1; of_string_encoding_t encoding; if (owner == nil && group == nil) @@ -644,11 +644,11 @@ id object; if (URL == nil) @throw [OFInvalidArgumentException exception]; - if (![[URL scheme] isEqual: _scheme]) + if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; keyEnumerator = [attributes keyEnumerator]; objectEnumerator = [attributes objectEnumerator]; @@ -684,14 +684,14 @@ bool ret; if (URL == nil) @throw [OFInvalidArgumentException exception]; - if (![[URL scheme] isEqual: _scheme]) + if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - if (of_stat([URL fileSystemRepresentation], &s) == -1) + if (of_stat(URL.fileSystemRepresentation, &s) == -1) return false; ret = S_ISREG(s.st_mode); objc_autoreleasePoolPop(pool); @@ -706,14 +706,14 @@ bool ret; if (URL == nil) @throw [OFInvalidArgumentException exception]; - if (![[URL scheme] isEqual: _scheme]) + if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - if (of_stat([URL fileSystemRepresentation], &s) == -1) + if (of_stat(URL.fileSystemRepresentation, &s) == -1) return false; ret = S_ISDIR(s.st_mode); objc_autoreleasePoolPop(pool); @@ -727,17 +727,17 @@ OFString *path; if (URL == nil) @throw [OFInvalidArgumentException exception]; - if (![[URL scheme] isEqual: _scheme]) + if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - path = [URL fileSystemRepresentation]; + path = URL.fileSystemRepresentation; #if defined(OF_WINDOWS) - if (_wmkdir([path UTF16String]) != 0) + if (_wmkdir(path.UTF16String) != 0) @throw [OFCreateDirectoryFailedException exceptionWithURL: URL errNo: errno]; #elif defined(OF_AMIGAOS) BPTR lock; @@ -792,22 +792,22 @@ OFString *path; if (URL == nil) @throw [OFInvalidArgumentException exception]; - if (![[URL scheme] isEqual: _scheme]) + if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - path = [URL fileSystemRepresentation]; + path = URL.fileSystemRepresentation; #if defined(OF_WINDOWS) HANDLE handle; WIN32_FIND_DATAW fd; path = [path stringByAppendingString: @"\\*"]; - if ((handle = FindFirstFileW([path UTF16String], + if ((handle = FindFirstFileW(path.UTF16String, &fd)) == INVALID_HANDLE_VALUE) { int errNo = 0; if (GetLastError() == ERROR_FILE_NOT_FOUND) errNo = ENOENT; @@ -1006,14 +1006,14 @@ of_stat_t s; if (URL == nil) @throw [OFInvalidArgumentException exception]; - if (![[URL scheme] isEqual: _scheme]) + if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - path = [URL fileSystemRepresentation]; + path = URL.fileSystemRepresentation; if (of_lstat(path, &s) != 0) @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; @@ -1049,21 +1049,21 @@ #ifndef OF_AMIGAOS # ifndef OF_WINDOWS if (rmdir([path cStringWithEncoding: [OFLocale encoding]]) != 0) # else - if (_wrmdir([path UTF16String]) != 0) + if (_wrmdir(path.UTF16String) != 0) # endif @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; } else { # ifndef OF_WINDOWS if (unlink([path cStringWithEncoding: [OFLocale encoding]]) != 0) # else - if (_wunlink([path UTF16String]) != 0) + if (_wunlink(path.UTF16String) != 0) # endif @throw [OFRemoveItemFailedException exceptionWithURL: URL errNo: errno]; #endif @@ -1108,16 +1108,16 @@ OFString *sourcePath, *destinationPath; if (source == nil || destination == nil) @throw [OFInvalidArgumentException exception]; - if (![[source scheme] isEqual: _scheme] || - ![[destination scheme] isEqual: _scheme]) + if (![source.scheme isEqual: _scheme] || + ![destination.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - sourcePath = [source fileSystemRepresentation]; - destinationPath = [destination fileSystemRepresentation]; + sourcePath = source.fileSystemRepresentation; + destinationPath = destination.fileSystemRepresentation; # ifndef OF_WINDOWS of_string_encoding_t encoding = [OFLocale encoding]; if (link([sourcePath cStringWithEncoding: encoding], @@ -1125,12 +1125,12 @@ @throw [OFLinkFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; # else - if (!CreateHardLinkW([destinationPath UTF16String], - [sourcePath UTF16String], NULL)) + if (!CreateHardLinkW(destinationPath.UTF16String, + sourcePath.UTF16String, NULL)) @throw [OFLinkFailedException exceptionWithSourceURL: source destinationURL: destination errNo: 0]; # endif @@ -1147,14 +1147,14 @@ OFString *path; if (URL == nil || target == nil) @throw [OFInvalidArgumentException exception]; - if (![[URL scheme] isEqual: _scheme]) + if (![URL.scheme isEqual: _scheme]) @throw [OFInvalidArgumentException exception]; - path = [URL fileSystemRepresentation]; + path = URL.fileSystemRepresentation; # ifndef OF_WINDOWS of_string_encoding_t encoding = [OFLocale encoding]; if (symlink([target cStringWithEncoding: encoding], @@ -1166,12 +1166,11 @@ # else if (func_CreateSymbolicLinkW == NULL) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; - if (!func_CreateSymbolicLinkW([path UTF16String], - [target UTF16String], 0)) + if (!func_CreateSymbolicLinkW(path.UTF16String, target.UTF16String, 0)) @throw [OFCreateSymbolicLinkFailedException exceptionWithURL: URL target: target errNo: 0]; # endif @@ -1183,12 +1182,12 @@ - (bool)moveItemAtURL: (OFURL *)source toURL: (OFURL *)destination { void *pool; - if (![[source scheme] isEqual: _scheme] || - ![[destination scheme] isEqual: _scheme]) + if (![source.scheme isEqual: _scheme] || + ![destination.scheme isEqual: _scheme]) return false; if ([self fileExistsAtURL: destination]) @throw [OFMoveItemFailedException exceptionWithSourceURL: source @@ -1196,22 +1195,22 @@ errNo: EEXIST]; pool = objc_autoreleasePoolPush(); #if defined(OF_WINDOWS) - if (_wrename([[source fileSystemRepresentation] UTF16String], - [[destination fileSystemRepresentation] UTF16String]) != 0) + if (_wrename(source.fileSystemRepresentation.UTF16String, + destination.fileSystemRepresentation.UTF16String) != 0) @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; #elif defined(OF_AMIGAOS) of_string_encoding_t encoding = [OFLocale encoding]; - if (!Rename([[source fileSystemRepresentation] + if (!Rename([source.fileSystemRepresentation cStringWithEncoding: encoding], - [[destination fileSystemRepresentation] + [destination.fileSystemRepresentation cStringWithEncoding: encoding])) { int errNo; switch (IoErr()) { case ERROR_RENAME_ACROSS_DEVICES: @@ -1241,13 +1240,13 @@ errNo: errNo]; } #else of_string_encoding_t encoding = [OFLocale encoding]; - if (rename([[source fileSystemRepresentation] + if (rename([source.fileSystemRepresentation cStringWithEncoding: encoding], - [[destination fileSystemRepresentation] + [destination.fileSystemRepresentation cStringWithEncoding: encoding]) != 0) @throw [OFMoveItemFailedException exceptionWithSourceURL: source destinationURL: destination errNo: errno]; Index: src/OFValue.m ================================================================== --- src/OFValue.m +++ src/OFValue.m @@ -170,11 +170,11 @@ void *value, *otherValue; if (![object isKindOfClass: [OFValue class]]) return false; - objCType = [self objCType]; + objCType = self.objCType; if (strcmp([object objCType], objCType) != 0) return false; size = of_sizeof_type_encoding(objCType); @@ -202,11 +202,11 @@ } } - (uint32_t)hash { - size_t size = of_sizeof_type_encoding([self objCType]); + size_t size = of_sizeof_type_encoding(self.objCType); unsigned char *value; uint32_t hash; if ((value = malloc(size)) == NULL) @throw [OFOutOfMemoryException @@ -307,11 +307,11 @@ - (OFString *)description { OFMutableString *ret = [OFMutableString stringWithString: @" UINT32_MAX) @throw [OFOutOfRangeException exception]; - if ((status = RegSetValueExW(_hKey, [value UTF16String], 0, type, - [data items], (DWORD)length)) != ERROR_SUCCESS) + if ((status = RegSetValueExW(_hKey, value.UTF16String, 0, type, + data.items, (DWORD)length)) != ERROR_SUCCESS) @throw [OFSetWindowsRegistryValueFailedException exceptionWithRegistryKey: self value: value data: data type: type @@ -266,14 +266,14 @@ OFString *ret; if (data == nil) return nil; - UTF16String = [data items]; - length = [data count]; + UTF16String = data.items; + length = data.count; - if ([data itemSize] != 1 || length % 2 == 1) + if (data.itemSize != 1 || length % 2 == 1) @throw [OFInvalidFormatException exception]; length /= 2; /* @@ -308,13 +308,13 @@ type: (DWORD)type { void *pool = objc_autoreleasePoolPush(); OFData *data; - data = [OFData dataWithItems: [string UTF16String] + data = [OFData dataWithItems: string.UTF16String itemSize: sizeof(of_char16_t) - count: [string UTF16StringLength] + 1]; + count: string.UTF16StringLength + 1]; [self setData: data forValue: value type: type]; objc_autoreleasePoolPop(pool); @@ -323,11 +323,11 @@ - (void)deleteValue: (OFString *)value { void *pool = objc_autoreleasePoolPush(); LSTATUS status; - if ((status = RegDeleteValueW(_hKey, [value UTF16String])) != + if ((status = RegDeleteValueW(_hKey, value.UTF16String)) != ERROR_SUCCESS) @throw [OFDeleteWindowsRegistryValueFailedException exceptionWithRegistryKey: self value: value status: status]; @@ -338,15 +338,15 @@ - (void)deleteSubkeyAtPath: (OFString *)subkeyPath { void *pool = objc_autoreleasePoolPush(); LSTATUS status; - if ((status = RegDeleteKeyW(_hKey, [subkeyPath UTF16String])) != + if ((status = RegDeleteKeyW(_hKey, subkeyPath.UTF16String)) != ERROR_SUCCESS) @throw [OFDeleteWindowsRegistryKeyFailedException exceptionWithRegistryKey: self subkeyPath: subkeyPath status: status]; objc_autoreleasePoolPop(pool); } @end Index: src/OFXMLAttribute.m ================================================================== --- src/OFXMLAttribute.m +++ src/OFXMLAttribute.m @@ -75,20 +75,19 @@ self = [super of_init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - _name = [[[element attributeForName: @"name"] - stringValue] copy]; - _namespace = [[[element attributeForName: @"namespace"] - stringValue] copy]; - _stringValue = [[[element attributeForName: @"stringValue"] - stringValue] copy]; + _name = [[element attributeForName: @"name"].stringValue copy]; + _namespace = [[element attributeForName: @"namespace"] + .stringValue copy]; + _stringValue = [[element attributeForName: @"stringValue"] + .stringValue copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -145,13 +144,13 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); - OF_HASH_ADD_HASH(hash, [_namespace hash]); - OF_HASH_ADD_HASH(hash, [_stringValue hash]); + OF_HASH_ADD_HASH(hash, _name.hash); + OF_HASH_ADD_HASH(hash, _namespace.hash); + OF_HASH_ADD_HASH(hash, _stringValue.hash); OF_HASH_FINALIZE(hash); return hash; } @@ -159,11 +158,11 @@ - (OFXMLElement *)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; - element = [OFXMLElement elementWithName: [self className] + element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; [element addAttributeWithName: @"name" stringValue: _name]; Index: src/OFXMLCDATA.m ================================================================== --- src/OFXMLCDATA.m +++ src/OFXMLCDATA.m @@ -49,15 +49,15 @@ self = [super of_init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - _CDATA = [[element stringValue] copy]; + _CDATA = [element.stringValue copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -88,11 +88,11 @@ return ([CDATA->_CDATA isEqual: _CDATA]); } - (uint32_t)hash { - return [_CDATA hash]; + return _CDATA.hash; } - (OFString *)stringValue { return [[_CDATA copy] autorelease]; @@ -118,29 +118,29 @@ return [ret autorelease]; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation { - return [self XMLString]; + return self.XMLString; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation level: (unsigned int)level { - return [self XMLString]; + return self.XMLString; } - (OFString *)description { - return [self XMLString]; + return self.XMLString; } - (OFXMLElement *)XMLElementBySerializing { OFXMLElement *element = - [OFXMLElement elementWithName: [self className] + [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; [element addChild: self]; return element; } @end Index: src/OFXMLCharacters.m ================================================================== --- src/OFXMLCharacters.m +++ src/OFXMLCharacters.m @@ -49,15 +49,15 @@ self = [super of_init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - _characters = [[element stringValue] copy]; + _characters = [element.stringValue copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -88,11 +88,11 @@ return ([characters->_characters isEqual: _characters]); } - (uint32_t)hash { - return [_characters hash]; + return _characters.hash; } - (OFString *)stringValue { return [[_characters copy] autorelease]; @@ -105,31 +105,31 @@ [old release]; } - (OFString *)XMLString { - return [_characters stringByXMLEscaping]; + return _characters.stringByXMLEscaping; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation { - return [_characters stringByXMLEscaping]; + return _characters.stringByXMLEscaping; } - (OFString *)XMLStringWithIndentation: (unsigned int)indentation level: (unsigned int)level { - return [_characters stringByXMLEscaping]; + return _characters.stringByXMLEscaping; } - (OFString *)description { - return [_characters stringByXMLEscaping]; + return _characters.stringByXMLEscaping; } - (OFXMLElement *)XMLElementBySerializing { - return [OFXMLElement elementWithName: [self className] + return [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS stringValue: _characters]; } @end Index: src/OFXMLComment.m ================================================================== --- src/OFXMLComment.m +++ src/OFXMLComment.m @@ -51,15 +51,15 @@ self = [super of_init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - _comment = [[element stringValue] copy]; + _comment = [element.stringValue copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -90,11 +90,11 @@ return ([comment->_comment isEqual: _comment]); } - (uint32_t)hash { - return [_comment hash]; + return _comment.hash; } - (OFString *)stringValue { return @""; @@ -139,10 +139,10 @@ return [OFString stringWithFormat: @"", _comment]; } - (OFXMLElement *)XMLElementBySerializing { - return [OFXMLElement elementWithName: [self className] + return [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS stringValue: _comment]; } @end Index: src/OFXMLElement.m ================================================================== --- src/OFXMLElement.m +++ src/OFXMLElement.m @@ -98,22 +98,22 @@ return [[[self alloc] initWithName: name stringValue: stringValue] autorelease]; } + (instancetype)elementWithName: (OFString *)name - namespace: (OFString *)ns + namespace: (OFString *)namespace { return [[[self alloc] initWithName: name - namespace: ns] autorelease]; + namespace: namespace] autorelease]; } + (instancetype)elementWithName: (OFString *)name - namespace: (OFString *)ns + namespace: (OFString *)namespace stringValue: (OFString *)stringValue { return [[[self alloc] initWithName: name - namespace: ns + namespace: namespace stringValue: stringValue] autorelease]; } + (instancetype)elementWithElement: (OFXMLElement *)element { @@ -177,11 +177,11 @@ initWithKeysAndObjects: @"http://www.w3.org/XML/1998/namespace", @"xml", @"http://www.w3.org/2000/xmlns/", @"xmlns", nil]; if (stringValue != nil) - [self setStringValue: stringValue]; + self.stringValue = stringValue; } @catch (id e) { [self release]; @throw e; } @@ -228,16 +228,16 @@ parser = [OFXMLParser parser]; builder = [OFXMLElementBuilder elementBuilder]; delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init] autorelease]; - [parser setDelegate: builder]; - [builder setDelegate: delegate]; + parser.delegate = builder; + builder.delegate = delegate; [parser parseString: string]; - if (![parser hasFinishedParsing]) + if (!parser.hasFinishedParsing) @throw [OFMalformedXMLException exceptionWithParser: parser]; self = [delegate->_element retain]; objc_autoreleasePoolPop(pool); @@ -260,16 +260,16 @@ parser = [OFXMLParser parser]; builder = [OFXMLElementBuilder elementBuilder]; delegate = [[[OFXMLElement_OFXMLElementBuilderDelegate alloc] init] autorelease]; - [parser setDelegate: builder]; - [builder setDelegate: delegate]; + parser.delegate = builder; + builder.delegate = delegate; [parser parseFile: path]; - if (![parser hasFinishedParsing]) + if (!parser.hasFinishedParsing) @throw [OFMalformedXMLException exceptionWithParser: parser]; self = [delegate->_element retain]; objc_autoreleasePoolPop(pool); @@ -287,39 +287,38 @@ OFXMLElement *attributesElement, *namespacesElement; OFXMLElement *childrenElement; OFEnumerator *keyEnumerator, *objectEnumerator; OFString *key, *object; - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - _name = [[[element attributeForName: @"name"] - stringValue] copy]; - _namespace = [[[element attributeForName: @"namespace"] - stringValue] copy]; - _defaultNamespace = [[[element attributeForName: - @"defaultNamespace"] stringValue] copy]; - - attributesElement = [[[element + _name = [[element attributeForName: @"name"].stringValue copy]; + _namespace = [[element attributeForName: @"namespace"] + .stringValue copy]; + _defaultNamespace = [[element attributeForName: + @"defaultNamespace"].stringValue copy]; + + attributesElement = [[element elementForName: @"attributes" namespace: OF_SERIALIZATION_NS] elementsForNamespace: - OF_SERIALIZATION_NS] firstObject]; - namespacesElement = [[[element + OF_SERIALIZATION_NS].firstObject; + namespacesElement = [[element elementForName: @"namespaces" namespace: OF_SERIALIZATION_NS] elementsForNamespace: - OF_SERIALIZATION_NS] firstObject]; - childrenElement = [[[element + OF_SERIALIZATION_NS].firstObject; + childrenElement = [[element elementForName: @"children" namespace: OF_SERIALIZATION_NS] elementsForNamespace: - OF_SERIALIZATION_NS] firstObject]; + OF_SERIALIZATION_NS].firstObject; - _attributes = [[attributesElement objectByDeserializing] + _attributes = [attributesElement.objectByDeserializing + mutableCopy]; + _namespaces = [namespacesElement.objectByDeserializing mutableCopy]; - _namespaces = [[namespacesElement objectByDeserializing] - mutableCopy]; - _children = [[childrenElement objectByDeserializing] + _children = [childrenElement.objectByDeserializing mutableCopy]; /* Sanity checks */ if ((_attributes != nil && ![_attributes isKindOfClass: [OFMutableArray class]]) || (_namespaces != nil && @@ -396,29 +395,29 @@ - (void)setStringValue: (OFString *)stringValue { void *pool = objc_autoreleasePoolPush(); - [self setChildren: [OFArray arrayWithObject: - [OFXMLCharacters charactersWithString: stringValue]]]; + self.children = [OFArray arrayWithObject: + [OFXMLCharacters charactersWithString: stringValue]]; objc_autoreleasePoolPop(pool); } - (OFString *)stringValue { OFMutableString *ret; - if ([_children count] == 0) + if (_children.count == 0) return @""; ret = [OFMutableString string]; for (OFXMLNode *child in _children) { void *pool = objc_autoreleasePoolPush(); - [ret appendString: [child stringValue]]; + [ret appendString: child.stringValue]; objc_autoreleasePoolPop(pool); } [ret makeImmutable]; @@ -471,43 +470,42 @@ defaultNS = parent->_defaultNamespace; else defaultNS = _defaultNamespace; i = 0; - length = [_name UTF8StringLength] + 3 + (level * indentation); + length = _name.UTF8StringLength + 3 + (level * indentation); cString = [self allocMemoryWithSize: length]; memset(cString + i, ' ', level * indentation); i += level * indentation; /* Start of tag */ cString[i++] = '<'; if (prefix != nil && ![_namespace isEqual: defaultNS]) { - length += [prefix UTF8StringLength] + 1; + length += prefix.UTF8StringLength + 1; @try { cString = [self resizeMemory: cString size: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } - memcpy(cString + i, [prefix UTF8String], - [prefix UTF8StringLength]); - i += [prefix UTF8StringLength]; + memcpy(cString + i, prefix.UTF8String, prefix.UTF8StringLength); + i += prefix.UTF8StringLength; cString[i++] = ':'; } - memcpy(cString + i, [_name UTF8String], [_name UTF8StringLength]); - i += [_name UTF8StringLength]; + memcpy(cString + i, _name.UTF8String, _name.UTF8StringLength); + i += _name.UTF8StringLength; /* xmlns if necessary */ if (prefix == nil && ((_namespace != nil && ![_namespace isEqual: defaultNS]) || (_namespace == nil && defaultNS != nil))) { - length += [_namespace UTF8StringLength] + 9; + length += _namespace.UTF8StringLength + 9; @try { cString = [self resizeMemory: cString size: length]; } @catch (id e) { [self freeMemory: cString]; @@ -514,25 +512,23 @@ @throw e; } memcpy(cString + i, " xmlns='", 8); i += 8; - memcpy(cString + i, [_namespace UTF8String], - [_namespace UTF8StringLength]); - i += [_namespace UTF8StringLength]; + memcpy(cString + i, _namespace.UTF8String, + _namespace.UTF8StringLength); + i += _namespace.UTF8StringLength; cString[i++] = '\''; } /* Attributes */ for (OFXMLAttribute *attribute in _attributes) { void *pool2 = objc_autoreleasePoolPush(); - const char *attributeNameCString = - [attribute->_name UTF8String]; - size_t attributeNameLength = - [attribute->_name UTF8StringLength]; + const char *attributeNameCString = attribute->_name.UTF8String; + size_t attributeNameLength = attribute->_name.UTF8StringLength; OFString *attributePrefix = nil; - OFString *tmp = [[attribute stringValue] stringByXMLEscaping]; + OFString *tmp = attribute.stringValue.stringByXMLEscaping; char delimiter = (attribute->_useDoubleQuotes ? '"' : '\''); if (attribute->_namespace != nil && (attributePrefix = [allNamespaces objectForKey: attribute->_namespace]) == nil) @@ -540,12 +536,12 @@ exceptionWithNamespace: [attribute namespace] element: self]; length += attributeNameLength + (attributePrefix != nil ? - [attributePrefix UTF8StringLength] + 1 : 0) + - [tmp UTF8StringLength] + 4; + attributePrefix.UTF8StringLength + 1 : 0) + + tmp.UTF8StringLength + 4; @try { cString = [self resizeMemory: cString size: length]; } @catch (id e) { @@ -553,21 +549,21 @@ @throw e; } cString[i++] = ' '; if (attributePrefix != nil) { - memcpy(cString + i, [attributePrefix UTF8String], - [attributePrefix UTF8StringLength]); - i += [attributePrefix UTF8StringLength]; + memcpy(cString + i, attributePrefix.UTF8String, + attributePrefix.UTF8StringLength); + i += attributePrefix.UTF8StringLength; cString[i++] = ':'; } memcpy(cString + i, attributeNameCString, attributeNameLength); i += attributeNameLength; cString[i++] = '='; cString[i++] = delimiter; - memcpy(cString + i, [tmp UTF8String], [tmp UTF8StringLength]); - i += [tmp UTF8StringLength]; + memcpy(cString + i, tmp.UTF8String, tmp.UTF8StringLength); + i += tmp.UTF8StringLength; cString[i++] = delimiter; objc_autoreleasePoolPop(pool2); } @@ -605,18 +601,18 @@ else childString = [child XMLStringWithIndentation: ind level: level + 1]; - [tmp addItems: [childString UTF8String] - count: [childString UTF8StringLength]]; + [tmp addItems: childString.UTF8String + count: childString.UTF8StringLength]; } if (indent) [tmp addItem: "\n"]; - length += [tmp count] + [_name UTF8StringLength] + 2 + + length += tmp.count + _name.UTF8StringLength + 2 + (indent ? level * indentation : 0); @try { cString = [self resizeMemory: cString size: length]; } @catch (id e) { @@ -624,38 +620,37 @@ @throw e; } cString[i++] = '>'; - memcpy(cString + i, [tmp items], [tmp count]); - i += [tmp count]; + memcpy(cString + i, tmp.items, tmp.count); + i += tmp.count; if (indent) { memset(cString + i, ' ', level * indentation); i += level * indentation; } cString[i++] = '<'; cString[i++] = '/'; if (prefix != nil) { - length += [prefix UTF8StringLength] + 1; + length += prefix.UTF8StringLength + 1; @try { cString = [self resizeMemory: cString size: length]; } @catch (id e) { [self freeMemory: cString]; @throw e; } - memcpy(cString + i, [prefix UTF8String], - [prefix UTF8StringLength]); - i += [prefix UTF8StringLength]; + memcpy(cString + i, prefix.UTF8String, + prefix.UTF8StringLength); + i += prefix.UTF8StringLength; cString[i++] = ':'; } - memcpy(cString + i, [_name UTF8String], - [_name UTF8StringLength]); - i += [_name UTF8StringLength]; + memcpy(cString + i, _name.UTF8String, _name.UTF8StringLength); + i += _name.UTF8StringLength; } else cString[i++] = '/'; cString[i++] = '>'; assert(i == length); @@ -699,11 +694,11 @@ - (OFXMLElement *)XMLElementBySerializing { void *pool = objc_autoreleasePoolPush(); OFXMLElement *element; - element = [OFXMLElement elementWithName: [self className] + element = [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS]; if (_name != nil) [element addAttributeWithName: @"name" stringValue: _name]; @@ -721,11 +716,11 @@ attributesElement = [OFXMLElement elementWithName: @"attributes" namespace: OF_SERIALIZATION_NS]; [attributesElement addChild: - [_attributes XMLElementBySerializing]]; + _attributes.XMLElementBySerializing]; [element addChild: attributesElement]; } if (_namespaces != nil) { OFXMLElement *namespacesElement; @@ -735,16 +730,16 @@ [namespacesCopy removeObjectForKey: @"http://www.w3.org/XML/1998/namespace"]; [namespacesCopy removeObjectForKey: @"http://www.w3.org/2000/xmlns/"]; - if ([namespacesCopy count] > 0) { + if (namespacesCopy.count > 0) { namespacesElement = [OFXMLElement elementWithName: @"namespaces" namespace: OF_SERIALIZATION_NS]; [namespacesElement addChild: - [namespacesCopy XMLElementBySerializing]]; + namespacesCopy.XMLElementBySerializing]; [element addChild: namespacesElement]; } } if (_children != nil) { @@ -751,11 +746,11 @@ OFXMLElement *childrenElement; childrenElement = [OFXMLElement elementWithName: @"children" namespace: OF_SERIALIZATION_NS]; - [childrenElement addChild: [_children XMLElementBySerializing]]; + [childrenElement addChild: _children.XMLElementBySerializing]; [element addChild: childrenElement]; } [element retain]; @@ -822,12 +817,12 @@ return nil; } - (void)removeAttributeForName: (OFString *)attributeName { - OFXMLAttribute *const *objects = [_attributes objects]; - size_t count = [_attributes count]; + OFXMLAttribute *const *objects = _attributes.objects; + size_t count = _attributes.count; for (size_t i = 0; i < count; i++) { if (objects[i]->_namespace == nil && [objects[i]->_name isEqual: attributeName]) { [_attributes removeObjectAtIndex: i]; @@ -846,12 +841,12 @@ if (attributeNS == nil) { [self removeAttributeForName: attributeName]; return; } - objects = [_attributes objects]; - count = [_attributes count]; + objects = _attributes.objects; + count = _attributes.count; for (size_t i = 0; i < count; i++) { if ([objects[i]->_namespace isEqual: attributeNS] && [objects[i]->_name isEqual: attributeName]) { [_attributes removeObjectAtIndex: i]; @@ -861,11 +856,11 @@ } - (void)setPrefix: (OFString *)prefix forNamespace: (OFString *)namespace { - if ([prefix length] == 0) + if (prefix.length == 0) @throw [OFInvalidArgumentException exception]; if (namespace == nil) namespace = @""; [_namespaces setObject: prefix @@ -951,18 +946,18 @@ withObject: node]; } - (OFXMLElement *)elementForName: (OFString *)elementName { - return [[self elementsForName: elementName] firstObject]; + return [self elementsForName: elementName].firstObject; } - (OFXMLElement *)elementForName: (OFString *)elementName namespace: (OFString *)elementNS { - return [[self elementsForName: elementName - namespace: elementNS] firstObject]; + return [self elementsForName: elementName + namespace: elementNS].firstObject; } - (OFArray *)elements { OFMutableArray OF_GENERIC(OFXMLElement *) *ret = [OFMutableArray array]; @@ -1076,16 +1071,16 @@ { uint32_t hash; OF_HASH_INIT(hash); - OF_HASH_ADD_HASH(hash, [_name hash]); - OF_HASH_ADD_HASH(hash, [_namespace hash]); - OF_HASH_ADD_HASH(hash, [_defaultNamespace hash]); - OF_HASH_ADD_HASH(hash, [_attributes hash]); - OF_HASH_ADD_HASH(hash, [_namespaces hash]); - OF_HASH_ADD_HASH(hash, [_children hash]); + OF_HASH_ADD_HASH(hash, _name.hash); + OF_HASH_ADD_HASH(hash, _namespace.hash); + OF_HASH_ADD_HASH(hash, _defaultNamespace.hash); + OF_HASH_ADD_HASH(hash, _attributes.hash); + OF_HASH_ADD_HASH(hash, _namespaces.hash); + OF_HASH_ADD_HASH(hash, _children.hash); OF_HASH_FINALIZE(hash); return hash; } Index: src/OFXMLElementBuilder.m ================================================================== --- src/OFXMLElementBuilder.m +++ src/OFXMLElementBuilder.m @@ -61,11 +61,11 @@ - (void)parser: (OFXMLParser *)parser foundProcessingInstructions: (OFString *)pi { OFXMLProcessingInstructions *node = [OFXMLProcessingInstructions processingInstructionsWithString: pi]; - OFXMLElement *parent = [_stack lastObject]; + OFXMLElement *parent = _stack.lastObject; if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) @@ -81,32 +81,32 @@ { OFXMLElement *element = [OFXMLElement elementWithName: name namespace: namespace]; for (OFXMLAttribute *attribute in attributes) { - if ([attribute namespace] == nil && - [[attribute name] isEqual: @"xmlns"]) + if (attribute.namespace == nil && + [attribute.name isEqual: @"xmlns"]) continue; - if ([[attribute namespace] - isEqual: @"http://www.w3.org/2000/xmlns/"]) - [element setPrefix: [attribute name] - forNamespace: [attribute stringValue]]; + if ([attribute.namespace isEqual: + @"http://www.w3.org/2000/xmlns/"]) + [element setPrefix: attribute.name + forNamespace: attribute.stringValue]; [element addAttribute: attribute]; } - [[_stack lastObject] addChild: element]; + [_stack.lastObject addChild: element]; [_stack addObject: element]; } - (void)parser: (OFXMLParser *)parser didEndElement: (OFString *)name prefix: (OFString *)prefix namespace: (OFString *)namespace { - switch ([_stack count]) { + switch (_stack.count) { case 0: if ([_delegate respondsToSelector: @selector(elementBuilder: didNotExpectCloseTag:prefix:namespace:)]) [_delegate elementBuilder: self didNotExpectCloseTag: name @@ -116,11 +116,11 @@ @throw [OFMalformedXMLException exception]; return; case 1: [_delegate elementBuilder: self - didBuildElement: [_stack firstObject]]; + didBuildElement: _stack.firstObject]; break; } [_stack removeLastObject]; } @@ -130,11 +130,11 @@ { OFXMLCharacters *node; OFXMLElement *parent; node = [OFXMLCharacters charactersWithString: characters]; - parent = [_stack lastObject]; + parent = _stack.lastObject; if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) @@ -144,11 +144,11 @@ - (void)parser: (OFXMLParser *)parser foundCDATA: (OFString *)CDATA { OFXMLCDATA *node = [OFXMLCDATA CDATAWithString: CDATA]; - OFXMLElement *parent = [_stack lastObject]; + OFXMLElement *parent = _stack.lastObject; if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) @@ -158,11 +158,11 @@ - (void)parser: (OFXMLParser *)parser foundComment: (OFString *)comment { OFXMLComment *node = [OFXMLComment commentWithString: comment]; - OFXMLElement *parent = [_stack lastObject]; + OFXMLElement *parent = _stack.lastObject; if (parent != nil) [parent addChild: node]; else if ([_delegate respondsToSelector: @selector(elementBuilder:didBuildParentlessNode:)]) Index: src/OFXMLNode.m ================================================================== --- src/OFXMLNode.m +++ src/OFXMLNode.m @@ -46,26 +46,26 @@ OF_UNRECOGNIZED_SELECTOR } - (intmax_t)decimalValue { - return [[self stringValue] decimalValue]; + return self.stringValue.decimalValue; } - (uintmax_t)hexadecimalValue { - return [[self stringValue] hexadecimalValue]; + return self.stringValue.hexadecimalValue; } - (float)floatValue { - return [[self stringValue] floatValue]; + return self.stringValue.floatValue; } - (double)doubleValue { - return [[self stringValue] doubleValue]; + return self.stringValue.doubleValue; } - (OFString *)XMLString { return [self XMLStringWithIndentation: 0 Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -76,30 +76,30 @@ else { void *pool = objc_autoreleasePoolPush(); OFString *tmp = [OFString stringWithCString: string encoding: encoding length: length]; - [buffer addItems: [tmp UTF8String] - count: [tmp UTF8StringLength]]; + [buffer addItems: tmp.UTF8String + count: tmp.UTF8StringLength]; objc_autoreleasePoolPop(pool); } } static OFString * transformString(OFXMLParser *parser, OFMutableData *buffer, size_t cut, bool unescape) { - char *items = [buffer items]; - size_t length = [buffer count] - cut; + char *items = buffer.mutableItems; + size_t length = buffer.count - cut; bool hasEntities = false; OFString *ret; for (size_t i = 0; i < length; i++) { if (items[i] == '\r') { if (i + 1 < length && items[i + 1] == '\n') { [buffer removeItemAtIndex: i]; - items = [buffer items]; + items = buffer.mutableItems; i--; length--; } else items[i] = '\n'; @@ -123,12 +123,12 @@ } static OFString * namespaceForPrefix(OFString *prefix, OFArray *namespaces) { - OFDictionary *const *objects = [namespaces objects]; - size_t count = [namespaces count]; + OFDictionary *const *objects = namespaces.objects; + size_t count = namespaces.count; if (prefix == nil) prefix = @""; while (count > 0) { @@ -280,21 +280,21 @@ length - _last); } - (void)parseString: (OFString *)string { - [self parseBuffer: [string UTF8String] - length: [string UTF8StringLength]]; + [self parseBuffer: string.UTF8String + length: string.UTF8StringLength]; } - (void)parseStream: (OFStream *)stream { size_t pageSize = [OFSystemInfo pageSize]; char *buffer = [self allocMemoryWithSize: pageSize]; @try { - while (![stream isAtEndOfStream]) { + while (!stream.atEndOfStream) { size_t length = [stream readIntoBuffer: buffer length: pageSize]; [self parseBuffer: buffer length: length]; @@ -344,11 +344,11 @@ /* Not in a tag */ - (void)of_outsideTagState { size_t length; - if ((_finishedParsing || [_previous count] < 1) && _data[_i] != ' ' && + if ((_finishedParsing || _previous.count < 1) && _data[_i] != ' ' && _data[_i] != '\t' && _data[_i] != '\n' && _data[_i] != '\r' && _data[_i] != '<') @throw [OFMalformedXMLException exceptionWithParser: self]; if (_data[_i] != '<') @@ -355,11 +355,11 @@ return; if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); - if ([_buffer count] > 0) { + if (_buffer.count > 0) { void *pool = objc_autoreleasePoolPush(); OFString *characters = transformString(self, _buffer, 0, true); if ([_delegate respondsToSelector: @selector(parser:foundCharacters:)]) @@ -396,11 +396,11 @@ _last = _i + 1; _state = OF_XMLPARSER_IN_EXCLAMATIONMARK; _acceptProlog = false; break; default: - if (_depthLimit > 0 && [_previous count] >= _depthLimit) + if (_depthLimit > 0 && _previous.count >= _depthLimit) @throw [OFOutOfRangeException exception]; _state = OF_XMLPARSER_IN_TAG_NAME; _acceptProlog = false; _i--; @@ -422,15 +422,15 @@ if (!_acceptProlog) return false; _acceptProlog = false; - pi = [pi substringWithRange: of_range(3, [pi length] - 3)]; - pi = [pi stringByDeletingEnclosingWhitespaces]; + pi = [pi substringWithRange: of_range(3, pi.length - 3)]; + pi = pi.stringByDeletingEnclosingWhitespaces; - cString = [pi UTF8String]; - length = [pi UTF8StringLength]; + cString = pi.UTF8String; + length = pi.UTF8StringLength; last = 0; for (size_t i = 0; i < length; i++) { switch (PIState) { case 0: @@ -545,12 +545,12 @@ if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); - bufferCString = [_buffer items]; - bufferLength = [_buffer count]; + bufferCString = _buffer.items; + bufferLength = _buffer.count; bufferString = [OFString stringWithUTF8String: bufferCString length: bufferLength]; if ((tmp = memchr(bufferCString, ':', bufferLength)) != NULL) { _name = [[OFString alloc] @@ -589,11 +589,11 @@ [_delegate parser: self didEndElement: _name prefix: _prefix namespace: namespace]; - if ([_previous count] == 0) + if (_previous.count == 0) _finishedParsing = true; } else [_previous addObject: bufferString]; [_name release]; @@ -630,12 +630,12 @@ if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); - bufferCString = [_buffer items]; - bufferLength = [_buffer count]; + bufferCString = _buffer.items; + bufferLength = _buffer.count; bufferString = [OFString stringWithUTF8String: bufferCString length: bufferLength]; if ((tmp = memchr(bufferCString, ':', bufferLength)) != NULL) { _name = [[OFString alloc] @@ -648,11 +648,11 @@ } else { _name = [bufferString copy]; _prefix = nil; } - if (![[_previous lastObject] isEqual: bufferString]) + if (![_previous.lastObject isEqual: bufferString]) @throw [OFMalformedXMLException exceptionWithParser: self]; [_previous removeLastObject]; [_buffer removeAllItems]; @@ -679,11 +679,11 @@ _last = _i + 1; _state = (_data[_i] == '>' ? OF_XMLPARSER_OUTSIDE_TAG : OF_XMLPARSER_EXPECT_SPACE_OR_TAG_CLOSE); - if ([_previous count] == 0) + if (_previous.count == 0) _finishedParsing = true; } /* Inside a tag, name found */ - (void)of_inTagState @@ -702,12 +702,12 @@ } return; } - attributesObjects = [_attributes objects]; - attributesCount = [_attributes count]; + attributesObjects = _attributes.objects; + attributesCount = _attributes.count; namespace = namespaceForPrefix(_prefix, _namespaces); if (_prefix != nil && namespace == nil) @throw [OFUnboundPrefixException exceptionWithPrefix: _prefix @@ -733,11 +733,11 @@ [_delegate parser: self didEndElement: _name prefix: _prefix namespace: namespace]; - if ([_previous count] == 0) + if (_previous.count == 0) _finishedParsing = true; [_namespaces removeLastObject]; } else if (_prefix != nil) { OFString *str = [OFString stringWithFormat: @"%@:%@", @@ -774,15 +774,15 @@ if ((length = _i - _last) > 0) appendToBuffer(_buffer, _data + _last, _encoding, length); pool = objc_autoreleasePoolPush(); - bufferString = [OFString stringWithUTF8String: [_buffer items] - length: [_buffer count]]; + bufferString = [OFString stringWithUTF8String: _buffer.items + length: _buffer.count]; - bufferCString = [bufferString UTF8String]; - bufferLength = [bufferString UTF8StringLength]; + bufferCString = bufferString.UTF8String; + bufferLength = bufferString.UTF8StringLength; if ((tmp = memchr(bufferCString, ':', bufferLength)) != NULL) { _attributeName = [[OFString alloc] initWithUTF8String: tmp + 1 length: bufferLength - @@ -851,15 +851,15 @@ pool = objc_autoreleasePoolPush(); attributeValue = transformString(self, _buffer, 0, true); if (_attributePrefix == nil && [_attributeName isEqual: @"xmlns"]) - [[_namespaces lastObject] setObject: attributeValue - forKey: @""]; + [_namespaces.lastObject setObject: attributeValue + forKey: @""]; if ([_attributePrefix isEqual: @"xmlns"]) - [[_namespaces lastObject] setObject: attributeValue - forKey: _attributeName]; + [_namespaces.lastObject setObject: attributeValue + forKey: _attributeName]; attribute = [OFXMLAttribute attributeWithName: _attributeName namespace: _attributePrefix stringValue: attributeValue]; attribute->_useDoubleQuotes = (_delimiter == '"'); Index: src/OFXMLProcessingInstructions.m ================================================================== --- src/OFXMLProcessingInstructions.m +++ src/OFXMLProcessingInstructions.m @@ -51,15 +51,15 @@ self = [super of_init]; @try { void *pool = objc_autoreleasePoolPush(); - if (![[element name] isEqual: [self className]] || - ![[element namespace] isEqual: OF_SERIALIZATION_NS]) + if (![element.name isEqual: self.className] || + ![element.namespace isEqual: OF_SERIALIZATION_NS]) @throw [OFInvalidArgumentException exception]; - _processingInstructions = [[element stringValue] copy]; + _processingInstructions = [element.stringValue copy]; objc_autoreleasePoolPop(pool); } @catch (id e) { [self release]; @throw e; @@ -91,11 +91,11 @@ isEqual: _processingInstructions]); } - (uint32_t)hash { - return [_processingInstructions hash]; + return _processingInstructions.hash; } - (OFString *)stringValue { return @""; @@ -140,10 +140,10 @@ return [OFString stringWithFormat: @"", _processingInstructions]; } - (OFXMLElement *)XMLElementBySerializing { - return [OFXMLElement elementWithName: [self className] + return [OFXMLElement elementWithName: self.className namespace: OF_SERIALIZATION_NS stringValue: _processingInstructions]; } @end Index: src/OFZIPArchive.h ================================================================== --- src/OFZIPArchive.h +++ src/OFZIPArchive.h @@ -31,11 +31,11 @@ * * @brief A class for accessing and manipulating ZIP files. */ @interface OFZIPArchive: OFObject { - OF_KINDOF(OFStream *) _stream; + OFStream *_stream; int64_t _offset; enum { OF_ZIP_ARCHIVE_MODE_READ, OF_ZIP_ARCHIVE_MODE_WRITE, OF_ZIP_ARCHIVE_MODE_APPEND @@ -75,11 +75,11 @@ * @param mode The mode for the ZIP file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return A new, autoreleased OFZIPArchive */ -+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode; #ifdef OF_HAVE_FILES /*! * @brief Creates a new OFZIPArchive object with the specified file. @@ -105,11 +105,11 @@ * @param mode The mode for the ZIP file. Valid modes are "r" for reading, * "w" for creating a new file and "a" for appending to an existing * archive. * @return An initialized OFZIPArchive */ -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode OF_DESIGNATED_INITIALIZER; #ifdef OF_HAVE_FILES /*! * @brief Initializes an already allocated OFZIPArchive object with the Index: src/OFZIPArchive.m ================================================================== --- src/OFZIPArchive.m +++ src/OFZIPArchive.m @@ -74,12 +74,12 @@ - (bool)matchesEntry: (OFZIPArchiveEntry *)entry; @end @interface OFZIPArchive_FileReadStream: OFStream { - OF_KINDOF(OFStream *) _stream; - OF_KINDOF(OFStream *) _decompressedStream; + OFStream *_stream; + OFStream *_decompressedStream; OFZIPArchiveEntry *_entry; uint64_t _toRead; uint32_t _CRC32; bool _atEndOfStream; } @@ -141,21 +141,21 @@ { @try { [stream seekToOffset: offset whence: whence]; } @catch (OFSeekFailedException *e) { - if ([e errNo] == EINVAL) + if (e.errNo == EINVAL) @throw [OFInvalidFormatException exception]; @throw e; } } @implementation OFZIPArchive @synthesize archiveComment = _archiveComment; -+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream ++ (instancetype)archiveWithStream: (OFStream *)stream mode: (OFString *)mode { return [[[self alloc] initWithStream: stream mode: mode] autorelease]; } @@ -172,11 +172,11 @@ - (instancetype)init { OF_INVALID_INIT_METHOD } -- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream +- (instancetype)initWithStream: (OFStream *)stream mode: (OFString *)mode { self = [super init]; @try { @@ -202,11 +202,11 @@ [self of_readEntries]; } if (_mode == OF_ZIP_ARCHIVE_MODE_APPEND) { _offset = _centralDirectoryOffset; - seekOrThrowInvalidFormat(_stream, + seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (of_offset_t)_offset, SEEK_SET); } } @catch (id e) { /* * If we are in write or append mode, we do not want -[close] @@ -266,11 +266,12 @@ uint16_t commentLength; of_offset_t offset = -22; bool valid = false; do { - seekOrThrowInvalidFormat(_stream, offset, SEEK_END); + seekOrThrowInvalidFormat((OFSeekableStream *)_stream, + offset, SEEK_END); if ([_stream readLittleEndianInt32] == 0x06054B50) { valid = true; break; } @@ -298,11 +299,12 @@ _centralDirectorySize == 0xFFFFFFFF || _centralDirectoryOffset == 0xFFFFFFFF) { int64_t offset64; uint64_t size; - seekOrThrowInvalidFormat(_stream, offset - 20, SEEK_END); + seekOrThrowInvalidFormat((OFSeekableStream *)_stream, + offset - 20, SEEK_END); if ([_stream readLittleEndianInt32] != 0x07064B50) { objc_autoreleasePoolPop(pool); return; } @@ -315,11 +317,11 @@ offset64 = [_stream readLittleEndianInt64]; if (offset64 < 0 || (of_offset_t)offset64 != offset64) @throw [OFOutOfRangeException exception]; - seekOrThrowInvalidFormat(_stream, + seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (of_offset_t)offset64, SEEK_SET); if ([_stream readLittleEndianInt32] != 0x06064B50) @throw [OFInvalidFormatException exception]; @@ -355,23 +357,23 @@ if (_centralDirectoryOffset < 0 || (of_offset_t)_centralDirectoryOffset != _centralDirectoryOffset) @throw [OFOutOfRangeException exception]; - seekOrThrowInvalidFormat(_stream, + seekOrThrowInvalidFormat((OFSeekableStream *)_stream, (of_offset_t)_centralDirectoryOffset, SEEK_SET); for (size_t i = 0; i < _centralDirectoryEntries; i++) { OFZIPArchiveEntry *entry = [[[OFZIPArchiveEntry alloc] of_initWithStream: _stream] autorelease]; - if ([_pathToEntryMap objectForKey: [entry fileName]] != nil) + if ([_pathToEntryMap objectForKey: entry.fileName] != nil) @throw [OFInvalidFormatException exception]; [_entries addObject: entry]; [_pathToEntryMap setObject: entry - forKey: [entry fileName]]; + forKey: entry.fileName]; } objc_autoreleasePoolPop(pool); } @@ -388,11 +390,11 @@ - (void)setArchiveComment: (OFString *)comment { void *pool = objc_autoreleasePoolPush(); OFString *old; - if ([comment UTF8StringLength] > UINT16_MAX) + if (comment.UTF8StringLength > UINT16_MAX) @throw [OFOutOfRangeException exception]; old = _archiveComment; _archiveComment = [comment copy]; [old release]; @@ -442,15 +444,16 @@ mode: @"r" errNo: ENOENT]; [self of_closeLastReturnedStream]; - offset64 = [entry of_localFileHeaderOffset]; + offset64 = entry.of_localFileHeaderOffset; if (offset64 < 0 || (of_offset_t)offset64 != offset64) @throw [OFOutOfRangeException exception]; - seekOrThrowInvalidFormat(_stream, (of_offset_t)offset64, SEEK_SET); + seekOrThrowInvalidFormat((OFSeekableStream *)_stream, + (of_offset_t)offset64, SEEK_SET); localFileHeader = [[[OFZIPArchive_LocalFileHeader alloc] initWithStream: _stream] autorelease]; if (![localFileHeader matchesEntry: entry]) @throw [OFInvalidFormatException exception]; @@ -488,46 +491,45 @@ @throw [OFInvalidArgumentException exception]; pool = objc_autoreleasePoolPush(); entry = [[entry_ mutableCopy] autorelease]; - if ([_pathToEntryMap objectForKey: [entry fileName]] != nil) + if ([_pathToEntryMap objectForKey: entry.fileName] != nil) @throw [OFOpenItemFailedException - exceptionWithPath: [entry fileName] + exceptionWithPath: entry.fileName mode: @"w" errNo: EEXIST]; - if ([entry compressionMethod] != + if (entry.compressionMethod != OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE) @throw [OFNotImplementedException exceptionWithSelector: _cmd object: self]; [self of_closeLastReturnedStream]; - fileName = [entry fileName]; - fileNameLength = [fileName UTF8StringLength]; - extraField = [entry extraField]; - extraFieldLength = [extraField count]; + fileName = entry.fileName; + fileNameLength = fileName.UTF8StringLength; + extraField = entry.extraField; + extraFieldLength = extraField.count; if (UINT16_MAX - extraFieldLength < 20) @throw [OFOutOfRangeException exception]; - [entry setVersionMadeBy: ([entry versionMadeBy] & 0xFF00) | 45]; - [entry setMinVersionNeeded: ([entry minVersionNeeded] & 0xFF00) | 45]; - [entry setCompressedSize: 0]; - [entry setUncompressedSize: 0]; - [entry setCRC32: 0]; - [entry setGeneralPurposeBitFlag: - [entry generalPurposeBitFlag] | (1 << 3) | (1 << 11)]; - [entry of_setLocalFileHeaderOffset: _offset]; + entry.versionMadeBy = (entry.versionMadeBy & 0xFF00) | 45; + entry.minVersionNeeded = (entry.minVersionNeeded & 0xFF00) | 45; + entry.compressedSize = 0; + entry.uncompressedSize = 0; + entry.CRC32 = 0; + entry.generalPurposeBitFlag |= (1 << 3) | (1 << 11); + entry.of_localFileHeaderOffset = _offset; [_stream writeLittleEndianInt32: 0x04034B50]; - [_stream writeLittleEndianInt16: [entry minVersionNeeded]]; - [_stream writeLittleEndianInt16: [entry generalPurposeBitFlag]]; - [_stream writeLittleEndianInt16: [entry compressionMethod]]; - [_stream writeLittleEndianInt16: [entry of_lastModifiedFileTime]]; - [_stream writeLittleEndianInt16: [entry of_lastModifiedFileDate]]; + [_stream writeLittleEndianInt16: entry.minVersionNeeded]; + [_stream writeLittleEndianInt16: entry.generalPurposeBitFlag]; + [_stream writeLittleEndianInt16: entry.compressionMethod]; + [_stream writeLittleEndianInt16: entry.of_lastModifiedFileTime]; + [_stream writeLittleEndianInt16: entry.of_lastModifiedFileDate]; /* We use the data descriptor */ [_stream writeLittleEndianInt32: 0]; /* We use ZIP64 */ [_stream writeLittleEndianInt32: 0xFFFFFFFF]; [_stream writeLittleEndianInt32: 0xFFFFFFFF]; @@ -604,11 +606,11 @@ [_stream writeLittleEndianInt16: 0xFFFF]; /* CD disk */ [_stream writeLittleEndianInt16: 0xFFFF]; /* CD entries in disk */ [_stream writeLittleEndianInt16: 0xFFFF]; /* CD entries */ [_stream writeLittleEndianInt32: 0xFFFFFFFF]; /* CD size */ [_stream writeLittleEndianInt32: 0xFFFFFFFF]; /* CD offset */ - [_stream writeLittleEndianInt16: [_archiveComment UTF8StringLength]]; + [_stream writeLittleEndianInt16: _archiveComment.UTF8StringLength]; if (_archiveComment != nil) [_stream writeString: _archiveComment]; objc_autoreleasePoolPop(pool); } @@ -685,11 +687,11 @@ @throw [OFInvalidFormatException exception]; [extraField removeItemsInRange: range]; } - if ([extraField count] > 0) { + if (extraField.count > 0) { [extraField makeImmutable]; _extraField = [extraField copy]; } objc_autoreleasePoolPop(pool); @@ -709,22 +711,22 @@ [super dealloc]; } - (bool)matchesEntry: (OFZIPArchiveEntry *)entry { - if (_compressionMethod != [entry compressionMethod] || - _lastModifiedFileTime != [entry of_lastModifiedFileTime] || - _lastModifiedFileDate != [entry of_lastModifiedFileDate]) + if (_compressionMethod != entry.compressionMethod || + _lastModifiedFileTime != entry.of_lastModifiedFileTime || + _lastModifiedFileDate != entry.of_lastModifiedFileDate) return false; if (!(_generalPurposeBitFlag & (1 << 3))) - if (_CRC32 != [entry CRC32] || - _compressedSize != [entry compressedSize] || - _uncompressedSize != [entry uncompressedSize]) + if (_CRC32 != entry.CRC32 || + _compressedSize != entry.compressedSize || + _uncompressedSize != entry.uncompressedSize) return false; - if (![_fileName isEqual: [entry fileName]]) + if (![_fileName isEqual: entry.fileName]) return false; return true; } @end @@ -736,11 +738,11 @@ self = [super init]; @try { _stream = [stream retain]; - switch ([entry compressionMethod]) { + switch (entry.compressionMethod) { case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE: _decompressedStream = [stream retain]; break; case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_DEFLATE: _decompressedStream = [[OFInflateStream alloc] @@ -755,11 +757,11 @@ exceptionWithSelector: _cmd object: self]; } _entry = [entry copy]; - _toRead = [entry uncompressedSize]; + _toRead = entry.uncompressedSize; _CRC32 = ~0; } @catch (id e) { [self release]; @throw e; } @@ -795,12 +797,11 @@ @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; - if ([_stream isAtEndOfStream] && - ![_decompressedStream hasDataInReadBuffer]) + if (_stream.atEndOfStream && !_decompressedStream.hasDataInReadBuffer) @throw [OFTruncatedDataException exception]; #if SIZE_MAX >= UINT64_MAX if (length > UINT64_MAX) @throw [OFOutOfRangeException exception]; @@ -816,15 +817,15 @@ _CRC32 = of_crc32(_CRC32, buffer, ret); if (_toRead == 0) { _atEndOfStream = true; - if (~_CRC32 != [_entry CRC32]) { + if (~_CRC32 != _entry.CRC32) { OFString *actualChecksum = [OFString stringWithFormat: @"%08" PRIX32, ~_CRC32]; OFString *expectedChecksum = [OFString stringWithFormat: - @"%08" PRIX32, [_entry CRC32]]; + @"%08" PRIX32, _entry.CRC32]; @throw [OFChecksumMismatchException exceptionWithActualChecksum: actualChecksum expectedChecksum: expectedChecksum]; } @@ -833,17 +834,18 @@ return ret; } - (bool)hasDataInReadBuffer { - return ([super hasDataInReadBuffer] || - [_decompressedStream hasDataInReadBuffer]); + return (super.hasDataInReadBuffer || + _decompressedStream.hasDataInReadBuffer); } - (int)fileDescriptorForReading { - return [_decompressedStream fileDescriptorForReading]; + return ((id )_decompressedStream) + .fileDescriptorForReading; } - (void)close { [_stream release]; @@ -912,13 +914,13 @@ [_stream writeLittleEndianInt64: _bytesWritten]; [_stream release]; _stream = nil; - [_entry setCRC32: ~_CRC32]; - [_entry setCompressedSize: _bytesWritten]; - [_entry setUncompressedSize: _bytesWritten]; + _entry.CRC32 = ~_CRC32; + _entry.compressedSize = _bytesWritten; + _entry.uncompressedSize = _bytesWritten; [_entry makeImmutable]; _bytesWritten += (2 * 4 + 2 * 8); } @end Index: src/OFZIPArchiveEntry.m ================================================================== --- src/OFZIPArchiveEntry.m +++ src/OFZIPArchiveEntry.m @@ -146,12 +146,12 @@ size_t of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag, uint16_t *size) { - const uint8_t *bytes = [extraField items]; - size_t count = [extraField count]; + const uint8_t *bytes = extraField.items; + size_t count = extraField.count; for (size_t i = 0; i < count;) { uint16_t currentTag, currentSize; if (i + 3 >= count) @@ -191,11 +191,11 @@ self = [super init]; @try { void *pool = objc_autoreleasePoolPush(); - if ([fileName UTF8StringLength] > UINT16_MAX) + if (fileName.UTF8StringLength > UINT16_MAX) @throw [OFOutOfRangeException exception]; _fileName = [fileName copy]; objc_autoreleasePoolPop(pool); @@ -280,11 +280,11 @@ @throw [OFInvalidFormatException exception]; [extraField removeItemsInRange: range]; } - if ([extraField count] > 0) { + if (extraField.count > 0) { [extraField makeImmutable]; _extraField = [extraField copy]; } objc_autoreleasePoolPop(pool); @@ -449,13 +449,13 @@ @"\tCompression method = %@\n" @"\tModification date = %@\n" @"\tCRC32 = %08" @PRIX32 @"\n" @"\tExtra field = %@\n" @">", - [self class], _fileName, _fileComment, _generalPurposeBitFlag, + self.class, _fileName, _fileComment, _generalPurposeBitFlag, _compressedSize, _uncompressedSize, compressionMethod, - [self modificationDate], _CRC32, _extraField]; + self.modificationDate, _CRC32, _extraField]; [ret retain]; objc_autoreleasePoolPop(pool); @@ -465,11 +465,11 @@ - (uint64_t)of_writeToStream: (OFStream *)stream { void *pool = objc_autoreleasePoolPush(); uint64_t size = 0; - if (UINT16_MAX - [_extraField count] < 32) + if (UINT16_MAX - _extraField.count < 32) @throw [OFOutOfRangeException exception]; [stream writeLittleEndianInt32: 0x02014B50]; [stream writeLittleEndianInt16: _versionMadeBy]; [stream writeLittleEndianInt16: _minVersionNeeded]; @@ -478,22 +478,22 @@ [stream writeLittleEndianInt16: _lastModifiedFileTime]; [stream writeLittleEndianInt16: _lastModifiedFileDate]; [stream writeLittleEndianInt32: _CRC32]; [stream writeLittleEndianInt32: 0xFFFFFFFF]; [stream writeLittleEndianInt32: 0xFFFFFFFF]; - [stream writeLittleEndianInt16: (uint16_t)[_fileName UTF8StringLength]]; - [stream writeLittleEndianInt16: (uint16_t)[_extraField count] + 32]; + [stream writeLittleEndianInt16: (uint16_t)_fileName.UTF8StringLength]; + [stream writeLittleEndianInt16: (uint16_t)_extraField.count + 32]; [stream writeLittleEndianInt16: - (uint16_t)[_fileComment UTF8StringLength]]; + (uint16_t)_fileComment.UTF8StringLength]; [stream writeLittleEndianInt16: 0xFFFF]; [stream writeLittleEndianInt16: _internalAttributes]; [stream writeLittleEndianInt32: _versionSpecificAttributes]; [stream writeLittleEndianInt32: 0xFFFFFFFF]; size += (4 + (6 * 2) + (3 * 4) + (5 * 2) + (2 * 4)); [stream writeString: _fileName]; - size += (uint64_t)[_fileName UTF8StringLength]; + size += (uint64_t)_fileName.UTF8StringLength; [stream writeLittleEndianInt16: OF_ZIP_ARCHIVE_ENTRY_EXTRA_FIELD_ZIP64]; [stream writeLittleEndianInt16: 28]; [stream writeLittleEndianInt64: _uncompressedSize]; [stream writeLittleEndianInt64: _compressedSize]; @@ -501,16 +501,16 @@ [stream writeLittleEndianInt32: _startDiskNumber]; size += (2 * 2) + (3 * 8) + 4; if (_extraField != nil) [stream writeData: _extraField]; - size += (uint64_t)[_extraField count]; + size += (uint64_t)_extraField.count; if (_fileComment != nil) [stream writeString: _fileComment]; - size += (uint64_t)[_fileComment UTF8StringLength]; + size += (uint64_t)_fileComment.UTF8StringLength; objc_autoreleasePoolPop(pool); return size; } @end Index: src/base64.m ================================================================== --- src/base64.m +++ src/base64.m @@ -103,11 +103,11 @@ size_t i; if ((length & 3) != 0) return false; - if ([data itemSize] != 1) + if (data.itemSize != 1) return false; for (i = 0; i < length; i += 4) { uint32_t sb = 0; uint8_t count = 3; Index: src/bridge/NSArray_OFArray.m ================================================================== --- src/bridge/NSArray_OFArray.m +++ src/bridge/NSArray_OFArray.m @@ -45,13 +45,13 @@ return object; } - (NSUInteger)count { - size_t count = [_array count]; + size_t count = _array.count; if (count > NSUIntegerMax) @throw [OFOutOfRangeException exception]; return (NSUInteger)count; } @end Index: src/bridge/NSBridging.h ================================================================== --- src/bridge/NSBridging.h +++ src/bridge/NSBridging.h @@ -40,9 +40,9 @@ * If possible, the original object is wrapped. If this is not possible, an * autoreleased copy is created. * * @return The receiver as an ObjFW object */ -- (id)OFObject; +@property (readonly, nonatomic) id OFObject; @end OF_ASSUME_NONNULL_END Index: src/bridge/NSDictionary_OFDictionary.m ================================================================== --- src/bridge/NSDictionary_OFDictionary.m +++ src/bridge/NSDictionary_OFDictionary.m @@ -52,13 +52,13 @@ return object; } - (NSUInteger)count { - size_t count = [_dictionary count]; + size_t count = _dictionary.count; if (count > NSUIntegerMax) @throw [OFOutOfRangeException exception]; return (NSUInteger)count; } @end Index: src/bridge/NSString+OFObject.m ================================================================== --- src/bridge/NSString+OFObject.m +++ src/bridge/NSString+OFObject.m @@ -21,8 +21,8 @@ int _NSString_OFObject_reference; @implementation NSString (OFObject) - (id)OFObject { - return [OFString stringWithUTF8String: [self UTF8String]]; + return [OFString stringWithUTF8String: self.UTF8String]; } @end Index: src/bridge/OFArray_NSArray.m ================================================================== --- src/bridge/OFArray_NSArray.m +++ src/bridge/OFArray_NSArray.m @@ -29,11 +29,11 @@ self = [super init]; @try { if (array == nil) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; _array = [array retain]; } @catch (id e) { [self release]; @throw e; @@ -57,8 +57,8 @@ return object; } - (size_t)count { - return [_array count]; + return _array.count; } @end Index: src/bridge/OFBridging.h ================================================================== --- src/bridge/OFBridging.h +++ src/bridge/OFBridging.h @@ -41,9 +41,9 @@ * If possible, the original object is wrapped. If this is not possible, an * autoreleased copy is created. * * @return The receiver as Foundation object */ -- (id)NSObject; +@property (readonly, nonatomic) id NSObject; @end OF_ASSUME_NONNULL_END Index: src/bridge/OFDictionary_NSDictionary.m ================================================================== --- src/bridge/OFDictionary_NSDictionary.m +++ src/bridge/OFDictionary_NSDictionary.m @@ -30,11 +30,11 @@ self = [super init]; @try { if (dictionary == nil) @throw [OFInitializationFailedException - exceptionWithClass: [self class]]; + exceptionWithClass: self.class]; _dictionary = [dictionary retain]; } @catch (id e) { [self release]; @throw e; @@ -58,8 +58,8 @@ return object; } - (size_t)count { - return [_dictionary count]; + return _dictionary.count; } @end Index: src/bridge/OFString+NSObject.m ================================================================== --- src/bridge/OFString+NSObject.m +++ src/bridge/OFString+NSObject.m @@ -24,14 +24,14 @@ int _OFString_NSObject_reference; @implementation OFString (NSObject) - (id)NSObject { - NSString *string = [NSString stringWithUTF8String: [self UTF8String]]; + NSString *string = [NSString stringWithUTF8String: self.UTF8String]; if (string == nil) @throw [OFInitializationFailedException exceptionWithClass: [NSString class]]; return string; } @end Index: src/exceptions/OFConditionBroadcastFailedException.m ================================================================== --- src/exceptions/OFConditionBroadcastFailedException.m +++ src/exceptions/OFConditionBroadcastFailedException.m @@ -53,10 +53,10 @@ - (OFString *)description { if (_condition != nil) return [OFString stringWithFormat: @"Broadcasting a condition of type %@ failed!", - [_condition class]]; + _condition.class]; else return @"Broadcasting a condition failed!"; } @end Index: src/exceptions/OFConditionSignalFailedException.m ================================================================== --- src/exceptions/OFConditionSignalFailedException.m +++ src/exceptions/OFConditionSignalFailedException.m @@ -53,10 +53,10 @@ - (OFString *)description { if (_condition != nil) return [OFString stringWithFormat: @"Signaling a condition of type %@ failed!", - [_condition class]]; + _condition.class]; else return @"Signaling a condition failed!"; } @end Index: src/exceptions/OFConditionStillWaitingException.m ================================================================== --- src/exceptions/OFConditionStillWaitingException.m +++ src/exceptions/OFConditionStillWaitingException.m @@ -54,11 +54,11 @@ { if (_condition != nil) return [OFString stringWithFormat: @"Deallocation of a condition of type %@ was tried, even " "though a thread was still waiting for it!", - [_condition class]]; + _condition.class]; else return @"Deallocation of a condition was tried, even though a " "thread was still waiting for it!"; } @end Index: src/exceptions/OFConditionWaitFailedException.m ================================================================== --- src/exceptions/OFConditionWaitFailedException.m +++ src/exceptions/OFConditionWaitFailedException.m @@ -53,10 +53,10 @@ - (OFString *)description { if (_condition != nil) return [OFString stringWithFormat: @"Waiting for a condition of type %@ failed!", - [_condition class]]; + _condition.class]; else return @"Waiting for a condition failed!"; } @end Index: src/exceptions/OFException.m ================================================================== --- src/exceptions/OFException.m +++ src/exceptions/OFException.m @@ -274,11 +274,11 @@ #endif - (OFString *)description { return [OFString stringWithFormat: - @"An exception of type %@ occurred!", [self class]]; + @"An exception of type %@ occurred!", self.class]; } - (OFArray OF_GENERIC(OFString *) *)backtrace { #ifdef HAVE__UNWIND_BACKTRACE Index: src/exceptions/OFGetOptionFailedException.m ================================================================== --- src/exceptions/OFGetOptionFailedException.m +++ src/exceptions/OFGetOptionFailedException.m @@ -61,8 +61,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Getting an option in a stream of type %@ failed: %@", - [_stream class], of_strerror(_errNo)]; + _stream.class, of_strerror(_errNo)]; } @end Index: src/exceptions/OFHTTPRequestFailedException.m ================================================================== --- src/exceptions/OFHTTPRequestFailedException.m +++ src/exceptions/OFHTTPRequestFailedException.m @@ -61,13 +61,12 @@ [super dealloc]; } - (OFString *)description { - const char *method = - of_http_request_method_to_string([_request method]); + const char *method = of_http_request_method_to_string(_request.method); return [OFString stringWithFormat: @"An HTTP %s request with URL %@ failed with code %d!", method, - [_request URL], [_response statusCode]]; + _request.URL, _response.statusCode]; } @end Index: src/exceptions/OFLockFailedException.m ================================================================== --- src/exceptions/OFLockFailedException.m +++ src/exceptions/OFLockFailedException.m @@ -51,10 +51,10 @@ - (OFString *)description { if (_lock != nil) return [OFString stringWithFormat: - @"A lock of type %@ could not be locked!", [_lock class]]; + @"A lock of type %@ could not be locked!", _lock.class]; else return @"A lock could not be locked!"; } @end Index: src/exceptions/OFMalformedXMLException.m ================================================================== --- src/exceptions/OFMalformedXMLException.m +++ src/exceptions/OFMalformedXMLException.m @@ -53,10 +53,10 @@ - (OFString *)description { if (_parser != nil) return [OFString stringWithFormat: @"An XML parser of type %@ encountered malformed XML in " - @"line %zu!", [_parser class], [_parser lineNumber]]; + @"line %zu!", _parser.class, _parser.lineNumber]; else return @"An XML parser encountered malformed XML!"; } @end Index: src/exceptions/OFObserveFailedException.m ================================================================== --- src/exceptions/OFObserveFailedException.m +++ src/exceptions/OFObserveFailedException.m @@ -66,8 +66,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"An observer of class %@ failed to observe: %@", - [_observer className], of_strerror(_errNo)]; + _observer.class, of_strerror(_errNo)]; } @end Index: src/exceptions/OFSeekFailedException.m ================================================================== --- src/exceptions/OFSeekFailedException.m +++ src/exceptions/OFSeekFailedException.m @@ -70,8 +70,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"Seeking failed in stream of type %@: %@", - [_stream class], of_strerror(_errNo)]; + _stream.class, of_strerror(_errNo)]; } @end Index: src/exceptions/OFStillLockedException.m ================================================================== --- src/exceptions/OFStillLockedException.m +++ src/exceptions/OFStillLockedException.m @@ -52,11 +52,11 @@ - (OFString *)description { if (_lock != nil) return [OFString stringWithFormat: @"Deallocation of a lock of type %@ even though it was " - @"still locked!", [_lock class]]; + @"still locked!", _lock.class]; else return @"Deallocation of a lock even though it was still " @"locked!"; } @end Index: src/exceptions/OFThreadJoinFailedException.m ================================================================== --- src/exceptions/OFThreadJoinFailedException.m +++ src/exceptions/OFThreadJoinFailedException.m @@ -54,11 +54,11 @@ { if (_thread != nil) return [OFString stringWithFormat: @"Joining a thread of type %@ failed! Most likely, another " @"thread already waits for the thread to join.", - [_thread class]]; + _thread.class]; else return @"Joining a thread failed! Most likely, another thread " @"already waits for the thread to join."; } @end Index: src/exceptions/OFThreadStartFailedException.m ================================================================== --- src/exceptions/OFThreadStartFailedException.m +++ src/exceptions/OFThreadStartFailedException.m @@ -52,10 +52,10 @@ - (OFString *)description { if (_thread != nil) return [OFString stringWithFormat: - @"Starting a thread of type %@ failed!", [_thread class]]; + @"Starting a thread of type %@ failed!", _thread.class]; else return @"Starting a thread failed!"; } @end Index: src/exceptions/OFThreadStillRunningException.m ================================================================== --- src/exceptions/OFThreadStillRunningException.m +++ src/exceptions/OFThreadStillRunningException.m @@ -54,11 +54,11 @@ { if (_thread) return [OFString stringWithFormat: @"Deallocation of a thread of type %@ was tried, even " @"though it was still running!", - [_thread class]]; + _thread.class]; else return @"Deallocation of a thread was tried, even though it " @"was still running!"; } @end Index: src/exceptions/OFUnboundNamespaceException.m ================================================================== --- src/exceptions/OFUnboundNamespaceException.m +++ src/exceptions/OFUnboundNamespaceException.m @@ -67,8 +67,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"The namespace %@ is not bound in an element of type %@!", - _namespace, [_element class]]; + _namespace, _element.class]; } @end Index: src/exceptions/OFUnboundPrefixException.m ================================================================== --- src/exceptions/OFUnboundPrefixException.m +++ src/exceptions/OFUnboundPrefixException.m @@ -67,8 +67,8 @@ - (OFString *)description { return [OFString stringWithFormat: @"An XML parser of type %@ encountered the unbound prefix %@ in " - @"line %zu!", [_parser class], _prefix, [_parser lineNumber]]; + @"line %zu!", _parser.class, _prefix, _parser.lineNumber]; } @end Index: src/exceptions/OFUnlockFailedException.m ================================================================== --- src/exceptions/OFUnlockFailedException.m +++ src/exceptions/OFUnlockFailedException.m @@ -51,10 +51,10 @@ - (OFString *)description { if (_lock != nil) return [OFString stringWithFormat: - @"A lock of type %@ could not be unlocked!", [_lock class]]; + @"A lock of type %@ could not be unlocked!", _lock.class]; else return @"A lock could not be unlocked!"; } @end Index: src/invocation/invoke-x86_64.m ================================================================== --- src/invocation/invoke-x86_64.m +++ src/invocation/invoke-x86_64.m @@ -191,12 +191,12 @@ #endif void of_invocation_invoke(OFInvocation *invocation) { - OFMethodSignature *methodSignature = [invocation methodSignature]; - size_t numberOfArguments = [methodSignature numberOfArguments]; + OFMethodSignature *methodSignature = invocation.methodSignature; + size_t numberOfArguments = methodSignature.numberOfArguments; struct call_context *context; const char *typeEncoding; uint_fast8_t currentGPR = 0, currentSSE = 0; if ((context = calloc(sizeof(*context), 1)) == NULL) @@ -308,11 +308,11 @@ free(context); @throw [OFInvalidFormatException exception]; } } - typeEncoding = [methodSignature methodReturnType]; + typeEncoding = methodSignature.methodReturnType; if (*typeEncoding == 'r') typeEncoding++; switch (*typeEncoding) { Index: src/of_asprintf.m ================================================================== --- src/of_asprintf.m +++ src/of_asprintf.m @@ -370,11 +370,11 @@ if ((object = va_arg(ctx->arguments, id)) != nil) { void *pool = objc_autoreleasePoolPush(); tmpLen = asprintf(&tmp, ctx->subformat, - [[object description] UTF8String]); + [object description].UTF8String); objc_autoreleasePoolPop(pool); } else tmpLen = asprintf(&tmp, ctx->subformat, "(nil)"); @@ -564,15 +564,15 @@ OFString *point = [OFLocale decimalPoint]; if (point != nil) [tmpStr replaceOccurrencesOfString: point withString: @"."]; - if ([tmpStr UTF8StringLength] > INT_MAX) + if (tmpStr.UTF8StringLength > INT_MAX) return false; - tmpLen = (int)[tmpStr UTF8StringLength]; + tmpLen = (int)tmpStr.UTF8StringLength; tmp2 = malloc(tmpLen); - memcpy(tmp2, [tmpStr UTF8String], tmpLen); + memcpy(tmp2, tmpStr.UTF8String, tmpLen); } @finally { free(tmp); objc_autoreleasePoolPop(pool); } Index: src/pbkdf2.m ================================================================== --- src/pbkdf2.m +++ src/pbkdf2.m @@ -32,15 +32,15 @@ const unsigned char *salt, size_t saltLength, const char *password, size_t passwordLength, unsigned char *key, size_t keyLength) { void *pool = objc_autoreleasePoolPush(); - size_t blocks, digestSize = [HMAC digestSize]; + size_t blocks, digestSize = HMAC.digestSize; OFSecureData *buffer = [OFSecureData dataWithCount: digestSize]; OFSecureData *digest = [OFSecureData dataWithCount: digestSize]; - unsigned char *bufferItems = [buffer items]; - unsigned char *digestItems = [digest items]; + unsigned char *bufferItems = buffer.mutableItems; + unsigned char *digestItems = digest.mutableItems; OFSecureData *extendedSalt; unsigned char *extendedSaltItems; if (HMAC == nil || iterations == 0 || salt == NULL || password == NULL || key == NULL || keyLength == 0) @@ -52,11 +52,11 @@ if (saltLength > SIZE_MAX - 4 || blocks > UINT32_MAX) @throw [OFOutOfRangeException exception]; extendedSalt = [OFSecureData dataWithCount: saltLength + 4]; - extendedSaltItems = [extendedSalt items]; + extendedSaltItems = extendedSalt.mutableItems; @try { uint32_t i = OF_BSWAP32_IF_LE(1); [HMAC setKey: password @@ -70,18 +70,18 @@ memcpy(extendedSaltItems + saltLength, &i, 4); [HMAC reset]; [HMAC updateWithBuffer: extendedSaltItems length: saltLength + 4]; - memcpy(bufferItems, [HMAC digest], digestSize); - memcpy(digestItems, [HMAC digest], digestSize); + memcpy(bufferItems, HMAC.digest, digestSize); + memcpy(digestItems, HMAC.digest, digestSize); for (size_t j = 1; j < iterations; j++) { [HMAC reset]; [HMAC updateWithBuffer: digestItems length: digestSize]; - memcpy(digestItems, [HMAC digest], digestSize); + memcpy(digestItems, HMAC.digest, digestSize); for (size_t k = 0; k < digestSize; k++) bufferItems[k] ^= digestItems[k]; } Index: src/socket.m ================================================================== --- src/socket.m +++ src/socket.m @@ -253,26 +253,26 @@ addrIn->sin_len = ret.length; #endif components = [IPv4 componentsSeparatedByString: @"."]; - if ([components count] != 4) + if (components.count != 4) @throw [OFInvalidFormatException exception]; addr = 0; for (OFString *component in components) { intmax_t number; - if ([component length] == 0) + if (component.length == 0) @throw [OFInvalidFormatException exception]; if ([component indexOfCharacterFromSet: whitespaceCharacterSet] != OF_NOT_FOUND) @throw [OFInvalidFormatException exception]; - number = [component decimalValue]; + number = component.decimalValue; if (number < 0 || number > UINT8_MAX) @throw [OFInvalidFormatException exception]; addr = (addr << 8) | (number & 0xFF); @@ -292,11 +292,11 @@ if ([component indexOfCharacterFromSet: [OFCharacterSet whitespaceCharacterSet]] != OF_NOT_FOUND) @throw [OFInvalidFormatException exception]; - number = [component hexadecimalValue]; + number = component.hexadecimalValue; if (number > UINT16_MAX) @throw [OFInvalidFormatException exception]; return (uint16_t)number; @@ -325,11 +325,11 @@ if (doubleColon != OF_NOT_FOUND) { OFString *left = [IPv6 substringWithRange: of_range(0, doubleColon)]; OFString *right = [IPv6 substringWithRange: - of_range(doubleColon + 2, [IPv6 length] - doubleColon - 2)]; + of_range(doubleColon + 2, IPv6.length - doubleColon - 2)]; OFArray OF_GENERIC(OFString *) *leftComponents; OFArray OF_GENERIC(OFString *) *rightComponents; size_t i; if ([right hasPrefix: @":"] || [right containsString: @"::"]) @@ -336,11 +336,11 @@ @throw [OFInvalidFormatException exception]; leftComponents = [left componentsSeparatedByString: @":"]; rightComponents = [right componentsSeparatedByString: @":"]; - if ([leftComponents count] + [rightComponents count] > 7) + if (leftComponents.count + rightComponents.count > 7) @throw [OFInvalidFormatException exception]; i = 0; for (OFString *component in leftComponents) { uint16_t number = parseIPv6Component(component); @@ -348,11 +348,11 @@ addrIn6->sin6_addr.s6_addr[i++] = number >> 8; addrIn6->sin6_addr.s6_addr[i++] = number; } i = 16; - for (OFString *component in [rightComponents reversedArray]) { + for (OFString *component in rightComponents.reversedArray) { uint16_t number = parseIPv6Component(component); addrIn6->sin6_addr.s6_addr[--i] = number >> 8; addrIn6->sin6_addr.s6_addr[--i] = number; } @@ -359,18 +359,18 @@ } else { OFArray OF_GENERIC(OFString *) *components = [IPv6 componentsSeparatedByString: @":"]; size_t i; - if ([components count] != 8) + if (components.count != 8) @throw [OFInvalidFormatException exception]; i = 0; for (OFString *component in components) { uint16_t number; - if ([component length] == 0) + if (component.length == 0) @throw [OFInvalidFormatException exception]; number = parseIPv6Component(component); addrIn6->sin6_addr.s6_addr[i++] = number >> 8; Index: src/threading_winapi.m ================================================================== --- src/threading_winapi.m +++ src/threading_winapi.m @@ -31,11 +31,11 @@ bool of_thread_new(of_thread_t *thread, void (*function)(id), id object, const of_thread_attr_t *attr) { *thread = CreateThread(NULL, (attr != NULL ? attr->stackSize : 0), - (LPTHREAD_START_ROUTINE)function, (__bridge void *)object, 0, NULL); + (LPTHREAD_START_ROUTINE)function, (void *)object, 0, NULL); if (thread == NULL) return false; if (attr != NULL && attr->priority != 0) { Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -514,16 +514,16 @@ [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } - (void)client: (OFHTTPClient *)client - didCreateSocket: (OF_KINDOF(OFTCPSocket *))sock + didCreateSocket: (OFTCPSocket *)sock request: (OFHTTPRequest *)request { if (_insecure && [sock respondsToSelector: @selector(setCertificateVerificationEnabled:)]) - [sock setCertificateVerificationEnabled: false]; + ((id )sock).certificateVerificationEnabled = false; } - (void)client: (OFHTTPClient *)client wantsRequestBody: (OFStream *)body request: (OFHTTPRequest *)request @@ -650,11 +650,11 @@ [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } -- (bool)stream: (OF_KINDOF(OFStream *))response +- (bool)stream: (OFStream *)response didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (id)exception { if (exception != nil) {