* DBModeler/Modeler.m,

* EOAccess/EOEntityPriv.h,
        * EOAccess/EOModel.h/m,
        * EOAccess/EOEntity.h/m,
        * EOAccess/EORelationship.h/m: Remove setCreateMutableObjects: and
        createsMutableObjects.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@26227 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Matt Rice 2008-03-06 16:28:22 +00:00
parent 0cd90888a5
commit e35a70da43
9 changed files with 38 additions and 301 deletions

View file

@ -1,3 +1,12 @@
2008-03-06 Matt Rice <ratmice@gmail.com>
* DBModeler/Modeler.m,
* EOAccess/EOEntityPriv.h,
* EOAccess/EOModel.h/m,
* EOAccess/EOEntity.h/m,
* EOAccess/EORelationship.h/m: Remove setCreateMutableObjects: and
createsMutableObjects.
2008-03-06 David Ayers <ayers@fsfe.org>
* EOControl/EOFault.m ([-forward::]): Make dummy implementation.

View file

@ -64,10 +64,6 @@
-(id <NSMenuItem>) addItemWithTitle: (NSString *)s action: (SEL)sel;
@end
@interface EOModel (foo)
-(void)setCreatesMutableObjects:(BOOL)flag;
@end
@implementation NSMenu (im_lazy)
-(id <NSMenuItem>) addItemWithTitle: (NSString *)s
{

View file

@ -116,8 +116,7 @@
unsigned int isAbstractEntity:1;
unsigned int updating:1;
unsigned int cachesObjects:1;
unsigned int createsMutableObjects:1;
unsigned int unused:1;
unsigned int extraRefCount:22;
} _flags;

View file

@ -387,7 +387,6 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
}
}
[self setCreateMutableObjects: NO]; //?? TC say no, mirko yes
_flags.updating = NO;
}
}
@ -566,7 +565,7 @@ NSString *EONextPrimaryKeyProcedureOperation = @"EONextPrimaryKeyProcedureOperat
{
_attributes = [NSMutableArray new];
_subEntities = [NSMutableArray new];
[self setCreateMutableObjects: YES];
_relationships = [NSMutableArray new];
}
return self;
@ -1784,11 +1783,7 @@ createInstanceWithEditingContext:globalID:zone:
[(EOEntity *)[attribute parent] name]);
[self willChange];
if ([self createsMutableObjects])
[_attributes addObject: attribute];
else
_attributes
= RETAIN([AUTORELEASE(_attributes) arrayByAddingObject: attribute]);
[_attributes addObject: attribute];
if (_attributesByName == nil)
{
@ -1815,45 +1810,10 @@ createInstanceWithEditingContext:globalID:zone:
[attribute setParent: nil];
NSEmitTODO(); //TODO
//TODO
if ([self createsMutableObjects])
{
[_attributes removeObject: attribute];
[_attributes removeObject: attribute];
[_classProperties removeObject:attribute];
[_primaryKeyAttributes removeObject:attribute];
[_classProperties removeObject:attribute];
[_primaryKeyAttributes removeObject:attribute];
}
else
{
_attributes
= [[NSMutableArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
[_attributes removeObject: attribute];
_attributes
= [[NSArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
if ([_classProperties containsObject:attribute])
{
_classProperties = [[NSMutableArray alloc]
initWithArray:AUTORELEASE(_classProperties)
copyItems:NO];
[_classProperties removeObject: attribute];
_classProperties = [[NSArray alloc]
initWithArray:AUTORELEASE(_classProperties)
copyItems:NO];
}
if ([_primaryKeyAttributes containsObject:attribute])
{
_primaryKeyAttributes = [[NSMutableArray alloc]
initWithArray:AUTORELEASE(_primaryKeyAttributes)
copyItems:NO];
[_primaryKeyAttributes removeObject: attribute];
_primaryKeyAttributes = [[NSArray alloc]
initWithArray:AUTORELEASE(_primaryKeyAttributes)
copyItems:NO];
}
}
// in _setIsEdited _attributesByName isn't cleared do it here??
[_attributesByName removeObjectForKey: [attribute name]];
// _classProperty*Names is cleared
@ -1883,11 +1843,7 @@ createInstanceWithEditingContext:globalID:zone:
relationshipName];
[self willChange];
if ([self createsMutableObjects])
[_relationships addObject: relationship];
else
_relationships = RETAIN([AUTORELEASE(_relationships)
arrayByAddingObject: relationship]);
[_relationships addObject: relationship];
if (_relationshipsByName == nil)
{
@ -1914,28 +1870,10 @@ createInstanceWithEditingContext:globalID:zone:
if(_relationshipsByName != nil)
[_relationshipsByName removeObjectForKey:[relationship name]];
if ([self createsMutableObjects])
{
[_relationships removeObject: relationship];
[_classProperties removeObject: relationship];
}
else
{
_relationships
= [[NSMutableArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
[_relationships removeObject: relationship];
_relationships
= [[NSArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
_classProperties = [[NSMutableArray alloc]
initWithArray:AUTORELEASE(_classProperties)
copyItems:NO];
[_classProperties removeObject: relationship];
_classProperties = [[NSArray alloc]
initWithArray:AUTORELEASE(_classProperties)
copyItems:NO];
}
[_relationships removeObject: relationship];
[_classProperties removeObject: relationship];
/* We call this after adjusting the arrays so that setEntity: has
the opportunity to check the relationships before calling
removeRelationshipt which would lead to an infinite loop. */
@ -2432,49 +2370,6 @@ createInstanceWithEditingContext:globalID:zone:
return NO; // TODO
}
- (void) setCreateMutableObjects: (BOOL)flag
{
if (_flags.createsMutableObjects == flag)
{
return;
}
_flags.createsMutableObjects = flag;
//TODO NSEmitTODO();
if (_flags.createsMutableObjects)
{
_attributes
= [[NSMutableArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
_relationships
= [[NSMutableArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
}
else
{
_attributes
= [[NSArray alloc] initWithArray:AUTORELEASE(_attributes)
copyItems:NO];
_relationships
= [[NSArray alloc] initWithArray:AUTORELEASE(_relationships)
copyItems:NO];
}
NSAssert4(!_attributesToFetch
|| [_attributesToFetch isKindOfClass: [NSArray class]],
@"entity %@ attributesToFetch %p is not an NSArray but a %@\n%@",
[self name],
_attributesToFetch,
[_attributesToFetch class],
_attributesToFetch);
}
- (BOOL) createsMutableObjects
{
return _flags.createsMutableObjects;
}
/* throws an exception if _model is not nil, and the model argument is not
* identical to the _model ivar. As a special case EOModel -removeEntity:
* is allowed to call this with a nil model, but removeEntity: is responsible

View file

@ -41,9 +41,6 @@ GDL2ACCESS_EXPORT void GDL2DestinationEntitiesRemoveRelationship(EOEntity *entit
- (BOOL)isPrototypeEntity;
- (void)setCreateMutableObjects: (BOOL)flag;
- (BOOL)createsMutableObjects;
- (void)_setModel: (EOModel *)model;
- (void)_setParentEntity: (EOEntity *)parent;

View file

@ -71,7 +71,7 @@
//NSMutableDictionary *_prototypesByName;
struct
{
BOOL createsMutableObjects:1;
BOOL unused:1;
BOOL errors:1;
} _flags;
}

View file

@ -87,8 +87,6 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
+ (NSString *) _formatModelPath: (NSString *)path checkFileSystem: (BOOL)chkFS;
- (void) setCreateMutableObjects: (BOOL)flag;
- (BOOL) createsMutableObjects;
- (EOEntity *) _verifyBuiltEntityObject: (id)entity
named: (NSString *)name;
@ -208,7 +206,6 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
{
// Turbocat
_version = DEFAULT_MODEL_VERSION;
_flags.createsMutableObjects = YES;
_entitiesByName = [NSMutableDictionary new];
_entitiesByClass = NSCreateMapTableWithZone(NSObjectMapKeyCallBacks,
@ -908,7 +905,6 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
propListSt = [propertyList objectForKey: @"storedProcedures"];
_flags.errors = NO;
[self setCreateMutableObjects: YES];
count = [propListEntities count];
for (i = 0; i < count; i++)
@ -993,8 +989,6 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
while ((sp = [enumerator nextObject]))
[sp awakeWithPropertyList: [markSP objectForKey: [sp name]]];
}
[self setCreateMutableObjects: NO];
}
}
NS_HANDLER
@ -1444,16 +1438,9 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
[entity name], [[entity model] name]);
[self willChange];
/* Do not access _entities until cache is triggered */
if ([self createsMutableObjects])
[(NSMutableArray *)[self entities] addObject: entity];
else
{
id e = [NSMutableArray arrayWithArray: [self entities]];
[e addObject: entity];
ASSIGNCOPY(_entities, e);
}
[(NSMutableArray *)[self entities] addObject: entity];
NSAssert(_entitiesByClass, @"No _entitiesByClass");
@ -1486,15 +1473,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
NSMapRemove(_entitiesByClass, className);
/* Do not access _entities until cache is triggered */
if ([self createsMutableObjects])
[(NSMutableArray *)[self entities] removeObject: entity];
else
{
id e = [NSMutableArray arrayWithArray: [self entities]];
[e removeObject: entity];
ASSIGNCOPY(_entities, e);
}
[(NSMutableArray *)[self entities] removeObject: entity];
}
- (void) removeEntityAndReferences: (EOEntity *)entity
@ -1514,12 +1493,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
[storedProcedure name]];
NSAssert(_storedProcedures, @"Uninitialised _storedProcedures!");
[self willChange];
if ([self createsMutableObjects])
[(NSMutableArray *)_storedProcedures addObject: storedProcedure];
else
{
_storedProcedures = RETAIN([AUTORELEASE(_storedProcedures) arrayByAddingObject:storedProcedure]);
}
[(NSMutableArray *)_storedProcedures addObject: storedProcedure];
}
- (void)removeStoredProcedure: (EOStoredProcedure *)storedProcedure
@ -1527,16 +1501,7 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
NSAssert(_storedProcedures, @"Uninitialised _storedProcedures!");
[self willChange];
if ([self createsMutableObjects])
[(NSMutableArray *)_storedProcedures removeObject: storedProcedure];
else
{
NSMutableArray *mCopy = AUTORELEASE([_storedProcedures mutableCopy]);
[mCopy removeObject: storedProcedure];
mCopy = AUTORELEASE([[NSArray alloc] initWithArray: mCopy
copyItems: NO]);
ASSIGN(_storedProcedures, mCopy);
}
[(NSMutableArray *)_storedProcedures removeObject: storedProcedure];
}
- (void) setModelGroup: (EOModelGroup *)group
@ -1742,33 +1707,6 @@ NSString *EOEntityLoadedNotification = @"EOEntityLoadedNotification";
return returnPath;
}
- (void) setCreateMutableObjects: (BOOL)flag
{
if (_flags.createsMutableObjects != flag)
{
NSArray *entityArray = [self entities];
_flags.createsMutableObjects = flag;
/* Do not access _entities until cache is triggered */
if (_flags.createsMutableObjects)
{
entityArray = [[NSMutableArray alloc] initWithArray: entityArray
copyItems:NO];
}
else
{
entityArray = [[NSArray alloc] initWithArray: entityArray
copyItems:NO];
}
ASSIGN(_entities, entityArray);
}
}
- (BOOL) createsMutableObjects
{
return _flags.createsMutableObjects;
}
- (EOEntity *) _verifyBuiltEntityObject: (id)entity
named: (NSString*)name
{

View file

@ -76,7 +76,7 @@ typedef enum {
unsigned int isMandatory:1;
unsigned int ownsDestination:1;
unsigned int propagatesPrimaryKey:1;
unsigned int createsMutableObjects:1;
unsigned int unused:1;
unsigned int isBidirectional:1;
unsigned int extraRefCount:23;
} _flags;
@ -194,8 +194,6 @@ typedef enum {
- (id)propertyList;*/
- (void)setCreateMutableObjects: (BOOL)flag;
- (BOOL)createsMutableObjects;
- (void)setInverseRelationship: (EORelationship *)relationship;
@end /* EORelationship (EORelationshipPrivate) */

View file

@ -95,12 +95,14 @@ RCS_ID("$Id$")
//OK
if ((self = [super init]))
{
/* _sourceNames = [NSMutableDictionary new];
/*
_sourceNames = [NSMutableDictionary new];
_destinationNames = [NSMutableDictionary new];
_userInfo = [NSDictionary new];
_sourceToDestinationKeyMap = [NSDictionary new];
*/
_joins = [NSMutableArray new];
*/
}
return self;
@ -146,7 +148,6 @@ RCS_ID("$Id$")
[self setName: relationshipName];
[self setEntity: owner];
[self setCreateMutableObjects: YES];
destinationEntityName = [propertyList objectForKey: @"destination"];
@ -374,8 +375,6 @@ RCS_ID("$Id$")
};
*/
[self setCreateMutableObjects: NO]; //?? tc say yes, mirko no
EOFLOGObjectFnStop();
}
@ -1046,7 +1045,7 @@ relationships. Nil if none" **/
EORelationship *inverseRelationship;
NSString *name;
NSArray *joins = nil;
int i, count;
unsigned int i, count;
EOFLOGObjectFnStart();
@ -1508,38 +1507,14 @@ relationships. Nil if none" **/
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
if ([self createsMutableObjects])
{
if (!_joins)
_joins = [NSMutableArray new];
if (!_joins)
_joins = [NSMutableArray new];
[(NSMutableArray *)_joins addObject: join];
[(NSMutableArray *)_joins addObject: join];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
}
else
{
if (_joins)
_joins = RETAIN([[_joins autorelease]
arrayByAddingObject: join]);
else
_joins = RETAIN([NSArray arrayWithObject: join]);
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
/*NO: will be recomputed _sourceAttributes = [[[_sourceAttributes autorelease]
arrayByAddingObject:[join sourceAttribute]]
retain];
_destinationAttributes = [[[_destinationAttributes autorelease]
arrayByAddingObject:
[join destinationAttribute]]
retain];
*/
}
EOFLOGObjectLevel(@"EORelationship", @"added");
[self _joinsChanged];
@ -1567,9 +1542,7 @@ relationships. Nil if none" **/
else
{
[self willChange];
if ([self createsMutableObjects])
{
[(NSMutableArray *)_joins removeObject: join];
[(NSMutableArray *)_joins removeObject: join];
/*NO: will be recomputed [(NSMutableArray *)_sourceAttributes
removeObject:[join sourceAttribute]];
@ -1577,34 +1550,8 @@ relationships. Nil if none" **/
removeObject:[join destinationAttribute]];
*/
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
}
else
{
NSMutableArray *ma = [_joins mutableCopy];
NSArray *a = _joins;
[ma removeObject: join];
_joins = ma;
[a release];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
/*NO: will be recomputed
_sourceAttributes = [[_sourceAttributes autorelease] mutableCopy];
[(NSMutableArray *)_sourceAttributes
removeObject:[join sourceAttribute]];
_sourceAttributes = [[_sourceAttributes autorelease] copy];
_destinationAttributes = [[_destinationAttributes autorelease]
mutableCopy];
[(NSMutableArray *)_destinationAttributes
removeObject:[join destinationAttribute]];
_destinationAttributes = [[_destinationAttributes autorelease] copy];
*/
}
[self _joinsChanged];
/* Ayers: Not sure what justifies this. */
@ -1738,48 +1685,6 @@ becomes "name", and "FIRST_NAME" becomes "firstName".*/
@implementation EORelationship (EORelationshipPrivate)
- (void)setCreateMutableObjects: (BOOL)flag
{
if (_flags.createsMutableObjects != flag)
{
_flags.createsMutableObjects = flag;
if (_flags.createsMutableObjects)
{
_joins = [[_joins autorelease] mutableCopy];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
DESTROY(_sourceAttributes);
DESTROY(_destinationAttributes);
/*Will be recomputed later _sourceAttributes = [[_sourceAttributes autorelease] mutableCopy];
_destinationAttributes = [[_destinationAttributes autorelease]
mutableCopy];
*/
}
else
{
_joins = [[NSArray alloc] initWithArray:[_joins autorelease] copyItems:NO];
EOFLOGObjectLevelArgs(@"EORelationship", @"XXjoins %p class%@",
_joins, [_joins class]);
DESTROY(_sourceAttributes);
DESTROY(_destinationAttributes);
/*Will be recomputed later _sourceAttributes = [[_sourceAttributes autorelease] copy];
_destinationAttributes = [[_destinationAttributes autorelease] copy];
*/
}
}
}
- (BOOL)createsMutableObjects
{
return _flags.createsMutableObjects;
}
/* TODO this method should probably be private. */
- (void)setInverseRelationship: (EORelationship*)relationship
{