From bda35fceb3410591a51297fe442939a00da3f513 Mon Sep 17 00:00:00 2001
From: Adrian Robert On return, the function result is a flag indicating success (YES)
* or failure (NO), and on success, the value stored in size is the number
- * of characters in the converted string. The converted string itsself is
+ * of characters in the converted string. The converted string itself is
* stored in the location given by dst. Implementation of [NSCoder] capable of creating sequential archives which
+ * must be read in the same order they were written. This class implements
+ * methods for saving to and restoring from a serial archive (usually a file
+ * on disk, but can be an [NSData] object) as well as methods that can be
+ * used by objects that need to write/restore themselves. Note, the sibling class [NSKeyedArchiver] supports a form of archive
+ * that is more robust to class changes, and is recommended over this one.
- * This method is used in the GS_INITIALIZED_LOCK macro
- * to initialize lock variables when it cannot be insured
- * that they can be initialized in a thread safe environment.
- *
- * This method is used in the GS_INITIALIZED_LOCK macro
- * to initialize lock variables when it cannot be insured
- * that they can be initialized in a thread safe environment.
- *
* NB. If the value stored in dst has been changed, it is a pointer to
* allocated memory which the caller is responsible for freeing, and the
diff --git a/Source/GSString.m b/Source/GSString.m
index a5b942839..d17dbcf59 100644
--- a/Source/GSString.m
+++ b/Source/GSString.m
@@ -313,7 +313,7 @@ setup(void)
* The GSPlaceholderString class is used by the abstract cluster root
* class to provide temporary objects that will be replaced as soon
* as the objects are initialised. This object tries to replace
- * itsself with an appropriate object whose type may vary depending
+ * itself with an appropriate object whose type may vary depending
* on the initialisation method used.
*/
@implementation GSPlaceholderString
diff --git a/Source/GSTcpPort.m b/Source/GSTcpPort.m
index b7c563a23..0227ddc0a 100644
--- a/Source/GSTcpPort.m
+++ b/Source/GSTcpPort.m
@@ -1996,7 +1996,7 @@ static unsigned wordAlign;
header = [components objectAtIndex: 0];
/*
* The Item header contains the item type and the length of the
- * data in the item (excluding the item header itsself).
+ * data in the item (excluding the item header itself).
*/
hLength = [header length];
l = hLength - sizeof(GSPortItemHeader);
diff --git a/Source/NSArchiver.m b/Source/NSArchiver.m
index c011d0f7e..e6ad263c4 100644
--- a/Source/NSArchiver.m
+++ b/Source/NSArchiver.m
@@ -56,6 +56,16 @@ NSString * const NSInconsistentArchiveException =
#define PREFIX "GNUstep archive"
+/**
+ * encodeWithCoder:
as normal.
+ */
- (void) encodeClassName: (NSString*)trueName
intoClassName: (NSString*)inArchiveName
{
@@ -857,6 +899,9 @@ static Class NSMutableDataMallocClass;
}
}
+/**
+ * Set encoder to write out newObject in place of object.
+ */
- (void) replaceObject: (id)object
withObject: (id)newObject
{
@@ -886,14 +931,15 @@ static Class NSMutableDataMallocClass;
-/*
- * Catagories for compatibility with old GNUstep encoding.
+/**
+ * Catagory for compatibility with old GNUstep encoding.
*/
-
@implementation NSArchiver (GNUstep)
-/* Re-using an archiver */
-
+/**
+ * Allow reuse of archiver (clears class substitution maps, etc.) but
+ * do not clear out current serialized data.
+ */
- (void) resetArchiver
{
if (_clsMap)
@@ -937,11 +983,17 @@ static Class NSMutableDataMallocClass;
pointers: 0];
}
+/**
+ * Returns YES.
+ */
- (BOOL) directDataAccess
{
return YES;
}
+/**
+ * Writes out header for GNUstep archive format.
+ */
- (void) serializeHeaderAt: (unsigned)positionInData
version: (unsigned)systemVersion
classes: (unsigned)classCount
diff --git a/Source/NSArray.m b/Source/NSArray.m
index 7f160b31e..1b709bfb0 100644
--- a/Source/NSArray.m
+++ b/Source/NSArray.m
@@ -643,7 +643,7 @@ static SEL rlSel;
* which must contain an array in property-list format.
*
In GNUstep, the property-list format may be either the OpenStep - * format (ASCII data), or the MacOS-X format (URF8 XML data) ... this + * format (ASCII data), or the MacOS-X format (UTF-8 XML data) ... this * method will recognise which it is. *
*If there is a failure to load the file for any reason, the receiver
@@ -937,8 +937,8 @@ compare(id elem1, id elem2, void* context)
/**
* Returns an autoreleased array in which the objects are ordered
* according to a sort with comparator, where the comparator function
- * is passed two objects to compare, and the copntext as the third
- * argument.
+ * is passed two objects to compare, and the context as the third
+ * argument. The hint argument is currently ignored, and may be nil.
*/
- (NSArray*) sortedArrayUsingFunction: (NSComparisonResult(*)(id,id,void*))comparator
context: (void*)context
@@ -1243,6 +1243,10 @@ compare(id elem1, id elem2, void* context)
@end
+/**
+ * NSMutableArray
is the mutable version of [NSArray]. It
+ * provides methods for altering the contents of the array.
+ */
@implementation NSMutableArray
+ (void) initialize
@@ -1412,7 +1416,7 @@ compare(id elem1, id elem2, void* context)
}
/**
- * Removes all occurrances of anObject (found by pointer equality)
+ * Removes all occurrences of anObject (found by pointer equality)
* from the receiver.
*/
- (void) removeObjectIdenticalTo: (id)anObject
@@ -1447,7 +1451,7 @@ compare(id elem1, id elem2, void* context)
}
/**
- * Removes all occurrances of anObject (found by the -isEqual: method
+ * Removes all occurrences of anObject (found by the -isEqual: method
* of anObject) aRange in the receiver.
*/
- (void) removeObject: (id)anObject inRange: (NSRange)aRange
@@ -1547,7 +1551,7 @@ compare(id elem1, id elem2, void* context)
}
/**
- * Removes all occurrances of anObject (found by anObjects -isEqual: method)
+ * Removes all occurrences of anObject (found by anObjects -isEqual: method)
* from the receiver.
*/
- (void) removeObject: (id)anObject
@@ -1928,7 +1932,9 @@ compare(id elem1, id elem2, void* context)
}
@end
-
+/**
+ * [NSArray] enhancements provided by GNUstep.
+ */
@implementation NSArray (GNUstep)
/**
diff --git a/Source/NSAttributedString.m b/Source/NSAttributedString.m
index 2fa482f4f..2b09c1a0c 100644
--- a/Source/NSAttributedString.m
+++ b/Source/NSAttributedString.m
@@ -85,7 +85,13 @@ static IMP remDictImp;
+ (NSMutableString*) stringWithOwner: (NSMutableAttributedString*)as;
@end
-
+/**
+ * A string in which name-value pairs represented by an [NSDictionary] may
+ * be associated to ranges of characters. Used for text rendering by the
+ * GUI/AppKit framework, in which fonts, sizes, etc. are stored under standard
+ * attributes in the dictionaries.
+ *
+ */
@implementation NSAttributedString
static Class NSAttributedStringClass;
@@ -232,16 +238,26 @@ static Class GSMutableAttributedStringClass;
return [self initWithString: nil attributes: nil];
}
+/**
+ * Initialize to aString with no attributes.
+ */
- (id) initWithString: (NSString*)aString
{
return [self initWithString: aString attributes: nil];
}
+/**
+ * Initialize to copy of attributedString.
+ */
- (id) initWithAttributedString: (NSAttributedString*)attributedString
{
return [self initWithString: (NSString*)attributedString attributes: nil];
}
+/**
+ * Initialize to aString with given attributes applying over full range of
+ * string.
+ */
- (id) initWithString: (NSString*)aString attributes: (NSDictionary*)attributes
{
//This is the designated initializer
@@ -269,11 +285,17 @@ static Class GSMutableAttributedStringClass;
}
//Retrieving character information
+/**
+ * Return length of the underlying string.
+ */
- (unsigned int) length
{
return [[self string] length];
}
+/**
+ * Return the underlying string, stripped of attributes.
+ */
- (NSString*) string
{
[self subclassResponsibility: _cmd];/* Primitive method! */
@@ -281,6 +303,12 @@ static Class GSMutableAttributedStringClass;
}
//Retrieving attribute information
+/**
+ * Returns attributes and values at index, and, if effectiveRange
+ * is non-nil, this gets filled with a range over which these attributes
+ * and values still hold. This may not be the maximum range, depending
+ * on the implementation.
+ */
- (NSDictionary*) attributesAtIndex: (unsigned int)index
effectiveRange: (NSRange*)aRange
{
@@ -288,6 +316,11 @@ static Class GSMutableAttributedStringClass;
return nil;
}
+/**
+ * Returns attributes and values at index, and, if longestEffectiveRange
+ * is non-nil, this gets filled with the range over which the attribute-value
+ * set is the same as at index, clipped to rangeLimit.
+ */
- (NSDictionary*) attributesAtIndex: (unsigned int)index
longestEffectiveRange: (NSRange*)aRange
inRange: (NSRange)rangeLimit
@@ -337,6 +370,11 @@ static Class GSMutableAttributedStringClass;
return attrDictionary;
}
+/**
+ * Returns value for given attribute at index, and, if effectiveRange is
+ * non-nil, this gets filled with a range over which this value holds. This
+ * may not be the maximum range, depending on the implementation.
+ */
- (id) attribute: (NSString*)attributeName
atIndex: (unsigned int)index
effectiveRange: (NSRange*)aRange
@@ -362,6 +400,11 @@ static Class GSMutableAttributedStringClass;
return attrValue;
}
+/**
+ * Returns value for given attribute at index, and, if longestEffectiveRange
+ * is non-nil, this gets filled with the range over which the attribute
+ * applies, clipped to rangeLimit.
+ */
- (id) attribute: (NSString*)attributeName
atIndex: (unsigned int)index
longestEffectiveRange: (NSRange*)aRange
@@ -432,6 +475,10 @@ static Class GSMutableAttributedStringClass;
}
//Comparing attributed strings
+/**
+ * Returns whether all characters and attributes are equal between this
+ * string and otherString.
+ */
- (BOOL) isEqualToAttributedString: (NSAttributedString*)otherString
{
NSRange ownEffectiveRange,otherEffectiveRange;
@@ -492,6 +539,9 @@ static Class GSMutableAttributedStringClass;
//Extracting a substring
+/**
+ * Returns substring with attribute information.
+ */
- (NSAttributedString*) attributedSubstringFromRange: (NSRange)aRange
{
NSAttributedString *newAttrString;
@@ -537,6 +587,9 @@ static Class GSMutableAttributedStringClass;
return newAttrString;
}
+/**
+ * Synonym for [-attributedSubstringFromRange:].
+ */
- (NSAttributedString*) attributedSubstringWithRange: (NSRange)aRange
{
return [self attributedSubstringFromRange: aRange];
@@ -544,6 +597,9 @@ static Class GSMutableAttributedStringClass;
@end //NSAttributedString
+/**
+ * Mutable version of [NSAttributedString].
+ */
@implementation NSMutableAttributedString
+ (id) allocWithZone: (NSZone*)z
@@ -601,23 +657,35 @@ static Class GSMutableAttributedStringClass;
}
//Retrieving character information
+/**
+ * Returns mutable version of the underlying string.
+ */
- (NSMutableString*) mutableString
{
return [GSMutableAttributedStringTracker stringWithOwner: self];
}
//Changing characters
+/**
+ * Removes characters and attributes applying to them.
+ */
- (void) deleteCharactersInRange: (NSRange)aRange
{
[self replaceCharactersInRange: aRange withString: nil];
}
//Changing attributes
+/**
+ * Sets attributes to apply over range, replacing any previous attributes.
+ */
- (void) setAttributes: (NSDictionary*)attributes range: (NSRange)aRange
{
[self subclassResponsibility: _cmd];// Primitive method!
}
+/**
+ * Adds attribute applying to given range.
+ */
- (void) addAttribute: (NSString*)name value: (id)value range: (NSRange)aRange
{
NSRange effectiveRange;
@@ -664,6 +732,9 @@ static Class GSMutableAttributedStringClass;
}
}
+/**
+ * Add attributes to apply over given range.
+ */
- (void) addAttributes: (NSDictionary*)attributes range: (NSRange)aRange
{
NSRange effectiveRange;
@@ -721,6 +792,9 @@ static Class GSMutableAttributedStringClass;
}
}
+/**
+ * Removes given attribute from aRange.
+ */
- (void) removeAttribute: (NSString*)name range: (NSRange)aRange
{
NSRange effectiveRange;
@@ -768,12 +842,18 @@ static Class GSMutableAttributedStringClass;
}
//Changing characters and attributes
+/**
+ * Appends attributed string to end of this one, preserving attributes.
+ */
- (void) appendAttributedString: (NSAttributedString*)attributedString
{
[self replaceCharactersInRange: NSMakeRange([self length],0)
withAttributedString: attributedString];
}
+/**
+ * Inserts attributed string within this one, preserving attributes.
+ */
- (void) insertAttributedString: (NSAttributedString*)attributedString
atIndex: (unsigned int)index
{
@@ -781,6 +861,9 @@ static Class GSMutableAttributedStringClass;
withAttributedString: attributedString];
}
+/**
+ * Replaces substring and attributes.
+ */
- (void) replaceCharactersInRange: (NSRange)aRange
withAttributedString: (NSAttributedString*)attributedString
{
@@ -823,12 +906,19 @@ static Class GSMutableAttributedStringClass;
[self endEditing];
}
+/**
+ * Replaces substring; replacement is granted attributes equal to those of
+ * the first character of the portion replaced.
+ */
- (void) replaceCharactersInRange: (NSRange)aRange
withString: (NSString*)aString
{
[self subclassResponsibility: _cmd];// Primitive method!
}
+/**
+ * Replaces entire contents (so this object can be reused).
+ */
- (void) setAttributedString: (NSAttributedString*)attributedString
{
[self replaceCharactersInRange: NSMakeRange(0,[self length])
@@ -836,11 +926,17 @@ static Class GSMutableAttributedStringClass;
}
//Grouping changes
+/**
+ * Call before executing a collection of changes, for optimization.
+ */
- (void) beginEditing
{
//Overridden by subclasses
}
+/**
+ * Call after executing a collection of changes, for optimization.
+ */
- (void) endEditing
{
//Overridden by subclasses
diff --git a/Source/NSBitmapCharSet.m b/Source/NSBitmapCharSet.m
index 2a12032b8..fa1f3029e 100644
--- a/Source/NSBitmapCharSet.m
+++ b/Source/NSBitmapCharSet.m
@@ -36,7 +36,7 @@
return [self initWithBitmap: NULL];
}
-/* Designated initializer */
+/** Designated initializer */
- (id) initWithBitmap: (NSData*)bitmap
{
[super init];
diff --git a/Source/NSCalendarDate.m b/Source/NSCalendarDate.m
index 17c45b584..927ce0a26 100644
--- a/Source/NSCalendarDate.m
+++ b/Source/NSCalendarDate.m
@@ -2246,7 +2246,7 @@ static void Grow(DescriptionInfo *info, unsigned size)
@end
/**
- * Routines for manipulating Gregorian dates
+ * Routines for manipulating Gregorian dates.
*/
// The following code is based upon the source code in
// ``Calendrical Calculations'' by Nachum Dershowitz and Edward M. Reingold,
@@ -2288,7 +2288,7 @@ static void Grow(DescriptionInfo *info, unsigned size)
/**
- * Methods present in OpenStep but later removed from MacOS-X
+ * Methods present in OpenStep but later removed from MacOS-X.
*/
@implementation NSCalendarDate (OPENSTEP)
diff --git a/Source/NSCharacterSet.m b/Source/NSCharacterSet.m
index 781a677c1..01eff3a98 100644
--- a/Source/NSCharacterSet.m
+++ b/Source/NSCharacterSet.m
@@ -45,6 +45,10 @@ static NSCharacterSet *cache_set[MAX_STANDARD_SETS];
static NSLock *cache_lock = nil;
static Class abstractClass = nil;
+/**
+ * Represents a set of unicode characters. Used by [NSScanner] and [NSString]
+ * for parsing-related methods.
+ */
@implementation NSCharacterSet
+ (void) initialize
@@ -139,11 +143,19 @@ static Class abstractClass = nil;
}
+/**
+ * Returns a character set containing letters, numbers, and diacritical
+ * marks. Note that "letters" includes all alphabetic as well as Chinese
+ * characters, etc..
+ */
+ (NSCharacterSet*) alphanumericCharacterSet
{
return [self _bitmapForSet: @"alphanumericCharSet" number: 0];
}
+/**
+ * Returns a character set containing control and format characters.
+ */
+ (NSCharacterSet*) controlCharacterSet
{
return [self _bitmapForSet: @"controlCharSet" number: 1];
@@ -176,6 +188,10 @@ static Class abstractClass = nil;
return [self _bitmapForSet: @"illegalCharSet" number: 4];
}
+/**
+ * Returns a character set containing letters, including all alphabetic as
+ * well as Chinese characters, etc..
+ */
+ (NSCharacterSet*) letterCharacterSet
{
return [self _bitmapForSet: @"letterCharSet" number: 5];
@@ -191,16 +207,26 @@ static Class abstractClass = nil;
return [self _bitmapForSet: @"lowercaseLetterCharSet" number: 6];
}
+/**
+ * Returns a character set containing characters for diacritical marks, which
+ * are usually only rendered in conjunction with another character.
+ */
+ (NSCharacterSet*) nonBaseCharacterSet
{
return [self _bitmapForSet: @"nonBaseCharSet" number: 7];
}
+/**
+ * Returns a character set containing punctuation marks.
+ */
+ (NSCharacterSet*) punctuationCharacterSet
{
return [self _bitmapForSet: @"punctuationCharSet" number: 8];
}
+/**
+ * Returns a character set containing mathematical symbols, etc..
+ */
+ (NSCharacterSet*) symbolAndOperatorCharacterSet
{
return [self _bitmapForSet: @"symbolAndOperatorCharSet" number: 9];
@@ -244,6 +270,10 @@ static Class abstractClass = nil;
return AUTORELEASE([[NSBitmapCharSet alloc] initWithBitmap: data]);
}
+/**
+ * Returns set with characters in aString, or empty set for empty string.
+ * Raises an exception if given a nil string.
+ */
+ (NSCharacterSet*) characterSetWithCharactersInString: (NSString*)aString
{
unsigned i;
@@ -270,6 +300,9 @@ static Class abstractClass = nil;
return [self characterSetWithBitmapRepresentation: bitmap];
}
+/**
+ * Returns set containing unicode index range given by aRange.
+ */
+ (NSCharacterSet*)characterSetWithRange: (NSRange)aRange
{
unsigned i;
@@ -291,6 +324,12 @@ static Class abstractClass = nil;
return [self characterSetWithBitmapRepresentation: bitmap];
}
+/**
+ * Initializes from a bitmap. (See [NSBitmapCharSet].) File must have
+ * extension ".bitmap
". (To get around this load the file
+ * into data yourself and use
+ * [NSCharacterSet -characterSetWithBitmapRepresentation].
+ */
+ (NSCharacterSet*) characterSetWithContentsOfFile: (NSString*)aFile
{
if ([@"bitmap" isEqual: [aFile pathExtension]])
@@ -394,6 +433,9 @@ static Class abstractClass = nil;
@end
+/**
+ * An [NSCharacterSet] that can be modified.
+ */
@implementation NSMutableCharacterSet
/* Provide a default object for allocation */
@@ -408,37 +450,61 @@ static Class abstractClass = nil;
return AUTORELEASE([[NSMutableBitmapCharSet alloc] initWithBitmap: data]);
}
-/* Mutable subclasses must implement ALL of these methods. */
+/* Mutable subclasses must implement ALL of these methods. */
+
+/**
+ * Adds characters specified by unicode indices in aRange to set.
+ */
- (void) addCharactersInRange: (NSRange)aRange
{
[self subclassResponsibility: _cmd];
}
+/**
+ * Adds characters in aString to set.
+ */
- (void) addCharactersInString: (NSString*)aString
{
[self subclassResponsibility: _cmd];
}
+/**
+ * Set union of character sets.
+ */
- (void) formUnionWithCharacterSet: (NSCharacterSet*)otherSet
{
[self subclassResponsibility: _cmd];
}
+/**
+ * Set intersection of character sets.
+ */
- (void) formIntersectionWithCharacterSet: (NSCharacterSet*)otherSet
{
[self subclassResponsibility: _cmd];
}
+/**
+ * Drop given range of characters. No error for characters not currently in
+ * set.
+ */
- (void) removeCharactersInRange: (NSRange)aRange
{
[self subclassResponsibility: _cmd];
}
+/**
+ * Drop characters in aString. No error for characters not currently in
+ * set.
+ */
- (void) removeCharactersInString: (NSString*)aString
{
[self subclassResponsibility: _cmd];
}
+/**
+ * Remove all characters currently in set and add all other characters.
+ */
- (void) invert
{
[self subclassResponsibility: _cmd];
diff --git a/Source/NSClassDescription.m b/Source/NSClassDescription.m
index ef81306c7..efe717f34 100644
--- a/Source/NSClassDescription.m
+++ b/Source/NSClassDescription.m
@@ -30,19 +30,28 @@
#include "Foundation/NSNotification.h"
+/**
+ * Each instance of this class provides descriptive information for an
+ * Objective C class. This is used for key-value coding, a framework
+ * used in Cocoa for scripting with Objective-C objects. Scripting is
+ * available in GNUstep using Guile, however that implementation does
+ * not make use of class descriptions. Therefore the primary purpose
+ * of this class is to smooth the process of porting between GNUstep
+ * and other OpenStep-derived systems.
+ */
@implementation NSClassDescription
static NSRecursiveLock *mapLock = nil;
static NSMapTable *classMap;
/**
- * Returns the class descriptuion for aClass. If there is no such description
- * available, sends an NSClassDescriptionNeededForClassNotification (with
- * aClass as its object) so that objects providing class descriptions can
- * register one, and tries again to find one.
- * Returns nil if there is no description found.
- * Handles locking to ensure thread safety and ensures that the returned
- * object will not be destroyed by other threads.
+ * Returns the class description for aClass. If there is no such description
+ * available, sends an
+ * NSClassDescriptionNeededForClassNotification
(with aClass as
+ * its object) so that objects providing class descriptions can register one,
+ * and tries again to find one.
Returns nil if there is no description
+ * found.
Handles locking to ensure thread safety and ensures that the
+ * returned object will not be destroyed by other threads.
*/
+ (NSClassDescription*) classDescriptionForClass: (Class)aClass
{
diff --git a/Source/NSCoder.m b/Source/NSCoder.m
index 2610164b4..9a882c739 100644
--- a/Source/NSCoder.m
+++ b/Source/NSCoder.m
@@ -290,6 +290,8 @@
- (unsigned int) systemVersion
{
+ //PENDING(ABR)- should probably mult major version by 1000, not 100, since,
+ // e.g., 2.0.0 is going to be <1000
return (((GNUSTEP_BASE_MAJOR_VERSION * 100)
+ GNUSTEP_BASE_MINOR_VERSION) * 100) + GNUSTEP_BASE_SUBMINOR_VERSION;
}
diff --git a/Source/NSCountedSet.m b/Source/NSCountedSet.m
index 7eec11872..bfdf00752 100644
--- a/Source/NSCountedSet.m
+++ b/Source/NSCountedSet.m
@@ -50,13 +50,14 @@ static BOOL uniquing = NO;
/**
*
- * The NSCountedSet class is used to maintain a set of objects where
- * the number of times each object has been added (wiithout a
+ * The NSCountedSet
class is used to maintain a set of objects
+ * where the number of times each object has been added (without a
* corresponding removal) is kept track of.
*
- * In GNUstep, extra methods are provided to make use of a counted
- * set for uniquing objects easier.
+ * In GNUstep, the purge
and unique
methods
+ * are provided to make use of a counted set for uniquing objects
+ * easier.
*
- * This method removes from the set all objects whose count is - * less than or equal to the specified value. - *
- *- * This is useful where a counted set is used for uniquing objects. - * The set can be periodically purged of objects that have only - * been added once - and are therefore simply wasting space. - *
- */ - (void) purge: (int)level { if (level > 0) @@ -251,22 +241,6 @@ static Class NSCountedSet_concrete_class; } } -/** - *- * If the supplied object (or one equal to it as determined by - * the [-isEqual:] method) is already present in the set, the - * count for that object is incremented, the supplied object - * is released, and the object in the set is retained and returned. - * Otherwise, the supplied object is added to the set and returned. - *
- *
- * This method is useful for uniquing objects - the init method of
- * a class need simply end with -
- *
- * return [myUniquingSet unique: self];
- *
- *
Class for storing a byte array. Methods for initializing from memory a + * file, or the network are provided, as well as the ability to write to a + * file or the network. If desired, object can take over management of a + * pre-allocated buffer (with malloc or similar), free'ing it when deallocated. + *
+ *The data buffer at any given time has a capacity, which is the + * size of its allocated memory area, in bytes, and a length, which + * is the length of data it is currently storing.
+ */ @implementation NSData #if NEED_WORD_ALIGNMENT @@ -574,6 +585,11 @@ static unsigned gsu32Align; return self; } +/** + * Initialize with data pointing to contents of file at path. Bytes are + * only "swapped in" as needed. File should not be moved or deleted for + * the life of this object. + */ - (id) initWithContentsOfMappedFile: (NSString *)path { #ifdef HAVE_MMAP @@ -586,6 +602,10 @@ static unsigned gsu32Align; #endif } +/** + * Initialize with data pointing to contents of URL, which will be + * retrieved immediately in a blocking manner. + */ - (id) initWithContentsOfURL: (NSURL*)url { NSData *data = [url resourceDataUsingCache: YES]; @@ -593,6 +613,9 @@ static unsigned gsu32Align; return [self initWithData: data]; } +/** + * Initializes by copying data's bytes into a new buffer. + */ - (id) initWithData: (NSData*)data { if (data == nil) @@ -620,6 +643,9 @@ static unsigned gsu32Align; return NULL; } +/** + * Returns a short description of this object. + */ - (NSString*) description { extern void GSPropertyListMake(id,NSDictionary*,BOOL,BOOL,unsigned,id*); @@ -987,11 +1013,19 @@ failure: // Deserializing Data +/** + * Copies data from buffer starting from cursor. Deprecated. + * Use [-getBytes:] and related methods instead. + */ - (unsigned int) deserializeAlignedBytesLengthAtCursor: (unsigned int*)cursor { return (unsigned)[self deserializeIntAtCursor: cursor]; } +/** + * Copies data from buffer starting from cursor. Deprecated. + * Use [-getBytes:] and related methods instead. + */ - (void) deserializeBytes: (void*)buffer length: (unsigned int)bytes atCursor: (unsigned int*)cursor @@ -1289,6 +1323,10 @@ failure: } } +/** + * Retrieve an int from this data, which is assumed to be in network + * (big-endian) byte order. Cursor refers to byte position. + */ - (int) deserializeIntAtCursor: (unsigned int*)cursor { unsigned ni, result; @@ -1298,6 +1336,10 @@ failure: return result; } +/** + * Retrieve an int from this data, which is assumed to be in network + * (big-endian) byte order. Index refers to byte position. + */ - (int) deserializeIntAtIndex: (unsigned int)index { unsigned ni, result; @@ -1307,6 +1349,11 @@ failure: return result; } +/** + * Retrieve ints from intBuffer, which is assumed to be in network (big-endian) + * byte order. Count refers to number of ints, but index refers to byte + * position. + */ - (void) deserializeInts: (int*)intBuffer count: (unsigned int)numInts atCursor: (unsigned int*)cursor @@ -1320,6 +1367,11 @@ failure: intBuffer[i] = NSSwapBigIntToHost(intBuffer[i]); } +/** + * Retrieve ints from intBuffer, which is assumed to be in network (big-endian) + * byte order. Count refers to number of ints, but index refers to byte + * position. + */ - (void) deserializeInts: (int*)intBuffer count: (unsigned int)numInts atIndex: (unsigned int)index @@ -1369,7 +1421,14 @@ failure: @end +/** + * Provides some shared-memory extensions to [NSData]. + */ @implementation NSData (GNUstepExtensions) + +/** + * New instance with given shared memory ID. + */ + (id) dataWithShmID: (int)anID length: (unsigned int)length { #ifdef HAVE_SHMCTL @@ -1384,6 +1443,9 @@ failure: #endif } +/** + * New instance with given bytes in shared memory. + */ + (id) dataWithSharedBytes: (const void*)bytes length: (unsigned int)length { NSData *d; @@ -1463,6 +1525,10 @@ failure: @end +/** + * Mutable version of [NSData]. Methods are provided for appending and + * replacing bytes in the buffer, which will be grown as needed. + */ @implementation NSMutableData + (id) allocWithZone: (NSZone*)z { @@ -1505,6 +1571,10 @@ failure: return AUTORELEASE(d); } +/** + * New instance with buffer of given numBytes with length of valid data set + * to zero. Note that capacity will be automatically increased as necessary. + */ + (id) dataWithCapacity: (unsigned int)numBytes { NSMutableData *d; @@ -1552,6 +1622,12 @@ failure: return AUTORELEASE(d); } +/** + * New instance with buffer of capacity and valid data size equal to given + * length in bytes. The buffer contents are set to zero. The length of + * valid data is set to zero. Note that buffer will be automatically + * increased as necessary. + */ + (id) dataWithLength: (unsigned int)length { NSMutableData *d; @@ -1590,6 +1666,11 @@ failure: } } +/** + * Initialize with buffer capable of holding size bytes. The length of valid + * data is initially set to zero. + *NSDate
object encapsulates a constant date/time to a high
+ * resolution represented by the NSTimeInterval
typedef.
+ * NSDate
has methods relating to times and time differences in
+ * the abstract, but not calendar dates or time zones. These features are
+ * added in the [NSCalendarDate] subclass. The [NSTimeZone] class handles time
+ * zone information.
*/
@implementation NSDate
@@ -1338,6 +1341,9 @@ GSTimeNow(void)
return NO;
}
+/**
+ * Returns whether equal to other within one NSTimeInterval
unit.
+ */
- (BOOL) isEqualToDate: (NSDate*)other
{
if (other == nil)
diff --git a/Source/NSDecimal.m b/Source/NSDecimal.m
index e086356f6..09fd38659 100644
--- a/Source/NSDecimal.m
+++ b/Source/NSDecimal.m
@@ -37,7 +37,7 @@
/*
This file provides two implementations of the NSDecimal functions.
One is based on pure simple decimal mathematics, as we all learned it
- in school. This version is rather slow and may be inexact in the extrem
+ in school. This version is rather slow and may be inexact in the extreme
cases.
THIS IS TESTED AND WORKING.
@@ -48,7 +48,7 @@
The data structure used for NSDecimals is a bit strange. It also does not
correspond to the description in the OpenStep specification. But this is
- not consistent, so a decission had to be made.
+ not consistent, so a decision had to be made.
The mantissa part (I know D. Knuth does not like this term, but it is used
in the specification so we stay with it) consists of up to 38 digits, this
are stored as an integer (in decimal representation or limps depending on the
@@ -72,7 +72,7 @@ typedef struct {
BOOL isNegative; /* Is this negative? */
BOOL validNumber; /* Is this a valid number? */
unsigned char length; /* digits in mantissa. */
- unsigned char cMantissa[2*NSDecimalMaxDigit]; /* Make this big enought for multiplication */
+ unsigned char cMantissa[2*NSDecimalMaxDigit]; /* Make this big enough for multiplication */
} GSDecimal;
static NSDecimal zero = {0, NO, YES, 0, {0}};
@@ -84,6 +84,15 @@ static NSDecimal one = {0, NO, YES, 1, {1}};
#else
// Make GSDecimal a synonym of NSDecimal
+/**
+typedef struct {
+ signed char exponent; // Signed exponent - -128 to 127
+ BOOL isNegative; // Is this negative?
+ BOOL validNumber; // Is this a valid number?
+ unsigned char length; // digits in mantissa.
+ unsigned char cMantissa[2*NSDecimalMaxDigit];
+}
+
*/
typedef NSDecimal GSDecimal;
static NSDecimal zero = {0, NO, YES, 0, {0}};
diff --git a/Source/NSDecimalNumber.m b/Source/NSDecimalNumber.m
index 54d9adfc1..9284d8ff9 100644
--- a/Source/NSDecimalNumber.m
+++ b/Source/NSDecimalNumber.m
@@ -30,6 +30,7 @@
#include "Foundation/NSDecimalNumber.h"
#include "GSPrivate.h"
+// shared default behavior for NSDecimalNumber class
static NSDecimalNumberHandler *handler;
@implementation NSDecimalNumberHandler
diff --git a/Source/NSDictionary.m b/Source/NSDictionary.m
index e9c5b557e..954f40a3d 100644
--- a/Source/NSDictionary.m
+++ b/Source/NSDictionary.m
@@ -43,6 +43,27 @@
#include "GNUstepBase/GSCategories.h"
#include "GSPrivate.h"
+/**
+ * This class and its subclasses store key-value pairs, where the key and + * the value are objects. A great many utility methods for working with + * dictionaries are provided as part of this class, including the ability to + * retrieve multiple entries simultaneously, obtain sorted contents, and + * read/write from/to a serialized representation.
+ * + *Both keys and values are retained by the implementation, and released + * when either their entry is dropped or the entire dictionary is deallocated. + * This differs from the implementation on OS X, where keys are copied instead + * of being retained and must therefore implement the [NSCopying] protocol.
+ * + *Objects of this class are immutable. For a mutable version, use the + * [NSMutableDictionary] subclass.
+ * + *The basic functionality in NSDictionary
is similar to that
+ * in Java's HashMap
, and like that class it includes no locking
+ * code and is not thread-safe. If the contents will be modified and
+ * accessed from multiple threads you should enclose critical operations
+ * within locks (see [NSLock]).
In GNUstep, the property-list format may be either the OpenStep - * format (ASCII data), or the MacOS-X format (URF8 XML data) ... this + * format (ASCII data), or the MacOS-X format (UTF-8 XML data) ... this * method will recognise which it is. *
*If there is a failure to load the file for any reason, the receiver @@ -531,7 +570,7 @@ static SEL appSel; * which must contain a dictionary in property-list format. *
*In GNUstep, the property-list format may be either the OpenStep - * format (ASCII data), or the MacOS-X format (URF8 XML data) ... this + * format (ASCII data), or the MacOS-X format (UTF-8 XML data) ... this * method will recognise which it is. *
*If there is a failure to load the URL for any reason, the receiver
@@ -610,6 +649,12 @@ static SEL appSel;
return NO;
}
+/**
+ * Two dictionaries are equal if they each hold the same number of
+ * entries, each key in one isEqual
to a key in the other,
+ * and, for a given key, the corresponding value objects also satisfy
+ * isEqual
.
+ */
- (BOOL) isEqualToDictionary: (NSDictionary*)other
{
unsigned count;
@@ -764,6 +809,14 @@ compareIt(id o1, id o2, void* context)
return (int)[o1 performSelector: f->s withObject: o2];
}
+/**
+ * Returns ordered array of the keys sorted according to the values they
+ * correspond to. To sort the values, a message with selector comp is
+ * send to each value with another value as argument, as in
+ * [a comp: b]
. The comp method should return
+ * NSOrderedSame
, NSOrderedAscending
, or
+ * NSOrderedDescending
as appropriate.
+ */
- (NSArray*) keysSortedByValueUsingSelector: (SEL)comp
{
struct foo info;
@@ -776,6 +829,12 @@ compareIt(id o1, id o2, void* context)
return k;
}
+/**
+ * Multiple version of [-objectForKey:]. Objects for each key in keys are
+ * looked up and placed into return array in same order. For each key that
+ * has no corresponding value in this dictionary, marker is put into the
+ * array in its place.
+ */
- (NSArray*) objectsForKeys: (NSArray*)keys notFoundMarker: (id)marker
{
unsigned c = [keys count];
@@ -978,6 +1037,10 @@ compareIt(id o1, id o2, void* context)
}
@end
+
+/**
+ * Mutable version of [NSDictionary].
+ */
@implementation NSMutableDictionary
+ (void) initialize
@@ -1037,23 +1100,46 @@ compareIt(id o1, id o2, void* context)
return NSMutableDictionaryClass;
}
-/* This is the designated initializer */
+/**
+ * Initializes an empty dictionary with memory preallocated for given number
+ * of entries. Although memory space will be grown as needed when entries
+ * are added, this can avoid the reallocate-and-copy process if the size of
+ * the ultimate contents is known in advance.
+ *
The NSDistributedNotificationCenter provides a versatile yet + *
The NSDistributedNotificationCenter
provides a versatile yet
* simple mechanism for objects in different processes to communicate
- * effectively while knowing very little about each others internals.
+ * effectively while knowing very little about each others' internals.
* A distributed notification center acts much like a normal
* notification center, but it handles notifications on a machine-wide
* (or local network wide) basis rather than just notifications within
@@ -76,7 +76,7 @@ NSString *GSNetworkNotificationCenterType =
*
Since posting of distributed notifications involves inter-process
* (and sometimes inter-host) communication, it is fundamentally slower
* than normal notifications, and should be used relatively sparingly.
- * In order to help with this, the NSDistributedNotificationCenter
+ * In order to help with this, the NSDistributedNotificationCenter
* provides a notion of 'suspension', whereby a center can be suspended
* causing notifications for observers in the process where the center
* was suspended to cease receiving notifications. Observers can
@@ -86,19 +86,19 @@ NSString *GSNetworkNotificationCenterType =
*
Distributed notifications are mediated by a server process which
* handles all notifications for a particular center type. In GNUstep
- * this process is the gdnc tool, and when started without special
+ * this process is the gdnc
tool, and when started without special
* options, a gdnc process acts as the local centre for the host it is
- * running on. When started with the GSNetwork user default set to YES,
- * the gdnc tool acts as a local network wide server (you should only
- * run one copy of gdnc like this on your LAN).
- * The gdnc process should be started at machine boot time, but GNUstep
- * will attempt to start it automatically if it can't find it.
+ * running on. When started with the GSNetwork
user default set
+ * to YES, the gdnc
tool acts as a local network wide server (you
+ * should only run one copy of gdnc
like this on your LAN).
+ * The gdnc
process should be started at machine boot time, but
+ * GNUstep will attempt to start it automatically if it can't find it.
*
MacOS-X currently defines only a notification center for the
* local host. GNUstep also defines a local network center which can
* be used from multiple hosts. By default the system sends this to
* any gdnc process it can find which is configured as a network-wide
- * server, but the GDNCHost user default may be used to specify a
+ * server, but the GDNCHost
user default may be used to specify a
* particular host to be contacted ... this may be of use where you
* wish to have logically separate clusters of machines on a shared LAN.
*
NSLocalNotificationCenterType
as its argument.
*/
+ (id) defaultCenter
{
@@ -128,11 +128,11 @@ static NSDistributedNotificationCenter *netCenter = nil;
/**
* Returns a notification center of the specified type.NSLocalNotificationCenterType
provides a shared access to
* a notificatiuon center used by processes on the local host.GSNetworkNotificationCenterType
provides a shared access to
* a notificatiuon center used by processes on the local network.NSLocalNotificationCenterType
.
*/
+ (id) notificationCenterForType: (NSString*)type
{
@@ -225,7 +225,7 @@ static NSDistributedNotificationCenter *netCenter = nil;
/**
* Adds an observer to the receiver. Calls
* -addObserver:selector:name:object:suspensionBehavior: with
- * NSNotificationSuspensionBehaviorCoalesce.
+ * NSNotificationSuspensionBehaviorCoalesce
.
*/
- (void) addObserver: (id)anObserver
selector: (SEL)aSelector
@@ -248,23 +248,23 @@ static NSDistributedNotificationCenter *netCenter = nil;
* when the process to which the notification should be delivered is
* suspended:
* NSNotificationSuspensionBehaviorDrop
NSNotificationSuspensionBehaviorCoalesce
NSNotificationSuspensionBehaviorHold
NSNotificationSuspensionBehaviorDeliverImmediately
gdnc
server locally.
*/
h = [NSHost hostWithName: host];
if (h == nil)
diff --git a/Source/NSEnumerator.m b/Source/NSEnumerator.m
index 82d0bd541..aebdfd80d 100644
--- a/Source/NSEnumerator.m
+++ b/Source/NSEnumerator.m
@@ -29,8 +29,15 @@
#include "Foundation/NSUtilities.h"
#include "Foundation/NSArray.h"
+/**
+ * Simple class for iterating over a collection of objects, usually returned
+ * from an [NSArray] or similar.
+ */
@implementation NSEnumerator
+/**
+ * Returns all objects remaining in the enumeration as an array.
+ */
- (NSArray*) allObjects
{
NSMutableArray *array;
@@ -54,6 +61,10 @@
return array;
}
+/**
+ * Returns next object in enumeration, or nil if none remain. Use code like
+ * while (object = [enumerator nextObject]) { ... }
.
+ */
- (id) nextObject
{
[self subclassResponsibility:_cmd];
diff --git a/Source/NSException.m b/Source/NSException.m
index 98f2a75b5..73d1a3912 100644
--- a/Source/NSException.m
+++ b/Source/NSException.m
@@ -40,7 +40,7 @@ NSString* const NSGenericException
= @"NSGenericException";
/**
- * An exception for caes where unexpected state is detected within an object
+ * An exception for cases where unexpected state is detected within an object.
*/
NSString* const NSInternalInconsistencyException
= @"NSInternalInconsistencyException";
@@ -53,7 +53,7 @@ NSString* const NSInvalidArgumentException
= @"NSInvalidArgumentException";
/**
- * An exception used when the system faols to allocate required memory.
+ * An exception used when the system fails to allocate required memory.
*/
NSString* const NSMallocException
= @"NSMallocException";
@@ -120,15 +120,16 @@ _NSFoundationUncaughtExceptionHandler (NSException *exception)
/**
- The NSException class helps manage errors in a program. It provides
- a mechanism for lower-level methods to provide information about
+ The NSException
class helps manage errors in a program. It
+ provides a mechanism for lower-level methods to provide information about
problems to higher-level methods, which more often than not, have a
better ability to decide what to do about the problems.
Exceptions are typically handled by enclosing a sensitive section
- of code inside the macros NS_DURING and NS_HANDLER, and then
- handling any problems after this, up to the NS_ENDHANDLER macro:
+ of code inside the macros NS_DURING
and NS_HANDLER
,
+ and then handling any problems after this, up to the
+ NS_ENDHANDLER
macro:
- The local variable localException is the name of the exception
- object you can use in the NS_HANDLER section.
- The easiest way to cause an exeption is using the +raise:format:,...
+ The local variable localException
is the name of the exception
+ object you can use in the NS_HANDLER
section.
+ The easiest way to cause an exception is using the +raise:format:,...
method.
- * NSFileHandler is a Class that provides a wrapper for accessing
- * system files and other connections. You can open connections to a
+ * NSFileHandle
is a class that provides a wrapper for accessing
+ * system files and socket connections. You can open connections to a
* file using class methods such as +fileHandleForReadingAtPath:.
*
- * GNUstep extends the use of this Class to allow you to create
+ * GNUstep extends the use of this class to allow you to create
* network connections (sockets), secure connections and also allows
* you to use compression with these files and connections (as long as
* GNUstep Base was compiled with the zlib library).
@@ -88,7 +88,7 @@ static Class NSFileHandle_ssl_class = nil;
// Allocating and Initializing a FileHandle Object
/**
- * Returns an NSFileHandle object setup for reading from the
+ * Returns an NSFileHandle
object set up for reading from the
* file listed at path. If the file does not exist or cannot
* be opened for some other reason, nil is returned.
*/
@@ -100,7 +100,7 @@ static Class NSFileHandle_ssl_class = nil;
}
/**
- * Returns an NSFileHandle object setup for writing to the
+ * Returns an NSFileHandle
object set up for writing to the
* file listed at path. If the file does not exist or cannot
* be opened for some other reason, nil is returned.
*/
@@ -112,7 +112,7 @@ static Class NSFileHandle_ssl_class = nil;
}
/**
- * Returns an NSFileHandle object setup for updating (reading and
+ * Returns an NSFileHandle
object setup for updating (reading and
* writing) from the file listed at path. If the file does not exist
* or cannot be opened for some other reason, nil is returned.
*/
@@ -124,9 +124,9 @@ static Class NSFileHandle_ssl_class = nil;
}
/**
- * Returns an NSFileHandle object for the standard error descriptor.
- * The returned object is a shared instance as there can only be one
- * standard error per process.
+ * Returns an NSFileHandle
object for the standard error
+ * descriptor. The returned object is a shared instance as there can only be
+ * one standard error per process.
*/
+ (id) fileHandleWithStandardError
{
@@ -136,9 +136,9 @@ static Class NSFileHandle_ssl_class = nil;
}
/**
- * Returns an NSFileHandle object for the standard input descriptor.
- * The returned object is a shared instance as there can only be one
- * standard input per process.
+ * Returns an NSFileHandle
object for the standard input
+ * descriptor. The returned object is a shared instance as there can only be
+ * one standard input per process.
*/
+ (id) fileHandleWithStandardInput
{
@@ -148,9 +148,9 @@ static Class NSFileHandle_ssl_class = nil;
}
/**
- * Returns an NSFileHandle object for the standard output descriptor.
- * The returned object is a shared instance as there can only be one
- * standard output per process.
+ * Returns an NSFileHandle
object for the standard output
+ * descriptor. The returned object is a shared instance as there can only be
+ * one standard output per process.
*/
+ (id) fileHandleWithStandardOutput
{
@@ -173,17 +173,29 @@ static Class NSFileHandle_ssl_class = nil;
return AUTORELEASE([o initWithNullDevice]);
}
+/**
+ * Initialize with desc, which can point to either a regular file or
+ * socket connection.
+ */
- (id) initWithFileDescriptor: (int)desc
{
return [self initWithFileDescriptor: desc closeOnDealloc: NO];
}
+/**
+ * Initialize with desc, which can point to either a regular file or
+ * socket connection. Close desc when this instance is deallocated if
+ * flag is YES.
+ */
- (id) initWithFileDescriptor: (int)desc closeOnDealloc: (BOOL)flag
{
[self subclassResponsibility: _cmd];
return nil;
}
+/**
+ * Windows-Unix compatibility support.
+ */
- (id) initWithNativeHandle: (void*)hdl
{
return [self initWithNativeHandle: hdl closeOnDealloc: NO];
@@ -191,6 +203,10 @@ static Class NSFileHandle_ssl_class = nil;
// This is the designated initializer.
+/**
+ * NSFileHandleOperationException
if problem encountered.
+ */
- (NSData*) availableData
{
[self subclassResponsibility: _cmd];
return nil;
}
+/**
+ * Reads up to maximum unsigned int bytes from file or communications
+ * channel into return data.
+ */
- (NSData*) readDataToEndOfFile
{
[self subclassResponsibility: _cmd];
return nil;
}
+/**
+ * Reads up to len bytes from file or communications channel into return data.
+ */
- (NSData*) readDataOfLength: (unsigned int)len
{
[self subclassResponsibility: _cmd];
return nil;
}
+/**
+ * Synchronously writes given data item to file or connection.
+ */
- (void) writeData: (NSData*)item
{
[self subclassResponsibility: _cmd];
@@ -239,11 +278,32 @@ static Class NSFileHandle_ssl_class = nil;
// Asynchronous I/O operations
+/**
+ * Asynchronously accept a stream-type socket connection and act as the
+ * (server) end of the communications channel. This instance should have
+ * been created by -initWithFileDescriptor: with a stream-type socket created
+ * by the appropriate system routine. Posts a
+ * NSFileHandleConnectionAcceptedNotification
when connection
+ * initiated, returning an NSFileHandle
for the client side with
+ * that notification.
+ */
- (void) acceptConnectionInBackgroundAndNotify
{
[self acceptConnectionInBackgroundAndNotifyForModes: nil];
}
+/**
+ *
Asynchronously accept a stream-type socket connection and act as the
+ * (server) end of the communications channel. This instance should have
+ * been created by -initWithFileDescriptor: with a stream-type socket created
+ * by the appropriate system routine. Posts a
+ * NSFileHandleConnectionAcceptedNotification
when connection
+ * initiated, returning an NSFileHandle
for the client side with
+ * that notification.
The modes array specifies [NSRunLoop] modes that the notification can + * be posted in.
+ */ - (void) acceptConnectionInBackgroundAndNotifyForModes: (NSArray*)modes { [self subclassResponsibility: _cmd]; @@ -305,18 +365,30 @@ static Class NSFileHandle_ssl_class = nil; // Seeking within a file +/** + * Return current position in file, or raises exception if instance does + * not represent a regular file. + */ - (unsigned long long) offsetInFile { [self subclassResponsibility: _cmd]; return 0; } +/** + * Position file pointer at end of file, raising exception if instance does + * not represent a regular file. + */ - (unsigned long long) seekToEndOfFile { [self subclassResponsibility: _cmd]; return 0; } +/** + * Position file pointer at pos, raising exception if instance does + * not represent a regular file. + */ - (void) seekToFileOffset: (unsigned long long)pos { [self subclassResponsibility: _cmd]; @@ -325,16 +397,27 @@ static Class NSFileHandle_ssl_class = nil; // Operations on file +/** + * Disallows further reading from read-access files or connections, and sends + * EOF on write-access files or connections. Descriptor is only + * deleted when this instance is deallocated. + */ - (void) closeFile { [self subclassResponsibility: _cmd]; } +/** + * Flush in-memory buffer to file or connection, then return. + */ - (void) synchronizeFile { [self subclassResponsibility: _cmd]; } +/** + * Chops file beyond pos then sets file pointer to that point. + */ - (void) truncateFileAtOffset: (unsigned long long)pos { [self subclassResponsibility: _cmd]; @@ -365,12 +448,19 @@ NSString * const NSFileHandleReadToEndOfFileCompletionNotification // Exceptions +/** + * An exception used when a file error occurs. + */ NSString * const NSFileHandleOperationException = @"NSFileHandleOperationException"; // GNUstep class extensions +/** + * A set of convenience methods for utilizing the socket communications + * capabilities of the [NSFileHandle] class. + */ @implementation NSFileHandle (GNUstepExtensions) /** diff --git a/Source/NSFileManager.m b/Source/NSFileManager.m index 0cd0517fb..8d7e8ab3c 100644 --- a/Source/NSFileManager.m +++ b/Source/NSFileManager.m @@ -230,7 +230,11 @@ @end /* NSFileManager (PrivateMethods) */ /** - * This is the main class for management of the local filesystem. + * This is the main class for platform-independent management of the local + * filesystem, which allows you to read and save files, create/list + * directories, and move or delete files and directories. In addition to + * simply listing directories, you may obtain an [NSDirectoryEnumerator] + * instance for recursive directory contents enumeration. */ @implementation NSFileManager @@ -1378,54 +1382,54 @@ static NSFileManager* defaultManager = nil; /** * If a file (or directory etc) exists at the specified path, and can be - * queriesd for its attributes, this method returns a dictionary containing + * queried for its attributes, this method returns a dictionary containing * the various attributes of that file. Otherwise nil is returned.* The dictionary keys for attributes are - *
*NSFileAppendOnly
NSFileCreationDate
NSFileDeviceIdentifier
NSFileExtensionHidden
NSFileGroupOwnerAccountName
NSFileGroupOwnerAccountID
NSFileHFSCreatorCode
NSFileHFSTypeCode
NSFileImmutable
NSFileModificationDate
NSFileOwnerAccountName
NSFileOwnerAccountID
NSFilePosixPermissions
NSFileReferenceCount
NSFileSize
NSFileSystemFileNumber
NSFileSystemNumber
NSFileType
- * The NSDictionary class also has a set of accessor methods which - * enable you to get at file attribute information more efficiently + * The [NSDictionary] class also has a set of convenience accessor methods + * which enable you to get at file attribute information more efficiently * than using the keys above to extract it. You should generally * use the accessor methods where they are available. *
@@ -1461,15 +1465,15 @@ static NSFileManager* defaultManager = nil; * Returns a dictionary containing the filesystem attributes for the * specified path (or nil if the path is not valid).NSFileSystemSize
NSFileSystemFreeSize
NSFileSystemNodes
NSFileSystemFreeNodes
NSFileSystemNumber
This is a subclass of NSEnumerator
which provides a full
+ * listing of all the files beneath a directory and its subdirectories.
+ * Instances can be obtained through [NSFileManager-enumeratorAtPath:],
+ * or through an initializer in this class. (For compatibility with OS X,
+ * use the NSFileManager
method.)
This implementation is optimized and performance should be comparable + * to the speed of standard Unix tools for large directories.
+ */ +@implementation NSDirectoryEnumerator +/* * The Objective-C interface hides a traditional C implementation. * This was the only way I could get near the speed of standard unix * tools for big directories. */ -@implementation NSDirectoryEnumerator - + (void) initialize { if (self == [NSDirectoryEnumerator class]) @@ -2031,11 +2042,21 @@ static SEL swfsSel = 0; // Initializing +/** + * Initialize instance to enumerate contents at path, which should be a + * directory and can be specified in relative or absolute, and may include + * Unix conventions like '~
' for user home directory, which will
+ * be appropriately converted on Windoze systems. The justContents flag, if
+ * set, is equivalent to recurseIntoSubdirectories = NO and followSymlinks =
+ * NO, but the implementation will be made more efficient.
+ */
- (id) initWithDirectoryPath: (NSString*)path
recurseIntoSubdirectories: (BOOL)recurse
followSymlinks: (BOOL)follow
justContents: (BOOL)justContents
{
+//TODO: the justContents flag is currently basically useless and should be
+// removed
DIR *dir_pointer;
const char *topPath;
@@ -2177,6 +2198,8 @@ static SEL swfsSel = 0;
return_file_name = append_file_to_path(dir.path, dirbuf->d_name);
/* TODO - can this one can be removed ? */
+ /* ... seems like it can... */
+ /* also, what if justContents=YES *and* isRecursive=YES? */
if (!_flags.justContents)
{
_current_file_path = append_file_to_path(_top_path,
@@ -2250,10 +2273,9 @@ static SEL swfsSel = 0;
@end /* NSDirectoryEnumerator */
-/*
- * Attributes dictionary access
+/**
+ * Convenience methods for accessing named file attributes in a dictionary.
*/
-
@implementation NSDictionary(NSFileAttributes)
/**
@@ -2272,11 +2294,17 @@ static SEL swfsSel = 0;
return [[self objectForKey: NSFileExtensionHidden] boolValue];
}
+/**
+ * Returns HFS creator attribute (OS X).
+ */
- (int) fileHFSCreatorCode
{
return [[self objectForKey: NSFileHFSCreatorCode] intValue];
}
+/**
+ * Returns HFS type code attribute (OS X).
+ */
- (int) fileHFSTypeCode
{
return [[self objectForKey: NSFileHFSTypeCode] intValue];
diff --git a/Source/NSHashTable.m b/Source/NSHashTable.m
index 7d7e81bd7..5e0b3f23a 100644
--- a/Source/NSHashTable.m
+++ b/Source/NSHashTable.m
@@ -183,7 +183,9 @@ NSCountHashTable(NSHashTable *table)
/**
* Create a new hash table by calling NSCreateHashTableWithZone() using
- * NSDefaultMallocZone().The NSInvocation class implements a mechanism of constructing - * messages (as NSInvocation instances), sending these to other + *
The NSInvocation
class implements a mechanism of constructing
+ * messages (as NSInvocation
instances), sending these to other
* objects, and handling the returned values.
*
An NSInvocation object may contain a target object to which a + *
An NSInvocation
object may contain a target object to which a
* message can be sent, or may send the message to an arbitrary object.
* Each message consists of a selector for that method and an argument
* list. Once the message has been sent, the invocation will contain
@@ -78,8 +78,8 @@ static Class NSInvocation_concrete_class;
* object to which it was sent.
*
Related to the class are two convenience macros ... NS_MESSAGE() - * and NS_INVOCATION() to allow easy construction of invocations with - * all the arguments set up. + * and NS_INVOCATION() ... to allow easy construction of invocations + * with all the arguments set up. *
*/ @implementation NSInvocation @@ -717,7 +717,7 @@ _arg_addr(NSInvocation *inv, int index) /** * Provides some minor extensions and some utility methods to aid - * integration of NSInvocation with the ObjectiveC runtime. + * integration ofNSInvocation
with the Objective-C runtime.
*/
@implementation NSInvocation (GNUstep)
@@ -903,7 +903,7 @@ _arg_addr(NSInvocation *inv, int index)
/**
* Sets the flag to tell the invocation that it should actually invoke a
* method in the superclass of the target rather than the method of the
- * target itsself.NSLock
is used in multi-threaded applications to protect
+ * critical pieces of code. While one thread holds a lock within a piece of
+ * code, another thread cannot execute that code until the first thread has
+ * given up its hold on the lock. The limitation of NSLock
is
+ * that you can only lock an NSLock
once and it must be unlocked
+ * before it can be aquired again.Represents a notification for posting to an [NSNotificationCenter]. + * Consists of a name, an object, and an optional dictionary. The + * notification center will check for observers registered to receive + * either notifications with the name, the object, or both and pass the + * notification instance on to them.
+ *This class is actually the interface for a class cluster, so instances + * will be of a (private) subclass.
+ */ @implementation NSNotification static Class abstractClass = 0; @@ -55,8 +64,7 @@ static Class concreteClass = 0; } /** - * Create a new autoreleased notification. Concrete subclasses override - * this method to create actual notification objects. + * Create a new autoreleased notification. */ + (NSNotification*) notificationWithName: (NSString*)name object: (id)object @@ -81,8 +89,7 @@ static Class concreteClass = 0; /** * The abstract class implements a copy as a simple retain ... - * subclasses should override this to perform more intelligent - * copy operations. + * subclasses override to perform more intelligent copy operations. */ - (id) copyWithZone: (NSZone*)zone { @@ -112,8 +119,7 @@ static Class concreteClass = 0; } /** - * Concrete subclasses of NSNotification are responsible for - * implementing this method to return the notification name. + * Returns the notification name. */ - (NSString*) name { @@ -122,8 +128,7 @@ static Class concreteClass = 0; } /** - * Concrete subclasses of NSNotification are responsible for - * implementing this method to return the notification object. + * Returns the notification object. */ - (id) object { @@ -132,8 +137,7 @@ static Class concreteClass = 0; } /** - * Concrete subclasses of NSNotification are responsible for - * implementing this method to return the notification user information. + * Returns the notification user information. */ - (NSDictionary*) userInfo { diff --git a/Source/NSNotificationCenter.m b/Source/NSNotificationCenter.m index f7617a55a..a827945e0 100644 --- a/Source/NSNotificationCenter.m +++ b/Source/NSNotificationCenter.m @@ -37,7 +37,7 @@ /** - * Concrete class implementing NSNotification + * Concrete class implementing NSNotification. */ @interface GSNotification : NSNotification { @@ -539,6 +539,24 @@ purgeMapNode(GSIMapTable map, GSIMapNode node, id observer) +/** + *GNUstep provides a framework for sending messages between objects within
+ * a process called notifications. Objects register with an
+ * NSNotificationCenter
to be informed whenever other objects
+ * post [NSNotification]s to it matching certain criteria. The notification
+ * center processes notifications synchronously -- that is, control is only
+ * returned to the notification poster once every recipient of the
+ * notification has received it and processed it. Asynchronous processing is
+ * possible using an [NSNotificationQueue].
Obtain an instance using the +defaultCenter method.
+ * + *In a multithreaded process, notifications are always sent on the thread + * that they are posted from.
+ * + *Use the [NSDistributedNotificationCenter] for interprocess + * communications on the same machine.
+ */ @implementation NSNotificationCenter /* The default instance, most often the only one created. @@ -564,6 +582,11 @@ static NSNotificationCenter *default_center = nil; } } +/** + * Returns the default notification center being used for this task (process). + * This is used for all notifications posted by the Base library unless + * otherwise noted. + */ + (NSNotificationCenter*) defaultCenter { return default_center; @@ -599,6 +622,21 @@ static NSNotificationCenter *default_center = nil; /* Adding new observers. */ +/** + *Registers observer to receive notifications with the name + * notificationName and/or containing object (one or both of these two must be + * non-nil; nil acts like a wildcard). When a notification of name name + * containing object is posted, observer receives a selector message with this + * notification as the argument. The notification center waits for the + * observer to finish processing the message, then informs the next registree + * matching the notification, and after all of this is done, control returns + * to the poster of the notification. Therefore the processing in the + * selector implementation should be short.
+ * + *The notification center does not retain observer or object. Therefore, + * you should always send removeObserver: or removeObserver:name:object: to + * the notification center before releasing these objects.
+ */ - (void) addObserver: (id)observer selector: (SEL)selector name: (NSString*)name @@ -710,6 +748,14 @@ static NSNotificationCenter *default_center = nil; unlockNCTable(TABLE); } +/** + * Deregisters observer for notifications matching name and/or object. If + * either or both is nil, they act like wildcards. The observer may still + * remain registered for other notifications; use -removeObserver: to remove + * it from all. If observer is nil, the effect is to remove all registrees + * for the specified notifications, unless both observer and name are nil, in + * which case nothing is done. + */ - (void) removeObserver: (id)observer name: (NSString*)name object: (id)object @@ -866,9 +912,10 @@ static NSNotificationCenter *default_center = nil; unlockNCTable(TABLE); } -/* Remove all records pertaining to OBSERVER. For instance, this - should be called before the OBSERVER is -dealloc'ed. */ - +/** + * Deregisters observer from all notifications. This should be called before + * the observer is deallocated. +*/ - (void) removeObserver: (id)observer { if (observer == nil) diff --git a/Source/NSNotificationQueue.m b/Source/NSNotificationQueue.m index 8af75ae6f..67a69668e 100644 --- a/Source/NSNotificationQueue.m +++ b/Source/NSNotificationQueue.m @@ -284,8 +284,22 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification, forModes: (NSArray*)modes; @end +/** + * This class supports asynchronous posting of [NSNotification]s to an + * [NSNotificationCenter]. The method to add a notification to the queue + * returns immediately. The queue will periodically post its oldest + * notification to the notification center. In a multithreaded process, + * notifications are always sent on the thread that they are posted from. + */ @implementation NSNotificationQueue + +/** + * Returns the default notification queue for use in this thread. It will + * always post notifications to the default notification center (for the + * entire task, which may have multiple threads and therefore multiple + * notification queues). + */ + (NSNotificationQueue*) defaultQueue { NotificationQueueList *list; @@ -309,6 +323,10 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification, [NSNotificationCenter defaultCenter]]; } +/** + * Initialize a new instance to post notifications to the given + * notificationCenter (instead of the default). + */ - (id) initWithNotificationCenter: (NSNotificationCenter*)notificationCenter { _zone = [self zone]; @@ -361,6 +379,17 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification, /* Inserting and Removing Notifications From a Queue */ +/** + * Immediately remove all notifications from queue matching notification on + * name and/or object as specified by coalesce mask, which is an OR + * ('|
') of the options
+ * NSNotificationCoalescingOnName
,
+ * NSNotificationCoalescingOnSender
(object), and
+ * NSNotificationNoCoalescing
(match only the given instance
+ * exactly). If both of the first options are specified, notifications must
+ * match on both attributes (not just either one). Removed notifications are
+ * not posted.
+ */
- (void) dequeueNotificationsMatching: (NSNotification*)notification
coalesceMask: (unsigned int)coalesceMask
{
@@ -378,6 +407,7 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
for (item = _asapQueue->tail; item; item = next)
{
next = item->next;
+ //PENDING: should object comparison be '==' instead of isEqual?!
if ((object == item->object) && [name isEqual: item->name])
{
remove_from_queue(_asapQueue, item, _zone);
@@ -447,6 +477,12 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
}
}
+/**
+ * Sets notification to be posted to notification center at time dependent on
+ * postingStyle, which may be either NSPostNow
(synchronous post),
+ * NSPostASAP
(post soon), or NSPostWhenIdle
(post
+ * when runloop is idle).
+ */
- (void) enqueueNotification: (NSNotification*)notification
postingStyle: (NSPostingStyle)postingStyle
{
@@ -457,6 +493,17 @@ add_to_queue(NSNotificationQueueList *queue, NSNotification *notification,
forModes: nil];
}
+/**
+ * Sets notification to be posted to notification center at time dependent on
+ * postingStyle, which may be either NSPostNow
(synchronous
+ * post), NSPostASAP
(post soon), or NSPostWhenIdle
+ * (post when runloop is idle). coalesceMask determines whether this
+ * notification should be considered same as other ones already on the queue,
+ * in which case they are removed through a call to
+ * -dequeueNotificationsMatching:coalesceMask: . The modes argument
+ * determines which [NSRunLoop] mode notification may be posted in (nil means
+ * all modes).
+ */
- (void) enqueueNotification: (NSNotification*)notification
postingStyle: (NSPostingStyle)postingStyle
coalesceMask: (unsigned int)coalesceMask
diff --git a/Source/NSNumber.m b/Source/NSNumber.m
index 287b8ff99..0cc255036 100644
--- a/Source/NSNumber.m
+++ b/Source/NSNumber.m
@@ -803,50 +803,11 @@ static Class doubleNumberClass;
return NSCopyObject(self, 0, zone);
}
-/**
- * Returns the string representation of this number using a non-localised
- * conversion (decimal point is '.' irrespective of the locale).
- */
- (NSString*) description
{
return [self descriptionWithLocale: nil];
}
-/**
- * - * Produces a string representation of the number. For a boolean - * this will be either 'true' or 'false'. For other numbers the - * format is produced using the initWithFormat:locale:... method - * of NSString, and the format depends on the type of number as - * follows - - *
- *
* NSObject
is the root class (a root class is
- * a class with no superclass) of the gnustep base library
+ * a class with no superclass) of the GNUstep base library
* class hierarchy, so all classes normally inherit from
* NSObject
. There is an exception though:
* NSProxy
(which is used for remote messaging)
@@ -792,16 +792,16 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
* your own classes should inherit (directly or indirectly)
* from NSObject
(or in special cases from
* NSProxy
). NSObject
provides
- * the basic common functionality shared by all gnustep
+ * the basic common functionality shared by all GNUstep
* classes and objects.
*
* The essential methods which must be implemented by all
- * classes for their instances to be usable within gnustep
+ * classes for their instances to be usable within GNUstep
* are declared in a separate protocol, which is the
* NSObject
protocol. Both
* NSObject
and NSProxy
conform to
- * this protocol, which means all objects in a gnustep
+ * this protocol, which means all objects in a GNUstep
* application will conform to this protocol (btw, if you
* don't find a method of NSObject
you are
* looking for in this documentation, make sure you also
@@ -813,7 +813,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
* implement a new root class. If you do, you need to make
* sure that your root class conforms (at least) to the
* NSObject
protocol, otherwise it will not
- * interact correctly with the gnustep framework. Said
+ * interact correctly with the GNUstep framework. Said
* that, I must note that I have never seen a case in which
* a new root class is needed.
*
[self class]
(no
+ * substitution).
+ */
- (Class) classForCoder
{
return [self class];
}
+/**
+ * Override to substitute class when an instance is being serialized by an
+ * [NSPortCoder]. Default implementation returns -classForCoder .
+ */
- (Class) classForPortCoder
{
return [self classForCoder];
}
+// FIXME - should this be added (as in OS X) now that we have NSKeyedArchiver?
+// - (id) replacedmentObjectForKeyedArchiver: (NSKeyedArchiver *)keyedArchiver
+// {
+// return [self replacementObjectForCoder: (NSArchiver *)keyedArchiver];
+// }
+
+/**
+ * Override to substitute another object for this instance when being archived
+ * by given [NSArchiver]. Default implementation returns
+ * -replacementObjectForCoder:.
+ */
- (id) replacementObjectForArchiver: (NSArchiver*)anArchiver
{
return [self replacementObjectForCoder: (NSCoder*)anArchiver];
}
+/**
+ * Override to substitute another object for this instance when being
+ * serialized by given [NSCoder]. Default implementation returns
+ * self
.
+ */
- (id) replacementObjectForCoder: (NSCoder*)anEncoder
{
return self;
@@ -1943,7 +1991,9 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
}
/**
- * Returns the version number of the receiving class.
+ * Returns the version number of the receiving class. This will default to
+ * a number assigned by the Objective C compiler if [NSObject -setVersion] has
+ * not been called.
*/
+ (int) version
{
@@ -1951,7 +2001,7 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
}
/**
- * Sets the version number of the receiving class.
+ * Sets the version number of the receiving class. Should be nonnegative.
*/
+ (id) setVersion: (int)aVersion
{
@@ -1966,10 +2016,16 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
@end
+/**
+ * Methods for compatibility with the NEXTSTEP (pre-OpenStep) 'Object' class.
+ */
@implementation NSObject (NEXTSTEP)
/* NEXTSTEP Object class compatibility */
+/**
+ * Logs a message. Deprecated. Use NSLog() in new code.
+ */
- (id) error: (const char *)aString, ...
{
#define FMT "error: %s (%s)\n%s\n"
@@ -2088,6 +2144,10 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
+/**
+ * Some non-standard extensions mainly needed for backwards compatibility
+ * and internal utility reasons.
+ */
@implementation NSObject (GNUstep)
/* GNU Object class compatibility */
@@ -2263,24 +2323,37 @@ GSDescriptionForClassMethod(pcl self, SEL aSel)
return class_get_version (self);
}
-// These are used to write or read the instance variables
-// declared in this particular part of the object. Subclasses
-// should extend these, by calling [super read/write: aStream]
-// before doing their own archiving. These methods are private, in
-// the sense that they should only be called from subclasses.
+//NOTE: original comments included the following excerpt, however it is
+// probably not relevant now since the implementations are stubbed out.
+// Subclasses should extend these, by calling
+// [super read/write: aStream] before doing their own archiving. These
+// methods are private, in the sense that they should only be called from
+// subclasses.
+/**
+ * Originally used to read the instance variables declared in this
+ * particular part of the object from a stream. Currently stubbed out.
+ */
- (id) read: (TypedStream*)aStream
{
// [super read: aStream];
return self;
}
+/**
+ * Originally used to write the instance variables declared in this
+ * particular part of the object to a stream. Currently stubbed out.
+ */
- (id) write: (TypedStream*)aStream
{
// [super write: aStream];
return self;
}
+/**
+ * Originally used before [NSCoder] and related classes existed. Currently
+ * stubbed out.
+ */
- (id) awake
{
// [super awake];
diff --git a/Source/NSPort.m b/Source/NSPort.m
index c671f8050..1af30182a 100644
--- a/Source/NSPort.m
+++ b/Source/NSPort.m
@@ -39,6 +39,10 @@
@implementation NSPort
+/**
+ * Exception raised if a timeout occurs during a port send or receive
+ * operation.
+ */
NSString * const NSPortTimeoutException = @"NSPortTimeoutException";
Class NSPort_abstract_class;
diff --git a/Source/NSProcessInfo.m b/Source/NSProcessInfo.m
index a71354e71..a8f883dc6 100644
--- a/Source/NSProcessInfo.m
+++ b/Source/NSProcessInfo.m
@@ -145,9 +145,17 @@ Please report the error to bug-gnustep@gnu.org.\n\n"
}
@end
+
/*************************************************************************
*** NSProcessInfo implementation
*************************************************************************/
+
+/**
+ * Instances of this class encapsulate information on the current process.
+ * For example, you can get the arguments, environment variables, host name,
+ * or process name. There is only one instance per process, for obvious
+ * reasons, and it may be obtained through the +processInfo method.
+ */
@implementation NSProcessInfo
/*************************************************************************
*** Static global vars
@@ -912,6 +920,10 @@ int main(int argc, char *argv[], char *env[])
@end
+/**
+ * Provides GNUstep-specific methods for controlled debug logging (a GNUstep
+ * facility) and an internal/developer-related method.
+ */
@implementation NSProcessInfo (GNUstep)
static BOOL debugTemporarilyDisabled = NO;
diff --git a/Source/NSProtocolChecker.m b/Source/NSProtocolChecker.m
index 742190ea6..c2d892734 100644
--- a/Source/NSProtocolChecker.m
+++ b/Source/NSProtocolChecker.m
@@ -33,6 +33,23 @@
#include "Foundation/NSInvocation.h"
#include "Foundation/NSMethodSignature.h"
+/**
+ * The NSProtocolChecker and NSProxy classes provide message filtering and
+ * forwarding capabilities. If you wish to ensure at runtime that a given
+ * object will only be sent messages in a certain protocol, you create an
+ * NSProtocolChecker
instance with the protocol and the object as
+ * arguments-
+
+NSInvalidArgumentException
.
*/
- (void) forwardInvocation: (NSInvocation*)anInvocation
{
@@ -150,7 +168,7 @@
* delegate. Thus, the checker can be vended in lieu of anObject to
* restrict the messages that can be sent to anObject. If any method
* in the protocol returns anObject, the checker will replace the returned
- * value with itsself rather than the target object.The NSProxy class provides a basic implementation of a class whose
* instances are used to stand in for other objects.
* The class provides the most basic methods of NSObject, and expects
* messages for other methods to be forwarded to the real
* object represented by the proxy. You must subclass NSProxy to
- * implement -forwardInvocation: to these real objects.
+ * implement -forwardInvocation: to these real objects.
Note that NSProxy
is a different sort of class than others
+ * in the GNUstep Base library in that it is the only example of a root class
+ * besides [NSObject]. Thus, it defines its own isa
+ * variable and implements the NSObject
protocol.
NSInvalidArgumentException
.
*/
- (void) forwardInvocation: (NSInvocation*)anInvocation
{
@@ -300,7 +305,7 @@ extern BOOL __objc_responds_to(id, SEL);
}
/**
- * Tests for pointer equality with anObject
+ * Tests for pointer equality with anObject.
*/
- (BOOL) isEqual: (id)anObject
{
@@ -350,7 +355,7 @@ extern BOOL __objc_responds_to(id, SEL);
}
/**
- * Returns YES
+ * Returns YES.
*/
- (BOOL) isProxy
{
@@ -536,7 +541,7 @@ extern BOOL __objc_responds_to(id, SEL);
}
/**
- * Returns the superclass of the receivers class.
+ * Returns the superclass of the receiver's class.
*/
- (Class) superclass
{
diff --git a/Source/NSRunLoop.m b/Source/NSRunLoop.m
index 87bf544e1..ba589770b 100644
--- a/Source/NSRunLoop.m
+++ b/Source/NSRunLoop.m
@@ -1181,7 +1181,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
@implementation NSObject (TimedPerformers)
-/**
+/*
* Cancels any perform operations set up for the specified target
* in the current run loop.
*/
@@ -1210,7 +1210,7 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
}
}
-/**
+/*
* Cancels any perform operations set up for the specified target
* in the current loop, but only if the value of aSelector and argument
* with which the performs were set up match those supplied.NSRunLoop
instances handle various utility tasks that must
+ * be performed repetitively in an application, such as processing input
+ * events, listening for distributed objects communications, firing
+ * [NSTimer]s, and sending notifications and other messages
+ * asynchronously.
In general, there is one run loop per thread in an application, which
+ * may always be obtained through the +currentRunLoop
method,
+ * however unless you are using the AppKit and the [NSApplication] class, the
+ * run loop will not be started unless you explicitly send it a
+ * -run
message.
At any given point, a run loop operates in a single mode, usually
+ * NSDefaultRunLoopMode
. Other options include
+ * NSConnectionReplyMode
, and certain modes used by the AppKit.
NSDefaultRunLoopMode
by repeated calls to
+ * -runMode:beforeDate: while there are still input sources. Exits when no
+ * more input sources remain.
+ */
- (void) run
{
[self runUntilDate: theFuture];
}
+/**
+ * Runs the loop in NSDefaultRunLoopMode
by repeated calls to
+ * -runMode:beforeDate: while there are still input sources. Exits when no
+ * more input sources remain, or date is reached, whichever occurs first.
+ */
- (void) runUntilDate: (NSDate*)date
{
double ti = [date timeIntervalSinceNow];
@@ -2061,8 +2091,15 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
+/**
+ * OpenStep-compatibility methods for [NSRunLoop]. These methods are also
+ * all in OS X.
+ */
@implementation NSRunLoop (OPENSTEP)
+/**
+ * Adds port to be monitored in given mode.
+ */
- (void) addPort: (NSPort*)port
forMode: (NSString*)mode
{
@@ -2146,6 +2183,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
NSEndMapTableEnumeration(&enumerator);
}
+/**
+ * Configure event processing for acting as a server process for distributed
+ * objects. (In the current implementation this is a no-op.)
+ */
- (void) configureAsServer
{
/* Nothing to do here */
@@ -2218,6 +2259,10 @@ static void setPollfd(int fd, int event, GSRunLoopCtxt *ctxt)
}
}
+/**
+ * Removes port to be monitored from given mode.
+ * Ports are also removed if they are detected to be invalid.
+ */
- (void) removePort: (NSPort*)port
forMode: (NSString*)mode
{
diff --git a/Source/NSScanner.m b/Source/NSScanner.m
index 660897f49..075ba1862 100644
--- a/Source/NSScanner.m
+++ b/Source/NSScanner.m
@@ -52,9 +52,9 @@
/**
*
- * The NSScanner class cluster (currently a single class in GNUstep)
- * provides a mechanism to parse the contents of a string into number
- * and string values by making a sequence of scan operations to
+ * The NSScanner
class cluster (currently a single class in
+ * GNUstep) provides a mechanism to parse the contents of a string into
+ * number and string values by making a sequence of scan operations to
* step through the string retrieving successive items.
*
diff --git a/Source/NSSet.m b/Source/NSSet.m
index 7124295e0..4afd774a9 100644
--- a/Source/NSSet.m
+++ b/Source/NSSet.m
@@ -40,7 +40,12 @@
@class GSSet;
@class GSMutableSet;
-@implementation NSSet
+/**
+ * NSSet
maintains an unordered collection of unique objects
+ * (according to [NSObject -isEqual]). When a duplicate object is added
+ * to the set, it replaces its old copy.
+ */
+@implementation NSSet
static Class NSSet_abstract_class;
static Class NSMutableSet_abstract_class;
@@ -70,23 +75,35 @@ static Class NSMutableSet_concrete_class;
}
}
+/**
+ * New autoreleased empty set.
+ */
+ (id) set
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] init]);
}
+/**
+ * New set containing (unique elements of) objects.
+ */
+ (id) setWithArray: (NSArray*)objects
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
initWithArray: objects]);
}
+/**
+ * New set containing single object anObject.
+ */
+ (id) setWithObject: anObject
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
initWithObjects: &anObject count: 1]);
}
+/**
+ * New set containing (unique elements of) objects.
+ */
+ (id) setWithObjects: (id*)objects
count: (unsigned)count
{
@@ -94,6 +111,9 @@ static Class NSMutableSet_concrete_class;
initWithObjects: objects count: count]);
}
+/**
+ * New set with objects in given nil-terminated list.
+ */
+ (id) setWithObjects: firstObject, ...
{
id set;
@@ -104,6 +124,9 @@ static Class NSMutableSet_concrete_class;
return AUTORELEASE(set);
}
+/**
+ * Copy constructor.
+ */
+ (id) setWithSet: (NSSet*)aSet
{
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
@@ -248,7 +271,9 @@ static Class NSMutableSet_concrete_class;
return self;
}
-/*
- * NSString objects represent an immutable string of characters.
- * NSString itself is an abstract class which provides factory
- * methods to generate objects of unspecified subclasses.
+ * NSString
objects represent an immutable string of Unicode 3.0
+ * characters. These may be accessed individually as type
+ * unichar
, an unsigned short.
+ * The [NSMutableString] subclass represents a modifiable string. Both are
+ * implemented as part of a class cluster and the instances you receive may
+ * actually be of unspecified concrete subclasses.
*
- * A constant NSString can be created using the following syntax:
+ * A constant NSString
can be created using the following syntax:
* @"..."
, where the contents of the quotes are the
* string, using only ASCII characters.
*
- * To create a concrete subclass of NSString, you must have your
- * class inherit from NSString and override at least the two
- * primitive methods - length and characterAtIndex:
+ * A variable string can be created using a C printf-like format,
+ * as in [NSString stringWithFormat: @"Total is %f", t]
.
+ *
+ * To create a concrete subclass of NSString
, you must have your
+ * class inherit from NSString
and override at least the two
+ * primitive methods - -length and -characterAtIndex:
*
* In general the rule is that your subclass must override any @@ -286,6 +293,8 @@ surrogatePairValue(unichar high, unichar low) *
*/ @implementation NSString +// NSString itself is an abstract class which provides factory +// methods to generate objects of unspecified subclasses. static NSStringEncoding _DefaultStringEncoding; static BOOL _ByteEncodingOk; @@ -480,11 +489,17 @@ handle_printf_atsign (FILE *stream, // Creating Temporary Strings +/** + * Create an empty string. + */ + (id) string { return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()] init]); } +/** + * Create a copy of aString. + */ + (id) stringWithString: (NSString*)aString { NSString *obj; @@ -494,6 +509,9 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } +/** + * Create a string of unicode characters. + */ + (id) stringWithCharacters: (const unichar*)chars length: (unsigned int)length { @@ -504,6 +522,11 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } +/** + * Create a string based on the given C (char[]) string, which should be + * null-terminated and encoded in the default C string encoding. (Characters + * will be converted to unicode representation internally.) + */ + (id) stringWithCString: (const char*) byteString { NSString *obj; @@ -514,6 +537,11 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } +/** + * Create a string based on the given C (char[]) string, which may contain + * null bytes and should be encoded in the default C string encoding. + * (Characters will be converted to unicode representation internally.) + */ + (id) stringWithCString: (const char*)byteString length: (unsigned int)length { @@ -524,6 +552,9 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } +/** + * Create a string based on the given UTF-8 string, null-terminated. + */ + (id) stringWithUTF8String: (const char *)bytes { NSString *obj; @@ -533,6 +564,11 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } +/** + * Load contents of file at path into a new string. Will interpret file as + * containing direct unicode if it begins with the unicode byte order mark, + * else converts to unicode using default C string encoding. + */ + (id) stringWithContentsOfFile: (NSString *)path { NSString *obj; @@ -542,6 +578,11 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } +/** + * Load contents of given URL into a new string. Will interpret contents as + * containing direct unicode if it begins with the unicode byte order mark, + * else converts to unicode using default C string encoding. + */ + (id) stringWithContentsOfURL: (NSURL *)url { NSString *obj; @@ -551,6 +592,11 @@ handle_printf_atsign (FILE *stream, return AUTORELEASE(obj); } +/** + * Creates a new string using C printf-style formatting. First argument should + * be a constant format string, like '@"float val = %f"
', remaining
+ * arguments should be the variables to print the values of, comma-separated.
+ */
+ (id) stringWithFormat: (NSString*)format,...
{
va_list ap;
@@ -908,9 +954,12 @@ handle_printf_atsign (FILE *stream,
}
/** Initialize with given unicode chars up to length, regardless of presence + * of null bytes. Does not copy the string. If flag, frees its storage when + * this instance is deallocated.
+ *Note, this is the most basic initialiser for unicode strings. * In the GNUstep implementation, your subclasses may override - * this initialiser in order to have all others function. + * this initialiser in order to have all others function.
*/ - (id) initWithCharactersNoCopy: (unichar*)chars length: (unsigned int)length @@ -920,6 +969,10 @@ handle_printf_atsign (FILE *stream, return self; } +/** + *Initialize with given unicode chars up to length, regardless of presence + * of null bytes. Copies the string and frees copy when deallocated.
+ */ - (id) initWithCharacters: (const unichar*)chars length: (unsigned int)length { @@ -977,6 +1030,12 @@ handle_printf_atsign (FILE *stream, return self; } +/** + *Initialize with given C string byteString up to length, regardless of + * presence of null bytes. Characters converted to unicode based on the + * default C encoding. Does not copy the string. If flag, frees its storage + * when this instance is deallocated.
+ */ - (id) initWithCStringNoCopy: (char*)byteString length: (unsigned int)length freeWhenDone: (BOOL)flag @@ -1000,6 +1059,11 @@ handle_printf_atsign (FILE *stream, return self; } +/** + *Initialize with given C string byteString up to length, regardless of + * presence of null bytes. Characters converted to unicode based on the + * default C encoding. Copies the string.
+ */ - (id) initWithCString: (const char*)byteString length: (unsigned int)length { if (length > 0) @@ -1020,12 +1084,20 @@ handle_printf_atsign (FILE *stream, return self; } +/** + *Initialize with given C string byteString, which should be + * null-terminated. Characters are converted to unicode based on the default + * C encoding. Copies the string.
+ */ - (id) initWithCString: (const char*)byteString { return [self initWithCString: byteString length: (byteString ? strlen(byteString) : 0)]; } +/** + * Initialize to be a copy of the given string. + */ - (id) initWithString: (NSString*)string { unsigned length = [string length]; @@ -1048,6 +1120,9 @@ handle_printf_atsign (FILE *stream, return self; } +/** + * Initialize based on given null-terminated UTF-8 string bytes. + */ - (id) initWithUTF8String: (const char *)bytes { unsigned length = 0; @@ -1448,6 +1523,24 @@ handle_printf_atsign (FILE *stream, return self; } +/** + *Initialises the receiver with the contents of the given URL. + *
+ *Invokes [NSData+dataWithContentsOfURL:] to read the contents, then + * examines the data to infer its encoding type, and converts the + * data to a string using -initWithData:encoding: + *
+ *The encoding to use is determined as follows ... if the data begins
+ * with the 16-bit unicode Byte Order Marker, then it is assumed to be
+ * unicode data in the appropriate ordering and converted as such.
+ * If it begins with a UTF8 representation of the BOM, the UTF8 encoding
+ * is used.
+ * Otherwise, the default C String encoding is used.
+ *
Releases the receiver and returns nil if the URL contents could not be + * read and converted to a string. + *
+ */ - (id) initWithContentsOfURL: (NSURL*)url { NSStringEncoding enc = _DefaultStringEncoding; @@ -1491,6 +1584,9 @@ handle_printf_atsign (FILE *stream, return self; } +/** + * Initializes as an empty string. + */ - (id) init { self = [self initWithCharactersNoCopy: (unichar*)0 @@ -1501,6 +1597,10 @@ handle_printf_atsign (FILE *stream, // Getting a String's Length +/** + * Returns the number of Unicode characters in this string, including the + * individual characters of composed character sequences, + */ - (unsigned int) length { [self subclassResponsibility: _cmd]; @@ -1509,20 +1609,34 @@ handle_printf_atsign (FILE *stream, // Accessing Characters +/** + * Returns unicode character at index.unichar
is an unsigned
+ * short. Thus, a 16-bit character is returned.
+ */
- (unichar) characterAtIndex: (unsigned int)index
{
[self subclassResponsibility: _cmd];
return (unichar)0;
}
-/* Inefficient. Should be overridden */
+/**
+ * Returns this string as an array of 16-bit unichar
(unsigned
+ * short) values. buffer must be preallocated and should be capable of
+ * holding -length shorts.
+ */
+// Inefficient. Should be overridden
- (void) getCharacters: (unichar*)buffer
{
[self getCharacters: buffer range: ((NSRange){0, [self length]})];
return;
}
-/* Inefficient. Should be overridden */
+/**
+ * Returns aRange of string as an array of 16-bit unichar
+ * (unsigned short) values. buffer must be preallocated and should be capable
+ * of holding a sufficient number of shorts.
+ */
+// Inefficient. Should be overridden
- (void) getCharacters: (unichar*)buffer
range: (NSRange)aRange
{
@@ -1543,6 +1657,10 @@ handle_printf_atsign (FILE *stream,
// Combining Strings
+/**
+ * Constructs a new string consisting of this instance followed by the string
+ * specified by format.
+ */
- (NSString*) stringByAppendingFormat: (NSString*)format,...
{
va_list ap;
@@ -1555,6 +1673,9 @@ handle_printf_atsign (FILE *stream,
return ret;
}
+/**
+ * Constructs a new string consisting of this instance followed by the aString.
+ */
- (NSString*) stringByAppendingString: (NSString*)aString
{
unsigned len = [self length];
@@ -1572,6 +1693,14 @@ handle_printf_atsign (FILE *stream,
// Dividing Strings into Substrings
+/**
+ * Returns an array of [NSString]s representing substrings of this string + * that are separated by separator (which itself is never returned in the + * array). If there are no occurrences of separator, the whole string is + * returned. If string begins or ends with separator, empty strings will + * be returned for those positions.
+ *Note, use an [NSScanner] if you need more sophisticated parsing.
+ */ - (NSArray*) componentsSeparatedByString: (NSString*)separator { NSRange search; @@ -1664,6 +1793,12 @@ handle_printf_atsign (FILE *stream, // Finding Ranges of Characters and Substrings +/** + * Returns position of first character in this string that is in aSet. + * Positions start at 0. If the character is a composed character sequence, + * the range returned will contain the whole sequence, else just the character + * itself. + */ - (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet { NSRange all = NSMakeRange(0, [self length]); @@ -1673,6 +1808,15 @@ handle_printf_atsign (FILE *stream, range: all]; } +/** + * Returns position of first character in this string that is in aSet. + * Positions start at 0. If the character is a composed character sequence, + * the range returned will contain the whole sequence, else just the character + * itself. mask may containNSCaseInsensitiveSearch
,
+ * NSLiteralSearch
(don't consider alternate forms of composed
+ * characters equal), or NSBackwardsSearch
(search from end of
+ * string).
+ */
- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet
options: (unsigned int)mask
{
@@ -1683,6 +1827,15 @@ handle_printf_atsign (FILE *stream,
range: all];
}
+/**
+ * Returns position of first character in this string that is in aSet.
+ * Positions start at 0. If the character is a composed character sequence,
+ * the range returned will contain the whole sequence, else just the character
+ * itself. mask may contain NSCaseInsensitiveSearch
,
+ * NSLiteralSearch
(don't consider alternate forms of composed
+ * characters equal), or NSBackwardsSearch
(search from end of
+ * string). Search only carried out within aRange.
+ */
- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet
options: (unsigned int)mask
range: (NSRange)aRange
@@ -1729,8 +1882,7 @@ handle_printf_atsign (FILE *stream,
}
/**
- * Invokes -rangeOfString:options: with the options mask
- * set to zero.
+ * Invokes -rangeOfString:options: with no options.
*/
- (NSRange) rangeOfString: (NSString*)string
{
@@ -1770,11 +1922,14 @@ handle_printf_atsign (FILE *stream,
* NSCaseInsensitiveSearch
NSLiteralSearch
NSBackwardsSearch
NSAnchoredSearch
NSAnchoredSearch
option means aString must occur at the
+ * beginning (or end, if NSBackwardsSearch
is also given) of the
+ * string. Options should be OR'd together using '|'
.
*/
- (NSRange) rangeOfString: (NSString *)aString
options: (unsigned int)mask
@@ -1804,6 +1959,11 @@ handle_printf_atsign (FILE *stream,
// Determining Composed Character Sequences
+/**
+ * Unicode utility method. If character at anIndex is part of a composed
+ * character sequence anIndex (note indices start from 0), returns the full
+ * range of this sequence.
+ */
- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (unsigned int)anIndex
{
unsigned start;
@@ -1836,11 +1996,24 @@ handle_printf_atsign (FILE *stream,
// Identifying and Comparing Strings
+/**
+ * Compares this instance with aString. Returns
+ * NSOrderedAscending
, NSOrderedDescending
, or
+ * NSOrderedSame
, depending on whether this instance occurs
+ * before or after string in lexical order, or is equal to it.
Compares this instance with aString. mask may be either
+ * NSCaseInsensitiveSearch
or NSLiteralSearch
. The
+ * latter requests a literal byte-by-byte comparison, which is fastest but may
+ * return inaccurate results in cases where two different composed character
+ * sequences may be used to express the same character.
Compares this instance with string. mask may be either
+ * NSCaseInsensitiveSearch
or NSLiteralSearch
. The
+ * latter requests a literal byte-by-byte comparison, which is fastest but may
+ * return inaccurate results in cases where two different composed character
+ * sequences may be used to express the same character. aRange refers
+ * to this instance, and should be set to 0..length to compare the whole
+ * string.
==
.
+ */
- (BOOL) isEqual: (id)anObject
{
if (anObject == self)
@@ -1896,6 +2088,10 @@ handle_printf_atsign (FILE *stream,
return NO;
}
+/**
+ * Returns whether this instance is equal as a string to aString. See also
+ * -compare: and related methods.
+ */
- (BOOL) isEqualToString: (NSString*)aString
{
if ([self hash] != [aString hash])
@@ -1960,6 +2156,14 @@ handle_printf_atsign (FILE *stream,
// Getting a Shared Prefix
+/**
+ * Returns the largest initial portion of this instance shared with aString.
+ * mask may be either NSCaseInsensitiveSearch
or
+ * NSLiteralSearch
. The latter requests a literal byte-by-byte
+ * comparison, which is fastest but may return inaccurate results in cases
+ * where two different composed character sequences may be used to express
+ * the same character.
+ */
- (NSString*) commonPrefixWithString: (NSString*)aString
options: (unsigned int)mask
{
@@ -2261,6 +2465,12 @@ handle_printf_atsign (FILE *stream,
// Changing Case
+/**
+ * Returns version of string in which each whitespace-delimited word
+ * is capitalized (not every letter). Conversion to capitals is done in a
+ * unicode-compliant manner but there may be exceptional cases where behavior
+ * is not what is desired.
+ */
// xxx There is more than this in word capitalization in Unicode,
// but this will work in most cases
- (NSString*) capitalizedString
@@ -2365,6 +2575,7 @@ handle_printf_atsign (FILE *stream,
// Storing the String
+/** Returns self
. */
- (NSString*) description
{
return self;
@@ -2374,10 +2585,11 @@ handle_printf_atsign (FILE *stream,
// Getting C Strings
/**
- * Returns a pointer to a null terminated string of 8-bit
- * characters in the default encoding. The memory pointed
- * to is not owned by the caller, so the caller must copy
- * its contents to keep it.
+ * Returns a pointer to a null terminated string of 8-bit characters in the
+ * default encoding. The memory pointed to is not owned by the caller, so the
+ * caller must copy its contents to keep it. Raises an
+ * NSCharacterConversionException
if loss of information would
+ * occur during conversion. (See -canBeConvertedToEncoding: .)
*/
- (const char*) cString
{
@@ -2397,6 +2609,11 @@ handle_printf_atsign (FILE *stream,
return (const char*)[m bytes];
}
+/**
+ * Returns a C string converted using the default C string encoding, which may
+ * result in information loss. The memory pointed to is not owned by the
+ * caller, so the caller must copy its contents to keep it.
+ */
- (const char*) lossyCString
{
NSData *d;
@@ -2410,6 +2627,11 @@ handle_printf_atsign (FILE *stream,
return (const char*)[m bytes];
}
+/**
+ * Returns null-terminated UTF-8 version of this unicode string. The char[]
+ * memory comes from an autoreleased object, so it will eventually go out of
+ * scope.
+ */
- (const char *) UTF8String
{
NSData *d;
@@ -2423,6 +2645,12 @@ handle_printf_atsign (FILE *stream,
return (const char*)[m bytes];
}
+/**
+ * Returns length of a version of this unicode string converted to bytes
+ * using the default C string encoding. If the conversion would result in
+ * information loss, the results are unpredictable. Check
+ * -canBeConvertedToEncoding: first.
+ */
- (unsigned int) cStringLength
{
NSData *d;
@@ -2540,8 +2768,8 @@ handle_printf_atsign (FILE *stream,
}
/**
- * Returns the strings content as a double. Skips leading whitespace.Returns the string's content as an int.
+ * Current implementation uses C library atoi()
, which does not
+ * detect conversion errors -- use with care!
* Returns the encoding used for any method accepting a C string. - * This value is determined automatically from the programs + * This value is determined automatically from the program's * environment and cannot be changed programmatically. *
*
@@ -2632,6 +2865,10 @@ handle_printf_atsign (FILE *stream,
table: nil];
}
+/**
+ * Returns whether this string can be converted to the given string encoding
+ * without information loss.
+ */
- (BOOL) canBeConvertedToEncoding: (NSStringEncoding)encoding
{
id d = [self dataUsingEncoding: encoding allowLossyConversion: NO];
@@ -2639,11 +2876,19 @@ handle_printf_atsign (FILE *stream,
return d != nil ? YES : NO;
}
+/**
+ * Converts string to a byte array in the given encoding, returning nil if
+ * this would result in information loss.
+ */
- (NSData*) dataUsingEncoding: (NSStringEncoding)encoding
{
return [self dataUsingEncoding: encoding allowLossyConversion: NO];
}
+/**
+ * Converts string to a byte array in the given encoding. If flag is NO,
+ * nil would be returned if this would result in information loss.
+ */
- (NSData*) dataUsingEncoding: (NSStringEncoding)encoding
allowLossyConversion: (BOOL)flag
{
@@ -2805,11 +3050,20 @@ handle_printf_atsign (FILE *stream,
return nil;
}
+
+/**
+ * Returns the encoding with which this string can be converted without
+ * information loss that would result in most efficient character access.
+ */
- (NSStringEncoding) fastestEncoding
{
return NSUnicodeStringEncoding;
}
+/**
+ * Returns the smallest encoding with which this string can be converted
+ * without information loss.
+ */
- (NSStringEncoding) smallestEncoding
{
return NSUnicodeStringEncoding;
@@ -2818,6 +3072,16 @@ handle_printf_atsign (FILE *stream,
// Manipulating File System Paths
+/**
+ * Attempts to complete this string as a path in the filesystem by finding
+ * a unique completion if one exists and returning it by reference in
+ * outputName (which must be a non-nil pointer), or if it finds a set of
+ * completions they are returned by reference in outputArray, if it is non-nil.
+ * filterTypes can be an array of strings specifying extensions to consider;
+ * files without these extensions will be ignored and will not constitute
+ * completions. Returns 0 if no match found, else a positive number that is
+ * only accurate if outputArray was non-nil.
+ */
- (unsigned int) completePathIntoString: (NSString**)outputName
caseSensitive: (BOOL)flag
matchesIntoArray: (NSArray**)outputArray
@@ -2889,7 +3153,13 @@ handle_printf_atsign (FILE *stream,
return match_count;
}
-/* Return a string for passing to OS calls to handle file system objects. */
+/**
+ * Converts this string, which is assumed to be a path in Unix notation ('/'
+ * is file separator, '.' is extension separator) to a C string path expressed
+ * in the convention for the host operating system. This string will be
+ * automatically freed soon after it is returned, so copy it if you need it
+ * for long.
+ */
- (const char*) fileSystemRepresentation
{
static NSFileManager *fm = nil;
@@ -2902,6 +3172,12 @@ handle_printf_atsign (FILE *stream,
return [fm fileSystemRepresentationWithPath: self];
}
+/**
+ * Converts this string, which is assumed to be a path in Unix notation ('/'
+ * is file separator, '.' is extension separator) to a C string path expressed
+ * in the convention for the host operating system. This string will be
+ * stored into buffer if it is shorter than size, otherwise NO is returned.
+ */
- (BOOL) getFileSystemRepresentation: (char*)buffer
maxLength: (unsigned int)size
{
@@ -3372,6 +3648,10 @@ handle_printf_atsign (FILE *stream,
}
}
+/**
+ * Replaces path string by one in which path components representing symbolic
+ * links have been replaced by their referents.
+ */
- (NSString*) stringByResolvingSymlinksInPath
{
#if defined(__MINGW__)
@@ -3760,9 +4040,9 @@ handle_printf_atsign (FILE *stream,
return s;
}
-/*
- * Returs YES if the receiver represents an absolute path ... ie if it begins
- * with a '/' or a '~'
+/**
+ * Returns YES if the receiver represents an absolute path ... i.e. if it
+ * begins with a '/' or a '~'
* Returns NO otherwise.
*/
- (BOOL) isAbsolutePath
@@ -3865,6 +4145,9 @@ handle_printf_atsign (FILE *stream,
return AUTORELEASE(r);
}
+/**
+ * Returns an autoreleased string with given format using the default locale.
+ */
+ (NSString*) localizedStringWithFormat: (NSString*) format, ...
{
va_list ap;
@@ -3886,6 +4169,11 @@ handle_printf_atsign (FILE *stream,
return ret;
}
+/**
+ * Compares this string with aString ignoring case. Convenience for
+ * -compare:options:range: with the NSCaseInsensitiveSearch
+ * option, in the default locale.
+ */
- (NSComparisonResult) caseInsensitiveCompare: (NSString*)aString
{
return [self compare: aString
@@ -3893,17 +4181,36 @@ handle_printf_atsign (FILE *stream,
range: ((NSRange){0, [self length]})];
}
+/**
+ *
Compares this instance with string, using rules in locale given by dict.
+ * mask may be either NSCaseInsensitiveSearch
or
+ * NSLiteralSearch
. The latter requests a literal byte-by-byte
+ * comparison, which is fastest but may return inaccurate results in cases
+ * where two different composed character sequences may be used to express
+ * the same character. compareRange refers to this instance, and should be
+ * set to 0..length to compare the whole string.
Returns NSOrderedAscending
, NSOrderedDescending
,
+ * or NSOrderedSame
, depending on whether this instance occurs
+ * before or after string in lexical order, or is equal to it.
Warning: this implementation and others in NSString + * IGNORE the locale.
+ */ - (NSComparisonResult) compare: (NSString *)string options: (unsigned int)mask range: (NSRange)compareRange locale: (NSDictionary *)dict { - // FIXME: This does only a normal compare + // FIXME: This does only a normal compare, ignoring locale return [self compare: string options: mask range: compareRange]; } +/** + * Compares this instance with string, using rules in the default locale. + */ - (NSComparisonResult) localizedCompare: (NSString *)string { NSDictionary *dict = GSUserDefaultsDictionaryRepresentation(); @@ -3914,6 +4221,10 @@ handle_printf_atsign (FILE *stream, locale: dict]; } +/** + * Compares this instance with string, using rules in the default locale, + * ignoring case. + */ - (NSComparisonResult) localizedCaseInsensitiveCompare: (NSString *)string { NSDictionary *dict = GSUserDefaultsDictionaryRepresentation(); @@ -3924,6 +4235,13 @@ handle_printf_atsign (FILE *stream, locale: dict]; } +/** + * Writes contents out to file at filename, using the default C string encoding + * unless this would result in information loss, otherwise straight unicode. + * The 'atomically
' option if set will cause the contents to be
+ * written to a temp file, which is then closed and renamed to filename. Thus,
+ * an incomplete file at filename should never result.
+ */
- (BOOL) writeToFile: (NSString*)filename
atomically: (BOOL)useAuxiliaryFile
{
@@ -3936,6 +4254,13 @@ handle_printf_atsign (FILE *stream,
return [d writeToFile: filename atomically: useAuxiliaryFile];
}
+/**
+ * Writes contents out to anURL, using the default C string encoding
+ * unless this would result in information loss, otherwise straight unicode.
+ * See [NSURLHandle-writeData:] on which URL types are supported.
+ * The 'atomically
' option is only heeded if the URL is a
+ * file://
URL; see -writeToFile:atomically: .
+ */
- (BOOL) writeToURL: (NSURL*)anURL atomically: (BOOL)atomically
{
id d = [self dataUsingEncoding: _DefaultStringEncoding];
@@ -4130,134 +4455,11 @@ handle_printf_atsign (FILE *stream,
*
* Both the traditional format and the XML format permit comments to be * placed in property list documents. In traditional format the - * comment notations used in ObjectiveC programming are supported, while + * comment notations used in Objective-C programming are supported, while * in XML format, the standard SGML comment sequences are used. *
- * A property list may only be one of the following classes - - *array
- * and whose content is the array content.
- * data
and whose content is a stream of base64 encoded bytes.
- * date
and whose content is a date in the above format.
- * dictionary
and whose content consists of pairs of
- * strings and other property list objects.
- * <*BY>
for YES or
- * <*BN>
for NO.<true />
or
- * <false />
- * <*INNN>
where NNN is an
- * integer.<integer>NNN<integer>
- * <*RNNN>
where NNN is a real
- * number.<real>NNN<real>
- * string
element, and the only character
- * escapes required are those used by XML such as the
- * '<' markup representing a '<' character.
- * See the documentation for [NSPropertyListSerialization] for more + * information on what a property list is.
*/ - (id) propertyList { @@ -4291,7 +4493,7 @@ handle_printf_atsign (FILE *stream, @end /** - * This is the mutable form of the NSString class. + * This is the mutable form of the [NSString] class. */ @implementation NSMutableString @@ -4309,19 +4511,28 @@ handle_printf_atsign (FILE *stream, // Creating Temporary Strings +/** + * Constructs an empty string. + */ + (NSMutableString*) string { return AUTORELEASE([[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] initWithCapacity: 0]); } +/** + * Constructs an empty string with initial buffer size of capacity. + */ + (NSMutableString*) stringWithCapacity: (unsigned int)capacity { return AUTORELEASE([[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] initWithCapacity: capacity]); } -/* Inefficient. */ +/** + * Create a string of unicode characters. + */ +// Inefficient implementation. + (NSString*) stringWithCharacters: (const unichar*)characters length: (unsigned int)length { @@ -4329,18 +4540,33 @@ handle_printf_atsign (FILE *stream, NSDefaultMallocZone()] initWithCharacters: characters length: length]); } +/** + * Load contents of file at path into a new string. Will interpret file as + * containing direct unicode if it begins with the unicode byte order mark, + * else converts to unicode using default C string encoding. + */ + (id) stringWithContentsOfFile: (NSString *)path { return AUTORELEASE([[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] initWithContentsOfFile: path]); } +/** + * Create a string based on the given C (char[]) string, which should be + * null-terminated and encoded in the default C string encoding. (Characters + * will be converted to unicode representation internally.) + */ + (NSString*) stringWithCString: (const char*)byteString { return AUTORELEASE([[GSMutableStringClass allocWithZone: NSDefaultMallocZone()] initWithCString: byteString]); } +/** + * Create a string based on the given C (char[]) string, which may contain + * null bytes and should be encoded in the default C string encoding. + * (Characters will be converted to unicode representation internally.) + */ + (NSString*) stringWithCString: (const char*)byteString length: (unsigned int)length { @@ -4348,6 +4574,11 @@ handle_printf_atsign (FILE *stream, NSDefaultMallocZone()] initWithCString: byteString length: length]); } +/** + * Creates a new string using C printf-style formatting. First argument should + * be a constant format string, like '@"float val = %f"
', remaining
+ * arguments should be the variables to print the values of, comma-separated.
+ */
+ (NSString*) stringWithFormat: (NSString*)format, ...
{
va_list ap;
@@ -4358,6 +4589,9 @@ handle_printf_atsign (FILE *stream,
}
// Designated initialiser
+/** Create a new thread - use this method rather than alloc-init. The new + * thread will begin executing the message given by aSelector, aTarget, and + * anArgument. This should have no return value, and must set up an + * autorelease pool if retain/release memory management is used. It should + * free this pool before it finishes execution.
+ * + *Note, unlike in Cocoa (and perhaps OpenStep), the + * thread will not exit when the method finishes execution. You must + * call [Thread +exit] yourself (from the thread) to terminate it.
*/ + (void) detachNewThreadSelector: (SEL)aSelector toTarget: (id)aTarget withObject: (id)anArgument diff --git a/Source/NSTimeZone.m b/Source/NSTimeZone.m index 640702572..9c93b36f0 100644 --- a/Source/NSTimeZone.m +++ b/Source/NSTimeZone.m @@ -942,7 +942,7 @@ static NSMapTable *absolutes = 0; @implementation NSTimeZone /** - * DEPRICATED. + * DEPRECATED. */ + (NSDictionary*) abbreviationDictionary { @@ -1563,7 +1563,7 @@ static NSMapTable *absolutes = 0; } /** - * DEPRICATED: see NSTimeZoneDetail + * DEPRECATED: see NSTimeZoneDetail */ - (NSArray*) timeZoneDetailArray { @@ -1571,7 +1571,7 @@ static NSMapTable *absolutes = 0; } /** - * DEPRICATED: see NSTimeZoneDetail + * DEPRECATED: see NSTimeZoneDetail */ - (NSTimeZoneDetail*) timeZoneDetailForDate: (NSDate*)date { @@ -1604,7 +1604,7 @@ static NSMapTable *absolutes = 0; } /** - * DEPRICATED: Class is no longer used. + * DEPRECATED: Class is no longer used. */ - (BOOL) isDaylightSavingTimeZone { @@ -1613,7 +1613,7 @@ static NSMapTable *absolutes = 0; } /** - * DEPRICATED: Class is no longer used. + * DEPRECATED: Class is no longer used. */ - (NSString*) timeZoneAbbreviation { @@ -1621,7 +1621,7 @@ static NSMapTable *absolutes = 0; } /** - * DEPRICATED: Class is no longer used. + * DEPRECATED: Class is no longer used. */ - (int) timeZoneSecondsFromGMT { diff --git a/Source/NSTimer.m b/Source/NSTimer.m index 512d8e7fa..b856f5cf4 100644 --- a/Source/NSTimer.m +++ b/Source/NSTimer.m @@ -36,6 +36,14 @@ @class NSGDate; static Class NSDate_class; +/** + * AnNSTimer
provides a way to send a message at some time in
+ * the future, possibly repeating every time a fixed interval has passed. To
+ * use a timer, you can either create one that will automatically be added to
+ * the run loop in the current thread (using the -addTimer:forMode: method),
+ * or you can create it without adding it then add it to an [NSRunLoop]
+ * explicitly later.
+ */
@implementation NSTimer
+ (void) initialize
diff --git a/Source/NSURL.m b/Source/NSURL.m
index da8b32bf2..e0f7763d4 100644
--- a/Source/NSURL.m
+++ b/Source/NSURL.m
@@ -1607,8 +1607,9 @@ static unsigned urlAlign;
/**
* An informal protocol to which clients may conform if they wish to be
- * notified of the progress in loading a URL for them. The default
- * implementations of these methods do nothing.
+ * notified of the progress in loading a URL for them. NSURL conforms to
+ * this protocol but all methods are implemented as no-ops. See also
+ * the [NSURLHandleClient] protocol.
*/
@implementation NSObject (NSURLClient)
diff --git a/Source/NSUnarchiver.m b/Source/NSUnarchiver.m
index 0c9ff2d55..c1062dc2f 100644
--- a/Source/NSUnarchiver.m
+++ b/Source/NSUnarchiver.m
@@ -294,8 +294,8 @@ mapClassName(NSUnarchiverObjectInfo *info)
@end
/**
- * This class reconstructs objects from an archive.This class reconstructs objects from an archive.
* The -resetUnarchiverWithData:atIndex: method lets you re-use * the archive to decode a new data object or, in conjunction @@ -303,9 +303,9 @@ mapClassName(NSUnarchiverObjectInfo *info) * position in the archive), decode a second archive that exists * in the data object after the first one. *
- * Subclassing with different input format.NSUnarchiver
normally reads directly from an [NSData]
+ * object using the methods -
*
- * And uses other NSData methods to read the archive header information
- * from within the method:
+ * NSUnarchiver
normally uses other [NSData] methods to read
+ * the archive header information from within the method:
* [-deserializeHeaderAt:version:classes:objects:pointers:]
* to read a fixed size header including archiver version
- * (obtained by [self systemVersion]) and crossreference
+ * (obtained by [self systemVersion]
) and crossreference
* table sizes.
*
- * To subclass NSUnarchiver, you must implement your own versions of the
- * four methods above, and override the 'directDataAccess' method to
- * return NO so that the archiver knows to use your serialization
- * methods rather than those in the NSData object.
+ * To subclass NSUnarchiver
, you must implement your own
+ * versions of the four methods above, and override the 'directDataAccess'
+ * method to return NO so that the archiver knows to use your serialization
+ * methods rather than those in the [NSData] object.
*
[[NSUndoManager alloc] init]
message.
*/
@implementation NSUndoManager
diff --git a/Source/externs.m b/Source/externs.m
index 03d644e4a..4a294e3b9 100644
--- a/Source/externs.m
+++ b/Source/externs.m
@@ -73,7 +73,10 @@ NSString *NSConnectionReplyMode = @"NSConnectionReplyMode";
-/* Exception handler */
+/**
+ * Last-resort exception handler, a function taking an NSException and
+ * returning void. Set with NSSetUncaughtExceptionHandler().
+ */
NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler;
/* NSBundle */