diff options
Diffstat (limited to 'Frameworks/MCPKit')
27 files changed, 331 insertions, 320 deletions
diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.h b/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.h index 834c8e18..469d0808 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.h +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.h @@ -42,7 +42,7 @@ NSString *internalType; // Name of the class, or type used for the class definition NSString *externalName; // Name of the corresponding column in the DB NSString *externalType; // Type used to store the attribute (in the DB) - unsigned int width; // Width (for storing by the DB) + NSUInteger width; // Width (for storing by the DB) BOOL allowsNull; // Attribute can be null BOOL autoGenerated; // Attribute is auto generated by the DB BOOL isPartOfKey; // Attribute is part of theprimary key of the class description @@ -69,15 +69,15 @@ - (void) setInternalType:(NSString *) iInternalType; - (void) setExternalType:(NSString *) iExternalType; - (void) setExternalName:(NSString *) iExternalName; -- (void) setWidth:(unsigned int) iWidth; +- (void) setWidth:(NSUInteger) iWidth; - (void) setAllowsNull:(BOOL) iAllowsNull; - (void) setAutoGenerated:(BOOL) iAutoGenerated; - (void) setIsPartOfKey:(BOOL) iIsPartOfKey; - (void) setIsPartOfIdentity:(BOOL) iIsPartOfIdentity; - (void) setHasAccessor:(BOOL) iHasAccessor; - (void) setDefaultValue:(id) iDefaultValue; -- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(unsigned int) index; -- (void) removeObjectFromJoinsAtIndex:(unsigned int) index; +- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(NSUInteger) index; +- (void) removeObjectFromJoinsAtIndex:(NSUInteger) index; //- (void) addRelation:(MCPRelation *) iRelation; //- (void) removeRelation:(MCPRelation *) iRelation; @@ -89,16 +89,16 @@ - (NSString *) internalType; - (NSString *) externalName; - (NSString *) externalType; -- (unsigned int) width; +- (NSUInteger) width; - (BOOL) allowsNull; - (BOOL) autoGenerated; - (BOOL) isPartOfKey; - (BOOL) isPartOfIdentity; - (BOOL) hasAccessor; - (id) defaultValue; -- (unsigned int) countOfJoins; -- (MCPJoin *) objectInJoinsAtIndex:(unsigned int) index; -- (unsigned int) indexOfJoinIdenticalTo:(id) iJoin; +- (NSUInteger) countOfJoins; +- (MCPJoin *) objectInJoinsAtIndex:(NSUInteger) index; +- (NSUInteger) indexOfJoinIdenticalTo:(id) iJoin; #pragma mark Some general methods: - (BOOL) isEqual:(id) iObject; diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m index 8ecfda92..085c1114 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPAttribute.m @@ -35,7 +35,7 @@ #import "MCPRelation.h" #import "MCPJoin.h" -static NSArray *MCPRecognisedInternalType; +static NSArray *MCPRecognisedInternalType; @interface MCPAttribute (Private) @@ -112,7 +112,7 @@ static NSArray *MCPRecognisedInternalType; [self setInternalType:[decoder decodeObjectForKey:@"MCPinternalType"]]; [self setExternalName:[decoder decodeObjectForKey:@"MCPexternalName"]]; [self setExternalType:[decoder decodeObjectForKey:@"MCPexternalType"]]; - [self setWidth:(unsigned int)[decoder decodeInt32ForKey:@"MCPwidth"]]; + [self setWidth:(NSUInteger)[decoder decodeInt32ForKey:@"MCPwidth"]]; [self setAllowsNull:[decoder decodeBoolForKey:@"MCPallowsNull"]]; [self setAutoGenerated:[decoder decodeBoolForKey:@"MCPautoGenerated"]]; [self setIsPartOfKey:[decoder decodeBoolForKey:@"MCPisPartOfKey"]]; @@ -231,7 +231,7 @@ static NSArray *MCPRecognisedInternalType; } } -- (void) setWidth:(unsigned int) iWidth +- (void) setWidth:(NSUInteger) iWidth { if (iWidth != width) { width = iWidth; @@ -302,12 +302,12 @@ static NSArray *MCPRecognisedInternalType; } } -- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(unsigned int) index +- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(NSUInteger) index { [joins insertObject:iJoin atIndex:index]; } -- (void) removeObjectFromJoinsAtIndex:(unsigned int) index +- (void) removeObjectFromJoinsAtIndex:(NSUInteger) index { [joins removeObjectAtIndex:index]; } @@ -373,7 +373,7 @@ static NSArray *MCPRecognisedInternalType; return externalType; } -- (unsigned int) width +- (NSUInteger) width { return width; } @@ -408,17 +408,17 @@ static NSArray *MCPRecognisedInternalType; return defaultValue; } -- (unsigned int) countOfJoins +- (NSUInteger) countOfJoins { return [joins count]; } -- (MCPJoin *) objectInJoinsAtIndex:(unsigned int) index +- (MCPJoin *) objectInJoinsAtIndex:(NSUInteger) index { return (MCPJoin *)((NSNotFound != index) ? [joins objectAtIndex:index] : nil); } -- (unsigned int) indexOfJoinIdenticalTo:(id) iJoin +- (NSUInteger) indexOfJoinIdenticalTo:(id) iJoin { return [joins indexOfObjectIdenticalTo:iJoin]; } diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+MCPEntreprise.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+MCPEntreprise.m index 604290b8..71a25911 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+MCPEntreprise.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+MCPEntreprise.m @@ -38,7 +38,7 @@ { NSArray *theRet; NSMutableArray *theKeys =[[NSMutableArray alloc] init]; - unsigned int i; + NSUInteger i; for (i=0; i != [self countOfAttributes]; ++i) { [theKeys insertObject:[(MCPAttribute *)[self objectInAttributesAtIndex:i] name] atIndex:i]; @@ -50,7 +50,7 @@ - (NSString *) inverseRelationshipKey:(NSString *) relationshipKey { - unsigned int index = [self indexOfRelation:relationshipKey]; + NSUInteger index = [self indexOfRelation:relationshipKey]; if (NSNotFound != index) { MCPRelation *theRelation; @@ -65,7 +65,7 @@ { NSArray *theRet; NSMutableArray *theToManyRel = [[NSMutableArray alloc] init]; - unsigned int i, j; + NSUInteger i, j; j=0; for (i=0; i != [self countOfRelations]; ++i) { @@ -85,7 +85,7 @@ { NSArray *theRet; NSMutableArray *theToOneRel = [[NSMutableArray alloc] init]; - unsigned int i, j; + NSUInteger i, j; j=0; for (i=0; i != [self countOfRelations]; ++i) { @@ -105,7 +105,7 @@ - (NSArray *) primaryKeyAttributes { NSMutableArray *theRet = [NSMutableArray array]; - unsigned int i, j; + NSUInteger i, j; j = 0; for (i=0; i != [self countOfAttributes]; ++i) { @@ -122,7 +122,7 @@ - (NSArray *) identityAttributes { NSMutableArray *theRet = [NSMutableArray array]; - unsigned int i, j; + NSUInteger i, j; j = 0; for (i=0; i != [self countOfAttributes]; ++i) { @@ -144,7 +144,7 @@ return (NSNotFound != index) ? (MCPAttribute *)[self objectInAttributesAtIndex:index] : nil ; */ - unsigned int i; + NSUInteger i; for (i = 0; [attributes count] != i; ++i) { if ([[(MCPAttribute *)[attributes objectAtIndex:i] name] isEqualToString:iName]) { @@ -161,7 +161,7 @@ return (NSNotFound != index) ? (MCPRelation *)[relations objectAtIndex:index] : nil; */ - unsigned int i; + NSUInteger i; for (i = 0; [relations count] != i; ++i) { if ([[(MCPRelation *)[relations objectAtIndex:i] name] isEqualToString:iRelationName]) { diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+Private.h b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+Private.h index 760ea4ef..df86b763 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+Private.h +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription+Private.h @@ -33,13 +33,13 @@ #pragma mark Setters - (void) setAttributes:(NSArray *) iAttributes; - (void) setRelations:(NSArray *) iRelations; -- (void) insertObject:(MCPRelation *) iRelation inIncomingsAtIndex:(unsigned int) index; -- (void) removeObjectFromIncomingsAtIndex:(unsigned int) index; +- (void) insertObject:(MCPRelation *) iRelation inIncomingsAtIndex:(NSUInteger) index; +- (void) removeObjectFromIncomingsAtIndex:(NSUInteger) index; #pragma mark Getters - (NSArray *) incomings; -- (unsigned int) countOfIncomings; -- (MCPRelation *) objectInIncomingsAtIndex:(unsigned int) index; -- (unsigned int) indexOfIncoming:(id) iRelation; +- (NSUInteger) countOfIncomings; +- (MCPRelation *) objectInIncomingsAtIndex:(NSUInteger) index; +- (NSUInteger) indexOfIncoming:(id) iRelation; @end diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.h b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.h index 5a6ae51b..cff3cf17 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.h +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.h @@ -59,29 +59,29 @@ - (void) encodeWithCoder:(NSCoder *) encoder; #pragma mark Making new attributes and relations -- (MCPAttribute *) addNewAttributeWithName:(NSString *) iName inPosition:(int) index; -- (MCPRelation *) addNewRelationTo:(MCPClassDescription *) iTo name:(NSString *) iName inPostion:(int) index; +- (MCPAttribute *) addNewAttributeWithName:(NSString *) iName inPosition:(NSInteger) index; +- (MCPRelation *) addNewRelationTo:(MCPClassDescription *) iTo name:(NSString *) iName inPostion:(NSInteger) index; #pragma mark Setters - (void) setName:(NSString *) iName; - (void) setExternalName:(NSString *) iExternalName; -- (void) insertObject:(MCPAttribute *) iAttribute inAttributesAtIndex:(unsigned int) index; -- (void) removeObjectFromAttributesAtIndex:(unsigned int) index; -- (void) insertObject:(MCPRelation *) iRelation inRelationsAtIndex:(unsigned int) index; -- (void) removeObjectFromRelationsAtIndex:(unsigned int) index; +- (void) insertObject:(MCPAttribute *) iAttribute inAttributesAtIndex:(NSUInteger) index; +- (void) removeObjectFromAttributesAtIndex:(NSUInteger) index; +- (void) insertObject:(MCPRelation *) iRelation inRelationsAtIndex:(NSUInteger) index; +- (void) removeObjectFromRelationsAtIndex:(NSUInteger) index; #pragma mark Getters - (MCPModel *) model; - (NSString *) name; - (NSString *) externalName; - (NSArray *) attributes; -- (unsigned int) countOfAttributes; -- (MCPAttribute *) objectInAttributesAtIndex:(unsigned int) index; -- (unsigned int) indexOfAttribute:(id) iAttribute; +- (NSUInteger) countOfAttributes; +- (MCPAttribute *) objectInAttributesAtIndex:(NSUInteger) index; +- (NSUInteger) indexOfAttribute:(id) iAttribute; - (NSArray *) relations; -- (unsigned int) countOfRelations; -- (MCPRelation *) objectInRelationsAtIndex:(unsigned int) index; -- (unsigned int) indexOfRelation:(id) iRelation; +- (NSUInteger) countOfRelations; +- (MCPRelation *) objectInRelationsAtIndex:(NSUInteger) index; +- (NSUInteger) indexOfRelation:(id) iRelation; - (Class) representedClass; #pragma mark Some general methods: diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.m index 030acf6a..9f2ad18d 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPClassDescription.m @@ -121,7 +121,7 @@ } #pragma mark Making new attributes and relations -- (MCPAttribute *) addNewAttributeWithName:(NSString *) iName inPosition:(int) index +- (MCPAttribute *) addNewAttributeWithName:(NSString *) iName inPosition:(NSInteger) index { MCPAttribute *theAttribute = [[MCPAttribute alloc] initForClassDescription:self withName:iName]; @@ -131,7 +131,7 @@ return theAttribute; } -- (MCPRelation *) addNewRelationTo:(MCPClassDescription *) iTo name:(NSString *) iName inPostion:(int) index +- (MCPRelation *) addNewRelationTo:(MCPClassDescription *) iTo name:(NSString *) iName inPostion:(NSInteger) index { MCPRelation *theRelation = [[MCPRelation alloc] initWithName:iName from:self to:iTo]; @@ -161,28 +161,28 @@ } } -- (void) insertObject:(MCPAttribute *) iAttribute inAttributesAtIndex:(unsigned int) index +- (void) insertObject:(MCPAttribute *) iAttribute inAttributesAtIndex:(NSUInteger) index { [attributes insertObject:iAttribute atIndex:index]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:model]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:self]; } -- (void) removeObjectFromAttributesAtIndex:(unsigned int) index +- (void) removeObjectFromAttributesAtIndex:(NSUInteger) index { [attributes removeObjectAtIndex:index]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:model]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:self]; } -- (void) insertObject:(MCPRelation *) iRelation inRelationsAtIndex:(unsigned int) index +- (void) insertObject:(MCPRelation *) iRelation inRelationsAtIndex:(NSUInteger) index { [relations insertObject:iRelation atIndex:index]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:model]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPClassDescriptionChangedNotification object:self]; } -- (void) removeObjectFromRelationsAtIndex:(unsigned int) index +- (void) removeObjectFromRelationsAtIndex:(NSUInteger) index { [relations removeObjectAtIndex:index]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:model]; @@ -210,17 +210,17 @@ return [NSArray arrayWithArray:attributes]; } -- (unsigned int) countOfAttributes +- (NSUInteger) countOfAttributes { return [attributes count]; } -- (MCPAttribute *) objectInAttributesAtIndex:(unsigned int) index +- (MCPAttribute *) objectInAttributesAtIndex:(NSUInteger) index { return (MCPAttribute *)((NSNotFound != index) ? [attributes objectAtIndex:index] : nil); } -- (unsigned int) indexOfAttribute:(id) iAttribute +- (NSUInteger) indexOfAttribute:(id) iAttribute { return [attributes indexOfObject:iAttribute]; } @@ -230,17 +230,17 @@ return [NSArray arrayWithArray:relations]; } -- (unsigned int) countOfRelations +- (NSUInteger) countOfRelations { return [relations count]; } -- (MCPRelation *) objectInRelationsAtIndex:(unsigned int) index +- (MCPRelation *) objectInRelationsAtIndex:(NSUInteger) index { return (MCPRelation *)((NSNotFound != index) ? [relations objectAtIndex:index] : nil); } -- (unsigned int) indexOfRelation:(id) iRelation +- (NSUInteger) indexOfRelation:(id) iRelation { return [relations indexOfObject:iRelation]; } @@ -281,14 +281,15 @@ */ #pragma mark Output for logging -- (NSString *) descriptionWithLocale:(NSDictionary *) locale + +- (NSString *)descriptionWithLocale:(NSDictionary *) locale { - NSMutableString *theOutput = [NSMutableString string]; - unsigned i; + NSUInteger i; + NSMutableString *theOutput = [NSMutableString string]; [theOutput appendFormat:@"MCPClassDescription for class : %@ (table : %@)\n", [self name], [self externalName]]; for (i=0; [attributes count] != i; ++i) { - MCPAttribute *theAttribute = (MCPAttribute *) [attributes objectAtIndex:i]; + MCPAttribute *theAttribute = (MCPAttribute *) [attributes objectAtIndex:i]; [theOutput appendFormat:@"attribute %u, name = %@, column = %@. Allows null : %c\n", i, [theAttribute name], [theAttribute externalName], ([theAttribute allowsNull] ? 'Y' : 'N')]; } @@ -333,7 +334,7 @@ } } -- (void) insertObject:(MCPRelation *) iRelation inIncomingsAtIndex:(unsigned int) index +- (void) insertObject:(MCPRelation *) iRelation inIncomingsAtIndex:(NSUInteger) index { if ([iRelation destination] == self) { [incomings insertObject:iRelation atIndex:index]; @@ -343,7 +344,7 @@ } } -- (void) removeObjectFromIncomingsAtIndex:(unsigned int) index +- (void) removeObjectFromIncomingsAtIndex:(NSUInteger) index { [incomings removeObjectAtIndex:index]; } @@ -354,17 +355,17 @@ return [NSArray arrayWithArray:incomings]; } -- (unsigned int) countOfIncomings +- (NSUInteger) countOfIncomings { return [incomings count]; } -- (MCPRelation *) objectInIncomingsAtIndex:(unsigned int) index +- (MCPRelation *) objectInIncomingsAtIndex:(NSUInteger) index { return (MCPRelation *)[incomings objectAtIndex:index]; } -- (unsigned int) indexOfIncoming:(id) iRelation +- (NSUInteger) indexOfIncoming:(id) iRelation { return [incomings indexOfObject:iRelation]; } diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.h b/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.h index 79c3c4b4..05e99f8d 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.h +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.h @@ -66,7 +66,7 @@ - (MCPRelation *) relation; - (MCPAttribute *) origin; - (MCPAttribute *) destination; -- (unsigned int) index; +- (NSUInteger) index; #pragma mark Some general methods: - (BOOL) isEqual:(id) iObject; diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.m index 47d2db97..576b1e10 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPJoin.m @@ -60,11 +60,11 @@ - (void) invalidate { [self retain]; - NSLog(@"Enterring -[MCPJoin invalidate], retain count is %u (after retaining : should be 4)", [self retainCount]); + NSLog(@"Enterring -[MCPJoin invalidate], retain count is %ld (after retaining : should be 4)", [self retainCount]); [origin removeObjectFromJoinsAtIndex:[origin indexOfJoinIdenticalTo:self]]; [destination removeObjectFromJoinsAtIndex:[destination indexOfJoinIdenticalTo:self]]; [relation removeObjectFromJoinsAtIndex:[relation indexOfJoinIdenticalTo:self]]; - NSLog(@"Enterring -[MCPJoin invalidate], retain count is %u (before releasing : should be 1)", [self retainCount]); + NSLog(@"Enterring -[MCPJoin invalidate], retain count is %ld (before releasing : should be 1)", [self retainCount]); [self release]; return; } @@ -144,7 +144,7 @@ return destination; } -- (unsigned int) index +- (NSUInteger) index { return [relation indexOfJoinIdenticalTo:self]; } diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel+MCPEntreprise.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel+MCPEntreprise.m index 0d71df8a..2652f0dc 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel+MCPEntreprise.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel+MCPEntreprise.m @@ -46,7 +46,7 @@ if ([theClass isSubclassOfClass:[MCPObject class]]) { NSString *theClassName = NSStringFromClass(theClass); - unsigned int index = [self indexOfClassDescription:theClassName]; + NSUInteger index = [self indexOfClassDescription:theClassName]; if (NSNotFound != index) { [NSClassDescription registerClassDescription:(NSClassDescription *)[self objectInClassDescriptionsAtIndex:index] forClass:theClass]; diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.h b/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.h index 3ad1f6e1..0a6c6afd 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.h +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.h @@ -54,13 +54,13 @@ - (void) encodeWithCoder:(NSCoder *) encoder; #pragma mark Making new class description -- (MCPClassDescription *) addNewClassDescriptionWithName:(NSString *) iName inPosition:(int) index; +- (MCPClassDescription *) addNewClassDescriptionWithName:(NSString *) iName inPosition:(NSInteger) index; #pragma mark Setters - (void) setName:(NSString *) iName; - (void) setClassDescriptions:(NSArray *) iClassDescriptions; -- (void) insertObject:(MCPClassDescription *) iClassDescription inClassDescriptionsAtIndex:(unsigned int) index; -- (void) removeObjectFromClassDescriptionsAtIndex:(unsigned int) index; +- (void) insertObject:(MCPClassDescription *) iClassDescription inClassDescriptionsAtIndex:(NSUInteger) index; +- (void) removeObjectFromClassDescriptionsAtIndex:(NSUInteger) index; - (void) setUsesInnoDBTables:(BOOL) iUsesInnoDB; // Deprecated : non KVC @@ -70,9 +70,9 @@ #pragma mark Getters - (NSString *) name; - (NSArray *) classDescriptions; -- (unsigned int) countOfClassDescriptions; -- (MCPClassDescription *) objectInClassDescriptionsAtIndex:(unsigned int) index; -- (unsigned int) indexOfClassDescription:(id) iClassDescription; +- (NSUInteger) countOfClassDescriptions; +- (MCPClassDescription *) objectInClassDescriptionsAtIndex:(NSUInteger) index; +- (NSUInteger) indexOfClassDescription:(id) iClassDescription; - (BOOL) usesInnoDBTables; // Deprecated : non KVC diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.m index 782342ba..7c73eff1 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPModel.m @@ -96,7 +96,7 @@ } #pragma mark Making new class description -- (MCPClassDescription *) addNewClassDescriptionWithName:(NSString *) iName inPosition:(int) index; +- (MCPClassDescription *) addNewClassDescriptionWithName:(NSString *) iName inPosition:(NSInteger) index; { MCPClassDescription *theClassDescription = [[MCPClassDescription alloc] initInModel:self withName:iName]; @@ -125,13 +125,13 @@ } } -- (void) insertObject:(MCPClassDescription *) iClassDescription inClassDescriptionsAtIndex:(unsigned int) index +- (void) insertObject:(MCPClassDescription *) iClassDescription inClassDescriptionsAtIndex:(NSUInteger) index { [classDescriptions insertObject:iClassDescription atIndex:index]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:self]; } -- (void) removeObjectFromClassDescriptionsAtIndex:(unsigned int) index +- (void) removeObjectFromClassDescriptionsAtIndex:(NSUInteger) index { [classDescriptions removeObjectAtIndex:index]; [[NSNotificationCenter defaultCenter] postNotificationName:MCPModelChangedNotification object:self]; @@ -171,12 +171,12 @@ return [NSArray arrayWithArray:classDescriptions]; } -- (unsigned int) countOfClassDescriptions +- (NSUInteger) countOfClassDescriptions { return [classDescriptions count]; } -- (MCPClassDescription *) objectInClassDescriptionsAtIndex:(unsigned int) index +- (MCPClassDescription *) objectInClassDescriptionsAtIndex:(NSUInteger) index { return (MCPClassDescription *)((NSNotFound != index) ? [classDescriptions objectAtIndex:index] : nil); } @@ -190,11 +190,11 @@ } return (i == [classDescriptions count]) ? nil : (MCPClassDescription *)[classDescriptions objectAtIndex:i]; */ - unsigned int theIndex = [classDescriptions indexOfObject:iClassDescriptionClassName]; + NSUInteger theIndex = [classDescriptions indexOfObject:iClassDescriptionClassName]; return (NSNotFound == theIndex) ? nil : [classDescriptions objectAtIndex:theIndex]; } -- (unsigned int) indexOfClassDescription:(id) iClassDescription +- (NSUInteger) indexOfClassDescription:(id) iClassDescription { return [classDescriptions indexOfObject:iClassDescription]; } diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.h b/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.h index 2b7b30ea..4f126928 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.h +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.h @@ -29,7 +29,7 @@ #import <Foundation/Foundation.h> /*" Possible return code on some operations of the database interaction. "*/ -typedef enum { +enum { MCPDBReturnUnknown = 0, /*"Unknown state, should not happen."*/ MCPDBReturnDeleted = 1, /*"The entry have been successfuly deleted from DB."*/ MCPDBReturnUsed = 2, /*"The entry can not be removed, because some entries are still connected to it (some delete restrict/inhibit delete)."*/ @@ -46,7 +46,8 @@ typedef enum { MCPDBReturnNoSuchRelation = 13, /*"There is no relation with such a name starting from this class."*/ MCPDBReturnNotTarget = 14, /*"Tried to remove an object from a relation, while the objects does NOT belong to the relation."*/ MCPDBReturnOK = 100 /*"Everything went OK."*/ -} MCPDBReturnCode; +}; +typedef NSUInteger MCPDBReturnCode; @class MCPConnection; @class MCPClassDescription; @@ -91,18 +92,18 @@ typedef enum { - (id) getTargetOfRelationNamed:(NSString *) iRelationName; - (MCPDBReturnCode) setTarget:(id) iTarget forRelation:(MCPRelation *) iRelation; - (MCPDBReturnCode) setTarget:(id) iTarget forRelationNamed:(NSString *) iRelationName; -- (unsigned int) countTargetForRelation:(MCPRelation *) iRelation; -- (unsigned int) countTargetForRelationNamed:(NSString *) iRelationName; -- (MCPObject *) getTargetOfRelation:(MCPRelation *) iRelation atIndex:(unsigned int) iIndex; -- (MCPObject *) getTargetOfRelationNamed:(NSString *) iRelationName atIndex:(unsigned int) iIndex; +- (NSUInteger) countTargetForRelation:(MCPRelation *) iRelation; +- (NSUInteger) countTargetForRelationNamed:(NSString *) iRelationName; +- (MCPObject *) getTargetOfRelation:(MCPRelation *) iRelation atIndex:(NSUInteger) iIndex; +- (MCPObject *) getTargetOfRelationNamed:(NSString *) iRelationName atIndex:(NSUInteger) iIndex; - (MCPDBReturnCode) addTarget:(MCPObject *) iTarget toRelation:(MCPRelation *) iRelation; - (MCPDBReturnCode) addTarget:(MCPObject *) iTarget toRelationNamed:(NSString *) iRelationName; - (MCPDBReturnCode) removeTarget:(MCPObject *) iTarget toRelation:(MCPRelation *) iRelation; - (MCPDBReturnCode) removeTarget:(MCPObject *) iTarget toRelationNamed:(NSString *) iRelationName; -- (MCPDBReturnCode) removeTargetToRelation:(MCPRelation *) iRelation atIndex:(unsigned int) iIndex; -- (MCPDBReturnCode) removeTargetToRelationNamed:(NSString *) iRelationName atIndex:(unsigned int) iIndex; -- (unsigned int) indexOfTarget:(MCPObject *) iTarget inRelation:(MCPRelation *) iRelation; -- (unsigned int) indexOfTarget:(MCPObject *) iTarget inRelationNamed:(NSString *) iRelationName; +- (MCPDBReturnCode) removeTargetToRelation:(MCPRelation *) iRelation atIndex:(NSUInteger) iIndex; +- (MCPDBReturnCode) removeTargetToRelationNamed:(NSString *) iRelationName atIndex:(NSUInteger) iIndex; +- (NSUInteger) indexOfTarget:(MCPObject *) iTarget inRelation:(MCPRelation *) iRelation; +- (NSUInteger) indexOfTarget:(MCPObject *) iTarget inRelationNamed:(NSString *) iRelationName; #pragma mark Utilities /*" Utility methods "*/ diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.m index 8d219400..ae5e2f59 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPObject.m @@ -66,7 +66,7 @@ { self = [super init]; if (self) { - unsigned int i; + NSUInteger i; NSArray *attrArray; classDescription = [[NSClassDescription classDescriptionForClass:[self class]] retain]; @@ -113,7 +113,7 @@ { NSArray *theAttributes = [classDescription attributes]; // NSArray *thePrimKeys = [classDescription primaryKeyAttributes]; - unsigned i; + NSUInteger i; for (i=0; [theAttributes count] != i; ++i) { MCPAttribute *theAttribute = (MCPAttribute *) [theAttributes objectAtIndex:i]; @@ -179,7 +179,7 @@ Otherwise, the search will be performed in the following order : iTableName.colu { NSArray *theAttributeKeys = [classDescription attributeKeys]; NSArray *thePrefixArray; - unsigned i; + NSUInteger i; // Depending on the value of iTableName, get the search order. if ((nil == iTableName) || ([@"" isEqualToString:iTableName])) { @@ -191,7 +191,7 @@ Otherwise, the search will be performed in the following order : iTableName.colu for (i=0; [theAttributeKeys count] != i; ++i) { id theValue = nil; MCPAttribute *theAttribute = [classDescription attributeWithName:[theAttributeKeys objectAtIndex:i]]; - unsigned j; + NSUInteger j; for (j=0; [thePrefixArray count] != j; ++j) { if (theValue = [iDictionary objectForKey:[NSString stringWithFormat:@"%@%@", [thePrefixArray objectAtIndex:j], [theAttribute externalName]]]) { @@ -214,7 +214,7 @@ Otherwise, the search will be performed in the following order : iTableName.colu { BOOL missingKey = NO; NSArray *theKeyAttr = [classDescription primaryKeyAttributes]; - unsigned i; + NSUInteger i; NSMutableString *query = [NSMutableString stringWithFormat:@"SELECT * FROM %@ WHERE ", [classDescription externalName]]; MCPResult *result; NSDictionary *row; @@ -287,17 +287,17 @@ If the identityAttributes of the class description is empty, the entry will alwa NSArray *theKeyAttr = [classDescription primaryKeyAttributes]; MCPConnection *theConnection = [self connection]; MCPResult *theResult; - unsigned int i; + NSUInteger i; if (! theConnection) { - return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:MCPDBReturnNoConnection], @"MCPDBReturnCode"]; + return [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:MCPDBReturnNoConnection], @"MCPDBReturnCode"]; } if (! [theKeyAttr count]) { // There is no primary key for this object. - [theKeys setObject:[NSNumber numberWithInt:MCPDBReturnNoKey] forKey:@"MCPDBReturnCode"]; + [theKeys setObject:[NSNumber numberWithInteger:MCPDBReturnNoKey] forKey:@"MCPDBReturnCode"]; return [NSDictionary dictionaryWithDictionary:theKeys]; } if (! [theIdAttr count]) { // Identity is not defined for this object. - [theKeys setObject:[NSNumber numberWithInt:MCPDBReturnNoIdentity] forKey:@"MCPDBReturnCode"]; + [theKeys setObject:[NSNumber numberWithInteger:MCPDBReturnNoIdentity] forKey:@"MCPDBReturnCode"]; for (i=0; [theKeyAttr count] != i; ++i) { NSString *theKey = [(MCPAttribute*)[theKeyAttr objectAtIndex:i] name]; [theKeys setObject:[self valueForKey:theKey] forKey:theKey]; @@ -329,7 +329,7 @@ If the identityAttributes of the class description is empty, the entry will alwa } */ if (([[(MCPAttribute *)[theIdAttr objectAtIndex:i] valueClass] isSubclassOfClass:[NSString class]]) && ([(MCPAttribute *)[theIdAttr objectAtIndex:i] width] != 0)) { - [theQuery appendFormat:@"(%@ = SUBSTRING(%@ FROM 1 FOR %u))", [(MCPAttribute *)[theIdAttr objectAtIndex:i] externalName], [theConnection quoteObject:[self valueForKey:[(MCPAttribute *)[theIdAttr objectAtIndex:i] name]]], [(MCPAttribute *)[theIdAttr objectAtIndex:i] width]]; + [theQuery appendFormat:@"(%@ = SUBSTRING(%@ FROM 1 FOR %ld))", [(MCPAttribute *)[theIdAttr objectAtIndex:i] externalName], [theConnection quoteObject:[self valueForKey:[(MCPAttribute *)[theIdAttr objectAtIndex:i] name]]], [(MCPAttribute *)[theIdAttr objectAtIndex:i] width]]; } else { [theQuery appendFormat:@"(%@ = %@)", [(MCPAttribute *)[theIdAttr objectAtIndex:i] externalName], [theConnection quoteObject:[self valueForKey:[(MCPAttribute *)[theIdAttr objectAtIndex:i] name]]]]; @@ -346,11 +346,11 @@ If the identityAttributes of the class description is empty, the entry will alwa if ([theResult numOfRows]) { // the object was found. NSDictionary *theFirstRow = [theResult fetchRowAsDictionary]; if ([theResult numOfRows] != 1) { - NSLog(@"in MCPObject -checkDBIdWithConnection: method.... not only one (as expected) but %i results were found, will take the first one."); - [theKeys setObject:[NSNumber numberWithInt:MCPDBReturnMultiple] forKey:@"MCPDBReturnCode"]; + NSLog(@"in MCPObject -checkDBIdWithConnection: method.... not only one (as expected) but %ld results were found, will take the first one."); + [theKeys setObject:[NSNumber numberWithInteger:MCPDBReturnMultiple] forKey:@"MCPDBReturnCode"]; } else { - [theKeys setObject:[NSNumber numberWithInt:MCPDBReturnOK] forKey:@"MCPDBReturnCode"]; + [theKeys setObject:[NSNumber numberWithInteger:MCPDBReturnOK] forKey:@"MCPDBReturnCode"]; } [theKeys addEntriesFromDictionary:theFirstRow]; // Setting the value of self for the primary key to the one just found. @@ -369,7 +369,7 @@ If the identityAttributes of the class description is empty, the entry will alwa } [theKeys setObject:[self valueForKey:[theAttribute name]] forKey:[theAttribute name]]; } - [theKeys setObject:[NSNumber numberWithInt:MCPDBReturnNone] forKey:@"MCPDBReturnCode"]; + [theKeys setObject:[NSNumber numberWithInteger:MCPDBReturnNone] forKey:@"MCPDBReturnCode"]; // Setting the value of self for the primary key to the default values. /* for (i=0; [theKeyAttr count] != i; ++i) { @@ -395,9 +395,9 @@ If the identityAttributes of the class description is empty, the entry will alwa MCPConnection *theConnection = [self connection]; NSDictionary *theCheckReturn = [self checkDBId]; NSMutableDictionary *theRet; - int theCheckCode = [(NSNumber *)[theCheckReturn objectForKey:@"MCPDBReturnCode"] intValue]; - unsigned i; - unsigned j; + NSInteger theCheckCode = [(NSNumber *)[theCheckReturn objectForKey:@"MCPDBReturnCode"] integerValue]; + NSUInteger i; + NSUInteger j; NSMutableString *theQuery = [NSMutableString string]; NSArray *theAttr = [classDescription attributes]; @@ -409,7 +409,7 @@ If the identityAttributes of the class description is empty, the entry will alwa // NSLog(@"in saveUsingConnection: the entry already existed so will update the one with key : %@", theCheckReturn); theCheckCode = [self updateInDB]; theRet = [NSMutableDictionary dictionaryWithDictionary:[self primaryKey]]; - [theRet setObject:[NSNumber numberWithInt:theCheckCode] forKey:@"MCPDBReturnCode"]; + [theRet setObject:[NSNumber numberWithInteger:theCheckCode] forKey:@"MCPDBReturnCode"]; return [NSDictionary dictionaryWithDictionary:theRet]; break; @@ -417,7 +417,7 @@ If the identityAttributes of the class description is empty, the entry will alwa NSLog(@"Multiple entries found with the same identity ... will update the first one."); theCheckCode = [self updateInDB]; theRet = [NSMutableDictionary dictionaryWithDictionary:[self primaryKey]]; - [theRet setObject:[NSNumber numberWithInt:theCheckCode] forKey:@"MCPDBReturnCode"]; + [theRet setObject:[NSNumber numberWithInteger:theCheckCode] forKey:@"MCPDBReturnCode"]; return [NSDictionary dictionaryWithDictionary:theRet]; break; @@ -429,7 +429,7 @@ If the identityAttributes of the class description is empty, the entry will alwa break; default : // We should not arrive here anyway. - NSLog(@"For some resons we got a unexpected result from checkDBId : %i", theCheckCode); + NSLog(@"For some resons we got a unexpected result from checkDBId : %ld", theCheckCode); break; } @@ -462,7 +462,7 @@ If the identityAttributes of the class description is empty, the entry will alwa // Now we perform the query... [theConnection queryString:theQuery]; if (1 != (i = [theConnection affectedRows])) { // More than one row affected ... Should NEVER occure. - NSLog(@"Problem while saving a MCPObject to the database : number of inserted rows is : %i !!!", i); + NSLog(@"Problem while saving a MCPObject to the database : number of inserted rows is : %ld !!!", i); NSLog(@"Maybe there is an error : %@ ", [theConnection getLastErrorMessage]); NSLog(@"The class of the object is : %@, and it's description is :\n%@", [self className], [self descriptionWithLocale:nil]); theCheckCode = (i == 0) ? MCPDBReturnNone : MCPDBReturnMultiple; @@ -479,7 +479,7 @@ If the identityAttributes of the class description is empty, the entry will alwa } [self getAutoGenerated]; theRet = [NSMutableDictionary dictionaryWithDictionary:[self primaryKey]]; - [theRet setObject:[NSNumber numberWithInt:theCheckCode] forKey:@"MCPDBReturnCode"]; + [theRet setObject:[NSNumber numberWithInteger:theCheckCode] forKey:@"MCPDBReturnCode"]; return [NSDictionary dictionaryWithDictionary:theRet]; } @@ -501,9 +501,9 @@ some auto-generated attributes. NSMutableArray *theAutoAttr = [NSMutableArray array]; NSArray *theAttr = [classDescription attributes]; NSArray *theKeyAttr = [classDescription primaryKeyAttributes]; - unsigned i,j; + NSUInteger i,j; NSMutableString *theQuery; - int theCheckCode; + NSInteger theCheckCode; MCPResult *theResult; NSDictionary *theRow; MCPConnection *theConnection = [self connection]; @@ -513,7 +513,7 @@ some auto-generated attributes. } if (0 != [[classDescription identityAttributes] count]) { - theCheckCode = [(NSNumber *)[[self checkDBId] objectForKey:@"MCPDBReturnCode"] intValue]; + theCheckCode = [(NSNumber *)[[self checkDBId] objectForKey:@"MCPDBReturnCode"] integerValue]; if ((MCPDBReturnOK != theCheckCode) && (MCPDBReturnMultiple != theCheckCode)) { NSLog(@"Unable to get the primary key for the object, will abort now the fetch of autoGenerated attributes (left unchanged)!"); return theCheckCode; @@ -586,8 +586,8 @@ some auto-generated attributes. NSArray *theAttributes = [classDescription attributes]; NSArray *thePrimKeyAttributes = [classDescription primaryKeyAttributes]; NSMutableString *theQuery = [NSMutableString string]; - int theCheckCode; - unsigned i, j; + NSInteger theCheckCode; + NSUInteger i, j; MCPConnection *theConnection = [self connection]; if (! theConnection) { @@ -644,7 +644,7 @@ some auto-generated attributes. } else { NSDictionary *theKeyCheck = [self checkDBId]; - int theIdCheckCode = [(NSNumber *) [theKeyCheck objectForKey:@"MCPDBReturnCode"] intValue]; + NSInteger theIdCheckCode = [(NSNumber *) [theKeyCheck objectForKey:@"MCPDBReturnCode"] integerValue]; if (MCPDBReturnOK == theIdCheckCode) { theCheckCode = [self updateInDB]; @@ -665,9 +665,9 @@ some auto-generated attributes. { NSArray *theKeyAttributes = [classDescription primaryKeyAttributes]; NSArray *theAttributes = [classDescription attributes]; - unsigned i; + NSUInteger i; // NSMutableDictionary *theKeyValue = [NSMutableDictionary dictionary]; - int theCheckCode = MCPDBReturnOK; + NSInteger theCheckCode = MCPDBReturnOK; MCPConnection *theConnection = [self connection]; if (! theConnection) { @@ -676,14 +676,14 @@ some auto-generated attributes. // Get the value of the primary key: for (i=0; [theKeyAttributes count] != i; ++i) { id theValue = [self valueForKey:[(MCPAttribute*) [theKeyAttributes objectAtIndex:i] name]]; - if ((! theValue) || ([theValue isKindOfClass:[NSNumber class]] && (0 == [theValue intValue]))) { + if ((! theValue) || ([theValue isKindOfClass:[NSNumber class]] && (0 == [theValue integerValue]))) { theCheckCode = MCPDBReturnIncompleteKey; break; } } // If incomplete, try to find the rest, and perform again: if (MCPDBReturnIncompleteKey == theCheckCode) { - if (MCPDBReturnOK == [(NSNumber *)[[self checkDBId] objectForKey:@"MCPDBReturnCode"] intValue]) { + if (MCPDBReturnOK == [(NSNumber *)[[self checkDBId] objectForKey:@"MCPDBReturnCode"] integerValue]) { return [self deleteInDB]; } else { @@ -715,7 +715,7 @@ some auto-generated attributes. NSMutableString *theQuery = [NSMutableString string]; MCPClassDescription *theClassDescription = (MCPClassDescription *) [NSClassDescription classDescriptionForClass:[self class]]; NSArray *theKeyAttributes = [theClassDescription primaryKeyAttributes]; - unsigned i; + NSUInteger i; if (! [iConnection checkConnection]) { return MCPDBReturnNoConnection; @@ -762,7 +762,7 @@ Also the returned object is ALWAYS autoreleased before being returned. NSArray *keys; NSArray *ids; MCPResult *result; - unsigned int i; + NSUInteger i; NSDictionary *theRow; id theRet; @@ -851,7 +851,7 @@ Also the returned object is ALWAYS autoreleased before being returned. Obviuosly this method is taking care of only to-one relation. It will hence check that iRelation is a to-one relation starting from self. Finally, you can use setTarget:nil forRelation:... to 'delete' a previously establlished relation (if the model and DB permit it)."*/ { - unsigned int i; + NSUInteger i; MCPObject *oldTarget; if (! [connection isConnected]) { @@ -891,10 +891,10 @@ Finally, you can use setTarget:nil forRelation:... to 'delete' a previously esta return (theRelation) ? [self setTarget:iTarget forRelation:theRelation] : MCPDBReturnNoSuchRelation; } -- (unsigned int) countTargetForRelation:(MCPRelation *) iRelation +- (NSUInteger) countTargetForRelation:(MCPRelation *) iRelation { NSMutableString *theQuery; - unsigned int i; + NSUInteger i; NSArray *theJoinArray; MCPResult *theResult; NSDictionary *theRow; @@ -914,30 +914,30 @@ Finally, you can use setTarget:nil forRelation:... to 'delete' a previously esta theResult = [connection queryString:theQuery]; [theQuery release]; theRow = [theResult fetchRowAsDictionary]; - return [(NSNumber *)[theRow objectForKey:@"COUNT(*)"] unsignedIntValue]; + return [(NSNumber *)[theRow objectForKey:@"COUNT(*)"] unsignedIntegerValue]; } -- (unsigned int) countTargetForRelationNamed:(NSString *) iRelationName +- (NSUInteger) countTargetForRelationNamed:(NSString *) iRelationName { MCPRelation *theRelation = [classDescription relationWithName:iRelationName]; return (theRelation) ? [self countTargetForRelation:theRelation] : 0; } -- (MCPObject *) getTargetOfRelation:(MCPRelation *) iRelation atIndex:(unsigned int) iIndex +- (MCPObject *) getTargetOfRelation:(MCPRelation *) iRelation atIndex:(NSUInteger) iIndex /*" This method will return the specific object which is the iIndex'th object of th relation (after ordering the object using the destination identity). This method (like other assuming order in the relation targets) will be doubtfull if the class does NOT have a single identity attribute."*/ { NSMutableString *query; MCPClassDescription *destinationDesc; - NSArray *joins; - NSArray *keys; - NSArray *ids; - MCPResult *result; - unsigned int i; - NSDictionary *theRow; - MCPObject *theRet; + NSArray *joins; + NSArray *keys; + NSArray *ids; + MCPResult *result; + NSUInteger i; + NSDictionary *theRow; + MCPObject *theRet; if (! iRelation) { NSLog(@"Tried to get the target of a relation... but the relation object is nil"); @@ -983,7 +983,7 @@ This method (like other assuming order in the relation targets) will be doubtful [query appendString:[(MCPAttribute *)[ids objectAtIndex:i] externalName]]; } */ - [query appendFormat:@" LIMIT 1 OFFSET %u", iIndex]; + [query appendFormat:@" LIMIT 1 OFFSET %ld", iIndex]; result = [connection queryString:query]; [query release]; @@ -1000,7 +1000,7 @@ This method (like other assuming order in the relation targets) will be doubtful return theRet; } -- (MCPObject *) getTargetOfRelationNamed:(NSString *) iRelationName atIndex:(unsigned int) iIndex +- (MCPObject *) getTargetOfRelationNamed:(NSString *) iRelationName atIndex:(NSUInteger) iIndex /*"This is the equivalent of the getTargetOfRelation:atIndex:, but giving a relation name instead of the MCPRelation object itself."*/ { MCPRelation *theRelation = [classDescription relationWithName:iRelationName]; @@ -1014,7 +1014,7 @@ If any value corresping to an attribute of self i modified in the DB, then it wi Obviuosly this method is taking care of only to-many relation. It will hence check that iRelation is a to-many relation starting from self."*/ { NSArray *joins; - unsigned int i; + NSUInteger i; NSDictionary *saveReturn; if (! [connection isConnected]) { @@ -1036,7 +1036,7 @@ Obviuosly this method is taking care of only to-many relation. It will hence che [iTarget setConnection:connection]; } saveReturn = [iTarget saveInDB]; - return (MCPDBReturnCode)[(NSNumber *)[saveReturn objectForKey:@"MCPDBReturnCode"] unsignedIntValue]; + return (MCPDBReturnCode)[(NSNumber *)[saveReturn objectForKey:@"MCPDBReturnCode"] unsignedIntegerValue]; } - (MCPDBReturnCode) addTarget:(MCPObject *) iTarget toRelationNamed:(NSString *) iRelationName @@ -1052,7 +1052,7 @@ If any value corresping to an attribute of self i modified in the DB, then it wi Obviuosly this method is taking care of only to-many relation. It will hence check that iRelation is a to-many relation starting from self."*/ { NSArray *joins; - unsigned int i; + NSUInteger i; // NSDictionary *saveReturn; BOOL targetIsTarget = YES; MCPDBReturnCode returnCode; @@ -1083,7 +1083,7 @@ Obviuosly this method is taking care of only to-many relation. It will hence che [iTarget setValue:[[join destination] defaultValue] forKey:[[join destination] name]]; } if (! [iRelation ownsDestination]) { - returnCode = [(NSNumber *)[[iTarget saveInDB] objectForKey:@"MCPDBReturnCode"] unsignedIntValue]; + returnCode = [(NSNumber *)[[iTarget saveInDB] objectForKey:@"MCPDBReturnCode"] unsignedIntegerValue]; } return returnCode; } @@ -1094,7 +1094,7 @@ Obviuosly this method is taking care of only to-many relation. It will hence che return (theRelation) ? [self removeTarget:iTarget toRelation:theRelation] : MCPDBReturnNoSuchRelation; } -- (MCPDBReturnCode) removeTargetToRelation:(MCPRelation *) iRelation atIndex:(unsigned int) iIndex +- (MCPDBReturnCode) removeTargetToRelation:(MCPRelation *) iRelation atIndex:(NSUInteger) iIndex /*" This method will use an index t first query the object that it should remove from the relation, then uses the -[MCPObject removeTarget:toRelation:] method to remove the object from the relation. If the index is out of bound (the returned object is nil), it will return MCPDBReturnNone, to signal there was no object with this index in the relation."*/ @@ -1119,20 +1119,20 @@ Obviuosly this method is taking care of only to-many relation. It will hence che } } -- (MCPDBReturnCode) removeTargetToRelationNamed:(NSString *) iRelationName atIndex:(unsigned int) iIndex +- (MCPDBReturnCode) removeTargetToRelationNamed:(NSString *) iRelationName atIndex:(NSUInteger) iIndex { MCPRelation *theRelation = [classDescription relationWithName:iRelationName]; return (theRelation) ? [self removeTargetToRelation:theRelation atIndex:iIndex] : MCPDBReturnNoSuchRelation; } -- (unsigned int) indexOfTarget:(MCPObject *) iTarget inRelation:(MCPRelation *) iRelation +- (NSUInteger) indexOfTarget:(MCPObject *) iTarget inRelation:(MCPRelation *) iRelation /*" Returns the index of the target object within the relation. Return NSNotFound if the objkect is NOT in the relation!!"*/ { NSMutableString *query; NSArray *joins; NSArray *keys; NSArray *ids; - unsigned int i; + NSUInteger i; MCPResult *result; NSDictionary *row; NSMutableDictionary *targetKey; @@ -1195,7 +1195,7 @@ Obviuosly this method is taking care of only to-many relation. It will hence che return NSNotFound; } -- (unsigned int) indexOfTarget:(MCPObject *) iTarget inRelationNamed:(NSString *) iRelationName +- (NSUInteger) indexOfTarget:(MCPObject *) iTarget inRelationNamed:(NSString *) iRelationName /*" The equivalent of -[MCPObject indexOfTarget:inRelation:] but using relation name instead of a MCPRelation object. Indeed after getting the MCPRelation object corresponding to the name, this method will only return the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]."*/ @@ -1219,7 +1219,7 @@ the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]." id theRet; if ([theAttrClass isSubclassOfClass:[NSNumber class]]) { - return [NSNumber numberWithInt:0]; + return [NSNumber numberWithInteger:0]; } theRet = [[[theAttrClass alloc] init] autorelease]; if (nil == theRet) { @@ -1235,7 +1235,7 @@ the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]." { NSMutableDictionary *theRet = [NSMutableDictionary dictionary]; NSArray *theIdAttr = [classDescription primaryKeyAttributes]; - unsigned i; + NSUInteger i; for (i=0; [theIdAttr count] != i; ++i) { NSString *theKey = [(MCPAttribute *)[theIdAttr objectAtIndex:i] name]; @@ -1254,7 +1254,7 @@ the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]." - (BOOL) isEqual:(id) iObject { NSArray *theIdAttr; - unsigned int i; + NSUInteger i; BOOL theRet; if (self == iObject) { @@ -1281,15 +1281,17 @@ the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]." - (NSString *) descriptionWithLocale:(NSDictionary *) locale { - NSMutableString *theOutput = [NSMutableString string]; - unsigned int i; - NSArray *theAttributes = [classDescription attributes]; - BOOL trunc = [MCPConnection truncateLongField]; + NSMutableString *theOutput = [NSMutableString string]; + NSUInteger i; + NSArray *theAttributes = [classDescription attributes]; + BOOL trunc = [MCPConnection truncateLongField]; - [theOutput appendFormat:@"MCPObject subclass : %@\n", [self className]]; - for (i=0; [theAttributes count] != i; ++i) { - MCPAttribute *theAttribute = (MCPAttribute *) [theAttributes objectAtIndex:i]; - id theValue = [self valueForKey:[theAttribute name]]; + [theOutput appendFormat:@"MCPObject subclass : %@\n", [self className]]; + + for (i = 0; [theAttributes count] != i; ++i) + { + MCPAttribute *theAttribute = (MCPAttribute *) [theAttributes objectAtIndex:i]; + id theValue = [self valueForKey:[theAttribute name]]; if (trunc) { if (([theValue isKindOfClass:[NSString class]]) && (kLengthOfTruncationForLog < [(NSString *)theValue length])) { @@ -1299,10 +1301,13 @@ the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]." theValue = [NSData dataWithBytes:[theValue bytes] length:kLengthOfTruncationForLog]; } } - [theOutput appendFormat:@"\tAttribute %u : name = %@, value = %@\n", i, [theAttribute name], theValue]; - } - [theOutput appendString:@"\n"]; - return theOutput; + + [theOutput appendFormat:@"\tAttribute %ld : name = %@, value = %@\n", i, [theAttribute name], theValue]; + } + + [theOutput appendString:@"\n"]; + + return theOutput; } #pragma mark Ordering the array for relations @@ -1310,7 +1315,7 @@ the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]." { NSMutableArray *theAttributes = [[NSMutableArray alloc] initWithArray:[iClassDescription identityAttributes]]; NSMutableString *theReturn = [NSMutableString string]; - unsigned int i; + NSUInteger i; for (i = 0; [[iClassDescription primaryKeyAttributes] count] != i; ++i) { [theAttributes insertObject:[[iClassDescription primaryKeyAttributes] objectAtIndex:i] atIndex:[theAttributes count]]; @@ -1331,7 +1336,7 @@ the result of the corresponding call to -[MCPObject indexOfTarget:inRelation:]." - (void) setNilValueForKey:(NSString *) iKey { NSLog(@"Try to set %@ to nil .... not possible, will set it to zero instead...", iKey); - [self setValue:[NSNumber numberWithInt:0] forKey:iKey]; + [self setValue:[NSNumber numberWithInteger:0] forKey:iKey]; } @end diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.h b/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.h index 5cf2437a..118734eb 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.h +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.h @@ -81,8 +81,8 @@ typedef enum { - (void) setName:(NSString *) iName; - (void) setDeleteRule:(MCPRelationDeleteRule) iDeleteRule; - (void) setInverseRelation:(MCPRelation *) iInverseRelation; -- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(unsigned int) index; -- (void) removeObjectFromJoinsAtIndex:(unsigned int) index; +- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(NSUInteger) index; +- (void) removeObjectFromJoinsAtIndex:(NSUInteger) index; - (void) setIsToMany:(BOOL) iIsToMany; - (void) setIsMandatory:(BOOL) iIsMandatory; - (void) setOwnsDestintation:(BOOL) iOwnsDestination; @@ -94,9 +94,9 @@ typedef enum { - (MCPClassDescription *) origin; - (MCPClassDescription *) destination; - (NSArray *) joins; -- (unsigned int) countOfJoins; -- (MCPJoin *) objectInJoinsAtIndex:(unsigned int) index; -- (unsigned int) indexOfJoinIdenticalTo:(id) iJoin; +- (NSUInteger) countOfJoins; +- (MCPJoin *) objectInJoinsAtIndex:(NSUInteger) index; +- (NSUInteger) indexOfJoinIdenticalTo:(id) iJoin; - (BOOL) isToMany; - (BOOL) isMandatory; - (BOOL) ownsDestination; diff --git a/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.m b/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.m index 9aa94fb1..6d1e58f4 100644 --- a/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.m +++ b/Frameworks/MCPKit/MCPEntrepriseKit/MCPRelation.m @@ -50,11 +50,11 @@ static NSArray *MCPexistingDeleteRules; [self setVersion:010101]; // Ma.Mi.Re -> MaMiRe - [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:OnDeleteNullify], @"tag", @"Nullify", @"name", nil]]; - [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:OnDeleteDeny], @"tag", @"Deny", @"name", nil]]; - [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:OnDeleteCascade], @"tag", @"Cascade", @"name", nil]]; - [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:OnDeleteDefault], @"tag", @"Default", @"name", nil]]; - [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:OnDeleteNoAction], @"tag", @"No Action", @"name", nil]]; + [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInteger:OnDeleteNullify], @"tag", @"Nullify", @"name", nil]]; + [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInteger:OnDeleteDeny], @"tag", @"Deny", @"name", nil]]; + [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInteger:OnDeleteCascade], @"tag", @"Cascade", @"name", nil]]; + [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInteger:OnDeleteDefault], @"tag", @"Default", @"name", nil]]; + [theExistingDeleteRules addObject:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInteger:OnDeleteNoAction], @"tag", @"No Action", @"name", nil]]; MCPexistingDeleteRules = [[NSArray alloc] initWithArray:theExistingDeleteRules]; [theExistingDeleteRules release]; } @@ -188,7 +188,7 @@ static NSArray *MCPexistingDeleteRules; - (void) removeJoinFrom:(MCPAttribute *) iFrom to:(MCPAttribute *) iTo { NSDictionary *theJoinDict = [[NSDictionary alloc] initWithObjectsAndKeys:self, @"relation", iFrom, @"origin", iTo, @"destination", nil]; - unsigned int i = [joins indexOfObject:theJoinDict]; + NSUInteger i = [joins indexOfObject:theJoinDict]; if (NSNotFound != i) { [[self objectInJoinsAtIndex:i] invalidate]; @@ -263,12 +263,12 @@ static NSArray *MCPexistingDeleteRules; } } -- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(unsigned int) index +- (void) insertObject:(MCPJoin *) iJoin inJoinsAtIndex:(NSUInteger) index { [joins insertObject:iJoin atIndex:index]; } -- (void) removeObjectFromJoinsAtIndex:(unsigned int) index +- (void) removeObjectFromJoinsAtIndex:(NSUInteger) index { [joins removeObjectAtIndex:index]; } @@ -334,17 +334,17 @@ static NSArray *MCPexistingDeleteRules; return [NSArray arrayWithArray:joins]; } -- (unsigned int) countOfJoins +- (NSUInteger) countOfJoins { return [joins count]; } -- (MCPJoin *) objectInJoinsAtIndex:(unsigned int) index +- (MCPJoin *) objectInJoinsAtIndex:(NSUInteger) index { return (MCPJoin *)((NSNotFound != index) ? [joins objectAtIndex:index] : nil); } -- (unsigned int) indexOfJoinIdenticalTo:(id) iJoin +- (NSUInteger) indexOfJoinIdenticalTo:(id) iJoin { return [joins indexOfObjectIdenticalTo:iJoin]; } @@ -368,7 +368,7 @@ static NSArray *MCPexistingDeleteRules; - (MCPAttribute *) destinationAttributeForOrigin:(MCPAttribute *) iFrom { - unsigned int i; + NSUInteger i; for (i=0; ([joins count] != i) && ([[(MCPJoin *)[joins objectAtIndex:i] origin] isEqual:iFrom]); ++i) { } @@ -377,7 +377,7 @@ static NSArray *MCPexistingDeleteRules; - (MCPAttribute *) originAttributeForDestination:(MCPAttribute *) iTo { - unsigned int i; + NSUInteger i; for (i=0; ([joins count] != i) && ([[(MCPJoin *)[joins objectAtIndex:i] destination] isEqual:iTo]); ++i) { } @@ -404,7 +404,7 @@ static NSArray *MCPexistingDeleteRules; - (NSString *) descriptionWithLocale:(NSDictionary *) locale { NSMutableString *theRet = [NSMutableString stringWithFormat:@"MCPRelation named %@, going from %@ to %@. Joins :\n", name, [origin name], [destination name]]; - unsigned int i; + NSUInteger i; for (i = 0; [joins count] != i; ++i) { MCPJoin *tmpJoin = (MCPJoin *)[joins objectAtIndex:i]; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h index 5b8aefba..edb71ee4 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h @@ -32,12 +32,13 @@ #import "mysql.h" -enum mcp_query_streaming_types +enum { MCP_NO_STREAMING = 0, MCP_FAST_STREAMING = 1, MCP_LOWMEM_STREAMING = 2 }; +typedef NSUInteger mcp_query_streaming_types; @class MCPResult, MCPStreamingResult; @protocol MCPConnectionProxy; @@ -45,9 +46,9 @@ enum mcp_query_streaming_types /** * NSStringDataUsingLossyEncoding(aStr, enc, lossy) := [aStr dataUsingEncoding:enc allowLossyConversion:lossy] */ -static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encoding, int lossy) +static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, NSInteger encoding, NSInteger lossy) { - typedef NSData* (*SPStringDataUsingLossyEncodingMethodPtr)(NSString*, SEL, int, int); + typedef NSData* (*SPStringDataUsingLossyEncodingMethodPtr)(NSString*, SEL, NSInteger, NSInteger); static SPStringDataUsingLossyEncodingMethodPtr SPNSStringDataUsingLossyEncoding; if (!SPNSStringDataUsingLossyEncoding) SPNSStringDataUsingLossyEncoding = (SPStringDataUsingLossyEncodingMethodPtr)[self methodForSelector:@selector(dataUsingEncoding:allowLossyConversion:)]; NSData* to_return = SPNSStringDataUsingLossyEncoding(self, @selector(dataUsingEncoding:allowLossyConversion:), encoding, lossy); @@ -73,30 +74,30 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin BOOL mConnected; /* Reflect the fact that the connection is already in place or not. */ NSStringEncoding mEncoding; /* The encoding used by MySQL server, to ISO-1 default. */ NSTimeZone *mTimeZone; /* The time zone of the session. */ - unsigned int mConnectionFlags; /* The flags to be used for the connection to the database. */ + NSUInteger mConnectionFlags; /* The flags to be used for the connection to the database. */ id delegate; /* Connection delegate */ NSLock *queryLock; /* Anything that performs a mysql_net_read is not thread-safe: mysql queries, pings */ BOOL useKeepAlive; - int connectionTimeout; - float keepAliveInterval; + NSInteger connectionTimeout; + CGFloat keepAliveInterval; id <MCPConnectionProxy> connectionProxy; NSString *connectionLogin; NSString *connectionPassword; NSString *connectionHost; - int connectionPort; + NSInteger connectionPort; NSString *connectionSocket; - int maxAllowedPacketSize; + NSInteger maxAllowedPacketSize; unsigned long connectionThreadId; - int currentProxyState; + NSInteger currentProxyState; double lastQueryExecutionTime; double lastQueryExecutedAtTime; NSString *lastQueryErrorMessage; - unsigned int lastQueryErrorId; + NSUInteger lastQueryErrorId; my_ulonglong lastQueryAffectedRows; BOOL isMaxAllowedPacketEditable; @@ -128,11 +129,11 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin @property (readwrite, assign) BOOL useKeepAlive; @property (readwrite, assign) BOOL delegateQueryLogging; -@property (readwrite, assign) int connectionTimeout; -@property (readwrite, assign) float keepAliveInterval; +@property (readwrite, assign) NSInteger connectionTimeout; +@property (readwrite, assign) CGFloat keepAliveInterval; // Initialisation -- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(int)port; +- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSInteger)port; - (id)initToSocket:(NSString *)socket withLogin:(NSString *)login; // Delegate @@ -140,7 +141,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin - (void)setDelegate:(id)connectionDelegate; // Connection details -- (BOOL)setPort:(int)thePort; +- (BOOL)setPort:(NSInteger)thePort; - (BOOL)setPassword:(NSString *)thePassword; // Proxy @@ -163,29 +164,29 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin - (double)timeConnected; // Server versions -- (int)serverMajorVersion; -- (int)serverMinorVersion; -- (int)serverReleaseVersion; +- (NSInteger)serverMajorVersion; +- (NSInteger)serverMinorVersion; +- (NSInteger)serverReleaseVersion; // MySQL defaults + (NSDictionary *)getMySQLLocales; + (NSStringEncoding)encodingForMySQLEncoding:(const char *)mysqlEncoding; + (NSStringEncoding)defaultMySQLEncoding; -+ (BOOL)isErrorNumberConnectionError:(int)theErrorNumber; ++ (BOOL)isErrorNumberConnectionError:(NSInteger)theErrorNumber; // Class maintenance + (void)setTruncateLongFieldInLogs:(BOOL)iTruncFlag; + (BOOL)truncateLongField; -- (BOOL)setConnectionOption:(int)option toValue:(BOOL)value; -- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(int)port socket:(NSString *)socket; +- (BOOL)setConnectionOption:(NSInteger)option toValue:(BOOL)value; +- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSInteger)port socket:(NSString *)socket; - (BOOL)selectDB:(NSString *)dbName; // Error information - (NSString *)getLastErrorMessage; - (void)setLastErrorMessage:(NSString *)theErrorMessage; -- (unsigned int)getLastErrorID; -+ (BOOL)isErrorNumberConnectionError:(int)theErrorNumber; +- (NSUInteger)getLastErrorID; ++ (BOOL)isErrorNumberConnectionError:(NSInteger)theErrorNumber; // Queries - (NSString *)prepareBinaryData:(NSData *)theData; @@ -194,7 +195,7 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin - (MCPResult *)queryString:(NSString *)query; - (MCPStreamingResult *)streamingQueryString:(NSString *)query; - (MCPStreamingResult *)streamingQueryString:(NSString *)query useLowMemoryBlockingStreaming:(BOOL)fullStream; -- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(int) streamResult; +- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(NSInteger) streamResult; - (double)lastQueryExecutionTime; - (my_ulonglong)affectedRows; - (my_ulonglong)insertId; @@ -230,9 +231,9 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin // Packet size - (BOOL)fetchMaxAllowedPacket; -- (int)getMaxAllowedPacket; +- (NSInteger)getMaxAllowedPacket; - (BOOL)isMaxAllowedPacketEditable; -- (int)setMaxAllowedPacketTo:(int)newSize resetSize:(BOOL)reset; +- (NSInteger)setMaxAllowedPacketTo:(NSInteger)newSize resetSize:(BOOL)reset; // Data conversion - (const char *)cStringFromString:(NSString *)theString; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 2463041a..06a8a757 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -38,12 +38,12 @@ #include <mach/mach_time.h> static jmp_buf pingTimeoutJumpLocation; -static void forcePingTimeout(int signalNumber); +static void forcePingTimeout(NSInteger signalNumber); -const unsigned int kMCPConnectionDefaultOption = CLIENT_COMPRESS | CLIENT_REMEMBER_OPTIONS ; +const NSUInteger kMCPConnectionDefaultOption = CLIENT_COMPRESS | CLIENT_REMEMBER_OPTIONS ; const char *kMCPConnectionDefaultSocket = MYSQL_UNIX_ADDR; -const unsigned int kMCPConnection_Not_Inited = 1000; -const unsigned int kLengthOfTruncationForLog = 100; +const NSUInteger kMCPConnection_Not_Inited = 1000; +const NSUInteger kLengthOfTruncationForLog = 100; static BOOL sTruncateLongFieldInLogs = YES; @@ -99,7 +99,7 @@ static BOOL sTruncateLongFieldInLogs = YES; connectionProxy = nil; lastKeepAliveSuccess = nil; connectionStartTime = -1; - lastQueryExecutedAtTime = INT_MAX; + lastQueryExecutedAtTime = CGFLOAT_MAX; // Initialize ivar defaults connectionTimeout = 10; @@ -137,7 +137,7 @@ static BOOL sTruncateLongFieldInLogs = YES; /** * Inialize connection using the supplied host details. */ -- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(int)port +- (id)initToHost:(NSString *)host withLogin:(NSString *)login usingPort:(NSInteger)port { if ((self = [self init])) { if (!host) host = @""; @@ -203,7 +203,7 @@ static BOOL sTruncateLongFieldInLogs = YES; /** * Sets or updates the connection port - for use with tunnels. */ -- (BOOL)setPort:(int)thePort +- (BOOL)setPort:(NSInteger)thePort { connectionPort = thePort; @@ -249,7 +249,7 @@ static BOOL sTruncateLongFieldInLogs = YES; */ - (void)connectionProxyStateChange:(id <MCPConnectionProxy>)proxy { - int newState = [proxy state]; + NSInteger newState = [proxy state]; // Restart the tunnel if it dies if (mConnected && newState == PROXY_STATE_IDLE && currentProxyState == PROXY_STATE_CONNECTED) { @@ -614,7 +614,7 @@ static BOOL sTruncateLongFieldInLogs = YES; * This function is paired with pingConnection, and provides a method of enforcing the connection * timeout when mysql_ping does not respect the specified limits. */ -static void forcePingTimeout(int signalNumber) +static void forcePingTimeout(NSInteger signalNumber) { longjmp(pingTimeoutJumpLocation, 1); } @@ -744,7 +744,7 @@ static void forcePingTimeout(int signalNumber) /** * rReturn the server major version or -1 on fail */ -- (int)serverMajorVersion +- (NSInteger)serverMajorVersion { if (mConnected) { @@ -753,7 +753,7 @@ static void forcePingTimeout(int signalNumber) } if (serverVersionString != nil) { - return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:0] intValue]; + return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:0] integerValue]; } } @@ -763,7 +763,7 @@ static void forcePingTimeout(int signalNumber) /** * Return the server minor version or -1 on fail */ -- (int)serverMinorVersion +- (NSInteger)serverMinorVersion { if (mConnected) { @@ -772,7 +772,7 @@ static void forcePingTimeout(int signalNumber) } if(serverVersionString != nil) { - return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:1] intValue]; + return [[[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:1] integerValue]; } } @@ -782,7 +782,7 @@ static void forcePingTimeout(int signalNumber) /** * Return the server release version or -1 on fail */ -- (int)serverReleaseVersion +- (NSInteger)serverReleaseVersion { if (mConnected) { if (serverVersionString == nil) { @@ -791,7 +791,7 @@ static void forcePingTimeout(int signalNumber) if (serverVersionString != nil) { NSString *s = [[serverVersionString componentsSeparatedByString:@"."] objectAtIndex:2]; - return [[[s componentsSeparatedByString:@"-"] objectAtIndex:0] intValue]; + return [[[s componentsSeparatedByString:@"-"] objectAtIndex:0] integerValue]; } } @@ -964,7 +964,7 @@ static void forcePingTimeout(int signalNumber) * [theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0]; * */ -- (BOOL)setConnectionOption:(int)option toValue:(BOOL)value +- (BOOL)setConnectionOption:(NSInteger)option toValue:(BOOL)value { // So far do nothing except for testing if it's proper time for setting option // What about if some option where setted and a connection is made again with connectTo... @@ -994,7 +994,7 @@ static void forcePingTimeout(int signalNumber) * The socket is used if the host is set to !{@"localhost"}, to an empty or a !{nil} string * For the moment the implementation might not be safe if you have a nil pointer to one of the NSString* variables (underestand: I don't know what the result will be). */ -- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(int)port socket:(NSString *)socket +- (BOOL)connectWithLogin:(NSString *)login password:(NSString *)pass host:(NSString *)host port:(NSInteger)port socket:(NSString *)socket { const char *theLogin = [self cStringFromString:login]; const char *theHost = [self cStringFromString:host]; @@ -1105,7 +1105,7 @@ static void forcePingTimeout(int signalNumber) /** * Returns the ErrorID of the last MySQL error on the connection. */ -- (unsigned int)getLastErrorID +- (NSUInteger)getLastErrorID { return lastQueryErrorId; } @@ -1113,7 +1113,7 @@ static void forcePingTimeout(int signalNumber) /** * Determines whether a supplied error number can be classed as a connection error. */ -+ (BOOL)isErrorNumberConnectionError:(int)theErrorNumber ++ (BOOL)isErrorNumberConnectionError:(NSInteger)theErrorNumber { switch (theErrorNumber) { @@ -1264,16 +1264,16 @@ static void forcePingTimeout(int signalNumber) * and the result can be returned or the connection and document have been closed. * If using streamingResult, the caller is responsible for releasing the result set. */ -- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(int) streamResultType +- (id)queryString:(NSString *) query usingEncoding:(NSStringEncoding) encoding streamingResult:(NSInteger) streamResultType { MCPResult *theResult = nil; double queryStartTime, queryExecutionTime; const char *theCQuery; unsigned long theCQueryLength; - int queryResultCode; - int queryErrorId = 0; + NSInteger queryResultCode; + NSInteger queryErrorId = 0; my_ulonglong queryAffectedRows = 0; - int currentMaxAllowedPacket = -1; + NSInteger currentMaxAllowedPacket = -1; BOOL isQueryRetry = NO; NSString *queryErrorMessage = nil; @@ -1322,9 +1322,9 @@ static void forcePingTimeout(int signalNumber) } else { - NSString *errorMessage = [NSString stringWithFormat:NSLocalizedString(@"The query length of %d bytes is larger than max_allowed_packet size (%d).", + NSString *errorMessage = [NSString stringWithFormat:NSLocalizedString(@"The query length of %ld bytes is larger than max_allowed_packet size (%ld).", @"error message if max_allowed_packet < query size"), - theCQueryLength, maxAllowedPacketSize]; + (unsigned long)theCQueryLength, maxAllowedPacketSize]; // Write a log entry and update the connection error messages for those uses that check it if ([delegate respondsToSelector:@selector(queryGaveError:connection:)]) [delegate queryGaveError:errorMessage connection:self]; @@ -1687,7 +1687,7 @@ static void forcePingTimeout(int signalNumber) */ - (NSNumber *)protoInfo { - return [MCPNumber numberWithUnsignedInt:mysql_get_proto_info(mConnection)]; + return [MCPNumber numberWithUnsignedInteger:mysql_get_proto_info(mConnection)]; } /** @@ -1720,7 +1720,7 @@ static void forcePingTimeout(int signalNumber) */ - (BOOL)killProcess:(unsigned long)pid { - int theErrorCode = mysql_kill(mConnection, pid); + NSInteger theErrorCode = mysql_kill(mConnection, pid); return (theErrorCode) ? NO : YES; } @@ -1745,7 +1745,7 @@ static void forcePingTimeout(int signalNumber) @"/Applications/MAMP/tmp/mysql/mysql.sock", // MAMP default location nil]; - for (int i = 0; i < [possibleSocketLocations count]; i++) + for (NSInteger i = 0; i < [possibleSocketLocations count]; i++) { if ([fileManager fileExistsAtPath:[possibleSocketLocations objectAtIndex:i]]) return [possibleSocketLocations objectAtIndex:i]; @@ -1881,7 +1881,7 @@ static void forcePingTimeout(int signalNumber) [r autorelease]; if([a count]) { [queryLock unlock]; - maxAllowedPacketSize = [[a objectAtIndex:([self serverMajorVersion] == 3)?1:0] intValue]; + maxAllowedPacketSize = [[a objectAtIndex:([self serverMajorVersion] == 3)?1:0] integerValue]; return true; } } @@ -1895,7 +1895,7 @@ static void forcePingTimeout(int signalNumber) * Retrieves max_allowed_packet size set as global variable. * It returns -1 if it fails. */ -- (int)getMaxAllowedPacket +- (NSInteger)getMaxAllowedPacket { MCPResult *r; r = [self queryString:@"SELECT @@global.max_allowed_packet" usingEncoding:mEncoding streamingResult:NO]; @@ -1906,7 +1906,7 @@ static void forcePingTimeout(int signalNumber) } NSArray *a = [r fetchRowAsArray]; if([a count]) - return [[a objectAtIndex:0] intValue]; + return [[a objectAtIndex:0] integerValue]; return -1; } @@ -1917,20 +1917,20 @@ static void forcePingTimeout(int signalNumber) * if the maximal size was reached (e.g. set it to 4GB it'll return 1GB up to now). * If something failed it return -1; */ -- (int)setMaxAllowedPacketTo:(int)newSize resetSize:(BOOL)reset +- (NSInteger)setMaxAllowedPacketTo:(NSInteger)newSize resetSize:(BOOL)reset { if(![self isMaxAllowedPacketEditable] || newSize < 1024) return maxAllowedPacketSize; [queryLock lock]; - mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %d", newSize] UTF8String]); + mysql_query(mConnection, [[NSString stringWithFormat:@"SET GLOBAL max_allowed_packet = %ld", newSize] UTF8String]); [queryLock unlock]; // Inform the user via a log entry about that change according to reset value if(delegate && [delegate respondsToSelector:@selector(queryGaveError:connection:)]) if(reset) - [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %d for new session", newSize] connection:self]; + [delegate queryGaveError:[NSString stringWithFormat:@"max_allowed_packet was reset to %ld for new session", newSize] connection:self]; else - [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %d for the current session to allow query to succeed", newSize] connection:self]; + [delegate queryGaveError:[NSString stringWithFormat:@"Query too large; max_allowed_packet temporarily set to %ld for the current session to allow query to succeed", newSize] connection:self]; return maxAllowedPacketSize; } diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h index a4d1989e..6d03137c 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionProxy.h @@ -55,12 +55,12 @@ enum PROXY_TUNNEL_STATES /** * Get the current state of the proxy. */ -- (int)state; +- (NSInteger)state; /** * Get the local port being used by the proxy. */ -- (int)localPort; +- (NSInteger)localPort; /** * Sets the method the proxy should call whenever the state of the connection changes. diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h index d696dad7..816d68ca 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConstants.h @@ -27,38 +27,40 @@ // More info at <http://code.google.com/p/sequel-pro/> // Result type constants -typedef enum { +enum { MCPTypeArray = 1, MCPTypeDictionary = 2, MCPTypeFlippedArray = 3, MCPTypeFlippedDictionary = 4 -} MCPReturnType; +}; +typedef NSUInteger MCPReturnType; // Connection check constants -typedef enum { +enum { MCPConnectionCheckRetry = 0, MCPConnectionCheckReconnect = 1, MCPConnectionCheckDisconnect = 2 -} MCPConnectionCheck; +}; +typedef NSUInteger MCPConnectionCheck; // Charcater set mapping constants typedef struct _OUR_CHARSET { - unsigned int nr; + NSUInteger nr; const char *name; const char *collation; - unsigned int char_minlen; - unsigned int char_maxlen; + NSUInteger char_minlen; + NSUInteger char_maxlen; } OUR_CHARSET; // Deafult connection option -extern const unsigned int kMCPConnectionDefaultOption; +extern const NSUInteger kMCPConnectionDefaultOption; // Default socket (from the mysql.h used at compile time) extern const char *kMCPConnectionDefaultSocket; // Added to MySQL error code -extern const unsigned int kMCPConnectionNotInited; +extern const NSUInteger kMCPConnectionNotInited; // The length of the truncation if required -extern const unsigned int kLengthOfTruncationForLog; +extern const NSUInteger kLengthOfTruncationForLog; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h index 5e80d470..e9ced5a0 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.h @@ -40,7 +40,7 @@ - (id)getFirstFieldFromQuery:(NSString *)query; - (id)getFirstRowFromQuery:(NSString *)query asType:(MCPReturnType)type; - (id)getAllRowsFromQuery:(NSString *)query asType:(MCPReturnType)type; -- (NSArray *)getQuery:(NSString *)query colWithIndex:(unsigned int)col; +- (NSArray *)getQuery:(NSString *)query colWithIndex:(NSUInteger)col; - (NSArray *)getQuery:(NSString *)query colWithName:(NSString *)colName; @end diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m index 6dcc2a17..c5f4d361 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPFastQueries.m @@ -97,7 +97,7 @@ * Get a column (as an NSArray) of the result from the query aQuery. The column is choosen from it's index, * starting from 0. */ -- (NSArray *)getQuery:(NSString *)query colWithIndex:(unsigned int)col +- (NSArray *)getQuery:(NSString *)query colWithIndex:(NSUInteger)col { return [[self queryString:query] fetchColAtIndex:col]; } diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m b/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m index bab493c3..3dab0e07 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPNumber.m @@ -55,12 +55,12 @@ + (MCPNumber *)numberWithInt:(int)value { - return [[[MCPNumber alloc] initWithInt:value] autorelease]; + return [[[MCPNumber alloc] initWithInteger:value] autorelease]; } + (MCPNumber *)numberWithUnsignedInt:(unsigned int)value { - return [[[MCPNumber alloc] initWithUnsignedInt:value] autorelease]; + return [[[MCPNumber alloc] initWithUnsignedInteger:value] autorelease]; } + (MCPNumber *)numberWithLong:(long)value @@ -85,7 +85,7 @@ + (MCPNumber *)numberWithFloat:(float)value { - return [[[MCPNumber alloc] initWithFloat:value] autorelease]; + return [[[MCPNumber alloc] initWithDouble:value] autorelease]; } + (MCPNumber *)numberWithDouble:(double)value @@ -135,16 +135,16 @@ - (id)initWithInt:(int)value { - typeCode = @encode(int); - number = [[NSNumber alloc] initWithInt:value]; + typeCode = @encode(NSInteger); + number = [[NSNumber alloc] initWithInteger:value]; return self; } - (id)initWithUnsignedInt:(unsigned int)value { - typeCode = @encode(unsigned int); - number = [[NSNumber alloc] initWithUnsignedInt:value]; + typeCode = @encode(NSUInteger); + number = [[NSNumber alloc] initWithUnsignedInteger:value]; return self; } @@ -183,8 +183,8 @@ - (id)initWithFloat:(float)value { - typeCode = @encode(float); - number = [[NSNumber alloc] initWithFloat:value]; + typeCode = @encode(CGFloat); + number = [[NSNumber alloc] initWithDouble:value]; return self; } @@ -246,12 +246,12 @@ - (int)intValue { - return [number intValue]; + return [number integerValue]; } - (unsigned int)unsignedIntValue { - return [number unsignedIntValue]; + return [number unsignedIntegerValue]; } - (long)longValue @@ -276,7 +276,7 @@ - (float)floatValue { - return [number floatValue]; + return [number doubleValue]; } - (double)doubleValue diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h index cb66a6cf..4f0d1f80 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.h @@ -38,7 +38,7 @@ MYSQL_RES *mResult; /* The MYSQL_RES structure of the C API. */ NSArray *mNames; /* An NSArray holding the name of the columns. */ NSStringEncoding mEncoding; /* The encoding used by MySQL server, to ISO-1 default. */ - unsigned int mNumOfFields; /* The number of fields in the result. */ + NSUInteger mNumOfFields; /* The number of fields in the result. */ NSTimeZone *mTimeZone; /* The time zone of the connection when the query was made. */ } @@ -48,7 +48,7 @@ // Result info - (my_ulonglong)numOfRows; -- (unsigned int)numOfFields; +- (NSUInteger)numOfFields; // Rows - (void)dataSeek:(my_ulonglong)row; @@ -63,10 +63,10 @@ - (NSDictionary *)fetchTypesAsDictionary; - (NSArray *)fetchResultFieldsStructure; -- (unsigned int)fetchFlagsAtIndex:(unsigned int)index; -- (unsigned int)fetchFlagsForKey:(NSString *)key; +- (NSUInteger)fetchFlagsAtIndex:(NSUInteger)index; +- (NSUInteger)fetchFlagsForKey:(NSString *)key; -- (BOOL)isBlobAtIndex:(unsigned int)index; +- (BOOL)isBlobAtIndex:(NSUInteger)index; - (BOOL)isBlobForKey:(NSString *)key; // Conversion @@ -75,10 +75,10 @@ - (NSString *)stringWithCString:(const char *)theCString; // Other -- (NSString *)mysqlTypeToStringForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags withLength:(unsigned long long)length; -- (NSString *)mysqlTypeToGroupForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags; -- (NSString *)findCharsetName:(unsigned int)charsetnr; -- (NSString *)findCharsetCollation:(unsigned int)charsetnr; -- (unsigned int)findCharsetMaxByteLengthPerChar:(unsigned int)charsetnr; +- (NSString *)mysqlTypeToStringForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags withLength:(unsigned long long)length; +- (NSString *)mysqlTypeToGroupForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags; +- (NSString *)findCharsetName:(NSUInteger)charsetnr; +- (NSString *)findCharsetCollation:(NSUInteger)charsetnr; +- (NSUInteger)findCharsetMaxByteLengthPerChar:(NSUInteger)charsetnr; @end diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m index f3edd9a5..bb7bef5e 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResult.m @@ -345,7 +345,7 @@ const OUR_CHARSET our_charsets60[] = /** * Return the number of fields selected by the query. As a side effect it forces an update of the number of fields. */ -- (unsigned int)numOfFields +- (NSUInteger)numOfFields { if (mResult) { return mNumOfFields = mysql_num_fields(mResult); @@ -375,7 +375,7 @@ const OUR_CHARSET our_charsets60[] = MYSQL_ROW theRow; unsigned long *theLengths; MYSQL_FIELD *theField; - int i; + NSInteger i; id theReturn; if (mResult == NULL) { @@ -461,7 +461,7 @@ const OUR_CHARSET our_charsets60[] = break; default: - NSLog (@"in fetchRowAsType : Unknown type : %d for column %d, send back a NSData object", (int)theField[i].type, (int)i); + NSLog (@"in fetchRowAsType : Unknown type : %ld for column %ld, send back a NSData object", (NSInteger)theField[i].type, (NSInteger)i); theCurrentObj = [NSData dataWithBytes:theData length:theLengths[i]]; break; } @@ -529,8 +529,8 @@ const OUR_CHARSET our_charsets60[] = */ - (NSArray *)fetchFieldNames { - int i; - unsigned int theNumFields; + NSInteger i; + NSUInteger theNumFields; NSMutableArray *theNamesArray; MYSQL_FIELD *theField; @@ -553,7 +553,7 @@ const OUR_CHARSET our_charsets60[] = [theNamesArray addObject:theName]; } else { - [theNamesArray addObject:[NSString stringWithFormat:@"Column %d", i]]; + [theNamesArray addObject:[NSString stringWithFormat:@"Column %ld", i]]; } } @@ -568,7 +568,7 @@ const OUR_CHARSET our_charsets60[] = */ - (id)fetchTypesAsType:(MCPReturnType)aType { - int i; + NSInteger i; id theTypes; MYSQL_FIELD *theField; @@ -670,7 +670,7 @@ const OUR_CHARSET our_charsets60[] = break; default: theType = @"unknown"; - NSLog (@"in fetchTypesAsArray : Unknown type for column %d of the MCPResult, type = %d", (int)i, (int)theField[i].type); + NSLog (@"in fetchTypesAsArray : Unknown type for column %ld of the MCPResult, type = %ld", (NSInteger)i, (NSInteger)theField[i].type); break; } @@ -723,8 +723,8 @@ const OUR_CHARSET our_charsets60[] = NSMutableArray *structureResult = [NSMutableArray array]; - unsigned int i; - unsigned int numFields = mysql_num_fields(mResult); + NSUInteger i; + NSUInteger numFields = mysql_num_fields(mResult); if (mResult == NULL) return nil; @@ -735,7 +735,7 @@ const OUR_CHARSET our_charsets60[] = NSMutableDictionary *fieldStructure = [NSMutableDictionary dictionaryWithCapacity:39]; /* Original column position */ - [fieldStructure setObject:[NSNumber numberWithInt:i] forKey:@"datacolumnindex"]; + [fieldStructure setObject:[NSNumber numberWithInteger:i] forKey:@"datacolumnindex"]; /* Name of column */ [fieldStructure setObject:[self stringWithCString:theField[i].name] forKey:@"name"]; @@ -796,10 +796,10 @@ const OUR_CHARSET our_charsets60[] = // [fieldStructure setObject:[NSNumber numberWithInt:(theField[i].flags & BINCMP_FLAG) ? 1 : 0] forKey:@"BINCMP_FLAG"]; /* Number of decimals in field */ - [fieldStructure setObject:[NSNumber numberWithUnsignedInt:theField[i].decimals] forKey:@"decimals"]; + [fieldStructure setObject:[NSNumber numberWithUnsignedInteger:theField[i].decimals] forKey:@"decimals"]; /* Character set */ - [fieldStructure setObject:[NSNumber numberWithUnsignedInt:theField[i].charsetnr] forKey:@"charsetnr"]; + [fieldStructure setObject:[NSNumber numberWithUnsignedInteger:theField[i].charsetnr] forKey:@"charsetnr"]; [fieldStructure setObject:[self findCharsetName:theField[i].charsetnr] forKey:@"charset_name"]; [fieldStructure setObject:[self findCharsetCollation:theField[i].charsetnr] forKey:@"charset_collation"]; @@ -827,10 +827,10 @@ const OUR_CHARSET our_charsets60[] = /** * Return the MySQL flags of the column at the given index... Can be used to check if a number is signed or not... */ -- (unsigned int)fetchFlagsAtIndex:(unsigned int)index +- (NSUInteger)fetchFlagsAtIndex:(NSUInteger)index { - unsigned int theRet; - unsigned int theNumFields; + NSUInteger theRet; + NSUInteger theNumFields; MYSQL_FIELD *theField; if (mResult == NULL) { @@ -855,10 +855,10 @@ const OUR_CHARSET our_charsets60[] = /** * */ -- (unsigned int)fetchFlagsForKey:(NSString *)key +- (NSUInteger)fetchFlagsForKey:(NSString *)key { - unsigned int theRet; - unsigned int theNumFields, index; + NSUInteger theRet; + NSUInteger theNumFields, index; MYSQL_FIELD *theField; if (mResult == NULL) { @@ -896,10 +896,10 @@ const OUR_CHARSET our_charsets60[] = * #{NOTE} That the current version handles properly TEXT, and returns those as NSString (and not NSData as * it used to be). */ -- (BOOL)isBlobAtIndex:(unsigned int)index +- (BOOL)isBlobAtIndex:(NSUInteger)index { BOOL theRet; - unsigned int theNumFields; + NSUInteger theNumFields; MYSQL_FIELD *theField; if (mResult == NULL) { @@ -944,7 +944,7 @@ const OUR_CHARSET our_charsets60[] = - (BOOL)isBlobForKey:(NSString *)key { BOOL theRet; - unsigned int theNumFields, index; + NSUInteger theNumFields, index; MYSQL_FIELD *theField; if (mResult == NULL) { @@ -1016,13 +1016,14 @@ const OUR_CHARSET our_charsets60[] = } else { NSMutableString *theString = [NSMutableString stringWithCapacity:0]; - int i; + NSInteger i; NSArray *theRow; MYSQL_ROW_OFFSET thePosition; BOOL trunc = [MCPConnection truncateLongField]; // First line, saying we are displaying a MCPResult - [theString appendFormat:@"MCPResult: (encoding : %d, dim %d x %d)\n", (long)mEncoding, (long)mNumOfFields, (long)[self numOfRows]]; + [theString appendFormat:@"MCPResult: (encoding : %ld, dim %ld x %ld)\n", (long)mEncoding, (long)mNumOfFields, (long)[self numOfRows]]; + // Second line: the field names, tab separated [self fetchFieldNames]; @@ -1097,7 +1098,7 @@ const OUR_CHARSET our_charsets60[] = /** * Convert a mysql_type to a string */ -- (NSString *)mysqlTypeToStringForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags withLength:(unsigned long long)length +- (NSString *)mysqlTypeToStringForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags withLength:(unsigned long long)length { // BOOL isUnsigned = (flags & UNSIGNED_FLAG) != 0; // BOOL isZerofill = (flags & ZEROFILL_FLAG) != 0; @@ -1146,7 +1147,7 @@ const OUR_CHARSET our_charsets60[] = case MYSQL_TYPE_BLOB: { BOOL isBlob = (charsetnr == MAGIC_BINARY_CHARSET_NR); - switch ((int)length/[self findCharsetMaxByteLengthPerChar:charsetnr]) { + switch ((NSInteger)length/[self findCharsetMaxByteLengthPerChar:charsetnr]) { case 255: return isBlob? @"TINYBLOB":@"TINYTEXT"; case 65535: return isBlob? @"BLOB":@"TEXT"; case 16777215: return isBlob? @"MEDIUMBLOB":@"MEDIUMTEXT"; @@ -1202,7 +1203,7 @@ const OUR_CHARSET our_charsets60[] = /** * Merge mysql_types into type groups */ -- (NSString *)mysqlTypeToGroupForType:(unsigned int)type withCharsetNr:(unsigned int)charsetnr withFlags:(unsigned int)flags +- (NSString *)mysqlTypeToGroupForType:(NSUInteger)type withCharsetNr:(NSUInteger)charsetnr withFlags:(NSUInteger)flags { switch(type){ case FIELD_TYPE_BIT: @@ -1268,7 +1269,7 @@ const OUR_CHARSET our_charsets60[] = /** * Convert a mysql_charsetnr into a charset name as string */ -- (NSString *)findCharsetName:(unsigned int)charsetnr +- (NSString *)findCharsetName:(NSUInteger)charsetnr { const OUR_CHARSET * c = our_charsets60; @@ -1284,7 +1285,7 @@ const OUR_CHARSET our_charsets60[] = /** * Convert a mysql_charsetnr into a collation name as string */ -- (NSString *)findCharsetCollation:(unsigned int)charsetnr +- (NSString *)findCharsetCollation:(NSUInteger)charsetnr { const OUR_CHARSET * c = our_charsets60; @@ -1301,7 +1302,7 @@ const OUR_CHARSET our_charsets60[] = * Return the max byte length to store a char by using * a specific mysql_charsetnr */ -- (unsigned int)findCharsetMaxByteLengthPerChar:(unsigned int)charsetnr +- (NSUInteger)findCharsetMaxByteLengthPerChar:(NSUInteger)charsetnr { const OUR_CHARSET * c = our_charsets60; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h index f4539522..f161bd0c 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.h @@ -33,7 +33,7 @@ @interface MCPResult (MCPResultPlus) // Getting a complete column as an array -- (NSArray *)fetchColAtIndex:(unsigned int)col; +- (NSArray *)fetchColAtIndex:(NSUInteger)col; - (NSArray *)fetchColWithName:(NSString *)colName; // Getting the complete result as 2D array diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m index 53b1846d..c171dc7f 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPResultPlus.m @@ -40,7 +40,7 @@ * The index 0 of the returned array always correspond to the first row (ie: returned NSArray is indexed * by row number), the read position is restored after to it's initial position after the read. */ -- (NSArray *)fetchColAtIndex:(unsigned int)col +- (NSArray *)fetchColAtIndex:(NSUInteger)col { NSMutableArray *theCol = [NSMutableArray arrayWithCapacity:[self numOfRows]]; MYSQL_ROW_OFFSET thePosition; @@ -52,7 +52,7 @@ } if (col >= mNumOfFields) { // Bad column number - NSLog (@"The index : %d is not within the range 0 - %d\n", (long)col, (long)mNumOfFields); + NSLog (@"The index : %ld is not within the range 0 - %ld\n", (long)col, (long)mNumOfFields); return nil; } @@ -78,7 +78,7 @@ */ - (NSArray *)fetchColWithName:(NSString *)colName { - unsigned int theCol; + NSUInteger theCol; if (mResult == NULL) { // If there is no results, returns nil. @@ -117,7 +117,7 @@ { id theTable, theVect; MYSQL_ROW_OFFSET thePosition; - unsigned int i; + NSUInteger i; if (mResult == NULL) { // If there is no results, returns nil. @@ -175,7 +175,7 @@ theTable = [NSDictionary dictionaryWithDictionary:theTable]; break; default : - NSLog (@"Unknown MCPReturnType : %d; return nil\n", (int)type); + NSLog (@"Unknown MCPReturnType : %ld; return nil\n", (NSInteger)type); theTable = nil; break; } diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m index c63a9f0b..58bd7399 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPStreamingResult.m @@ -142,7 +142,7 @@ MYSQL_ROW theRow; char *theRowData; unsigned long *fieldLengths; - int i, copiedDataLength; + NSInteger i, copiedDataLength; NSMutableArray *returnArray; // Retrieve the next row according to the mode this result set is in. @@ -257,7 +257,7 @@ break; default: - NSLog(@"in fetchNextRowAsArray : Unknown type : %d for column %d, sending back a NSData object", (int)fieldDefinitions[i].type, (int)i); + NSLog(@"in fetchNextRowAsArray : Unknown type : %ld for column %ld, sending back a NSData object", (NSInteger)fieldDefinitions[i].type, (NSInteger)i); cellData = [NSData dataWithBytes:theData length:fieldLengths[i]]; break; } @@ -355,7 +355,7 @@ NSAutoreleasePool *downloadPool = [[NSAutoreleasePool alloc] init]; MYSQL_ROW theRow; unsigned long *fieldLengths; - int i, dataCopiedLength, rowDataLength; + NSInteger i, dataCopiedLength, rowDataLength; LOCAL_ROW_DATA *newRowStore; size_t sizeOfLocalRowData = sizeof(LOCAL_ROW_DATA); |