Implemented description method for NSUserDefaults. and tidied description stuff

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6332 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-03-19 09:23:41 +00:00
parent 79e7e51a48
commit 4394e1d65b
4 changed files with 137 additions and 122 deletions

View file

@ -1,3 +1,12 @@
2000-03-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSUserDefaults.m: ([-description]) implemented.
* Source/NSArray.m: ([-descriptionWithLocale:indent:]) put space
after comma even when doing unformatted description.
* Source/NSDictionary.m: ([-descriptionWithLocale:indent:]) put space
after semicolon and around equals even when doing unformatted
description. Don't sort array items in unformatted description.
2000-03-19 Richard Frith-Macdonald <rfm@gnu.org> 2000-03-19 Richard Frith-Macdonald <rfm@gnu.org>
* Source/NSGAttributedString.m: ([setAttributes:range:]) make sure * Source/NSGAttributedString.m: ([setAttributes:range:]) make sure

View file

@ -662,18 +662,61 @@ static NSString *indentStrings[] = {
to: (id<GNUDescriptionDestination>)result to: (id<GNUDescriptionDestination>)result
{ {
IMP myObj = [self methodForSelector: objSel]; IMP myObj = [self methodForSelector: objSel];
BOOL canCompare = YES;
unsigned i; unsigned i;
NSArray *keyArray = [self allKeys]; NSArray *keyArray = [self allKeys];
unsigned numKeys = [keyArray count]; unsigned numKeys = [keyArray count];
NSString *plists[numKeys]; NSString *plists[numKeys];
NSString *keys[numKeys]; NSString *keys[numKeys];
IMP appImp; IMP appImp;
Class lastClass = 0;
appImp = [(NSObject*)result methodForSelector: appSel]; appImp = [(NSObject*)result methodForSelector: appSel];
[keyArray getObjects: keys]; [keyArray getObjects: keys];
if (locale == nil)
{
for (i = 0; i < numKeys; i++)
{
plists[i] = (*myObj)(self, objSel, keys[i]);
}
(*appImp)(result, appSel, @"{");
for (i = 0; i < numKeys; i++)
{
id o = plists[i];
[keys[i] descriptionWithLocale: nil indent: 0 to: result];
(*appImp)(result, appSel, @" = ");
[o descriptionWithLocale: nil indent: 0 to: result];
(*appImp)(result, appSel, @"; ");
}
(*appImp)(result, appSel, @"}");
}
else
{
NSString *iBaseString;
NSString *iSizeString;
BOOL canCompare = YES;
Class lastClass = 0;
if (level < sizeof(indentStrings)/sizeof(id))
{
iBaseString = indentStrings[level];
}
else
{
iBaseString = indentStrings[sizeof(indentStrings)/sizeof(id)-1];
}
level++;
if (level < sizeof(indentStrings)/sizeof(id))
{
iSizeString = indentStrings[level];
}
else
{
iSizeString = indentStrings[sizeof(indentStrings)/sizeof(id)-1];
}
for (i = 0; i < numKeys; i++) for (i = 0; i < numKeys; i++)
{ {
if (fastClass(keys[i]) == lastClass) if (fastClass(keys[i]) == lastClass)
@ -686,7 +729,7 @@ static NSString *indentStrings[] = {
lastClass = fastClass(keys[i]); lastClass = fastClass(keys[i]);
} }
if (canCompare) if (canCompare == YES)
{ {
/* /*
* Shell sort algorithm taken from SortingInAction - a NeXT example * Shell sort algorithm taken from SortingInAction - a NeXT example
@ -777,43 +820,6 @@ static NSString *indentStrings[] = {
plists[i] = (*myObj)(self, objSel, keys[i]); plists[i] = (*myObj)(self, objSel, keys[i]);
} }
if (locale == nil)
{
(*appImp)(result, appSel, @"{");
for (i = 0; i < numKeys; i++)
{
id o = plists[i];
[keys[i] descriptionWithLocale: nil indent: 0 to: result];
(*appImp)(result, appSel, @"=");
[o descriptionWithLocale: nil indent: 0 to: result];
(*appImp)(result, appSel, @";");
}
(*appImp)(result, appSel, @"}");
}
else
{
NSString *iBaseString;
NSString *iSizeString;
if (level < sizeof(indentStrings)/sizeof(id))
{
iBaseString = indentStrings[level];
}
else
{
iBaseString = indentStrings[sizeof(indentStrings)/sizeof(id)-1];
}
level++;
if (level < sizeof(indentStrings)/sizeof(id))
{
iSizeString = indentStrings[level];
}
else
{
iSizeString = indentStrings[sizeof(indentStrings)/sizeof(id)-1];
}
(*appImp)(result, appSel, @"{\n"); (*appImp)(result, appSel, @"{\n");
for (i = 0; i < numKeys; i++) for (i = 0; i < numKeys; i++)
{ {

View file

@ -405,16 +405,16 @@ static NSString *pathForUser(NSString *user)
// Check and if not existent add the Application and the Global domains // Check and if not existent add the Application and the Global domains
if (![_persDomains objectForKey: processName]) if (![_persDomains objectForKey: processName])
{ {
[_persDomains setObject: [_persDomains
[NSMutableDictionaryClass setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
dictionaryWithCapacity: 10] forKey: processName]; forKey: processName];
[self __changePersistentDomain: processName]; [self __changePersistentDomain: processName];
} }
if (![_persDomains objectForKey: NSGlobalDomain]) if (![_persDomains objectForKey: NSGlobalDomain])
{ {
[_persDomains setObject: [_persDomains
[NSMutableDictionaryClass setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
dictionaryWithCapacity: 10] forKey: NSGlobalDomain]; forKey: NSGlobalDomain];
[self __changePersistentDomain: NSGlobalDomain]; [self __changePersistentDomain: NSGlobalDomain];
} }
@ -422,9 +422,9 @@ static NSString *pathForUser(NSString *user)
_tempDomains = [[NSMutableDictionaryClass alloc] initWithCapacity: 10]; _tempDomains = [[NSMutableDictionaryClass alloc] initWithCapacity: 10];
[_tempDomains setObject: [self __createArgumentDictionary] [_tempDomains setObject: [self __createArgumentDictionary]
forKey: NSArgumentDomain]; forKey: NSArgumentDomain];
[_tempDomains setObject: [_tempDomains
[NSMutableDictionaryClass setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
dictionaryWithCapacity: 10] forKey: NSRegistrationDomain]; forKey: NSRegistrationDomain];
return self; return self;
} }
@ -444,12 +444,12 @@ static NSString *pathForUser(NSString *user)
- (NSString*) description - (NSString*) description
{ {
NSMutableString *desc = NSMutableString *desc;
[NSMutableString stringWithFormat: @"%@",[super description]];
// $$$ Not Implemented desc = [NSMutableString stringWithFormat: @"%@", [super description]];
// It's good idea to put all useful info here -- so I can test it later [desc appendFormat: @" SearchList: %@", _searchList];
[self notImplemented: _cmd]; [desc appendFormat: @" Persistant: %@", _persDomains];
[desc appendFormat: @" Temporary: %@", _tempDomains];
return desc; return desc;
} }