diff options
Diffstat (limited to 'Frameworks')
13 files changed, 131 insertions, 86 deletions
diff --git a/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj b/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj index ed554b9c..24ff9f9f 100644 --- a/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj +++ b/Frameworks/PostgresKit/PostgresKit.xcodeproj/project.pbxproj @@ -650,8 +650,9 @@ GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES; + GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_PEDANTIC = NO; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; @@ -700,8 +701,9 @@ GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES; + GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_PEDANTIC = NO; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; @@ -746,8 +748,9 @@ GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES; GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; GCC_WARN_MISSING_PARENTHESES = YES; - GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = YES; + GCC_WARN_MULTIPLE_DEFINITION_TYPES_FOR_SELECTOR = NO; GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES; + GCC_WARN_PEDANTIC = NO; GCC_WARN_PROTOTYPE_CONVERSION = NO; GCC_WARN_SHADOW = YES; GCC_WARN_SIGN_COMPARE = YES; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnection.m b/Frameworks/PostgresKit/Source/FLXPostgresConnection.m index 5155b79a..a649a982 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresConnection.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresConnection.m @@ -297,7 +297,7 @@ static void _FLXPostgresConnectionNoticeProcessor(void *arg, const char *message BOOL reset = [isReset boolValue]; - NSInteger sock = PQsocket(_connection); + int sock = PQsocket(_connection); if (sock == -1) { [pool release]; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnectionParameters.m b/Frameworks/PostgresKit/Source/FLXPostgresConnectionParameters.m index ce730513..b5c3d9db 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresConnectionParameters.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresConnectionParameters.m @@ -156,7 +156,7 @@ NSString *stringValue = [NSString stringWithUTF8String:value]; - id paramObject = [self _isBooleanParameterValue:stringValue] ? [NSNumber numberWithBool:[self _booleanForParameterValue:stringValue]] : stringValue; + id paramObject = [self _isBooleanParameterValue:stringValue] ? (id)[NSNumber numberWithBool:[self _booleanForParameterValue:stringValue]] : stringValue; [_parameters setObject:paramObject forKey:parameter]; } diff --git a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m index 5d99fd8c..b2f80702 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresConnectionQueryPreparation.m @@ -86,7 +86,7 @@ NSString *name = [[NSProcessInfo processInfo] globallyUniqueString]; - PGresult *result = PQprepare(_connection, [name UTF8String], [statement UTF8Statement], paramNum, paramTypes); + PGresult *result = PQprepare(_connection, [name UTF8String], [statement UTF8Statement], (int)paramNum, paramTypes); if (!result) return NO; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresResult.m b/Frameworks/PostgresKit/Source/FLXPostgresResult.m index 9fd44d8c..57a26268 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresResult.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresResult.m @@ -25,8 +25,6 @@ #import "FLXPostgresConnection.h" #import "FLXPostgresConnectionTypeHandling.h" -static NSString *FLXPostgresResultError = @"FLXPostgresResultError"; - @interface FLXPostgresResult () - (void)_populateFields; @@ -178,7 +176,7 @@ static NSString *FLXPostgresResultError = @"FLXPostgresResultError"; for (NSUInteger i = 0; i < _numberOfFields; i++) { - const char *bytes = PQfname(_result, i); + const char *bytes = PQfname(_result, (int)i); if (!bytes) continue; @@ -199,9 +197,9 @@ static NSString *FLXPostgresResultError = @"FLXPostgresResultError"; if (row >= _numberOfRows || column >= _numberOfFields) return nil; // Check for null - if (PQgetisnull(_result, row, column)) return [NSNull null]; + if (PQgetisnull(_result, (int)row, (int)column)) return [NSNull null]; - FLXPostgresOid type = PQftype(_result, column); + FLXPostgresOid type = PQftype(_result, (int)column); // Get handler for this type id <FLXPostgresTypeHandlerProtocol> handler = [self _typeHandlerForColumn:column withType:type]; @@ -209,8 +207,8 @@ static NSString *FLXPostgresResultError = @"FLXPostgresResultError"; if (!handler) { NSLog(@"PostgresKit: Warning: No type handler found for type %d, return NSData.", type); - const void *bytes = PQgetvalue(_result, row, column); - NSUInteger length = PQgetlength(_result, row, column); + const void *bytes = PQgetvalue(_result, (int)row, (int)column); + NSUInteger length = PQgetlength(_result, (int)row, (int)column); if (!bytes || !length) return nil; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.h index 4b148bbc..f072cf8a 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.h @@ -23,5 +23,21 @@ #import "FLXPostgresTypeHandler.h" @interface FLXPostgresTypeDateTimeHandler : FLXPostgresTypeHandler <FLXPostgresTypeHandlerProtocol> +{ + NSUInteger _row; + NSUInteger _column; + + const PGresult *_result; + + FLXPostgresOid _type; +} + +@property (readwrite, assign) NSUInteger row; + +@property (readwrite, assign) NSUInteger column; + +@property (readwrite, assign) FLXPostgresOid type; + +@property (readwrite, assign) const PGresult *result; @end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m index 3fe08d97..aa61381b 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeDateTimeHandler.m @@ -58,7 +58,6 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = @synthesize type = _type; @synthesize column = _column; @synthesize result = _result; -@synthesize connection = _connection; #pragma mark - #pragma mark Protocol Implementation @@ -79,7 +78,9 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = } - (id)objectFromResult -{ +{ + if (!_result || !_type || !_row || !_column) return [NSNull null]; + switch (_type) { case FLXPostgresOidDate: @@ -110,7 +111,7 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = { PGdate date; - if (!PQgetf(_result, _row, FLXPostgresResultValueDate, _column, &date)) return [NSNull null]; + if (!PQgetf(_result, (int)_row, FLXPostgresResultValueDate, (int)_column, &date)) return [NSNull null]; NSDateComponents *components = [[NSDateComponents alloc] init]; @@ -130,7 +131,7 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = { PGinterval interval; - if (!PQgetf(_result, _row, FLXPostgresResultValueInterval, _column, &interval)) return [NSNull null]; + if (!PQgetf(_result, (int)_row, FLXPostgresResultValueInterval, (int)_column, &interval)) return [NSNull null]; return [FLXPostgresTimeInterval intervalWithPGInterval:&interval]; } @@ -144,11 +145,11 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = */ - (id)_timeFromResult { - PGtime time; + PGtime pgTime; BOOL hasTimeZone = _type == FLXPostgresOidTimeTZ; - if (!PQgetf(_result, _row, hasTimeZone ? FLXPostgresResultValueTimeTZ : FLXPostgresResultValueTime, _column, &time)) return [NSNull null]; + if (!PQgetf(_result, (int)_row, hasTimeZone ? FLXPostgresResultValueTimeTZ : FLXPostgresResultValueTime, (int)_column, &pgTime)) return [NSNull null]; NSDateComponents *components = [[NSDateComponents alloc] init]; @@ -157,13 +158,13 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = [components setMonth:1]; [components setYear:2000]; - [components setHour:time.hour]; - [components setMinute:time.min]; - [components setSecond:time.sec]; + [components setHour:pgTime.hour]; + [components setMinute:pgTime.min]; + [components setSecond:pgTime.sec]; NSDate *date = [self _dateFromComponents:components]; - return hasTimeZone ? [FLXPostgresTimeTZ timeWithDate:date timeZoneGMTOffset:time.gmtoff] : date; + return hasTimeZone ? (id)[FLXPostgresTimeTZ timeWithDate:date timeZoneGMTOffset:pgTime.gmtoff] : date; } /** @@ -177,7 +178,7 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = BOOL hasTimeZone = _type == FLXPostgresOidTimestampTZ; - if (!PQgetf(_result, _row, hasTimeZone ? FLXPostgresResultValueTimestmpTZ : FLXPostgresResultValueTimestamp, _column, ×tamp)) return [NSNull null]; + if (!PQgetf(_result, (int)_row, hasTimeZone ? FLXPostgresResultValueTimestmpTZ : FLXPostgresResultValueTimestamp, (int)_column, ×tamp)) return [NSNull null]; FLXPostgresTimeTZ *timestampTZ = nil; NSDate *date = [NSDate dateWithTimeIntervalSince1970:timestamp.epoch]; @@ -188,7 +189,7 @@ static FLXPostgresOid FLXPostgresTypeDateTimeTypes[] = [timestampTZ setHasDate:YES]; } - return hasTimeZone ? timestampTZ : date; + return hasTimeZone ? (id)timestampTZ : date; } /** diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h index 7c639100..3bfdac39 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.h @@ -23,15 +23,8 @@ @class FLXPostgresConnection; -@interface FLXPostgresTypeHandler : NSObject +@interface FLXPostgresTypeHandler : NSObject { - NSUInteger _row; - NSUInteger _column; - - const PGresult *_result; - - FLXPostgresOid _type; - FLXPostgresConnection *_connection; } diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m index 41903d91..2f232307 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeHandler.m @@ -30,8 +30,6 @@ - (id)initWithConnection:(FLXPostgresConnection *)connection { if ((self = [super init])) { - _type = -1; - _result = nil; _connection = [connection retain]; } @@ -41,9 +39,7 @@ #pragma mark - - (void)dealloc -{ - _result = nil; - +{ if (_connection) [_connection release], _connection = nil; [super dealloc]; diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.h index a3305e19..3f5aa78d 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.h @@ -23,6 +23,22 @@ #import "FLXPostgresTypeHandler.h" @interface FLXPostgresTypeNumberHandler : FLXPostgresTypeHandler <FLXPostgresTypeHandlerProtocol> +{ + NSUInteger _row; + NSUInteger _column; + + const PGresult *_result; + + FLXPostgresOid _type; +} + +@property (readwrite, assign) NSUInteger row; + +@property (readwrite, assign) NSUInteger column; + +@property (readwrite, assign) FLXPostgresOid type; + +@property (readwrite, assign) const PGresult *result; @end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m index 25fd3839..8063a960 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeNumberHandler.m @@ -44,6 +44,10 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] = - (Float32)_float32FromBytes:(const void *)bytes; - (Float64)_float64FromBytes:(const void *)bytes; +- (id)_integerObjectFromBytes:(const void *)bytes length:(NSUInteger)length; +- (id)_floatObjectFromBytes:(const void *)bytes length:(NSUInteger)length; +- (id)_booleanObjectFromBytes:(const void *)bytes length:(NSUInteger)length; + @end @implementation FLXPostgresTypeNumberHandler @@ -52,7 +56,49 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] = @synthesize type = _type; @synthesize column = _column; @synthesize result = _result; -@synthesize connection = _connection; + +#pragma mark - +#pragma mark Protocol Implementation + +- (FLXPostgresOid *)remoteTypes +{ + return FLXPostgresTypeNumberTypes; +} + +- (Class)nativeClass +{ + return [NSNumber class]; +} + +- (NSArray *)classAliases +{ + return nil; +} + +- (id)objectFromResult +{ + if (!_result || !_type || !_row || !_column) return [NSNull null]; + + NSUInteger length = PQgetlength(_result, (int)_row, (int)_column); + const void *bytes = PQgetvalue(_result, (int)_row, (int)_column); + + if (!bytes || !length) return [NSNull null]; + + switch (_type) + { + case FLXPostgresOidInt8: + case FLXPostgresOidInt2: + case FLXPostgresOidInt4: + return [self _integerObjectFromBytes:bytes length:length]; + case FLXPostgresOidFloat4: + case FLXPostgresOidFloat8: + return [self _floatObjectFromBytes:bytes length:length]; + case FLXPostgresOidBool: + return [self _booleanObjectFromBytes:bytes length:length]; + default: + return [NSNull null]; + } +} #pragma mark - #pragma mark Integer @@ -133,45 +179,4 @@ static FLXPostgresOid FLXPostgresTypeNumberTypes[] = return [NSNumber numberWithBool:*((const int8_t *)bytes) ? YES : NO]; } -#pragma mark - -#pragma mark Protocol Implementation - -- (FLXPostgresOid *)remoteTypes -{ - return FLXPostgresTypeNumberTypes; -} - -- (Class)nativeClass -{ - return [NSNumber class]; -} - -- (NSArray *)classAliases -{ - return nil; -} - -- (id)objectFromResult -{ - NSUInteger length = PQgetlength(_result, _row, _column); - const void *bytes = PQgetvalue(_result, _row, _column); - - if (!bytes || !length) return [NSNull null]; - - switch (_type) - { - case FLXPostgresOidInt8: - case FLXPostgresOidInt2: - case FLXPostgresOidInt4: - return [self _integerObjectFromBytes:bytes length:length]; - case FLXPostgresOidFloat4: - case FLXPostgresOidFloat8: - return [self _floatObjectFromBytes:bytes length:length]; - case FLXPostgresOidBool: - return [self _booleanObjectFromBytes:bytes length:length]; - default: - return [NSNull null]; - } -} - @end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.h b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.h index 43a70cfe..27b1c8c2 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.h +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.h @@ -23,6 +23,22 @@ #import "FLXPostgresTypeHandler.h" @interface FLXPostgresTypeStringHandler : FLXPostgresTypeHandler <FLXPostgresTypeHandlerProtocol> +{ + NSUInteger _row; + NSUInteger _column; + + const PGresult *_result; + + FLXPostgresOid _type; +} + +@property (readwrite, assign) NSUInteger row; + +@property (readwrite, assign) NSUInteger column; + +@property (readwrite, assign) FLXPostgresOid type; + +@property (readwrite, assign) const PGresult *result; @end diff --git a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m index dab3dd41..cdb2ea94 100644 --- a/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m +++ b/Frameworks/PostgresKit/Source/FLXPostgresTypeStringHandler.m @@ -57,7 +57,6 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = @synthesize type = _type; @synthesize column = _column; @synthesize result = _result; -@synthesize connection = _connection; #pragma mark - #pragma mark Protocol Implementation @@ -79,6 +78,8 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = - (id)objectFromResult { + if (!_result || !_type || !_row || !_column) return [NSNull null]; + switch (_type) { case FLXPostgresOidText: @@ -112,8 +113,8 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = */ - (id)_stringFromResult { - const void *bytes = PQgetvalue(_result, _row, _column); - NSUInteger length = PQgetlength(_result, _row, _column); + const void *bytes = PQgetvalue(_result, (int)_row, (int)_column); + NSUInteger length = PQgetlength(_result, (int)_row, (int)_column); if (!bytes || !length) return [NSNull null]; @@ -129,7 +130,7 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = { PGmacaddr address; - if (!PQgetf(_result, _row, FLXPostgresResultValueMacAddr, _column, &address)) return [NSNull null]; + if (!PQgetf(_result, (int)_row, FLXPostgresResultValueMacAddr, (int)_column, &address)) return [NSNull null]; return [NSString stringWithFormat:@"%02d:%02d:%02d:%02d:%02d:%02d", address.a, address.b, address.c, address.d, address.e, address.f]; } @@ -143,12 +144,12 @@ static FLXPostgresOid FLXPostgresTypeStringTypes[] = { PGinet inet; - if (!PQgetf(_result, _row, _type == FLXPostgresOidInetAddr ? FLXPostgresResultValueInet : FLXPostgresResultValueCidr, _column, &inet)) return [NSNull null]; + if (!PQgetf(_result, (int)_row, _type == FLXPostgresOidInetAddr ? FLXPostgresResultValueInet : FLXPostgresResultValueCidr, (int)_column, &inet)) return [NSNull null]; char ip[80]; struct sockaddr *sa = (struct sockaddr *)inet.sa_buf; - NSUInteger success = getnameinfo(sa, inet.sa_buf_len, ip, sizeof(ip), NULL, 0, NI_NUMERICHOST); + int success = getnameinfo(sa, inet.sa_buf_len, ip, sizeof(ip), NULL, 0, NI_NUMERICHOST); if (success != 0) { const char *error = gai_strerror(success); |