description tidyups

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6297 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-03-17 13:13:08 +00:00
parent 0781dc0250
commit 6978b88eed
14 changed files with 526 additions and 190 deletions

View file

@ -1,3 +1,20 @@
2000-03-17 Richard Frith-Macdonald <rfm@gnu.org>
Changed so that property lists are output in a compact form when
no locale is supplied.
* Documentation/gsdoc/NSObject.gsdoc: Added documentation of the
various description methods.
* GSDoc/gsdoc.m: Bugfixes for text in descriptions.
* Headers/gnustep/base/NSObject.h: Updated description methods
* Source/NSArray.m: Updated to be closer to MacOS description.
* Source/NSDictionary.m: ditto.
* Source/NSGCString.m: ditto.
* Source/NSGString.m: ditto.
* Source/NSObject.m: added more description methods.
* Tools/defaults.m: updated to use locale.
* Tools/dread.m: ditto.
* Tools/pldes.m: ditto.
Fri Mar 17 07:47:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Source/NSGString.m: Add checks to safely (and more efficiently)

View file

@ -57,8 +57,47 @@
<method type="NSString*" factory="yes">
<sel>description</sel>
<desc>
The <code>description</code> factory method describes the class
of the receiver. In the default GNUstep implementation, this
simply returns the name of the class as an NSString object.
</desc>
</method>
<method type="NSString*" factory="yes">
<sel>descriptionWithLocale:</sel>
<arg type="NSDictionary*">aLocale</arg>
<desc>
The default (NSOBject) implementation of this method simply calls
the <code>description</code> method and discards the locale
information.
</desc>
<standards><GNUstep/></standards>
</method>
<method type="NSString*" factory="yes">
<sel>descriptionWithLocale:</sel>
<arg type="NSDictionary*">aLocale</arg>
<sel>indent:</sel>
<arg type="unsigned int">level</arg>
<desc>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:</code> method and discards the
level information.
</desc>
<standards><GNUstep/></standards>
</method>
<method type="NSString*" factory="yes">
<sel>descriptionWithLocale:</sel>
<arg type="NSDictionary*">aLocale</arg>
<sel>indent:</sel>
<arg type="unsigned int">level</arg>
<sel>to:</sel>
<arg type="id&lt;GNUDescriptionDestination&gt;">output</arg>
<desc>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:indent:</code> method and appends
the value returned by that method to the output object.
</desc>
<standards><GNUstep/></standards>
</method>
<method type="void" factory="yes">
<sel>initialize</sel>
<desc>
@ -162,8 +201,60 @@
<method type="NSString*">
<sel>description</sel>
<desc>
<p>
The <code>description</code> method describes the reciever.
In the default GNUstep implementation, this returns an NSString
object giving the name of the class of the receiver and the
hexadecimal representation of the recievers address enclosed
in angle brackets.
</p>
<p>
Generally, classes other than NSObject will override this method
to provide a more informative description of their instances.
</p>
</desc>
</method>
<method type="NSString*">
<sel>descriptionWithLocale:</sel>
<arg type="NSDictionary*">aLocale</arg>
<desc>
The default (NSOBject) implementation of this method simply calls
the <code>description</code> method and discards the locale
information.
</desc>
<standards><GNUstep/></standards>
</method>
<method type="NSString*">
<sel>descriptionWithLocale:</sel>
<arg type="NSDictionary*">aLocale</arg>
<sel>indent:</sel>
<arg type="unsigned int">level</arg>
<desc>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:</code> method and discards the
level information.
</desc>
<standards><GNUstep/></standards>
</method>
<method type="NSString*">
<sel>descriptionWithLocale:</sel>
<arg type="NSDictionary*">aLocale</arg>
<sel>indent:</sel>
<arg type="unsigned int">level</arg>
<sel>to:</sel>
<arg type="id&lt;GNUDescriptionDestination&gt;">output</arg>
<desc>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:indent:</code> method and appends
the value returned by that method to the output object.
<p>
Property-list classes (NSString, NSArray, NSDictionary and
NSData) will override this method in order to efficiently
write descriptions of themselves into property lists.
</p>
</desc>
<standards><GNUstep/></standards>
</method>
<method type="void">
<sel>doesNotRecognizeSelector:</sel>
<arg type="SEL">aSelector</arg>

View file

@ -29,38 +29,44 @@
<li><a href="NSObject.html#method-4">+conformsToProtocol:</a>
<li><a href="NSObject.html#method-5">+copyWithZone:</a>
<li><a href="NSObject.html#method-6">+description</a>
<li><a href="NSObject.html#method-7">+initialize</a>
<li><a href="NSObject.html#method-8">+instanceMethodForSelector:</a>
<li><a href="NSObject.html#method-9">+instanceMethodSignatureForSelector:</a>
<li><a href="NSObject.html#method-10">+instancesRespondToSelector:</a>
<li><a href="NSObject.html#method-11">+load</a>
<li><a href="NSObject.html#method-12">+mutableCopyWithZone:</a>
<li><a href="NSObject.html#method-13">+new</a>
<li><a href="NSObject.html#method-14">+poseAsClass:</a>
<li><a href="NSObject.html#method-15">+setVersion:</a>
<li><a href="NSObject.html#method-16">+superclass</a>
<li><a href="NSObject.html#method-17">+version</a>
<li><a href="NSObject.html#method-18">-awakeAfterUsingCoder:</a>
<li><a href="NSObject.html#method-19">-classForArchiver</a>
<li><a href="NSObject.html#method-20">-classForCoder</a>
<li><a href="NSObject.html#method-21">-classForPortCoder</a>
<li><a href="NSObject.html#method-22">-connection:handleRequest:</a>
<li><a href="NSObject.html#method-23">-copy</a>
<li><a href="NSObject.html#method-24">-dealloc</a>
<li><a href="NSObject.html#method-25">-description</a>
<li><a href="NSObject.html#method-26">-doesNotRecognizeSelector:</a>
<li><a href="NSObject.html#method-27">-forwardInvocation:</a>
<li><a href="NSObject.html#method-28">-hash</a>
<li><a href="NSObject.html#method-29">-init</a>
<li><a href="NSObject.html#method-30">-isEqual:</a>
<li><a href="NSObject.html#method-31">-methodForSelector:</a>
<li><a href="NSObject.html#method-32">-methodSignatureForSelector:</a>
<li><a href="NSObject.html#method-33">-mutableCopy</a>
<li><a href="NSObject.html#method-34">-performSelector:withObject:</a>
<li><a href="NSObject.html#method-35">-performSelector:withObject:afterDelay:inModes:</a>
<li><a href="NSObject.html#method-36">-replacementObjectForArchiver:</a>
<li><a href="NSObject.html#method-37">-replacementObjectForCoder:</a>
<li><a href="NSObject.html#method-38">-replacementObjectForPortCoder:</a>
<li><a href="NSObject.html#method-7">+descriptionWithLocale:</a>
<li><a href="NSObject.html#method-8">+descriptionWithLocale:indent:</a>
<li><a href="NSObject.html#method-9">+descriptionWithLocale:indent:to:</a>
<li><a href="NSObject.html#method-10">+initialize</a>
<li><a href="NSObject.html#method-11">+instanceMethodForSelector:</a>
<li><a href="NSObject.html#method-12">+instanceMethodSignatureForSelector:</a>
<li><a href="NSObject.html#method-13">+instancesRespondToSelector:</a>
<li><a href="NSObject.html#method-14">+load</a>
<li><a href="NSObject.html#method-15">+mutableCopyWithZone:</a>
<li><a href="NSObject.html#method-16">+new</a>
<li><a href="NSObject.html#method-17">+poseAsClass:</a>
<li><a href="NSObject.html#method-18">+setVersion:</a>
<li><a href="NSObject.html#method-19">+superclass</a>
<li><a href="NSObject.html#method-20">+version</a>
<li><a href="NSObject.html#method-21">-awakeAfterUsingCoder:</a>
<li><a href="NSObject.html#method-22">-classForArchiver</a>
<li><a href="NSObject.html#method-23">-classForCoder</a>
<li><a href="NSObject.html#method-24">-classForPortCoder</a>
<li><a href="NSObject.html#method-25">-connection:handleRequest:</a>
<li><a href="NSObject.html#method-26">-copy</a>
<li><a href="NSObject.html#method-27">-dealloc</a>
<li><a href="NSObject.html#method-28">-description</a>
<li><a href="NSObject.html#method-29">-descriptionWithLocale:</a>
<li><a href="NSObject.html#method-30">-descriptionWithLocale:indent:</a>
<li><a href="NSObject.html#method-31">-descriptionWithLocale:indent:to:</a>
<li><a href="NSObject.html#method-32">-doesNotRecognizeSelector:</a>
<li><a href="NSObject.html#method-33">-forwardInvocation:</a>
<li><a href="NSObject.html#method-34">-hash</a>
<li><a href="NSObject.html#method-35">-init</a>
<li><a href="NSObject.html#method-36">-isEqual:</a>
<li><a href="NSObject.html#method-37">-methodForSelector:</a>
<li><a href="NSObject.html#method-38">-methodSignatureForSelector:</a>
<li><a href="NSObject.html#method-39">-mutableCopy</a>
<li><a href="NSObject.html#method-40">-performSelector:withObject:</a>
<li><a href="NSObject.html#method-41">-performSelector:withObject:afterDelay:inModes:</a>
<li><a href="NSObject.html#method-42">-replacementObjectForArchiver:</a>
<li><a href="NSObject.html#method-43">-replacementObjectForCoder:</a>
<li><a href="NSObject.html#method-44">-replacementObjectForPortCoder:</a>
</ul>
<hr>
<h2><a name="method-0">alloc</a></h2>
@ -96,164 +102,243 @@
<h2><a name="method-6">description</a></h2>
+ (NSString*) <b>description</b><br>
The <code>description</code> factory method describes the class
of the receiver. In the default GNUstep implementation, this
simply returns the name of the class as an NSString object.
<hr>
<h2><a name="method-7">initialize</a></h2>
<h2><a name="method-7">descriptionWithLocale:</a></h2>
+ (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)aLocale<br>
Standards: GNUstep<br>
The default (NSOBject) implementation of this method simply calls
the <code>description</code> method and discards the locale
information.
<hr>
<h2><a name="method-8">descriptionWithLocale:indent:</a></h2>
+ (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)aLocale <b>indent:</b> (unsigned int)level<br>
Standards: GNUstep<br>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:</code> method and discards the
level information.
<hr>
<h2><a name="method-9">descriptionWithLocale:indent:to:</a></h2>
+ (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)aLocale <b>indent:</b> (unsigned int)level <b>to:</b> (id&#60;GNUDescriptionDestination>)output<br>
Standards: GNUstep<br>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:indent:</code> method and appends
the value returned by that method to the output object.
<hr>
<h2><a name="method-10">initialize</a></h2>
+ (void) <b>initialize</b><br>
<hr>
<h2><a name="method-8">instanceMethodForSelector:</a></h2>
<h2><a name="method-11">instanceMethodForSelector:</a></h2>
+ (IMP) <b>instanceMethodForSelector:</b> (SEL)aSelector<br>
<hr>
<h2><a name="method-9">instanceMethodSignatureForSelector:</a></h2>
<h2><a name="method-12">instanceMethodSignatureForSelector:</a></h2>
+ (NSMethodSignature*) <b>instanceMethodSignatureForSelector:</b> (SEL)aSelector<br>
<hr>
<h2><a name="method-10">instancesRespondToSelector:</a></h2>
<h2><a name="method-13">instancesRespondToSelector:</a></h2>
+ (BOOL) <b>instancesRespondToSelector:</b> (SEL)aSelector<br>
<hr>
<h2><a name="method-11">load</a></h2>
<h2><a name="method-14">load</a></h2>
+ (void) <b>load</b><br>
<hr>
<h2><a name="method-12">mutableCopyWithZone:</a></h2>
<h2><a name="method-15">mutableCopyWithZone:</a></h2>
+ (id) <b>mutableCopyWithZone:</b> (NSZone*)zone<br>
<hr>
<h2><a name="method-13">new</a></h2>
<h2><a name="method-16">new</a></h2>
+ (id) <b>new</b><br>
<hr>
<h2><a name="method-14">poseAsClass:</a></h2>
<h2><a name="method-17">poseAsClass:</a></h2>
+ (void) <b>poseAsClass:</b> (Class)aClass<br>
<hr>
<h2><a name="method-15">setVersion:</a></h2>
<h2><a name="method-18">setVersion:</a></h2>
+ (void) <b>setVersion:</b> (int)aVersion<br>
<hr>
<h2><a name="method-16">superclass</a></h2>
<h2><a name="method-19">superclass</a></h2>
+ (Class) <b>superclass</b><br>
<hr>
<h2><a name="method-17">version</a></h2>
<h2><a name="method-20">version</a></h2>
+ (int) <b>version</b><br>
<hr>
<h2><a name="method-18">awakeAfterUsingCoder:</a></h2>
<h2><a name="method-21">awakeAfterUsingCoder:</a></h2>
- (id) <b>awakeAfterUsingCoder:</b> (NSCoder*)aDecoder<br>
<hr>
<h2><a name="method-19">classForArchiver</a></h2>
<h2><a name="method-22">classForArchiver</a></h2>
- (Class) <b>classForArchiver</b><br>
<hr>
<h2><a name="method-20">classForCoder</a></h2>
<h2><a name="method-23">classForCoder</a></h2>
- (Class) <b>classForCoder</b><br>
<hr>
<h2><a name="method-21">classForPortCoder</a></h2>
<h2><a name="method-24">classForPortCoder</a></h2>
- (Class) <b>classForPortCoder</b><br>
<hr>
<h2><a name="method-22">connection:handleRequest:</a></h2>
<h2><a name="method-25">connection:handleRequest:</a></h2>
- (BOOL) <b>connection:</b> (NSConnection*)connection <b>handleRequest:</b> (NSDistantObjectRequest*)doreq<br>
<hr>
<h2><a name="method-23">copy</a></h2>
<h2><a name="method-26">copy</a></h2>
- (id) <b>copy</b><br>
<hr>
<h2><a name="method-24">dealloc</a></h2>
<h2><a name="method-27">dealloc</a></h2>
- (void) <b>dealloc</b><br>
<hr>
<h2><a name="method-25">description</a></h2>
<h2><a name="method-28">description</a></h2>
- (NSString*) <b>description</b><br>
<p>
The <code>description</code> method describes the reciever.
In the default GNUstep implementation, this returns an NSString
object giving the name of the class of the receiver and the
hexadecimal representation of the recievers address enclosed
in angle brackets.
</p>
<p>
Generally, classes other than NSObject will override this method
to provide a more informative description of their instances.
</p>
<hr>
<h2><a name="method-26">doesNotRecognizeSelector:</a></h2>
<h2><a name="method-29">descriptionWithLocale:</a></h2>
- (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)aLocale<br>
Standards: GNUstep<br>
The default (NSOBject) implementation of this method simply calls
the <code>description</code> method and discards the locale
information.
<hr>
<h2><a name="method-30">descriptionWithLocale:indent:</a></h2>
- (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)aLocale <b>indent:</b> (unsigned int)level<br>
Standards: GNUstep<br>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:</code> method and discards the
level information.
<hr>
<h2><a name="method-31">descriptionWithLocale:indent:to:</a></h2>
- (NSString*) <b>descriptionWithLocale:</b> (NSDictionary*)aLocale <b>indent:</b> (unsigned int)level <b>to:</b> (id&#60;GNUDescriptionDestination>)output<br>
Standards: GNUstep<br>
The default (NSObject) implementation of this method simply calls
the <code>descriptionWithLocale:indent:</code> method and appends
the value returned by that method to the output object.
<p>
Property-list classes (NSString, NSArray, NSDictionary and
NSData) will override this method in order to efficiently
write descriptions of themselves into property lists.
</p>
<hr>
<h2><a name="method-32">doesNotRecognizeSelector:</a></h2>
- (void) <b>doesNotRecognizeSelector:</b> (SEL)aSelector<br>
<hr>
<h2><a name="method-27">forwardInvocation:</a></h2>
<h2><a name="method-33">forwardInvocation:</a></h2>
- (void) <b>forwardInvocation:</b> (NSInvocation*)anInvocation<br>
<hr>
<h2><a name="method-28">hash</a></h2>
<h2><a name="method-34">hash</a></h2>
- (unsigned int) <b>hash</b><br>
<hr>
<h2><a name="method-29">init</a></h2>
<h2><a name="method-35">init</a></h2>
- (id) <b>init</b><br>
<hr>
<h2><a name="method-30">isEqual:</a></h2>
<h2><a name="method-36">isEqual:</a></h2>
- (BOOL) <b>isEqual:</b> (id)anObject<br>
<hr>
<h2><a name="method-31">methodForSelector:</a></h2>
<h2><a name="method-37">methodForSelector:</a></h2>
- (IMP) <b>methodForSelector:</b> (SEL)aSelector<br>
<hr>
<h2><a name="method-32">methodSignatureForSelector:</a></h2>
<h2><a name="method-38">methodSignatureForSelector:</a></h2>
- (NSMethodSignature*) <b>methodSignatureForSelector:</b> (SEL)aSelector<br>
<hr>
<h2><a name="method-33">mutableCopy</a></h2>
<h2><a name="method-39">mutableCopy</a></h2>
- (id) <b>mutableCopy</b><br>
<hr>
<h2><a name="method-34">performSelector:withObject:</a></h2>
<h2><a name="method-40">performSelector:withObject:</a></h2>
- (void) <b>performSelector:</b> (SEL)aSelector <b>withObject:</b> (id)anArgument<br>
<hr>
<h2><a name="method-35">performSelector:withObject:afterDelay:inModes:</a></h2>
<h2><a name="method-41">performSelector:withObject:afterDelay:inModes:</a></h2>
- (void) <b>performSelector:</b> (SEL)aSelector <b>withObject:</b> (id)anArgument <b>afterDelay:</b> (NSTimeInterval)delay <b>inModes:</b> (NSArray*)modes<br>
<hr>
<h2><a name="method-36">replacementObjectForArchiver:</a></h2>
<h2><a name="method-42">replacementObjectForArchiver:</a></h2>
- (id) <b>replacementObjectForArchiver:</b> (NSArchiver*)anArchiver<br>
<hr>
<h2><a name="method-37">replacementObjectForCoder:</a></h2>
<h2><a name="method-43">replacementObjectForCoder:</a></h2>
- (id) <b>replacementObjectForCoder:</b> (NSCoder*)aCoder<br>
<hr>
<h2><a name="method-38">replacementObjectForPortCoder:</a></h2>
<h2><a name="method-44">replacementObjectForPortCoder:</a></h2>
- (id) <b>replacementObjectForPortCoder:</b> (NSPortCoder*)aCoder<br>

View file

@ -47,6 +47,7 @@
- (NSMutableDictionary*) indexForType: (NSString*)type;
- (id) initWithFileName: (NSString*)name;
- (NSString*) parseText: (xmlNodePtr)node;
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode;
@end
static xmlParserInputPtr
@ -213,6 +214,20 @@ loader(const char *url, const char* eid, xmlParserCtxtPtr *ctxt)
}
- (NSString*) parseText: (xmlNodePtr)node
{
xmlNodePtr endNode;
NSString *result;
result = [self parseText: node end: &endNode];
if (endNode != 0)
{
NSLog(@"Unexpected node type in text node - %d", endNode->type);
result = nil;
}
return result;
}
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode
{
return nil;
}
@ -250,7 +265,7 @@ loader(const char *url, const char* eid, xmlParserCtxtPtr *ctxt)
- (NSString*) parseMacro: (xmlNodePtr)node;
- (NSString*) parseMethod: (xmlNodePtr)node;
- (NSArray*) parseStandards: (xmlNodePtr)node;
- (NSString*) parseText: (xmlNodePtr)node;
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode;
- (void) setEntry: (NSString*)entry
withRef: (NSString*)ref
inIndexOfType: (NSString*)type;
@ -1261,7 +1276,8 @@ loader(const char *url, const char* eid, xmlParserCtxtPtr *ctxt)
}
else
{
[text appendString: [self parseText: node]];
[text appendString: [self parseText: node end: &node]];
continue;
}
node = node->next;
@ -1873,10 +1889,11 @@ loader(const char *url, const char* eid, xmlParserCtxtPtr *ctxt)
return nil;
}
- (NSString*) parseText: (xmlNodePtr)node
- (NSString*) parseText: (xmlNodePtr)node end: (xmlNodePtr*)endNode
{
NSMutableString *text = [NSMutableString string];
*endNode = node;
while (node != 0)
{
switch (node->type)
@ -1960,13 +1977,17 @@ loader(const char *url, const char* eid, xmlParserCtxtPtr *ctxt)
elem = ref;
[text appendFormat: @"<a href=\"%@\">%@</a>", ref, elem];
}
else
{
return text;
}
break;
default:
NSLog(@"Unexpected node type in text node - %d", node->type);
return nil;
return text;
}
node = node->next;
*endNode = node;
}
return text;
}

View file

@ -70,8 +70,8 @@
- autorelease;
- (oneway void) release;
- (unsigned) retainCount;
- (NSZone *) zone;
- (NSString *) description;
- (NSZone*) zone;
- (NSString*) description;
@end
@protocol NSCopying
@ -166,24 +166,40 @@ enum {NSNotFound = 0x7fffffff};
extern NSRecursiveLock *gnustep_global_lock;
/*
* The GNUDescriptionDestination protocol declares a single method used
* to append a property-list description string to some output destination
* The GNUDescriptionDestination protocol declares methods used to
* append a property-list description string to some output destination
* so that property-lists can be converted to strings in a stream avoiding
* the use of ridiculous amounts of memory for deeply nested data structures.
*/
@protocol GNUDescriptionDestination
- (void) appendFormat: (NSString*)str, ...;
- (void) appendString: (NSString*)str;
@end
@interface NSObject (GNU)
- (int) compare: anObject;
- (void) descriptionTo: (id<GNUDescriptionDestination>)output;
- (void) descriptionWithLocale: (NSDictionary*)aLocale
to: (id<GNUDescriptionDestination>)output;
- (int) compare: (id)anObject;
/*
* Default description methods -
* [descriptionWithLocale:] calls [description]
* [descriptionWithLocale:indent:] calls [descriptionWithLocale:]
* [descriptionWithLocale:indent:to:] calls [descriptionWithLocale:indent:]
* So - to have working descriptions, it is only necessary to implement the
* [description] method, and to have efficient property-list generation, it
* is necessary to override [descriptionWithLocale:indent:to:]
*/
- (NSString*) descriptionWithLocale: (NSDictionary*)aLocale;
+ (NSString*) descriptionWithLocale: (NSDictionary*)aLocale;
- (NSString*) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned)level;
+ (NSString*) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned)level;
- (void) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned)level
to: (id<GNUDescriptionDestination>)output;
- (Class)transmuteClassTo:(Class)aClassObject;
+ (void) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned)level
to: (id<GNUDescriptionDestination>)output;
- (Class) transmuteClassTo: (Class)aClassObject;
- subclassResponsibility: (SEL)aSel;
- shouldNotImplement: (SEL)aSel;
+ (Class) autoreleaseClass;

View file

@ -37,6 +37,7 @@
#include <Foundation/NSUtilities.h>
#include <Foundation/NSException.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSDebug.h>
#include <base/fast.x>
@ -626,26 +627,35 @@ static SEL rlSel = @selector(removeLastObject);
GS_RANGE_CHECK(aRange, c);
if (aRange.length == 0)
return [NSArray array];
{
na = [NSArray array];
}
else
{
id objects[aRange.length];
{
id objects[aRange.length];
[self getObjects: objects range: aRange];
na = [NSArray arrayWithObjects: objects count: aRange.length];
}
[self getObjects: objects range: aRange];
na = [NSArray arrayWithObjects: objects count: aRange.length];
}
return na;
}
- (NSEnumerator*) objectEnumerator
{
return AUTORELEASE([[NSArrayEnumerator allocWithZone: NSDefaultMallocZone()]
initWithArray: self]);
id e;
e = [NSArrayEnumerator allocWithZone: NSDefaultMallocZone()];
e = [e initWithArray: self];
return AUTORELEASE(e);
}
- (NSEnumerator*) reverseObjectEnumerator
{
return AUTORELEASE([[NSArrayEnumeratorReverse allocWithZone: NSDefaultMallocZone()] initWithArray: self]);
id e;
e = [NSArrayEnumeratorReverse allocWithZone: NSDefaultMallocZone()];
e = [e initWithArray: self];
return AUTORELEASE(e);
}
- (NSString*) description
@ -663,7 +673,8 @@ static SEL rlSel = @selector(removeLastObject);
{
NSMutableString *result;
result = AUTORELEASE([[NSGMutableCString alloc] initWithCapacity: 20*[self count]]);
result = [[NSGMutableCString alloc] initWithCapacity: 20*[self count]];
result = AUTORELEASE(result);
[self descriptionWithLocale: locale
indent: level
to: (id<GNUDescriptionDestination>)result];
@ -690,64 +701,85 @@ static NSString *indentStrings[] = {
indent: (unsigned int)level
to: (id<GNUDescriptionDestination>)result
{
NSString *iBaseString;
NSString *iSizeString;
unsigned count = [self count];
unsigned last = count - 1;
NSString *plists[count];
unsigned i;
IMP appImp;
appImp = [(NSObject*)result methodForSelector: appSel];
if (level < sizeof(indentStrings)/sizeof(NSString*))
iBaseString = indentStrings[level];
else
iBaseString = indentStrings[sizeof(indentStrings)/sizeof(NSString*)-1];
level++;
if (level < sizeof(indentStrings)/sizeof(NSString*))
iSizeString = indentStrings[level];
else
iSizeString = indentStrings[sizeof(indentStrings)/sizeof(NSString*)-1];
(*appImp)(result, appSel, @"(\n");
[self getObjects: plists];
for (i = 0; i < count; i++)
{
id item = plists[i];
(*appImp)(result, appSel, iSizeString);
if ([item respondsToSelector:
@selector(descriptionWithLocale:indent:)])
if (locale == nil)
{
(*appImp)(result, appSel, @"(");
for (i = 0; i < count; i++)
{
[item descriptionWithLocale: locale indent: level to: result];
}
else if ([item respondsToSelector:
@selector(descriptionWithLocale:)])
{
[item descriptionWithLocale: locale to: result];
}
else
{
[item descriptionTo: result];
}
if (i == count - 1)
{
(*appImp)(result, appSel, @"\n");
}
else
{
(*appImp)(result, appSel, @",\n");
id item = plists[i];
[item descriptionWithLocale: nil indent: 0 to: result];
if (i != last)
{
(*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 < count; i++)
{
id item = plists[i];
(*appImp)(result, appSel, iSizeString);
[item descriptionWithLocale: locale indent: level to: result];
if (i == last)
{
(*appImp)(result, appSel, @"\n");
}
else
{
(*appImp)(result, appSel, @",\n");
}
}
(*appImp)(result, appSel, iBaseString);
(*appImp)(result, appSel, @")");
}
(*appImp)(result, appSel, iBaseString);
(*appImp)(result, appSel, @")");
}
- (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile
{
return [[self description] writeToFile: path atomically: useAuxiliaryFile];
NSDictionary *loc;
NSString *desc;
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
desc = [self descriptionWithLocale: loc indent: 0];
return [desc writeToFile: path atomically: useAuxiliaryFile];
}
@end

View file

@ -176,6 +176,26 @@ static Class NSMutableAttributedString_concrete_class;
return nil;
}
- (NSString*) description
{
NSRange r = NSMakeRange(0, 0);
unsigned index = NSMaxRange(r);
unsigned length = [self length];
NSString *string = [self string];
NSDictionary *attrs;
NSMutableString *desc;
desc = AUTORELEASE([[super description] mutableCopy]);
while (index <= length &&
(attrs = [self attributesAtIndex: index effectiveRange: &r]) != nil)
{
index = NSMaxRange(r);
[desc appendFormat: @"\nRange: %@ Chars:'%@' Attrs: %@",
NSStringFromRange(r), [string substringFromRange: r], attrs];
}
return desc;
}
//Retrieving character information
- (unsigned int) length
{

View file

@ -32,6 +32,7 @@
#include <Foundation/NSException.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSFileManager.h>
#include <Foundation/NSUserDefaults.h>
#include <Foundation/NSDebug.h>
@interface NSDictionaryNonCore : NSDictionary
@ -577,12 +578,18 @@ compareIt(id o1, id o2, void* context)
- (BOOL) writeToFile: (NSString *)path atomically: (BOOL)useAuxiliaryFile
{
return [[self description] writeToFile: path atomically: useAuxiliaryFile];
NSDictionary *loc;
NSString *desc;
loc = [[NSUserDefaults standardUserDefaults] dictionaryRepresentation];
desc = [self descriptionWithLocale: loc indent: 0];
return [desc writeToFile: path atomically: useAuxiliaryFile];
}
- (NSString*) description
{
return [self descriptionWithLocale: nil];
return [self descriptionWithLocale: nil indent: 0];
}
- (NSString*) descriptionInStringsFileFormat
@ -601,11 +608,13 @@ compareIt(id o1, id o2, void* context)
id val = (*myObj)(self, objSel, key);
[key descriptionWithLocale: nil
indent: 0
to: (id<GNUDescriptionDestination>)result];
if (val != nil && [val isEqualToString: @""] == NO)
{
(*appImp)(result, appSel, @" = ");
[val descriptionWithLocale: nil
indent: 0
to: (id<GNUDescriptionDestination>)result];
}
(*appImp)(result, appSel, @";\n");
@ -654,8 +663,6 @@ static NSString *indentStrings[] = {
{
IMP myObj = [self methodForSelector: objSel];
BOOL canCompare = YES;
NSString *iBaseString;
NSString *iSizeString;
unsigned i;
NSArray *keyArray = [self allKeys];
unsigned numKeys = [keyArray count];
@ -666,16 +673,6 @@ static NSString *indentStrings[] = {
appImp = [(NSObject*)result methodForSelector: appSel];
if (level < sizeof(indentStrings)/sizeof(NSString*))
iBaseString = indentStrings[level];
else
iBaseString = indentStrings[sizeof(indentStrings)/sizeof(NSString*)-1];
level++;
if (level < sizeof(indentStrings)/sizeof(NSString*))
iSizeString = indentStrings[level];
else
iSizeString = indentStrings[sizeof(indentStrings)/sizeof(NSString*)-1];
[keyArray getObjects: keys];
for (i = 0; i < numKeys; i++)
{
@ -780,34 +777,57 @@ static NSString *indentStrings[] = {
plists[i] = (*myObj)(self, objSel, keys[i]);
}
(*appImp)(result, appSel, @"{\n");
for (i = 0; i < numKeys; i++)
if (locale == nil)
{
id item = plists[i];
(*appImp)(result, appSel, iSizeString);
[keys[i] descriptionTo: result];
(*appImp)(result, appSel, @" = ");
if ([item respondsToSelector: @selector(descriptionWithLocale:indent:)])
(*appImp)(result, appSel, @"{");
for (i = 0; i < numKeys; i++)
{
[item descriptionWithLocale: locale indent: level to: result];
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, @";");
}
else if ([item respondsToSelector: @selector(descriptionWithLocale:)])
(*appImp)(result, appSel, @"}");
}
else
{
NSString *iBaseString;
NSString *iSizeString;
if (level < sizeof(indentStrings)/sizeof(id))
{
[item descriptionWithLocale: locale to: result];
iBaseString = indentStrings[level];
}
else
{
[item descriptionTo: result];
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++)
{
id o = plists[i];
(*appImp)(result, appSel, iSizeString);
[keys[i] descriptionWithLocale: nil indent: 0 to: result];
(*appImp)(result, appSel, @" = ");
[o descriptionWithLocale: locale indent: level to: result];
(*appImp)(result, appSel, @";\n");
}
(*appImp)(result, appSel, iBaseString);
(*appImp)(result, appSel, @"}");
}
(*appImp)(result, appSel, iBaseString);
(*appImp)(result, appSel, @"}");
}
@end

View file

@ -595,7 +595,9 @@ static IMP msInitImp; /* designated initialiser for mutable */
return [self initWithCStringNoCopy: buf length: length fromZone: z];
}
- (void) descriptionTo: (id<GNUDescriptionDestination>)output
- (void) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned) level
to: (id<GNUDescriptionDestination>)output
{
if (output == nil)
return;

View file

@ -780,7 +780,7 @@ static BOOL deallocNotifications = NO;
- (NSString*) description
{
return [NSString stringWithFormat: @"<%s: %lx>",
object_get_class_name(self), (unsigned long)self];
object_get_class_name(self), (unsigned long)self];
}
+ (NSString*) description
@ -788,22 +788,40 @@ static BOOL deallocNotifications = NO;
return [NSString stringWithCString: object_get_class_name(self)];
}
- (void) descriptionTo: (id<GNUDescriptionDestination>)output
- (NSString*) descriptionWithLocale: (NSDictionary*)locale
{
[output appendString: [self description]];
return [self description];
}
- (void) descriptionWithLocale: (NSDictionary*)aLocale
to: (id<GNUDescriptionDestination>)output
+ (NSString*) descriptionWithLocale: (NSDictionary*)locale
{
[output appendString: [(id)self descriptionWithLocale: aLocale]];
return [self description];
}
- (NSString*) descriptionWithLocale: (NSDictionary*)locale indent: (unsigned)c
{
return [self descriptionWithLocale: locale];
}
+ (NSString*) descriptionWithLocale: (NSDictionary*)locale indent: (unsigned)c
{
return [self descriptionWithLocale: locale];
}
- (void) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned)level
to: (id<GNUDescriptionDestination>)output
{
[output appendString: [(id)self descriptionWithLocale: aLocale indent: level]];
[output appendString:
[(id)self descriptionWithLocale: aLocale indent: level]];
}
+ (void) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned)level
to: (id<GNUDescriptionDestination>)output
{
[output appendString:
[(id)self descriptionWithLocale: aLocale indent: level]];
}
+ (void) poseAsClass: (Class)aClassObject
@ -1273,7 +1291,7 @@ static BOOL deallocNotifications = NO;
double_release_check_enabled = enable;
}
- (int)compare:anotherObject;
- (int) compare: (id)anotherObject;
{
if ([self isEqual:anotherObject])
return 0;
@ -1285,34 +1303,34 @@ static BOOL deallocNotifications = NO;
return -1;
}
- (BOOL)isMetaClass
- (BOOL) isMetaClass
{
return NO;
}
- (BOOL)isClass
- (BOOL) isClass
{
return object_is_class(self);
}
- (BOOL)isInstance
- (BOOL) isInstance
{
return object_is_instance(self);
}
- (BOOL)isMemberOfClassNamed:(const char *)aClassName
- (BOOL) isMemberOfClassNamed: (const char*)aClassName
{
return ((aClassName!=NULL)
&&!strcmp(class_get_class_name(self->isa), aClassName));
}
+ (struct objc_method_description *)descriptionForInstanceMethod:(SEL)aSel
+ (struct objc_method_description *) descriptionForInstanceMethod: (SEL)aSel
{
return ((struct objc_method_description *)
class_get_instance_method(self, aSel));
}
- (struct objc_method_description *)descriptionForMethod:(SEL)aSel
- (struct objc_method_description *) descriptionForMethod: (SEL)aSel
{
return ((struct objc_method_description *)
(object_is_instance(self)
@ -1320,7 +1338,7 @@ static BOOL deallocNotifications = NO;
:class_get_class_method(self->isa, aSel)));
}
- (Class)transmuteClassTo:(Class)aClassObject
- (Class) transmuteClassTo: (Class)aClassObject
{
if (object_is_instance(self))
if (class_is_class(aClassObject))
@ -1334,7 +1352,7 @@ static BOOL deallocNotifications = NO;
return nil;
}
- subclassResponsibility:(SEL)aSel
- (id) subclassResponsibility: (SEL)aSel
{
[NSException
raise: NSGenericException
@ -1342,7 +1360,7 @@ static BOOL deallocNotifications = NO;
return nil;
}
- shouldNotImplement:(SEL)aSel
- (id) shouldNotImplement: (SEL)aSel
{
[NSException
raise: NSGenericException
@ -1351,7 +1369,7 @@ static BOOL deallocNotifications = NO;
return nil;
}
+ (int)streamVersion: (TypedStream*)aStream
+ (int) streamVersion: (TypedStream*)aStream
{
if (aStream->mode == OBJC_READONLY)
return objc_get_stream_class_version (aStream, self);

View file

@ -2264,7 +2264,9 @@ handle_printf_atsign (FILE *stream,
return [d writeToFile: filename atomically: useAuxiliaryFile];
}
- (void) descriptionTo: (id<GNUDescriptionDestination>)output
- (void) descriptionWithLocale: (NSDictionary*)aLocale
indent: (unsigned)level
to: (id<GNUDescriptionDestination>)output
{
if ([self length] == 0)
{
@ -2273,8 +2275,9 @@ handle_printf_atsign (FILE *stream,
}
if (quotables == nil)
setupQuotables();
{
setupQuotables();
}
if ([self rangeOfCharacterFromSet: quotables].length > 0)
{
const char *cstring = [self cString];

View file

@ -213,6 +213,8 @@ property list which is set as the value of a default.\n\n");
if ([[args objectAtIndex: i] isEqual: @"read"] ||
[[args objectAtIndex: i] isEqual: @"readkey"])
{
NSDictionary *locale = [defs dictionaryRepresentation];
if ([[args objectAtIndex: i] isEqual: @"read"])
{
if ([args count] == ++i)
@ -266,7 +268,8 @@ property list which is set as the value of a default.\n\n");
printf("%s %s '",
[domainName cString], [key cString]);
ptr = [[obj description] cString];
ptr = [[obj descriptionWithLocale: locale indent: 0]
cString];
while (*ptr)
{
if (*ptr == '\'')
@ -289,7 +292,8 @@ property list which is set as the value of a default.\n\n");
printf("%s %s '",
[domainName cString], [name cString]);
ptr = [[obj description] cString];
ptr = [[obj descriptionWithLocale: locale indent: 0]
cString];
while (*ptr)
{
if (*ptr == '\'')

View file

@ -38,6 +38,7 @@ main(int argc, char** argv)
NSString *name = nil;
NSString *user = nil;
BOOL found = NO;
NSDictionary *locale;
int i;
proc = [NSProcessInfo processInfo];
@ -169,6 +170,7 @@ main(int argc, char** argv)
/* We don't want dwrite in the defaults database - so remove it. */
[defs removePersistentDomainForName: [proc processName]];
locale = [defs dictionaryRepresentation];
domains = [defs persistentDomainNames];
for (i = 0; i < [domains count]; i++) {
NSString *domainName = [domains objectAtIndex: i];
@ -188,7 +190,8 @@ main(int argc, char** argv)
const char *ptr;
printf("%s %s '", [domainName cString], [key cString]);
ptr = [[obj description] cString];
ptr = [[obj descriptionWithLocale: locale indent: 0]
cString];
while (*ptr) {
if (*ptr == '\'') {
putchar('\'');
@ -206,7 +209,8 @@ main(int argc, char** argv)
const char *ptr;
printf("%s %s '", [domainName cString], [name cString]);
ptr = [[obj description] cString];
ptr = [[obj descriptionWithLocale: locale indent: 0]
cString];
while (*ptr) {
if (*ptr == '\'') {
putchar('\'');

View file

@ -53,6 +53,9 @@ main(int argc, char** argv)
}
else
{
NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];
NSDictionary *locale = [defs dictionaryRepresentation];
for (i = 1; i < [args count]; i++)
{
NSString *file = [args objectAtIndex: i];
@ -72,7 +75,7 @@ main(int argc, char** argv)
{
NSFileHandle *out;
myString = [result description];
myString = [result descriptionWithLocale: locale indent: 0];
out = [NSFileHandle fileHandleWithStandardOutput];
myData = [myString dataUsingEncoding: NSASCIIStringEncoding];
[out writeData: myData];