* EOAccess/EOEntity.m: Replaced autorelease with AUTORELEASE.

([EOEntity -addRelationship:]): Update _relationshipByName cache.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@16638 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
David Ayers 2003-05-05 16:24:17 +00:00
parent 566354cac6
commit 1838637ee3
2 changed files with 55 additions and 32 deletions

View file

@ -1,3 +1,8 @@
2003-05-05 David Ayers <d.ayers@inode.at>
* EOAccess/EOEntity.m: Replaced autorelease with AUTORELEASE.
([EOEntity -addRelationship:]): Update _relationshipByName cache.
2003-05-02 David Ayers <d.ayers@inode.at> 2003-05-02 David Ayers <d.ayers@inode.at>
* EOControl/EOKeyValueCoding.h: Use base/Foundation * EOControl/EOKeyValueCoding.h: Use base/Foundation

View file

@ -1,7 +1,7 @@
/** /**
EOEntity.m <title>EOEntity Class</title> EOEntity.m <title>EOEntity Class</title>
Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
Author: Mirko Viviani <mirko.viviani@rccr.cremona.it> Author: Mirko Viviani <mirko.viviani@rccr.cremona.it>
Date: February 2000 Date: February 2000
@ -91,14 +91,14 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
+ (EOEntity *)entity + (EOEntity *)entity
{ {
return [[[self alloc] init] autorelease]; return AUTORELEASE([[self alloc] init]);
} }
+ (EOEntity *)entityWithPropertyList: (NSDictionary *)propertyList + (EOEntity *)entityWithPropertyList: (NSDictionary *)propertyList
owner: (id)owner owner: (id)owner
{ {
return [[[self alloc] initWithPropertyList: propertyList return AUTORELEASE([[self alloc] initWithPropertyList: propertyList
owner: owner] autorelease]; owner: owner]);
} }
- (id) initWithPropertyList: (NSDictionary*)propertyList - (id) initWithPropertyList: (NSDictionary*)propertyList
@ -312,11 +312,10 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
NSEnumerator *variablesEnum; NSEnumerator *variablesEnum;
id fetchSpecName; id fetchSpecName;
unarchiver = [[[EOKeyValueUnarchiver alloc] unarchiver = AUTORELEASE([[EOKeyValueUnarchiver alloc]
initWithDictionary: initWithDictionary:
[NSDictionary dictionaryWithObject: plist [NSDictionary dictionaryWithObject: plist
forKey: @"fspecs"]] forKey: @"fspecs"]]);
autorelease];
variables = [unarchiver decodeObjectForKey: @"fspecs"]; variables = [unarchiver decodeObjectForKey: @"fspecs"];
//NSLog(@"fspecs variables:%@",variables); //NSLog(@"fspecs variables:%@",variables);
@ -2030,7 +2029,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if ([self createsMutableObjects]) if ([self createsMutableObjects])
[(GCMutableArray *)_attributes addObject: attribute]; [(GCMutableArray *)_attributes addObject: attribute];
else else
_attributes = RETAIN([[_attributes autorelease] _attributes = RETAIN([AUTORELEASE(_attributes)
arrayByAddingObject: attribute]); arrayByAddingObject: attribute]);
if (_attributesByName == nil) if (_attributesByName == nil)
@ -2055,9 +2054,13 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
[(GCMutableArray *)_attributes removeObject: attribute]; [(GCMutableArray *)_attributes removeObject: attribute];
else else
{ {
_attributes = [[GCMutableArray alloc] initWithArray:[_attributes autorelease] copyItems:NO]; _attributes
= [[GCMutableArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
[(GCMutableArray *)_attributes removeObject: attribute]; [(GCMutableArray *)_attributes removeObject: attribute];
_attributes = [[GCArray alloc] initWithArray:[_attributes autorelease] copyItems:NO]; _attributes
= [[GCArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
} }
[_attributesByName removeObjectForKey: [attribute name]]; [_attributesByName removeObjectForKey: [attribute name]];
[self _setIsEdited];//To clean caches [self _setIsEdited];//To clean caches
@ -2087,8 +2090,14 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if ([self createsMutableObjects]) if ([self createsMutableObjects])
[(GCMutableArray *)_relationships addObject: relationship]; [(GCMutableArray *)_relationships addObject: relationship];
else else
_relationships = RETAIN([[_relationships autorelease] _relationships = RETAIN([AUTORELEASE(_relationships)
arrayByAddingObject: relationship]); arrayByAddingObject: relationship]);
if (_relationshipsByName == nil)
{
_relationshipsByName = [GCMutableDictionary new];
}
[_relationshipsByName setObject: relationship forKey: relationshipName];
[relationship setEntity: self]; [relationship setEntity: self];
[self _setIsEdited];//To clean caches [self _setIsEdited];//To clean caches
@ -2109,9 +2118,13 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
[(GCMutableArray *)_relationships removeObject: relationship]; [(GCMutableArray *)_relationships removeObject: relationship];
else else
{ {
_relationships = [[GCMutableArray alloc] initWithArray:[_relationships autorelease] copyItems:NO]; _relationships
= [[GCMutableArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
[(GCMutableArray *)_relationships removeObject: relationship]; [(GCMutableArray *)_relationships removeObject: relationship];
_relationships = [[GCArray alloc] initWithArray:[_relationships autorelease] copyItems:NO]; _relationships
= [[GCArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
} }
[self _setIsEdited];//To clean caches [self _setIsEdited];//To clean caches
} }
@ -2633,13 +2646,21 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
if (_flags.createsMutableObjects) if (_flags.createsMutableObjects)
{ {
_attributes = [[GCMutableArray alloc] initWithArray:[_attributes autorelease] copyItems:NO]; _attributes
_relationships = [[GCMutableArray alloc] initWithArray:[_relationships autorelease] copyItems:NO]; = [[GCMutableArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
_relationships
= [[GCMutableArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
} }
else else
{ {
_attributes = [[GCArray alloc] initWithArray:[_attributes autorelease] copyItems:NO]; _attributes
_relationships = [[GCArray alloc] initWithArray:[_relationships autorelease] copyItems:NO]; = [[GCArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
_relationships
= [[GCArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
} }
NSAssert4(!_attributesToFetch NSAssert4(!_attributesToFetch
@ -3769,7 +3790,7 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString*)path
EOFLOGObjectLevelArgs(@"EOEntity", @"expression=%@", description); EOFLOGObjectLevelArgs(@"EOEntity", @"expression=%@", description);
expressionArray = [[EOExpressionArray new] autorelease]; expressionArray = AUTORELEASE([EOExpressionArray new]);
s = [description cString]; s = [description cString];
if (s) if (s)
@ -3855,7 +3876,7 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString*)path
NSLog(@"exception=%@", localException); NSLog(@"exception=%@", localException);
[pool release];//Release the pool ! [pool release];//Release the pool !
[localException autorelease]; AUTORELEASE(localException);
[localException raise]; [localException raise];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
@ -4091,7 +4112,7 @@ toDestinationAttributeInLastComponentOfRelationshipPath: (NSString*)path
+ (EOEntityClassDescription*)entityClassDescriptionWithEntity: (EOEntity *)entity + (EOEntityClassDescription*)entityClassDescriptionWithEntity: (EOEntity *)entity
{ {
return [[[self alloc] initWithEntity: entity] autorelease]; return AUTORELEASE([[self alloc] initWithEntity: entity]);
} }
- (id)initWithEntity: (EOEntity *)entity - (id)initWithEntity: (EOEntity *)entity
@ -4247,11 +4268,10 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
if (objectTo && [entityTo if (objectTo && [entityTo
isPrimaryKeyValidInObject:objectTo] == NO) isPrimaryKeyValidInObject:objectTo] == NO)
{ {
pk = [[[entityTo primaryKeyAttributeNames] mutableCopy] pk = AUTORELEASE([[[entityTo primaryKeyAttributeNames] mutableCopy]);
autorelease];
[pk removeObjectsInArray:[entityTo classPropertyNames]]; [pk removeObjectsInArray:[entityTo classPropertyNames]];
pkObj = [[newPK mutableCopy] autorelease]; pkObj = AUTORELEASE([newPK mutableCopy]);
[pkObj removeObjectsForKeys:pk]; [pkObj removeObjectsForKeys:pk];
[objectTo takeStoredValuesFromDictionary:pkObj]; [objectTo takeStoredValuesFromDictionary:pkObj];
@ -4333,14 +4353,12 @@ fromInsertionInEditingContext: (EOEditingContext *)anEditingContext
{ {
EOFLOGObjectLevelArgs(@"EOEntity", @"objectClass=%@", objectClass); EOFLOGObjectLevelArgs(@"EOEntity", @"objectClass=%@", objectClass);
obj = [[objectClass allocWithZone:zone] obj = AUTORELEASE([[objectClass allocWithZone:zone]
initWithEditingContext: editingContext initWithEditingContext: editingContext
classDescription: self classDescription: self
globalID: globalID]; globalID: globalID]);
} }
[obj autorelease];
EOFLOGObjectFnStop(); EOFLOGObjectFnStop();
return obj; return obj;