From e822541c1eea8c2c3f60da57d1a2f565519f1832 Mon Sep 17 00:00:00 2001 From: Jonathan Schleifer Date: Sat, 16 Mar 2019 22:58:16 +0000 Subject: [PATCH] Use dot syntax FossilOrigin-Name: dfb0336763997b766d56a302c7534656f518a37c06178af7f15edbed5790dabf --- src/PGConnection.m | 26 +++++++++++++------------- src/PGResult+Private.h | 3 +-- src/PGResultRow+Private.h | 3 +-- src/PGResultRow.m | 24 ++++++++++++------------ 4 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/PGConnection.m b/src/PGConnection.m index a94d0ce..c642ee6 100644 --- a/src/PGConnection.m +++ b/src/PGConnection.m @@ -1,5 +1,5 @@ /* - * 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 @@ -61,7 +61,7 @@ @"%@=%@", key, object]; } - if ((_connection = PQconnectdb([connectionInfo UTF8String])) == NULL) + if ((_connection = PQconnectdb(connectionInfo.UTF8String)) == NULL) @throw [OFOutOfMemoryException exception]; if (PQstatus(_connection) == CONNECTION_BAD) @@ -86,7 +86,7 @@ - (PGResult *)executeCommand: (OFConstantString *)command { - PGresult *result = PQexec(_connection, [command UTF8String]); + PGresult *result = PQexec(_connection, command.UTF8String); if (PQresultStatus(result) == PGRES_FATAL_ERROR) { PQclear(result); @@ -134,26 +134,26 @@ 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]; @@ -190,7 +190,7 @@ [command appendString: table]; [command appendString: @" ("]; - count = [row count]; + count = row.count; i = 0; enumerator = [row keyEnumerator]; @@ -214,14 +214,14 @@ 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]; diff --git a/src/PGResult+Private.h b/src/PGResult+Private.h index 2833a5f..9ce12ce 100644 --- a/src/PGResult+Private.h +++ b/src/PGResult+Private.h @@ -29,8 +29,7 @@ OF_ASSUME_NONNULL_BEGIN @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 diff --git a/src/PGResultRow+Private.h b/src/PGResultRow+Private.h index 00a257c..ae143ec 100644 --- a/src/PGResultRow+Private.h +++ b/src/PGResultRow+Private.h @@ -29,8 +29,7 @@ OF_ASSUME_NONNULL_BEGIN + (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 diff --git a/src/PGResultRow.m b/src/PGResultRow.m index 6b3a1aa..8aa5a4a 100644 --- a/src/PGResultRow.m +++ b/src/PGResultRow.m @@ -1,5 +1,5 @@ /* - * 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 @@ -35,17 +35,17 @@ convertType(PGresult *res, int column, OFString *string) 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; @@ -76,13 +76,13 @@ convertType(PGresult *res, int column, OFString *string) 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; @@ -170,13 +170,13 @@ convertType(PGresult *res, int column, OFString *string) @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);