Index: src/PGConnection+Private.h ================================================================== --- src/PGConnection+Private.h +++ src/PGConnection+Private.h @@ -24,9 +24,9 @@ #import "PGConnection.h" OF_ASSUME_NONNULL_BEGIN @interface PGConnection () -- (PGconn *)PG_connection; +@property (readonly, nonatomic) PGconn *pg_connection; @end OF_ASSUME_NONNULL_END Index: src/PGConnection.m ================================================================== --- src/PGConnection.m +++ src/PGConnection.m @@ -28,10 +28,11 @@ #import "PGConnectionFailedException.h" #import "PGCommandFailedException.h" @implementation PGConnection +@synthesize pg_connection = _connection; @synthesize parameters = _parameters; - (void)dealloc { [_parameters release]; @@ -94,11 +95,11 @@ command: command]; } switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: - return [PGResult PG_resultWithResult: result]; + return [PGResult pg_resultWithResult: result]; case PGRES_COMMAND_OK: PQclear(result); return nil; default: PQclear(result); @@ -160,11 +161,11 @@ objc_autoreleasePoolPop(pool); switch (PQresultStatus(result)) { case PGRES_TUPLES_OK: - return [PGResult PG_resultWithResult: result]; + return [PGResult pg_resultWithResult: result]; case PGRES_COMMAND_OK: PQclear(result); return nil; default: PQclear(result); @@ -243,11 +244,6 @@ { for (OFDictionary *row in rows) [self insertRow: row intoTable: table]; } - -- (PGconn *)PG_connection -{ - return _connection; -} @end Index: src/PGResult+Private.h ================================================================== --- src/PGResult+Private.h +++ src/PGResult+Private.h @@ -24,11 +24,13 @@ #import "PGResult.h" OF_ASSUME_NONNULL_BEGIN @interface PGResult () -+ (instancetype)PG_resultWithResult: (PGresult *)result; -- PG_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init); -- (PGresult *)PG_result; +@property (readonly, nonatomic) PGresult *pg_result; + ++ (instancetype)pg_resultWithResult: (PGresult *)result; +- (instancetype)pg_initWithResult: (PGresult *)result OF_METHOD_FAMILY(init) + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/PGResult.m ================================================================== --- src/PGResult.m +++ src/PGResult.m @@ -20,20 +20,23 @@ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ #import "PGResult.h" +#import "PGResult+Private.h" #import "PGResultRow.h" #import "PGResultRow+Private.h" @implementation PGResult -+ (instancetype)PG_resultWithResult: (PGresult *)result +@synthesize pg_result = _result; + ++ (instancetype)pg_resultWithResult: (PGresult *)result { - return [[[self alloc] PG_initWithResult: result] autorelease]; + return [[[self alloc] pg_initWithResult: result] autorelease]; } -- (instancetype)PG_initWithResult: (PGresult *)result +- (instancetype)pg_initWithResult: (PGresult *)result { self = [super init]; _result = result; @@ -56,14 +59,9 @@ - (id)objectAtIndex: (size_t)index { if (index > PQntuples(_result)) @throw [OFOutOfRangeException exception]; - return [PGResultRow PG_rowWithResult: self + return [PGResultRow pg_rowWithResult: self row: (int)index]; } - -- (PGresult *)PG_result -{ - return _result; -} @end Index: src/PGResultRow+Private.h ================================================================== --- src/PGResultRow+Private.h +++ src/PGResultRow+Private.h @@ -24,12 +24,13 @@ #import "PGResultRow.h" OF_ASSUME_NONNULL_BEGIN @interface PGResultRow () -+ (instancetype)PG_rowWithResult: (PGResult *)result ++ (instancetype)pg_rowWithResult: (PGResult *)result row: (int)row; -- PG_initWithResult: (PGResult *)result - row: (int)row OF_METHOD_FAMILY(init); +- (instancetype)pg_initWithResult: (PGResult *)result + row: (int)row OF_METHOD_FAMILY(init) + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/PGResultRow.m ================================================================== --- src/PGResultRow.m +++ src/PGResultRow.m @@ -80,11 +80,11 @@ row: (int)row { self = [super init]; _result = [result retain]; - _res = [result PG_result]; + _res = [result pg_result]; _row = row; return self; } @@ -161,11 +161,11 @@ PQfname(_res, state->state + i)]; } state->state += count; state->itemsPtr = objects; - state->mutationsPtr = (unsigned long*)self; + state->mutationsPtr = (unsigned long *)self; return j; } @end @@ -174,11 +174,11 @@ row: (int)row { self = [super init]; _result = [result retain]; - _res = [result PG_result]; + _res = [result pg_result]; _row = row; _count = PQnfields(_res); return self; } Index: src/exceptions/PGCommandFailedException.h ================================================================== --- src/exceptions/PGCommandFailedException.h +++ src/exceptions/PGCommandFailedException.h @@ -30,12 +30,16 @@ OFString *_command; } @property (readonly, nonatomic) OFString *command; ++ (instancetype)exceptionWithConnection: (PGConnection *)connection + OF_UNAVAILABLE; + (instancetype)exceptionWithConnection: (PGConnection *)connection command: (OFString *)command; -- initWithConnection: (PGConnection *)connection - command: (OFString *)command; +- (instancetype)initWithConnection: (PGConnection *)connection OF_UNAVAILABLE; +- (instancetype)initWithConnection: (PGConnection *)connection + command: (OFString *)command + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/PGCommandFailedException.m ================================================================== --- src/exceptions/PGCommandFailedException.m +++ src/exceptions/PGCommandFailedException.m @@ -23,20 +23,30 @@ #import "PGCommandFailedException.h" @implementation PGCommandFailedException @synthesize command = _command; + ++ (instancetype)exceptionWithConnection: (PGConnection *)connection +{ + OF_UNRECOGNIZED_SELECTOR +} + (instancetype)exceptionWithConnection: (PGConnection *)connection command: (OFString *)command { return [[[self alloc] initWithConnection: connection command: command] autorelease]; } -- initWithConnection: (PGConnection *)connection - command: (OFString *)command +- (instancetype)initWithConnection: (PGConnection *)connection +{ + OF_INVALID_INIT_METHOD +} + +- (instancetype)initWithConnection: (PGConnection *)connection + command: (OFString *)command { self = [super initWithConnection: connection]; @try { _command = [command copy]; Index: src/exceptions/PGException.h ================================================================== --- src/exceptions/PGException.h +++ src/exceptions/PGException.h @@ -34,9 +34,10 @@ } @property (readonly, nonatomic) PGConnection *connection; + (instancetype)exceptionWithConnection: (PGConnection *)connection; -- initWithConnection: (PGConnection *)connection; +- (instancetype)initWithConnection: (PGConnection *)connection + OF_DESIGNATED_INITIALIZER; @end OF_ASSUME_NONNULL_END Index: src/exceptions/PGException.m ================================================================== --- src/exceptions/PGException.m +++ src/exceptions/PGException.m @@ -37,11 +37,11 @@ self = [super init]; @try { _connection = [connection retain]; _error = [[OFString alloc] - initWithCString: PQerrorMessage([_connection PG_connection]) + initWithCString: PQerrorMessage([_connection pg_connection]) encoding: [OFLocale encoding]]; } @catch (id e) { [self release]; @throw e; }