From 872d8d0e633c873dea268e63b80791e48a1ea6d7 Mon Sep 17 00:00:00 2001 From: helge Date: Tue, 12 Apr 2005 21:08:05 +0000 Subject: [PATCH] gcc 3.4.3 cleanups removed some unused EOAttribute features to simplify the code git-svn-id: http://svn.opengroupware.org/SOPE/trunk@734 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-gdl1/GDLAccess/ChangeLog | 9 + sope-gdl1/GDLAccess/EOAdaptorDataSource.m | 2 +- sope-gdl1/GDLAccess/EOAttribute.h | 66 ++--- sope-gdl1/GDLAccess/EOAttribute.m | 264 ++++---------------- sope-gdl1/GDLAccess/EODatabase.m | 4 +- sope-gdl1/GDLAccess/EOEntity.m | 48 ++-- sope-gdl1/GDLAccess/EOExpressionArray.h | 10 +- sope-gdl1/GDLAccess/EOQuotedExpression.m | 27 +- sope-gdl1/GDLAccess/EORelationship.m | 41 ++- sope-gdl1/GDLAccess/EOSQLExpression.m | 97 ++----- sope-gdl1/GDLAccess/EOSQLQualifier.m | 21 +- sope-gdl1/GDLAccess/EOSelectSQLExpression.m | 49 +--- sope-gdl1/GDLAccess/Version | 2 +- 13 files changed, 170 insertions(+), 470 deletions(-) diff --git a/sope-gdl1/GDLAccess/ChangeLog b/sope-gdl1/GDLAccess/ChangeLog index ee3c2d34..460dc487 100644 --- a/sope-gdl1/GDLAccess/ChangeLog +++ b/sope-gdl1/GDLAccess/ChangeLog @@ -1,3 +1,12 @@ +2005-04-12 Helge Hess + + * v4.5.49 + + * fixed various gcc 3.4.3 warnings + + * removed support for unused EOAttribute features like flattened, + derived, read-only, insert/update formats, definition + 2005-03-15 Helge Hess * FoundationExt/GNUmakefile: properly include config.make (v4.5.48) diff --git a/sope-gdl1/GDLAccess/EOAdaptorDataSource.m b/sope-gdl1/GDLAccess/EOAdaptorDataSource.m index 63102f0d..ab8bc710 100644 --- a/sope-gdl1/GDLAccess/EOAdaptorDataSource.m +++ b/sope-gdl1/GDLAccess/EOAdaptorDataSource.m @@ -782,7 +782,7 @@ static NSNotificationCenter *getNC(void ) { self->connectionDictionary]; [newGID autorelease]; } - [_obj setObject:newGID forKey:@"globalID"]; + [(NSMutableDictionary *)_obj setObject:newGID forKey:@"globalID"]; } [self postDataSourceChangedNotification]; } diff --git a/sope-gdl1/GDLAccess/EOAttribute.h b/sope-gdl1/GDLAccess/EOAttribute.h index 86feb5c5..e08c1375 100644 --- a/sope-gdl1/GDLAccess/EOAttribute.h +++ b/sope-gdl1/GDLAccess/EOAttribute.h @@ -42,31 +42,21 @@ NSTimeZone *clientTimeZone; NSTimeZone *serverTimeZone; NSString *columnName; - NSString *definition; NSString *externalType; NSString *valueClassName; NSString *valueType; - NSString *insertFormat; - NSString *selectFormat; - NSString *updateFormat; NSDictionary *userDictionary; - - /* Garbage collectable objects */ - EOEntity *entity; /* non-retained */ - NSMutableArray *definitionArray; // These variables are meaningful only - EOAttribute *realAttribute; // if the attribute is flattened - unsigned width; + EOEntity *entity; /* non-retained */ + unsigned width; struct { - BOOL isReadOnly:1; - BOOL isDerived:1; - BOOL isFlattened:1; - BOOL allowsNull:1; + int allowsNull:1; + int reserved:31; } flags; } /* Initializing new instances */ -- (id)initWithName:(NSString*)name; +- (id)initWithName:(NSString *)name; /* Accessing the entity */ - (void)setEntity:(EOEntity*)entity; @@ -75,48 +65,33 @@ - (BOOL)hasEntity; /* Accessing the name */ -- (BOOL)setName:(NSString*)name; -- (NSString*)name; -+ (BOOL)isValidName:(NSString*)name; +- (BOOL)setName:(NSString *)name; +- (NSString *)name; ++ (BOOL)isValidName:(NSString *)name; /* Accessing date information */ -+ (NSString*)defaultCalendarFormat; -- (void)setCalendarFormat:(NSString*)format; -- (NSString*)calendarFormat; ++ (NSString *)defaultCalendarFormat; +- (void)setCalendarFormat:(NSString *)format; +- (NSString *)calendarFormat; - (void)setClientTimeZone:(NSTimeZone*)tz; - (NSTimeZone*)clientTimeZone; - (void)setServerTimeZone:(NSTimeZone*)tz; - (NSTimeZone*)serverTimeZone; /* Accessing external definitions */ -- (void)setColumnName:(NSString*)columnName; -- (NSString*)columnName; -- (void)setDefinition:(NSString*)definition; -- (NSString*)definition; -- (NSMutableArray*)definitionArray; -- (void)setExternalType:(NSString*)type; -- (NSString*)externalType; +- (void)setColumnName:(NSString *)columnName; +- (NSString *)columnName; +- (void)setExternalType:(NSString *)type; +- (NSString *)externalType; /* Accessing value type information */ -- (void)setValueClassName:(NSString*)name; -- (NSString*)valueClassName; -- (void)setValueType:(NSString*)type; -- (NSString*)valueType; +- (void)setValueClassName:(NSString *)name; +- (NSString *)valueClassName; +- (void)setValueType:(NSString *)type; +- (NSString *)valueType; /* Checking type information */ - (BOOL)referencesProperty:property; -- (BOOL)isDerived; -- (BOOL)isFlattened; -- (BOOL)setReadOnly:(BOOL)flag; -- (BOOL)isReadOnly; - -/* Accessing SQL statement formats */ -- (void)setInsertFormat:(NSString*)string; -- (NSString*)insertFormat; -- (void)setSelectFormat:(NSString*)string; -- (NSString*)selectFormat; -- (void)setUpdateFormat:(NSString*)string; -- (NSString*)updateFormat; /* Accessing the user dictionary */ - (void)setUserDictionary:(NSDictionary*)dictionary; @@ -173,9 +148,6 @@ - (NSException *)validateValue:(id *)_value; -- (NSString *)readFormat; -- (NSString *)writeFormat; - @end #endif /* __EOAttribute_h__ */ diff --git a/sope-gdl1/GDLAccess/EOAttribute.m b/sope-gdl1/GDLAccess/EOAttribute.m index 09b49453..8e2e1ac2 100644 --- a/sope-gdl1/GDLAccess/EOAttribute.m +++ b/sope-gdl1/GDLAccess/EOAttribute.m @@ -63,31 +63,25 @@ static EONull *null = nil; } - (void)dealloc { - RELEASE(self->name); - RELEASE(self->calendarFormat); - RELEASE(self->clientTimeZone); - RELEASE(self->serverTimeZone); - RELEASE(self->columnName); - RELEASE(self->definition); - RELEASE(self->externalType); - RELEASE(self->valueClassName); - RELEASE(self->valueType); - RELEASE(self->insertFormat); - RELEASE(self->selectFormat); - RELEASE(self->updateFormat); - RELEASE(self->userDictionary); + [self->name release]; + [self->calendarFormat release]; + [self->clientTimeZone release]; + [self->serverTimeZone release]; + [self->columnName release]; + [self->externalType release]; + [self->valueClassName release]; + [self->valueType release]; + [self->userDictionary release]; self->entity = nil; /* non-retained */ - RELEASE(self->definitionArray); - RELEASE(self->realAttribute); [super dealloc]; } // These methods should be here to let the library work with NeXT foundation - (id)copy { - return RETAIN(self); + return [self retain]; } - (id)copyWithZone:(NSZone *)_zone { - return RETAIN(self); + return [self retain]; } // Is equal only if same name; used to make aliasing ordering stable @@ -110,97 +104,8 @@ static EONull *null = nil; return [EOEntity isValidName:_name]; } -- (BOOL)setReadOnly:(BOOL)flag { - if(!flag && ([self isDerived] || [self isFlattened])) - return NO; - flags.isReadOnly = flag; - return YES; -} - -- (BOOL)referencesProperty:(id)property { - return (flags.isDerived) - ? [self->definitionArray indexOfObject:property] != NSNotFound - : NO; -} - -- (void)setDefinition:(NSString *)def { - NSArray *defArray; - int i, count; - EOEntity *currentEntity; - id realAttributeName; - - if (def == nil) { - [NSException raise:NSInvalidArgumentException - format:@"invalid (nil) definition argument!"]; - } - - self->flags.isDerived = YES; - self->flags.isFlattened = NO; - - ASSIGN(self->definition, def); - - if ([definition isNameOfARelationshipPath]) { - self->flags.isFlattened = YES; - defArray = [definition componentsSeparatedByString:@"."]; - count = [defArray count]; - - RELEASE(self->definitionArray); - self->definitionArray = [[NSMutableArray alloc] initWithCapacity:count]; - - NS_DURING { - currentEntity = self->entity; - - for (i = 0; i < count - 1; i++) { - id relationshipName, relationship; - - relationshipName = [defArray objectAtIndex:i]; - - if(![EOEntity isValidName:relationshipName]) { - [[[InvalidNameException alloc] - initWithName:relationshipName] raise]; - } - - relationship - = [currentEntity relationshipNamed:relationshipName]; - - if(relationship == nil) { - [[[InvalidPropertyException alloc] - initWithName:relationshipName entity:currentEntity] raise]; - } - if([relationship isToMany]) { - [[[RelationshipMustBeToOneException alloc] - initWithName:relationshipName entity:currentEntity] raise]; - } - [self->definitionArray addObject:relationship]; - currentEntity = [relationship destinationEntity]; - } - realAttributeName = [defArray lastObject]; - - RELEASE(self->realAttribute); - self->realAttribute = - RETAIN([currentEntity attributeNamed:realAttributeName]); - if (self->realAttribute == nil) { - [[[InvalidPropertyException alloc] - initWithName:realAttributeName entity:currentEntity] raise]; - } - [self->definitionArray addObject:self->realAttribute]; - } - NS_HANDLER { - RELEASE(self->definitionArray); - self->definitionArray = nil; - [localException raise]; - } - NS_ENDHANDLER; - } - else { - [self->definitionArray release]; - self->definitionArray = nil; - self->definitionArray - = [[EOExpressionArray parseExpression:definition - entity:entity - replacePropertyReferences:YES] - retain]; - } +- (BOOL)referencesProperty:(id)property { // TODO: still used? + return NO; } - (NSString *)expressionValueForContext:(id)context { @@ -243,59 +148,32 @@ static EONull *null = nil; return self->serverTimeZone; } -- (void)setColumnName:(NSString*)_name { - ASSIGN(self->columnName, _name); +- (void)setColumnName:(NSString *)_name { + ASSIGNCOPY(self->columnName, _name); } - (NSString *)columnName { return self->columnName; } -- (void)setExternalType:(NSString*)type { - ASSIGN(self->externalType, type); +- (void)setExternalType:(NSString *)type { + ASSIGNCOPY(self->externalType, type); } - (NSString *)externalType { - return ((self->externalType == nil) && self->flags.isFlattened) - ? [self->realAttribute externalType] - : self->externalType; + return self->externalType; } - (void)setValueClassName:(NSString *)_name { - ASSIGN(self->valueClassName, _name); + ASSIGNCOPY(self->valueClassName, _name); } - (NSString *)valueClassName { - return ((self->valueClassName == nil) && self->flags.isFlattened) - ? [self->realAttribute valueClassName] - : self->valueClassName; + return self->valueClassName; } - (void)setValueType:(NSString *)type { ASSIGN(self->valueType, type); } - (NSString *)valueType { - return ((self->valueType == nil) && self->flags.isFlattened) - ? [self->realAttribute valueType] - : self->valueType; -} - -- (void)setInsertFormat:(NSString *)string { - ASSIGN(self->insertFormat, string); -} -- (NSString *)insertFormat { - return self->insertFormat; -} - -- (void)setSelectFormat:(NSString *)string { - ASSIGN(self->selectFormat, string); -} -- (NSString *)selectFormat { - return self->selectFormat; -} - -- (void)setUpdateFormat:(NSString*)string { - ASSIGN(self->updateFormat, string); -} -- (NSString *)updateFormat { - return self->updateFormat; + return self->valueType; } - (void)setUserDictionary:(NSDictionary *)dict { @@ -311,22 +189,6 @@ static EONull *null = nil; - (NSString *)name { return self->name; } -- (NSString *)definition { - return self->definition; -} -- (NSMutableArray *)definitionArray { - return self->definitionArray; -} -- (BOOL)isDerived { - return self->flags.isDerived; -} -- (BOOL)isFlattened { - return self->flags.isFlattened; -} - -- (BOOL)isReadOnly { - return self->flags.isDerived ? YES : self->flags.isReadOnly; -} /* description */ @@ -334,54 +196,39 @@ static EONull *null = nil; return [[self propertyList] description]; } -@end /* EOAttribute */ - - -@implementation EOAttribute (EOAttributePrivate) +/* EOAttributePrivate */ + (EOAttribute*)attributeFromPropertyList:(id)propertyList { + NSDictionary *plist = propertyList; EOAttribute *attribute = nil; NSString *timeZoneName; id tmp; + + attribute = [[[EOAttribute alloc] init] autorelease]; + + [attribute setName:[plist objectForKey:@"name"]]; + [attribute setCalendarFormat:[plist objectForKey:@"calendarFormat"]]; - attribute = [[EOAttribute alloc] init]; - AUTORELEASE(attribute); - - [attribute setName:[propertyList objectForKey:@"name"]]; - [attribute setCalendarFormat:[propertyList objectForKey:@"calendarFormat"]]; - - timeZoneName = [propertyList objectForKey:@"clientTimeZone"]; + timeZoneName = [plist objectForKey:@"clientTimeZone"]; if (timeZoneName) [attribute setClientTimeZone:[NSTimeZone timeZoneWithName:timeZoneName]]; - timeZoneName = [propertyList objectForKey:@"serverTimeZone"]; + timeZoneName = [plist objectForKey:@"serverTimeZone"]; if (timeZoneName) [attribute setServerTimeZone:[NSTimeZone timeZoneWithName:timeZoneName]]; - [attribute setColumnName: [propertyList objectForKey:@"columnName"]]; - [attribute setExternalType: [propertyList objectForKey:@"externalType"]]; - [attribute setValueClassName:[propertyList objectForKey:@"valueClassName"]]; - [attribute setValueType: [propertyList objectForKey:@"valueType"]]; - [attribute setInsertFormat: [propertyList objectForKey:@"insertFormat"]]; - [attribute setSelectFormat: [propertyList objectForKey:@"selectFormat"]]; - [attribute setUpdateFormat: [propertyList objectForKey:@"updateFormat"]]; - [attribute setUserDictionary:[propertyList objectForKey:@"userDictionary"]]; + [attribute setColumnName: [plist objectForKey:@"columnName"]]; + [attribute setExternalType: [plist objectForKey:@"externalType"]]; + [attribute setValueClassName:[plist objectForKey:@"valueClassName"]]; + [attribute setValueType: [plist objectForKey:@"valueType"]]; + [attribute setUserDictionary:[plist objectForKey:@"userDictionary"]]; - [attribute setReadOnly: - [[propertyList objectForKey:@"isReadOnly"] isEqual:@"Y"]]; - - if ((tmp = [propertyList objectForKey:@"allowsNull"])) + if ((tmp = [plist objectForKey:@"allowsNull"])) [attribute setAllowsNull:[tmp isEqual:@"Y"]]; else [attribute setAllowsNull:YES]; - [attribute setWidth: - [[propertyList objectForKey:@"width"] unsignedIntValue]]; - - /* Don't call setDefinition: now. The attributes array in - entity is not yet set. */ - attribute->definition = RETAIN([propertyList objectForKey:@"definition"]); - + [attribute setWidth:[[plist objectForKey:@"width"] unsignedIntValue]]; return attribute; } @@ -389,16 +236,6 @@ static EONull *null = nil; were constructed and after the `attributes' array contains the real attributes. */ - (void)replaceStringsWithObjects { - if(self->definition) { - NS_DURING - [self setDefinition:self->definition]; - NS_HANDLER { - //CATCH(PropertyDefinitionException) - NSLog([localException reason]); - [[self->entity model] errorInReading]; - } - NS_ENDHANDLER; - } } - (id)propertyList { @@ -413,9 +250,7 @@ static EONull *null = nil; return [[(EOAttribute *)self name] compare:[_other name]]; } -@end /* EOAttribute (EOAttributePrivate) */ - -@implementation EOAttribute(ValuesConversion) +/* ValuesConversion */ - (id)convertValue:(id)aValue toClass:(Class)aClass forType:(NSString*)_type { // Check nil/EONull @@ -493,9 +328,9 @@ static EONull *null = nil; toClass:aValueClass forType:[self valueType]]; } -@end +@end /* EOAttribute */ -@implementation NSString (EOAttributeTypeCheck) +@implementation NSString(EOAttributeTypeCheck) - (BOOL)isNameOfARelationshipPath { BOOL result = NO; @@ -519,7 +354,7 @@ static EONull *null = nil; return result; } -@end +@end /* NSString(EOAttributeTypeCheck) */ @implementation EOAttribute(PropertyListCoding) @@ -532,13 +367,9 @@ static inline void _addToPropList(NSMutableDictionary *propertyList, _addToPropList(_plist, self->name, @"name"); _addToPropList(_plist, self->calendarFormat, @"calendarFormat"); _addToPropList(_plist, self->columnName, @"columnName"); - _addToPropList(_plist, self->definition, @"definition"); _addToPropList(_plist, self->externalType, @"externalType"); _addToPropList(_plist, self->valueClassName, @"valueClassName"); _addToPropList(_plist, self->valueType, @"valueType"); - _addToPropList(_plist, self->insertFormat, @"insertFormat"); - _addToPropList(_plist, self->selectFormat, @"selectFormat"); - _addToPropList(_plist, self->updateFormat, @"updateFormat"); _addToPropList(_plist, self->userDictionary, @"userDictionary"); if (self->clientTimeZone) { @@ -564,11 +395,6 @@ static inline void _addToPropList(NSMutableDictionary *propertyList, [_plist setObject:[NSNumber numberWithUnsignedInt:self->width] forKey:@"width"]; } - - if (self->flags.isReadOnly) { - [_plist setObject:[NSString stringWithCString:"Y"] - forKey:@"isReadOnly"]; - } if (self->flags.allowsNull) { [_plist setObject:[NSString stringWithCString:"Y"] forKey:@"allowsNull"]; @@ -678,18 +504,12 @@ static inline void _addToPropList(NSMutableDictionary *propertyList, return nil; } -- (NSString *)readFormat { - return nil; -} -- (NSString *)writeFormat { - return nil; -} - @end /* EOAttribute(EOF2Additions) */ @implementation NSString(BeautifyAttributeName) - (NSString *)_beautifyAttributeName { + // DML Unicode unsigned clen = 0; char *s = NULL; unsigned cnt, cnt2; diff --git a/sope-gdl1/GDLAccess/EODatabase.m b/sope-gdl1/GDLAccess/EODatabase.m index 8f5ef430..d56207b1 100644 --- a/sope-gdl1/GDLAccess/EODatabase.m +++ b/sope-gdl1/GDLAccess/EODatabase.m @@ -225,7 +225,9 @@ static inline void _removeDatabaseInstance(EODatabase *_db) { } + (void)forgetObject:(id)_object { - [EOObjectUniquer forgetObject:_object]; + static Class UniquerClass = Nil; + if (UniquerClass == Nil) UniquerClass = [EOObjectUniquer class]; + [(EOObjectUniquer *)UniquerClass forgetObject:_object]; [lock lock]; { diff --git a/sope-gdl1/GDLAccess/EOEntity.m b/sope-gdl1/GDLAccess/EOEntity.m index e3989dd1..e85ae23d 100644 --- a/sope-gdl1/GDLAccess/EOEntity.m +++ b/sope-gdl1/GDLAccess/EOEntity.m @@ -486,10 +486,7 @@ static int _compareByName(id obj1, id obj2, void * context); if(!([anAttribute isKindOfClass:[EOAttribute class]] && [self->attributesByName objectForKey:[anAttribute name]])) return NO; - - if([anAttribute isDerived]) - return NO; - + return YES; } @@ -588,28 +585,26 @@ static int _compareByName(id obj1, id obj2, void * context); return self->attributes; } -@end /* EOEntity */ - - -@implementation EOEntity (EOEntityCreation) +/* EOEntityCreation */ + (EOEntity *)entityFromPropertyList:(id)propertyList model:(EOModel *)_model { + NSDictionary *plist = propertyList; EOEntity *entity; NSArray *array; NSEnumerator *enumerator; id attributePList; id relationshipPList; - entity = AUTORELEASE([[EOEntity alloc] init]); + entity = [[[EOEntity alloc] init] autorelease]; [entity setCreateMutableObjects:YES]; - entity->name = RETAIN([propertyList objectForKey:@"name"]); - entity->className = RETAIN([propertyList objectForKey:@"className"]); - entity->externalName = RETAIN([propertyList objectForKey:@"externalName"]); - entity->externalQuery = RETAIN([propertyList objectForKey:@"externalQuery"]); - entity->userDictionary = RETAIN([propertyList objectForKey:@"userDictionary"]); + entity->name = RETAIN([plist objectForKey:@"name"]); + entity->className = RETAIN([plist objectForKey:@"className"]); + entity->externalName = RETAIN([plist objectForKey:@"externalName"]); + entity->externalQuery = RETAIN([plist objectForKey:@"externalQuery"]); + entity->userDictionary = RETAIN([plist objectForKey:@"userDictionary"]); - array = [propertyList objectForKey:@"attributes"]; + array = [plist objectForKey:@"attributes"]; enumerator = [array objectEnumerator]; while ((attributePList = [enumerator nextObject])) { @@ -625,21 +620,21 @@ static int _compareByName(id obj1, id obj2, void * context); } entity->attributesUsedForLocking - = RETAIN([propertyList objectForKey:@"attributesUsedForLocking"]); + = RETAIN([plist objectForKey:@"attributesUsedForLocking"]); entity->classPropertyNames - = RETAIN([propertyList objectForKey:@"classProperties"]); + = RETAIN([plist objectForKey:@"classProperties"]); - if ((attributePList = [propertyList objectForKey:@"primaryKeyAttributes"])) { + if ((attributePList = [plist objectForKey:@"primaryKeyAttributes"])) { entity->primaryKeyAttributeNames = RETAIN([attributePList sortedArrayUsingSelector:@selector(compare:)]); } else - if ((attributePList = [propertyList objectForKey:@"primaryKeyAttribute"])) + if ((attributePList = [plist objectForKey:@"primaryKeyAttribute"])) entity->primaryKeyAttributeNames = RETAIN([NSArray arrayWithObject:attributePList]); - array = [propertyList objectForKey:@"relationships"]; + array = [plist objectForKey:@"relationships"]; enumerator = [array objectEnumerator]; while((relationshipPList = [enumerator nextObject])) { EORelationship *relationship @@ -802,12 +797,15 @@ static inline BOOL _containsObject(NSArray *a, id obj) { EOAttribute *attr = [self->attributes objectAtIndex:i]; BOOL pk, lk, cp, sa; - pk = _containsObject(self->primaryKeyAttributes, attr); + pk = _containsObject(self->primaryKeyAttributes, attr); lk = _containsObject(self->attributesUsedForLocking, attr); - cp = _containsObject(self->classProperties, attr); - sa = (![attr isDerived] && ![attr isFlattened]); - - //NSLog(@"attribute %@ pk=%i lk=%i cp=%i sa=%i", [attr name], pk, lk, cp, sa); + cp = _containsObject(self->classProperties, attr); + sa = YES; + +#if 0 + NSLog(@"attribute %@ pk=%i lk=%i cp=%i sa=%i", + [attr name], pk, lk, cp, sa); +#endif if ((pk || lk || cp) && (!_containsObject(fetAttr, attr))) [fetAttr addObject:attr]; diff --git a/sope-gdl1/GDLAccess/EOExpressionArray.h b/sope-gdl1/GDLAccess/EOExpressionArray.h index 08f887f5..4452d866 100644 --- a/sope-gdl1/GDLAccess/EOExpressionArray.h +++ b/sope-gdl1/GDLAccess/EOExpressionArray.h @@ -64,14 +64,14 @@ /* Checking contents */ - (BOOL)referencesObject:(id)anObject; -- (NSString*)expressionValueForContext:(id)ctx; +- (NSString *)expressionValueForContext:(id)ctx; -+ (EOExpressionArray*)parseExpression:(NSString*)expression - entity:(EOEntity*)entity ++ (EOExpressionArray *)parseExpression:(NSString *)expression + entity:(EOEntity *)entity replacePropertyReferences:(BOOL)flag; -+ (EOExpressionArray*)parseExpression:(NSString*)expression - entity:(EOEntity*)entity ++ (EOExpressionArray *)parseExpression:(NSString *)expression + entity:(EOEntity *)entity replacePropertyReferences:(BOOL)flag relationshipPaths:(NSMutableArray *)relationshipPaths; diff --git a/sope-gdl1/GDLAccess/EOQuotedExpression.m b/sope-gdl1/GDLAccess/EOQuotedExpression.m index 7a001282..2a11fc37 100644 --- a/sope-gdl1/GDLAccess/EOQuotedExpression.m +++ b/sope-gdl1/GDLAccess/EOQuotedExpression.m @@ -32,19 +32,20 @@ @implementation EOQuotedExpression - (id)expressionValueForContext:(id)_context { - NSMutableString *result; - NSArray *components; - id expr; - - expr = [self->expression expressionValueForContext:_context]; - components = [expr componentsSeparatedByString:quote]; - result = [[NSMutableString alloc] initWithCapacity:[expr length] + 10]; - - [result appendString:quote]; - [result appendString:[components componentsJoinedByString:escape]]; - [result appendString:quote]; - - return AUTORELEASE(result); + NSMutableString *result; + NSArray *components; + id expr; + + expr = [(EOExpressionArray *)self->expression + expressionValueForContext:_context]; + components = [expr componentsSeparatedByString:quote]; + result = [NSMutableString stringWithCapacity:[expr length] + 10]; + + [result appendString:quote]; + [result appendString:[components componentsJoinedByString:escape]]; + [result appendString:quote]; + + return result; } - (id)initWithExpression:(id)_expression diff --git a/sope-gdl1/GDLAccess/EORelationship.m b/sope-gdl1/GDLAccess/EORelationship.m index 8918554f..1e16cd14 100644 --- a/sope-gdl1/GDLAccess/EORelationship.m +++ b/sope-gdl1/GDLAccess/EORelationship.m @@ -93,6 +93,7 @@ static EONull *null = nil; } - (void)setDefinition:(NSString *)def { + // TODO: do we need this? if (def == nil) { [NSException raise:NSInvalidArgumentException format:@"invalid (nil) definition argument ..."]; @@ -284,18 +285,19 @@ static EONull *null = nil; + (EORelationship *)relationshipFromPropertyList:(id)_plist model:(EOModel *)model { + NSDictionary *plist = _plist; EORelationship *relationship = nil; NSArray *array = nil; NSEnumerator *enumerator = nil; id joinPList = nil; - relationship = AUTORELEASE([EORelationship new]); + relationship = [[[EORelationship alloc] init] autorelease]; [relationship setCreateMutableObjects:YES]; - [relationship setName:[_plist objectForKey:@"name"]]; + [relationship setName:[plist objectForKey:@"name"]]; [relationship setUserDictionary: - [_plist objectForKey:@"userDictionary"]]; + [plist objectForKey:@"userDictionary"]]; - if ((array = [_plist objectForKey:@"joins"])) { + if ((array = [plist objectForKey:@"joins"])) { enumerator = [array objectEnumerator]; joinPList = [enumerator nextObject]; @@ -308,19 +310,19 @@ static EONull *null = nil; } relationship->destinationEntity = - RETAIN([_plist objectForKey:@"destination"]); + RETAIN([plist objectForKey:@"destination"]); // retained string relationship->flags.isToMany = - [[_plist objectForKey:@"isToMany"] isEqual:@"Y"]; + [[plist objectForKey:@"isToMany"] isEqual:@"Y"]; relationship->flags.isMandatory = - [[_plist objectForKey:@"isMandatory"] isEqual:@"Y"]; + [[plist objectForKey:@"isMandatory"] isEqual:@"Y"]; /* Do not send here the -setDefinition: message because the relationships are not yet created from the model file. */ relationship->definition - = RETAIN([_plist objectForKey:@"definition"]); + = RETAIN([plist objectForKey:@"definition"]); return relationship; } @@ -433,26 +435,25 @@ static EONull *null = nil; return [[(EORelationship *)self name] compare:[_other name]]; } -@end /* EORelationship (EORelationshipPrivate) */ - -@implementation EORelationship(EOJoin) +/* EOJoin */ - (void)loadJoinPropertyList:(id)propertyList { + NSDictionary *plist = propertyList; NSString *joinOperatorPList; NSString *joinSemanticPList; id tmp; - tmp = [propertyList objectForKey:@"sourceAttribute"]; + tmp = [plist objectForKey:@"sourceAttribute"]; [self setSourceAttribute:tmp]; - tmp = [propertyList objectForKey:@"destinationAttribute"]; + tmp = [plist objectForKey:@"destinationAttribute"]; [self setDestinationAttribute:tmp]; - if ((joinOperatorPList = [propertyList objectForKey:@"joinOperator"])) { + if ((joinOperatorPList = [plist objectForKey:@"joinOperator"])) { NSAssert([joinOperatorPList isEqual:@"EOJoinEqualTo"], @"only EOJoinEqualTo is supported as the join operator !"); } - if ((joinSemanticPList = [propertyList objectForKey:@"joinSemantic"])) { + if ((joinSemanticPList = [plist objectForKey:@"joinSemantic"])) { NSAssert([joinSemanticPList isEqual:@"EOInnerJoin"], @"only EOInnerJoin is supported as the join semantic !"); } @@ -490,9 +491,7 @@ static EONull *null = nil; [self setDestinationAttribute:[_join destinationAttribute]]; } -@end /* EORelationship(EOJoin) */ - -@implementation EORelationship(PropertyListCoding) +/* PropertyListCoding */ static inline void _addToPropList(NSMutableDictionary *_plist, id _value, NSString *key) { @@ -523,9 +522,7 @@ static inline void _addToPropList(NSMutableDictionary *_plist, _addToPropList(_plist, flags.isMandatory ? @"Y" : @"N", @"isMandatory"); } -@end /* EORelationship(PropertyListCoding) */ - -@implementation EORelationship(EOF2Additions) +/* EOF2Additions */ /* constraints */ @@ -561,7 +558,7 @@ static inline void _addToPropList(NSMutableDictionary *_plist, return nil; } -@end /* EORelationship(EOF2Additions) */ +@end /* EORelationship */ @implementation EOJoin @end /* EOJoin */ diff --git a/sope-gdl1/GDLAccess/EOSQLExpression.m b/sope-gdl1/GDLAccess/EOSQLExpression.m index d273de63..f8dc18a2 100644 --- a/sope-gdl1/GDLAccess/EOSQLExpression.m +++ b/sope-gdl1/GDLAccess/EOSQLExpression.m @@ -563,12 +563,10 @@ NSString *EOBindVariableValueKey = @"value"; while((attributeName = [enumerator nextObject])) { EOAttribute *attribute; - NSString *updateFormat; NSString *columnName = nil; id value = nil; - attribute = [entity attributeNamed:attributeName]; - updateFormat = [attribute updateFormat]; + attribute = [entity attributeNamed:attributeName]; NSAssert1(attribute, @"attribute %@ should be non nil", attributeName); columnName = adaptor @@ -577,26 +575,10 @@ NSString *EOBindVariableValueKey = @"value"; value = [row objectForKey:attributeName]; - if (updateFormat) { - [scannerHandler setValue:value - attribute:attribute - adaptor:adaptor]; -#if defined(__s390__) - value = [formatScanner performSelector: - @selector(stringWithFormat:arguments:) - withObject:updateFormat - withObject:nil]; -#else - value = [formatScanner stringWithFormat:updateFormat - arguments:NULL]; -#endif - } - else { - value = [self literalForAttribute:attribute - withValue:value fromRow:row]; - } - - if(first) first = NO; + value = [self literalForAttribute:attribute + withValue:value fromRow:row]; + + if (first) first = NO; else [expression appendString:@", "]; [expression appendString:columnName]; @@ -657,34 +639,16 @@ NSString *EOBindVariableValueKey = @"value"; while ((attributeName = [enumerator nextObject])) { EOAttribute *attribute; - NSString *insertFormat; id value; attribute = [entity attributeNamed:attributeName]; - insertFormat = [attribute insertFormat]; value = [row objectForKey:attributeName]; NSAssert1(attribute, @"attribute %@ should be non nil", attributeName); - if (insertFormat) { - [scannerHandler setValue:value - attribute:attribute - adaptor:self->adaptor]; -#if defined(__s390__) - value = [formatScanner performSelector: - @selector(stringWithFormat:arguments:) - withObject:insertFormat - withObject:nil]; -#else - value = [formatScanner stringWithFormat:insertFormat - arguments:NULL]; -#endif - } - else { - value = [self literalForAttribute:attribute - withValue:value fromRow:row]; - } - - if(first) first = NO; + value = [self literalForAttribute:attribute + withValue:value fromRow:row]; + + if (first) first = NO; else [expression appendString:@", "]; [expression appendString:value]; @@ -722,18 +686,9 @@ NSString *EOBindVariableValueKey = @"value"; [attribute name], [entity name]] raise]; } - if ([attribute isFlattened]) { - id definitionArray = [attribute definitionArray]; - NSRange range = { 0, [definitionArray count] - 1 }; - id relationshipPath = [definitionArray subarrayWithRange:range]; - [relationshipPaths addObject:relationshipPath]; - [entities addObjectsFromArray:relationshipPath]; - } - else { - /* attribute is normal. */ - [entities addObject:[attribute entity]]; - } + /* attribute is normal. */ + [entities addObject:[attribute entity]]; } [relationshipPaths unionSet:[qualifier relationshipPaths]]; @@ -756,14 +711,6 @@ NSString *EOBindVariableValueKey = @"value"; [attribute name], [entity name]] raise]; } - if ([attribute isFlattened]) { - id definitionArray = [attribute definitionArray]; - NSRange range = { 0, [definitionArray count] - 1 }; - id relationshipPath = [definitionArray subarrayWithRange:range]; - - [relationshipPaths addObject:relationshipPath]; - [entities addObjectsFromArray:relationshipPath]; - } } entitiesAndPropertiesAliases = [NSMutableDictionary new]; @@ -807,16 +754,10 @@ NSString *EOBindVariableValueKey = @"value"; } - (NSString *)expressionValueForAttribute:(EOAttribute *)attribute { - if([attribute isFlattened]) - return [self expressionValueForAttributePath: - [attribute definitionArray]]; - else if([attribute isDerived]) - return [[attribute definitionArray] expressionValueForContext:self]; - - /* attribute is a normal attribute. Its alias is the alias - of its entity. */ - return [self expressionValueForAttribute:attribute - context:[attribute entity]]; + /* attribute is a normal attribute. Its alias is the alias + of its entity. */ + return [self expressionValueForAttribute:attribute + context:[attribute entity]]; } - (NSString *)expressionValueForAttributePath:(NSArray *)definitionArray { @@ -1268,7 +1209,7 @@ NSString *EOBindVariableValueKey = @"value"; sql = [self sqlStringForAttributeNamed:[_q leftKey]]; a = [[self entity] attributeNamed:[_q leftKey]]; /* relationships ? */ - sql = [[self class] formatSQLString:sql format:[a readFormat]]; + sql = [[self class] formatSQLString:sql format:nil]; [s appendString:sql]; [s appendString:@" "]; @@ -1277,7 +1218,7 @@ NSString *EOBindVariableValueKey = @"value"; sql = [self sqlStringForAttributeNamed:[_q rightKey]]; a = [[self entity] attributeNamed:[_q rightKey]]; /* relationships ? */ - sql = [[self class] formatSQLString:sql format:[a readFormat]]; + sql = [[self class] formatSQLString:sql format:nil]; [s appendString:sql]; return s; @@ -1294,7 +1235,7 @@ NSString *EOBindVariableValueKey = @"value"; sql = [self sqlStringForAttributeNamed:[_q key]]; a = [[self entity] attributeNamed:[_q key]]; /* relationships ? */ - sql = [[self class] formatSQLString:sql format:[a readFormat]]; + sql = [[self class] formatSQLString:sql format:nil]; [s appendString:sql]; [s appendString:@" "]; @@ -1404,7 +1345,7 @@ NSString *EOBindVariableValueKey = @"value"; s = [[NSMutableString alloc] initWithCapacity:32]; [s appendString:[_attr columnName]]; [s appendString:@"="]; - _value = [[self class] formatSQLString:_value format:[_attr writeFormat]]; + _value = [[self class] formatSQLString:_value format:nil]; [s appendString:_value]; [self appendItem:s toListString:[self listString]]; diff --git a/sope-gdl1/GDLAccess/EOSQLQualifier.m b/sope-gdl1/GDLAccess/EOSQLQualifier.m index 2d7e5cca..ccf08d9b 100644 --- a/sope-gdl1/GDLAccess/EOSQLQualifier.m +++ b/sope-gdl1/GDLAccess/EOSQLQualifier.m @@ -88,7 +88,7 @@ static EONull *null = nil; adaptor = [context adaptor]; if ([source isKindOfClass:AttributeClass]) { - formattedLeft = [source expressionValueForContext:context]; + formattedLeft = [(EOAttribute *)source expressionValueForContext:context]; } else { NSAssert([destination isKindOfClass:AttributeClass], @@ -103,7 +103,8 @@ static EONull *null = nil; if ([destination isKindOfClass:AttributeClass]) { NSString *tmp = formattedLeft; - formattedLeft = [destination expressionValueForContext:context]; + formattedLeft = + [(EOAttribute *)destination expressionValueForContext:context]; formattedRight = tmp; } else { @@ -405,21 +406,7 @@ static EONull *null = nil; static void handle_attribute(EOSQLQualifier *self, id object, id _relationshipPaths) { - if ([object isFlattened]) { - id definitionArray = nil; - id relsArray = nil; - NSRange range; - - definitionArray = [object definitionArray]; - range = NSMakeRange(0, [definitionArray count] - 1); - relsArray = [definitionArray subarrayWithRange:range]; - - [self->relationshipPaths addObject:relsArray]; - [self->additionalEntities addObjectsFromArray:relsArray]; - } - else { - [self->additionalEntities addObject:[object entity]]; - } + [self->additionalEntities addObject:[object entity]]; } - (void)_computeRelationshipPaths:(NSArray *)_relationshipPaths { diff --git a/sope-gdl1/GDLAccess/EOSelectSQLExpression.m b/sope-gdl1/GDLAccess/EOSelectSQLExpression.m index 2c750a3d..f6340db3 100644 --- a/sope-gdl1/GDLAccess/EOSelectSQLExpression.m +++ b/sope-gdl1/GDLAccess/EOSelectSQLExpression.m @@ -57,35 +57,11 @@ { NSString *alias; NSString *columnName; - NSString *selectFormat; - alias = [entitiesAndPropertiesAliases objectForKey:context]; - selectFormat = [attribute selectFormat]; + alias = [entitiesAndPropertiesAliases objectForKey:context]; //NSLog(@"entitiesAndPropertiesAliases: %@", entitiesAndPropertiesAliases); - if (selectFormat) { - PrintfFormatScanner *formatScanner; - EOSelectScannerHandler *scannerHandler; - - formatScanner = - [[[[PrintfFormatScanner alloc] init] setAllowOnlySpecifier:YES] - autorelease]; - scannerHandler = - [[[EOSelectScannerHandler alloc] init] autorelease]; - - [scannerHandler setAttribute:attribute adaptor:adaptor alias:alias]; - [formatScanner setFormatScannerHandler:scannerHandler]; -#if defined(__s390__) - return [formatScanner performSelector: - @selector(stringWithFormat:arguments:) - withObject:selectFormat - withObject:nil]; -#else - return [formatScanner stringWithFormat:selectFormat arguments:NULL]; -#endif - } - else { columnName = adaptor ? [adaptor formatAttribute:attribute] : [attribute columnName]; @@ -96,28 +72,25 @@ } return columnName; - } } @end /* EOSelectSQLExpression */ @implementation EOSelectScannerHandler -- (id)init -{ - [super init]; - +- (id)init { + if ((self = [super init]) != nil) { specHandler['A'] - = [self methodForSelector:@selector(convertAttribute:scanner:)]; - return self; + = [self methodForSelector:@selector(convertAttribute:scanner:)]; + } + return self; } -- (void)dealloc -{ - RELEASE(self->attribute); - RELEASE(self->adaptor); - RELEASE(self->alias); - [super dealloc]; +- (void)dealloc { + [self->attribute release]; + [self->adaptor release]; + [self->alias release]; + [super dealloc]; } - (void)setAttribute:(EOAttribute*)_attribute diff --git a/sope-gdl1/GDLAccess/Version b/sope-gdl1/GDLAccess/Version index 9c2df247..704a8fa2 100644 --- a/sope-gdl1/GDLAccess/Version +++ b/sope-gdl1/GDLAccess/Version @@ -1,3 +1,3 @@ # version file -SUBMINOR_VERSION:=48 +SUBMINOR_VERSION:=49 -- 2.39.5