* EOAccess/EOAdaptor.m:

o optimization in 'for' loops
* EOAccess/EODatabase.m:
  o include <EOCOntrol/EOPriv.h>
  o replaced isNilOrEONull() by _isNilOrEONull()
* EOAccess/EODatabaseContext.h:
  o added _snapshotForGlobalIDIMP
* EOAccess/EODatabaseContext.m:
  o commented  NSEmitTODO in
  -objectsForSourceGlobalID:relationshipName:editingContext:
  o added beter exception format in
  qualifierForLockingAttributes:primaryKeyAttributes:entity:snapshot:
  o fix compiler warning in -relayPrimaryKey:object:entity:
  o logs
  o optimizations in -objectsWithFetchSpecification:editingContext:
  o replaced isNilOrEONull() by _isNilOrEONull()
  o replace [EOFault isFault:] by _isFault()
  o use _snapshotForGlobalIDIMP
  o IMP usage optimization
* EOAccess/EOAttribute.[hm]:
  o added EOAdaptorUnknownType
  o added _adaptorValueType and avoid recomputing it each time
  o added _valueTypeChar to avoid string comparaisons
  o use EOPriv classes declarations
  o Temporary reverted David changes in
  -adaptorValueByConvertingAttributeValue
* EOAccess/EOAttributePriv.h:
  o added _valueTypeChar to avoid string comparaisons
* EOAccess/EOEntityPriv.h:
  o moved -attributeForPath: and -relationshipForPath: to
  EOEntityGDL2Additions category
* EOAccess/EOEntity.h:
  o moved private -attributeForPath: and -relationshipForPath: to
  EOEntityGDL2Additions category
* EOAccess/EOEntity.m:
  o better exception in classProperties
  o fix compiler warning in -setClassProperties:,
  -setPrimaryKeyAttributes:,
	-setAttributesUsedForLocking:
	o moved -attributeForPath: and -relationshipForPath: to
  EOEntityGDL2Additions category
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLExpression.m:
  o optimization in -tableListWithRootEntity:
  o optimization in -formatSQLString:format:
  o optimization in +sqlPatternFromShellPattern:
  o optimization in +sqlPatternFromShellPattern:withEscapeCharacter:
  o fix in -sqlStringForKeyValueQualifier:
  o added log in -sqlStringForKeyValueQualifier: for not handled
  readFormat
  o added log -addInsertListAttribute:value: for not handled
  writeFormat
  o added log -addUpdateListAttribute:value: for not handled
  writeFormat
  o changed  EOFLOGObjectFnStart to EOFLOGObjectFnStartCond
  o changed  EOFLOGObjectFnStop to EOFLOGObjectFnStopCond
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
* EOAccess/EOSQLQualifier.m:
  o implemented EOKeyComparisonQualifier
  -schemaBasedQualifierWithRootEntity
* EOAccess/EOUtilities.m:
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
* EOControl/EOPriv.[hm]:
  o added. Contains various classes/selectors/IMPs
* EOControl/EOClassDescription.m:
  o handle EONull case in -propagateDeleteForObject:editingContext:,
    -addObject:toPropertyWithKey:, -snapshot,
  -removeObject:fromPropertyWithKey:,
	_setObject:forBothSidesOfRelationshipWithKey:,
  addObject:toBothSidesOfRelationshipWithKey:,
	-removeObject:fromBothSidesOfRelationshipWithKey:
	o fix compiler warning in -dictionaryForInstanceProperties,
  -shallowCopy, -updateFromSnapshot:, -snapshot
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
  o replaced isNilOrEONull() by _isNilOrEONull()
  o fix in -validateForSave
  o rewritten -validateValue:forKey: selector build
* EOControl/EOEditingContext.h:
  o added -hasUnprocessedChanges
* EOControl/EOEditingContext.m:
  o added -hasUnprocessedChanges
  o added NS_DURING,... to catch exceptions
  o replace [EOFault isFault:] by _isFault()
  o IMP usage optimization
* EOControl/EOKeyGlobalID.m:
  o replaced isNilOrEONull() by _isNilOrEONull()
  o include <EOCOntrol/EOPriv.h>
* EOControl/EOGenericRecord.m:
  o partially rewritten -description
  o include <EOCOntrol/EOPriv.h>
  o replaced isNilOrEONull() by _isNilOrEONull()
  o replace [EOFault isFault:] by _isFault()
  o changed variable name type of
  _infoForInstanceVariableNamed:retType:retSize:retOffset:
  o rewritten valueForKey:,... to use cString NSKeyValueCoding
* EOControl/EOKeyValueCoding.m:
  o changed NSAssert in NSArray -valueForKey:
  o optimization in NSDictionary -takeValue:forKeyPath:isSmart:
  o optimization in NSDictionary -takeStoredValue:forKeyPath:
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
  o include <EOCOntrol/EOPriv.h>
* EOControl/EOKeyValueQualifier.m:
  o fixes for EONull/nil in -evaluateWithObject:
  o replaced [EONull null] by GDL2EONull
  o include <EOCOntrol/EOPriv.h>
* EOControl/EOSortOrdering.m:
  o include <EOCOntrol/EOPriv.h>
  o replaced [EONull null] by GDL2EONull
* EOAdaptors/Postgres95SQLExpression.m:
  o float formatting in +formatValue:forAttribute:
  o added -externalNameQuoteCharacter
  o added +sqlPatternFromShellPattern:
  o added +sqlPatternFromShellPattern:withEscapeCharacter:
  o replaced isNilOrEONull() by _isNilOrEONull()
* EOAdaptors/Postgres95Channel.m:
  o logs
* EOAdaptors/Postgres95Values.m:
  o logs
  o fix in +setPostgres95Format:
  o fix calendard format to handle timezone (%z)
  o optimizations
* EOControl/EOMutableKnownKeyDictionary.m
  o removed EOMKKDArrayMapping
  +dictionaryFromDictionary:subsetMapping:
  o include <EOCOntrol/EOPriv.h>
  o replaced isNilOrEONull() by _isNilOrEONull()
* EOControl/EONSAddOns.[hm]:
  o added NSString(ShellPattern)


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@20687 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2005-02-11 17:31:29 +00:00
parent 2cb429235f
commit 409de8d589
19 changed files with 2472 additions and 1225 deletions

File diff suppressed because it is too large Load diff

View file

@ -370,9 +370,17 @@ shouldContinueFetchingWithCurrentObjectCount: (unsigned)count
*/
@interface EOEditingContext (EOEditingContextInfo)
- (NSDictionary*)unprocessedObjects;
- (NSDictionary *)unprocessedInfo;
- (NSDictionary *)pendingInfo;
/** Returns YES if there unprocessed changes or deletes or inserts **/
- (BOOL)hasUnprocessedChanges;
@end
// Private
GDL2CONTROL_EXPORT id EOEditingContext_objectForGlobalIDWithImpPtr(EOEditingContext* edContext,IMP* impPtr,EOGlobalID* gid);
EOGlobalID* EOEditingContext_globalIDForObjectWithImpPtr(EOEditingContext* edContext,IMP* impPtr,id object);
GDL2CONTROL_EXPORT id EOEditingContext_recordObjectGlobalIDWithImpPtr(EOEditingContext* edContext,IMP* impPtr,id object,EOGlobalID* gid);
#endif

File diff suppressed because it is too large Load diff

View file

@ -54,6 +54,7 @@
@interface EOFault
{
@public
Class isa;
EOFaultHandler *_handler;
}

View file

@ -172,6 +172,7 @@ static Class EOFaultClass = NULL;
+ (BOOL)isFault: (id)object
{
//See also EOControl/EOPriv.h
// NSDebugFLLog(@"gsdb",@"object=%p",object);
if (object == nil)
@ -491,6 +492,10 @@ static Class EOFaultClass = NULL;
- (void)forwardInvocation: (NSInvocation *)invocation
{
NSDebugFLLog(@"gsdb",@"invocation selector=%@ target: %p",
NSStringFromSelector([invocation selector]),
[invocation target]);
if ([_handler shouldPerformInvocation: invocation])
[_handler completeInitializationOfObject: self];

View file

@ -44,6 +44,7 @@ RCS_ID("$Id$")
#include <Foundation/NSObjCRuntime.h>
#include <Foundation/NSDebug.h>
#include <Foundation/NSException.h>
#include <Foundation/NSInvocation.h>
#else
#include <Foundation/Foundation.h>
#endif
@ -234,6 +235,9 @@ BOOL __isGCEnabled(Class class_)
- (BOOL)shouldPerformInvocation: (NSInvocation *)invocation
{
NSDebugFLLog(@"gsdb",@"invocation selector=%@ target: %p",
NSStringFromSelector([invocation selector]),
[invocation target]);
return YES;
}

View file

@ -63,6 +63,7 @@ RCS_ID("$Id$")
#include <EOControl/EONull.h>
#include <EOControl/EOObserver.h>
#include <EOControl/EOFault.h>
#include <EOControl/EOPriv.h>
#include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOKeyValueCoding.h>
@ -109,8 +110,13 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
+ (void) initialize
{
if (self == [EOGenericRecord class] && !allGenericRecords)
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
allGenericRecords = NSCreateHashTable(NSNonOwnedPointerHashCallBacks,
1000);
allGenericRecordsLock = [GSLazyRecursiveLock new];
@ -201,7 +207,8 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
static const char _c_id[2] = { _C_ID, 0 };
//used to allow derived object implementation
- (BOOL)_infoForInstanceVariableNamed: (NSString*)name
- (BOOL)_infoForInstanceVariableNamed: (const char*)cStringName
stringName: (NSString*)stringName
retType: (const char**)type
retSize: (unsigned int*)size
retOffset: (int*)offset
@ -214,22 +221,24 @@ static const char _c_id[2] = { _C_ID, 0 };
retSize:size
retOffset:offset];
*/
ok = GSObjCFindVariable(self, [name cString], type, size, offset);
ok = GSObjCFindVariable(self, cStringName, type, size, offset);
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"Super InstanceVar named %@:%s",
name, (ok ? "YES" : "NO"));
@"Super InstanceVar named %s:%s",
cStringName, (ok ? "YES" : "NO"));
if (!ok)
{
NSString* name=(stringName ? stringName : GDL2StringWithCString(cStringName));
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"dictionary: %p eoMKKDInitializer: %p",
dictionary,
[dictionary eoMKKDInitializer]);
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"dictionary allkeys= %@",
[dictionary allKeys]);
if ([dictionary hasKey: name])
if (EOMKKD_hasKeyWithImpPtr(dictionary,NULL,name))
{
if (type)
*type = _c_id;
@ -262,24 +271,18 @@ static const char _c_id[2] = { _C_ID, 0 };
EOFLOGObjectFnStartCond(@"EOGenericRecordKVC");
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"Super InstanceVar named %@: offset=%u",
aKey, offset);
@"Super InstanceVar named %@: sel=%@ type=%s size=%u offset=%u",
aKey,NSStringFromSelector(sel),type,size,offset);
if (offset == UINT_MAX)
{
value = [dictionary objectForKey: aKey];
value = EOMKKD_objectForKeyWithImpPtr(dictionary,NULL,aKey);
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"value %p (class=%@)",
value, [value class]);
}
else
{
/* value=[super _getValueForKey:aKey
selector:sel
type:type
size:size
offset:offset];*/
value = GSObjCGetValue(self, aKey, sel, type, size, offset);
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"value %p (class=%@)",
value, [value class]);
@ -308,19 +311,11 @@ static const char _c_id[2] = { _C_ID, 0 };
if (offset == UINT_MAX)
{
if (anObject)
[dictionary setObject: anObject
forKey: aKey];
EOMKKD_setObjectForKeyWithImpPtr(dictionary,NULL,anObject,aKey);
else
[dictionary removeObjectForKey: aKey];
EOMKKD_removeObjectForKeyWithImpPtr(dictionary,NULL,aKey);
}
else
/* [super _setValueForKey:aKey
object:anObject
selector:sel
type:type
size:size
offset:offset];
*/
GSObjCSetValue(self, aKey, anObject, sel, type, size, offset);
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
@ -360,7 +355,7 @@ static const char _c_id[2] = { _C_ID, 0 };
forKey: key];
EOFLOGObjectFnStopOrCond(@"EOGenericRecord");
//
// if(value == nil || value == [EONull null])
// if(value == nil || value == GDL2EONull)
// [dictionary removeObjectForKey:key];
// else
// {
@ -419,20 +414,30 @@ static const char _c_id[2] = { _C_ID, 0 };
}
*/
inline BOOL infoForInstanceVariableWithImpPtr(id object,GDL2IMP_BOOL* impPtr,
const char* cStringName,NSString* stringName,
const char** type,unsigned int* size,
int* offset)
{
SEL sel=@selector(_infoForInstanceVariableNamed:stringName:retType:retSize:retOffset:);
if (!*impPtr)
*impPtr=(GDL2IMP_BOOL)[object methodForSelector:sel];
return (**impPtr)(object,sel,cStringName,stringName,type,size,offset);
};
- (id) storedValueForKey: (NSString*)aKey
{
SEL sel = 0;
const char *type = NULL;
unsigned size = 0;
unsigned off = 0;
NSString *name = nil;
NSString *cap = nil;
id value = nil;
Class selfClass=[self class];
EOFLOGObjectFnStartCond(@"EOGenericRecordKVC");
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"aKey=%@", aKey);
if ([[self class] useStoredAccessor] == NO)
if ([selfClass useStoredAccessor] == NO)
{
value = [self valueForKey: aKey];
}
@ -445,70 +450,116 @@ static const char _c_id[2] = { _C_ID, 0 };
[NSException raise: NSInvalidArgumentException
format: @"storedValueForKey: ... empty key"];
}
cap = [[aKey substringToIndex: 1] uppercaseString];
if (size > 1)
else
{
cap = [cap stringByAppendingString: [aKey substringFromIndex: 1]];
}
char buf[size+5];
char lo;
char hi;
GDL2IMP_BOOL rtsIMP=NULL;
GDL2IMP_BOOL infoVarIMP=NULL;
strcpy(buf, "_get");
[aKey getCString: &buf[4]];
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
name = [NSString stringWithFormat: @"_get%@", cap];
sel = NSSelectorFromString(name);
// test _getKey
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"A aKey=%@ Method [_getKey] name=%s",
aKey, buf);
sel = sel_get_any_uid(buf);
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
name = [NSString stringWithFormat: @"_%@", aKey];
sel = NSSelectorFromString(name);
if (sel == 0 || [self respondsToSelector: sel] == NO)
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
sel = 0;
}
}
// test _key
buf[3]='_';
buf[4]=lo;
if (sel == 0)
{
if ([[self class] accessInstanceVariablesDirectly] == YES)
{
name = [NSString stringWithFormat: @"_%@", aKey];
if ([self _infoForInstanceVariableNamed:name
retType: &type
retSize: &size
retOffset: &off]==NO)
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"B aKey=%@ Method [_key] name=%s",
aKey, &buf[3]);
sel = sel_get_any_uid(&buf[3]);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
name = aKey;
[self _infoForInstanceVariableNamed:name
retType: &type
retSize: &size
retOffset: &off];
sel = 0;
}
}
if (type == NULL)
if (sel == 0)
{
name = [NSString stringWithFormat: @"get%@", cap];
sel = NSSelectorFromString(name);
if (sel == 0 || [self respondsToSelector: sel] == NO)
if ([selfClass accessInstanceVariablesDirectly] == YES)
{
name = aKey;
sel = NSSelectorFromString(name);
// test _key
buf[3]='_';
buf[4]=lo;
if (sel == 0 || [self respondsToSelector: sel] == NO)
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"C aKey=%@ Instance [_key] name=%s",
aKey, &buf[3]);
/*if ([self _infoForInstanceVariableNamed:&buf[3]
stringName: nil
retType: &type
retSize: &size
retOffset: &off]==NO)*/
if (infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[3], // name
nil, // stringName
&type, // retType
&size, // retSize
&off)==NO) // retOffset
{
sel = 0;
// key
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"C aKey=%@ Instance [key] name=%s",
aKey, &buf[4]);
/*[self _infoForInstanceVariableNamed:&buf[4]
stringName: aKey
retType: &type
retSize: &size
retOffset: &off];*/
infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[4], // name
aKey, // stringName
&type, // retType
&size, // retSize
&off); // retOffset
}
}
if (type == NULL)
{
//test getKey
buf[3]='t';
buf[4]=hi;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"E aKey=%@ Method [getKey] name=%s",
aKey, &buf[1]);
sel = sel_get_any_uid(&buf[1]);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
// test key
buf[4]=lo;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"F aKey=%@ Method [key] name=%s",
aKey, &buf[4]);
sel = sel_get_any_uid(&buf[4]);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
sel = 0;
}
}
}
}
}
value = [self _getValueForKey: aKey
selector: sel
type: type
size: size
offset: off];
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"class=%@ aKey=%@ sel=%@ offset=%u",
selfClass, aKey, NSStringFromSelector(sel), off);
value = [self _getValueForKey: aKey
selector: sel
type: type
size: size
offset: off];
};
}
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"value=%@", value);
@ -524,14 +575,13 @@ static const char _c_id[2] = { _C_ID, 0 };
const char *type = NULL;
unsigned size = 0;
unsigned off = 0;
NSString *cap = nil;
NSString *name = nil;
Class selfClass=[self class];
EOFLOGObjectFnStartCond(@"EOGenericRecordKVC");
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"anObject=%@", anObject);
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"aKey=%@", aKey);
if ([[self class] useStoredAccessor] == NO)
if ([selfClass useStoredAccessor] == NO)
{
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"aKey=%@", aKey);
@ -547,72 +597,106 @@ static const char _c_id[2] = { _C_ID, 0 };
[NSException raise: NSInvalidArgumentException
format: @"takeStoredValue:forKey: ... empty key"];
}
cap = [[aKey substringToIndex: 1] uppercaseString];
if (size > 1)
else
{
cap = [cap stringByAppendingString: [aKey substringFromIndex: 1]];
}
name = [NSString stringWithFormat: @"_set%@:", cap];
type = NULL;
sel = NSSelectorFromString(name);
char buf[size+6];
char lo;
char hi;
GDL2IMP_BOOL rtsIMP=NULL;
GDL2IMP_BOOL infoVarIMP=NULL;
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
sel = 0;
strcpy(buf, "_set");
[aKey getCString: &buf[4]];
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
buf[size+4] = ':';
buf[size+5] = '\0';
if ([[self class] accessInstanceVariablesDirectly] == YES)
// test _setKey:
type = NULL;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"A aKey=%@ Method [_setKey] name=%s",
aKey, buf);
sel = sel_get_any_uid(buf);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
name = [NSString stringWithFormat: @"_%@", aKey];
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"aKey=%@ name=%@",
aKey, name);
if ([self _infoForInstanceVariableNamed: name
retType: &type
retSize: &size
retOffset: &off]==NO)
sel = 0;
if ([selfClass accessInstanceVariablesDirectly] == YES)
{
name = aKey;
// test _key
buf[3] = '_';
buf[4] = lo;
buf[size+4] = '\0';
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"aKey=%@ name=%@", aKey, name);
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"B aKey=%@ Instance [_key] name=%s",
aKey, &buf[3]);
/*if ([self _infoForInstanceVariableNamed:&buf[3]
stringName: nil
retType: &type
retSize: &size
retOffset: &off]==NO)
*/
if (infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[3], // name
nil, // stringName
&type, // retType
&size, // retSize
&off)==NO) // retOffset
{
// Test key
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"C aKey=%@ Instance [_key] name=%s", aKey, &buf[4]);
/*[self _infoForInstanceVariableNamed: &buf[4]
stringName: aKey
retType: &type
retSize: &size
retOffset: &off];*/
infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[4], // name
aKey, // stringName
&type, // retType
&size, // retSize
&off); // retOffset
}
}
if (type == NULL)
{
// Test setKey:
buf[3] = 't';
buf[4] = hi;
buf[size+4] = ':';
[self _infoForInstanceVariableNamed: name
retType: &type
retSize: &size
retOffset: &off];
}
}
if (type == NULL)
{
name = [NSString stringWithFormat: @"set%@:", cap];
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"aKey=%@ name=%@",
aKey, name);
sel = NSSelectorFromString(name);
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
sel = 0;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"D aKey=%@ Method [setKey:] name=%s",
aKey, &buf[1]);
sel = sel_get_any_uid(&buf[1]);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
sel = 0;
}
}
}
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"class=%@ aKey=%@ sel=%@ offset=%u",
selfClass, aKey, NSStringFromSelector(sel), off);
[self _setValueForKey: aKey
object: anObject
selector: sel
type: type
size: size
offset: off];
}
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"class=%@ aKey=%@ sel=%p offset=%u",
[self class], aKey, sel, off);
[self _setValueForKey: aKey
object: anObject
selector: sel
type: type
size: size
offset: off];
}
};
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
}
@ -632,11 +716,11 @@ static const char _c_id[2] = { _C_ID, 0 };
|| [[classDescription toOneRelationshipKeys] containsObject: aKey])
&& [classDescription inverseForRelationshipKey: aKey] != nil)
{
if (isNilOrEONull(anObject))
if (_isNilOrEONull(anObject))
{
id oldObj = [self valueForKey: aKey];
if (isNilOrEONull(oldObj))
if (_isNilOrEONull(oldObj))
{
if (!isToMany)
[self takeValue: anObject
@ -662,8 +746,6 @@ static const char _c_id[2] = { _C_ID, 0 };
const char *type;
unsigned size;
unsigned off=0;
NSString *cap;
NSString *name;
EOFLOGObjectFnStartCond(@"EOGenericRecordKVC");
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"anObject=%@", anObject);
@ -675,52 +757,91 @@ static const char _c_id[2] = { _C_ID, 0 };
[NSException raise: NSInvalidArgumentException
format: @"takeValue:forKey: ... empty key"];
}
cap = [[aKey substringToIndex: 1] uppercaseString];
if (size > 1)
else
{
cap = [cap stringByAppendingString: [aKey substringFromIndex: 1]];
}
char buf[size+6];
char lo;
char hi;
GDL2IMP_BOOL rtsIMP=NULL;
GDL2IMP_BOOL infoVarIMP=NULL;
name = [NSString stringWithFormat: @"set%@:", cap];
type = NULL;
sel = NSSelectorFromString(name);
strcpy(buf, "_set");
[aKey getCString: &buf[4]];
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
buf[size+4] = ':';
buf[size+5] = '\0';
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
name = [NSString stringWithFormat: @"_set%@:", cap];
sel = NSSelectorFromString(name);
type = NULL;
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
sel = 0;
//Try setKey:
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"A aKey=%@ Method [setKey:] name=%s",
aKey, &buf[1]);
sel = sel_get_any_uid(&buf[1]);
if ([[self class] accessInstanceVariablesDirectly] == YES)
{
name = [NSString stringWithFormat: @"_%@", aKey];
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
// Try _setKey:
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"B aKey=%@ Method [_setKey:] name=%s",
aKey, buf);
sel = sel_get_any_uid(buf);
if ([self _infoForInstanceVariableNamed: name
retType: &type
retSize: &size
retOffset: &off]==NO)
{
name = aKey;
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
sel = 0;
[self _infoForInstanceVariableNamed: name
retType: &type
retSize: &size
retOffset: &off];
}
}
}
}
if ([[self class] accessInstanceVariablesDirectly] == YES)
{
// test _key
buf[size+4] = '\0';
buf[3] = '_';
buf[4] = lo;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"C aKey=%@ Instance [_key] name=%s",
aKey, &buf[3]);
/*if ([self _infoForInstanceVariableNamed: &buf[3]
stringName: nil
retType: &type
retSize: &size
retOffset: &off]==NO)*/
if (infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[3], // name
nil, // stringName
&type, // retType
&size, // retSize
&off)==NO) // retOffset
{
// Test key
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"D aKey=%@ Instance [key] name=%s",
aKey, &buf[4]);
/*[self _infoForInstanceVariableNamed: &buf[4]
stringName: aKey
retType: &type
retSize: &size
retOffset: &off];*/
infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[4], // name
aKey, // stringName
&type, // retType
&size, // retSize
&off); // retOffset
}
}
}
}
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"aKey=%@ sel=%@ offset=%u",
aKey, NSStringFromSelector(sel), off);
[self _setValueForKey: aKey
object: anObject
selector: sel
type: type
size: size
offset: off];
[self _setValueForKey: aKey
object: anObject
selector: sel
type: type
size: size
offset: off];
};
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
}
@ -728,8 +849,6 @@ static const char _c_id[2] = { _C_ID, 0 };
- (id) valueForKey: (NSString*)aKey
{
SEL sel = 0;
NSString *cap;
NSString *name = nil;
const char *type = NULL;
unsigned size;
unsigned off = 0;
@ -744,63 +863,109 @@ static const char _c_id[2] = { _C_ID, 0 };
[NSException raise: NSInvalidArgumentException
format: @"valueForKey: ... empty key"];
}
cap = [[aKey substringToIndex: 1] uppercaseString];
if (size > 1)
else
{
cap = [cap stringByAppendingString: [aKey substringFromIndex: 1]];
}
char buf[size+5];
char lo;
char hi;
GDL2IMP_BOOL rtsIMP=NULL;
GDL2IMP_BOOL infoVarIMP=NULL;
name = [@"get" stringByAppendingString: cap];
sel = NSSelectorFromString(name);
strcpy(buf, "_get");
[aKey getCString: &buf[4]];
lo = buf[4];
hi = islower(lo) ? toupper(lo) : lo;
buf[4] = hi;
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
name = aKey;
sel = NSSelectorFromString(name);
// Test getKey
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"A aKey=%@ Method [getKey] name=%s",
aKey, &buf[1]);
sel = sel_get_any_uid(&buf[1]);
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
name = [@"_get" stringByAppendingString: cap];
sel = NSSelectorFromString(name);
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
name = [NSString stringWithFormat: @"_%@", aKey];
sel = NSSelectorFromString(name);
if (sel == 0 || [self respondsToSelector: sel] == NO)
{
sel = 0;
}
}
}
}
if (sel == 0 && [[self class] accessInstanceVariablesDirectly] == YES)
{
name = [NSString stringWithFormat: @"_%@", aKey];
if ([self _infoForInstanceVariableNamed: name
retType: &type
retSize: &size
retOffset: &off]==NO)
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
name = aKey;
//Test key
buf[4] = lo;
[self _infoForInstanceVariableNamed: name
retType: &type
retSize: &size
retOffset: &off];
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"B aKey=%@ Method [key] name=%s",
aKey, &buf[4]);
sel = sel_get_any_uid(&buf[4]);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
//Test _getKey
buf[4] = hi;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"C aKey=%@ Method [_getKey] name=%s",
aKey, buf);
sel = sel_get_any_uid(buf);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
// Test _key
buf[3] = '_';
buf[4] = lo;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"C aKey=%@ Method [_key] name=%s",
aKey, &buf[3]);
sel = sel_get_any_uid(&buf[3]);
if (sel == 0 || GDL2RespondsToSelectorWithImpPtr(self,&rtsIMP,sel) == NO)
{
sel = 0;
}
}
}
}
}
value = [self _getValueForKey: aKey
selector: sel
type: type
size: size
offset: off];
if (sel == 0 && [[self class] accessInstanceVariablesDirectly] == YES)
{
// Test _key
buf[3] = '_';
buf[4] = lo;
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"D aKey=%@ Instance [_key] name=%s",
aKey, &buf[3]);
/*if ([self _infoForInstanceVariableNamed: &buf[3]
stringName: nil
retType: &type
retSize: &size
retOffset: &off]==NO)*/
if (infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[3], // name
nil, // stringName
&type, // retType
&size, // retSize
&off)==NO) // retOffset
{
// Test key
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"E aKey=%@ Instance [key] name=%s",
aKey, &buf[4]);
/*[self _infoForInstanceVariableNamed: &buf[4]
stringName: aKey
retType: &type
retSize: &size
retOffset: &off];*/
infoForInstanceVariableWithImpPtr(self,&infoVarIMP,
&buf[4], // name
aKey, // stringName
&type, // retType
&size, // retSize
&off); // retOffset
}
}
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"aKey=%@ sel=%@ offset=%u",
aKey, NSStringFromSelector(sel), off);
value = [self _getValueForKey: aKey
selector: sel
type: type
size: size
offset: off];
};
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"value: %p (class=%@)",
value, [value class]);
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
@ -847,7 +1012,7 @@ static const char _c_id[2] = { _C_ID, 0 };
[dictionary setObject: value
forKey: key];
else
// [dictionary setObject: [EONull null]
// [dictionary setObject: GDL2EONull
// forKey: key];
[dictionary removeObjectForKey: key];
@ -867,6 +1032,7 @@ infinite loop in description **/
NSMutableDictionary *dict;
NSString *key = nil;
id obj = nil;
IMP ofkIMP=NULL;
toManyKeys = [classDescription toManyRelationshipKeys];
toOneKeys = [classDescription toOneRelationshipKeys];
@ -874,8 +1040,7 @@ infinite loop in description **/
while ((key = [enumerator nextObject]))
{
obj = [dictionary objectForKey: key];
obj = EOMKKD_objectForKeyWithImpPtr(dictionary,&ofkIMP,key);
if (!obj)
[dict setObject: @"(null)"
forKey: key];
@ -906,6 +1071,7 @@ infinite loop in description **/
NSMutableDictionary *dict;
NSString *key = nil;
id obj = nil;
IMP ofkIMP=NULL;
toManyKeys = [classDescription toManyRelationshipKeys];
toOneKeys = [classDescription toOneRelationshipKeys];
@ -914,64 +1080,63 @@ infinite loop in description **/
while ((key = [enumerator nextObject]))
{
obj = [dictionary objectForKey: key];
obj = EOMKKD_objectForKeyWithImpPtr(dictionary,&ofkIMP,key);
if (!obj)
[dict setObject: @"(null)"
forKey: key];
else if (_isFault(obj) == YES)
{
[dict setObject: [obj description]
forKey: key];
}
else if (obj==GDL2EONull)
[dict setObject: @"(null)"
forKey: key];
else
{
if ([toManyKeys containsObject: key] == NO
&& [toOneKeys containsObject: key] == NO)
if ([toManyKeys containsObject: key] != NO)
{
[dict setObject: obj
NSEnumerator *toManyEnum;
NSMutableArray *array;
id rel;
array = [NSMutableArray arrayWithCapacity: 8];
toManyEnum = [obj objectEnumerator];
while ((rel = [toManyEnum nextObject]))
{
NSString* relDescr=nil;
// Avoid infinit loop
if ([rel respondsToSelector: @selector(_shortDescription)])
relDescr=[rel _shortDescription];
else
relDescr=[rel description];
[array addObject:
[NSString
stringWithFormat: @"<%@ %p>",
relDescr, NSStringFromClass([rel class])]];
}
[dict setObject: [NSString stringWithFormat:
@"<%p %@ : %@>",
obj, [obj class], array]
forKey: key];
}
else if ([toOneKeys containsObject: key] != NO)
{
[dict setObject: [NSString
stringWithFormat: @"<%p %@: classDescription=%@>",
obj,
NSStringFromClass([obj class]),
[(EOGenericRecord *)obj classDescription]]
forKey: key];
}
else
{
if ([EOFault isFault: obj] == YES)
{
[dict setObject: [obj description]
forKey: key];
}
else if ([toManyKeys containsObject: key] == YES)
{
NSEnumerator *toManyEnum;
NSMutableArray *array;
id rel;
array = [NSMutableArray arrayWithCapacity: 8];
toManyEnum = [obj objectEnumerator];
while ((rel = [toManyEnum nextObject]))
{
NSString* relDescr;
// Avoid infinit loop
if ([rel respondsToSelector: @selector(_shortDescription)])
relDescr=[rel _shortDescription];
else
relDescr=[rel description];
[array addObject:
[NSString
stringWithFormat: @"<%@ %p>",
relDescr, NSStringFromClass([rel class])]];
}
[dict setObject: [NSString stringWithFormat:
@"<%p %@ : %@>",
obj, [obj class], array]
forKey: key];
}
else
{
[dict setObject: [NSString
stringWithFormat: @"<%p %@: classDescription=%@>",
obj,
NSStringFromClass([obj class]),
[(EOGenericRecord *)obj classDescription]]
forKey: key];
}
[dict setObject: obj
forKey: key];
}
}
}
@ -1026,7 +1191,7 @@ You can override this to exclude properties manually handled by derived object *
while ((record = (EOGenericRecord*)NSNextHashEnumeratorItem(&hashEnum)))
{
if ([EOFault isFault:record])
if (_isFault(record))
[EOFault eoCalculateSizeWith: dict
forFault: record];
else
@ -1114,12 +1279,12 @@ You can override this to exclude properties manually handled by derived object *
id value = [self valueForKey: propKey];
//NSDebugMLog(@"propKey=%@", propKey);
//NSDebugMLog(@"value isFault=%s", ([EOFault isFault:value] ? "YES" : "NO"));
//NSDebugMLog(@"value isFault=%s", (_isFault(value) ? "YES" : "NO"));
//NSDebugMLog(@"value=%p class=%@", value, [value class]);
if (value)
{
if ([EOFault isFault:value])
if (_isFault(value))
size += [EOFault eoCalculateSizeWith: dict
forFault: value];
else if ([value respondsToSelector: @selector(eoCalculateSizeWith:)])

View file

@ -53,10 +53,20 @@ RCS_ID("$Id$")
#include <EOControl/EOKeyGlobalID.h>
#include <EOControl/EODebug.h>
#include <EOControl/EONull.h>
#include <EOControl/EOPriv.h>
@implementation EOKeyGlobalID
+ (void) initialize
{
static BOOL initialized=NO;
if (!initialized)
{
GDL2PrivInit();
};
};
+ (id)globalIDWithEntityName: (NSString *)entityName
keys: (id *)keys
keyCount: (unsigned)count
@ -229,7 +239,7 @@ RCS_ID("$Id$")
BOOL areNulls = YES;
for (i = 0; areNulls && i < _keyCount; i++)
areNulls = isNilOrEONull(_keyValues[i]);
areNulls = _isNilOrEONull(_keyValues[i]);
return areNulls;
}

View file

@ -68,27 +68,27 @@ RCS_ID("$Id$")
#include <EOControl/EONSAddOns.h>
#include <EOControl/EODebug.h>
#include <EOControl/EONull.h>
#include <EOControl/EOPriv.h>
#include <GNUstepBase/GSObjCRuntime.h>
static EONull *null = nil;
static SEL oaiSel;
static BOOL strictWO;
static BOOL initialized=NO;
static inline void
initialize(void)
{
if (null == nil)
if (!initialized)
{
oaiSel = @selector(objectAtIndex:);
initialized=YES;
strictWO = GSUseStrictWO451Compatibility(nil);
null = [EONull null];
GDL2PrivInit();
}
}
/* This macro is only used locally in defined places so for the sake
of efficiency, we don't use the do {} while (0) pattern. */
#define INITIALIZE if (null == nil) initialize();
#define INITIALIZE if (!initialized) initialize();
@implementation NSObject (_EOKeyValueCodingCompatibility)
@ -217,7 +217,9 @@ initialize(void)
selStr = [NSString stringWithFormat: @"compute%@ForKey:",
[[key substringWithRange: r] initialCapitalizedString]];
sel = NSSelectorFromString(selStr);
NSAssert1(sel!=NULL, @"Invalid computational key %@", selStr);
NSAssert2(sel!=NULL,@"Invalid computational key: '%@' Selector: '%@'",
key,
selStr);
result = [self performSelector: sel
withObject: attrStr];
@ -226,7 +228,7 @@ initialize(void)
{
result = [self resultsOfPerformingSelector: @selector(valueForKey:)
withObject: key
defaultResult: null];
defaultResult: GDL2EONull];
}
EOFLOGObjectFnStopCond(@"EOKVC");
@ -302,26 +304,30 @@ initialize(void)
*/
- (id)computeSumForKey: (NSString *)key
{
NSDecimalNumber *ret;
NSDecimalNumber *ret=nil;
NSDecimal result, left, right;
NSRoundingMode mode;
unsigned int i, count;
IMP oai;
unsigned int count;
INITIALIZE;
EOFLOGObjectFnStartCond(@"EOKVC");
mode = [[NSDecimalNumber defaultBehavior] roundingMode];
oai = [self methodForSelector: oaiSel];
count = [self count];
NSDecimalFromComponents(&result, 0, 0, NO);
for (i=0; i<count; i++)
if (count>0)
{
left = result;
right = [[(*oai)(self, oaiSel, i) valueForKey: key] decimalValue];
NSDecimalAdd(&result, &left, &right, mode);
}
unsigned int i=0;
IMP oaiIMP = [self methodForSelector: GDL2_objectAtIndexSEL];
for (i=0; i<count; i++)
{
left = result;
right = [[GDL2ObjectAtIndexWithImp(self,oaiIMP,i) valueForKey: key] decimalValue];
NSDecimalAdd(&result, &left, &right, mode);
}
};
ret = [NSDecimalNumber decimalNumberWithDecimal: result];
EOFLOGObjectFnStopCond(@"EOKVC");
@ -336,26 +342,30 @@ initialize(void)
*/
- (id)computeAvgForKey: (NSString *)key
{
NSDecimalNumber *ret;
NSDecimalNumber *ret = nil;
NSDecimal result, left, right;
NSRoundingMode mode;
unsigned int i, count;
IMP oai;
unsigned int count = 0;
INITIALIZE;
EOFLOGObjectFnStartCond(@"EOKVC");
mode = [[NSDecimalNumber defaultBehavior] roundingMode];
oai = [self methodForSelector: oaiSel];
count = [self count];
NSDecimalFromComponents(&result, 0, 0, NO);
for (i=0; i<count; i++)
if (count>0)
{
left = result;
right = [[(*oai)(self, oaiSel, i) valueForKey: key] decimalValue];
NSDecimalAdd(&result, &left, &right, mode);
}
unsigned int i=0;
IMP oaiIMP = [self methodForSelector: GDL2_objectAtIndexSEL];
for (i=0; i<count; i++)
{
left = result;
right = [[GDL2ObjectAtIndexWithImp(self,oaiIMP,i) valueForKey: key] decimalValue];
NSDecimalAdd(&result, &left, &right, mode);
}
};
left = result;
NSDecimalFromComponents(&right, (unsigned long long) count, 0, NO);
@ -380,33 +390,34 @@ initialize(void)
- (id)computeMaxForKey: (NSString *)key
{
id result, resultVal;
unsigned int i, count;;
id result=nil;
id resultVal=nil;
unsigned int count=0;
INITIALIZE;
EOFLOGObjectFnStartCond(@"EOKVC");
result = nil;
resultVal = nil;
count = [self count];
if (count > 0)
{
id current,currentVal;
IMP oai;
unsigned int i=0;
id current = nil;
id currentVal = nil;
IMP oaiIMP = [self methodForSelector: GDL2_objectAtIndexSEL];
oai = [self methodForSelector: oaiSel];
for(i=0; i<count && (resultVal == nil || resultVal == null); i++)
for(i=0; i<count && (resultVal == nil || resultVal == GDL2EONull); i++)
{
result = (*oai)(self, oaiSel, i);
result = GDL2ObjectAtIndexWithImp(self,oaiIMP,i);
resultVal = [result valueForKey: key];
}
for (; i<count; i++)
{
current = (*oai)(self, oaiSel, i);
current = GDL2ObjectAtIndexWithImp(self,oaiIMP,i);
currentVal = [current valueForKey: key];
if (currentVal == nil || currentVal == null) continue;
if (currentVal == nil || currentVal == GDL2EONull)
continue;
if ([(NSObject *)resultVal compare: currentVal] == NSOrderedAscending)
{
@ -422,33 +433,33 @@ initialize(void)
- (id)computeMinForKey: (NSString *)key
{
id result, resultVal;
unsigned int i, count;
id result=nil;
id resultVal=nil;
unsigned int count = 0;
INITIALIZE;
EOFLOGObjectFnStartCond(@"EOKVC");
result = nil;
resultVal = nil;
count = [self count];
if (count > 0)
{
id current, currentVal;
IMP oai;
id current=nil;
id currentVal=nil;
unsigned int i = 0;
IMP oaiIMP = [self methodForSelector: GDL2_objectAtIndexSEL];
oai = [self methodForSelector: oaiSel];
for(i=0; i<count && (resultVal == nil || resultVal == null); i++)
for(i=0; i<count && (resultVal == nil || resultVal == GDL2EONull); i++)
{
result = (*oai)(self, oaiSel, i);
result = GDL2ObjectAtIndexWithImp(self,oaiIMP,i);
resultVal = [result valueForKey: key];
}
for (; i<count; i++)
{
current = (*oai)(self, oaiSel, i);
current = GDL2ObjectAtIndexWithImp(self,oaiIMP,i);
currentVal = [current valueForKey: key];
if (currentVal == nil || currentVal == null) continue;
if (currentVal == nil || currentVal == GDL2EONull) continue;
if ([(NSObject *)resultVal compare: currentVal] == NSOrderedDescending)
{
@ -839,9 +850,11 @@ initialize(void)
mutableCopy] autorelease];
NSMutableString *key = [NSMutableString string];
int keyPathArrayCount=[keyPathArray count];
//EOFLOGObjectLevelArgs(@"EOKVC", @"keyPathArray=%@", keyPathArray);
while ([keyPathArray count] > 0)
while (keyPathArrayCount > 0)
{
id tmpKey;
@ -851,6 +864,7 @@ initialize(void)
//EOFLOGObjectLevelArgs(@"EOKVC", @"tmpKey=%@", tmpKey);
[keyPathArray removeObjectAtIndex: 0];
keyPathArrayCount--;
if ([key length] > 0)
[key appendString: @"."];
@ -872,7 +886,7 @@ initialize(void)
//EOFLOGObjectLevelArgs(@"EOKVC",@"left keyPathArray=\"%@\"",
// keyPathArray);
if ([keyPathArray count] > 0)
if (keyPathArrayCount > 0)
{
id obj = [self objectForKey: key];
@ -937,9 +951,11 @@ initialize(void)
mutableCopy] autorelease];
NSMutableString *key = [NSMutableString string];
int keyPathArrayCount=[keyPathArray count];
//EOFLOGObjectLevelArgs(@"EOKVC", @"keyPathArray=%@", keyPathArray);
while ([keyPathArray count] > 0)
while (keyPathArrayCount > 0)
{
id tmpKey;
@ -949,6 +965,7 @@ initialize(void)
//EOFLOGObjectLevelArgs(@"EOKVC", @"tmpKey=%@", tmpKey);
[keyPathArray removeObjectAtIndex: 0];
keyPathArrayCount--;
if ([key length] > 0)
[key appendString: @"."];
@ -969,7 +986,7 @@ initialize(void)
//EOFLOGObjectLevelArgs(@"EOKVC",@"left keyPathArray=\"%@\"",
// keyPathArray);
if ([keyPathArray count] > 0)
if (keyPathArrayCount > 0)
{
id obj = [self objectForKey: key];
@ -1055,7 +1072,7 @@ initialize(void)
if (val == nil)
{
val = null;
val = GDL2EONull;
}
[newKeyPaths addObject: keyPath];
@ -1173,7 +1190,7 @@ initialize(void)
NS_ENDHANDLER;
if (val == nil)
val = null;
val = GDL2EONull;
[newKeyPaths addObject: keyPath];
[newVals addObject: val];

View file

@ -61,6 +61,7 @@ RCS_ID("$Id$")
#include <EOControl/EOEditingContext.h>
#include <EOControl/EONull.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
/*
This declaration is needed by the compiler to state that
@ -81,10 +82,16 @@ RCS_ID("$Id$")
@end
@implementation EOKeyValueQualifier
static EONull *null = nil;
+ (void)initialize
{
null = [EONull null];
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
};
}
/**
@ -121,7 +128,7 @@ static EONull *null = nil;
ASSIGNCOPY(_key, key);
if (value == nil)
{
value = null;
value = GDL2EONull;
}
ASSIGN(_value, value);
}
@ -200,59 +207,99 @@ static EONull *null = nil;
*/
- (BOOL) evaluateWithObject: (id)object
{
NSObject *val;
NSObject *objectValue;
NSObject *selfValue=_value;
BOOL (*imp)(id, SEL, id);
val = [object valueForKey: _key];
objectValue = [object valueForKey: _key];
if (val == nil)
if (objectValue == nil)
{
val = null;
objectValue = GDL2EONull;
}
if (selfValue == nil)
{
selfValue = GDL2EONull;
}
imp = (BOOL (*)(id, SEL, id))[val methodForSelector: _selector];
imp = (BOOL (*)(id, SEL, id))[objectValue methodForSelector: _selector];
if (imp != NULL)
{
return (*imp) (val, _selector, _value);
return (*imp) (objectValue, _selector, selfValue);
}
if (sel_eq(_selector, EOQualifierOperatorEqual) == YES)
{
return [val isEqual: _value];
return [objectValue isEqual: selfValue];
}
else if (sel_eq(_selector, EOQualifierOperatorNotEqual) == YES)
{
return ([val isEqual: _value]?NO:YES);
return ([objectValue isEqual: selfValue]?NO:YES);
}
else if (sel_eq(_selector, EOQualifierOperatorLessThan) == YES)
{
return [val compare: _value] == NSOrderedAscending;
if (objectValue==GDL2EONull)
return ((selfValue==GDL2EONull) ? NO : YES);
else if (selfValue==GDL2EONull)
return NO;
else
return [objectValue compare: selfValue] == NSOrderedAscending;
}
else if (sel_eq(_selector, EOQualifierOperatorGreaterThan) == YES)
{
return [val compare: _value] == NSOrderedDescending;
if (objectValue==GDL2EONull)
return NO;
else if (selfValue==GDL2EONull)
return YES;
else
return [objectValue compare: selfValue] == NSOrderedDescending;
}
else if (sel_eq(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES)
{
return [val compare: _value] != NSOrderedDescending;
if (objectValue==GDL2EONull)
return YES;
else if (selfValue==GDL2EONull)
return NO;
else
return [objectValue compare: selfValue] != NSOrderedDescending;
}
else if (sel_eq(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES)
{
return [val compare: _value] != NSOrderedAscending;
if (objectValue==GDL2EONull)
return ((selfValue==GDL2EONull) ? YES : NO);
else if (selfValue==GDL2EONull)
return YES;
else
return [objectValue compare: selfValue] != NSOrderedAscending;
}
else if (sel_eq(_selector, EOQualifierOperatorContains) == YES)
{
return [(id)val rangeOfString: _value].location != NSNotFound;
//Philosophical question: does nil contains nil ??
if (objectValue==GDL2EONull) // Let's say nil does contain nothing (even not nil)
return NO;
else if (selfValue==GDL2EONull) // Let's say nil is contained by nothing
return NO;
else
return [(NSString*)objectValue rangeOfString:
(NSString*)selfValue].location != NSNotFound;
}
else if (sel_eq(_selector, EOQualifierOperatorLike) == YES)
{
NSEmitTODO(); //TODO
return [val isEqual: _value] == NSOrderedSame;
//How to handle nil like ?
return [objectValue isEqual: selfValue];
}
else if (sel_eq(_selector, EOQualifierOperatorCaseInsensitiveLike) == YES)
{
NSEmitTODO(); //TODO
return [[(id)val uppercaseString] isEqual: [_value uppercaseString]]
== NSOrderedSame;
//How to handle nil like ?
if (objectValue==GDL2EONull)
return ((selfValue==GDL2EONull) ? YES : NO);
else if (selfValue==GDL2EONull)
return NO;
else
return [(id)objectValue caseInsensitiveCompare:
(NSString*)selfValue] == NSOrderedSame;
}
/*Ayers (09-02-2002): Maybe we should raise instead of returning NO.*/
return NO;

View file

@ -171,4 +171,13 @@
@end
/** mkkkd can be a NSMutableKnownKey or another kind of dictionary **/
GDL2CONTROL_EXPORT id EOMKKD_objectForKeyWithImpPtr(NSDictionary* mkkd,IMP* impPtr,NSString* key);
GDL2CONTROL_EXPORT void EOMKKD_setObjectForKeyWithImpPtr(NSDictionary* mkkd,IMP* impPtr,id anObject,NSString* key);
GDL2CONTROL_EXPORT void EOMKKD_removeObjectForKeyWithImpPtr(NSDictionary* mkkd,IMP* impPtr,NSString* key);
GDL2CONTROL_EXPORT BOOL EOMKKD_hasKeyWithImpPtr(NSDictionary* mkkd,GDL2IMP_BOOL* impPtr,NSString* key);
GDL2CONTROL_EXPORT unsigned int EOMKKD_indexForKeyWithImpPtr(EOMutableKnownKeyDictionary* mkkd,GDL2IMP_UINT* impPtr,NSString* key);
GDL2CONTROL_EXPORT unsigned int EOMKKDInitializer_indexForKeyWithImpPtr(EOMKKDInitializer* mkkdInit,GDL2IMP_UINT* impPtr,NSString* key);
#endif

View file

@ -53,6 +53,7 @@ RCS_ID("$Id$")
#include <GNUstepBase/GSCategories.h>
#endif
#include <EOControl/EOPriv.h>
#include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOControl/EODebug.h>
#include <EOControl/EONull.h>
@ -60,6 +61,16 @@ RCS_ID("$Id$")
@implementation EOMKKDInitializer
+ (void)initialize
{
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
}
}
+ (EOMKKDInitializer*)initializerFromKeyArray: (NSArray*)keys
{
EOMKKDInitializer *initializer = [[self newWithKeyArray: keys] autorelease];
@ -236,15 +247,14 @@ RCS_ID("$Id$")
- (BOOL)hasKey: (id)key
{
return ([self indexForKey: key] != NSNotFound);
return (EOMKKDInitializer_indexForKeyWithImpPtr(self,NULL,key) != NSNotFound);
}
- (EOMKKDArrayMapping*) arrayMappingForKeys: (NSArray*)keys
{
int selfKeyCount = [keys count];
int keyCount = [keys count];
EOMKKDArrayMapping *arrayMapping;
int i;
EOMKKDArrayMapping *arrayMapping = nil;
NSAssert(keyCount <= selfKeyCount, @"key count greater than our key count");
@ -252,13 +262,21 @@ RCS_ID("$Id$")
destinationDescription: self
zone: [self zone]] autorelease];
for (i = 0; i < keyCount; i++)
if (keyCount>0)
{
NSString *key = [keys objectAtIndex: i];
int destinationIndex = [self indexForKey:key];
int i=0;
GDL2IMP_UINT indexForKeyIMP=NULL;
IMP objectAtIndexIMP=[keys methodForSelector:GDL2_objectAtIndexSEL];
arrayMapping->_destinationOffsetForArrayIndex[i] = destinationIndex + 1;
}
for (i = 0; i < keyCount; i++)
{
NSString *key = GDL2AddObjectWithImp(keys,objectAtIndexIMP,i);
int destinationIndex = EOMKKDInitializer_indexForKeyWithImpPtr(self,&indexForKeyIMP,key);
arrayMapping->_destinationOffsetForArrayIndex[i] = destinationIndex + 1;
}
};
return arrayMapping;
}
@ -269,8 +287,7 @@ RCS_ID("$Id$")
{
unsigned int selfKeyCount = [self count];
unsigned int keyCount = [destinationKeys count];
EOMKKDSubsetMapping *subsetMapping;
int i;
EOMKKDSubsetMapping *subsetMapping = nil;
NSAssert([sourceKeys count] == keyCount, @"Source and destination keys count are different");
NSAssert(keyCount <= selfKeyCount, @"key count greater than our key count");
@ -285,38 +302,55 @@ RCS_ID("$Id$")
EOFLOGObjectLevelArgs(@"EOMKKD", @"sourceKeys=%@", sourceKeys);
EOFLOGObjectLevelArgs(@"EOMKKD", @"destinationKeys=%@", destinationKeys);
for (i = 0; i < keyCount; i++)
{
NSString *sourceKey;
NSString *destinationKey;
int destinationIndex;
int sourceIndex;
if (keyCount>0)
{
int i;
GDL2IMP_UINT selfIndexForKeyIMP=NULL;
GDL2IMP_UINT sourceInitializerIndexForKeyIMP=NULL;
IMP sourceObjectAtIndexIMP=[sourceKeys methodForSelector:GDL2_objectAtIndexSEL];
IMP destinationObjectAtIndexIMP=[destinationKeys methodForSelector:GDL2_objectAtIndexSEL];
sourceKey = [sourceKeys objectAtIndex: i];
EOFLOGObjectLevelArgs(@"EOMKKD", @"sourceKey=%@", sourceKey);
destinationKey = [destinationKeys objectAtIndex: i];
EOFLOGObjectLevelArgs(@"EOMKKD", @"destinationKey=%@", destinationKey);
destinationIndex = [self indexForKey: destinationKey];
EOFLOGObjectLevelArgs(@"EOMKKD", @"destinationIndex=%d",
destinationIndex);
sourceIndex = [sourceInitializer indexForKey: sourceKey];
EOFLOGObjectLevelArgs(@"EOMKKD", @"sourceIndex=%d", sourceIndex);
NSAssert2(destinationIndex != NSNotFound,
@"Destination Key %@ not found in %@",
destinationKey,
self);
NSAssert2(sourceIndex != NSNotFound,
@"Source Key %@ not found in %@",
sourceKey,
sourceInitializer);
subsetMapping->_sourceOffsetForDestinationOffset[destinationIndex]
= sourceIndex + 1;
}
for (i = 0; i < keyCount; i++)
{
NSString *sourceKey = nil;
NSString *destinationKey = nil;
int destinationIndex = 0;
int sourceIndex = 0;
sourceKey =
GDL2AddObjectWithImp(sourceKeys,sourceObjectAtIndexIMP,i);
EOFLOGObjectLevelArgs(@"EOMKKD", @"sourceKey=%@", sourceKey);
destinationKey =
GDL2AddObjectWithImp(destinationKeys,destinationObjectAtIndexIMP,i);
EOFLOGObjectLevelArgs(@"EOMKKD", @"destinationKey=%@", destinationKey);
destinationIndex =
EOMKKDInitializer_indexForKeyWithImpPtr(self,
&selfIndexForKeyIMP,
destinationKey);
EOFLOGObjectLevelArgs(@"EOMKKD", @"destinationIndex=%d",
destinationIndex);
sourceIndex =
EOMKKDInitializer_indexForKeyWithImpPtr(sourceInitializer,
&sourceInitializerIndexForKeyIMP,
sourceKey);
EOFLOGObjectLevelArgs(@"EOMKKD", @"sourceIndex=%d", sourceIndex);
NSAssert2(destinationIndex != NSNotFound,
@"Destination Key %@ not found in %@",
destinationKey,
self);
NSAssert2(sourceIndex != NSNotFound,
@"Source Key %@ not found in %@",
sourceKey,
sourceInitializer);
subsetMapping->_sourceOffsetForDestinationOffset[destinationIndex]
= sourceIndex + 1;
}
};
return subsetMapping;
}
@ -329,22 +363,28 @@ RCS_ID("$Id$")
sourceDescription: sourceInitializer
destinationDescription: self
zone: [self zone]] autorelease];
int i;
for (i = 0; i < keyCount; i++)
if (keyCount>0)
{
NSString *key;
int index;
key = _keys[i];
EOFLOGObjectLevelArgs(@"EOMKKD", @"key=%@", key);
index = [sourceInitializer indexForKey: key];
EOFLOGObjectLevelArgs(@"EOMKKD", @"index=%d", index);
subsetMapping->_sourceOffsetForDestinationOffset[i]
= (index == NSNotFound ? 0 : index + 1);
}
int i=0;
GDL2IMP_UINT indexForKeyIMP=NULL;
for (i = 0; i < keyCount; i++)
{
NSString *key;
int index;
key = _keys[i];
EOFLOGObjectLevelArgs(@"EOMKKD", @"key=%@", key);
index = EOMKKDInitializer_indexForKeyWithImpPtr(sourceInitializer,
&indexForKeyIMP,key);
EOFLOGObjectLevelArgs(@"EOMKKD", @"index=%d", index);
subsetMapping->_sourceOffsetForDestinationOffset[i]
= (index == NSNotFound ? 0 : index + 1);
}
};
return subsetMapping;
}
@ -485,16 +525,6 @@ RCS_ID("$Id$")
@implementation EOMKKDArrayMapping
+ (id)dictionaryFromDictionary: (NSDictionary *)dict
subsetMapping: (EOMKKDSubsetMapping *)subsetMapping
{
#warning (stephane@sente.ch) Method is really not implemented!
#warning (Ayers 28-03-2003) Either remove this method from array or use EOMutableKnownKeyDictionary instead of self
return [[self newDictionaryFromDictionary: dict
subsetMapping: subsetMapping
zone: NULL] autorelease];
}
+ (id)newInstanceWithKeyCount: (unsigned int)keyCount
destinationDescription: (EOMKKDInitializer*)destination
zone: (NSZone*)zone
@ -536,6 +566,16 @@ RCS_ID("$Id$")
@implementation EOMutableKnownKeyDictionary
+ (void)initialize
{
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
}
}
+ (id)dictionaryFromDictionary: (NSDictionary *)dict
subsetMapping: (EOMKKDSubsetMapping *)subsetMapping
{
@ -803,7 +843,7 @@ RCS_ID("$Id$")
// EOFLOGObjectFnStart();
NSAssert(_MKKDInitializer, @"No _MKKDInitializer");
index = [_MKKDInitializer indexForKey: key];
index = EOMKKDInitializer_indexForKeyWithImpPtr(_MKKDInitializer,NULL,key);
// EOFLOGObjectLevelArgs(@"EOMKKD", @"index=%d", index);
@ -832,7 +872,7 @@ RCS_ID("$Id$")
NSAssert(_MKKDInitializer, @"No _MKKDInitializer");
index = [_MKKDInitializer indexForKey: key];
index = EOMKKDInitializer_indexForKeyWithImpPtr(_MKKDInitializer,NULL,key);
if (index == NSNotFound)
{
@ -857,7 +897,7 @@ RCS_ID("$Id$")
NSAssert(_MKKDInitializer, @"No _MKKDInitializer");
index = [_MKKDInitializer indexForKey: key];
index = EOMKKDInitializer_indexForKeyWithImpPtr(_MKKDInitializer,NULL,key);
if (index == NSNotFound)
{
@ -883,9 +923,9 @@ RCS_ID("$Id$")
{
if (_values[i] != object)
{
if (isNilOrEONull(_values[i]))
result =! isNilOrEONull(object);
else if (isNilOrEONull(object))
if (_isNilOrEONull(_values[i]))
result =! _isNilOrEONull(object);
else if (_isNilOrEONull(object))
result = YES;
else
result = ![_values[i] isEqual: object];
@ -900,11 +940,12 @@ RCS_ID("$Id$")
- (void)addEntriesFromDictionary: (NSDictionary*)dictionary
{
NSEnumerator *e = [dictionary keyEnumerator];
id key;
id key=nil;
IMP indexForKeyIMP=NULL;
while ((key = [e nextObject]))
{
if (![self objectForKey: key]) //Don't overwrite already present values ?
if (!EOMKKD_objectForKeyWithImpPtr(self,&indexForKeyIMP,key)) //Don't overwrite already present values ?
{
[self setObject: [dictionary objectForKey: key]
forKey: key];
@ -965,3 +1006,137 @@ RCS_ID("$Id$")
}
@end
id EOMKKD_objectForKeyWithImpPtr(NSDictionary* mkkd,IMP* impPtr,NSString* key)
{
if (mkkd)
{
IMP imp=NULL;
if (impPtr)
imp=*impPtr;
if (!imp)
{
if (GSObjCClass(mkkd)==GDL2MKKDClass
&& GDL2MKKD_objectForKeyIMP)
imp=GDL2MKKD_objectForKeyIMP;
else
imp=[mkkd methodForSelector:GDL2_objectForKeySEL];
if (impPtr)
*impPtr=imp;
}
return (*imp)(mkkd,GDL2_objectForKeySEL,key);
}
else
return nil;
};
void EOMKKD_setObjectForKeyWithImpPtr(NSDictionary* mkkd,IMP* impPtr,id anObject,NSString* key)
{
if (mkkd)
{
IMP imp=NULL;
if (impPtr)
imp=*impPtr;
if (!imp)
{
if (GSObjCClass(mkkd)==GDL2MKKDClass
&& GDL2MKKD_setObjectForKeyIMP)
imp=GDL2MKKD_setObjectForKeyIMP;
else
imp=[mkkd methodForSelector:GDL2_setObjectForKeySEL];
if (impPtr)
*impPtr=imp;
}
(*imp)(mkkd,GDL2_setObjectForKeySEL,anObject,key);
};
};
void EOMKKD_removeObjectForKeyWithImpPtr(NSDictionary* mkkd,IMP* impPtr,NSString* key)
{
if (mkkd)
{
IMP imp=NULL;
if (impPtr)
imp=*impPtr;
if (!imp)
{
if (GSObjCClass(mkkd)==GDL2MKKDClass
&& GDL2MKKD_removeObjectForKeyIMP)
imp=GDL2MKKD_removeObjectForKeyIMP;
else
imp=[mkkd methodForSelector:GDL2_removeObjectForKeySEL];
if (impPtr)
*impPtr=imp;
}
(*imp)(mkkd,GDL2_removeObjectForKeySEL,key);
};
};
BOOL EOMKKD_hasKeyWithImpPtr(NSDictionary* mkkd,GDL2IMP_BOOL* impPtr,NSString* key)
{
if (mkkd)
{
GDL2IMP_BOOL imp=NULL;
if (impPtr)
imp=*impPtr;
if (!imp)
{
if (GSObjCClass(mkkd)==GDL2MKKDClass
&& GDL2MKKD_hasKeyIMP)
imp=GDL2MKKD_hasKeyIMP;
else
imp=(GDL2IMP_BOOL)[mkkd methodForSelector:GDL2_hasKeySEL];
if (impPtr)
*impPtr=imp;
}
return (*imp)(mkkd,GDL2_hasKeySEL,key);
}
else
return NO;
};
unsigned int EOMKKD_indexForKeyWithImpPtr(EOMutableKnownKeyDictionary* mkkd,GDL2IMP_UINT* impPtr,NSString* key)
{
if (mkkd)
{
GDL2IMP_UINT imp=NULL;
if (impPtr)
imp=*impPtr;
if (!imp)
{
if (GSObjCClass(mkkd)==GDL2MKKDClass
&& GDL2MKKD_indexForKeyIMP)
imp=GDL2MKKD_indexForKeyIMP;
else
imp=(GDL2IMP_UINT)[mkkd methodForSelector:GDL2_indexForKeySEL];
if (impPtr)
*impPtr=imp;
}
return (*imp)(mkkd,GDL2_indexForKeySEL,key);
}
else
return 0;
};
unsigned int EOMKKDInitializer_indexForKeyWithImpPtr(EOMKKDInitializer* mkkdInit,GDL2IMP_UINT* impPtr,NSString* key)
{
if (mkkdInit)
{
GDL2IMP_UINT imp=NULL;
if (impPtr)
imp=*impPtr;
if (!imp)
{
if (GSObjCClass(mkkdInit)==GDL2EOMKKDInitializerClass
&& GDL2EOMKKDInitializer_indexForKeyIMP)
imp=GDL2EOMKKDInitializer_indexForKeyIMP;
else
imp=(GDL2IMP_UINT)[mkkdInit methodForSelector:GDL2_indexForKeySEL];
if (impPtr)
*impPtr=imp;
}
return (*imp)(mkkdInit,GDL2_indexForKeySEL,key);
}
else
return 0;
};

View file

@ -1,7 +1,7 @@
/* -*-objc-*-
EONSAddOns.h
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000-2005 Free Software Foundation, Inc.
Author: Manuel Guesdon <mguesdon@orange-concept.com>
Date: October 2000
@ -118,6 +118,12 @@ GDL2_ActivateAllGDL2Categories(void);
-(unsigned long long)unsignedLongLongValue;
@end
@interface NSString (ShellPattern)
/** returns YES is string contain shell pattern characters,
NO otherwise **/
- (BOOL)hasShellPatternCharacter;
@end
@interface NSObject (PerformSelect3)
/**
* Causes the receiver to execute the method implementation corresponding

View file

@ -59,6 +59,7 @@ RCS_ID("$Id$")
#include <EOControl/EONSAddOns.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
#include <limits.h>
@ -147,6 +148,16 @@ GDL2_ActivateAllGDL2Categories(void)
}
@implementation NSString (ShellPattern)
/** returns YES is string contain shell pattern characters,
NO otherwise **/
- (BOOL)hasShellPatternCharacter
{
NSRange r=[self rangeOfCharacterFromSet:GDL2_shellPatternCharacterSet];
return (r.length>0 ? YES : NO);
};
@end
@implementation NSObject (NSObjectPerformingSelector)
@ -190,7 +201,7 @@ GDL2_ActivateAllGDL2Categories(void)
object,
sel_get_name(sel));
[results addObject: result];
[results addObject: result]; //TODO What to do if nil ??
}
}
NS_HANDLER

View file

@ -50,5 +50,6 @@
GDL2CONTROL_EXPORT BOOL isNilOrEONull(id v);
#endif /* __EONull_h__ */

164
EOControl/EOPriv.h Normal file
View file

@ -0,0 +1,164 @@
/* -*-objc-*-
EOPriv.h
Copyright (C) 2005 Free Software Foundation, Inc.
Author: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 2005
This file is part of the GNUstep Database Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __EOPriv_h__
#define __EOPriv_h__
#include <EOControl/EODefines.h>
@class NSNumber;
@class EONull;
typedef unsigned int (*GDL2IMP_UINT)(id, SEL, ...);
typedef BOOL (*GDL2IMP_BOOL)(id, SEL, ...);
GDL2CONTROL_EXPORT Class GDL2NSStringClass;
GDL2CONTROL_EXPORT Class GDL2NSNumberClass;
GDL2CONTROL_EXPORT Class GDL2NSDecimalNumberClass;
GDL2CONTROL_EXPORT Class GDL2NSCalendarDateClass;
GDL2CONTROL_EXPORT Class GDL2NSDateClass;
GDL2CONTROL_EXPORT Class GDL2NSAutoreleasePoolClass;
GDL2CONTROL_EXPORT Class GDL2NSDataClass;
GDL2CONTROL_EXPORT Class GDL2EOFaultClass;
GDL2CONTROL_EXPORT Class GDL2MKKDClass;
GDL2CONTROL_EXPORT Class GDL2EOMKKDInitializerClass;
GDL2CONTROL_EXPORT Class GDL2EODatabaseContextClass;
GDL2CONTROL_EXPORT Class GDL2EOEditingContextClass;
GDL2CONTROL_EXPORT Class GDL2EOAttributeClass;
GDL2CONTROL_EXPORT SEL GDL2_newSEL;
GDL2CONTROL_EXPORT SEL GDL2_allocWithZoneSEL;
GDL2CONTROL_EXPORT SEL GDL2_isEqualToStringSEL;
GDL2CONTROL_EXPORT SEL GDL2_appendStringSEL;
GDL2CONTROL_EXPORT SEL GDL2_stringWithCString_lengthSEL;
GDL2CONTROL_EXPORT SEL GDL2_stringWithCStringSEL;
GDL2CONTROL_EXPORT SEL GDL2_addObjectSEL;
GDL2CONTROL_EXPORT SEL GDL2_objectAtIndexSEL;
GDL2CONTROL_EXPORT SEL GDL2_indexOfObjectIdenticalToSEL;
GDL2CONTROL_EXPORT SEL GDL2_nextObjectSEL;
GDL2CONTROL_EXPORT SEL GDL2_takeStoredValueForKeySEL;
GDL2CONTROL_EXPORT SEL GDL2_snapshotForGlobalIDSEL;
GDL2CONTROL_EXPORT SEL GDL2_objectForKeySEL;
GDL2CONTROL_EXPORT SEL GDL2_setObjectForKeySEL;
GDL2CONTROL_EXPORT SEL GDL2_removeObjectForKeySEL;
GDL2CONTROL_EXPORT SEL GDL2_respondsToSelectorSEL;
GDL2CONTROL_EXPORT SEL GDL2_hasKeySEL;
GDL2CONTROL_EXPORT SEL GDL2_indexForKeySEL;
GDL2CONTROL_EXPORT SEL GDL2_snapshotForGlobalIDSEL;
GDL2CONTROL_EXPORT SEL GDL2_recordObjectGlobalIDSEL;
GDL2CONTROL_EXPORT SEL GDL2_objectForGlobalIDSEL;
GDL2CONTROL_EXPORT SEL GDL2_globalIDForObjectSEL;
GDL2CONTROL_EXPORT IMP GDL2NSAutoreleasePool_newIMP;
GDL2CONTROL_EXPORT IMP GDL2NSNumber_allocWithZoneIMP;
GDL2CONTROL_EXPORT IMP GDL2NSDecimalNumber_allocWithZoneIMP;
GDL2CONTROL_EXPORT IMP GDL2NSString_allocWithZoneIMP;
GDL2CONTROL_EXPORT IMP GDL2NSCalendarDate_allocWithZoneIMP;
GDL2CONTROL_EXPORT IMP GDL2NSData_allocWithZoneIMP;
GDL2CONTROL_EXPORT IMP GDL2NSString_stringWithCString_lengthIMP;
GDL2CONTROL_EXPORT IMP GDL2NSString_stringWithCStringIMP;
GDL2CONTROL_EXPORT IMP GDL2MKKD_objectForKeyIMP;
GDL2CONTROL_EXPORT IMP GDL2MKKD_setObjectForKeyIMP;
GDL2CONTROL_EXPORT IMP GDL2MKKD_removeObjectForKeyIMP;
GDL2CONTROL_EXPORT GDL2IMP_BOOL GDL2MKKD_hasKeyIMP;
GDL2CONTROL_EXPORT GDL2IMP_UINT GDL2MKKD_indexForKeyIMP;
GDL2CONTROL_EXPORT GDL2IMP_UINT GDL2EOMKKDInitializer_indexForKeyIMP;
GDL2CONTROL_EXPORT IMP GDL2EODatabaseContext_snapshotForGlobalIDIMP;
GDL2CONTROL_EXPORT IMP GDL2EOEditingContext_recordObjectGlobalIDIMP;
GDL2CONTROL_EXPORT IMP GDL2EOEditingContext_objectForGlobalIDIMP;
GDL2CONTROL_EXPORT IMP GDL2EOEditingContext_globalIDForObjectIMP;
GDL2CONTROL_EXPORT NSNumber* GDL2NSNumberBool_Yes;
GDL2CONTROL_EXPORT NSNumber* GDL2NSNumberBool_No;
GDL2CONTROL_EXPORT EONull* GDL2EONull;
GDL2CONTROL_EXPORT NSCharacterSet* GDL2_shellPatternCharacterSet;
GDL2CONTROL_EXPORT void GDL2PrivInit();
#define _isNilOrEONull(v) \
(isNilOrEONull(v))
// (((v)==nil || (v)==GDL2EONull) ? YES : NO)
//See also EOControl/EOFault.m
#define _isFault(v) \
(((v)==nil) ? NO : ((((EOFault*)(v))->isa == GDL2EOFaultClass) ? YES : NO))
#define GDL2AppendStringWithImp(string,methodIMP,aString) \
(*(methodIMP))((string),GDL2_appendStringSEL,(aString))
#define GDL2AddObjectWithImp(array,methodIMP,anObject) \
(*(methodIMP))((array),GDL2_addObjectSEL,(anObject))
#define GDL2ObjectAtIndexWithImp(array,methodIMP,index) \
(*(methodIMP))((array),GDL2_objectAtIndexSEL,(index))
#define GDL2IndexOfObjectIdenticalToWithImp(array,methodIMP,anObject) \
(*(methodIMP))((array),GDL2_indexOfObjectIdenticalToSEL,(anObject))
#define GDL2NextObjectWithImp(enumerator,methodIMP) \
(*(methodIMP))((array),GDL2_nextObjectSEL)
#define GDL2TakeStoredValueForKeyWithImp(object,methodIMP,value,key) \
(*methodIMP)((object),GDL2_takeStoredValueForKeySEL,value,key)
#define GDL2StringWithCStringAndLength(cString,length) \
(*GDL2NSString_stringWithCString_lengthIMP)(GDL2NSStringClass,GDL2_stringWithCString_lengthSEL,(const char*)(cString),(int)(length))
#define GDL2StringWithCString(cString) \
(*GDL2NSString_stringWithCStringIMP)(GDL2NSStringClass,GDL2_stringWithCStringSEL,(const char*)(cString))
#define GDL2NSAutoreleasePool_new() \
(*GDL2NSAutoreleasePool_newIMP)(GDL2NSAutoreleasePoolClass,GDL2_newSEL)
#define GDL2NSString_alloc() \
(*GDL2NSString_allocWithZoneIMP)(GDL2NSStringClass,GDL2_allocWithZoneSEL,NULL)
#define GDL2NSDecimalNumber_alloc() \
(*GDL2NSDecimalNumber_allocWithZoneIMP)(GDL2NSDecimalNumberClass,GDL2_allocWithZoneSEL,NULL)
#define GDL2NSNumber_alloc() \
(*GDL2NSNumber_allocWithZoneIMP)(GDL2NSNumberClass,GDL2_allocWithZoneSEL,NULL)
#define GDL2NSCalendarDate_alloc() \
(*GDL2NSCalendarDate_allocWithZoneIMP)(GDL2NSCalendarDateClass,GDL2_allocWithZoneSEL,NULL)
#define GDL2NSData_alloc() \
(*GDL2NSData_allocWithZoneIMP)(GDL2NSDataClass,GDL2_allocWithZoneSEL,NULL)
static inline BOOL GDL2RespondsToSelectorWithImpPtr(id object,GDL2IMP_BOOL* impPtr,SEL sel)
{
if (!*impPtr)
*impPtr=(GDL2IMP_BOOL)[object methodForSelector:GDL2_respondsToSelectorSEL];
return (**impPtr)(object,GDL2_respondsToSelectorSEL,sel);
};
#endif /* __EOPriv_h__ */

202
EOControl/EOPriv.m Normal file
View file

@ -0,0 +1,202 @@
/**
EOPriv.m <title>EOPriv: various definitions</title>
Copyright (C) 2005 Free Software Foundation, Inc.
Date: Jan 2005
$Revision$
$Date$
<abstract></abstract>
This file is part of the GNUstep Database Library.
<license>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
</license>
**/
#include "config.h"
RCS_ID("$Id$")
#include <Foundation/Foundation.h>
#ifndef GNUSTEP
#include <GNUstepBase/GNUstep.h>
#include <GNUstepBase/GSCategories.h>
#endif
#include <EOControl/EOPriv.h>
#include <EOControl/EOFault.h>
#include <EOControl/EOMutableKnownKeyDictionary.h>
#include <EOAccess/EODatabaseContext.h>
Class GDL2NSStringClass=Nil;
Class GDL2NSNumberClass=Nil;
Class GDL2NSDecimalNumberClass=Nil;
Class GDL2NSCalendarDateClass=Nil;
Class GDL2NSDateClass=Nil;
Class GDL2NSAutoreleasePoolClass=Nil;
Class GDL2NSDataClass=Nil;
Class GDL2EOFaultClass=Nil;
Class GDL2MKKDClass=Nil;
Class GDL2EOMKKDInitializerClass=Nil;
Class GDL2EODatabaseContextClass=Nil;
Class GDL2EOEditingContextClass=Nil;
Class GDL2EOAttributeClass=Nil;
SEL GDL2_newSEL=NULL;
SEL GDL2_allocWithZoneSEL=NULL;
SEL GDL2_isEqualToStringSEL=NULL;
SEL GDL2_appendStringSEL=NULL;
SEL GDL2_stringWithCString_lengthSEL=NULL;
SEL GDL2_stringWithCStringSEL=NULL;
SEL GDL2_addObjectSEL=NULL;
SEL GDL2_objectAtIndexSEL=NULL;
SEL GDL2_indexOfObjectIdenticalToSEL=NULL;
SEL GDL2_nextObjectSEL=NULL;
SEL GDL2_takeStoredValueForKeySEL=NULL;
SEL GDL2_snapshotForGlobalIDSEL=NULL;
SEL GDL2_objectForKeySEL=NULL;
SEL GDL2_respondsToSelectorSEL=NULL;
SEL GDL2_setObjectForKeySEL=NULL;
SEL GDL2_removeObjectForKeySEL=NULL;
SEL GDL2_hasKeySEL=NULL;
SEL GDL2_indexForKeySEL=NULL;
SEL GDL2_recordObjectGlobalIDSEL=NULL;
SEL GDL2_objectForGlobalIDSEL=NULL;
SEL GDL2_globalIDForObjectSEL=NULL;
IMP GDL2NSAutoreleasePool_newIMP=NULL;
IMP GDL2NSNumber_allocWithZoneIMP=NULL;
IMP GDL2NSDecimalNumber_allocWithZoneIMP=NULL;
IMP GDL2NSString_allocWithZoneIMP=NULL;
IMP GDL2NSCalendarDate_allocWithZoneIMP=NULL;
IMP GDL2NSData_allocWithZoneIMP=NULL;
IMP GDL2NSString_stringWithCString_lengthIMP=NULL;
IMP GDL2NSString_stringWithCStringIMP=NULL;
IMP GDL2MKKD_objectForKeyIMP=NULL;
IMP GDL2MKKD_setObjectForKeyIMP=NULL;
IMP GDL2MKKD_removeObjectForKeyIMP=NULL;
GDL2IMP_BOOL GDL2MKKD_hasKeyIMP=NULL;
GDL2IMP_UINT GDL2MKKD_indexForKeyIMP=NULL;
GDL2IMP_UINT GDL2EOMKKDInitializer_indexForKeyIMP=NULL;
IMP GDL2EODatabaseContext_snapshotForGlobalIDIMP=NULL;
IMP GDL2EOEditingContext_recordObjectGlobalIDIMP=NULL;
IMP GDL2EOEditingContext_objectForGlobalIDIMP=NULL;
IMP GDL2EOEditingContext_globalIDForObjectIMP=NULL;
NSNumber* GDL2NSNumberBool_Yes=nil;
NSNumber* GDL2NSNumberBool_No=nil;
EONull* GDL2EONull=nil;
NSCharacterSet* GDL2_shellPatternCharacterSet=nil;
void GDL2PrivInit()
{
static BOOL initialized=NO;
if (!initialized)
{
GDL2NSStringClass=[NSString class];
GDL2NSNumberClass=[NSNumber class];
GDL2NSDecimalNumberClass=[NSDecimalNumber class];
GDL2NSCalendarDateClass=[NSCalendarDate class];
GDL2NSDateClass = [NSDate class];
GDL2NSAutoreleasePoolClass = [NSAutoreleasePool class];
GDL2NSDataClass = [NSData class];
GDL2EOFaultClass = [EOFault class];
GDL2MKKDClass = [EOMutableKnownKeyDictionary class];
GDL2EOMKKDInitializerClass = [EOMKKDInitializer class];
GDL2EODatabaseContextClass = [EODatabaseContext class];
GDL2EOEditingContextClass = [EOEditingContext class];
GDL2EOAttributeClass = [EOAttribute class];
GDL2_newSEL=@selector(new);
GDL2_allocWithZoneSEL=@selector(alloc);
GDL2_isEqualToStringSEL=@selector(isEqualToString:);
GDL2_appendStringSEL=@selector(appendString:);
GDL2_stringWithCString_lengthSEL=@selector(stringWithCString:length:);
GDL2_stringWithCStringSEL=@selector(stringWithCString:);
GDL2_addObjectSEL=@selector(addObject:);
GDL2_objectAtIndexSEL=@selector(objectAtIndex:);
GDL2_indexOfObjectIdenticalToSEL=@selector(indexOfObjectIdenticalTo:);
GDL2_nextObjectSEL=@selector(nextObject);
GDL2_takeStoredValueForKeySEL=@selector(takeStoredValue:forKey:);
GDL2_snapshotForGlobalIDSEL=@selector(snapshotForGlobalID:);
GDL2_objectForKeySEL=@selector(objectForKey:);
GDL2_setObjectForKeySEL=@selector(setObject:forKey:);
GDL2_removeObjectForKeySEL=@selector(removeObjectForKey:);
GDL2_respondsToSelectorSEL=@selector(respondsToSelector:);
GDL2_hasKeySEL=@selector(hasKey:);
GDL2_indexForKeySEL=@selector(indexForKey:);
GDL2_snapshotForGlobalIDSEL=@selector(snapshotForGlobalID:);
GDL2_recordObjectGlobalIDSEL=@selector(recordObject:globalID:);
GDL2_objectForGlobalIDSEL=@selector(objectForGlobalID:);
GDL2_globalIDForObjectSEL=@selector(globalIDForObject:);
GDL2NSAutoreleasePool_newIMP=[GDL2NSAutoreleasePoolClass
methodForSelector:GDL2_newSEL];
GDL2NSNumber_allocWithZoneIMP=[GDL2NSNumberClass
methodForSelector:GDL2_allocWithZoneSEL];
GDL2NSDecimalNumber_allocWithZoneIMP=[GDL2NSDecimalNumberClass
methodForSelector:GDL2_allocWithZoneSEL];
GDL2NSString_allocWithZoneIMP=[GDL2NSStringClass
methodForSelector:GDL2_allocWithZoneSEL];
GDL2NSCalendarDate_allocWithZoneIMP=[GDL2NSCalendarDateClass
methodForSelector:GDL2_allocWithZoneSEL];
GDL2NSData_allocWithZoneIMP=[GDL2NSDataClass
methodForSelector:GDL2_allocWithZoneSEL];
GDL2NSString_stringWithCString_lengthIMP=
[GDL2NSStringClass methodForSelector:GDL2_stringWithCString_lengthSEL];
GDL2NSString_stringWithCStringIMP=
[GDL2NSStringClass methodForSelector:GDL2_stringWithCStringSEL];
GDL2MKKD_objectForKeyIMP=[GDL2MKKDClass instanceMethodForSelector:GDL2_objectForKeySEL];
GDL2MKKD_setObjectForKeyIMP=[GDL2MKKDClass instanceMethodForSelector:GDL2_setObjectForKeySEL];
GDL2MKKD_removeObjectForKeyIMP=[GDL2MKKDClass instanceMethodForSelector:GDL2_removeObjectForKeySEL];
GDL2MKKD_hasKeyIMP=(GDL2IMP_BOOL)[GDL2MKKDClass instanceMethodForSelector:GDL2_hasKeySEL];
GDL2MKKD_indexForKeyIMP=(GDL2IMP_UINT)[GDL2MKKDClass instanceMethodForSelector:GDL2_indexForKeySEL];
GDL2EOMKKDInitializer_indexForKeyIMP=(GDL2IMP_UINT)[GDL2EOMKKDInitializerClass instanceMethodForSelector:GDL2_indexForKeySEL];
GDL2EODatabaseContext_snapshotForGlobalIDIMP=[GDL2EODatabaseContextClass instanceMethodForSelector:GDL2_snapshotForGlobalIDSEL];
GDL2EOEditingContext_recordObjectGlobalIDIMP==[GDL2EOEditingContextClass instanceMethodForSelector:GDL2_recordObjectGlobalIDSEL];
GDL2EOEditingContext_objectForGlobalIDIMP=[GDL2EOEditingContextClass instanceMethodForSelector:GDL2_objectForGlobalIDSEL];
GDL2EOEditingContext_globalIDForObjectIMP=[GDL2EOEditingContextClass instanceMethodForSelector:GDL2_globalIDForObjectSEL];
ASSIGN(GDL2NSNumberBool_Yes,[GDL2NSNumberClass numberWithBool:YES]);
ASSIGN(GDL2NSNumberBool_No,[GDL2NSNumberClass numberWithBool:NO]);
ASSIGN(GDL2EONull,[EONull null]);
ASSIGN(GDL2_shellPatternCharacterSet,([NSCharacterSet characterSetWithCharactersInString:@"*?%_"]));
};
}

View file

@ -52,9 +52,21 @@ RCS_ID("$Id$")
#include <EOControl/EOKeyValueCoding.h>
#include <EOControl/EOKeyValueArchiver.h>
#include <EOControl/EODebug.h>
#include <EOControl/EOPriv.h>
@implementation EOSortOrdering
+ (void)initialize
{
static BOOL initialized=NO;
if (!initialized)
{
initialized=YES;
GDL2PrivInit();
};
};
/**
* Returns an autoreleased EOSortOrdering initilaized with key and selector.
* The selector should take an id as an argument and return an
@ -176,17 +188,11 @@ compareUsingSortOrderings(id left,
id right,
void* vpSortOrders)
{
static EONull *null = nil;
NSArray *sortOrders = (NSArray *)vpSortOrders;
NSComparisonResult r = NSOrderedSame;
unsigned int i;
unsigned int sortOrdCnt = [sortOrders count];
if (null == nil)
{
null = [EONull null];
}
/* Loop over all sort orderings until we have an ordering difference. */
for (i=0; (r == NSOrderedSame) && (i < sortOrdCnt); i++)
{
@ -199,15 +205,15 @@ compareUsingSortOrderings(id left,
NSComparisonResult (*imp)(id, SEL, id);
/* Use EONull instead of nil. */
leftVal = (leftVal != nil)?(leftVal) :(null);
rightVal = (rightVal != nil)?(rightVal):(null);
leftVal = (leftVal != nil)?(leftVal) :(GDL2EONull);
rightVal = (rightVal != nil)?(rightVal):(GDL2EONull);
/* Insure that EONull is not the parameter for
comparisons with other classes. */
if (rightVal == null)
if (rightVal == GDL2EONull)
{
rightVal = leftVal;
leftVal = null;
leftVal = GDL2EONull;
inverted = YES;
}

View file

@ -65,7 +65,8 @@ EOMutableKnownKeyDictionary.m \
EONSAddOns.m \
EOCheapArray.m \
EOArrayDataSource.m \
EODebug.m
EODebug.m \
EOPriv.m
libgnustep-db2control_HEADER_FILES_DIR = .
libgnustep-db2control_HEADER_FILES_INSTALL_DIR = /EOControl
@ -94,7 +95,7 @@ EONSAddOns.h \
EODefines.h \
EODeprecated.h \
EOControl.h \
EOPriv.h
DOCUMENT_NAME = EOControl
EOControl_AUTOGSDOC_HEADERS = $(libgnustep-db2control_HEADER_FILES)