* EOAccess/EODatabaseContext.m

-initializeObject:withGlobalID:editingContext:
remove exessive checking
-initializeObject:row:entity:editingContext:
reformat, less IMPs, less logs
* EOControl/EOFault.h
+ retainCount
unsigned -> NSUInteger
* EOControl/EOFault.m
+ retainCount
unsigned -> NSUInteger
+ clearFault:
raise if argument is no fault
rewrote retain behaviour
it makes no sense to free objects here and use the pointers
this would mess up the whole memory and crash.



git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@30886 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Dave Wetzel 2010-06-29 03:10:35 +00:00
parent f14aafa3fc
commit 7c14405e1d
5 changed files with 204 additions and 229 deletions

View file

@ -1,3 +1,22 @@
2010-06-28 David Wetzel <dave@turbocat.de>
* EOAccess/EODatabaseContext.m
-initializeObject:withGlobalID:editingContext:
remove exessive checking
-initializeObject:row:entity:editingContext:
reformat, less IMPs, less logs
* EOControl/EOFault.h
+ retainCount
unsigned -> NSUInteger
* EOControl/EOFault.m
+ retainCount
unsigned -> NSUInteger
+ clearFault:
raise if argument is no fault
rewrote retain behaviour
it makes no sense to free objects here and use the pointers
this would mess up the whole memory and crash.
2010-06-28 David Wetzel <dave@turbocat.de>
* EOAccess/EOEntity.m
- createInstanceWithEditingContext:globalID:zone:

View file

@ -440,7 +440,6 @@ RCS_ID("$Id$")
NS_DURING
{
[_currentEditingContext initializeObject: object
withGlobalID: gid
editingContext: _currentEditingContext];
@ -460,6 +459,7 @@ RCS_ID("$Id$")
}
[object awakeFromFetchInEditingContext: _currentEditingContext];
}
}
}

View file

@ -860,21 +860,12 @@ classPropertyNames = [entity classPropertyNames];
[NSException raise: NSInternalInconsistencyException
format: @"%s No snapshot for gid %@", __PRETTY_FUNCTION__, globalID];
} else {
if ((!object) || ([object isKindOfClass:[EOCustomObject class]] == NO)) {
[NSException raise: NSInternalInconsistencyException
format: @"%s:%d cannot initialize nil/non EOCustomObject object!", __FILE__, __LINE__];
}
[self initializeObject: object
row: snapDict
entity: entity
editingContext: context];
if ((!object) || ([object isKindOfClass:[EOCustomObject class]] == NO)) {
[NSException raise: NSInternalInconsistencyException
format: @"%s:%d Something went wrong!", __FILE__, __LINE__];
}
[_database incrementSnapshotCountForGlobalID:globalID];
}
@ -6140,7 +6131,6 @@ Raises an exception is the adaptor is unable to perform the operations.
NSArray *relationships = nil;
NSArray *classPropertyAttributeNames = nil;
NSUInteger count = 0;
IMP objectTakeStoredValueForKeyIMP=NULL;
IMP rowObjectForKeyIMP=NULL;
classPropertyAttributeNames = [entity classPropertyAttributeNames];
@ -6156,8 +6146,6 @@ Raises an exception is the adaptor is unable to perform the operations.
NSAssert(!_isFault(object),
@"Object is a fault. call -methodForSelector: on it is a bad idea");
objectTakeStoredValueForKeyIMP=[object methodForSelector:@selector(takeStoredValue:forKey:)];
for (i = 0; i < count; i++)
{
id key = GDL2_ObjectAtIndexWithImp(classPropertyAttributeNames,oaiIMP,i);
@ -6169,13 +6157,8 @@ Raises an exception is the adaptor is unable to perform the operations.
if (value == GDL2_EONull)
value = nil;
NSDebugMLLog(@"EODatabaseContext", @"value (%p)",
value);
NSDebugMLLog(@"EODatabaseContext", @"value (%p)=%@ (class: %@)",
value, value, [value class]);
GDL2_TakeStoredValueForKeyWithImp(object,objectTakeStoredValueForKeyIMP,
value,key);
[object takeStoredValue:value
forKey:key];
}
};
@ -6190,13 +6173,9 @@ Raises an exception is the adaptor is unable to perform the operations.
NSUInteger i=0;
IMP oaiIMP=[relationships methodForSelector:@selector(objectAtIndex:)];
if (!objectTakeStoredValueForKeyIMP)
{
NSAssert(!_isFault(object),
@"Object is a fault. call -methodForSelector: on it is a bad idea");
objectTakeStoredValueForKeyIMP=[object methodForSelector:@selector(takeStoredValue:forKey:)];
};
for (i = 0; i < count; i++)
{
@ -6261,8 +6240,8 @@ Raises an exception is the adaptor is unable to perform the operations.
NSDebugMLLog(@"EODatabaseContext", @"relObject=%p (%@)",
relObject, [relObject class]);
//end
/*
//end
/*
NSArray *joins = [(EORelationship *)prop joins];
EOJoin *join;
NSMutableDictionary *row;
@ -6305,14 +6284,12 @@ Raises an exception is the adaptor is unable to perform the operations.
else
fault = nil;
*/
*/
}
}
GDL2_TakeStoredValueForKeyWithImp(object,objectTakeStoredValueForKeyIMP,
relObject,relName);
[object takeStoredValue:relObject
forKey:relName];
}
};

View file

@ -65,7 +65,7 @@
+ (id)retain;
+ (void)release;
+ (id)autorelease;
+ (unsigned)retainCount;
+ (NSUInteger)retainCount;
+ (BOOL)isKindOfClass: (Class)aClass;
+ (void)doesNotRecognizeSelector: (SEL)selector;

View file

@ -114,7 +114,7 @@ static Class EOFaultClass = NULL;
return self;
}
+ (unsigned)retainCount
+ (NSUInteger)retainCount
{
return UINT_MAX;
}
@ -198,49 +198,37 @@ static Class EOFaultClass = NULL;
+ (void)clearFault: (id)fault
{
EOFaultHandler *handler;
EOFault *aFault = (EOFault *)fault;
int refs = 0;
NSDebugFLLog(@"gsdb", @"START fault=%p", fault);
EOFaultHandler * handler;
EOFault * aFault = (EOFault *)fault;
NSUInteger refs = 0;
if ([EOFaultClass isFault:fault] == NO)
{
//REVOIR!!!
/*
[NSException raise:NSInvalidArgumentException
format:@"%@ -- %@ 0x%x: object %@ of class %@ is not a fault object",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
format:@"%s -- object %@ of class %@ is not a fault object",
__PRETTY_FUNCTION__,
fault,
[fault class]];
*/
}
else
{
} else {
handler = aFault->_handler;
[handler faultWillFire: fault];
refs = [handler extraRefCount];
// this will transfer our fault instance into an EO
aFault->isa = [handler targetClass];
aFault->_handler = [handler extraData];
// get the extra references to add them later to the EO
refs = [handler extraRefCount];
[handler autorelease];
refs -= [fault retainCount];
if (refs > 0)
while (refs-- > 0)
// add up extra references to the EO
while (refs-- > 0) {
[aFault retain];
else
while (refs++ < 0)
[aFault release];
}
}
NSDebugFLLog(@"gsdb", @"STOP fault=%p", fault);
}
+ (EOFaultHandler *)handlerForFault:(id)fault
@ -403,18 +391,9 @@ static Class EOFaultClass = NULL;
- (void)dealloc
{
#ifdef DEBUG
NSDebugFLog(@"Dealloc EOFault %p. %@",
(void*)self,GSCurrentThread());
#endif
[EOFaultClass clearFault: self];
NSDebugMLog(@"EOFault dealloc self=%p",self);
if (![EOFaultClass isFault:self]) // otherwise, this loop.
[self dealloc];
#ifdef DEBUG
NSDebugFLog(@"Stop Dealloc EOFault %p. %@",
(void*)self,GSCurrentThread());
#endif
}
- (NSZone *)zone