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>
* Source/NSGAttributedString.m: ([setAttributes:range:]) make sure

View file

@ -721,7 +721,7 @@ static NSString *indentStrings[] = {
[item descriptionWithLocale: nil indent: 0 to: result];
if (i != last)
{
(*appImp)(result, appSel, @",");
(*appImp)(result, appSel, @", ");
}
}
(*appImp)(result, appSel, @")");

View file

@ -662,18 +662,61 @@ static NSString *indentStrings[] = {
to: (id<GNUDescriptionDestination>)result
{
IMP myObj = [self methodForSelector: objSel];
BOOL canCompare = YES;
unsigned i;
NSArray *keyArray = [self allKeys];
unsigned numKeys = [keyArray count];
NSString *plists[numKeys];
NSString *keys[numKeys];
IMP appImp;
Class lastClass = 0;
appImp = [(NSObject*)result methodForSelector: appSel];
[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++)
{
if (fastClass(keys[i]) == lastClass)
@ -686,9 +729,9 @@ static NSString *indentStrings[] = {
lastClass = fastClass(keys[i]);
}
if (canCompare)
if (canCompare == YES)
{
/*
/*
* Shell sort algorithm taken from SortingInAction - a NeXT example
* good value for stride factor is not well-understood
* 3 is a fairly good choice (Sedgewick)
@ -777,43 +820,6 @@ static NSString *indentStrings[] = {
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");
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
if (![_persDomains objectForKey: processName])
{
[_persDomains setObject:
[NSMutableDictionaryClass
dictionaryWithCapacity: 10] forKey: processName];
[_persDomains
setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
forKey: processName];
[self __changePersistentDomain: processName];
}
if (![_persDomains objectForKey: NSGlobalDomain])
{
[_persDomains setObject:
[NSMutableDictionaryClass
dictionaryWithCapacity: 10] forKey: NSGlobalDomain];
[_persDomains
setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
forKey: NSGlobalDomain];
[self __changePersistentDomain: NSGlobalDomain];
}
@ -422,9 +422,9 @@ static NSString *pathForUser(NSString *user)
_tempDomains = [[NSMutableDictionaryClass alloc] initWithCapacity: 10];
[_tempDomains setObject: [self __createArgumentDictionary]
forKey: NSArgumentDomain];
[_tempDomains setObject:
[NSMutableDictionaryClass
dictionaryWithCapacity: 10] forKey: NSRegistrationDomain];
[_tempDomains
setObject: [NSMutableDictionaryClass dictionaryWithCapacity: 10]
forKey: NSRegistrationDomain];
return self;
}
@ -444,12 +444,12 @@ static NSString *pathForUser(NSString *user)
- (NSString*) description
{
NSMutableString *desc =
[NSMutableString stringWithFormat: @"%@",[super description]];
NSMutableString *desc;
// $$$ Not Implemented
// It's good idea to put all useful info here -- so I can test it later
[self notImplemented: _cmd];
desc = [NSMutableString stringWithFormat: @"%@", [super description]];
[desc appendFormat: @" SearchList: %@", _searchList];
[desc appendFormat: @" Persistant: %@", _persDomains];
[desc appendFormat: @" Temporary: %@", _tempDomains];
return desc;
}