Index: src/PGConnection.m ================================================================== --- src/PGConnection.m +++ src/PGConnection.m @@ -1,7 +1,7 @@ /* - * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 + * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 * Jonathan Schleifer * * https://heap.zone/git/objpgsql.git * * Permission to use, copy, modify, and/or distribute this software for any @@ -59,11 +59,11 @@ else connectionInfo = [OFMutableString stringWithFormat: @"%@=%@", key, object]; } - if ((_connection = PQconnectdb([connectionInfo UTF8String])) == NULL) + if ((_connection = PQconnectdb(connectionInfo.UTF8String)) == NULL) @throw [OFOutOfMemoryException exception]; if (PQstatus(_connection) == CONNECTION_BAD) @throw [PGConnectionFailedException exceptionWithConnection: self]; @@ -84,11 +84,11 @@ _connection = NULL; } - (PGResult *)executeCommand: (OFConstantString *)command { - PGresult *result = PQexec(_connection, [command UTF8String]); + PGresult *result = PQexec(_connection, command.UTF8String); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @throw [PGCommandFailedException exceptionWithConnection: self @@ -132,30 +132,30 @@ if ([parameter isKindOfClass: [OFString class]]) values[i++] = [parameter UTF8String]; else if ([parameter isKindOfClass: [OFNumber class]]) { OFNumber *number = parameter; - switch ([number type]) { + switch (number.type) { case OF_NUMBER_TYPE_BOOL: - if ([number boolValue]) + if (number.boolValue) values[i++] = "t"; else values[i++] = "f"; break; default: - values[i++] = [[number description] - UTF8String]; + values[i++] = + number.description.UTF8String; break; } } else if ([parameter isKindOfClass: [OFNull class]]) values[i++] = NULL; else - values[i++] = [[parameter description] - UTF8String]; + values[i++] = + [parameter description].UTF8String; } while ((parameter = va_arg(args, id)) != nil); - result = PQexecParams(_connection, [command UTF8String], + result = PQexecParams(_connection, command.UTF8String, argsCount, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } @@ -188,11 +188,11 @@ command = [OFMutableString stringWithString: @"INSERT INTO "]; [command appendString: table]; [command appendString: @" ("]; - count = [row count]; + count = row.count; i = 0; enumerator = [row keyEnumerator]; while ((key = [enumerator nextObject]) != nil) { if (i > 0) @@ -212,18 +212,18 @@ enumerator = [row objectEnumerator]; while ((value = [enumerator nextObject]) != nil) { if (i > 0) [command appendString: @", "]; - values[i] = [value UTF8String]; + values[i] = value.UTF8String; [command appendFormat: @"$%zd", ++i]; } [command appendString: @")"]; - result = PQexecParams(_connection, [command UTF8String], + result = PQexecParams(_connection, command.UTF8String, (int)count, NULL, values, NULL, NULL, 0); } @finally { [self freeMemory: values]; } Index: src/PGResult+Private.h ================================================================== --- src/PGResult+Private.h +++ src/PGResult+Private.h @@ -27,10 +27,9 @@ @interface PGResult () @property (readonly, nonatomic) PGresult *pg_result; + (instancetype)pg_resultWithResult: (PGresult *)result; -- (instancetype)pg_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init) - OF_DESIGNATED_INITIALIZER; +- (instancetype)pg_initWithResult: (PGresult *)result; @end OF_ASSUME_NONNULL_END Index: src/PGResultRow+Private.h ================================================================== --- src/PGResultRow+Private.h +++ src/PGResultRow+Private.h @@ -27,10 +27,9 @@ @interface PGResultRow () + (instancetype)pg_rowWithResult: (PGResult *)result row: (int)row; - (instancetype)pg_initWithResult: (PGResult *)result - row: (int)row OF_METHOD_FAMILY(init) - OF_DESIGNATED_INITIALIZER; + row: (int)row; @end OF_ASSUME_NONNULL_END Index: src/PGResultRow.m ================================================================== --- src/PGResultRow.m +++ src/PGResultRow.m @@ -1,7 +1,7 @@ /* - * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017 + * Copyright (c) 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 * Jonathan Schleifer * * https://heap.zone/git/objpgsql.git * * Permission to use, copy, modify, and/or distribute this software for any @@ -33,21 +33,21 @@ return [OFNumber numberWithBool: YES]; else return [OFNumber numberWithBool: NO]; case 21: /* INT2OID */ return [OFNumber numberWithInt16: - (int16_t)[string decimalValue]]; + (int16_t)string.decimalValue]; case 23: /* INT4OID */ return [OFNumber numberWithInt32: - (int32_t)[string decimalValue]]; + (int32_t)string.decimalValue]; case 20: /* INT8OID */ return [OFNumber numberWithInt64: - (int64_t)[string decimalValue]]; + (int64_t)string.decimalValue]; case 700: /* FLOAT4OID */ - return [OFNumber numberWithFloat: [string floatValue]]; + return [OFNumber numberWithFloat: string.floatValue]; case 701: /* FLOAT8OID */ - return [OFNumber numberWithDouble: [string doubleValue]]; + return [OFNumber numberWithDouble: string.doubleValue]; } return string; } @@ -74,17 +74,17 @@ { return [[[self alloc] initWithResult: result row: row] autorelease]; } -- initWithResult: (PGResult *)result - row: (int)row +- (instancetype)initWithResult: (PGResult *)result + row: (int)row { self = [super init]; _result = [result retain]; - _res = [result pg_result]; + _res = result.pg_result; _row = row; return self; } @@ -168,17 +168,17 @@ return j; } @end @implementation PGResultRowEnumerator -- initWithResult: (PGResult *)result - row: (int)row +- (instancetype)initWithResult: (PGResult *)result + row: (int)row { self = [super init]; _result = [result retain]; - _res = [result pg_result]; + _res = result.pg_result; _row = row; _count = PQnfields(_res); return self; }