summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Schleifer <js@heap.zone>2019-03-08 01:35:48 +0100
committerJonathan Schleifer <js@heap.zone>2019-03-08 01:35:48 +0100
commita40b3a9901c347fc59857c2f40a04a90bf102473 (patch)
treee1ed37fe4e9d884c62956d41a1357a723ae20598
parente8ccc2241b7a0fe6ae5fee802605f2809f5c5e83 (diff)
Use dot syntax
-rw-r--r--src/OFASN1BitString.m8
-rw-r--r--src/OFASN1Boolean.m4
-rw-r--r--src/OFASN1Enumerated.m4
-rw-r--r--src/OFASN1IA5String.m10
-rw-r--r--src/OFASN1Integer.m4
-rw-r--r--src/OFASN1NumericString.m14
-rw-r--r--src/OFASN1ObjectIdentifier.m12
-rw-r--r--src/OFASN1OctetString.m4
-rw-r--r--src/OFASN1PrintableString.m14
-rw-r--r--src/OFASN1UTF8String.m10
-rw-r--r--src/OFASN1Value.m6
-rw-r--r--src/OFApplication.m30
-rw-r--r--src/OFArray.m52
-rw-r--r--src/OFArray_adjacent.m60
-rw-r--r--src/OFArray_adjacentSubarray.m10
-rw-r--r--src/OFCharacterSet_bitset.m4
-rw-r--r--src/OFCondition.m4
-rw-r--r--src/OFConstantString.m50
-rw-r--r--src/OFCountedSet.m4
-rw-r--r--src/OFCountedSet_hashtable.m16
-rw-r--r--src/OFDNSResolver.m120
-rw-r--r--src/OFDNSResourceRecord.m74
-rw-r--r--src/OFData+ASN1DERValue.m14
-rw-r--r--src/OFData+CryptoHashing.m2
-rw-r--r--src/OFData+MessagePackValue.m16
-rw-r--r--src/OFData.m32
-rw-r--r--src/OFDate.m32
-rw-r--r--src/OFDictionary.m54
-rw-r--r--src/OFDictionary_hashtable.m26
-rw-r--r--src/OFEnumerator.h2
-rw-r--r--src/OFFile.m8
-rw-r--r--src/OFFileManager.m28
-rw-r--r--src/OFGZIPStream.m12
-rw-r--r--src/OFHMAC.m14
-rw-r--r--src/OFHTTPClient.h2
-rw-r--r--src/OFHTTPClient.m161
-rw-r--r--src/OFHTTPCookie.m58
-rw-r--r--src/OFHTTPCookieManager.m38
-rw-r--r--src/OFHTTPRequest.m22
-rw-r--r--src/OFHTTPResponse.m28
-rw-r--r--src/OFHTTPServer.h2
-rw-r--r--src/OFHTTPServer.m124
-rw-r--r--src/OFINICategory.m40
-rw-r--r--src/OFINIFile.m10
-rw-r--r--src/OFInflate64Stream.h7
-rw-r--r--src/OFInflateStream.h7
-rw-r--r--src/OFInflateStream.m9
-rw-r--r--src/OFIntrospection.m26
-rw-r--r--src/OFInvocation.m12
-rw-r--r--src/OFKernelEventObserver.m20
-rw-r--r--src/OFKernelEventObserver_epoll.m14
-rw-r--r--src/OFKernelEventObserver_kqueue.m14
-rw-r--r--src/OFKernelEventObserver_poll.m20
-rw-r--r--src/OFKernelEventObserver_select.m18
-rw-r--r--src/OFLHAArchive.h8
-rw-r--r--src/OFLHAArchive.m80
-rw-r--r--src/OFLHAArchiveEntry.m72
-rw-r--r--src/OFLHAArchive_LHStream.h4
-rw-r--r--src/OFLHAArchive_LHStream.m11
-rw-r--r--src/OFList.m16
-rw-r--r--src/OFLocale.m21
-rw-r--r--src/OFMD5Hash.m4
-rw-r--r--src/OFMessagePackExtension.m10
-rw-r--r--src/OFMethodSignature.m6
-rw-r--r--src/OFMutableArray.m22
-rw-r--r--src/OFMutableArray_adjacent.m59
-rw-r--r--src/OFMutableData.h69
-rw-r--r--src/OFMutableData.m13
-rw-r--r--src/OFMutableDictionary.m2
-rw-r--r--src/OFMutableSet.m2
-rw-r--r--src/OFMutableString.m40
-rw-r--r--src/OFMutableString_UTF8.m52
-rw-r--r--src/OFMutableURL.m24
-rw-r--r--src/OFMutableZIPArchiveEntry.m18
-rw-r--r--src/OFMutex.m7
-rw-r--r--src/OFNull.m6
-rw-r--r--src/OFNumber.m74
-rw-r--r--src/OFObject+KeyValueCoding.m20
-rw-r--r--src/OFObject+Serialization.m2
-rw-r--r--src/OFObject.m72
-rw-r--r--src/OFOptionsParser.m18
-rw-r--r--src/OFPlugin.m6
-rw-r--r--src/OFProcess.m48
-rw-r--r--src/OFRIPEMD160Hash.m4
-rw-r--r--src/OFRecursiveMutex.m7
-rw-r--r--src/OFRunLoop+Private.h2
-rw-r--r--src/OFRunLoop.m58
-rw-r--r--src/OFSHA1Hash.m4
-rw-r--r--src/OFSHA224Or256Hash.m6
-rw-r--r--src/OFSHA384Or512Hash.m6
-rw-r--r--src/OFSecureData.h65
-rw-r--r--src/OFSecureData.m13
-rw-r--r--src/OFSet.m12
-rw-r--r--src/OFSet_hashtable.m10
-rw-r--r--src/OFSettings_INIFile.m2
-rw-r--r--src/OFStdIOStream.m4
-rw-r--r--src/OFStdIOStream_Win32Console.m8
-rw-r--r--src/OFStream.h22
-rw-r--r--src/OFStream.m31
-rw-r--r--src/OFString+CryptoHashing.m6
-rw-r--r--src/OFString+JSONValue.m10
-rw-r--r--src/OFString+PathAdditions_AmigaOS.m40
-rw-r--r--src/OFString+PathAdditions_DOS.m36
-rw-r--r--src/OFString+PathAdditions_UNIX.m34
-rw-r--r--src/OFString+PathAdditions_libfat.m36
-rw-r--r--src/OFString+PropertyListValue.m44
-rw-r--r--src/OFString+Serialization.m8
-rw-r--r--src/OFString+URLEncoding.m8
-rw-r--r--src/OFString+XMLEscaping.m4
-rw-r--r--src/OFString+XMLUnescaping.m4
-rw-r--r--src/OFString.m180
-rw-r--r--src/OFString_UTF8.m56
-rw-r--r--src/OFSystemInfo.m15
-rw-r--r--src/OFTCPSocket.h15
-rw-r--r--src/OFTCPSocket.m54
-rw-r--r--src/OFTarArchive.h8
-rw-r--r--src/OFTarArchive.m69
-rw-r--r--src/OFTarArchiveEntry.m15
-rw-r--r--src/OFThread.m14
-rw-r--r--src/OFThreadPool.m4
-rw-r--r--src/OFTimer.m6
-rw-r--r--src/OFUDPSocket.h4
-rw-r--r--src/OFURL.m108
-rw-r--r--src/OFURLHandler.m2
-rw-r--r--src/OFURLHandler_file.m85
-rw-r--r--src/OFValue.m6
-rw-r--r--src/OFWindowsRegistryKey.m30
-rw-r--r--src/OFXMLAttribute.m23
-rw-r--r--src/OFXMLCDATA.m16
-rw-r--r--src/OFXMLCharacters.m18
-rw-r--r--src/OFXMLComment.m10
-rw-r--r--src/OFXMLElement.m167
-rw-r--r--src/OFXMLElementBuilder.m26
-rw-r--r--src/OFXMLNode.m8
-rw-r--r--src/OFXMLParser.m70
-rw-r--r--src/OFXMLProcessingInstructions.m10
-rw-r--r--src/OFZIPArchive.h6
-rw-r--r--src/OFZIPArchive.m114
-rw-r--r--src/OFZIPArchiveEntry.m26
-rw-r--r--src/base64.m2
-rw-r--r--src/bridge/NSArray_OFArray.m2
-rw-r--r--src/bridge/NSBridging.h2
-rw-r--r--src/bridge/NSDictionary_OFDictionary.m2
-rw-r--r--src/bridge/NSString+OFObject.m2
-rw-r--r--src/bridge/OFArray_NSArray.m4
-rw-r--r--src/bridge/OFBridging.h2
-rw-r--r--src/bridge/OFDictionary_NSDictionary.m4
-rw-r--r--src/bridge/OFString+NSObject.m2
-rw-r--r--src/exceptions/OFConditionBroadcastFailedException.m2
-rw-r--r--src/exceptions/OFConditionSignalFailedException.m2
-rw-r--r--src/exceptions/OFConditionStillWaitingException.m2
-rw-r--r--src/exceptions/OFConditionWaitFailedException.m2
-rw-r--r--src/exceptions/OFException.m2
-rw-r--r--src/exceptions/OFGetOptionFailedException.m2
-rw-r--r--src/exceptions/OFHTTPRequestFailedException.m5
-rw-r--r--src/exceptions/OFLockFailedException.m2
-rw-r--r--src/exceptions/OFMalformedXMLException.m2
-rw-r--r--src/exceptions/OFObserveFailedException.m2
-rw-r--r--src/exceptions/OFSeekFailedException.m2
-rw-r--r--src/exceptions/OFStillLockedException.m2
-rw-r--r--src/exceptions/OFThreadJoinFailedException.m2
-rw-r--r--src/exceptions/OFThreadStartFailedException.m2
-rw-r--r--src/exceptions/OFThreadStillRunningException.m2
-rw-r--r--src/exceptions/OFUnboundNamespaceException.m2
-rw-r--r--src/exceptions/OFUnboundPrefixException.m2
-rw-r--r--src/exceptions/OFUnlockFailedException.m2
-rw-r--r--src/invocation/invoke-x86_64.m6
-rw-r--r--src/of_asprintf.m8
-rw-r--r--src/pbkdf2.m14
-rw-r--r--src/socket.m18
-rw-r--r--src/threading_winapi.m2
-rw-r--r--utils/ofhttp/OFHTTP.m6
172 files changed, 1947 insertions, 1989 deletions
diff --git a/src/OFASN1BitString.m b/src/OFASN1BitString.m
index 13df7c7e..acefdbb9 100644
--- a/src/OFASN1BitString.m
+++ b/src/OFASN1BitString.m
@@ -43,7 +43,7 @@
self = [super init];
@try {
- if ([bitStringValue count] * [bitStringValue itemSize] !=
+ if (bitStringValue.count * bitStringValue.itemSize !=
bitStringLength / 8)
@throw [OFInvalidFormatException exception];
@@ -68,13 +68,13 @@
@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 =
@@ -134,7 +134,7 @@
- (uint32_t)hash
{
- return [_bitStringValue hash] + (uint32_t)_bitStringLength;
+ return _bitStringValue.hash + (uint32_t)_bitStringLength;
}
- (OFString *)description
diff --git a/src/OFASN1Boolean.m b/src/OFASN1Boolean.m
index 2fef5ec4..f53e754b 100644
--- a/src/OFASN1Boolean.m
+++ b/src/OFASN1Boolean.m
@@ -53,8 +53,8 @@
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];
diff --git a/src/OFASN1Enumerated.m b/src/OFASN1Enumerated.m
index 1b9427ac..91447740 100644
--- a/src/OFASN1Enumerated.m
+++ b/src/OFASN1Enumerated.m
@@ -55,11 +55,11 @@ extern intmax_t of_asn1_der_integer_parse(const unsigned char *buffer,
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;
diff --git a/src/OFASN1IA5String.m b/src/OFASN1IA5String.m
index 876f9534..e66af36f 100644
--- a/src/OFASN1IA5String.m
+++ b/src/OFASN1IA5String.m
@@ -58,13 +58,13 @@
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;
@@ -91,7 +91,7 @@
- (OFString *)stringValue
{
- return [self IA5StringValue];
+ return self.IA5StringValue;
}
- (bool)isEqual: (id)object
@@ -111,7 +111,7 @@
- (uint32_t)hash
{
- return [_IA5StringValue hash];
+ return _IA5StringValue.hash;
}
- (OFString *)description
diff --git a/src/OFASN1Integer.m b/src/OFASN1Integer.m
index 6846faeb..89877370 100644
--- a/src/OFASN1Integer.m
+++ b/src/OFASN1Integer.m
@@ -77,11 +77,11 @@ of_asn1_der_integer_parse(const unsigned char *buffer, size_t length)
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;
diff --git a/src/OFASN1NumericString.m b/src/OFASN1NumericString.m
index d0d3bf3c..14141664 100644
--- a/src/OFASN1NumericString.m
+++ b/src/OFASN1NumericString.m
@@ -38,8 +38,8 @@
@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] != ' ')
@@ -70,13 +70,13 @@
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;
@@ -103,7 +103,7 @@
- (OFString *)stringValue
{
- return [self numericStringValue];
+ return self.numericStringValue;
}
- (bool)isEqual: (id)object
@@ -123,7 +123,7 @@
- (uint32_t)hash
{
- return [_numericStringValue hash];
+ return _numericStringValue.hash;
}
- (OFString *)description
diff --git a/src/OFASN1ObjectIdentifier.m b/src/OFASN1ObjectIdentifier.m
index 54f92c65..f354b571 100644
--- a/src/OFASN1ObjectIdentifier.m
+++ b/src/OFASN1ObjectIdentifier.m
@@ -43,7 +43,7 @@
self = [super init];
@try {
- if ([subidentifiers count] < 1)
+ if (subidentifiers.count < 1)
@throw [OFInvalidFormatException exception];
switch ([[subidentifiers objectAtIndex: 0] intMaxValue]) {
@@ -73,8 +73,8 @@
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;
@@ -83,7 +83,7 @@
constructed)
@throw [OFInvalidArgumentException exception];
- if ([DEREncodedContents itemSize] != 1 || count == 0)
+ if (DEREncodedContents.itemSize != 1 || count == 0)
@throw [OFInvalidArgumentException exception];
subidentifiers = [OFMutableArray array];
@@ -101,7 +101,7 @@
if (items[i] & 0x80)
continue;
- if ([subidentifiers count] == 0) {
+ if (subidentifiers.count == 0) {
if (value < 40)
[subidentifiers addObject:
[OFNumber numberWithUIntMax: 0]];
@@ -168,7 +168,7 @@
- (uint32_t)hash
{
- return [_subidentifiers hash];
+ return _subidentifiers.hash;
}
- (OFString *)description
diff --git a/src/OFASN1OctetString.m b/src/OFASN1OctetString.m
index c97a2d25..7d73ae95 100644
--- a/src/OFASN1OctetString.m
+++ b/src/OFASN1OctetString.m
@@ -57,7 +57,7 @@
constructed)
@throw [OFInvalidArgumentException exception];
- if ([DEREncodedContents itemSize] != 1)
+ if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidArgumentException exception];
} @catch (id e) {
[self release];
@@ -96,7 +96,7 @@
- (uint32_t)hash
{
- return [_octetStringValue hash];
+ return _octetStringValue.hash;
}
- (OFString *)description
diff --git a/src/OFASN1PrintableString.m b/src/OFASN1PrintableString.m
index 0ad47671..31b3966f 100644
--- a/src/OFASN1PrintableString.m
+++ b/src/OFASN1PrintableString.m
@@ -38,8 +38,8 @@
@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]))
@@ -89,13 +89,13 @@
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;
@@ -122,7 +122,7 @@
- (OFString *)stringValue
{
- return [self printableStringValue];
+ return self.printableStringValue;
}
- (bool)isEqual: (id)object
@@ -143,7 +143,7 @@
- (uint32_t)hash
{
- return [_printableStringValue hash];
+ return _printableStringValue.hash;
}
- (OFString *)description
diff --git a/src/OFASN1UTF8String.m b/src/OFASN1UTF8String.m
index 931a9fea..7081ed8b 100644
--- a/src/OFASN1UTF8String.m
+++ b/src/OFASN1UTF8String.m
@@ -58,12 +58,12 @@
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;
@@ -90,7 +90,7 @@
- (OFString *)stringValue
{
- return [self UTF8StringValue];
+ return self.UTF8StringValue;
}
- (bool)isEqual: (id)object
@@ -110,7 +110,7 @@
- (uint32_t)hash
{
- return [_UTF8StringValue hash];
+ return _UTF8StringValue.hash;
}
- (OFString *)description
diff --git a/src/OFASN1Value.m b/src/OFASN1Value.m
index 6ce54dc5..ef276f7c 100644
--- a/src/OFASN1Value.m
+++ b/src/OFASN1Value.m
@@ -48,7 +48,7 @@
self = [super init];
@try {
- if ([DEREncodedContents itemSize] != 1)
+ if (DEREncodedContents.itemSize != 1)
@throw [OFInvalidFormatException exception];
_tagClass = tagClass;
@@ -105,7 +105,7 @@
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);
@@ -122,6 +122,6 @@
@"\tDER-encoded contents = %@\n"
@">",
_tagClass, _tagNumber, _constructed,
- [_DEREncodedContents description]];
+ _DEREncodedContents.description];
}
@end
diff --git a/src/OFApplication.m b/src/OFApplication.m
index 4f93f708..e981d4fa 100644
--- a/src/OFApplication.m
+++ b/src/OFApplication.m
@@ -98,7 +98,7 @@ static OFApplication *app = nil;
static void
atexitHandler(void)
{
- id <OFApplicationDelegate> delegate = [app delegate];
+ id <OFApplicationDelegate> delegate = app.delegate;
if ([delegate respondsToSelector: @selector(applicationWillTerminate)])
[delegate applicationWillTerminate];
@@ -147,7 +147,7 @@ of_application_main(int *argc, char **argv[],
andWideArgumentValues: wargv];
#endif
- [app setDelegate: delegate];
+ app.delegate = delegate;
[app of_run];
@@ -171,17 +171,17 @@ of_application_main(int *argc, char **argv[],
+ (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
@@ -263,7 +263,7 @@ of_application_main(int *argc, char **argv[],
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];
@@ -577,14 +577,14 @@ of_application_main(int *argc, char **argv[],
- (void)terminate
{
- [[self class] terminate];
+ [self.class terminate];
OF_UNREACHABLE
}
- (void)terminateWithStatus: (int)status
{
- [[self class] terminateWithStatus: status];
+ [self.class terminateWithStatus: status];
OF_UNREACHABLE
}
@@ -602,15 +602,15 @@ of_application_main(int *argc, char **argv[],
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];
@@ -621,7 +621,7 @@ of_application_main(int *argc, char **argv[],
sandbox->_unveiledPathsIndex = unveiledPathsCount;
- promises = [[sandbox pledgeString] cStringWithEncoding: encoding];
+ promises = [sandbox.pledgeString cStringWithEncoding: encoding];
if (pledge(promises, NULL) != 0)
@throw [OFSandboxActivationFailedException
@@ -644,10 +644,10 @@ of_application_main(int *argc, char **argv[],
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)
diff --git a/src/OFArray.m b/src/OFArray.m
index b45fb39f..fd3d6e70 100644
--- a/src/OFArray.m
+++ b/src/OFArray.m
@@ -244,9 +244,9 @@ static struct {
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)];
@@ -281,7 +281,7 @@ static struct {
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);
@@ -289,7 +289,7 @@ static struct {
return [ret autorelease];
}
- ret = [OFMutableArray arrayWithCapacity: [self count]];
+ ret = [OFMutableArray arrayWithCapacity: self.count];
for (id object in self) {
id value = [object valueForKey: key];
@@ -311,7 +311,7 @@ static struct {
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];
@@ -370,7 +370,7 @@ static struct {
- (id)firstObject
{
- if ([self count] > 0)
+ if (self.count > 0)
return [self objectAtIndex: 0];
return nil;
@@ -378,7 +378,7 @@ static struct {
- (id)lastObject
{
- size_t count = [self count];
+ size_t count = self.count;
if (count > 0)
return [self objectAtIndex: count - 1];
@@ -392,7 +392,7 @@ static struct {
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]])
@@ -447,10 +447,10 @@ static struct {
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];
@@ -471,8 +471,8 @@ static struct {
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];
}
@@ -520,9 +520,9 @@ static struct {
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++)
@@ -552,7 +552,7 @@ static struct {
void *pool;
OFMutableString *ret;
- if ([self count] == 0)
+ if (self.count == 0)
return @"()";
pool = objc_autoreleasePoolPush();
@@ -587,10 +587,10 @@ static struct {
element = [OFXMLElement elementWithName: @"OFArray"
namespace: OF_SERIALIZATION_NS];
- for (id object in self) {
+ for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
- [element addChild: [object XMLElementBySerializing]];
+ [element addChild: object.XMLElementBySerializing];
objc_autoreleasePoolPop(pool2);
}
@@ -619,7 +619,7 @@ static struct {
{
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];
@@ -679,7 +679,7 @@ static struct {
void *pool;
data = [OFMutableData data];
- count = [self count];
+ count = self.count;
if (count <= 15) {
uint8_t tmp = 0x90 | ((uint8_t)count & 0xF);
@@ -711,8 +711,8 @@ static struct {
i++;
child = [object messagePackRepresentation];
- [data addItems: [child items]
- count: [child count]];
+ [data addItems: child.items
+ count: child.count];
objc_autoreleasePoolPop(pool2);
}
@@ -799,8 +799,8 @@ static struct {
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];
@@ -875,7 +875,7 @@ static struct {
- (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];
@@ -897,7 +897,7 @@ static struct {
- (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];
@@ -921,7 +921,7 @@ static struct {
- (id)foldUsingBlock: (of_array_fold_block_t)block
{
- size_t count = [self count];
+ size_t count = self.count;
__block id current;
if (count == 0)
diff --git a/src/OFArray_adjacent.m b/src/OFArray_adjacent.m
index 5ebc2a68..23b77af6 100644
--- a/src/OFArray_adjacent.m
+++ b/src/OFArray_adjacent.m
@@ -97,8 +97,8 @@
return self;
@try {
- objects = [array objects];
- count = [array count];
+ objects = array.objects;
+ count = array.count;
_array = [[OFMutableData alloc] initWithItemSize: sizeof(id)
capacity: count];
@@ -166,9 +166,9 @@
@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
@@ -176,7 +176,7 @@
void *pool2 = objc_autoreleasePoolPush();
id object;
- object = [child objectByDeserializing];
+ object = child.objectByDeserializing;
[_array addItem: &object];
[object retain];
@@ -194,12 +194,12 @@
- (size_t)count
{
- return [_array count];
+ return _array.count;
}
- (id const *)objects
{
- return [_array items];
+ return _array.items;
}
- (id)objectAtIndex: (size_t)idx
@@ -215,8 +215,8 @@
- (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)
@@ -228,14 +228,14 @@
- (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])
@@ -246,14 +246,14 @@
- (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)
@@ -266,12 +266,12 @@
- (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
@@ -293,13 +293,13 @@
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]])
@@ -310,8 +310,8 @@
- (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);
@@ -328,7 +328,7 @@
objects: (id *)objects
count: (int)count_
{
- size_t count = [_array count];
+ size_t count = _array.count;
if (count > INT_MAX)
/*
@@ -343,7 +343,7 @@
return 0;
state->state = (unsigned long)count;
- state->itemsPtr = [_array items];
+ state->itemsPtr = _array.items;
state->mutationsPtr = (unsigned long *)self;
return (int)count;
@@ -352,8 +352,8 @@
#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++)
@@ -363,8 +363,8 @@
- (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];
diff --git a/src/OFArray_adjacentSubarray.m b/src/OFArray_adjacentSubarray.m
index f4da55a1..fe816ffb 100644
--- a/src/OFArray_adjacentSubarray.m
+++ b/src/OFArray_adjacentSubarray.m
@@ -24,7 +24,7 @@
@implementation OFArray_adjacentSubarray
- (const id *)objects
{
- return [_array objects] + _range.location;
+ return _array.objects + _range.location;
}
- (bool)isEqual: (id)object
@@ -41,11 +41,11 @@
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]])
@@ -57,7 +57,7 @@
#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++)
diff --git a/src/OFCharacterSet_bitset.m b/src/OFCharacterSet_bitset.m
index 4ae2173a..bdd22bfc 100644
--- a/src/OFCharacterSet_bitset.m
+++ b/src/OFCharacterSet_bitset.m
@@ -34,8 +34,8 @@
@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];
diff --git a/src/OFCondition.m b/src/OFCondition.m
index 3c81c005..5ed7f70e 100644
--- a/src/OFCondition.m
+++ b/src/OFCondition.m
@@ -37,7 +37,7 @@
self = [super init];
if (!of_condition_new(&_condition)) {
- Class c = [self class];
+ Class c = self.class;
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
@@ -72,7 +72,7 @@
- (bool)waitUntilDate: (OFDate *)date
{
return of_condition_timed_wait(&_condition, &_mutex,
- [date timeIntervalSinceNow]);
+ date.timeIntervalSinceNow);
}
- (void)signal
diff --git a/src/OFConstantString.m b/src/OFConstantString.m
index 298b393f..9b9a6b6a 100644
--- a/src/OFConstantString.m
+++ b/src/OFConstantString.m
@@ -264,14 +264,14 @@ struct {
{
[self finishInitialization];
- return [self hash];
+ return self.hash;
}
- (OFString *)description
{
[self finishInitialization];
- return [self description];
+ return self.description;
}
/* From OFString */
@@ -279,7 +279,7 @@ struct {
{
[self finishInitialization];
- return [self UTF8String];
+ return self.UTF8String;
}
- (size_t)getCString: (char *)cString_
@@ -304,14 +304,14 @@ struct {
{
[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
@@ -468,42 +468,42 @@ struct {
{
[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
@@ -558,70 +558,70 @@ struct {
{
[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
@@ -635,14 +635,14 @@ struct {
{
[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
@@ -664,14 +664,14 @@ struct {
{
[self finishInitialization];
- return [self decomposedStringWithCanonicalMapping];
+ return self.decomposedStringWithCanonicalMapping;
}
- (OFString *)decomposedStringWithCompatibilityMapping
{
[self finishInitialization];
- return [self decomposedStringWithCompatibilityMapping];
+ return self.decomposedStringWithCompatibilityMapping;
}
#endif
diff --git a/src/OFCountedSet.m b/src/OFCountedSet.m
index 06723c58..feec1b2b 100644
--- a/src/OFCountedSet.m
+++ b/src/OFCountedSet.m
@@ -141,7 +141,7 @@ static struct {
{
OFMutableString *ret;
void *pool;
- size_t i, count = [self count];
+ size_t i, count = self.count;
if (count == 0)
return @"{()}";
@@ -206,7 +206,7 @@ static struct {
namespace: OF_SERIALIZATION_NS];
[objectElement addAttributeWithName: @"count"
stringValue: count];
- [objectElement addChild: [object XMLElementBySerializing]];
+ [objectElement addChild: object.XMLElementBySerializing];
[element addChild: objectElement];
objc_autoreleasePoolPop(pool2);
diff --git a/src/OFCountedSet_hashtable.m b/src/OFCountedSet_hashtable.m
index 94922af8..a7c7849c 100644
--- a/src/OFCountedSet_hashtable.m
+++ b/src/OFCountedSet_hashtable.m
@@ -72,8 +72,8 @@
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]];
@@ -128,8 +128,8 @@
@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
@@ -141,8 +141,8 @@
intmax_t signedCount;
uintmax_t count;
- object = [[objectElement elementsForNamespace:
- OF_SERIALIZATION_NS] firstObject];
+ object = [objectElement elementsForNamespace:
+ OF_SERIALIZATION_NS].firstObject;
countAttribute =
[objectElement attributeForName: @"count"];
@@ -150,7 +150,7 @@
@throw [OFInvalidFormatException exception];
signedCount =
- [[countAttribute stringValue] decimalValue];
+ countAttribute.stringValue.decimalValue;
if (signedCount < 0)
@throw [OFOutOfRangeException exception];
@@ -159,7 +159,7 @@
@throw [OFOutOfRangeException exception];
[_mapTable setObject: (void *)(uintptr_t)count
- forKey: [object objectByDeserializing]];
+ forKey: object.objectByDeserializing];
objc_autoreleasePoolPop(pool2);
}
diff --git a/src/OFDNSResolver.m b/src/OFDNSResolver.m
index e5c6d72e..7ecc5dcf 100644
--- a/src/OFDNSResolver.m
+++ b/src/OFDNSResolver.m
@@ -199,7 +199,7 @@ static of_run_loop_mode_t resolveRunLoopMode = @"of_dns_resolver_resolve_mode";
answerRecords: (OFDictionary *)answerRecords
authorityRecords: (OFDictionary *)authorityRecords
additionalRecords: (OFDictionary *)additionalRecords
- context: (id)context
+ context: (OFNumber *)context
exception: (id)exception;
- (void)done;
- (void)resolver: (OFDNSResolver *)resolver
@@ -207,7 +207,7 @@ static of_run_loop_mode_t resolveRunLoopMode = @"of_dns_resolver_resolve_mode";
answerRecords: (OFDictionary *)answerRecords
authorityRecords: (OFDictionary *)authorityRecords
additionalRecords: (OFDictionary *)additionalRecords
- context: (id)context
+ context: (OFNumber *)context
exception: (id)exception;
@end
@@ -292,7 +292,7 @@ domainFromHostname(void)
return nil;
return [domain substringWithRange:
- of_range(pos + 1, [domain length] - pos - 1)];
+ of_range(pos + 1, domain.length - pos - 1)];
}
}
#endif
@@ -300,8 +300,8 @@ domainFromHostname(void)
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: @"."])
@@ -371,7 +371,7 @@ parseName(const unsigned char *buffer, size_t length, size_t *i,
suffix = parseName(buffer, length, &j,
pointerLevel - 1);
- if ([components count] == 0)
+ if (components.count == 0)
return suffix;
else {
[components addObject: suffix];
@@ -761,7 +761,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
/* Header */
- tmp = OF_BSWAP16_IF_LE([ID uInt16Value]);
+ tmp = OF_BSWAP16_IF_LE(ID.uInt16Value);
[queryData addItems: &tmp
count: 2];
@@ -783,15 +783,15 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
/* 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];
}
@@ -872,16 +872,16 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
{
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
@@ -901,7 +901,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
recursion: (unsigned int)recursion
result: (OFMutableArray *)result
{
- OFString *alias = [CNAME alias];
+ OFString *alias = CNAME.alias;
bool found = false;
if (recursion == 0)
@@ -925,7 +925,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
if (!found) {
of_run_loop_mode_t runLoopMode =
- [[OFRunLoop currentRunLoop] currentMode];
+ [OFRunLoop currentRunLoop].currentMode;
OFNumber *recordTypeNumber =
[OFNumber numberWithInt: recordType];
@@ -955,7 +955,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
answerRecords: (OFDictionary *)answerRecords
authorityRecords: (OFDictionary *)authorityRecords
additionalRecords: (OFDictionary *)additionalRecords
- context: (id)context
+ context: (OFNumber *)context
exception: (id)exception
{
/*
@@ -963,7 +963,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
* 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;
@@ -1004,7 +1004,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
return;
}
- count = [_records count];
+ count = _records.count;
for (size_t i = 0; i < count; i++) {
id object = [_records objectAtIndex: i];
@@ -1020,7 +1020,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
[_records removeObjectAtIndex: i];
[_records insertObjectsFromArray: records
atIndex: i];
- i += [records count] - 1;
+ i += records.count - 1;
}
if (_expectedResponses == 0)
@@ -1049,7 +1049,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
[addresses makeImmutable];
- if ([addresses count] == 0)
+ if (addresses.count == 0)
exception = [OFResolveHostFailedException
exceptionWithHost: _host
recordClass: OF_DNS_RESOURCE_RECORD_CLASS_IN
@@ -1069,7 +1069,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
answerRecords: (OFDictionary *)answerRecords
authorityRecords: (OFDictionary *)authorityRecords
additionalRecords: (OFDictionary *)additionalRecords
- context: (id)context
+ context: (OFNumber *)context
exception: (id)exception
{
/*
@@ -1077,7 +1077,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
* 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);
@@ -1317,14 +1317,14 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
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];
@@ -1390,30 +1390,30 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
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];
@@ -1437,25 +1437,25 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
@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) {
@@ -1488,7 +1488,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
[OFString stringWithCString: iter->IpAddress.String
encoding: encoding]];
- if ([nameServers count] > 0) {
+ if (nameServers.count > 0) {
[nameServers makeImmutable];
_nameServers = [nameServers copy];
}
@@ -1532,7 +1532,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
ReleaseDomainNameServerList(nameServerList);
}
- if ([nameServers count] > 0) {
+ if (nameServers.count > 0) {
[nameServers makeImmutable];
_nameServers = [nameServers copy];
}
@@ -1579,7 +1579,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
(ip >> 8) & 0xFF, ip & 0xFF]];
}
- if ([nameServers count] > 0) {
+ if (nameServers.count > 0) {
[nameServers makeImmutable];
_nameServers = [nameServers copy];
}
@@ -1594,7 +1594,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
*/
if (_lastConfigReload != nil && _configReloadInterval > 0 &&
- [_lastConfigReload timeIntervalSinceNow] < _configReloadInterval)
+ _lastConfigReload.timeIntervalSinceNow < _configReloadInterval)
return;
[_staticHosts release];
@@ -1653,7 +1653,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
host, searchDomain];
}
- if ([domainName UTF8StringLength] > 253)
+ if (domainName.UTF8StringLength > 253)
@throw [OFOutOfRangeException exception];
query = [[[OFDNSResolverQuery alloc]
@@ -1808,8 +1808,8 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
_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];
}
@@ -1825,8 +1825,8 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
_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];
}
@@ -1850,10 +1850,10 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
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;
}
@@ -1861,7 +1861,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
query->_attempt++;
query->_nameServersIndex = 0;
[self of_sendQuery: query
- runLoopMode: [[OFRunLoop currentRunLoop] currentMode]];
+ runLoopMode: [OFRunLoop currentRunLoop].currentMode];
return;
}
@@ -1891,7 +1891,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
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
@@ -1934,11 +1934,11 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
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)
@@ -1964,9 +1964,9 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
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++;
@@ -2129,7 +2129,7 @@ static void callback(id target, SEL selector, OFDNSResolver *resolver,
[addresses makeImmutable];
- if ([addresses count] == 0) {
+ if (addresses.count == 0) {
of_dns_resource_record_type_t recordType = 0;
addresses = nil;
diff --git a/src/OFDNSResourceRecord.m b/src/OFDNSResourceRecord.m
index d3e15638..6be51501 100644
--- a/src/OFDNSResourceRecord.m
+++ b/src/OFDNSResourceRecord.m
@@ -76,7 +76,7 @@ of_dns_resource_record_class_t of_dns_resource_record_class_parse(
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;
@@ -94,7 +94,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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;
@@ -171,7 +171,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\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];
}
@@ -235,7 +235,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -255,7 +255,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tAddress = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_socket_address_ip_string(&_address, NULL), _TTL];
}
@end
@@ -318,7 +318,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -338,7 +338,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tAddress = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_socket_address_ip_string(&_address, NULL), _TTL];
}
@end
@@ -412,12 +412,12 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -433,7 +433,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tAlias = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_dns_resource_record_class_to_string(_recordClass), _alias, _TTL];
}
@end
@@ -512,13 +512,13 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -535,7 +535,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tOS = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_dns_resource_record_class_to_string(_recordClass), _CPU, _OS,
_TTL];
}
@@ -615,14 +615,14 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -639,7 +639,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tMail Exchange = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_dns_resource_record_class_to_string(_recordClass), _preference,
_mailExchange, _TTL];
}
@@ -714,12 +714,12 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -735,7 +735,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tAuthoritative Host = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_dns_resource_record_class_to_string(_recordClass),
_authoritativeHost, _TTL];
}
@@ -810,12 +810,12 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -831,7 +831,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tDomain Name = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_dns_resource_record_class_to_string(_recordClass), _domainName,
_TTL];
}
@@ -913,13 +913,13 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -936,7 +936,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tTXT Domain Name = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_dns_resource_record_class_to_string(_recordClass), _mailbox,
_TXTDomainName, _TTL];
}
@@ -1047,13 +1047,13 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -1095,7 +1095,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\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,
@@ -1187,7 +1187,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -1196,7 +1196,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -1216,7 +1216,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tPort = %" PRIu16 "\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name, _priority, _weight, _target, _port, _TTL];
+ self.className, _name, _priority, _weight, _target, _port, _TTL];
}
@end
@@ -1289,12 +1289,12 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
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);
@@ -1310,7 +1310,7 @@ of_dns_resource_record_type_t of_dns_resource_record_type_parse(
@"\tText Data = %@\n"
@"\tTTL = %" PRIu32 "\n"
@">",
- [self className], _name,
+ self.className, _name,
of_dns_resource_record_class_to_string(_recordClass), _textData,
_TTL];
}
diff --git a/src/OFData+ASN1DERValue.m b/src/OFData+ASN1DERValue.m
index d85f7335..6daa7b1e 100644
--- a/src/OFData+ASN1DERValue.m
+++ b/src/OFData+ASN1DERValue.m
@@ -50,7 +50,7 @@ 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];
@@ -77,7 +77,7 @@ 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)
@@ -114,8 +114,8 @@ parseSet(OFData *contents, size_t depthLimit)
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;
@@ -177,7 +177,7 @@ parseObject(OFData *self, id *object, size_t depthLimit)
if (tag & ASN1_TAG_CONSTRUCTED_MASK)
@throw [OFInvalidFormatException exception];
- if ([contents count] != 0)
+ if (contents.count != 0)
@throw [OFInvalidFormatException exception];
*object = [OFNull null];
@@ -236,10 +236,10 @@ parseObject(OFData *self, id *object, 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];
diff --git a/src/OFData+CryptoHashing.m b/src/OFData+CryptoHashing.m
index 6a0b2076..4c224951 100644
--- a/src/OFData+CryptoHashing.m
+++ b/src/OFData+CryptoHashing.m
@@ -41,7 +41,7 @@ int _OFData_CryptoHashing_reference;
[hash updateWithBuffer: _items
length: _count * _itemSize];
- digest = [hash digest];
+ digest = hash.digest;
for (size_t i = 0; i < digestSize; i++) {
uint8_t high, low;
diff --git a/src/OFData+MessagePackValue.m b/src/OFData+MessagePackValue.m
index dbe2fc3d..d9d903cf 100644
--- a/src/OFData+MessagePackValue.m
+++ b/src/OFData+MessagePackValue.m
@@ -132,11 +132,11 @@ parseTable(const unsigned char *buffer, size_t length, id *object, size_t count,
static OFDate *
createDate(OFData *data)
{
- switch ([data count]) {
+ switch (data.count) {
case 4: {
uint32_t timestamp;
- memcpy(&timestamp, [data items], 4);
+ memcpy(&timestamp, data.items, 4);
timestamp = OF_BSWAP32_IF_LE(timestamp);
return [OFDate dateWithTimeIntervalSince1970: timestamp];
@@ -144,7 +144,7 @@ createDate(OFData *data)
case 8: {
uint64_t combined;
- memcpy(&combined, [data items], 8);
+ memcpy(&combined, data.items, 8);
combined = OF_BSWAP64_IF_LE(combined);
return [OFDate dateWithTimeIntervalSince1970:
@@ -155,8 +155,8 @@ createDate(OFData *data)
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);
@@ -558,13 +558,13 @@ parseObject(const unsigned char *buffer, size_t length, id *object,
- (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];
diff --git a/src/OFData.m b/src/OFData.m
index d62b6554..df67063e 100644
--- a/src/OFData.m
+++ b/src/OFData.m
@@ -189,8 +189,8 @@ _references_to_categories_of_OFData(void)
@try {
OFFile *file;
- size = [[[OFFileManager defaultManager]
- attributesOfItemAtPath: path] fileSize];
+ size = [[OFFileManager defaultManager]
+ attributesOfItemAtPath: path].fileSize;
# if UINTMAX_MAX > SIZE_MAX
if (size > SIZE_MAX)
@@ -253,7 +253,7 @@ _references_to_categories_of_OFData(void)
pageSize = [OFSystemInfo pageSize];
buffer = [self allocMemoryWithSize: pageSize];
- while (![stream isAtEndOfStream]) {
+ while (!stream.atEndOfStream) {
size_t length = [stream readIntoBuffer: buffer
length: pageSize];
@@ -338,7 +338,7 @@ _references_to_categories_of_OFData(void)
self = [OFMutableData alloc];
}
- self = [(OFMutableData *)self initWithCapacity: [string length] / 3];
+ self = [(OFMutableData *)self initWithCapacity: string.length / 3];
@try {
if (!of_base64_decode((OFMutableData *)self,
@@ -363,11 +363,11 @@ _references_to_categories_of_OFData(void)
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;
@@ -448,9 +448,9 @@ _references_to_categories_of_OFData(void)
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;
@@ -467,13 +467,13 @@ _references_to_categories_of_OFData(void)
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;
@@ -566,16 +566,16 @@ _references_to_categories_of_OFData(void)
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--) {
@@ -639,7 +639,7 @@ _references_to_categories_of_OFData(void)
pool = objc_autoreleasePoolPush();
element = [OFXMLElement
- elementWithName: [self className]
+ elementWithName: self.className
namespace: OF_SERIALIZATION_NS
stringValue: of_base64_encode(_items, _count * _itemSize)];
diff --git a/src/OFDate.m b/src/OFDate.m
index 01d87cd6..c787cb6a 100644
--- a/src/OFDate.m
+++ b/src/OFDate.m
@@ -276,14 +276,14 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
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);
@@ -301,7 +301,7 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
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
@@ -312,8 +312,8 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
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) {
@@ -345,11 +345,11 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
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);
@@ -435,12 +435,12 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
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];
@@ -626,13 +626,13 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
@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];
@@ -686,13 +686,13 @@ tmAndTzToTime(struct tm *tm, int16_t *tz)
@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];
diff --git a/src/OFDictionary.m b/src/OFDictionary.m
index 7adddbc8..85e8aa5d 100644
--- a/src/OFDictionary.m
+++ b/src/OFDictionary.m
@@ -290,13 +290,13 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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;
@@ -354,7 +354,7 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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);
@@ -371,7 +371,7 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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];
@@ -418,7 +418,7 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
otherDictionary = object;
- if ([otherDictionary count] != [self count])
+ if (otherDictionary.count != self.count)
return false;
pool = objc_autoreleasePoolPush();
@@ -490,7 +490,7 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
- (OFArray *)allKeys
{
- OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]];
+ OFMutableArray *ret = [OFMutableArray arrayWithCapacity: self.count];
for (id key in self)
[ret addObject: key];
@@ -502,7 +502,7 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
- (OFArray *)allObjects
{
- OFMutableArray *ret = [OFMutableArray arrayWithCapacity: [self count]];
+ OFMutableArray *ret = [OFMutableArray arrayWithCapacity: self.count];
void *pool = objc_autoreleasePoolPush();
OFEnumerator *enumerator = [self objectEnumerator];
id object;
@@ -605,8 +605,8 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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 @"{}";
@@ -621,9 +621,9 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = 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"];
@@ -650,7 +650,7 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
OFCharacterSet *allowed = [OFCharacterSet_URLQueryPartAllowed
URLQueryPartAllowedCharacterSet];
bool first = true;
- id key, object;
+ OFObject *key, *object;
while ((key = [keyEnumerator nextObject]) != nil &&
(object = [objectEnumerator nextObject]) != nil) {
@@ -659,10 +659,10 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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]];
}
@@ -697,12 +697,12 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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];
@@ -736,7 +736,7 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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) {
@@ -816,10 +816,10 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
size_t i, count;
void *pool;
OFEnumerator *keyEnumerator, *objectEnumerator;
- id key, object;
+ id <OFMessagePackRepresentation> key, object;
data = [OFMutableData data];
- count = [self count];
+ count = self.count;
if (count <= 15) {
uint8_t tmp = 0x80 | ((uint8_t)count & 0xF);
@@ -853,13 +853,13 @@ static OFCharacterSet *URLQueryPartAllowedCharacterSet = nil;
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);
}
diff --git a/src/OFDictionary_hashtable.m b/src/OFDictionary_hashtable.m
index f342a9c9..5653ca4a 100644
--- a/src/OFDictionary_hashtable.m
+++ b/src/OFDictionary_hashtable.m
@@ -122,7 +122,7 @@ static const of_map_table_functions_t objectFunctions = {
}
@try {
- count = [dictionary count];
+ count = dictionary.count;
} @catch (id e) {
[self release];
@throw e;
@@ -256,13 +256,13 @@ static const of_map_table_functions_t objectFunctions = {
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];
@@ -271,16 +271,16 @@ static const of_map_table_functions_t objectFunctions = {
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);
}
@@ -308,7 +308,7 @@ static const of_map_table_functions_t objectFunctions = {
- (size_t)count
{
- return [_mapTable count];
+ return _mapTable.count;
}
- (bool)isEqual: (id)object
@@ -343,7 +343,7 @@ static const of_map_table_functions_t objectFunctions = {
id *keys;
size_t count;
- count = [_mapTable count];
+ count = _mapTable.count;
keys = [self allocMemoryWithSize: sizeof(*keys)
count: count];
@@ -378,7 +378,7 @@ static const of_map_table_functions_t objectFunctions = {
id *objects;
size_t count;
- count = [_mapTable count];
+ count = _mapTable.count;
objects = [self allocMemoryWithSize: sizeof(*objects)
count: count];
@@ -448,6 +448,6 @@ static const of_map_table_functions_t objectFunctions = {
- (uint32_t)hash
{
- return [_mapTable hash];
+ return _mapTable.hash;
}
@end
diff --git a/src/OFEnumerator.h b/src/OFEnumerator.h
index 94101be3..5fec405e 100644
--- a/src/OFEnumerator.h
+++ b/src/OFEnumerator.h
@@ -87,7 +87,7 @@ 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 */
diff --git a/src/OFFile.m b/src/OFFile.m
index 499b494d..e437bc18 100644
--- a/src/OFFile.m
+++ b/src/OFFile.m
@@ -245,13 +245,13 @@ parseMode(const char *mode, bool *append)
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:
@@ -270,7 +270,7 @@ parseMode(const char *mode, bool *append)
exceptionWithRequestedSize: sizeof(*handle)];
@try {
- if ((flags = parseMode([mode UTF8String],
+ if ((flags = parseMode(mode.UTF8String,
&handle->append)) == -1)
@throw [OFInvalidArgumentException exception];
@@ -358,7 +358,7 @@ parseMode(const char *mode, bool *append)
OFString *fileSystemRepresentation;
@try {
- fileSystemRepresentation = [URL fileSystemRepresentation];
+ fileSystemRepresentation = URL.fileSystemRepresentation;
} @catch (id e) {
[self release];
@throw e;
diff --git a/src/OFFileManager.m b/src/OFFileManager.m
index 8a1866c1..363403bd 100644
--- a/src/OFFileManager.m
+++ b/src/OFFileManager.m
@@ -183,7 +183,7 @@ OF_DESTRUCTOR()
void *pool = objc_autoreleasePoolPush();
OFURL *ret;
- ret = [OFURL fileURLWithPath: [self currentDirectoryPath]];
+ ret = [OFURL fileURLWithPath: self.currentDirectoryPath];
[ret retain];
objc_autoreleasePoolPop(pool);
@@ -344,7 +344,7 @@ OF_DESTRUCTOR()
@throw e;
}
- components = [[URL URLEncodedPath] componentsSeparatedByString: @"/"];
+ components = [URL.URLEncodedPath componentsSeparatedByString: @"/"];
for (OFString *component in components) {
if (currentPath != nil)
@@ -353,9 +353,9 @@ OF_DESTRUCTOR()
else
currentPath = component;
- [URL setURLEncodedPath: currentPath];
+ URL.URLEncodedPath = currentPath;
- if ([currentPath length] > 0 &&
+ if (currentPath.length > 0 &&
![self directoryExistsAtURL: URL])
[self createDirectoryAtURL: URL];
}
@@ -416,7 +416,7 @@ OF_DESTRUCTOR()
@throw [OFInvalidArgumentException exception];
#if defined(OF_WINDOWS)
- if (_wchdir([path UTF16String]) != 0)
+ if (_wchdir(path.UTF16String) != 0)
@throw [OFChangeCurrentDirectoryPathFailedException
exceptionWithPath: path
errNo: errno];
@@ -465,7 +465,7 @@ OF_DESTRUCTOR()
{
void *pool = objc_autoreleasePoolPush();
- [self changeCurrentDirectoryPath: [URL fileSystemRepresentation]];
+ [self changeCurrentDirectoryPath: URL.fileSystemRepresentation];
objc_autoreleasePoolPop(pool);
}
@@ -514,10 +514,10 @@ OF_DESTRUCTOR()
@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;
@@ -586,7 +586,7 @@ OF_DESTRUCTOR()
destination] openItemAtURL: destination
mode: @"w"];
- while (![sourceStream isAtEndOfStream]) {
+ while (!sourceStream.atEndOfStream) {
size_t length;
length = [sourceStream
@@ -630,7 +630,7 @@ OF_DESTRUCTOR()
} else if ([type isEqual: of_file_type_symbolic_link]) {
@try {
OFString *linkDestination =
- [attributes fileSymbolicLinkDestination];
+ attributes.fileSymbolicLinkDestination;
[self createSymbolicLinkAtURL: destination
withDestinationPath: linkDestination];
@@ -690,7 +690,7 @@ OF_DESTRUCTOR()
toURL: destination])
return;
} @catch (OFMoveItemFailedException *e) {
- if ([e errNo] != EXDEV)
+ if (e.errNo != EXDEV)
@throw e;
}
@@ -709,7 +709,7 @@ OF_DESTRUCTOR()
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
- errNo: [e errNo]];
+ errNo: e.errNo];
}
@try {
@@ -718,7 +718,7 @@ OF_DESTRUCTOR()
@throw [OFMoveItemFailedException
exceptionWithSourceURL: source
destinationURL: destination
- errNo: [e errNo]];
+ errNo: e.errNo];
}
objc_autoreleasePoolPop(pool);
@@ -755,7 +755,7 @@ OF_DESTRUCTOR()
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];
diff --git a/src/OFGZIPStream.m b/src/OFGZIPStream.m
index 4e3d1c3e..ff858855 100644
--- a/src/OFGZIPStream.m
+++ b/src/OFGZIPStream.m
@@ -83,7 +83,7 @@
uint8_t byte;
uint32_t CRC32, uncompressedSize;
- if ([_stream isAtEndOfStream]) {
+ if (_stream.atEndOfStream) {
if (_state != OF_GZIP_STREAM_ID1)
@throw [OFTruncatedDataException exception];
@@ -239,7 +239,7 @@
_inflateStream = [[OFInflateStream alloc]
initWithStream: _stream];
- if (![_inflateStream isAtEndOfStream]) {
+ if (!_inflateStream.atEndOfStream) {
size_t bytesRead = [_inflateStream
readIntoBuffer: buffer
length: length];
@@ -309,16 +309,16 @@
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
diff --git a/src/OFHMAC.m b/src/OFHMAC.m
index ea3a0626..0b68e4e6 100644
--- a/src/OFHMAC.m
+++ b/src/OFHMAC.m
@@ -62,8 +62,8 @@
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];
@@ -82,8 +82,8 @@
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);
@@ -139,13 +139,13 @@
@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
diff --git a/src/OFHTTPClient.h b/src/OFHTTPClient.h
index d225f0a9..dbba8d45 100644
--- a/src/OFHTTPClient.h
+++ b/src/OFHTTPClient.h
@@ -74,7 +74,7 @@ OF_ASSUME_NONNULL_BEGIN
* @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;
/*!
diff --git a/src/OFHTTPClient.m b/src/OFHTTPClient.m
index 03acb2e4..db1db7bb 100644
--- a/src/OFHTTPClient.m
+++ b/src/OFHTTPClient.m
@@ -110,42 +110,42 @@ 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"];
@@ -154,19 +154,19 @@ constructRequestString(OFHTTPRequest *request)
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"];
@@ -177,8 +177,8 @@ constructRequestString(OFHTTPRequest *request)
@"<https://heap.zone/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"];
@@ -291,7 +291,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
- (void)createResponseWithSocketOrThrow: (OFTCPSocket *)sock
{
- OFURL *URL = [_request URL];
+ OFURL *URL = _request.URL;
OFHTTPClientResponse *response;
OFString *connectionHeader;
bool keepAlive;
@@ -299,9 +299,9 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
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"]) {
@@ -319,12 +319,12 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
}
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];
}
@@ -333,7 +333,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
_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;
@@ -349,18 +349,17 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
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"];
/*
@@ -383,12 +382,11 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
[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;
@@ -434,7 +432,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
return false;
}
- if (![line hasPrefix: @"HTTP/"] || [line length] < 9 ||
+ if (![line hasPrefix: @"HTTP/"] || line.length < 9 ||
[line characterAtIndex: 8] != ' ')
@throw [OFInvalidServerReplyException exception];
@@ -443,7 +441,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
@throw [OFUnsupportedVersionException
exceptionWithVersion: _version];
- _status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue];
+ _status = (int)[line substringWithRange: of_range(9, 3)].decimalValue;
return true;
}
@@ -458,7 +456,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
if (line == nil)
@throw [OFInvalidServerReplyException exception];
- if ([line length] == 0) {
+ if (line.length == 0) {
[_serverHeaders makeImmutable];
if ([_client->_delegate respondsToSelector: @selector(client:
@@ -468,7 +466,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
statusCode: _status
request: _request];
- [sock setDelegate: nil];
+ sock.delegate = nil;
[self performSelector: @selector(createResponseWithSocket:)
withObject: sock
@@ -477,7 +475,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
return false;
}
- lineC = [line UTF8String];
+ lineC = line.UTF8String;
if ((tmp = strchr(lineC, ':')) == NULL)
@throw [OFInvalidServerReplyException exception];
@@ -514,7 +512,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
return true;
}
-- (bool)stream: (OF_KINDOF(OFStream *))sock
+- (bool)stream: (OFStream *)sock
didReadLine: (OFString *)line
exception: (id)exception
{
@@ -535,7 +533,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
ret = [self handleFirstLine: line];
} else
ret = [self handleServerHeader: line
- socket: sock];
+ socket: (OFTCPSocket *)sock];
} @catch (id e) {
[self raiseException: e];
ret = false;
@@ -544,7 +542,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
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
@@ -565,12 +563,12 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
_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:)])
@@ -602,12 +600,12 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
}
}
-- (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];
@@ -627,16 +625,15 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
- (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
@@ -651,7 +648,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
[_client->_lastResponse release];
_client->_lastResponse = nil;
- [sock setDelegate: self];
+ sock.delegate = self;
[self performSelector: @selector(handleSocket:)
withObject: sock
@@ -663,14 +660,14 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
- (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];
@@ -682,12 +679,12 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
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];
@@ -709,13 +706,13 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
_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];
@@ -794,7 +791,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
if (_toWrite > 0)
@throw [OFTruncatedDataException exception];
- [_socket setDelegate: _handler];
+ _socket.delegate = _handler;
[_socket asyncReadLine];
[_socket release];
@@ -803,7 +800,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
- (int)fileDescriptorForWriting
{
- return [_socket fileDescriptorForWriting];
+ return _socket.fileDescriptorForWriting;
}
@end
@@ -830,7 +827,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
{
OFString *contentLength;
- [super setHeaders: headers];
+ super.headers = headers;
_chunked = [[headers objectForKey: @"Transfer-Encoding"]
isEqual: @"chunked"];
@@ -840,7 +837,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
_hasContentLength = true;
@try {
- intmax_t toRead = [contentLength decimalValue];
+ intmax_t toRead = contentLength.decimalValue;
if (toRead < 0)
@throw [OFInvalidServerReplyException
@@ -866,7 +863,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
return [_socket readIntoBuffer: buffer
length: length];
- if ([_socket isAtEndOfStream])
+ if (_socket.atEndOfStream)
@throw [OFTruncatedDataException exception];
/* Content-Length */
@@ -907,7 +904,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
_toRead -= length;
if (_toRead == 0)
- if ([[_socket readLine] length] > 0)
+ if ([_socket readLine].length > 0)
@throw [OFInvalidServerReplyException
exception];
@@ -929,7 +926,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
of_range(0, range.location)];
@try {
- intmax_t toRead = [line hexadecimalValue];
+ intmax_t toRead = line.hexadecimalValue;
if (toRead < 0)
@throw [OFOutOfRangeException exception];
@@ -950,7 +947,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
exception];
}
- if ([line length] > 0)
+ if (line.length > 0)
@throw [OFInvalidServerReplyException
exception];
} else {
@@ -974,7 +971,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
@throw [OFNotOpenException exceptionWithObject: self];
if (!_hasContentLength && !_chunked)
- return [_socket isAtEndOfStream];
+ return _socket.atEndOfStream;
return _atEndOfStream;
}
@@ -984,12 +981,12 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
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
@@ -1010,9 +1007,9 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
@try {
_client = [client retain];
- _delegate = [client delegate];
+ _delegate = client.delegate;
- [_client setDelegate: self];
+ _client.delegate = self;
} @catch (id e) {
[self release];
@throw e;
@@ -1023,7 +1020,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
- (void)dealloc
{
- [_client setDelegate: _delegate];
+ _client.delegate = _delegate;
[_client release];
[super dealloc];
@@ -1063,13 +1060,13 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
* 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:
@@ -1117,7 +1114,7 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
request: request
response: response];
else
- return defaultShouldFollow([request method], statusCode);
+ return defaultShouldFollow(request.method, statusCode);
}
@end
@@ -1170,8 +1167,8 @@ defaultShouldFollow(of_http_request_method_t method, int statusCode)
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];
diff --git a/src/OFHTTPCookie.m b/src/OFHTTPCookie.m
index 1ff7e055..f0e2559c 100644
--- a/src/OFHTTPCookie.m
+++ b/src/OFHTTPCookie.m
@@ -28,32 +28,32 @@
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];
}
}
@@ -69,9 +69,9 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
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,
@@ -166,7 +166,7 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
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);
@@ -187,7 +187,7 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
*/
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"] ||
@@ -197,7 +197,7 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
[value isEqual: @"Sun"]))
break;
- handleAttribute([ret lastObject], name, value);
+ handleAttribute(ret.lastObject, name, value);
state = (characters[i] == ';'
? STATE_PRE_ATTR_NAME : STATE_PRE_NAME);
@@ -233,14 +233,14 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
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;
}
@@ -258,7 +258,7 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
OFMutableString *cookieString;
bool first = true;
- if ([cookies count] == 0)
+ if (cookies.count == 0)
return [OFDictionary dictionary];
pool = objc_autoreleasePoolPush();
@@ -270,9 +270,9 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
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
@@ -368,14 +368,14 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
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;
@@ -420,7 +420,7 @@ handleAttribute(OFHTTPCookie *cookie, OFString *name, OFString *value)
if (_HTTPOnly)
[ret appendString: @"; HTTPOnly"];
- if ([_extensions count] > 0)
+ if (_extensions.count > 0)
[ret appendFormat:
@"; %@", [_extensions componentsJoinedByString: @"; "]];
diff --git a/src/OFHTTPCookieManager.m b/src/OFHTTPCookieManager.m
index 501454fb..2f561d85 100644
--- a/src/OFHTTPCookieManager.m
+++ b/src/OFHTTPCookieManager.m
@@ -62,18 +62,18 @@
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];
@@ -85,9 +85,9 @@
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];
@@ -121,23 +121,23 @@
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];
}
@@ -149,8 +149,8 @@
continue;
}
- cookiePath = [cookie path];
- URLPath = [URL path];
+ cookiePath = cookie.path;
+ URLPath = URL.path;
if (![cookiePath isEqual: @"/"]) {
if ([cookiePath isEqual: URLPath])
match = true;
@@ -178,10 +178,10 @@
- (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--;
diff --git a/src/OFHTTPRequest.m b/src/OFHTTPRequest.m
index a90a8087..8e69bad8 100644
--- a/src/OFHTTPRequest.m
+++ b/src/OFHTTPRequest.m
@@ -141,9 +141,9 @@ of_http_request_method_from_string(const char *string)
@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;
@@ -184,8 +184,8 @@ of_http_request_method_from_string(const char *string)
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);
@@ -216,11 +216,11 @@ of_http_request_method_from_string(const char *string)
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];
@@ -228,7 +228,7 @@ of_http_request_method_from_string(const char *string)
protocolVersion.major = (uint8_t)major;
protocolVersion.minor = (uint8_t)minor;
- [self setProtocolVersion: protocolVersion];
+ self.protocolVersion = protocolVersion;
objc_autoreleasePoolPop(pool);
}
@@ -246,7 +246,7 @@ of_http_request_method_from_string(const char *string)
const char *method = of_http_request_method_to_string(_method);
OFString *indentedHeaders, *ret;
- indentedHeaders = [[_headers description]
+ indentedHeaders = [_headers.description
stringByReplacingOccurrencesOfString: @"\n"
withString: @"\n\t"];
@@ -256,7 +256,7 @@ of_http_request_method_from_string(const char *string)
@"\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);
diff --git a/src/OFHTTPResponse.m b/src/OFHTTPResponse.m
index 33566f8c..c8ab9cf0 100644
--- a/src/OFHTTPResponse.m
+++ b/src/OFHTTPResponse.m
@@ -32,8 +32,8 @@
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,
@@ -87,8 +87,8 @@ encodingForContentType(OFString *contentType)
value = [OFString
stringWithUTF8String: UTF8String + last
length: i - last];
- value = [value
- stringByDeletingTrailingWhitespaces];
+ value =
+ value.stringByDeletingTrailingWhitespaces;
if ([name isEqual: @"charset"])
charset = value;
@@ -121,7 +121,7 @@ encodingForContentType(OFString *contentType)
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;
@@ -185,11 +185,11 @@ encodingForContentType(OFString *contentType)
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];
@@ -197,7 +197,7 @@ encodingForContentType(OFString *contentType)
protocolVersion.major = (uint8_t)major;
protocolVersion.minor = (uint8_t)minor;
- [self setProtocolVersion: protocolVersion];
+ self.protocolVersion = protocolVersion;
objc_autoreleasePoolPop(pool);
}
@@ -230,12 +230,12 @@ encodingForContentType(OFString *contentType)
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);
@@ -247,7 +247,7 @@ encodingForContentType(OFString *contentType)
void *pool = objc_autoreleasePoolPush();
OFString *indentedHeaders, *ret;
- indentedHeaders = [[_headers description]
+ indentedHeaders = [_headers.description
stringByReplacingOccurrencesOfString: @"\n"
withString: @"\n\t"];
@@ -256,7 +256,7 @@ encodingForContentType(OFString *contentType)
@"\tStatus code = %d\n"
@"\tHeaders = %@\n"
@">",
- [self class], _statusCode, indentedHeaders];
+ self.class, _statusCode, indentedHeaders];
objc_autoreleasePoolPop(pool);
diff --git a/src/OFHTTPServer.h b/src/OFHTTPServer.h
index aea677f8..c7e18b1f 100644
--- a/src/OFHTTPServer.h
+++ b/src/OFHTTPServer.h
@@ -99,7 +99,7 @@ OF_ASSUME_NONNULL_BEGIN
const char *_Nullable _privateKeyPassphrase;
id <OFHTTPServerDelegate> _Nullable _delegate;
OFString *_Nullable _name;
- OF_KINDOF(OFTCPSocket *) _Nullable _listeningSocket;
+ OFTCPSocket *_Nullable _listeningSocket;
#ifdef OF_HAVE_THREADS
size_t _numberOfThreads, _nextThreadIndex;
OFArray *_threadPool;
diff --git a/src/OFHTTPServer.m b/src/OFHTTPServer.m
index b3a08248..0c6be460 100644
--- a/src/OFHTTPServer.m
+++ b/src/OFHTTPServer.m
@@ -57,13 +57,13 @@
@interface OFHTTPServerResponse: OFHTTPResponse <OFReadyForWritingObserving>
{
- 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
@@ -71,7 +71,7 @@
@interface OFHTTPServer_Connection: OFObject <OFTCPSocketDelegate>
{
@public
- OF_KINDOF(OFTCPSocket *) _socket;
+ OFTCPSocket *_socket;
OFHTTPServer *_server;
OFTimer *_timer;
enum {
@@ -88,7 +88,7 @@
OFStream *_requestBody;
}
-- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock
+- (instancetype)initWithSocket: (OFTCPSocket *)sock
server: (OFHTTPServer *)server;
- (bool)parseProlog: (OFString *)line;
- (bool)parseHeaders: (OFString *)line;
@@ -98,12 +98,12 @@
@interface OFHTTPServerRequestBodyStream: OFStream <OFReadyForReadingObserving>
{
- 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
@@ -205,13 +205,13 @@ statusCodeToString(short code)
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)) {
@@ -233,7 +233,7 @@ normalizedKey(OFString *key)
}
@implementation OFHTTPServerResponse
-- (instancetype)initWithSocket: (OF_KINDOF(OFTCPSocket *))sock
+- (instancetype)initWithSocket: (OFTCPSocket *)sock
server: (OFHTTPServer *)server
request: (OFHTTPRequest *)request
{
@@ -266,7 +266,7 @@ normalizedKey(OFString *key)
OFString *key, *value;
[_socket writeFormat: @"HTTP/%@ %d %s\r\n",
- [self protocolVersionString], _statusCode,
+ self.protocolVersionString, _statusCode,
statusCodeToString(_statusCode)];
headers = [[_headers mutableCopy] autorelease];
@@ -280,7 +280,7 @@ normalizedKey(OFString *key)
}
if ([headers objectForKey: @"Server"] == nil) {
- OFString *name = [_server name];
+ OFString *name = _server.name;
if (name != nil)
[headers setObject: name
@@ -344,7 +344,7 @@ normalizedKey(OFString *key)
[_socket writeBuffer: "0\r\n\r\n"
length: 5];
} @catch (OFWriteFailedException *e) {
- id <OFHTTPServerDelegate> delegate = [_server delegate];
+ id <OFHTTPServerDelegate> delegate = _server.delegate;
if ([delegate respondsToSelector: @selector(server:
didReceiveExceptionForResponse:request:exception:)])
@@ -365,12 +365,12 @@ normalizedKey(OFString *key)
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];
@@ -409,7 +409,7 @@ normalizedKey(OFString *key)
[super dealloc];
}
-- (bool)stream: (OF_KINDOF(OFStream *))sock
+- (bool)stream: (OFStream *)sock
didReadLine: (OFString *)line
exception: (id)exception
{
@@ -440,7 +440,7 @@ normalizedKey(OFString *key)
@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."])
@@ -461,14 +461,13 @@ normalizedKey(OFString *key)
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];
@@ -494,7 +493,7 @@ normalizedKey(OFString *key)
OFString *key, *value, *old;
size_t pos;
- if ([line length] == 0) {
+ if (line.length == 0) {
OFString *contentLengthString;
if ((contentLengthString =
@@ -503,7 +502,7 @@ normalizedKey(OFString *key)
@try {
contentLength =
- [contentLengthString decimalValue];
+ contentLengthString.decimalValue;
} @catch (OFInvalidFormatException *e) {
return [self sendErrorAndClose: 400];
@@ -535,10 +534,10 @@ normalizedKey(OFString *key)
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)
@@ -559,9 +558,9 @@ normalizedKey(OFString *key)
@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];
@@ -590,7 +589,7 @@ normalizedKey(OFString *key)
@"Server: %@\r\n"
@"\r\n",
statusCode, statusCodeToString(statusCode),
- date, [_server name]];
+ date, _server.name];
return false;
}
@@ -614,53 +613,53 @@ normalizedKey(OFString *key)
}
[_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];
@@ -711,12 +710,12 @@ normalizedKey(OFString *key)
- (bool)hasDataInReadBuffer
{
- return ([super hasDataInReadBuffer] || [_socket hasDataInReadBuffer]);
+ return (super.hasDataInReadBuffer || _socket.hasDataInReadBuffer);
}
- (int)fileDescriptorForReading
{
- return [_socket fileDescriptorForReading];
+ return _socket.fileDescriptorForReading;
}
- (void)close
@@ -859,15 +858,15 @@ normalizedKey(OFString *key)
}
#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
@@ -887,18 +886,17 @@ normalizedKey(OFString *key)
@throw [OFAlreadyConnectedException exception];
if (_usesTLS) {
- id <OFTLSSocket> listeningSocket;
+ OFTCPSocket <OFTLSSocket> *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];
@@ -924,7 +922,7 @@ normalizedKey(OFString *key)
}
#endif
- [(OFTCPSocket *)_listeningSocket setDelegate: self];
+ ((OFTCPSocket *)_listeningSocket).delegate = self;
[_listeningSocket asyncAccept];
objc_autoreleasePoolPop(pool);
@@ -945,18 +943,18 @@ normalizedKey(OFString *key)
#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) {
diff --git a/src/OFINICategory.m b/src/OFINICategory.m
index 86741ecd..c4f8b69f 100644
--- a/src/OFINICategory.m
+++ b/src/OFINICategory.m
@@ -81,7 +81,7 @@ unescapeString(OFString *string)
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"
@@ -163,10 +163,10 @@ unescapeString(OFString *string)
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);
@@ -219,9 +219,9 @@ unescapeString(OFString *string)
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;
@@ -262,7 +262,7 @@ unescapeString(OFString *string)
float ret;
if (value != nil)
- ret = [value floatValue];
+ ret = value.floatValue;
else
ret = defaultValue;
@@ -280,7 +280,7 @@ unescapeString(OFString *string)
double ret;
if (value != nil)
- ret = [value doubleValue];
+ ret = value.doubleValue;
else
ret = defaultValue;
@@ -403,14 +403,14 @@ unescapeString(OFString *string)
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;
@@ -425,8 +425,8 @@ unescapeString(OFString *string)
[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++) {
@@ -446,12 +446,12 @@ unescapeString(OFString *string)
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;
}
@@ -466,8 +466,8 @@ unescapeString(OFString *string)
- (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;
@@ -480,8 +480,8 @@ unescapeString(OFString *string)
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;
@@ -495,7 +495,7 @@ unescapeString(OFString *string)
encoding: (of_string_encoding_t)encoding
first: (bool)first
{
- if ([_lines count] == 0)
+ if (_lines.count == 0)
return false;
if (first)
diff --git a/src/OFINIFile.m b/src/OFINIFile.m
index 1f155cdf..64ba30f3 100644
--- a/src/OFINIFile.m
+++ b/src/OFINIFile.m
@@ -37,8 +37,8 @@
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]))
@@ -102,7 +102,7 @@ isWhitespaceLine(OFString *line)
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];
@@ -126,7 +126,7 @@ isWhitespaceLine(OFString *line)
mode: @"r"];
} @catch (OFOpenItemFailedException *e) {
/* Handle missing file like an empty file */
- if ([e errNo] == ENOENT)
+ if (e.errNo == ENOENT)
return;
@throw e;
@@ -143,7 +143,7 @@ isWhitespaceLine(OFString *line)
@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];
diff --git a/src/OFInflate64Stream.h b/src/OFInflate64Stream.h
index 9f2ffd7d..9464f9c4 100644
--- a/src/OFInflate64Stream.h
+++ b/src/OFInflate64Stream.h
@@ -36,7 +36,7 @@ OF_ASSUME_NONNULL_BEGIN
#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;
@@ -81,7 +81,7 @@ OF_ASSUME_NONNULL_BEGIN
* 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;
@@ -93,8 +93,7 @@ OF_ASSUME_NONNULL_BEGIN
* 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
diff --git a/src/OFInflateStream.h b/src/OFInflateStream.h
index cb0314e9..e3ea89f2 100644
--- a/src/OFInflateStream.h
+++ b/src/OFInflateStream.h
@@ -36,7 +36,7 @@ OF_ASSUME_NONNULL_BEGIN
#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;
@@ -81,7 +81,7 @@ OF_ASSUME_NONNULL_BEGIN
* 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;
@@ -93,8 +93,7 @@ OF_ASSUME_NONNULL_BEGIN
* 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
diff --git a/src/OFInflateStream.m b/src/OFInflateStream.m
index 4483165f..5b350a53 100644
--- a/src/OFInflateStream.m
+++ b/src/OFInflateStream.m
@@ -172,7 +172,7 @@ tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count)
fixedDistTree = of_huffman_tree_construct(lengths, 32);
}
-+ (instancetype)streamWithStream: (OF_KINDOF(OFStream *))stream
++ (instancetype)streamWithStream: (OFStream *)stream
{
return [[[self alloc] initWithStream: stream] autorelease];
}
@@ -182,7 +182,7 @@ tryReadBits(OFInflateStream *stream, uint16_t *bits, uint8_t count)
OF_INVALID_INIT_METHOD
}
-- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)initWithStream: (OFStream *)stream
{
self = [super init];
@@ -668,12 +668,13 @@ start:
- (int)fileDescriptorForReading
{
- return [_stream fileDescriptorForReading];
+ return ((id <OFReadyForReadingObserving>)_stream)
+ .fileDescriptorForReading;
}
- (bool)hasDataInReadBuffer
{
- return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer] ||
+ return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer ||
_bufferLength - _bufferIndex > 0);
}
diff --git a/src/OFIntrospection.m b/src/OFIntrospection.m
index 0424876b..a998e965 100644
--- a/src/OFIntrospection.m
+++ b/src/OFIntrospection.m
@@ -81,7 +81,7 @@
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@ [%s]>",
- [self class], _name, _typeEncoding];
+ self.class, _name, _typeEncoding];
}
- (bool)isEqual: (id)object
@@ -119,7 +119,7 @@
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);
@@ -179,7 +179,7 @@
if ((attributes = property_getAttributes(property)) == NULL)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
while (*attributes != '\0') {
const char *start;
@@ -211,7 +211,7 @@
if (_getter != nil)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
while (*attributes != ',' &&
*attributes != '\0')
@@ -227,7 +227,7 @@
if (_setter != nil)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
while (*attributes != ',' &&
*attributes != '\0')
@@ -254,7 +254,7 @@
if (_iVar != nil)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
while (*attributes != ',' &&
*attributes != '\0')
@@ -267,12 +267,12 @@
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++;
@@ -334,8 +334,8 @@
@"\tSetter = %@\n"
@"\tiVar = %@\n"
@">",
- [self class], _name, _attributes,
- _getter, _setter, _iVar];
+ self.class, _name, _attributes, _getter, _setter,
+ _iVar];
}
- (bool)isEqual: (id)object
@@ -368,11 +368,11 @@
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);
diff --git a/src/OFInvocation.m b/src/OFInvocation.m
index 6708dd93..9d3ac4e4 100644
--- a/src/OFInvocation.m
+++ b/src/OFInvocation.m
@@ -42,7 +42,7 @@ extern void of_invocation_invoke(OFInvocation *);
@try {
void *pool = objc_autoreleasePoolPush();
- size_t numberOfArguments = [signature numberOfArguments];
+ size_t numberOfArguments = signature.numberOfArguments;
const char *typeEncoding;
size_t typeSize;
@@ -62,7 +62,7 @@ extern void of_invocation_invoke(OFInvocation *);
[_arguments addObject: data];
}
- typeEncoding = [_methodSignature methodReturnType];
+ typeEncoding = _methodSignature.methodReturnType;
typeSize = of_sizeof_type_encoding(typeEncoding);
if (typeSize > 0) {
@@ -95,7 +95,7 @@ extern void of_invocation_invoke(OFInvocation *);
{
OFMutableData *data = [_arguments objectAtIndex: idx];
- memcpy([data items], buffer, [data itemSize]);
+ memcpy(data.mutableItems, buffer, data.itemSize);
}
- (void)getArgument: (void *)buffer
@@ -103,17 +103,17 @@ extern void of_invocation_invoke(OFInvocation *);
{
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
diff --git a/src/OFKernelEventObserver.m b/src/OFKernelEventObserver.m
index c7569c38..ee239642 100644
--- a/src/OFKernelEventObserver.m
+++ b/src/OFKernelEventObserver.m
@@ -114,13 +114,13 @@ enum {
#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;
@@ -134,13 +134,13 @@ enum {
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;
@@ -159,7 +159,7 @@ enum {
if (of_socket_errno() != EADDRINUSE)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
}
# endif
#endif
@@ -308,11 +308,11 @@ enum {
[_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];
@@ -412,7 +412,7 @@ enum {
- (void)observeUntilDate: (OFDate *)date
{
- [self observeForTimeInterval: [date timeIntervalSinceNow]];
+ [self observeForTimeInterval: date.timeIntervalSinceNow];
}
- (void)cancel
diff --git a/src/OFKernelEventObserver_epoll.m b/src/OFKernelEventObserver_epoll.m
index f03c3c2f..a04ed13d 100644
--- a/src/OFKernelEventObserver_epoll.m
+++ b/src/OFKernelEventObserver_epoll.m
@@ -55,13 +55,13 @@ static const of_map_table_functions_t mapFunctions = { NULL };
#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);
@@ -77,7 +77,7 @@ static const of_map_table_functions_t mapFunctions = { 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;
@@ -155,28 +155,28 @@ static const of_map_table_functions_t mapFunctions = { NULL };
- (void)of_addObjectForReading: (id <OFReadyForReadingObserving>)object
{
[self of_addObject: object
- fileDescriptor: [object fileDescriptorForReading]
+ fileDescriptor: object.fileDescriptorForReading
events: EPOLLIN];
}
- (void)of_addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
[self of_addObject: object
- fileDescriptor: [object fileDescriptorForWriting]
+ fileDescriptor: object.fileDescriptorForWriting
events: EPOLLOUT];
}
- (void)of_removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
[self of_removeObject: object
- fileDescriptor: [object fileDescriptorForReading]
+ fileDescriptor: object.fileDescriptorForReading
events: EPOLLIN];
}
- (void)of_removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
[self of_removeObject: object
- fileDescriptor: [object fileDescriptorForWriting]
+ fileDescriptor: object.fileDescriptorForWriting
events: EPOLLOUT];
}
diff --git a/src/OFKernelEventObserver_kqueue.m b/src/OFKernelEventObserver_kqueue.m
index ba251f82..5ea61e89 100644
--- a/src/OFKernelEventObserver_kqueue.m
+++ b/src/OFKernelEventObserver_kqueue.m
@@ -55,13 +55,13 @@
#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);
@@ -71,7 +71,7 @@
if (kevent(_kernelQueue, &event, 1, NULL, 0, NULL) != 0)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
} @catch (id e) {
[self release];
@throw e;
@@ -92,7 +92,7 @@
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
@@ -111,7 +111,7 @@
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
@@ -130,7 +130,7 @@
struct kevent event;
memset(&event, 0, sizeof(event));
- event.ident = [object fileDescriptorForReading];
+ event.ident = object.fileDescriptorForReading;
event.filter = EVFILT_READ;
event.flags = EV_DELETE;
@@ -144,7 +144,7 @@
struct kevent event;
memset(&event, 0, sizeof(event));
- event.ident = [object fileDescriptorForWriting];
+ event.ident = object.fileDescriptorForWriting;
event.filter = EVFILT_WRITE;
event.flags = EV_DELETE;
diff --git a/src/OFKernelEventObserver_poll.m b/src/OFKernelEventObserver_poll.m
index 65fdd69a..cf7080d0 100644
--- a/src/OFKernelEventObserver_poll.m
+++ b/src/OFKernelEventObserver_poll.m
@@ -75,8 +75,8 @@
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++) {
@@ -106,8 +106,8 @@
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) {
@@ -129,28 +129,28 @@
- (void)of_addObjectForReading: (id <OFReadyForReadingObserving>)object
{
[self of_addObject: object
- fileDescriptor: [object fileDescriptorForReading]
+ fileDescriptor: object.fileDescriptorForReading
events: POLLIN];
}
- (void)of_addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
[self of_addObject: object
- fileDescriptor: [object fileDescriptorForWriting]
+ fileDescriptor: object.fileDescriptorForWriting
events: POLLOUT];
}
- (void)of_removeObjectForReading: (id <OFReadyForReadingObserving>)object
{
[self of_removeObject: object
- fileDescriptor: [object fileDescriptorForReading]
+ fileDescriptor: object.fileDescriptorForReading
events: POLLIN];
}
- (void)of_removeObjectForWriting: (id <OFReadyForWritingObserving>)object
{
[self of_removeObject: object
- fileDescriptor: [object fileDescriptorForWriting]
+ fileDescriptor: object.fileDescriptorForWriting
events: POLLOUT];
}
@@ -165,8 +165,8 @@
if ([self of_processReadBuffers])
return;
- FDs = [_FDs items];
- nFDs = [_FDs count];
+ FDs = _FDs.mutableItems;
+ nFDs = _FDs.count;
#ifdef OPEN_MAX
if (nFDs > OPEN_MAX)
diff --git a/src/OFKernelEventObserver_select.m b/src/OFKernelEventObserver_select.m
index beaa7fbd..9f2e77cd 100644
--- a/src/OFKernelEventObserver_select.m
+++ b/src/OFKernelEventObserver_select.m
@@ -51,7 +51,7 @@
#ifndef OF_WINDOWS
if (_cancelFD[0] >= (int)FD_SETSIZE)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
#endif
FD_ZERO(&_readFDs);
@@ -68,7 +68,7 @@
- (void)of_addObjectForReading: (id <OFReadyForReadingObserving>)object
{
- int fd = [object fileDescriptorForReading];
+ int fd = object.fileDescriptorForReading;
if (fd < 0 || fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
@@ -86,7 +86,7 @@
- (void)of_addObjectForWriting: (id <OFReadyForWritingObserving>)object
{
- int fd = [object fileDescriptorForWriting];
+ int fd = object.fileDescriptorForWriting;
if (fd < 0 || fd > INT_MAX - 1)
@throw [OFOutOfRangeException exception];
@@ -106,7 +106,7 @@
{
/* TODO: Adjust _maxFD */
- int fd = [object fileDescriptorForReading];
+ int fd = object.fileDescriptorForReading;
if (fd < 0)
@throw [OFOutOfRangeException exception];
@@ -123,7 +123,7 @@
{
/* TODO: Adjust _maxFD */
- int fd = [object fileDescriptorForWriting];
+ int fd = object.fileDescriptorForWriting;
if (fd < 0)
@throw [OFOutOfRangeException exception];
@@ -189,8 +189,8 @@
#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();
@@ -204,8 +204,8 @@
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();
diff --git a/src/OFLHAArchive.h b/src/OFLHAArchive.h
index 4a914d16..ffd81015 100644
--- a/src/OFLHAArchive.h
+++ b/src/OFLHAArchive.h
@@ -31,14 +31,14 @@ OF_ASSUME_NONNULL_BEGIN
*/
@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;
}
/*!
@@ -67,7 +67,7 @@ OF_ASSUME_NONNULL_BEGIN
* archive.
* @return A new, autoreleased OFLHAArchive
*/
-+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
++ (instancetype)archiveWithStream: (OFStream *)stream
mode: (OFString *)mode;
#ifdef OF_HAVE_FILES
@@ -97,7 +97,7 @@ OF_ASSUME_NONNULL_BEGIN
* 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
diff --git a/src/OFLHAArchive.m b/src/OFLHAArchive.m
index 788c8312..9476565c 100644
--- a/src/OFLHAArchive.m
+++ b/src/OFLHAArchive.m
@@ -40,15 +40,15 @@
@interface OFLHAArchive_FileReadStream: OFStream <OFReadyForReadingObserving>
{
- 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
@@ -57,13 +57,13 @@
{
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
@@ -71,7 +71,7 @@
@implementation OFLHAArchive
@synthesize encoding = _encoding;
-+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
++ (instancetype)archiveWithStream: (OFStream *)stream
mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream
@@ -92,7 +92,7 @@
OF_INVALID_INIT_METHOD
}
-- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode
{
self = [super init];
@@ -115,8 +115,8 @@
@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) {
@@ -167,13 +167,13 @@
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;
@@ -207,7 +207,8 @@
if (_lastReturnedStream == nil)
@throw [OFInvalidArgumentException exception];
- return [[_lastReturnedStream retain] autorelease];
+ return [[(OFLHAArchive_FileReadStream *)_lastReturnedStream
+ retain] autorelease];
}
- (OFStream <OFReadyForWritingObserving> *)
@@ -219,7 +220,7 @@
_mode != OF_LHA_ARCHIVE_MODE_APPEND)
@throw [OFInvalidArgumentException exception];
- compressionMethod = [entry compressionMethod];
+ compressionMethod = entry.compressionMethod;
if (![compressionMethod isEqual: @"-lh0-"] &&
![compressionMethod isEqual: @"-lhd-"])
@@ -231,11 +232,12 @@
_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
@@ -253,7 +255,7 @@
@end
@implementation OFLHAArchive_FileReadStream
-- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFLHAArchiveEntry *)entry
{
self = [super init];
@@ -263,7 +265,7 @@
_stream = [stream retain];
- compressionMethod = [entry compressionMethod];
+ compressionMethod = entry.compressionMethod;
if ([compressionMethod isEqual: @"-lh4-"] ||
[compressionMethod isEqual: @"-lh5-"])
@@ -285,7 +287,7 @@
_decompressedStream = [stream retain];
_entry = [entry copy];
- _toRead = [entry uncompressedSize];
+ _toRead = entry.uncompressedSize;
} @catch (id e) {
[self release];
@throw e;
@@ -324,8 +326,7 @@
if (_atEndOfStream)
return 0;
- if ([_stream isAtEndOfStream] &&
- ![_decompressedStream hasDataInReadBuffer])
+ if (_stream.atEndOfStream && !_decompressedStream.hasDataInReadBuffer)
@throw [OFTruncatedDataException exception];
if (length > _toRead)
@@ -340,11 +341,11 @@
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
@@ -357,18 +358,19 @@
- (bool)hasDataInReadBuffer
{
- return ([super hasDataInReadBuffer] ||
- [_decompressedStream hasDataInReadBuffer]);
+ return (super.hasDataInReadBuffer ||
+ _decompressedStream.hasDataInReadBuffer);
}
- (int)fileDescriptorForReading
{
- return [_decompressedStream fileDescriptorForReading];
+ return ((id <OFReadyForReadingObserving>)_decompressedStream)
+ .fileDescriptorForReading;
}
- (void)of_skip
{
- OF_KINDOF(OFStream *) stream;
+ OFStream *stream;
uint32_t toRead;
if (_stream == nil || _skipped)
@@ -383,18 +385,19 @@
*/
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];
@@ -427,7 +430,7 @@
@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
{
@@ -479,8 +482,8 @@
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;
}
@@ -496,12 +499,13 @@
if (_stream == nil)
@throw [OFNotOpenException exceptionWithObject: self];
- return [_stream isAtEndOfStream];
+ return _stream.atEndOfStream;
}
- (int)fileDescriptorForWriting
{
- return [_stream fileDescriptorForWriting];
+ return ((id <OFReadyForWritingObserving>)_stream)
+ .fileDescriptorForWriting;
}
- (void)close
@@ -511,9 +515,9 @@
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];
diff --git a/src/OFLHAArchiveEntry.m b/src/OFLHAArchiveEntry.m
index 2e5227d7..5a3ae089 100644
--- a/src/OFLHAArchiveEntry.m
+++ b/src/OFLHAArchiveEntry.m
@@ -64,7 +64,7 @@ parseFileNameExtension(OFLHAArchiveEntry *entry, OFData *extension,
entry->_fileName = nil;
entry->_fileName = [[OFString alloc]
- initWithCString: (char *)[extension items] + 1
+ initWithCString: (char *)extension.items + 1
encoding: encoding
length: [extension count] - 1];
}
@@ -75,8 +75,8 @@ parseDirectoryNameExtension(OFLHAArchiveEntry *entry, OFData *extension,
{
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++)
@@ -108,9 +108,9 @@ parseCommentExtension(OFLHAArchiveEntry *entry, OFData *extension,
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
@@ -119,10 +119,10 @@ parsePermissionsExtension(OFLHAArchiveEntry *entry, OFData *extension,
{
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];
@@ -137,13 +137,13 @@ parseGIDUIDExtension(OFLHAArchiveEntry *entry, OFData *extension,
{
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];
@@ -164,9 +164,9 @@ parseGroupExtension(OFLHAArchiveEntry *entry, OFData *extension,
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
@@ -177,9 +177,9 @@ parseOwnerExtension(OFLHAArchiveEntry *entry, OFData *extension,
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
@@ -188,10 +188,10 @@ parseModificationDateExtension(OFLHAArchiveEntry *entry, OFData *extension,
{
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];
@@ -291,8 +291,8 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
[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++) {
@@ -595,7 +595,7 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
[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)];
@@ -657,7 +657,7 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
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)];
}
@@ -671,11 +671,11 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
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)];
}
@@ -717,15 +717,15 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
[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)
@@ -734,24 +734,25 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
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];
@@ -761,10 +762,9 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
- (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:
@@ -786,7 +786,7 @@ getFileNameAndDirectoryName(OFLHAArchiveEntry *entry,
@"\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];
diff --git a/src/OFLHAArchive_LHStream.h b/src/OFLHAArchive_LHStream.h
index 7dcd7deb..221d5e9b 100644
--- a/src/OFLHAArchive_LHStream.h
+++ b/src/OFLHAArchive_LHStream.h
@@ -24,7 +24,7 @@ OF_ASSUME_NONNULL_BEGIN
@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;
@@ -45,7 +45,7 @@ OF_ASSUME_NONNULL_BEGIN
uint32_t _distance;
}
-- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)of_initWithStream: (OFStream *)stream
distanceBits: (uint8_t)distanceBits
dictionaryBits: (uint8_t)dictionaryBits;
@end
diff --git a/src/OFLHAArchive_LHStream.m b/src/OFLHAArchive_LHStream.m
index cc974bc2..4455044d 100644
--- a/src/OFLHAArchive_LHStream.m
+++ b/src/OFLHAArchive_LHStream.m
@@ -90,7 +90,7 @@ tryReadBits(OFLHAArchive_LHStream *stream, uint16_t *bits, uint8_t count)
}
@implementation OFLHAArchive_LHStream
-- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)of_initWithStream: (OFStream *)stream
distanceBits: (uint8_t)distanceBits
dictionaryBits: (uint8_t)dictionaryBits
{
@@ -141,7 +141,7 @@ tryReadBits(OFLHAArchive_LHStream *stream, uint16_t *bits, uint8_t count)
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;
@@ -494,18 +494,19 @@ start:
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 <OFReadyForReadingObserving>)_stream)
+ .fileDescriptorForReading;
}
- (bool)hasDataInReadBuffer
{
- return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer] ||
+ return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer ||
_bufferLength - _bufferIndex > 0);
}
diff --git a/src/OFList.m b/src/OFList.m
index 09c7679d..85d0fe5e 100644
--- a/src/OFList.m
+++ b/src/OFList.m
@@ -44,15 +44,15 @@
@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);
}
@@ -216,10 +216,10 @@
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])
@@ -356,7 +356,7 @@
- (OFXMLElement *)XMLElementBySerializing
{
OFXMLElement *element =
- [OFXMLElement elementWithName: [self className]
+ [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS];
for (of_list_object_t *iter = _firstListObject;
@@ -415,7 +415,7 @@
self = [super init];
_list = [list retain];
- _current = [list firstListObject];
+ _current = _list.firstListObject;
_mutations = *mutationsPtr;
_mutationsPtr = mutationsPtr;
@@ -452,6 +452,6 @@
@throw [OFEnumerationMutationException
exceptionWithObject: _list];
- _current = [_list firstListObject];
+ _current = _list.firstListObject;
}
@end
diff --git a/src/OFLocale.m b/src/OFLocale.m
index e75b2e9c..9d3d5a31 100644
--- a/src/OFLocale.m
+++ b/src/OFLocale.m
@@ -149,22 +149,22 @@ parseLocale(char *locale, of_string_encoding_t *encoding,
+ (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
@@ -184,7 +184,7 @@ parseLocale(char *locale, of_string_encoding_t *encoding,
if (currentLocale != nil)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
_encoding = OF_STRING_ENCODING_UTF_8;
_decimalPoint = @".";
@@ -323,16 +323,15 @@ parseLocale(char *locale, of_string_encoding_t *encoding,
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);
@@ -389,8 +388,8 @@ parseLocale(char *locale, of_string_encoding_t *encoding,
}
if (UTF8String == NULL) {
- UTF8String = [fallback UTF8String];
- UTF8StringLength = [fallback UTF8StringLength];
+ UTF8String = fallback.UTF8String;
+ UTF8StringLength = fallback.UTF8StringLength;
}
state = 0;
diff --git a/src/OFMD5Hash.m b/src/OFMD5Hash.m
index 5484199d..297edc28 100644
--- a/src/OFMD5Hash.m
+++ b/src/OFMD5Hash.m
@@ -144,7 +144,7 @@ processBlock(uint32_t *state, uint32_t *buffer)
@try {
_iVarsData = [[OFSecureData alloc]
initWithCount: sizeof(*_iVars)];
- _iVars = [_iVarsData items];
+ _iVars = _iVarsData.mutableItems;
[self of_resetState];
} @catch (id e) {
@@ -172,7 +172,7 @@ processBlock(uint32_t *state, uint32_t *buffer)
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;
diff --git a/src/OFMessagePackExtension.m b/src/OFMessagePackExtension.m
index ec334cf6..436c1352 100644
--- a/src/OFMessagePackExtension.m
+++ b/src/OFMessagePackExtension.m
@@ -44,7 +44,7 @@
self = [super init];
@try {
- if (data == nil || [data itemSize] != 1)
+ if (data == nil || data.itemSize != 1)
@throw [OFInvalidArgumentException exception];
_type = type;
@@ -68,7 +68,7 @@
{
OFMutableData *ret;
uint8_t prefix;
- size_t count = [_data count];
+ size_t count = _data.count;
if (count == 1) {
ret = [OFMutableData dataWithCapacity: 3];
@@ -145,8 +145,8 @@
[ret addItem: &_type];
}
- [ret addItems: [_data items]
- count: [_data count]];
+ [ret addItems: _data.items
+ count: _data.count];
[ret makeImmutable];
@@ -184,7 +184,7 @@
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);
diff --git a/src/OFMethodSignature.m b/src/OFMethodSignature.m
index a010882f..785f5321 100644
--- a/src/OFMethodSignature.m
+++ b/src/OFMethodSignature.m
@@ -679,17 +679,17 @@ of_alignof_type_encoding(const char *type)
- (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
diff --git a/src/OFMutableArray.m b/src/OFMutableArray.m
index 60ee9c9b..5a068c5b 100644
--- a/src/OFMutableArray.m
+++ b/src/OFMutableArray.m
@@ -260,13 +260,13 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
- (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
@@ -306,7 +306,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
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]) {
@@ -325,7 +325,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
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) {
@@ -349,7 +349,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
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]) {
@@ -367,7 +367,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
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) {
@@ -386,7 +386,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
- (void)removeLastObject
{
- size_t count = [self count];
+ size_t count = self.count;
if (count == 0)
return;
@@ -396,7 +396,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
- (void)removeAllObjects
{
- [self removeObjectsInRange: of_range(0, [self count])];
+ [self removeObjectsInRange: of_range(0, self.count)];
}
#ifdef OF_HAVE_BLOCKS
@@ -439,7 +439,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
- (void)sortUsingSelector: (SEL)selector
options: (int)options
{
- size_t count = [self count];
+ size_t count = self.count;
if (count == 0 || count == 1)
return;
@@ -451,7 +451,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
- (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;
@@ -462,7 +462,7 @@ quicksortWithBlock(OFMutableArray *array, size_t left, size_t right,
- (void)reverse
{
- size_t i, j, count = [self count];
+ size_t i, j, count = self.count;
if (count == 0 || count == 1)
return;
diff --git a/src/OFMutableArray_adjacent.m b/src/OFMutableArray_adjacent.m
index fb655ac0..95294eff 100644
--- a/src/OFMutableArray_adjacent.m
+++ b/src/OFMutableArray_adjacent.m
@@ -80,8 +80,8 @@
- (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
@@ -106,8 +106,8 @@
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]) {
@@ -129,9 +129,9 @@
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];
@@ -148,8 +148,8 @@
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) {
@@ -164,14 +164,14 @@
- (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]) {
@@ -189,14 +189,14 @@
- (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) {
@@ -223,8 +223,8 @@
- (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];
@@ -234,8 +234,9 @@
- (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)
@@ -259,7 +260,7 @@
- (void)removeLastObject
{
#ifndef __clang_analyzer__
- size_t count = [_array count];
+ size_t count = _array.count;
id object;
if (count == 0)
@@ -276,8 +277,8 @@
- (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)
@@ -290,8 +291,8 @@
- (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;
@@ -307,7 +308,7 @@
objects: (id *)objects
count: (int)count_
{
- size_t count = [_array count];
+ size_t count = _array.count;
if (count > INT_MAX) {
/*
@@ -326,7 +327,7 @@
return 0;
state->state = (unsigned long)count;
- state->itemsPtr = [_array items];
+ state->itemsPtr = _array.items;
state->mutationsPtr = &_mutations;
return (int)count;
@@ -342,8 +343,8 @@
#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;
@@ -358,8 +359,8 @@
- (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++) {
diff --git a/src/OFMutableData.h b/src/OFMutableData.h
index 3f6d68ae..adde18ac 100644
--- a/src/OFMutableData.h
+++ b/src/OFMutableData.h
@@ -33,6 +33,16 @@ OF_ASSUME_NONNULL_BEGIN
}
/*!
+ * @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
@@ -107,6 +117,17 @@ OF_ASSUME_NONNULL_BEGIN
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
@@ -180,52 +201,4 @@ OF_ASSUME_NONNULL_BEGIN
- (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
diff --git a/src/OFMutableData.m b/src/OFMutableData.m
index f7892113..9f7179bc 100644
--- a/src/OFMutableData.m
+++ b/src/OFMutableData.m
@@ -142,6 +142,19 @@
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 ||
diff --git a/src/OFMutableDictionary.m b/src/OFMutableDictionary.m
index 30e92580..c222ad93 100644
--- a/src/OFMutableDictionary.m
+++ b/src/OFMutableDictionary.m
@@ -187,7 +187,7 @@ static struct {
{
void *pool = objc_autoreleasePoolPush();
- for (id key in [self allKeys])
+ for (id key in self.allKeys)
[self removeObjectForKey: key];
objc_autoreleasePoolPop(pool);
diff --git a/src/OFMutableSet.m b/src/OFMutableSet.m
index 6e15b9c9..5c3e3c69 100644
--- a/src/OFMutableSet.m
+++ b/src/OFMutableSet.m
@@ -169,7 +169,7 @@ static struct {
- (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)
diff --git a/src/OFMutableString.m b/src/OFMutableString.m
index c5df8a88..0764720a 100644
--- a/src/OFMutableString.m
+++ b/src/OFMutableString.m
@@ -239,14 +239,14 @@ static struct {
}
#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++) {
@@ -276,8 +276,8 @@ static struct {
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++) {
@@ -314,7 +314,7 @@ static struct {
- (void)appendString: (OFString *)string
{
[self insertString: string
- atIndex: [self length]];
+ atIndex: self.length];
}
- (void)appendCharacters: (const of_unichar_t *)characters
@@ -391,7 +391,7 @@ static struct {
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];
@@ -411,7 +411,7 @@ static struct {
- (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];
@@ -491,7 +491,7 @@ static struct {
[self replaceOccurrencesOfString: string
withString: replacement
options: 0
- range: of_range(0, [self length])];
+ range: of_range(0, self.length)];
}
- (void)replaceOccurrencesOfString: (OFString *)string
@@ -501,15 +501,15 @@ static struct {
{
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) {
@@ -518,7 +518,7 @@ static struct {
}
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,
@@ -536,7 +536,7 @@ static struct {
objc_autoreleasePoolPop(pool2);
pool2 = objc_autoreleasePoolPush();
- characters = [self characters];
+ characters = self.characters;
}
objc_autoreleasePoolPop(pool);
@@ -545,8 +545,8 @@ static struct {
- (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];
@@ -566,13 +566,13 @@ static struct {
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--) {
diff --git a/src/OFMutableString_UTF8.m b/src/OFMutableString_UTF8.m
index 05d32a05..2e4957fb 100644
--- a/src/OFMutableString_UTF8.m
+++ b/src/OFMutableString_UTF8.m
@@ -104,7 +104,7 @@
return;
}
- unicodeLen = [self length];
+ unicodeLen = self.length;
unicodeString = [self allocMemoryWithSize: sizeof(of_unichar_t)
count: unicodeLen];
@@ -360,17 +360,17 @@
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;
@@ -431,7 +431,7 @@
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];
@@ -535,19 +535,19 @@
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]]) {
@@ -600,7 +600,7 @@
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,
@@ -610,7 +610,7 @@
}
newCStringLength = _s->cStringLength - (end - start) +
- [replacement UTF8StringLength];
+ replacement.UTF8StringLength;
_s->hashed = false;
/*
@@ -625,10 +625,10 @@
_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';
/*
@@ -655,10 +655,10 @@
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;
@@ -666,7 +666,7 @@
@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) {
@@ -677,7 +677,7 @@
_s->cStringLength - range.location);
}
- if ([string UTF8StringLength] > range.length)
+ if (string.UTF8StringLength > range.length)
return;
newCString = NULL;
@@ -690,10 +690,10 @@
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;
@@ -704,7 +704,7 @@
replacementString, replacementLength);
newCStringLength += i - last + replacementLength;
- newLength = newLength - [string length] + [replacement length];
+ newLength = newLength - string.length + replacement.length;
i += searchLength - 1;
last = i + 1;
diff --git a/src/OFMutableURL.m b/src/OFMutableURL.m
index 38224423..9b211663 100644
--- a/src/OFMutableURL.m
+++ b/src/OFMutableURL.m
@@ -179,17 +179,17 @@ extern void of_url_verify_escaped(OFString *, OFCharacterSet *);
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);
}
@@ -271,29 +271,29 @@ extern void of_url_verify_escaped(OFString *, OFCharacterSet *);
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)];
@@ -310,7 +310,7 @@ extern void of_url_verify_escaped(OFString *, OFCharacterSet *);
[array addObject: @""];
path = [array componentsJoinedByString: @"/"];
- if ([path length] == 0)
+ if (path.length == 0)
path = @"/";
[self setURLEncodedPath: path];
diff --git a/src/OFMutableZIPArchiveEntry.m b/src/OFMutableZIPArchiveEntry.m
index 3fa9102b..b47251f3 100644
--- a/src/OFMutableZIPArchiveEntry.m
+++ b/src/OFMutableZIPArchiveEntry.m
@@ -46,7 +46,7 @@
void *pool = objc_autoreleasePoolPush();
OFString *old;
- if ([fileName UTF8StringLength] > UINT16_MAX)
+ if (fileName.UTF8StringLength > UINT16_MAX)
@throw [OFOutOfRangeException exception];
old = _fileName;
@@ -61,7 +61,7 @@
void *pool = objc_autoreleasePoolPush();
OFString *old;
- if ([fileComment UTF8StringLength] > UINT16_MAX)
+ if (fileComment.UTF8StringLength > UINT16_MAX)
@throw [OFOutOfRangeException exception];
old = _fileComment;
@@ -76,10 +76,10 @@
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;
@@ -103,11 +103,11 @@
{
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);
}
diff --git a/src/OFMutex.m b/src/OFMutex.m
index 32d6bf9a..130c0f4c 100644
--- a/src/OFMutex.m
+++ b/src/OFMutex.m
@@ -38,7 +38,7 @@
self = [super init];
if (!of_mutex_new(&_mutex)) {
- Class c = [self class];
+ Class c = self.class;
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
@@ -79,9 +79,8 @@
- (OFString *)description
{
if (_name == nil)
- return [super description];
+ return super.description;
- return [OFString stringWithFormat: @"<%@: %@>",
- [self className], _name];
+ return [OFString stringWithFormat: @"<%@: %@>", self.className, _name];
}
@end
diff --git a/src/OFNull.m b/src/OFNull.m
index 43829983..87231938 100644
--- a/src/OFNull.m
+++ b/src/OFNull.m
@@ -50,8 +50,8 @@ static OFNull *null = nil;
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);
@@ -74,7 +74,7 @@ static OFNull *null = nil;
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
- element = [OFXMLElement elementWithName: [self className]
+ element = [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS];
[element retain];
diff --git a/src/OFNumber.m b/src/OFNumber.m
index 7c188b4c..396e419c 100644
--- a/src/OFNumber.m
+++ b/src/OFNumber.m
@@ -532,11 +532,11 @@
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;
@@ -553,10 +553,10 @@
* 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;
@@ -564,7 +564,7 @@
} 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);
@@ -575,7 +575,7 @@
} 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);
@@ -986,8 +986,8 @@
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;
@@ -999,9 +999,9 @@
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 <OFComparing>)object
@@ -1015,8 +1015,8 @@
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;
@@ -1026,8 +1026,8 @@
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;
@@ -1036,8 +1036,8 @@
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;
@@ -1054,20 +1054,20 @@
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;
}
}
@@ -1080,15 +1080,15 @@
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);
@@ -1097,7 +1097,7 @@
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);
@@ -1134,7 +1134,7 @@
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:
@@ -1148,7 +1148,7 @@
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_];
@@ -1177,9 +1177,9 @@
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:
@@ -1227,9 +1227,9 @@
[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:;
@@ -1242,9 +1242,9 @@
[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:
@@ -1278,7 +1278,7 @@
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)
@@ -1289,7 +1289,7 @@
@throw [OFInvalidArgumentException exception];
}
- return [self description];
+ return self.description;
}
- (OFData *)messagePackRepresentation
@@ -1322,7 +1322,7 @@
[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);
@@ -1371,7 +1371,7 @@
} 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);
diff --git a/src/OFObject+KeyValueCoding.m b/src/OFObject+KeyValueCoding.m
index 21bf1cd0..4d17fb2f 100644
--- a/src/OFObject+KeyValueCoding.m
+++ b/src/OFObject+KeyValueCoding.m
@@ -34,7 +34,7 @@ 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;
@@ -43,7 +43,7 @@ int _OFObject_KeyValueCoding_reference;
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)
@@ -52,7 +52,7 @@ int _OFObject_KeyValueCoding_reference;
@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]);
@@ -67,19 +67,19 @@ int _OFObject_KeyValueCoding_reference;
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];
@@ -128,7 +128,7 @@ int _OFObject_KeyValueCoding_reference;
OFMethodSignature *methodSignature;
const char *valueType;
- if ((keyLength = [key UTF8StringLength]) < 1) {
+ if ((keyLength = key.UTF8StringLength) < 1) {
[self setValue: value
forUndefinedKey: key];
return;
@@ -140,7 +140,7 @@ int _OFObject_KeyValueCoding_reference;
@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]);
@@ -153,8 +153,8 @@ int _OFObject_KeyValueCoding_reference;
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
diff --git a/src/OFObject+Serialization.m b/src/OFObject+Serialization.m
index 474e899b..4c45d9b8 100644
--- a/src/OFObject+Serialization.m
+++ b/src/OFObject+Serialization.m
@@ -41,7 +41,7 @@ int _OFObject_Serialization_reference;
}
pool = objc_autoreleasePoolPush();
- element = [(id)self XMLElementBySerializing];
+ element = ((id <OFSerialization>)self).XMLElementBySerializing;
root = [OFXMLElement elementWithName: @"serialization"
namespace: OF_SERIALIZATION_NS];
diff --git a/src/OFObject.m b/src/OFObject.m
index 25207440..9a043716 100644
--- a/src/OFObject.m
+++ b/src/OFObject.m
@@ -676,7 +676,7 @@ _references_to_categories_of_OFObject(void)
target: self
selector: selector
repeats: false];
- [[thread runLoop] addTimer: timer];
+ [thread.runLoop addTimer: timer];
if (waitUntilDone)
[timer waitUntilDone];
@@ -695,7 +695,7 @@ _references_to_categories_of_OFObject(void)
selector: selector
object: object
repeats: false];
- [[thread runLoop] addTimer: timer];
+ [thread.runLoop addTimer: timer];
if (waitUntilDone)
[timer waitUntilDone];
@@ -716,7 +716,7 @@ _references_to_categories_of_OFObject(void)
object: object1
object: object2
repeats: false];
- [[thread runLoop] addTimer: timer];
+ [thread.runLoop addTimer: timer];
if (waitUntilDone)
[timer waitUntilDone];
@@ -739,7 +739,7 @@ _references_to_categories_of_OFObject(void)
object: object2
object: object3
repeats: false];
- [[thread runLoop] addTimer: timer];
+ [thread.runLoop addTimer: timer];
if (waitUntilDone)
[timer waitUntilDone];
@@ -764,7 +764,7 @@ _references_to_categories_of_OFObject(void)
object: object3
object: object4
repeats: false];
- [[thread runLoop] addTimer: timer];
+ [thread.runLoop addTimer: timer];
if (waitUntilDone)
[timer waitUntilDone];
@@ -878,10 +878,10 @@ _references_to_categories_of_OFObject(void)
{
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);
}
@@ -893,11 +893,11 @@ _references_to_categories_of_OFObject(void)
{
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);
}
@@ -910,12 +910,12 @@ _references_to_categories_of_OFObject(void)
{
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);
}
@@ -929,13 +929,13 @@ _references_to_categories_of_OFObject(void)
{
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);
}
@@ -950,14 +950,14 @@ _references_to_categories_of_OFObject(void)
{
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);
}
@@ -1000,7 +1000,7 @@ _references_to_categories_of_OFObject(void)
{
/* Classes containing data should reimplement this! */
- return [OFString stringWithFormat: @"<%@>", [self className]];
+ return [OFString stringWithFormat: @"<%@>", self.className];
}
- (void *)allocMemoryWithSize: (size_t)size
diff --git a/src/OFOptionsParser.m b/src/OFOptionsParser.m
index 163a002c..a1b7ff98 100644
--- a/src/OFOptionsParser.m
+++ b/src/OFOptionsParser.m
@@ -27,7 +27,7 @@
static uint32_t
stringHash(void *object)
{
- return [(OFString *)object hash];
+ return ((OFString *)object).hash;
}
static bool
@@ -165,7 +165,7 @@ stringEqual(void *object1, void *object2)
of_options_parser_option_t *iter;
OFString *argument;
- if (_done || _index >= [_arguments count])
+ if (_done || _index >= _arguments.count)
return '\0';
[_lastLongOption release];
@@ -176,7 +176,7 @@ stringEqual(void *object1, void *object2)
argument = [_arguments objectAtIndex: _index];
if (_subIndex == 0) {
- if ([argument length] < 2 ||
+ if (argument.length < 2 ||
[argument characterAtIndex: 0] != '-') {
_done = true;
return '\0';
@@ -199,11 +199,11 @@ stringEqual(void *object1, void *object2)
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];
@@ -236,7 +236,7 @@ stringEqual(void *object1, void *object2)
_lastOption = [argument characterAtIndex: _subIndex++];
- if (_subIndex >= [argument length]) {
+ if (_subIndex >= argument.length) {
_index++;
_subIndex = 0;
}
@@ -251,12 +251,12 @@ stringEqual(void *object1, void *object2)
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];
@@ -279,6 +279,6 @@ stringEqual(void *object1, void *object2)
- (OFArray *)remainingArguments
{
return [_arguments objectsInRange:
- of_range(_index, [_arguments count] - _index)];
+ of_range(_index, _arguments.count - _index)];
}
@end
diff --git a/src/OFPlugin.m b/src/OFPlugin.m
index 32da8634..40f187a0 100644
--- a/src/OFPlugin.m
+++ b/src/OFPlugin.m
@@ -42,7 +42,7 @@ of_dlopen(OFString *path, int flags)
if (path == nil)
return GetModuleHandle(NULL);
- return LoadLibraryW([path UTF16String]);
+ return LoadLibraryW(path.UTF16String);
#endif
}
@@ -87,10 +87,10 @@ of_dlerror(void)
#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
diff --git a/src/OFProcess.m b/src/OFProcess.m
index 58a8d86e..5aa34eac 100644
--- a/src/OFProcess.m
+++ b/src/OFProcess.m
@@ -143,7 +143,7 @@ extern char **environ;
if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
path = [program cStringWithEncoding: [OFLocale encoding]];
[self of_getArgv: &argv
@@ -159,13 +159,13 @@ extern char **environ;
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 {
@@ -178,19 +178,19 @@ extern char **environ;
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);
@@ -210,7 +210,7 @@ extern char **environ;
if (_pid == -1)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
# endif
} @finally {
close(_readPipe[1]);
@@ -234,20 +234,20 @@ extern char **environ;
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));
@@ -293,19 +293,19 @@ extern char **environ;
[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];
}
@@ -338,8 +338,8 @@ extern char **environ;
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 *)
@@ -368,7 +368,7 @@ extern char **environ;
encoding = [OFLocale encoding];
- count = [environment count];
+ count = environment.count;
envp = [self allocMemoryWithSize: sizeof(char *)
count: count + 1];
@@ -417,19 +417,19 @@ extern char **environ;
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
diff --git a/src/OFRIPEMD160Hash.m b/src/OFRIPEMD160Hash.m
index 3cb99865..cea73035 100644
--- a/src/OFRIPEMD160Hash.m
+++ b/src/OFRIPEMD160Hash.m
@@ -158,7 +158,7 @@ processBlock(uint32_t *state, uint32_t *buffer)
@try {
_iVarsData = [[OFSecureData alloc]
initWithCount: sizeof(*_iVars)];
- _iVars = [_iVarsData items];
+ _iVars = _iVarsData.mutableItems;
[self of_resetState];
} @catch (id e) {
@@ -186,7 +186,7 @@ processBlock(uint32_t *state, uint32_t *buffer)
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;
diff --git a/src/OFRecursiveMutex.m b/src/OFRecursiveMutex.m
index d5993a69..e9b87bec 100644
--- a/src/OFRecursiveMutex.m
+++ b/src/OFRecursiveMutex.m
@@ -38,7 +38,7 @@
self = [super init];
if (!of_rmutex_new(&_rmutex)) {
- Class c = [self class];
+ Class c = self.class;
[self release];
@throw [OFInitializationFailedException exceptionWithClass: c];
}
@@ -79,9 +79,8 @@
- (OFString *)description
{
if (_name == nil)
- return [super description];
+ return super.description;
- return [OFString stringWithFormat: @"<%@: %@>",
- [self className], _name];
+ return [OFString stringWithFormat: @"<%@: %@>", self.className, _name];
}
@end
diff --git a/src/OFRunLoop+Private.h b/src/OFRunLoop+Private.h
index bdcdfee9..254e5efb 100644
--- a/src/OFRunLoop+Private.h
+++ b/src/OFRunLoop+Private.h
@@ -28,7 +28,7 @@ OF_ASSUME_NONNULL_BEGIN
#ifdef OF_HAVE_SOCKETS
@protocol OFTCPSocketDelegate_Private <OFObject>
-- (void)of_socketDidConnect: (OF_KINDOF(OFTCPSocket *))socket
+- (void)of_socketDidConnect: (OFTCPSocket *)socket
exception: (nullable id)exception;
@end
#endif
diff --git a/src/OFRunLoop.m b/src/OFRunLoop.m
index ff7cfada..3582091c 100644
--- a/src/OFRunLoop.m
+++ b/src/OFRunLoop.m
@@ -183,7 +183,7 @@ static OFRunLoop *mainRunLoop = nil;
#if defined(OF_HAVE_SOCKETS)
_kernelEventObserver = [[OFKernelEventObserver alloc] init];
- [_kernelEventObserver setDelegate: self];
+ _kernelEventObserver.delegate = self;
_readQueues = [[OFMutableDictionary alloc] init];
_writeQueues = [[OFMutableDictionary alloc] init];
@@ -225,8 +225,8 @@ static OFRunLoop *mainRunLoop = nil;
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]
@@ -244,7 +244,7 @@ static OFRunLoop *mainRunLoop = nil;
[queue removeListObject: listObject];
- if ([queue count] == 0) {
+ if (queue.count == 0) {
[_kernelEventObserver
removeObjectForReading: object];
[_readQueues
@@ -268,8 +268,8 @@ static OFRunLoop *mainRunLoop = nil;
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]
@@ -287,7 +287,7 @@ static OFRunLoop *mainRunLoop = nil;
[queue removeListObject: listObject];
- if ([queue count] == 0) {
+ if (queue.count == 0) {
[_kernelEventObserver
removeObjectForWriting: object];
[_writeQueues
@@ -463,11 +463,11 @@ static OFRunLoop *mainRunLoop = nil;
{
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];
@@ -720,8 +720,8 @@ static OFRunLoop *mainRunLoop = 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;
@@ -786,7 +786,7 @@ static OFRunLoop *mainRunLoop = nil;
+ (OFRunLoop *)currentRunLoop
{
#ifdef OF_HAVE_THREADS
- return [[OFThread currentThread] runLoop];
+ return [OFThread currentThread].runLoop;
#else
return [self mainRunLoop];
#endif
@@ -809,10 +809,10 @@ static OFRunLoop *mainRunLoop = nil;
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]; \
\
@@ -831,7 +831,7 @@ static OFRunLoop *mainRunLoop = nil;
forKey: object]; \
} \
\
- if ([queue count] == 0) \
+ if (queue.count == 0) \
[state->_kernelEventObserver \
addObjectForWriting: object]; \
\
@@ -1038,7 +1038,7 @@ static OFRunLoop *mainRunLoop = 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
@@ -1051,7 +1051,7 @@ static OFRunLoop *mainRunLoop = nil;
}
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
@@ -1182,7 +1182,7 @@ static OFRunLoop *mainRunLoop = nil;
#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];
@@ -1206,7 +1206,7 @@ static OFRunLoop *mainRunLoop = nil;
_stop = false;
while (!_stop &&
- (deadline == nil || [deadline timeIntervalSinceNow] >= 0))
+ (deadline == nil || deadline.timeIntervalSinceNow >= 0))
[self runMode: of_run_loop_mode_default
beforeDate: deadline];
}
@@ -1234,10 +1234,10 @@ static OFRunLoop *mainRunLoop = nil;
@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];
@@ -1254,7 +1254,7 @@ static OFRunLoop *mainRunLoop = nil;
}
#endif
- if ([timer isValid]) {
+ if (timer.valid) {
[timer fire];
return;
}
@@ -1277,12 +1277,12 @@ static OFRunLoop *mainRunLoop = 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;
@@ -1292,7 +1292,7 @@ static OFRunLoop *mainRunLoop = nil;
[state->_kernelEventObserver
observeForTimeInterval: timeout];
} @catch (OFObserveFailedException *e) {
- if ([e errNo] != EINTR)
+ if (e.errNo != EINTR)
@throw e;
}
#elif defined(OF_HAVE_THREADS)
@@ -1312,7 +1312,7 @@ static OFRunLoop *mainRunLoop = nil;
@try {
[state->_kernelEventObserver observe];
} @catch (OFObserveFailedException *e) {
- if ([e errNo] != EINTR)
+ if (e.errNo != EINTR)
@throw e;
}
#elif defined(OF_HAVE_THREADS)
diff --git a/src/OFSHA1Hash.m b/src/OFSHA1Hash.m
index 26437d78..6a5aba92 100644
--- a/src/OFSHA1Hash.m
+++ b/src/OFSHA1Hash.m
@@ -118,7 +118,7 @@ processBlock(uint32_t *state, uint32_t *buffer)
@try {
_iVarsData = [[OFSecureData alloc]
initWithCount: sizeof(*_iVars)];
- _iVars = [_iVarsData items];
+ _iVars = _iVarsData.mutableItems;
[self of_resetState];
} @catch (id e) {
@@ -146,7 +146,7 @@ processBlock(uint32_t *state, uint32_t *buffer)
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;
diff --git a/src/OFSHA224Or256Hash.m b/src/OFSHA224Or256Hash.m
index 694db048..decd327e 100644
--- a/src/OFSHA224Or256Hash.m
+++ b/src/OFSHA224Or256Hash.m
@@ -140,9 +140,9 @@ processBlock(uint32_t *state, uint32_t *buffer)
@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();
}
@@ -173,7 +173,7 @@ processBlock(uint32_t *state, uint32_t *buffer)
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;
diff --git a/src/OFSHA384Or512Hash.m b/src/OFSHA384Or512Hash.m
index cdad5895..d5a4c775 100644
--- a/src/OFSHA384Or512Hash.m
+++ b/src/OFSHA384Or512Hash.m
@@ -151,9 +151,9 @@ processBlock(uint64_t *state, uint64_t *buffer)
@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();
}
@@ -184,7 +184,7 @@ processBlock(uint64_t *state, uint64_t *buffer)
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;
diff --git a/src/OFSecureData.h b/src/OFSecureData.h
index 572a03d6..fe7039ea 100644
--- a/src/OFSecureData.h
+++ b/src/OFSecureData.h
@@ -38,6 +38,14 @@ OF_ASSUME_NONNULL_BEGIN
#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.
*/
@@ -106,6 +114,17 @@ OF_ASSUME_NONNULL_BEGIN
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
@@ -138,50 +157,4 @@ OF_ASSUME_NONNULL_BEGIN
- (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
diff --git a/src/OFSecureData.m b/src/OFSecureData.m
index aed997d1..dff85391 100644
--- a/src/OFSecureData.m
+++ b/src/OFSecureData.m
@@ -509,6 +509,19 @@ freeMemory(struct page *page, void *pointer, size_t bytes)
[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);
diff --git a/src/OFSet.m b/src/OFSet.m
index 3bbd9c13..6a788435 100644
--- a/src/OFSet.m
+++ b/src/OFSet.m
@@ -219,7 +219,7 @@ static struct {
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);
@@ -227,7 +227,7 @@ static struct {
return [ret autorelease];
}
- ret = [OFMutableSet setWithCapacity: [self count]];
+ ret = [OFMutableSet setWithCapacity: self.count];
for (id object in self) {
id value = [object valueForKey: key];
@@ -247,7 +247,7 @@ static struct {
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];
@@ -289,7 +289,7 @@ static struct {
set = object;
- if ([set count] != [self count])
+ if (set.count != self.count)
return false;
return [set isSubsetOfSet: self];
@@ -312,7 +312,7 @@ static struct {
{
void *pool;
OFMutableString *ret;
- size_t i, count = [self count];
+ size_t i, count = self.count;
if (count == 0)
return @"{()}";
@@ -386,7 +386,7 @@ static struct {
for (id <OFSerialization> object in self) {
void *pool2 = objc_autoreleasePoolPush();
- [element addChild: [object XMLElementBySerializing]];
+ [element addChild: object.XMLElementBySerializing];
objc_autoreleasePoolPop(pool2);
}
diff --git a/src/OFSet_hashtable.m b/src/OFSet_hashtable.m
index 502229e3..a42d3863 100644
--- a/src/OFSet_hashtable.m
+++ b/src/OFSet_hashtable.m
@@ -92,7 +92,7 @@ static const of_map_table_functions_t objectFunctions = { NULL };
return [self init];
@try {
- count = [set count];
+ count = set.count;
} @catch (id e) {
[self release];
@throw e;
@@ -120,7 +120,7 @@ static const of_map_table_functions_t objectFunctions = { NULL };
return self;
@try {
- count = [array count];
+ count = array.count;
} @catch (id e) {
[self release];
@throw e;
@@ -197,9 +197,9 @@ static const of_map_table_functions_t objectFunctions = { NULL };
@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
diff --git a/src/OFSettings_INIFile.m b/src/OFSettings_INIFile.m
index 7f3263c5..ba750ea0 100644
--- a/src/OFSettings_INIFile.m
+++ b/src/OFSettings_INIFile.m
@@ -69,7 +69,7 @@
*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
diff --git a/src/OFStdIOStream.m b/src/OFStdIOStream.m
index 58b51c3d..382d1335 100644
--- a/src/OFStdIOStream.m
+++ b/src/OFStdIOStream.m
@@ -99,7 +99,7 @@ of_log(OFConstantString *format, ...)
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
@@ -110,7 +110,7 @@ of_log(OFConstantString *format, ...)
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);
}
diff --git a/src/OFStdIOStream_Win32Console.m b/src/OFStdIOStream_Win32Console.m
index 6b0bc115..8f5bf008 100644
--- a/src/OFStdIOStream_Win32Console.m
+++ b/src/OFStdIOStream_Win32Console.m
@@ -168,8 +168,8 @@
_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];
@@ -208,8 +208,8 @@
}
if (rest != nil)
- [self unreadFromBuffer: [rest items]
- length: [rest count]];
+ [self unreadFromBuffer: rest.items
+ length: rest.count];
} @finally {
[self freeMemory: UTF16];
}
diff --git a/src/OFStream.h b/src/OFStream.h
index cf05cdb1..c5747b22 100644
--- a/src/OFStream.h
+++ b/src/OFStream.h
@@ -50,9 +50,8 @@ OF_ASSUME_NONNULL_BEGIN
* 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
@@ -65,9 +64,8 @@ typedef bool (^of_stream_async_read_block_t)(
* 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
@@ -82,7 +80,7 @@ typedef bool (^of_stream_async_read_line_block_t)(
* @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);
/*!
@@ -99,7 +97,7 @@ typedef OFData *_Nullable (^of_stream_async_write_data_block_t)(
* @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
@@ -120,7 +118,7 @@ typedef OFString *_Nullable (^of_stream_async_write_string_block_t)(
* @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;
@@ -135,7 +133,7 @@ typedef OFString *_Nullable (^of_stream_async_write_string_block_t)(
* @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;
@@ -151,7 +149,7 @@ typedef OFString *_Nullable (^of_stream_async_write_string_block_t)(
* @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;
@@ -169,7 +167,7 @@ typedef OFString *_Nullable (^of_stream_async_write_string_block_t)(
* @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
diff --git a/src/OFStream.m b/src/OFStream.m
index 11903f85..efcea114 100644
--- a/src/OFStream.m
+++ b/src/OFStream.m
@@ -186,7 +186,7 @@
size_t readLength = 0;
while (readLength < length) {
- if ([self isAtEndOfStream])
+ if (self.atEndOfStream)
@throw [OFTruncatedDataException exception];
readLength += [self readIntoBuffer: (char *)buffer + readLength
@@ -662,7 +662,7 @@
char *buffer = [self allocMemoryWithSize: pageSize];
@try {
- while (![self isAtEndOfStream]) {
+ while (!self.atEndOfStream) {
size_t length;
length = [self readIntoBuffer: buffer
@@ -867,7 +867,7 @@
OFString *line = nil;
while ((line = [self tryReadLineWithEncoding: encoding]) == nil)
- if ([self isAtEndOfStream])
+ if (self.atEndOfStream)
return nil;
return line;
@@ -1114,10 +1114,9 @@
{
OFString *ret = nil;
-
while ((ret = [self tryReadTillDelimiter: delimiter
encoding: encoding]) == nil)
- if ([self isAtEndOfStream])
+ if (self.atEndOfStream)
return nil;
return ret;
@@ -1696,9 +1695,9 @@
@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);
@@ -1782,7 +1781,7 @@
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];
@@ -1814,8 +1813,8 @@
@try {
int readFlags;
- readFlags =
- fcntl([(id)self fileDescriptorForReading], F_GETFL, 0);
+ readFlags = fcntl(((id <OFReadyForReadingObserving>)self)
+ .fileDescriptorForReading, F_GETFL, 0);
readImplemented = true;
@@ -1829,8 +1828,8 @@
else
readFlags |= O_NONBLOCK;
- if (fcntl([(id)self fileDescriptorForReading], F_SETFL,
- readFlags) == -1)
+ if (fcntl(((id <OFReadyForReadingObserving>)self)
+ .fileDescriptorForReading, F_SETFL, readFlags) == -1)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: errno];
@@ -1840,8 +1839,8 @@
@try {
int writeFlags;
- writeFlags =
- fcntl([(id)self fileDescriptorForWriting], F_GETFL, 0);
+ writeFlags = fcntl(((id <OFReadyForWritingObserving>)self)
+ .fileDescriptorForWriting, F_GETFL, 0);
writeImplemented = true;
@@ -1855,8 +1854,8 @@
else
writeFlags |= O_NONBLOCK;
- if (fcntl([(id)self fileDescriptorForWriting], F_SETFL,
- writeFlags) == -1)
+ if (fcntl(((id <OFReadyForWritingObserving>)self)
+ .fileDescriptorForWriting, F_SETFL, writeFlags) == -1)
@throw [OFSetOptionFailedException
exceptionWithObject: self
errNo: errno];
diff --git a/src/OFString+CryptoHashing.m b/src/OFString+CryptoHashing.m
index bc7e0c9f..131c77b8 100644
--- a/src/OFString+CryptoHashing.m
+++ b/src/OFString+CryptoHashing.m
@@ -38,9 +38,9 @@ int _OFString_CryptoHashing_reference;
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;
diff --git a/src/OFString+JSONValue.m b/src/OFString+JSONValue.m
index 9d282601..99abfedf 100644
--- a/src/OFString+JSONValue.m
+++ b/src/OFString+JSONValue.m
@@ -556,17 +556,17 @@ parseNumber(const char **pointer, const char *stop, size_t *line)
@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];
}
@@ -650,8 +650,8 @@ nextObject(const char **pointer, const char *stop, size_t *line,
- (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;
diff --git a/src/OFString+PathAdditions_AmigaOS.m b/src/OFString+PathAdditions_AmigaOS.m
index 58b98bcc..54176b5e 100644
--- a/src/OFString+PathAdditions_AmigaOS.m
+++ b/src/OFString+PathAdditions_AmigaOS.m
@@ -32,7 +32,7 @@ int _OFString_PathAdditions_reference;
bool firstAfterDevice = true;
for (OFString *component in components) {
- if ([component length] == 0)
+ if (component.length == 0)
continue;
if (!firstAfterDevice)
@@ -60,8 +60,8 @@ int _OFString_PathAdditions_reference;
{
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);
@@ -105,7 +105,7 @@ int _OFString_PathAdditions_reference;
* though.
*/
void *pool = objc_autoreleasePoolPush();
- OFString *ret = [[self pathComponents] lastObject];
+ OFString *ret = self.pathComponents.lastObject;
[ret retain];
objc_autoreleasePoolPop(pool);
@@ -118,7 +118,7 @@ int _OFString_PathAdditions_reference;
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) {
@@ -127,7 +127,7 @@ int _OFString_PathAdditions_reference;
}
ret = [fileName substringWithRange:
- of_range(pos + 1, [fileName length] - pos - 1)];
+ of_range(pos + 1, fileName.length - pos - 1)];
[ret retain];
objc_autoreleasePoolPop(pool);
@@ -141,13 +141,13 @@ int _OFString_PathAdditions_reference;
* 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];
}
@@ -157,7 +157,7 @@ int _OFString_PathAdditions_reference;
}
components = [components objectsInRange:
- of_range(0, [components count] - 1)];
+ of_range(0, components.count - 1)];
ret = [OFString pathWithComponents: components];
[ret retain];
@@ -172,12 +172,12 @@ int _OFString_PathAdditions_reference;
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;
@@ -187,7 +187,7 @@ int _OFString_PathAdditions_reference;
}
fileName = [fileName substringWithRange: of_range(0, pos)];
- [components replaceObjectAtIndex: [components count] - 1
+ [components replaceObjectAtIndex: components.count - 1
withObject: fileName];
ret = [OFString pathWithComponents: components];
@@ -205,12 +205,12 @@ int _OFString_PathAdditions_reference;
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];
}
@@ -218,7 +218,7 @@ int _OFString_PathAdditions_reference;
array = [[components mutableCopy] autorelease];
while (!done) {
- size_t length = [array count];
+ size_t length = array.count;
done = true;
@@ -227,7 +227,7 @@ int _OFString_PathAdditions_reference;
OFString *parent =
(i > 0 ? [array objectAtIndex: i - 1] : 0);
- if ([component length] == 0) {
+ if (component.length == 0) {
[array removeObjectAtIndex: i];
done = false;
diff --git a/src/OFString+PathAdditions_DOS.m b/src/OFString+PathAdditions_DOS.m
index 67ff4202..b2cbf86b 100644
--- a/src/OFString+PathAdditions_DOS.m
+++ b/src/OFString+PathAdditions_DOS.m
@@ -32,7 +32,7 @@ int _OFString_PathAdditions_reference;
bool first = true;
for (OFString *component in components) {
- if ([component length] == 0)
+ if (component.length == 0)
continue;
if ([component isEqual: @"\\"] || [component isEqual: @"/"])
@@ -65,8 +65,8 @@ int _OFString_PathAdditions_reference;
{
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);
@@ -105,8 +105,8 @@ int _OFString_PathAdditions_reference;
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);
@@ -153,7 +153,7 @@ int _OFString_PathAdditions_reference;
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) {
@@ -162,7 +162,7 @@ int _OFString_PathAdditions_reference;
}
ret = [fileName substringWithRange:
- of_range(pos + 1, [fileName length] - pos - 1)];
+ of_range(pos + 1, fileName.length - pos - 1)];
[ret retain];
objc_autoreleasePoolPop(pool);
@@ -179,8 +179,8 @@ int _OFString_PathAdditions_reference;
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);
@@ -219,12 +219,12 @@ int _OFString_PathAdditions_reference;
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;
@@ -234,7 +234,7 @@ int _OFString_PathAdditions_reference;
}
fileName = [fileName substringWithRange: of_range(0, pos)];
- [components replaceObjectAtIndex: [components count] - 1
+ [components replaceObjectAtIndex: components.count - 1
withObject: fileName];
ret = [OFString pathWithComponents: components];
@@ -252,12 +252,12 @@ int _OFString_PathAdditions_reference;
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];
}
@@ -265,7 +265,7 @@ int _OFString_PathAdditions_reference;
array = [[components mutableCopy] autorelease];
while (!done) {
- size_t length = [array count];
+ size_t length = array.count;
done = true;
@@ -275,7 +275,7 @@ int _OFString_PathAdditions_reference;
(i > 0 ? [array objectAtIndex: i - 1] : 0);
if ([component isEqual: @"."] ||
- [component length] == 0) {
+ component.length == 0) {
[array removeObjectAtIndex: i];
done = false;
diff --git a/src/OFString+PathAdditions_UNIX.m b/src/OFString+PathAdditions_UNIX.m
index ba51c4a3..08b5578c 100644
--- a/src/OFString+PathAdditions_UNIX.m
+++ b/src/OFString+PathAdditions_UNIX.m
@@ -32,7 +32,7 @@ int _OFString_PathAdditions_reference;
bool first = true;
for (OFString *component in components) {
- if ([component length] == 0)
+ if (component.length == 0)
continue;
if (!first && [component isEqual: @"/"])
@@ -62,8 +62,8 @@ int _OFString_PathAdditions_reference;
{
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);
@@ -96,8 +96,8 @@ int _OFString_PathAdditions_reference;
- (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;
@@ -145,7 +145,7 @@ int _OFString_PathAdditions_reference;
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) {
@@ -154,7 +154,7 @@ int _OFString_PathAdditions_reference;
}
ret = [fileName substringWithRange:
- of_range(pos + 1, [fileName length] - pos - 1)];
+ of_range(pos + 1, fileName.length - pos - 1)];
[ret retain];
objc_autoreleasePoolPop(pool);
@@ -164,8 +164,8 @@ int _OFString_PathAdditions_reference;
- (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) {
@@ -209,12 +209,12 @@ int _OFString_PathAdditions_reference;
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;
@@ -242,12 +242,12 @@ int _OFString_PathAdditions_reference;
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];
}
@@ -259,7 +259,7 @@ int _OFString_PathAdditions_reference;
[array removeObjectAtIndex: 0];
while (!done) {
- size_t length = [array count];
+ size_t length = array.count;
done = true;
@@ -269,7 +269,7 @@ int _OFString_PathAdditions_reference;
(i > 0 ? [array objectAtIndex: i - 1] : 0);
if ([component isEqual: @"."] ||
- [component length] == 0) {
+ component.length == 0) {
[array removeObjectAtIndex: i];
done = false;
diff --git a/src/OFString+PathAdditions_libfat.m b/src/OFString+PathAdditions_libfat.m
index d7acdf46..1dbbd67f 100644
--- a/src/OFString+PathAdditions_libfat.m
+++ b/src/OFString+PathAdditions_libfat.m
@@ -32,7 +32,7 @@ int _OFString_PathAdditions_reference;
bool first = true;
for (OFString *component in components) {
- if ([component length] == 0)
+ if (component.length == 0)
continue;
if ([component isEqual: @"/"])
@@ -65,8 +65,8 @@ int _OFString_PathAdditions_reference;
{
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);
@@ -105,8 +105,8 @@ int _OFString_PathAdditions_reference;
if ([self hasSuffix: @":/"])
return self;
- cString = [self UTF8String];
- cStringLength = [self UTF8StringLength];
+ cString = self.UTF8String;
+ cStringLength = self.UTF8StringLength;
if (cStringLength == 0) {
objc_autoreleasePoolPop(pool);
@@ -152,7 +152,7 @@ int _OFString_PathAdditions_reference;
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) {
@@ -161,7 +161,7 @@ int _OFString_PathAdditions_reference;
}
ret = [fileName substringWithRange:
- of_range(pos + 1, [fileName length] - pos - 1)];
+ of_range(pos + 1, fileName.length - pos - 1)];
[ret retain];
objc_autoreleasePoolPop(pool);
@@ -178,8 +178,8 @@ int _OFString_PathAdditions_reference;
if ([self hasSuffix: @":/"])
return self;
- cString = [self UTF8String];
- cStringLength = [self UTF8StringLength];
+ cString = self.UTF8String;
+ cStringLength = self.UTF8StringLength;
if (cStringLength == 0) {
objc_autoreleasePoolPop(pool);
@@ -217,12 +217,12 @@ int _OFString_PathAdditions_reference;
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;
@@ -232,7 +232,7 @@ int _OFString_PathAdditions_reference;
}
fileName = [fileName substringWithRange: of_range(0, pos)];
- [components replaceObjectAtIndex: [components count] - 1
+ [components replaceObjectAtIndex: components.count - 1
withObject: fileName];
ret = [OFString pathWithComponents: components];
@@ -250,12 +250,12 @@ int _OFString_PathAdditions_reference;
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];
}
@@ -263,7 +263,7 @@ int _OFString_PathAdditions_reference;
array = [[components mutableCopy] autorelease];
while (!done) {
- size_t length = [array count];
+ size_t length = array.count;
done = true;
@@ -273,7 +273,7 @@ int _OFString_PathAdditions_reference;
(i > 0 ? [array objectAtIndex: i - 1] : 0);
if ([component isEqual: @"."] ||
- [component length] == 0) {
+ component.length == 0) {
[array removeObjectAtIndex: i];
done = false;
diff --git a/src/OFString+PropertyListValue.m b/src/OFString+PropertyListValue.m
index ae3bbb93..d92127e1 100644
--- a/src/OFString+PropertyListValue.m
+++ b/src/OFString+PropertyListValue.m
@@ -39,7 +39,7 @@ 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];
@@ -54,22 +54,22 @@ 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];
@@ -82,26 +82,26 @@ parseDictElement(OFXMLElement *element)
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];
@@ -110,7 +110,7 @@ parseTrueElement(OFXMLElement *element)
static OFNumber *
parseFalseElement(OFXMLElement *element)
{
- if ([[element children] count] != 0)
+ if (element.children.count != 0)
@throw [OFInvalidFormatException exception];
return [OFNumber numberWithBool: false];
@@ -119,14 +119,13 @@ parseFalseElement(OFXMLElement *element)
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
@@ -134,11 +133,10 @@ 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);
@@ -171,8 +169,8 @@ parseElement(OFXMLElement *element)
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"];
@@ -180,16 +178,16 @@ parseElement(OFXMLElement *element)
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);
diff --git a/src/OFString+Serialization.m b/src/OFString+Serialization.m
index 30bac15c..1558e81c 100644
--- a/src/OFString+Serialization.m
+++ b/src/OFString+Serialization.m
@@ -48,20 +48,20 @@ int _OFString_Serialization_reference;
@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);
diff --git a/src/OFString+URLEncoding.m b/src/OFString+URLEncoding.m
index 6f2ab8bb..f032c4b0 100644
--- a/src/OFString+URLEncoding.m
+++ b/src/OFString+URLEncoding.m
@@ -36,8 +36,8 @@ int _OFString_URLEncoding_reference;
{
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:)];
@@ -82,8 +82,8 @@ int _OFString_URLEncoding_reference;
- (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;
diff --git a/src/OFString+XMLEscaping.m b/src/OFString+XMLEscaping.m
index fd7ddea4..b60dbe68 100644
--- a/src/OFString+XMLEscaping.m
+++ b/src/OFString+XMLEscaping.m
@@ -37,8 +37,8 @@ int _OFString_XMLEscaping_reference;
size_t j;
OFString *ret;
- string = [self UTF8String];
- length = [self UTF8StringLength];
+ string = self.UTF8String;
+ length = self.UTF8StringLength;
j = 0;
retLength = length;
diff --git a/src/OFString+XMLUnescaping.m b/src/OFString+XMLUnescaping.m
index 4a6aec99..d3f59a9f 100644
--- a/src/OFString+XMLUnescaping.m
+++ b/src/OFString+XMLUnescaping.m
@@ -88,8 +88,8 @@ parseEntities(OFString *self, id (*lookup)(void *, OFString *, OFString *),
pool = objc_autoreleasePoolPush();
- string = [self UTF8String];
- length = [self UTF8StringLength];
+ string = self.UTF8String;
+ length = self.UTF8StringLength;
last = 0;
inEntity = false;
diff --git a/src/OFString.m b/src/OFString.m
index 3cefcefc..9d487496 100644
--- a/src/OFString.m
+++ b/src/OFString.m
@@ -148,7 +148,7 @@ 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;
@@ -340,8 +340,8 @@ 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];
@@ -875,16 +875,16 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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;
}
@@ -997,13 +997,13 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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);
@@ -1080,9 +1080,9 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
@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);
@@ -1095,18 +1095,18 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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;
@@ -1124,8 +1124,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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:;
@@ -1374,7 +1374,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
lossy: (bool)lossy
{
OFObject *object = [[[OFObject alloc] init] autorelease];
- size_t length = [self length];
+ size_t length = self.length;
char *cString;
switch (encoding) {
@@ -1453,8 +1453,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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];
@@ -1481,7 +1481,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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];
}
@@ -1518,15 +1518,15 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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) {
@@ -1563,13 +1563,13 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
@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]) {
@@ -1585,9 +1585,9 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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;
@@ -1602,10 +1602,10 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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);
@@ -1655,8 +1655,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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);
@@ -1665,8 +1665,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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);
@@ -1737,7 +1737,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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] != '$') ||
@@ -1767,7 +1767,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
OFMutableData *data;
size_t length;
- length = [self UTF8StringLength];
+ length = self.UTF8StringLength;
if (length <= 31) {
uint8_t tmp = 0xA0 | ((uint8_t)length & 0x1F);
@@ -1808,7 +1808,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
} else
@throw [OFOutOfRangeException exception];
- [data addItems: [self UTF8String]
+ [data addItems: self.UTF8String
count: length];
return data;
@@ -1818,7 +1818,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
{
return [self rangeOfString: string
options: 0
- range: of_range(0, [self length])];
+ range: of_range(0, self.length)];
}
- (of_range_t)rangeOfString: (OFString *)string
@@ -1826,7 +1826,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
{
return [self rangeOfString: string
options: options
- range: of_range(0, [self length])];
+ range: of_range(0, self.length)];
}
- (of_range_t)rangeOfString: (OFString *)string
@@ -1838,7 +1838,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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)
@@ -1849,7 +1849,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
pool = objc_autoreleasePoolPush();
- searchCharacters = [string characters];
+ searchCharacters = string.characters;
if ((characters = malloc(range.length * sizeof(of_unichar_t))) == NULL)
@throw [OFOutOfMemoryException exceptionWithRequestedSize:
@@ -1896,7 +1896,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
{
return [self indexOfCharacterFromSet: characterSet
options: 0
- range: of_range(0, [self length])];
+ range: of_range(0, self.length)];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
@@ -1904,7 +1904,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
{
return [self indexOfCharacterFromSet: characterSet
options: options
- range: of_range(0, [self length])];
+ range: of_range(0, self.length)];
}
- (size_t)indexOfCharacterFromSet: (OFCharacterSet *)characterSet
@@ -1961,16 +1961,16 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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,
@@ -1991,12 +1991,12 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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);
@@ -2152,11 +2152,10 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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)
@@ -2167,8 +2166,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
[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);
@@ -2186,10 +2184,10 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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];
@@ -2200,7 +2198,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
inRange: of_range(length - suffixLength,
suffixLength)];
- suffixCharacters = [suffix characters];
+ suffixCharacters = suffix.characters;
hasSuffix = (memcmp(tmp, suffixCharacters,
suffixLength * sizeof(of_unichar_t)) == 0);
@@ -2225,15 +2223,15 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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]];
@@ -2251,14 +2249,14 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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];
@@ -2282,8 +2280,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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:)];
@@ -2318,8 +2316,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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;
@@ -2367,8 +2365,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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;
@@ -2430,8 +2428,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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;
@@ -2479,7 +2477,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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)
@@ -2490,16 +2488,16 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
#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;
@@ -2529,7 +2527,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
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)
@@ -2540,16 +2538,16 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
#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;
@@ -2577,7 +2575,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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)
@@ -2597,8 +2595,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
{
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);
@@ -2647,10 +2645,10 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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)
@@ -2667,7 +2665,7 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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)
@@ -2761,8 +2759,8 @@ decomposedString(OFString *self, const char *const *const *table, size_t size)
- (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++) {
diff --git a/src/OFString_UTF8.m b/src/OFString_UTF8.m
index 59f10079..371a39b9 100644
--- a/src/OFString_UTF8.m
+++ b/src/OFString_UTF8.m
@@ -450,7 +450,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
@try {
_s = &_storage;
- _s->cStringLength = [string UTF8StringLength];
+ _s->cStringLength = string.UTF8StringLength;
if ([string isKindOfClass: [OFString_UTF8 class]] ||
[string isKindOfClass: [OFMutableString_UTF8 class]])
@@ -458,10 +458,10 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
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;
@@ -680,7 +680,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
_s = &_storage;
- if ((cStringLength = of_vasprintf(&tmp, [format UTF8String],
+ if ((cStringLength = of_vasprintf(&tmp, format.UTF8String,
arguments)) == -1)
@throw [OFInvalidFormatException exception];
@@ -793,8 +793,8 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
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]] ||
@@ -803,7 +803,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
_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;
@@ -822,11 +822,11 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
@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;
@@ -856,8 +856,8 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
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) {
@@ -947,8 +947,8 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
@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;
}
@@ -985,7 +985,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
{
/* 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)
@@ -1001,8 +1001,8 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
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 ||
@@ -1032,7 +1032,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
cStringLength) == 0) {
range.location += of_string_utf8_get_index(
_s->cString + rangeLocation, i);
- range.length = [string length];
+ range.length = string.length;
return range;
}
@@ -1047,7 +1047,7 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
cStringLength) == 0) {
range.location += of_string_utf8_get_index(
_s->cString + rangeLocation, i);
- range.length = [string length];
+ range.length = string.length;
return range;
}
@@ -1059,8 +1059,8 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
- (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;
@@ -1096,23 +1096,23 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
- (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
@@ -1120,8 +1120,8 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
{
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;
@@ -1143,14 +1143,14 @@ of_string_utf8_get_position(const char *string, size_t idx, size_t length)
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];
diff --git a/src/OFSystemInfo.m b/src/OFSystemInfo.m
index 12561089..70368df2 100644
--- a/src/OFSystemInfo.m
+++ b/src/OFSystemInfo.m
@@ -149,10 +149,11 @@ initOperatingSystemVersion(void)
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);
@@ -177,8 +178,8 @@ initOperatingSystemVersion(void)
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;
@@ -437,7 +438,7 @@ x86_cpuid(uint32_t eax, uint32_t ecx)
void *pool;
if ((var = [env objectForKey: @"XDG_DATA_HOME"]) != nil &&
- [var length] > 0)
+ var.length > 0)
return var;
if ((var = [env objectForKey: @"HOME"]) == nil)
@@ -530,7 +531,7 @@ x86_cpuid(uint32_t eax, uint32_t ecx)
OFString *var;
if ((var = [env objectForKey: @"XDG_CONFIG_HOME"]) != nil &&
- [var length] > 0)
+ var.length > 0)
return var;
if ((var = [env objectForKey: @"HOME"]) == nil)
diff --git a/src/OFTCPSocket.h b/src/OFTCPSocket.h
index 6b5dd6ec..240d9e5a 100644
--- a/src/OFTCPSocket.h
+++ b/src/OFTCPSocket.h
@@ -35,8 +35,8 @@ OF_ASSUME_NONNULL_BEGIN
* @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.
@@ -48,9 +48,8 @@ typedef void (^of_tcp_socket_async_connect_block_t)(
* @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
/*!
@@ -69,7 +68,7 @@ typedef bool (^of_tcp_socket_async_accept_block_t)(
* @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;
@@ -83,8 +82,8 @@ typedef bool (^of_tcp_socket_async_accept_block_t)(
* 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
diff --git a/src/OFTCPSocket.m b/src/OFTCPSocket.m
index 0f5f9964..e92d8c45 100644
--- a/src/OFTCPSocket.m
+++ b/src/OFTCPSocket.m
@@ -138,7 +138,7 @@ static uint16_t defaultSOCKS5Port = 1080;
_SOCKS5Port = SOCKS5Port;
_delegate = [delegate retain];
- [_socket setDelegate: self];
+ _socket.delegate = self;
} @catch (id e) {
[self release];
@throw e;
@@ -176,10 +176,10 @@ static uint16_t defaultSOCKS5Port = 1080;
- (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];
@@ -198,14 +198,14 @@ static uint16_t defaultSOCKS5Port = 1080;
- (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:)])
@@ -218,16 +218,16 @@ static uint16_t defaultSOCKS5Port = 1080;
#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;
@@ -252,7 +252,7 @@ static uint16_t defaultSOCKS5Port = 1080;
if (![_socket of_createSocketForAddress: &address
errNo: &errNo]) {
- if (_socketAddressesIndex >= [_socketAddresses count]) {
+ if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [[OFConnectionFailedException alloc]
initWithHost: _host
port: _port
@@ -277,9 +277,9 @@ static uint16_t defaultSOCKS5Port = 1080;
*
* 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
@@ -294,7 +294,7 @@ static uint16_t defaultSOCKS5Port = 1080;
#endif
[_socket of_closeSocket];
- if (_socketAddressesIndex >= [_socketAddresses count]) {
+ if (_socketAddressesIndex >= _socketAddresses.count) {
_exception = [[OFConnectionFailedException
alloc] initWithHost: _host
port: _port
@@ -312,7 +312,7 @@ static uint16_t defaultSOCKS5Port = 1080;
}
#if defined(OF_NINTENDO_3DS) || defined(OF_WII)
- [_socket setBlocking: false];
+ _socket.blocking = false;
#endif
[self didConnect];
@@ -332,7 +332,7 @@ static uint16_t defaultSOCKS5Port = 1080;
_socketAddresses = [socketAddresses copy];
[self tryNextAddressWithRunLoopMode:
- [[OFRunLoop currentRunLoop] currentMode]];
+ [OFRunLoop currentRunLoop].currentMode];
}
- (void)startWithRunLoopMode: (of_run_loop_mode_t)runLoopMode
@@ -341,7 +341,7 @@ static uint16_t defaultSOCKS5Port = 1080;
uint16_t port;
if (_SOCKS5Host != nil) {
- if ([_host UTF8StringLength] > 255)
+ if (_host.UTF8StringLength > 255)
@throw [OFOutOfRangeException exception];
host = _SOCKS5Host;
@@ -379,10 +379,10 @@ static uint16_t defaultSOCKS5Port = 1080;
_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
@@ -399,7 +399,7 @@ static uint16_t defaultSOCKS5Port = 1080;
return false;
}
- runLoopMode = [[OFRunLoop currentRunLoop] currentMode];
+ runLoopMode = [OFRunLoop currentRunLoop].currentMode;
switch (_SOCKS5State) {
case SOCKS5_STATE_READ_VERSION:
@@ -421,15 +421,15 @@ static uint16_t defaultSOCKS5Port = 1080;
[_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
@@ -535,7 +535,7 @@ static uint16_t defaultSOCKS5Port = 1080;
}
}
-- (OFData *)stream: (OF_KINDOF(OFStream *))sock
+- (OFData *)stream: (OFStream *)sock
didWriteData: (OFData *)data
bytesWritten: (size_t)bytesWritten
exception: (id)exception
@@ -548,7 +548,7 @@ static uint16_t defaultSOCKS5Port = 1080;
return nil;
}
- runLoopMode = [[OFRunLoop currentRunLoop] currentMode];
+ runLoopMode = [OFRunLoop currentRunLoop].currentMode;
switch (_SOCKS5State) {
case SOCKS5_STATE_SEND_AUTHENTICATION:
@@ -581,7 +581,7 @@ static uint16_t defaultSOCKS5Port = 1080;
[super dealloc];
}
-- (void)socket: (OF_KINDOF(OFTCPSocket *))sock
+- (void)socket: (OFTCPSocket *)sock
didConnectToHost: (OFString *)host
port: (uint16_t)port
exception: (id)exception
@@ -708,7 +708,7 @@ static uint16_t defaultSOCKS5Port = 1080;
[[[OFTCPSocket_ConnectDelegate alloc] init] autorelease];
OFRunLoop *runLoop = [OFRunLoop currentRunLoop];
- [self setDelegate: connectDelegate];
+ self.delegate = connectDelegate;
[self asyncConnectToHost: host
port: port
runLoopMode: connectRunLoopMode];
@@ -724,7 +724,7 @@ static uint16_t defaultSOCKS5Port = 1080;
if (connectDelegate->_exception != nil)
@throw connectDelegate->_exception;
- [self setDelegate: delegate];
+ self.delegate = delegate;
objc_autoreleasePoolPop(pool);
}
diff --git a/src/OFTarArchive.h b/src/OFTarArchive.h
index c2f9d261..0a3b980a 100644
--- a/src/OFTarArchive.h
+++ b/src/OFTarArchive.h
@@ -31,14 +31,14 @@ OF_ASSUME_NONNULL_BEGIN
*/
@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;
}
/*!
@@ -67,7 +67,7 @@ OF_ASSUME_NONNULL_BEGIN
* archive.
* @return A new, autoreleased OFTarArchive
*/
-+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
++ (instancetype)archiveWithStream: (OFStream *)stream
mode: (OFString *)mode;
#ifdef OF_HAVE_FILES
@@ -97,7 +97,7 @@ OF_ASSUME_NONNULL_BEGIN
* 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
diff --git a/src/OFTarArchive.m b/src/OFTarArchive.m
index b4018186..61cf7987 100644
--- a/src/OFTarArchive.m
+++ b/src/OFTarArchive.m
@@ -20,9 +20,9 @@
#import "OFTarArchive.h"
#import "OFTarArchiveEntry.h"
#import "OFTarArchiveEntry+Private.h"
-#import "OFStream.h"
-#import "OFSeekableStream.h"
#import "OFDate.h"
+#import "OFSeekableStream.h"
+#import "OFStream.h"
#ifdef OF_HAVE_FILES
# import "OFFile.h"
#endif
@@ -37,7 +37,7 @@
@interface OFTarArchive_FileReadStream: OFStream <OFReadyForReadingObserving>
{
OFTarArchiveEntry *_entry;
- OF_KINDOF(OFStream *) _stream;
+ OFStream *_stream;
uint64_t _toRead;
bool _atEndOfStream, _skipped;
}
@@ -50,18 +50,18 @@
@interface OFTarArchive_FileWriteStream: OFStream <OFReadyForWritingObserving>
{
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
@@ -82,7 +82,7 @@
OF_INVALID_INIT_METHOD
}
-- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode
{
self = [super init];
@@ -109,9 +109,9 @@
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++)
@@ -121,8 +121,8 @@
if (!empty)
@throw [OFInvalidFormatException exception];
- [_stream seekToOffset: -1024
- whence: SEEK_END];
+ [(OFSeekableStream *)stream seekToOffset: -1024
+ whence: SEEK_END];
}
_encoding = OF_STRING_ENCODING_UTF_8;
@@ -177,12 +177,12 @@
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
@@ -222,7 +222,8 @@
if (_lastReturnedStream == nil)
@throw [OFInvalidArgumentException exception];
- return [[_lastReturnedStream retain] autorelease];
+ return [[(OFTarArchive_FileReadStream *)_lastReturnedStream
+ retain] autorelease];
}
- (OFStream <OFReadyForWritingObserving> *)
@@ -249,7 +250,8 @@
objc_autoreleasePoolPop(pool);
- return [[_lastReturnedStream retain] autorelease];
+ return [[(OFTarArchive_FileWriteStream *)_lastReturnedStream
+ retain] autorelease];
}
- (void)close
@@ -283,7 +285,7 @@
@try {
_entry = [entry copy];
_stream = [stream retain];
- _toRead = [entry size];
+ _toRead = entry.size;
} @catch (id e) {
[self release];
@throw e;
@@ -341,12 +343,13 @@
- (bool)hasDataInReadBuffer
{
- return ([super hasDataInReadBuffer] || [_stream hasDataInReadBuffer]);
+ return (super.hasDataInReadBuffer || _stream.hasDataInReadBuffer);
}
- (int)fileDescriptorForReading
{
- return [_stream fileDescriptorForReading];
+ return ((id <OFReadyForReadingObserving>)_stream)
+ .fileDescriptorForReading;
}
- (void)close
@@ -368,16 +371,17 @@
_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;
@@ -394,7 +398,7 @@
_toRead = 0;
}
- size = [_entry size];
+ size = _entry.size;
if (size % 512 != 0)
[_stream readIntoBuffer: buffer
@@ -406,7 +410,7 @@
@end
@implementation OFTarArchive_FileWriteStream
-- (instancetype)of_initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)of_initWithStream: (OFStream *)stream
entry: (OFTarArchiveEntry *)entry
{
self = [super init];
@@ -414,7 +418,7 @@
@try {
_entry = [entry copy];
_stream = [stream retain];
- _toWrite = [entry size];
+ _toWrite = entry.size;
} @catch (id e) {
[self release];
@throw e;
@@ -447,7 +451,7 @@
bytesWritten = [_stream writeBuffer: buffer
length: length];
} @catch (OFWriteFailedException *e) {
- _toWrite -= [e bytesWritten];
+ _toWrite -= e.bytesWritten;
@throw e;
}
@@ -466,7 +470,8 @@
- (int)fileDescriptorForWriting
{
- return [_stream fileDescriptorForWriting];
+ return ((id <OFReadyForWritingObserving>)_stream)
+ .fileDescriptorForWriting;
}
- (void)close
@@ -474,13 +479,13 @@
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];
@@ -488,7 +493,7 @@
[_stream writeInt8: 0];
[_stream flushWriteBuffer];
- [_stream setWriteBuffered: wasWriteBuffered];
+ _stream.writeBuffered = wasWriteBuffered;
}
[_stream release];
diff --git a/src/OFTarArchiveEntry.m b/src/OFTarArchiveEntry.m
index 56f1b130..ec2e3711 100644
--- a/src/OFTarArchiveEntry.m
+++ b/src/OFTarArchiveEntry.m
@@ -65,8 +65,8 @@ octalValueFromBuffer(const unsigned char *buffer, size_t length, uintmax_t max)
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];
@@ -110,7 +110,7 @@ octalValueFromBuffer(const unsigned char *buffer, size_t length, uintmax_t max)
_type = header[156];
targetFileName = stringFromBuffer(header + 157, 100, encoding);
- if ([targetFileName length] > 0)
+ if (targetFileName.length > 0)
_targetFileName = [targetFileName copy];
if (_type == '\0')
@@ -130,7 +130,7 @@ octalValueFromBuffer(const unsigned char *buffer, size_t length, uintmax_t max)
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];
@@ -280,9 +280,8 @@ octalValueFromBuffer(const unsigned char *buffer, size_t length, uintmax_t max)
@"\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];
@@ -311,7 +310,7 @@ octalValueFromBuffer(const unsigned char *buffer, size_t length, uintmax_t max)
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);
diff --git a/src/OFThread.m b/src/OFThread.m
index 358a5b34..b596d75f 100644
--- a/src/OFThread.m
+++ b/src/OFThread.m
@@ -122,11 +122,11 @@ callMain(id object)
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]]);
@@ -298,7 +298,7 @@ static OFDNSResolver *DNSResolver;
+ (void)sleepUntilDate: (OFDate *)date
{
- [self sleepForTimeInterval: [date timeIntervalSinceNow]];
+ [self sleepForTimeInterval: date.timeIntervalSinceNow];
}
+ (void)yield
@@ -345,18 +345,18 @@ static OFDNSResolver *DNSResolver;
+ (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
@@ -376,7 +376,7 @@ static OFDNSResolver *DNSResolver;
@try {
if (!of_thread_attr_init(&_attr))
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
} @catch (id e) {
[self release];
@throw e;
diff --git a/src/OFThreadPool.m b/src/OFThreadPool.m
index 431dd5ee..6b80d971 100644
--- a/src/OFThreadPool.m
+++ b/src/OFThreadPool.m
@@ -169,7 +169,7 @@
return nil;
}
- listObject = [_queue firstListObject];
+ listObject = _queue.firstListObject;
while (listObject == NULL) {
[_queueCondition wait];
@@ -179,7 +179,7 @@
return nil;
}
- listObject = [_queue firstListObject];
+ listObject = _queue.firstListObject;
}
job = [[listObject->object retain] autorelease];
diff --git a/src/OFTimer.m b/src/OFTimer.m
index 663d2fd7..7eb11767 100644
--- a/src/OFTimer.m
+++ b/src/OFTimer.m
@@ -545,7 +545,7 @@
if (_repeats && _valid) {
int64_t missedIntervals =
- -[_fireDate timeIntervalSinceNow] / _interval;
+ -_fireDate.timeIntervalSinceNow / _interval;
of_time_interval_t newFireDate;
OFRunLoop *runLoop;
@@ -553,7 +553,7 @@
if (missedIntervals < 0)
missedIntervals = 0;
- newFireDate = [_fireDate timeIntervalSince1970] +
+ newFireDate = _fireDate.timeIntervalSince1970 +
(missedIntervals + 1) * _interval;
[_fireDate release];
@@ -562,7 +562,7 @@
runLoop = [OFRunLoop currentRunLoop];
[runLoop addTimer: self
- forMode: [runLoop currentMode]];
+ forMode: runLoop.currentMode];
} else
[self invalidate];
diff --git a/src/OFUDPSocket.h b/src/OFUDPSocket.h
index 6e2a79ff..273dc406 100644
--- a/src/OFUDPSocket.h
+++ b/src/OFUDPSocket.h
@@ -76,7 +76,7 @@ typedef OFData *_Nullable (^of_udp_socket_async_send_data_block_t)(
* 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
@@ -91,7 +91,7 @@ typedef OFData *_Nullable (^of_udp_socket_async_send_data_block_t)(
* @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;
diff --git a/src/OFURL.m b/src/OFURL.m
index e483857a..6868130c 100644
--- a/src/OFURL.m
+++ b/src/OFURL.m
@@ -72,11 +72,11 @@ pathToURLPath(OFString *path)
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: @"/"])
@@ -101,7 +101,7 @@ 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: @"\\"];
@@ -110,10 +110,10 @@ URLPathToPath(OFString *path)
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];
@@ -133,7 +133,7 @@ URLPathToPath(OFString *path)
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
@@ -473,10 +473,10 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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;
@@ -542,11 +542,11 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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];
@@ -618,10 +618,10 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
_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;
@@ -669,7 +669,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
exception];
range.location++;
- range.length = [path length] - range.location;
+ range.length = path.length - range.location;
[path replaceCharactersInRange: range
withString: relativePath];
@@ -734,13 +734,13 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
@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);
@@ -769,11 +769,11 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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;
@@ -845,14 +845,14 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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);
@@ -861,7 +861,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)scheme
{
- return [_URLEncodedScheme stringByURLDecoding];
+ return _URLEncodedScheme.stringByURLDecoding;
}
- (OFString *)URLEncodedScheme
@@ -871,7 +871,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)host
{
- return [_URLEncodedHost stringByURLDecoding];
+ return _URLEncodedHost.stringByURLDecoding;
}
- (OFString *)URLEncodedHost
@@ -886,7 +886,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)user
{
- return [_URLEncodedUser stringByURLDecoding];
+ return _URLEncodedUser.stringByURLDecoding;
}
- (OFString *)URLEncodedUser
@@ -896,7 +896,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)password
{
- return [_URLEncodedPassword stringByURLDecoding];
+ return _URLEncodedPassword.stringByURLDecoding;
}
- (OFString *)URLEncodedPassword
@@ -906,7 +906,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)path
{
- return [_URLEncodedPath stringByURLDecoding];
+ return _URLEncodedPath.stringByURLDecoding;
}
- (OFString *)URLEncodedPath
@@ -916,13 +916,13 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (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;
@@ -940,11 +940,10 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
}
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] == '/') {
@@ -964,7 +963,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)query
{
- return [_URLEncodedQuery stringByURLDecoding];
+ return _URLEncodedQuery.stringByURLDecoding;
}
- (OFString *)URLEncodedQuery
@@ -974,7 +973,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)fragment
{
- return [_URLEncodedFragment stringByURLDecoding];
+ return _URLEncodedFragment.stringByURLDecoding;
}
- (OFString *)URLEncodedFragment
@@ -1055,11 +1054,10 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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);
@@ -1078,12 +1076,12 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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: @"/"];
@@ -1092,7 +1090,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
[component stringByURLEncodingWithAllowedCharacters:
[OFCharacterSet URLPathAllowedCharacterSet]]];
- [ret setURLEncodedPath: URLEncodedPath];
+ ret.URLEncodedPath = URLEncodedPath;
objc_autoreleasePoolPop(pool);
@@ -1104,12 +1102,12 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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);
}
@@ -1128,8 +1126,8 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
if (isDirectory) {
void *pool = objc_autoreleasePoolPush();
- [ret setURLEncodedPath:
- [[ret URLEncodedPath] stringByAppendingString: @"/"]];
+ ret.URLEncodedPath =
+ [ret.URLEncodedPath stringByAppendingString: @"/"];
objc_autoreleasePoolPop(pool);
}
@@ -1152,7 +1150,7 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
- (OFString *)description
{
return [OFString stringWithFormat: @"<%@: %@>",
- [self class], [self string]];
+ self.class, self.string];
}
- (OFXMLElement *)XMLElementBySerializing
@@ -1160,9 +1158,9 @@ of_url_verify_escaped(OFString *string, OFCharacterSet *characterSet)
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];
diff --git a/src/OFURLHandler.m b/src/OFURLHandler.m
index f49ef1a0..7c922cc0 100644
--- a/src/OFURLHandler.m
+++ b/src/OFURLHandler.m
@@ -143,7 +143,7 @@ attributeForKeyOrException(of_file_attributes_t attributes,
[mutex lock];
@try {
#endif
- return [handlers objectForKey: [URL scheme]];
+ return [handlers objectForKey: URL.scheme];
#ifdef OF_HAVE_THREADS
} @finally {
[mutex unlock];
diff --git a/src/OFURLHandler_file.m b/src/OFURLHandler_file.m
index ae0365c2..d5db37ed 100644
--- a/src/OFURLHandler_file.m
+++ b/src/OFURLHandler_file.m
@@ -138,7 +138,7 @@ 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
@@ -344,7 +344,7 @@ 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)) {
@@ -374,13 +374,13 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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)
@@ -498,7 +498,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
{
void *pool = objc_autoreleasePoolPush();
OFFile *file = [[OFFile alloc]
- initWithPath: [URL fileSystemRepresentation]
+ initWithPath: URL.fileSystemRepresentation
mode: mode];
objc_autoreleasePoolPop(pool);
@@ -519,7 +519,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
if (![[URL scheme] isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
- path = [URL fileSystemRepresentation];
+ path = URL.fileSystemRepresentation;
if (of_lstat(path, &s) == -1)
@throw [OFRetrieveItemAttributesFailedException
@@ -551,13 +551,13 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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
@@ -576,7 +576,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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;
@@ -646,7 +646,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
if (URL == nil)
@throw [OFInvalidArgumentException exception];
- if (![[URL scheme] isEqual: _scheme])
+ if (![URL.scheme isEqual: _scheme])
@throw [OFInvalidArgumentException exception];
keyEnumerator = [attributes keyEnumerator];
@@ -686,10 +686,10 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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);
@@ -708,10 +708,10 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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);
@@ -729,13 +729,13 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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];
@@ -794,10 +794,10 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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;
@@ -805,7 +805,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
path = [path stringByAppendingString: @"\\*"];
- if ((handle = FindFirstFileW([path UTF16String],
+ if ((handle = FindFirstFileW(path.UTF16String,
&fd)) == INVALID_HANDLE_VALUE) {
int errNo = 0;
@@ -1008,10 +1008,10 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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
@@ -1051,7 +1051,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
# 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
@@ -1061,7 +1061,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
if (unlink([path cStringWithEncoding:
[OFLocale encoding]]) != 0)
# else
- if (_wunlink([path UTF16String]) != 0)
+ if (_wunlink(path.UTF16String) != 0)
# endif
@throw [OFRemoveItemFailedException
exceptionWithURL: URL
@@ -1110,12 +1110,12 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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];
@@ -1127,8 +1127,8 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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
@@ -1149,10 +1149,10 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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];
@@ -1168,8 +1168,7 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
@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
@@ -1185,8 +1184,8 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
{
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])
@@ -1198,8 +1197,8 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
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
@@ -1207,9 +1206,9 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
#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;
@@ -1243,9 +1242,9 @@ setSymbolicLinkDestinationAttribute(of_mutable_file_attributes_t attributes,
#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
diff --git a/src/OFValue.m b/src/OFValue.m
index 23d6cf84..f6c550ad 100644
--- a/src/OFValue.m
+++ b/src/OFValue.m
@@ -172,7 +172,7 @@ static struct {
if (![object isKindOfClass: [OFValue class]])
return false;
- objCType = [self objCType];
+ objCType = self.objCType;
if (strcmp([object objCType], objCType) != 0)
return false;
@@ -204,7 +204,7 @@ static struct {
- (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;
@@ -309,7 +309,7 @@ static struct {
{
OFMutableString *ret =
[OFMutableString stringWithString: @"<OFValue: "];
- size_t size = of_sizeof_type_encoding([self objCType]);
+ size_t size = of_sizeof_type_encoding(self.objCType);
unsigned char *value;
if ((value = malloc(size)) == NULL)
diff --git a/src/OFWindowsRegistryKey.m b/src/OFWindowsRegistryKey.m
index ce50c784..41dcb992 100644
--- a/src/OFWindowsRegistryKey.m
+++ b/src/OFWindowsRegistryKey.m
@@ -107,7 +107,7 @@
LSTATUS status;
HKEY subKey;
- if ((status = RegOpenKeyExW(_hKey, [path UTF16String], options,
+ if ((status = RegOpenKeyExW(_hKey, path.UTF16String, options,
securityAndAccessRights, &subKey)) != ERROR_SUCCESS) {
if (status == ERROR_FILE_NOT_FOUND) {
objc_autoreleasePoolPop(pool);
@@ -150,7 +150,7 @@
LSTATUS status;
HKEY subKey;
- if ((status = RegCreateKeyExW(_hKey, [path UTF16String], 0,
+ if ((status = RegCreateKeyExW(_hKey, path.UTF16String, 0,
NULL, options, securityAndAccessRights, securityAttributes,
&subKey, NULL)) != ERROR_SUCCESS)
@throw [OFCreateWindowsRegistryKeyFailedException
@@ -180,8 +180,8 @@
LSTATUS status;
for (;;) {
- status = RegGetValueW(_hKey, [subkeyPath UTF16String],
- [value UTF16String], flags, type, buffer, &length);
+ status = RegGetValueW(_hKey, subkeyPath.UTF16String,
+ value.UTF16String, flags, type, buffer, &length);
switch (status) {
case ERROR_SUCCESS:
@@ -208,7 +208,7 @@
ret = [OFMutableData dataWithCapacity: length];
[ret increaseCountBy: length];
- buffer = [ret items];
+ buffer = ret.items;
continue;
default:
@@ -226,14 +226,14 @@
forValue: (OFString *)value
type: (DWORD)type
{
- size_t length = [data count] * [data itemSize];
+ size_t length = data.count * data.itemSize;
LSTATUS status;
if (length > 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
@@ -268,10 +268,10 @@
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;
@@ -310,9 +310,9 @@
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];
@@ -325,7 +325,7 @@
void *pool = objc_autoreleasePoolPush();
LSTATUS status;
- if ((status = RegDeleteValueW(_hKey, [value UTF16String])) !=
+ if ((status = RegDeleteValueW(_hKey, value.UTF16String)) !=
ERROR_SUCCESS)
@throw [OFDeleteWindowsRegistryValueFailedException
exceptionWithRegistryKey: self
@@ -340,7 +340,7 @@
void *pool = objc_autoreleasePoolPush();
LSTATUS status;
- if ((status = RegDeleteKeyW(_hKey, [subkeyPath UTF16String])) !=
+ if ((status = RegDeleteKeyW(_hKey, subkeyPath.UTF16String)) !=
ERROR_SUCCESS)
@throw [OFDeleteWindowsRegistryKeyFailedException
exceptionWithRegistryKey: self
diff --git a/src/OFXMLAttribute.m b/src/OFXMLAttribute.m
index b6246bf3..be21a513 100644
--- a/src/OFXMLAttribute.m
+++ b/src/OFXMLAttribute.m
@@ -77,16 +77,15 @@
@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) {
@@ -147,9 +146,9 @@
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);
@@ -161,7 +160,7 @@
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
- element = [OFXMLElement elementWithName: [self className]
+ element = [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS];
[element addAttributeWithName: @"name"
diff --git a/src/OFXMLCDATA.m b/src/OFXMLCDATA.m
index a437df50..e69b15e4 100644
--- a/src/OFXMLCDATA.m
+++ b/src/OFXMLCDATA.m
@@ -51,11 +51,11 @@
@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) {
@@ -90,7 +90,7 @@
- (uint32_t)hash
{
- return [_CDATA hash];
+ return _CDATA.hash;
}
- (OFString *)stringValue
@@ -120,24 +120,24 @@
- (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];
diff --git a/src/OFXMLCharacters.m b/src/OFXMLCharacters.m
index 084e7e42..06c6dedf 100644
--- a/src/OFXMLCharacters.m
+++ b/src/OFXMLCharacters.m
@@ -51,11 +51,11 @@
@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) {
@@ -90,7 +90,7 @@
- (uint32_t)hash
{
- return [_characters hash];
+ return _characters.hash;
}
- (OFString *)stringValue
@@ -107,28 +107,28 @@
- (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];
}
diff --git a/src/OFXMLComment.m b/src/OFXMLComment.m
index f013bd1b..79d6efc7 100644
--- a/src/OFXMLComment.m
+++ b/src/OFXMLComment.m
@@ -53,11 +53,11 @@
@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) {
@@ -92,7 +92,7 @@
- (uint32_t)hash
{
- return [_comment hash];
+ return _comment.hash;
}
- (OFString *)stringValue
@@ -141,7 +141,7 @@
- (OFXMLElement *)XMLElementBySerializing
{
- return [OFXMLElement elementWithName: [self className]
+ return [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS
stringValue: _comment];
}
diff --git a/src/OFXMLElement.m b/src/OFXMLElement.m
index f7237125..1fc1fe96 100644
--- a/src/OFXMLElement.m
+++ b/src/OFXMLElement.m
@@ -100,18 +100,18 @@ static Class CDATAClass = Nil;
}
+ (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];
}
@@ -179,7 +179,7 @@ static Class CDATAClass = Nil;
@"http://www.w3.org/2000/xmlns/", @"xmlns", nil];
if (stringValue != nil)
- [self setStringValue: stringValue];
+ self.stringValue = stringValue;
} @catch (id e) {
[self release];
@throw e;
@@ -230,12 +230,12 @@ static Class CDATAClass = Nil;
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];
@@ -262,12 +262,12 @@ static Class CDATAClass = Nil;
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];
@@ -289,35 +289,34 @@ static Class CDATAClass = Nil;
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];
+ _name = [[element attributeForName: @"name"].stringValue copy];
+ _namespace = [[element attributeForName: @"namespace"]
+ .stringValue copy];
+ _defaultNamespace = [[element attributeForName:
+ @"defaultNamespace"].stringValue copy];
- attributesElement = [[[element
+ 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]
+ _namespaces = [namespacesElement.objectByDeserializing
mutableCopy];
- _children = [[childrenElement objectByDeserializing]
+ _children = [childrenElement.objectByDeserializing
mutableCopy];
/* Sanity checks */
@@ -398,8 +397,8 @@ static Class CDATAClass = Nil;
{
void *pool = objc_autoreleasePoolPush();
- [self setChildren: [OFArray arrayWithObject:
- [OFXMLCharacters charactersWithString: stringValue]]];
+ self.children = [OFArray arrayWithObject:
+ [OFXMLCharacters charactersWithString: stringValue]];
objc_autoreleasePoolPop(pool);
}
@@ -408,7 +407,7 @@ static Class CDATAClass = Nil;
{
OFMutableString *ret;
- if ([_children count] == 0)
+ if (_children.count == 0)
return @"";
ret = [OFMutableString string];
@@ -416,7 +415,7 @@ static Class CDATAClass = Nil;
for (OFXMLNode *child in _children) {
void *pool = objc_autoreleasePoolPush();
- [ret appendString: [child stringValue]];
+ [ret appendString: child.stringValue];
objc_autoreleasePoolPop(pool);
}
@@ -473,7 +472,7 @@ static Class CDATAClass = Nil;
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);
@@ -483,7 +482,7 @@ static Class CDATAClass = Nil;
cString[i++] = '<';
if (prefix != nil && ![_namespace isEqual: defaultNS]) {
- length += [prefix UTF8StringLength] + 1;
+ length += prefix.UTF8StringLength + 1;
@try {
cString = [self resizeMemory: cString
size: length];
@@ -492,20 +491,19 @@ static Class CDATAClass = Nil;
@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];
@@ -516,21 +514,19 @@ static Class CDATAClass = Nil;
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 &&
@@ -542,8 +538,8 @@ static Class CDATAClass = Nil;
length += attributeNameLength +
(attributePrefix != nil ?
- [attributePrefix UTF8StringLength] + 1 : 0) +
- [tmp UTF8StringLength] + 4;
+ attributePrefix.UTF8StringLength + 1 : 0) +
+ tmp.UTF8StringLength + 4;
@try {
cString = [self resizeMemory: cString
@@ -555,17 +551,17 @@ static Class CDATAClass = Nil;
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);
@@ -607,14 +603,14 @@ static Class CDATAClass = Nil;
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
@@ -626,8 +622,8 @@ static Class CDATAClass = Nil;
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);
@@ -637,7 +633,7 @@ static Class CDATAClass = Nil;
cString[i++] = '<';
cString[i++] = '/';
if (prefix != nil) {
- length += [prefix UTF8StringLength] + 1;
+ length += prefix.UTF8StringLength + 1;
@try {
cString = [self resizeMemory: cString
size: length];
@@ -646,14 +642,13 @@ static Class CDATAClass = Nil;
@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++] = '/';
@@ -701,7 +696,7 @@ static Class CDATAClass = Nil;
void *pool = objc_autoreleasePoolPush();
OFXMLElement *element;
- element = [OFXMLElement elementWithName: [self className]
+ element = [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS];
if (_name != nil)
@@ -723,7 +718,7 @@ static Class CDATAClass = Nil;
[OFXMLElement elementWithName: @"attributes"
namespace: OF_SERIALIZATION_NS];
[attributesElement addChild:
- [_attributes XMLElementBySerializing]];
+ _attributes.XMLElementBySerializing];
[element addChild: attributesElement];
}
@@ -737,12 +732,12 @@ static Class CDATAClass = Nil;
[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];
}
}
@@ -753,7 +748,7 @@ static Class CDATAClass = Nil;
childrenElement =
[OFXMLElement elementWithName: @"children"
namespace: OF_SERIALIZATION_NS];
- [childrenElement addChild: [_children XMLElementBySerializing]];
+ [childrenElement addChild: _children.XMLElementBySerializing];
[element addChild: childrenElement];
}
@@ -824,8 +819,8 @@ static Class CDATAClass = 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 &&
@@ -848,8 +843,8 @@ static Class CDATAClass = Nil;
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] &&
@@ -863,7 +858,7 @@ static Class CDATAClass = Nil;
- (void)setPrefix: (OFString *)prefix
forNamespace: (OFString *)namespace
{
- if ([prefix length] == 0)
+ if (prefix.length == 0)
@throw [OFInvalidArgumentException exception];
if (namespace == nil)
namespace = @"";
@@ -953,14 +948,14 @@ static Class CDATAClass = Nil;
- (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
@@ -1078,12 +1073,12 @@ static Class CDATAClass = Nil;
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);
diff --git a/src/OFXMLElementBuilder.m b/src/OFXMLElementBuilder.m
index e7661cb9..a081812c 100644
--- a/src/OFXMLElementBuilder.m
+++ b/src/OFXMLElementBuilder.m
@@ -63,7 +63,7 @@
{
OFXMLProcessingInstructions *node = [OFXMLProcessingInstructions
processingInstructionsWithString: pi];
- OFXMLElement *parent = [_stack lastObject];
+ OFXMLElement *parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
@@ -83,19 +83,19 @@
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];
}
@@ -104,7 +104,7 @@
prefix: (OFString *)prefix
namespace: (OFString *)namespace
{
- switch ([_stack count]) {
+ switch (_stack.count) {
case 0:
if ([_delegate respondsToSelector: @selector(elementBuilder:
didNotExpectCloseTag:prefix:namespace:)])
@@ -118,7 +118,7 @@
return;
case 1:
[_delegate elementBuilder: self
- didBuildElement: [_stack firstObject]];
+ didBuildElement: _stack.firstObject];
break;
}
@@ -132,7 +132,7 @@
OFXMLElement *parent;
node = [OFXMLCharacters charactersWithString: characters];
- parent = [_stack lastObject];
+ parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
@@ -146,7 +146,7 @@
foundCDATA: (OFString *)CDATA
{
OFXMLCDATA *node = [OFXMLCDATA CDATAWithString: CDATA];
- OFXMLElement *parent = [_stack lastObject];
+ OFXMLElement *parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
@@ -160,7 +160,7 @@
foundComment: (OFString *)comment
{
OFXMLComment *node = [OFXMLComment commentWithString: comment];
- OFXMLElement *parent = [_stack lastObject];
+ OFXMLElement *parent = _stack.lastObject;
if (parent != nil)
[parent addChild: node];
diff --git a/src/OFXMLNode.m b/src/OFXMLNode.m
index ffc68f4e..bb7e2910 100644
--- a/src/OFXMLNode.m
+++ b/src/OFXMLNode.m
@@ -48,22 +48,22 @@
- (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
diff --git a/src/OFXMLParser.m b/src/OFXMLParser.m
index 4ca87b39..3cb3ab58 100644
--- a/src/OFXMLParser.m
+++ b/src/OFXMLParser.m
@@ -78,8 +78,8 @@ appendToBuffer(OFMutableData *buffer, const char *string,
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);
}
}
@@ -88,8 +88,8 @@ 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;
@@ -97,7 +97,7 @@ transformString(OFXMLParser *parser, OFMutableData *buffer, size_t cut,
if (items[i] == '\r') {
if (i + 1 < length && items[i + 1] == '\n') {
[buffer removeItemAtIndex: i];
- items = [buffer items];
+ items = buffer.mutableItems;
i--;
length--;
@@ -125,8 +125,8 @@ transformString(OFXMLParser *parser, OFMutableData *buffer, size_t cut,
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 = @"";
@@ -282,8 +282,8 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
- (void)parseString: (OFString *)string
{
- [self parseBuffer: [string UTF8String]
- length: [string UTF8StringLength]];
+ [self parseBuffer: string.UTF8String
+ length: string.UTF8StringLength];
}
- (void)parseStream: (OFStream *)stream
@@ -292,7 +292,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
char *buffer = [self allocMemoryWithSize: pageSize];
@try {
- while (![stream isAtEndOfStream]) {
+ while (!stream.atEndOfStream) {
size_t length = [stream readIntoBuffer: buffer
length: pageSize];
@@ -346,7 +346,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
{
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];
@@ -357,7 +357,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
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);
@@ -398,7 +398,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
_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;
@@ -424,11 +424,11 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
_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++) {
@@ -547,8 +547,8 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
pool = objc_autoreleasePoolPush();
- bufferCString = [_buffer items];
- bufferLength = [_buffer count];
+ bufferCString = _buffer.items;
+ bufferLength = _buffer.count;
bufferString = [OFString stringWithUTF8String: bufferCString
length: bufferLength];
@@ -591,7 +591,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
prefix: _prefix
namespace: namespace];
- if ([_previous count] == 0)
+ if (_previous.count == 0)
_finishedParsing = true;
} else
[_previous addObject: bufferString];
@@ -632,8 +632,8 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
pool = objc_autoreleasePoolPush();
- bufferCString = [_buffer items];
- bufferLength = [_buffer count];
+ bufferCString = _buffer.items;
+ bufferLength = _buffer.count;
bufferString = [OFString stringWithUTF8String: bufferCString
length: bufferLength];
@@ -650,7 +650,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
_prefix = nil;
}
- if (![[_previous lastObject] isEqual: bufferString])
+ if (![_previous.lastObject isEqual: bufferString])
@throw [OFMalformedXMLException exceptionWithParser: self];
[_previous removeLastObject];
@@ -681,7 +681,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
? OF_XMLPARSER_OUTSIDE_TAG
: OF_XMLPARSER_EXPECT_SPACE_OR_TAG_CLOSE);
- if ([_previous count] == 0)
+ if (_previous.count == 0)
_finishedParsing = true;
}
@@ -704,8 +704,8 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
return;
}
- attributesObjects = [_attributes objects];
- attributesCount = [_attributes count];
+ attributesObjects = _attributes.objects;
+ attributesCount = _attributes.count;
namespace = namespaceForPrefix(_prefix, _namespaces);
@@ -735,7 +735,7 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
prefix: _prefix
namespace: namespace];
- if ([_previous count] == 0)
+ if (_previous.count == 0)
_finishedParsing = true;
[_namespaces removeLastObject];
@@ -776,11 +776,11 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
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]
@@ -853,11 +853,11 @@ resolveAttributeNamespace(OFXMLAttribute *attribute, OFArray *namespaces,
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
diff --git a/src/OFXMLProcessingInstructions.m b/src/OFXMLProcessingInstructions.m
index 9671c297..0966f222 100644
--- a/src/OFXMLProcessingInstructions.m
+++ b/src/OFXMLProcessingInstructions.m
@@ -53,11 +53,11 @@
@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) {
@@ -93,7 +93,7 @@
- (uint32_t)hash
{
- return [_processingInstructions hash];
+ return _processingInstructions.hash;
}
- (OFString *)stringValue
@@ -142,7 +142,7 @@
- (OFXMLElement *)XMLElementBySerializing
{
- return [OFXMLElement elementWithName: [self className]
+ return [OFXMLElement elementWithName: self.className
namespace: OF_SERIALIZATION_NS
stringValue: _processingInstructions];
}
diff --git a/src/OFZIPArchive.h b/src/OFZIPArchive.h
index 429a9e48..f64db3a5 100644
--- a/src/OFZIPArchive.h
+++ b/src/OFZIPArchive.h
@@ -33,7 +33,7 @@ OF_ASSUME_NONNULL_BEGIN
*/
@interface OFZIPArchive: OFObject
{
- OF_KINDOF(OFStream *) _stream;
+ OFStream *_stream;
int64_t _offset;
enum {
OF_ZIP_ARCHIVE_MODE_READ,
@@ -77,7 +77,7 @@ OF_ASSUME_NONNULL_BEGIN
* archive.
* @return A new, autoreleased OFZIPArchive
*/
-+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
++ (instancetype)archiveWithStream: (OFStream *)stream
mode: (OFString *)mode;
#ifdef OF_HAVE_FILES
@@ -107,7 +107,7 @@ OF_ASSUME_NONNULL_BEGIN
* 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
diff --git a/src/OFZIPArchive.m b/src/OFZIPArchive.m
index a8560a61..66bca227 100644
--- a/src/OFZIPArchive.m
+++ b/src/OFZIPArchive.m
@@ -76,8 +76,8 @@
@interface OFZIPArchive_FileReadStream: OFStream
{
- OF_KINDOF(OFStream *) _stream;
- OF_KINDOF(OFStream *) _decompressedStream;
+ OFStream *_stream;
+ OFStream *_decompressedStream;
OFZIPArchiveEntry *_entry;
uint64_t _toRead;
uint32_t _CRC32;
@@ -143,7 +143,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
[stream seekToOffset: offset
whence: whence];
} @catch (OFSeekFailedException *e) {
- if ([e errNo] == EINVAL)
+ if (e.errNo == EINVAL)
@throw [OFInvalidFormatException exception];
@throw e;
@@ -153,7 +153,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
@implementation OFZIPArchive
@synthesize archiveComment = _archiveComment;
-+ (instancetype)archiveWithStream: (OF_KINDOF(OFStream *))stream
++ (instancetype)archiveWithStream: (OFStream *)stream
mode: (OFString *)mode
{
return [[[self alloc] initWithStream: stream
@@ -174,7 +174,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
OF_INVALID_INIT_METHOD
}
-- (instancetype)initWithStream: (OF_KINDOF(OFStream *))stream
+- (instancetype)initWithStream: (OFStream *)stream
mode: (OFString *)mode
{
self = [super init];
@@ -204,7 +204,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
if (_mode == OF_ZIP_ARCHIVE_MODE_APPEND) {
_offset = _centralDirectoryOffset;
- seekOrThrowInvalidFormat(_stream,
+ seekOrThrowInvalidFormat((OFSeekableStream *)_stream,
(of_offset_t)_offset, SEEK_SET);
}
} @catch (id e) {
@@ -268,7 +268,8 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
bool valid = false;
do {
- seekOrThrowInvalidFormat(_stream, offset, SEEK_END);
+ seekOrThrowInvalidFormat((OFSeekableStream *)_stream,
+ offset, SEEK_END);
if ([_stream readLittleEndianInt32] == 0x06054B50) {
valid = true;
@@ -300,7 +301,8 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
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);
@@ -317,7 +319,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
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)
@@ -357,19 +359,19 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
(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);
@@ -390,7 +392,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
void *pool = objc_autoreleasePoolPush();
OFString *old;
- if ([comment UTF8StringLength] > UINT16_MAX)
+ if (comment.UTF8StringLength > UINT16_MAX)
@throw [OFOutOfRangeException exception];
old = _archiveComment;
@@ -444,11 +446,12 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
[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];
@@ -490,42 +493,41 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
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 */
@@ -606,7 +608,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
[_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];
@@ -687,7 +689,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
[extraField removeItemsInRange: range];
}
- if ([extraField count] > 0) {
+ if (extraField.count > 0) {
[extraField makeImmutable];
_extraField = [extraField copy];
}
@@ -711,18 +713,18 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
- (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;
@@ -738,7 +740,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
@try {
_stream = [stream retain];
- switch ([entry compressionMethod]) {
+ switch (entry.compressionMethod) {
case OF_ZIP_ARCHIVE_ENTRY_COMPRESSION_METHOD_NONE:
_decompressedStream = [stream retain];
break;
@@ -757,7 +759,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
}
_entry = [entry copy];
- _toRead = [entry uncompressedSize];
+ _toRead = entry.uncompressedSize;
_CRC32 = ~0;
} @catch (id e) {
[self release];
@@ -797,8 +799,7 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
if (_atEndOfStream)
return 0;
- if ([_stream isAtEndOfStream] &&
- ![_decompressedStream hasDataInReadBuffer])
+ if (_stream.atEndOfStream && !_decompressedStream.hasDataInReadBuffer)
@throw [OFTruncatedDataException exception];
#if SIZE_MAX >= UINT64_MAX
@@ -818,11 +819,11 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
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
@@ -835,13 +836,14 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
- (bool)hasDataInReadBuffer
{
- return ([super hasDataInReadBuffer] ||
- [_decompressedStream hasDataInReadBuffer]);
+ return (super.hasDataInReadBuffer ||
+ _decompressedStream.hasDataInReadBuffer);
}
- (int)fileDescriptorForReading
{
- return [_decompressedStream fileDescriptorForReading];
+ return ((id <OFReadyForReadingObserving>)_decompressedStream)
+ .fileDescriptorForReading;
}
- (void)close
@@ -914,9 +916,9 @@ seekOrThrowInvalidFormat(OFSeekableStream *stream,
[_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);
diff --git a/src/OFZIPArchiveEntry.m b/src/OFZIPArchiveEntry.m
index b256b69b..a7b6196b 100644
--- a/src/OFZIPArchiveEntry.m
+++ b/src/OFZIPArchiveEntry.m
@@ -148,8 +148,8 @@ 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;
@@ -193,7 +193,7 @@ of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag,
@try {
void *pool = objc_autoreleasePoolPush();
- if ([fileName UTF8StringLength] > UINT16_MAX)
+ if (fileName.UTF8StringLength > UINT16_MAX)
@throw [OFOutOfRangeException exception];
_fileName = [fileName copy];
@@ -282,7 +282,7 @@ of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag,
[extraField removeItemsInRange: range];
}
- if ([extraField count] > 0) {
+ if (extraField.count > 0) {
[extraField makeImmutable];
_extraField = [extraField copy];
}
@@ -451,9 +451,9 @@ of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag,
@"\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];
@@ -467,7 +467,7 @@ of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag,
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];
@@ -480,10 +480,10 @@ of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag,
[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];
@@ -491,7 +491,7 @@ of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag,
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];
@@ -503,11 +503,11 @@ of_zip_archive_entry_extra_field_find(OFData *extraField, uint16_t tag,
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);
diff --git a/src/base64.m b/src/base64.m
index eb91a3d2..858df9c3 100644
--- a/src/base64.m
+++ b/src/base64.m
@@ -105,7 +105,7 @@ of_base64_decode(OFMutableData *data, const char *string, size_t length)
if ((length & 3) != 0)
return false;
- if ([data itemSize] != 1)
+ if (data.itemSize != 1)
return false;
for (i = 0; i < length; i += 4) {
diff --git a/src/bridge/NSArray_OFArray.m b/src/bridge/NSArray_OFArray.m
index 123148e2..3106dfac 100644
--- a/src/bridge/NSArray_OFArray.m
+++ b/src/bridge/NSArray_OFArray.m
@@ -47,7 +47,7 @@
- (NSUInteger)count
{
- size_t count = [_array count];
+ size_t count = _array.count;
if (count > NSUIntegerMax)
@throw [OFOutOfRangeException exception];
diff --git a/src/bridge/NSBridging.h b/src/bridge/NSBridging.h
index 4fa3eac4..3fd1df7b 100644
--- a/src/bridge/NSBridging.h
+++ b/src/bridge/NSBridging.h
@@ -42,7 +42,7 @@ OF_ASSUME_NONNULL_BEGIN
*
* @return The receiver as an ObjFW object
*/
-- (id)OFObject;
+@property (readonly, nonatomic) id OFObject;
@end
OF_ASSUME_NONNULL_END
diff --git a/src/bridge/NSDictionary_OFDictionary.m b/src/bridge/NSDictionary_OFDictionary.m
index bbd0249d..7fe17823 100644
--- a/src/bridge/NSDictionary_OFDictionary.m
+++ b/src/bridge/NSDictionary_OFDictionary.m
@@ -54,7 +54,7 @@
- (NSUInteger)count
{
- size_t count = [_dictionary count];
+ size_t count = _dictionary.count;
if (count > NSUIntegerMax)
@throw [OFOutOfRangeException exception];
diff --git a/src/bridge/NSString+OFObject.m b/src/bridge/NSString+OFObject.m
index e469d4fc..e7d856c8 100644
--- a/src/bridge/NSString+OFObject.m
+++ b/src/bridge/NSString+OFObject.m
@@ -23,6 +23,6 @@ int _NSString_OFObject_reference;
@implementation NSString (OFObject)
- (id)OFObject
{
- return [OFString stringWithUTF8String: [self UTF8String]];
+ return [OFString stringWithUTF8String: self.UTF8String];
}
@end
diff --git a/src/bridge/OFArray_NSArray.m b/src/bridge/OFArray_NSArray.m
index 9e0c007b..4c42079e 100644
--- a/src/bridge/OFArray_NSArray.m
+++ b/src/bridge/OFArray_NSArray.m
@@ -31,7 +31,7 @@
@try {
if (array == nil)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
_array = [array retain];
} @catch (id e) {
@@ -59,6 +59,6 @@
- (size_t)count
{
- return [_array count];
+ return _array.count;
}
@end
diff --git a/src/bridge/OFBridging.h b/src/bridge/OFBridging.h
index 48374942..21301e6a 100644
--- a/src/bridge/OFBridging.h
+++ b/src/bridge/OFBridging.h
@@ -43,7 +43,7 @@ OF_ASSUME_NONNULL_BEGIN
*
* @return The receiver as Foundation object
*/
-- (id)NSObject;
+@property (readonly, nonatomic) id NSObject;
@end
OF_ASSUME_NONNULL_END
diff --git a/src/bridge/OFDictionary_NSDictionary.m b/src/bridge/OFDictionary_NSDictionary.m
index bbe83f66..70bffb0d 100644
--- a/src/bridge/OFDictionary_NSDictionary.m
+++ b/src/bridge/OFDictionary_NSDictionary.m
@@ -32,7 +32,7 @@
@try {
if (dictionary == nil)
@throw [OFInitializationFailedException
- exceptionWithClass: [self class]];
+ exceptionWithClass: self.class];
_dictionary = [dictionary retain];
} @catch (id e) {
@@ -60,6 +60,6 @@
- (size_t)count
{
- return [_dictionary count];
+ return _dictionary.count;
}
@end
diff --git a/src/bridge/OFString+NSObject.m b/src/bridge/OFString+NSObject.m
index 4399e310..39cae65d 100644
--- a/src/bridge/OFString+NSObject.m
+++ b/src/bridge/OFString+NSObject.m
@@ -26,7 +26,7 @@ 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
diff --git a/src/exceptions/OFConditionBroadcastFailedException.m b/src/exceptions/OFConditionBroadcastFailedException.m
index de683255..92c37661 100644
--- a/src/exceptions/OFConditionBroadcastFailedException.m
+++ b/src/exceptions/OFConditionBroadcastFailedException.m
@@ -55,7 +55,7 @@
if (_condition != nil)
return [OFString stringWithFormat:
@"Broadcasting a condition of type %@ failed!",
- [_condition class]];
+ _condition.class];
else
return @"Broadcasting a condition failed!";
}
diff --git a/src/exceptions/OFConditionSignalFailedException.m b/src/exceptions/OFConditionSignalFailedException.m
index 6ef580f9..09fad423 100644
--- a/src/exceptions/OFConditionSignalFailedException.m
+++ b/src/exceptions/OFConditionSignalFailedException.m
@@ -55,7 +55,7 @@
if (_condition != nil)
return [OFString stringWithFormat:
@"Signaling a condition of type %@ failed!",
- [_condition class]];
+ _condition.class];
else
return @"Signaling a condition failed!";
}
diff --git a/src/exceptions/OFConditionStillWaitingException.m b/src/exceptions/OFConditionStillWaitingException.m
index 62750175..c5b97b43 100644
--- a/src/exceptions/OFConditionStillWaitingException.m
+++ b/src/exceptions/OFConditionStillWaitingException.m
@@ -56,7 +56,7 @@
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!";
diff --git a/src/exceptions/OFConditionWaitFailedException.m b/src/exceptions/OFConditionWaitFailedException.m
index 5b613367..9e558b4a 100644
--- a/src/exceptions/OFConditionWaitFailedException.m
+++ b/src/exceptions/OFConditionWaitFailedException.m
@@ -55,7 +55,7 @@
if (_condition != nil)
return [OFString stringWithFormat:
@"Waiting for a condition of type %@ failed!",
- [_condition class]];
+ _condition.class];
else
return @"Waiting for a condition failed!";
}
diff --git a/src/exceptions/OFException.m b/src/exceptions/OFException.m
index c4918ddf..36bf38c0 100644
--- a/src/exceptions/OFException.m
+++ b/src/exceptions/OFException.m
@@ -276,7 +276,7 @@ backtrace_callback(struct _Unwind_Context *ctx, void *data)
- (OFString *)description
{
return [OFString stringWithFormat:
- @"An exception of type %@ occurred!", [self class]];
+ @"An exception of type %@ occurred!", self.class];
}
- (OFArray OF_GENERIC(OFString *) *)backtrace
diff --git a/src/exceptions/OFGetOptionFailedException.m b/src/exceptions/OFGetOptionFailedException.m
index f5d78e47..730b395a 100644
--- a/src/exceptions/OFGetOptionFailedException.m
+++ b/src/exceptions/OFGetOptionFailedException.m
@@ -63,6 +63,6 @@
{
return [OFString stringWithFormat:
@"Getting an option in a stream of type %@ failed: %@",
- [_stream class], of_strerror(_errNo)];
+ _stream.class, of_strerror(_errNo)];
}
@end
diff --git a/src/exceptions/OFHTTPRequestFailedException.m b/src/exceptions/OFHTTPRequestFailedException.m
index af6e6e41..a4254538 100644
--- a/src/exceptions/OFHTTPRequestFailedException.m
+++ b/src/exceptions/OFHTTPRequestFailedException.m
@@ -63,11 +63,10 @@
- (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
diff --git a/src/exceptions/OFLockFailedException.m b/src/exceptions/OFLockFailedException.m
index b69d990c..b9649fe5 100644
--- a/src/exceptions/OFLockFailedException.m
+++ b/src/exceptions/OFLockFailedException.m
@@ -53,7 +53,7 @@
{
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!";
}
diff --git a/src/exceptions/OFMalformedXMLException.m b/src/exceptions/OFMalformedXMLException.m
index 45efddd7..b76ee85f 100644
--- a/src/exceptions/OFMalformedXMLException.m
+++ b/src/exceptions/OFMalformedXMLException.m
@@ -55,7 +55,7 @@
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!";
}
diff --git a/src/exceptions/OFObserveFailedException.m b/src/exceptions/OFObserveFailedException.m
index cf761537..38814afa 100644
--- a/src/exceptions/OFObserveFailedException.m
+++ b/src/exceptions/OFObserveFailedException.m
@@ -68,6 +68,6 @@
{
return [OFString stringWithFormat:
@"An observer of class %@ failed to observe: %@",
- [_observer className], of_strerror(_errNo)];
+ _observer.class, of_strerror(_errNo)];
}
@end
diff --git a/src/exceptions/OFSeekFailedException.m b/src/exceptions/OFSeekFailedException.m
index 2720d885..29907e64 100644
--- a/src/exceptions/OFSeekFailedException.m
+++ b/src/exceptions/OFSeekFailedException.m
@@ -72,6 +72,6 @@
{
return [OFString stringWithFormat:
@"Seeking failed in stream of type %@: %@",
- [_stream class], of_strerror(_errNo)];
+ _stream.class, of_strerror(_errNo)];
}
@end
diff --git a/src/exceptions/OFStillLockedException.m b/src/exceptions/OFStillLockedException.m
index 3a283012..169708c9 100644
--- a/src/exceptions/OFStillLockedException.m
+++ b/src/exceptions/OFStillLockedException.m
@@ -54,7 +54,7 @@
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!";
diff --git a/src/exceptions/OFThreadJoinFailedException.m b/src/exceptions/OFThreadJoinFailedException.m
index 5bb58354..11221789 100644
--- a/src/exceptions/OFThreadJoinFailedException.m
+++ b/src/exceptions/OFThreadJoinFailedException.m
@@ -56,7 +56,7 @@
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.";
diff --git a/src/exceptions/OFThreadStartFailedException.m b/src/exceptions/OFThreadStartFailedException.m
index 5d12ec95..72d4a189 100644
--- a/src/exceptions/OFThreadStartFailedException.m
+++ b/src/exceptions/OFThreadStartFailedException.m
@@ -54,7 +54,7 @@
{
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!";
}
diff --git a/src/exceptions/OFThreadStillRunningException.m b/src/exceptions/OFThreadStillRunningException.m
index 3b01d82b..eb9af5eb 100644
--- a/src/exceptions/OFThreadStillRunningException.m
+++ b/src/exceptions/OFThreadStillRunningException.m
@@ -56,7 +56,7 @@
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!";
diff --git a/src/exceptions/OFUnboundNamespaceException.m b/src/exceptions/OFUnboundNamespaceException.m
index 82216752..1eb48233 100644
--- a/src/exceptions/OFUnboundNamespaceException.m
+++ b/src/exceptions/OFUnboundNamespaceException.m
@@ -69,6 +69,6 @@
{
return [OFString stringWithFormat:
@"The namespace %@ is not bound in an element of type %@!",
- _namespace, [_element class]];
+ _namespace, _element.class];
}
@end
diff --git a/src/exceptions/OFUnboundPrefixException.m b/src/exceptions/OFUnboundPrefixException.m
index 976f3b82..065f5f8c 100644
--- a/src/exceptions/OFUnboundPrefixException.m
+++ b/src/exceptions/OFUnboundPrefixException.m
@@ -69,6 +69,6 @@
{
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
diff --git a/src/exceptions/OFUnlockFailedException.m b/src/exceptions/OFUnlockFailedException.m
index e64e0091..99bae685 100644
--- a/src/exceptions/OFUnlockFailedException.m
+++ b/src/exceptions/OFUnlockFailedException.m
@@ -53,7 +53,7 @@
{
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!";
}
diff --git a/src/invocation/invoke-x86_64.m b/src/invocation/invoke-x86_64.m
index f8ab6bb8..190ca85e 100644
--- a/src/invocation/invoke-x86_64.m
+++ b/src/invocation/invoke-x86_64.m
@@ -193,8 +193,8 @@ pushInt128(struct call_context **context, uint_fast8_t *currentGPR,
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;
@@ -310,7 +310,7 @@ of_invocation_invoke(OFInvocation *invocation)
}
}
- typeEncoding = [methodSignature methodReturnType];
+ typeEncoding = methodSignature.methodReturnType;
if (*typeEncoding == 'r')
typeEncoding++;
diff --git a/src/of_asprintf.m b/src/of_asprintf.m
index 54a58719..e5759d65 100644
--- a/src/of_asprintf.m
+++ b/src/of_asprintf.m
@@ -372,7 +372,7 @@ formatConversionSpecifierState(struct context *ctx)
void *pool = objc_autoreleasePoolPush();
tmpLen = asprintf(&tmp, ctx->subformat,
- [[object description] UTF8String]);
+ [object description].UTF8String);
objc_autoreleasePoolPop(pool);
} else
@@ -566,11 +566,11 @@ formatConversionSpecifierState(struct context *ctx)
[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);
diff --git a/src/pbkdf2.m b/src/pbkdf2.m
index 318cb958..c95a7e42 100644
--- a/src/pbkdf2.m
+++ b/src/pbkdf2.m
@@ -34,11 +34,11 @@ void of_pbkdf2(OFHMAC *HMAC, size_t iterations,
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;
@@ -54,7 +54,7 @@ void of_pbkdf2(OFHMAC *HMAC, size_t iterations,
@throw [OFOutOfRangeException exception];
extendedSalt = [OFSecureData dataWithCount: saltLength + 4];
- extendedSaltItems = [extendedSalt items];
+ extendedSaltItems = extendedSalt.mutableItems;
@try {
uint32_t i = OF_BSWAP32_IF_LE(1);
@@ -72,14 +72,14 @@ void of_pbkdf2(OFHMAC *HMAC, size_t iterations,
[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];
diff --git a/src/socket.m b/src/socket.m
index 0e261885..9c120591 100644
--- a/src/socket.m
+++ b/src/socket.m
@@ -255,7 +255,7 @@ of_socket_address_parse_ipv4(OFString *IPv4, uint16_t port)
components = [IPv4 componentsSeparatedByString: @"."];
- if ([components count] != 4)
+ if (components.count != 4)
@throw [OFInvalidFormatException exception];
addr = 0;
@@ -263,14 +263,14 @@ of_socket_address_parse_ipv4(OFString *IPv4, uint16_t port)
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];
@@ -294,7 +294,7 @@ parseIPv6Component(OFString *component)
[OFCharacterSet whitespaceCharacterSet]] != OF_NOT_FOUND)
@throw [OFInvalidFormatException exception];
- number = [component hexadecimalValue];
+ number = component.hexadecimalValue;
if (number > UINT16_MAX)
@throw [OFInvalidFormatException exception];
@@ -327,7 +327,7 @@ of_socket_address_parse_ipv6(OFString *IPv6, uint16_t port)
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;
@@ -338,7 +338,7 @@ of_socket_address_parse_ipv6(OFString *IPv6, uint16_t port)
leftComponents = [left componentsSeparatedByString: @":"];
rightComponents = [right componentsSeparatedByString: @":"];
- if ([leftComponents count] + [rightComponents count] > 7)
+ if (leftComponents.count + rightComponents.count > 7)
@throw [OFInvalidFormatException exception];
i = 0;
@@ -350,7 +350,7 @@ of_socket_address_parse_ipv6(OFString *IPv6, uint16_t port)
}
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;
@@ -361,14 +361,14 @@ of_socket_address_parse_ipv6(OFString *IPv6, uint16_t port)
[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);
diff --git a/src/threading_winapi.m b/src/threading_winapi.m
index 6ece9730..cc0aef41 100644
--- a/src/threading_winapi.m
+++ b/src/threading_winapi.m
@@ -33,7 +33,7 @@ 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;
diff --git a/utils/ofhttp/OFHTTP.m b/utils/ofhttp/OFHTTP.m
index fe42058b..b7d7e00f 100644
--- a/utils/ofhttp/OFHTTP.m
+++ b/utils/ofhttp/OFHTTP.m
@@ -516,12 +516,12 @@ fileNameFromContentDisposition(OFString *contentDisposition)
}
- (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 <OFTLSSocket>)sock).certificateVerificationEnabled = false;
}
- (void)client: (OFHTTPClient *)client
@@ -652,7 +652,7 @@ fileNameFromContentDisposition(OFString *contentDisposition)
afterDelay: 0];
}
-- (bool)stream: (OF_KINDOF(OFStream *))response
+- (bool)stream: (OFStream *)response
didReadIntoBuffer: (void *)buffer
length: (size_t)length
exception: (id)exception