OSX fixes.

Addes eoutil.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@15870 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mirko 2003-02-04 15:17:07 +00:00
parent 3e49f9b7a5
commit e062f22178
21 changed files with 268 additions and 78 deletions

View file

@ -1,3 +1,60 @@
2003-02-04 Stephane Corthesy <stephane@sente.ch>
* Tools/eoutil.m: implemented.
* EOAndQualifier.m: replaced autorelease by AUTORELEASE
* EOClassDescription.m: added #include <gnustep/base/objc-gnu2next.h>
and note about subclassing NSClassDescription
* EOEditingContext.m: removed EOAccess inclusion; note that we need to
rewrite -faultForRawRow:entityNamed:editingContext: to break dependency
to EOAccess
* EOFault.m: implemented +doesNotRecognizeSelector:
* EOFaultHandler.m: added #include <objc/objc-class.h> and #include
<objc/Protocol.h>
* EOFetchSpecification.m: added #import <Foundation/NSDictionary.h>
* EOGenericRecord.h: declaration of -valueForKey: and
-takeValue:forKey: needs to be done only when !FOUNDATION_HAS_KVC
* EOGenericRecord.m: removed #import <EOAccess/EOEntity.h> and #import
<EOAccess/EORelationship.h>; added #include <objc/objc-class.h>;
declared +eoCalculateSizeWith:forArray:; corrected +initialize (doesn't
return a value); renamed +removeDestoyedObject: to
+removeDestroyedObject:; modified
-initWithEditingContext:classDescription:globalID: to no longer depend
on EOAccess via EOEntity; some methods need to be implemented only when
!FOUNDATION_HAS_KVC (else they are already correctly implemented in
NSObject), some others only when FOUNDATION_HAS_KVC
(-handleQueryWithUnboundKey: and handleTakeValue:forUnboundKey:); in
-smartTakeValue:forKey:, removed dependency to EOAccess via
EORelationship; corrected problem with macro NSDebugMLog, which should
be replaced by other macro anyway; modified -eoCalculateSizeWith: to no
longer depend on EOAccess via EOEntity
* EOGlobalID.m: added #include <stdio.h> and #include <string.h>; added
cast in +assignGloballyUniqueBytes:
* EOKeyComparisonQualifier.m: added casts
* EOKeyGlobalID.m: replaced retain by RETAIN
* EOKeyValueCoding.h: removed #import
<EOControl/EOKeyValueCodingBase.h>; added - (id)storedValueForKeyPath:
(NSString *)key; declared some methods only when !FOUNDATION_HAS_KVC;
declared hidden methods for MacOS X.
* EOKeyValueCoding.m: added #include <ctype.h>; implemented some
methods only when !FOUNDATION_HAS_KVC; corrected problem with macros
NSDebugMLog/NSWarnLog, which should be replaced by other macro anyway;
declared -[NSMutableDictionary(EOKeyValueCodingPrivate)
takeValue:forKeyPath:isSmart:]; corrected zombie in
-[NSMutableDictionary(EOKeyValueCoding) takeValue:forKeyPath:isSmart:]
* EOKeyValueQualifier: added casts
* EOMutableKnownKeyDictionary.m: added #warning about missing method;
moved method implementation to avoid warning
* EONSAddOns.m: added casts
* EOObjectStoreCoordinator.m: corrected problem with macro NSDebugMLog,
which should be replaced by other macro anyway
* EOQualifier.m: added #include <gnustep/base/GSObjCRuntime.h>;
corrected problem with macro NSDebugLog, which should be replaced by
other macro anyway; replaced retain by RETAIN; in -doesContain:, no
need to test against NSMutableArray class
* EOSortOrdering.m: replaced retain by RETAIN; avoid autoreleased
objects; replaced mutableCopy by initWithArray:copyItems:
2003-02-03 Stephane Corthesy <stephane@sente.ch> 2003-02-03 Stephane Corthesy <stephane@sente.ch>
* Postgres95Adaptor.m: made some changes to externalTypeNames (needs * Postgres95Adaptor.m: made some changes to externalTypeNames (needs

View file

@ -51,7 +51,7 @@ RCS_ID("$Id$")
+ (EOQualifier *)qualifierWithQualifierArray: (NSArray *)array + (EOQualifier *)qualifierWithQualifierArray: (NSArray *)array
{ {
return [[[self alloc] initWithQualifierArray: array] autorelease]; return AUTORELEASE([[self alloc] initWithQualifierArray: array]);
} }
+ (EOQualifier *)qualifierWithQualifiers: (EOQualifier *)qualifiers, ... + (EOQualifier *)qualifierWithQualifiers: (EOQualifier *)qualifiers, ...
@ -70,7 +70,7 @@ RCS_ID("$Id$")
va_end(ap); va_end(ap);
return [[[self alloc] initWithQualifierArray: qualArray] autorelease]; return AUTORELEASE([[self alloc] initWithQualifierArray: qualArray]);
} }
- (id) initWithQualifiers: (EOQualifier *)qualifiers, ... - (id) initWithQualifiers: (EOQualifier *)qualifiers, ...

View file

@ -47,8 +47,12 @@ RCS_ID("$Id$")
#import <EOControl/EOCheapArray.h> #import <EOControl/EOCheapArray.h>
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
#include <gnustep/base/objc-gnu2next.h>
//?? #define NOT_FOUND_CLASS_DESCRIPTION ([NSObject class]) //we use NSObject class as a "not found" value******* //?? #define NOT_FOUND_CLASS_DESCRIPTION ([NSObject class]) //we use NSObject class as a "not found" value*******
// NOTE: (stephane@sente.ch) Should we subclass NSClassDescription?
@implementation EOClassDescription @implementation EOClassDescription

View file

@ -48,7 +48,8 @@ RCS_ID("$Id$")
#import <EOControl/EONSAddOns.h> #import <EOControl/EONSAddOns.h>
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
#import <EOAccess/EOEntity.h>
@class EOEntityClassDescription;
@implementation EOEditingContext @implementation EOEditingContext
@ -2487,6 +2488,7 @@ modified state of the object.**/
classDesc = (id)[EOClassDescription classDescriptionForEntityName: classDesc = (id)[EOClassDescription classDescriptionForEntityName:
entityName]; entityName];
#warning (stephane@sente.ch) ERROR: trying to use EOEntity/EOEntityDescription which are defined in EOAccess
globalID = [[classDesc entity] globalIDForRow: row]; globalID = [[classDesc entity] globalIDForRow: row];
object = [self objectForGlobalID: globalID]; object = [self objectForGlobalID: globalID];

View file

@ -118,7 +118,7 @@ typedef struct {
+ (BOOL)isKindOfClass: (Class)aClass + (BOOL)isKindOfClass: (Class)aClass
{ {
if(aClass == [EOFault class]) if (aClass == [EOFault class])
return YES; return YES;
return NO; return NO;
@ -126,8 +126,12 @@ typedef struct {
+ (void)doesNotRecognizeSelector: (SEL)sel + (void)doesNotRecognizeSelector: (SEL)sel
{ {
return; [NSException raise: NSInvalidArgumentException
[self notImplemented: _cmd]; format: @"%@ -- %@ 0x%x: selector \"%@\" not recognized",
NSStringFromSelector(_cmd),
NSStringFromClass([self class]),
self,
NSStringFromSelector(sel)];
} }
+ (BOOL)respondsToSelector: (SEL)sel + (BOOL)respondsToSelector: (SEL)sel

View file

@ -49,6 +49,12 @@ RCS_ID("$Id$")
#import <EOControl/EOFault.h> #import <EOControl/EOFault.h>
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
#ifndef GNU_RUNTIME
#include <objc/objc-class.h>
#endif
#include <objc/Protocol.h>
BOOL __isGCEnabled(Class class_) BOOL __isGCEnabled(Class class_)
{ {

View file

@ -36,6 +36,7 @@
RCS_ID("$Id$") RCS_ID("$Id$")
#import <Foundation/NSCoder.h> #import <Foundation/NSCoder.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSValue.h> #import <Foundation/NSValue.h>
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>

View file

@ -51,9 +51,11 @@
classDescription: (EOClassDescription *)classDesc classDescription: (EOClassDescription *)classDesc
globalID: (EOGlobalID *)globalID; globalID: (EOGlobalID *)globalID;
#if !FOUNDATION_HAS_KVC
- (id)valueForKey: (NSString *)key; - (id)valueForKey: (NSString *)key;
- (void)takeValue: (id)value - (void)takeValue: (id)value
forKey: (NSString *)key; forKey: (NSString *)key;
#endif
+ (void)eoCalculateAllSizeWith: (NSMutableDictionary*)dict; + (void)eoCalculateAllSizeWith: (NSMutableDictionary*)dict;
- (unsigned int)eoCalculateSizeWith: (NSMutableDictionary*)dict; - (unsigned int)eoCalculateSizeWith: (NSMutableDictionary*)dict;

View file

@ -49,9 +49,6 @@ RCS_ID("$Id$")
#import <gnustep/base/GSObjCRuntime.h> #import <gnustep/base/GSObjCRuntime.h>
#import <EOAccess/EOEntity.h>
#import <EOAccess/EORelationship.h>
#import <EOControl/EOClassDescription.h> #import <EOControl/EOClassDescription.h>
#import <EOControl/EOGenericRecord.h> #import <EOControl/EOGenericRecord.h>
#import <EOControl/EONull.h> #import <EOControl/EONull.h>
@ -61,6 +58,10 @@ RCS_ID("$Id$")
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
#import <EOControl/EOKeyValueCoding.h> #import <EOControl/EOKeyValueCoding.h>
#ifndef GNU_RUNTIME
#include <objc/objc-class.h>
#endif
@interface NSObject (EOCalculateSize) @interface NSObject (EOCalculateSize)
- (unsigned int)eoGetSize; - (unsigned int)eoGetSize;
@ -84,6 +85,11 @@ RCS_ID("$Id$")
forFault: (id)object; forFault: (id)object;
@end @end
@interface EOGenericRecord(EOCalculateSize)
+ (unsigned int)eoCalculateSizeWith: (NSMutableDictionary *)dict
forArray: (NSArray *)array;
@end
static NSHashTable *allGenericRecords = NULL; static NSHashTable *allGenericRecords = NULL;
static NSRecursiveLock *allGenericRecordsLock = nil; static NSRecursiveLock *allGenericRecordsLock = nil;
@ -93,14 +99,13 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
+ (void) initialize + (void) initialize
{ {
if ([[super superclass] initialize]) [[super superclass] initialize];
if (self == [EOGenericRecord class] && !allGenericRecords)
{ {
if (self == [EOGenericRecord class]) allGenericRecords = NSCreateHashTable(NSNonOwnedPointerHashCallBacks,
{ 1000);
allGenericRecords = NSCreateHashTable(NSNonOwnedPointerHashCallBacks, allGenericRecordsLock = [NSRecursiveLock new];
1000);
allGenericRecordsLock = [NSRecursiveLock new];
}
} }
} }
@ -111,7 +116,7 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
[allGenericRecordsLock unlock]; [allGenericRecordsLock unlock];
} }
+ (void)removeDestoyedObject: (EOGenericRecord *)o + (void)removeDestroyedObject: (EOGenericRecord *)o
{ {
[allGenericRecordsLock lock]; [allGenericRecordsLock lock];
NSHashRemove(allGenericRecords, o); NSHashRemove(allGenericRecords, o);
@ -134,7 +139,7 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
{ {
if ((self = [self init])) if ((self = [self init]))
{ {
EOEntity *entity = nil; NSMutableArray *classPropertyNames = nil;
EOMutableKnownKeyDictionary *entityMKKD = nil; EOMutableKnownKeyDictionary *entityMKKD = nil;
if (!classDesc) if (!classDesc)
@ -151,14 +156,25 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
ASSIGN(classDescription, classDesc); ASSIGN(classDescription, classDesc);
entity = [(EOEntityClassDescription*)classDesc entity]; // Get class properties (attributes + relationships)
NSAssert(entity, @"No entity"); classPropertyNames = [[NSMutableArray alloc]
initWithArray: [classDesc attributeKeys]];
[classPropertyNames addObjectsFromArray:
[classDesc toOneRelationshipKeys]];
[classPropertyNames addObjectsFromArray:
[classDesc toManyRelationshipKeys]];
entityMKKD = [entity _dictionaryForProperties]; NSAssert1([classPropertyNames count] > 0,
@"No classPropertyNames in %@", classDesc);
entityMKKD = [EOMutableKnownKeyDictionary
dictionaryWithInitializer:
[[EOMKKDInitializer newWithKeyArray: classPropertyNames] autorelease]];
ASSIGN(dictionary,entityMKKD); ASSIGN(dictionary,entityMKKD);
EOFLOGObjectLevelArgs(@"EOGenericRecord", @"Record %p: dictionary=%@", EOFLOGObjectLevelArgs(@"EOGenericRecord", @"Record %p: dictionary=%@",
self, dictionary); self, dictionary);
[classPropertyNames release];
} }
return self; return self;
@ -170,7 +186,7 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
@"Deallocate EOGenericRecord %p (dict=%p)", @"Deallocate EOGenericRecord %p (dict=%p)",
self, dictionary); self, dictionary);
[[self class] removeDestoyedObject: self]; [[self class] removeDestroyedObject: self];
DESTROY(classDescription); DESTROY(classDescription);
DESTROY(dictionary); DESTROY(dictionary);
@ -183,6 +199,8 @@ static NSRecursiveLock *allGenericRecordsLock = nil;
return classDescription; return classDescription;
} }
#if !FOUNDATION_HAS_KVC
static const char _c_id[2] = { _C_ID, NULL }; static const char _c_id[2] = { _C_ID, NULL };
//used to allow derived object implementation //used to allow derived object implementation
@ -601,17 +619,21 @@ static const char _c_id[2] = { _C_ID, NULL };
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC"); EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
} }
#endif /* !FOUNDATION_HAS_KVC */
/** if key is a bidirectional rel, use addObject:toBothSidesOfRelationship otherwise call takeValue:forKey: **/ /** if key is a bidirectional rel, use addObject:toBothSidesOfRelationship otherwise call takeValue:forKey: **/
- (void)smartTakeValue: (id)anObject - (void)smartTakeValue: (id)anObject
forKey: (NSString *)aKey forKey: (NSString *)aKey
{ {
EORelationship *rel = [classDescription relationshipNamed: aKey]; BOOL isToMany = [[classDescription toManyRelationshipKeys]
containsObject: aKey];
//NSDebugMLog(@"aKey=%@ rel=%@ anObject=%@", aKey, rel, anObject); //NSDebugMLog(@"aKey=%@ rel=%@ anObject=%@", aKey, rel, anObject);
//NSDebugMLog(@"[rel isBidirectional]=%d", [rel isBidirectional]); //NSDebugMLog(@"[rel isBidirectional]=%d", [rel isBidirectional]);
if (rel && [rel isBidirectional]) if ((isToMany
|| [[classDescription toOneRelationshipKeys] containsObject: aKey])
&& [classDescription inverseForRelationshipKey: aKey] != nil)
{ {
if (isNilOrEONull(anObject)) if (isNilOrEONull(anObject))
{ {
@ -619,7 +641,7 @@ static const char _c_id[2] = { _C_ID, NULL };
if (isNilOrEONull(oldObj)) if (isNilOrEONull(oldObj))
{ {
if (![rel isToMany]) if (!isToMany)
[self takeValue: anObject [self takeValue: anObject
forKey: aKey]; forKey: aKey];
} }
@ -636,6 +658,7 @@ static const char _c_id[2] = { _C_ID, NULL };
forKey: aKey]; forKey: aKey];
} }
#if !FOUNDATION_HAS_KVC
- (void) takeValue: (id)anObject forKey: (NSString*)aKey - (void) takeValue: (id)anObject forKey: (NSString*)aKey
{ {
SEL sel; SEL sel;
@ -788,6 +811,54 @@ static const char _c_id[2] = { _C_ID, NULL };
return value; return value;
} }
#else /* FOUNDATION_HAS_KVC */
- (id) handleQueryWithUnboundKey: (NSString *)key
{
id value;
EOFLOGObjectFnStartCond(@"EOGenericRecordKVC");
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"Unbound key named %@",
key);
if (![dictionary hasKey: key])
return [super handleQueryWithUnboundKey: key];
value = [dictionary objectForKey: key];
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC", @"value %p (class=%@)",
value, [value class]);
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
return value;
}
- (void) handleTakeValue: (id)value forUnboundKey: (NSString *)key
{
EOFLOGObjectFnStartCond(@"EOGenericRecordKVC");
EOFLOGObjectLevelArgs(@"EOGenericRecordKVC",
@"Unbound key named %@",
key);
[self willChange];
if (![dictionary hasKey:key])
[super handleTakeValue:value forUnboundKey: key];
if (value)
[dictionary setObject: value
forKey: key];
else
// [dictionary setObject: [EONull null]
// forKey: key];
[dictionary removeObjectForKey: key];
EOFLOGObjectFnStopCond(@"EOGenericRecordKVC");
}
#endif /* FOUNDATION_HAS_KVC */
/** used in -decription for self toOne or toMany objects to avoid /** used in -decription for self toOne or toMany objects to avoid
infinite loop in description **/ infinite loop in description **/
@ -901,7 +972,7 @@ infinite loop in description **/
stringWithFormat: @"<%p %@: classDescription=%@>", stringWithFormat: @"<%p %@: classDescription=%@>",
obj, obj,
NSStringFromClass([obj class]), NSStringFromClass([obj class]),
[obj classDescription]] [(EOGenericRecord *)obj classDescription]]
forKey: key]; forKey: key];
} }
} }
@ -967,7 +1038,7 @@ infinite loop in description **/
[allGenericRecordsLock unlock]; [allGenericRecordsLock unlock];
NSDebugMLog(@"CALCULATE STOPEXC"); NSDebugMLog(@"CALCULATE STOPEXC", "");
[localException raise]; [localException raise];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
@ -1017,8 +1088,12 @@ infinite loop in description **/
//NSDebugMLog(@"classDescription=%@", classDescription); //NSDebugMLog(@"classDescription=%@", classDescription);
props = [[(EOEntityClassDescription *)classDescription entity] // Get class properties (attributes + relationships)
classPropertyNames]; props = [NSMutableArray arrayWithArray: [classDescription attributeKeys]];
[(NSMutableArray *)props addObjectsFromArray:
[classDescription toOneRelationshipKeys]];
[(NSMutableArray *)props addObjectsFromArray:
[classDescription toManyRelationshipKeys]];
size += [self eoGetSize]; size += [self eoGetSize];
size += [dictionary eoGetSize]; size += [dictionary eoGetSize];

View file

@ -41,6 +41,8 @@ RCS_ID("$Id$")
#import <EOControl/EOGlobalID.h> #import <EOControl/EOGlobalID.h>
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
#include <stdio.h>
#include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h> #include <unistd.h>
@ -114,7 +116,7 @@ static unsigned long sequenceRev = 0;
sequence-- % 0xff, sequence-- % 0xff,
getpid() % 0xff, getpid() % 0xff,
(unsigned int)time( NULL ) % 0xffff, (unsigned int)time( NULL ) % 0xffff,
sequenceRev++ % 0xffff); (unsigned int)sequenceRev++ % 0xffff);
if (sequence == 0) if (sequence == 0)
sequence = 65535; sequence = 65535;

View file

@ -122,19 +122,19 @@ RCS_ID("$Id$")
} }
else if (sel_eq(_selector, EOQualifierOperatorLessThan) == YES) else if (sel_eq(_selector, EOQualifierOperatorLessThan) == YES)
{ {
return [leftKey compare: rightKey] == NSOrderedAscending; return [(NSObject *)leftKey compare: rightKey] == NSOrderedAscending;
} }
else if (sel_eq(_selector, EOQualifierOperatorGreaterThan) == YES) else if (sel_eq(_selector, EOQualifierOperatorGreaterThan) == YES)
{ {
return [leftKey compare: rightKey] == NSOrderedDescending; return [(NSObject *)leftKey compare: rightKey] == NSOrderedDescending;
} }
else if (sel_eq(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES) else if (sel_eq(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES)
{ {
return [leftKey compare: rightKey] != NSOrderedDescending; return [(NSObject *)leftKey compare: rightKey] != NSOrderedDescending;
} }
else if (sel_eq(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES) else if (sel_eq(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES)
{ {
return [leftKey compare: rightKey] != NSOrderedAscending; return [(NSObject *)leftKey compare: rightKey] != NSOrderedAscending;
} }
else if (sel_eq(_selector, EOQualifierOperatorContains) == YES) else if (sel_eq(_selector, EOQualifierOperatorContains) == YES)
{ {

View file

@ -160,7 +160,7 @@ RCS_ID("$Id$")
self = [super init]; self = [super init];
[coder decodeValueOfObjCType: @encode(unsigned short) at: &_keyCount]; [coder decodeValueOfObjCType: @encode(unsigned short) at: &_keyCount];
_entityName = [[coder decodeObject] retain]; _entityName = RETAIN([coder decodeObject]);
_keyValues = NSZoneMalloc([coder objectZone], _keyCount); _keyValues = NSZoneMalloc([coder objectZone], _keyCount);
[coder decodeArrayOfObjCType: @encode(id) count: _keyCount at: _keyValues]; [coder decodeArrayOfObjCType: @encode(id) count: _keyCount at: _keyValues];

View file

@ -32,8 +32,6 @@
#import <Foundation/NSKeyValueCoding.h> #import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSDictionary.h> #import <Foundation/NSDictionary.h>
#import <EOControl/EOKeyValueCodingBase.h>
@interface NSObject (EOKVCPAdditions2) @interface NSObject (EOKVCPAdditions2)
- (void)smartTakeValue: (id)anObject - (void)smartTakeValue: (id)anObject
@ -42,11 +40,19 @@
forKeyPath: (NSString *)aKeyPath; forKeyPath: (NSString *)aKeyPath;
- (void)takeStoredValue: value - (void)takeStoredValue: value
forKeyPath: (NSString *)key; forKeyPath: (NSString *)key;
- (id)storedValueForKeyPath: (NSString *)key;
#if !FOUNDATION_HAS_KVC
- (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary; - (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary;
#endif
- (NSDictionary *)valuesForKeyPaths: (NSArray *)keyPaths; - (NSDictionary *)valuesForKeyPaths: (NSArray *)keyPaths;
- (NSDictionary *)storedValuesForKeyPaths: (NSArray *)keyPaths; - (NSDictionary *)storedValuesForKeyPaths: (NSArray *)keyPaths;
@end @end
#if NeXT_Foundation_LIBRARY
@interface NSObject (MacOSXRevealed)
- (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary;
@end
#endif
@interface NSArray (EOKeyValueCoding) @interface NSArray (EOKeyValueCoding)
- (id)valueForKey: (NSString *)key; - (id)valueForKey: (NSString *)key;
@ -61,6 +67,7 @@
#if !FOUNDATION_HAS_KVC
@interface NSDictionary (EOKeyValueCoding) @interface NSDictionary (EOKeyValueCoding)
- (id)valueForKey: (NSString *)key; - (id)valueForKey: (NSString *)key;
@end @end
@ -70,6 +77,7 @@
- (void)takeValue: (id)value - (void)takeValue: (id)value
forKey: (NSString*)key; forKey: (NSString*)key;
@end @end
#endif
extern NSString *EOUnknownKeyException; extern NSString *EOUnknownKeyException;
extern NSString *EOTargetObjectUserInfoKey; extern NSString *EOTargetObjectUserInfoKey;

View file

@ -55,6 +55,7 @@ RCS_ID("$Id$")
#import <Foundation/NSDebug.h> #import <Foundation/NSDebug.h>
#include <objc/objc-api.h> #include <objc/objc-api.h>
#include <ctype.h>
#import <EOControl/EOKeyValueCoding.h> #import <EOControl/EOKeyValueCoding.h>
#import <EOControl/EONSAddOns.h> #import <EOControl/EONSAddOns.h>
@ -145,6 +146,7 @@ RCS_ID("$Id$")
return obj; return obj;
} }
#if !FOUNDATION_HAS_KVC
- (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary - (void)takeStoredValuesFromDictionary: (NSDictionary *)dictionary
{ {
NSEnumerator *keyEnum; NSEnumerator *keyEnum;
@ -167,6 +169,7 @@ RCS_ID("$Id$")
EOFLOGObjectFnStopCond(@"EOKVC"); EOFLOGObjectFnStopCond(@"EOKVC");
} }
#endif /* !FOUNDATION_HAS_KVC */
- (NSDictionary *)storedValuesForKeyPaths: (NSArray *)keyPaths - (NSDictionary *)storedValuesForKeyPaths: (NSArray *)keyPaths
{ {
@ -315,7 +318,7 @@ RCS_ID("$Id$")
if (warnedCount == NO) if (warnedCount == NO)
{ {
warnedCount = YES; warnedCount = YES;
NSWarnLog(@"use of special 'count' key may works differently with only foundation base"); NSWarnLog(@"use of special 'count' key may works differently with only foundation base", "");
} }
result = [super valueForKey: key]; result = [super valueForKey: key];
} }
@ -396,7 +399,7 @@ RCS_ID("$Id$")
if (warnedCount == NO) if (warnedCount == NO)
{ {
warnedCount = YES; warnedCount = YES;
NSWarnLog(@"use of special 'count' key may works differently with only foundation base"); NSWarnLog(@"use of special 'count' key may works differently with only foundation base", "");
} }
result = [super valueForKeyPath: keyPath]; result = [super valueForKeyPath: keyPath];
} }
@ -518,6 +521,7 @@ RCS_ID("$Id$")
@implementation NSDictionary (EOKeyValueCoding) @implementation NSDictionary (EOKeyValueCoding)
#if !FOUNDATION_HAS_KVC
- (id)valueForKey:(NSString *)key - (id)valueForKey:(NSString *)key
{ {
id value; id value;
@ -536,7 +540,7 @@ RCS_ID("$Id$")
if (warnedAllValues == NO) if (warnedAllValues == NO)
{ {
warnedAllValues = YES; warnedAllValues = YES;
NSWarnLog(@"use of special 'allValues' key works differently with only foundation base"); NSWarnLog(@"use of special 'allValues' key works differently with only foundation base", "");
} }
value = [self allValues]; value = [self allValues];
@ -547,7 +551,7 @@ RCS_ID("$Id$")
if (warnedAllKeys == NO) if (warnedAllKeys == NO)
{ {
warnedAllKeys = YES; warnedAllKeys = YES;
NSWarnLog(@"use of special 'allKeys' key works differently with only foundation base"); NSWarnLog(@"use of special 'allKeys' key works differently with only foundation base", "");
} }
value = [self allKeys]; value = [self allKeys];
@ -558,7 +562,7 @@ RCS_ID("$Id$")
if (warnedCount == NO) if (warnedCount == NO)
{ {
warnedCount = YES; warnedCount = YES;
NSWarnLog(@"use of special 'count' key works differently with only foundation base"); NSWarnLog(@"use of special 'count' key works differently with only foundation base", "");
} }
value = [NSNumber numberWithInt: [self count]]; value = [NSNumber numberWithInt: [self count]];
@ -681,6 +685,7 @@ RCS_ID("$Id$")
return value; return value;
} }
#endif /* !FOUNDATION_HAS_KVC */
- (id)storedValueForKeyPath: (NSString*)keyPath - (id)storedValueForKeyPath: (NSString*)keyPath
{ {
@ -768,8 +773,15 @@ RCS_ID("$Id$")
@end @end
@interface NSMutableDictionary(EOKeyValueCodingPrivate)
- (void)takeValue: (id)value
forKeyPath: (NSString *)keyPath
isSmart: (BOOL)smartFlag;
@end
@implementation NSMutableDictionary (EOKeyValueCoding) @implementation NSMutableDictionary (EOKeyValueCoding)
#if !FOUNDATION_HAS_KVC
- (void)takeValue: (id)value - (void)takeValue: (id)value
forKey: (NSString *)key forKey: (NSString *)key
{ {
@ -797,6 +809,7 @@ RCS_ID("$Id$")
EOFLOGObjectFnStopCond(@"EOKVC"); EOFLOGObjectFnStopCond(@"EOKVC");
} }
#endif /* !FOUNDATION_HAS_KVC */
- (void)smartTakeValue: (id)value - (void)smartTakeValue: (id)value
forKeyPath: (NSString*)keyPath forKeyPath: (NSString*)keyPath
@ -806,6 +819,7 @@ RCS_ID("$Id$")
isSmart:YES]; isSmart:YES];
} }
#if !FOUNDATION_HAS_KVC
- (void)takeValue: (id)value - (void)takeValue: (id)value
forKeyPath: (NSString *)keyPath forKeyPath: (NSString *)keyPath
{ {
@ -813,6 +827,7 @@ RCS_ID("$Id$")
forKeyPath:keyPath forKeyPath:keyPath
isSmart:NO]; isSmart:NO];
} }
#endif /* !FOUNDATION_HAS_KVC */
- (void)takeValue: (id)value - (void)takeValue: (id)value
forKeyPath: (NSString *)keyPath forKeyPath: (NSString *)keyPath
@ -837,7 +852,7 @@ RCS_ID("$Id$")
//EOFLOGObjectLevelArgs(@"EOKVC", @"keyPathArray=%@", keyPathArray); //EOFLOGObjectLevelArgs(@"EOKVC", @"keyPathArray=%@", keyPathArray);
tmpKey = [keyPathArray objectAtIndex: 0]; tmpKey = RETAIN([keyPathArray objectAtIndex: 0]);
//EOFLOGObjectLevelArgs(@"EOKVC", @"tmpKey=%@", tmpKey); //EOFLOGObjectLevelArgs(@"EOKVC", @"tmpKey=%@", tmpKey);
[keyPathArray removeObjectAtIndex: 0]; [keyPathArray removeObjectAtIndex: 0];
@ -846,13 +861,15 @@ RCS_ID("$Id$")
[key appendString: @"."]; [key appendString: @"."];
if ([tmpKey hasSuffix: @"'"]) if ([tmpKey hasSuffix: @"'"])
{ {
tmpKey = [tmpKey stringByDeletingSuffix: @"'"]; ASSIGN(tmpKey, [tmpKey stringByDeletingSuffix: @"'"]);
[key appendString: tmpKey]; [key appendString: tmpKey];
break; break;
} }
else else
[key appendString: tmpKey]; [key appendString: tmpKey];
RELEASE(tmpKey);
//EOFLOGObjectLevelArgs(@"EOKVC", @"key=%@", key); //EOFLOGObjectLevelArgs(@"EOKVC", @"key=%@", key);
} }

View file

@ -116,27 +116,27 @@ operatorSelector: (SEL)selector
if (sel_eq(_selector, EOQualifierOperatorEqual) == YES) if (sel_eq(_selector, EOQualifierOperatorEqual) == YES)
{ {
return [key compare: _value] == NSOrderedSame; return [(NSString *)key compare: _value] == NSOrderedSame;
} }
else if (sel_eq(_selector, EOQualifierOperatorNotEqual) == YES) else if (sel_eq(_selector, EOQualifierOperatorNotEqual) == YES)
{ {
return [key compare: _value] != NSOrderedSame; return [(NSString *)key compare: _value] != NSOrderedSame;
} }
else if (sel_eq(_selector, EOQualifierOperatorLessThan) == YES) else if (sel_eq(_selector, EOQualifierOperatorLessThan) == YES)
{ {
return [key compare: _value] == NSOrderedAscending; return [(NSString *)key compare: _value] == NSOrderedAscending;
} }
else if (sel_eq(_selector, EOQualifierOperatorGreaterThan) == YES) else if (sel_eq(_selector, EOQualifierOperatorGreaterThan) == YES)
{ {
return [key compare: _value] == NSOrderedDescending; return [(NSString *)key compare: _value] == NSOrderedDescending;
} }
else if (sel_eq(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES) else if (sel_eq(_selector, EOQualifierOperatorLessThanOrEqualTo) == YES)
{ {
return [key compare: _value] != NSOrderedDescending; return [(NSString *)key compare: _value] != NSOrderedDescending;
} }
else if (sel_eq(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES) else if (sel_eq(_selector, EOQualifierOperatorGreaterThanOrEqualTo) == YES)
{ {
return [key compare: _value] != NSOrderedAscending; return [(NSString *)key compare: _value] != NSOrderedAscending;
} }
else if (sel_eq(_selector, EOQualifierOperatorContains) == YES) else if (sel_eq(_selector, EOQualifierOperatorContains) == YES)
{ {

View file

@ -472,6 +472,7 @@ RCS_ID("$Id$")
+ (id)dictionaryFromDictionary: (NSDictionary *)dict + (id)dictionaryFromDictionary: (NSDictionary *)dict
subsetMapping: (EOMKKDSubsetMapping *)subsetMapping subsetMapping: (EOMKKDSubsetMapping *)subsetMapping
{ {
#warning (stephane@sente.ch) Method is really not implemented!
return [[self newDictionaryFromDictionary: dict return [[self newDictionaryFromDictionary: dict
subsetMapping: subsetMapping subsetMapping: subsetMapping
zone: NULL] autorelease]; zone: NULL] autorelease];
@ -518,14 +519,6 @@ RCS_ID("$Id$")
@implementation EOMutableKnownKeyDictionary @implementation EOMutableKnownKeyDictionary
+ (id)dictionaryFromDictionary: (NSDictionary *)dict
subsetMapping: (EOMKKDSubsetMapping *)subsetMapping
{
return [[self newDictionaryFromDictionary: dict
subsetMapping: subsetMapping
zone: NULL] autorelease];
}
+ (id)newDictionaryFromDictionary: (NSDictionary*)dict + (id)newDictionaryFromDictionary: (NSDictionary*)dict
subsetMapping: (EOMKKDSubsetMapping*)subsetMapping subsetMapping: (EOMKKDSubsetMapping*)subsetMapping
zone: (NSZone*)zone zone: (NSZone*)zone
@ -584,6 +577,14 @@ RCS_ID("$Id$")
return newDict; return newDict;
} }
+ (id)dictionaryFromDictionary: (NSDictionary *)dict
subsetMapping: (EOMKKDSubsetMapping *)subsetMapping
{
return [[self newDictionaryFromDictionary: dict
subsetMapping: subsetMapping
zone: NULL] autorelease];
}
+ (id)newDictionaryWithObjects: (id*)objects + (id)newDictionaryWithObjects: (id*)objects
arrayMapping: (id)mapping arrayMapping: (id)mapping
zone: (NSZone*)zone zone: (NSZone*)zone

View file

@ -422,7 +422,7 @@ RCS_ID("$Id$")
- (NSComparisonResult)eoCompareOnName: (id)object - (NSComparisonResult)eoCompareOnName: (id)object
{ {
return [[self name] compare: [object name]]; return [(NSString *)[(id)self name] compare: [object name]];
} }
@end @end

View file

@ -62,12 +62,12 @@ NSString *EOCooperatingObjectStoreNeeded = @"EOCooperatingObjectStoreNeeded";
- (void)dealloc - (void)dealloc
{ {
NSDebugMLog(@"dealloc coordinator"); NSDebugMLog(@"dealloc coordinator", "");
DESTROY(_stores); DESTROY(_stores);
DESTROY(_userInfo); DESTROY(_userInfo);
[super dealloc]; [super dealloc];
NSDebugMLog(@"dealloc coordinator end"); NSDebugMLog(@"dealloc coordinator end", "");
} }
- (void)addCooperatingObjectStore: (EOCooperatingObjectStore *)store - (void)addCooperatingObjectStore: (EOCooperatingObjectStore *)store

View file

@ -49,6 +49,8 @@ RCS_ID("$Id$")
#import <EOControl/EOQualifier.h> #import <EOControl/EOQualifier.h>
#import <EOControl/EODebug.h> #import <EOControl/EODebug.h>
#include <gnustep/base/GSObjCRuntime.h>
@implementation NSNumber (EOQualifierExtras) @implementation NSNumber (EOQualifierExtras)
@ -127,7 +129,7 @@ static NSString *getOperator(const char **cFormat, const char **s)
{ {
while (**s && !isalnum(**s) && !isspace(**s) && **s != '%' && **s != '\'') while (**s && !isalnum(**s) && !isspace(**s) && **s != '%' && **s != '\'')
{ {
NSDebugLog(@"avoid gcc 3.1.1 bug which optimizes to segfault"); NSDebugLog(@"avoid gcc 3.1.1 bug which optimizes to segfault", "");
(*s)++; (*s)++;
} }
@ -811,7 +813,7 @@ static Class whichQualifier(const char **cFormat, const char **s)
{ {
if ((self = [super init])) if ((self = [super init]))
{ {
_key = [[coder decodeObject] retain]; _key = RETAIN([coder decodeObject]);
} }
return self; return self;
@ -873,13 +875,12 @@ static Class whichQualifier(const char **cFormat, const char **s)
- (BOOL)isNotEqualTo: (id)object - (BOOL)isNotEqualTo: (id)object
{ {
return ([self isEqual: object] ? NO : YES); return ([self isEqualTo: object] ? NO : YES);
} }
- (BOOL)doesContain: (id)object - (BOOL)doesContain: (id)object
{ {
if ([self isKindOfClass: [NSArray class]] if ([self isKindOfClass: [NSArray class]])
|| [self isKindOfClass: [NSMutableArray class]])
return [(NSArray *)self containsObject: object]; return [(NSArray *)self containsObject: object];
return NO; return NO;

View file

@ -65,7 +65,7 @@ RCS_ID("$Id$")
self = [super init]; self = [super init];
[coder decodeValueOfObjCType: @encode(SEL) at: &_selector]; [coder decodeValueOfObjCType: @encode(SEL) at: &_selector];
_key = [[coder decodeObject] retain]; _key = RETAIN([coder decodeObject]);
return self; return self;
} }
@ -129,12 +129,17 @@ RCS_ID("$Id$")
return self; return self;
else else
{ {
NSMutableArray *sortedArray = [[self mutableCopy] autorelease]; NSMutableArray *sortedArray = [[NSMutableArray alloc]
initWithArray: self copyItems: NO];
NSArray *result;
[sortedArray sortUsingKeyOrderArray: orderArray]; [sortedArray sortUsingKeyOrderArray: orderArray];
// make array immutable but don't copy as mutable arrays copy deep // make array immutable but don't copy as mutable arrays copy deep
return [NSArray arrayWithArray: sortedArray]; result = [NSArray arrayWithArray: sortedArray];
[sortedArray release];
return result;
} }
} }
@ -275,18 +280,18 @@ RCS_ID("$Id$")
if (count > 1) if (count > 1)
{ {
EOSortOrdering *order; int i, max;
NSEnumerator *orderEnum;
//NSString *key; //NSString *key;
orderEnum = [orderArray objectEnumerator]; max = [orderArray count];
if ((order = [orderEnum nextObject])) for (i = 0; i < max; i++)
{ {
EOSortOrdering *order = [orderArray objectAtIndex: i];
//id a, b; //id a, b;
[self _sortUsingKeyOrder: order [self _sortUsingKeyOrder: order
fromIndex: 0 fromIndex: 0
count: [self count]]; count: count];
#if 0 #if 0
key = [order key]; key = [order key];

View file

@ -32,7 +32,7 @@ include $(GNUSTEP_MAKEFILES)/common.make
include ../Version include ../Version
# The library to be compiled # The library to be compiled
TOOL_NAME=gdlgsdoc TOOL_NAME=gdlgsdoc eoutil
LIBRARIES_DEPEND_UPON=-lgnustep-base -lgnustep-db2control -lgnustep-db2 LIBRARIES_DEPEND_UPON=-lgnustep-base -lgnustep-db2control -lgnustep-db2
@ -81,6 +81,11 @@ gdl2gsdoc_AGSDOC_FLAGS = \
}' -Up gdl2gsdoc }' -Up gdl2gsdoc
eoutil_OBJC_FILES = eoutil.m
eoutil_HEADER_FILES =
-include Makefile.preamble -include Makefile.preamble
-include GNUmakefile.local -include GNUmakefile.local