diff --git a/Headers/Foundation/NSArchiver.h b/Headers/Foundation/NSArchiver.h index 2dbd378cf..eca8b1361 100644 --- a/Headers/Foundation/NSArchiver.h +++ b/Headers/Foundation/NSArchiver.h @@ -21,10 +21,9 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. - AutogsdocSource: NSArchiver.m - AutogsdocSource: NSUnarchiver.m - - */ + AutogsdocSource:NSUnarchiver.m + AutogsdocSource:NSArchiver.m +*/ #ifndef __NSArchiver_h_GNUSTEP_BASE_INCLUDE #define __NSArchiver_h_GNUSTEP_BASE_INCLUDE diff --git a/Headers/Foundation/NSAutoreleasePool.h b/Headers/Foundation/NSAutoreleasePool.h index 4285c4d0a..a885da774 100644 --- a/Headers/Foundation/NSAutoreleasePool.h +++ b/Headers/Foundation/NSAutoreleasePool.h @@ -79,8 +79,9 @@ typedef struct autorelease_array_list * object gets deallocated. *

*

- * A simple retain/release mechanism is not very interesting ... - * so it's spiced up with autorelease pools. You can use the + * A simple retain/release mechanism has problems with passing objects + * from one scope to another, + * so it's augmented with autorelease pools. You can use the * AUTORELEASE() macro to call the [NSObject-autorelease] * method, which adds an object to the current autorelease pool by * calling [NSAutoreleasePool+addObject:].
@@ -127,7 +128,7 @@ typedef struct autorelease_array_list * * Methods whose names begin with init return an initialised * version of the receiving object, owned by the caller.
- * NB. The returned object may not actualy be the same as the + * NB. The returned object may not actually be the same as the * receiver ... sometimes an init method releases the original * receiver and returns an alternative. *
diff --git a/Headers/Foundation/NSBitmapCharSet.h b/Headers/Foundation/NSBitmapCharSet.h index bdef16511..6689509b2 100644 --- a/Headers/Foundation/NSBitmapCharSet.h +++ b/Headers/Foundation/NSBitmapCharSet.h @@ -27,6 +27,7 @@ #include #include +//PENDING: may want to make these less likely to conflict #define UNICODE_SIZE 65536 #define BITMAP_SIZE UNICODE_SIZE/8 @@ -36,20 +37,35 @@ #define ISSET(a,i) ((((a) & (1<<(i)))) > 0) ? YES : NO; #endif +/** + * An [NSCharacterSet] that stores the set of unicode characters in it as a + * simple bitmap. Implementation is very efficient. + */ @interface NSBitmapCharSet : NSCharacterSet { char _data[BITMAP_SIZE]; } +/** + * Init directly with bitmap data. bitmap should be BITMAP_SIZE + * long, which is currently 2^16 / 8. + */ - (id) initWithBitmap: (NSData*)bitmap; @end +/** + * Mutable version of [NSBitmapCharSet]. + */ @interface NSMutableBitmapCharSet : NSMutableCharacterSet { char _data[BITMAP_SIZE]; } +/** + * Init directly with bitmap data. bitmap should be BITMAP_SIZE + * long, which is currently 2^16 / 8. + */ - (id) initWithBitmap: (NSData*)bitmap; @end diff --git a/Headers/Foundation/NSBundle.h b/Headers/Foundation/NSBundle.h index ab0134301..eabefd3d7 100644 --- a/Headers/Foundation/NSBundle.h +++ b/Headers/Foundation/NSBundle.h @@ -140,7 +140,7 @@ GS_EXPORT NSString* NSLoadedClasses; inDirectory: (NSString*)bundlePath; /** - This method has been depreciated. Version numbers were never implemented + This method has been deprecated. Version numbers were never implemented so this method behaves exactly like +pathForResource:ofType:inDirectory:. */ + (NSString*) pathForResource: (NSString*)name @@ -173,6 +173,10 @@ GS_EXPORT NSString* NSLoadedClasses; */ - (Class) principalClass; +/** + * Not implemented. Create an instance and call the corresponding instance + * method instead. + */ + (NSArray*) pathsForResourcesOfType: (NSString*)extension inDirectory: (NSString*)bundlePath; @@ -241,14 +245,29 @@ GS_EXPORT NSString* NSLoadedClasses; - (void) setBundleVersion: (unsigned)version; #ifndef STRICT_OPENSTEP +/** + * Returns subarray of given array containing those localizations that are + * used to locate resources given environment and user preferences. + */ + (NSArray *) preferredLocalizationsFromArray: (NSArray *)localizationsArray; +/** + * Returns subarray of given array containing those localizations that are + * used to locate resources given environment given user preferences (which + * are used instead of looking up the preferences of the current user). + */ + (NSArray *) preferredLocalizationsFromArray: (NSArray *)localizationsArray forPreferences: (NSArray *)preferencesArray; - (BOOL) isLoaded; +/** + * Not implemented. + */ - (NSArray*) pathsForResourcesOfType: (NSString*)extension inDirectory: (NSString*)bundlePath forLocalization: (NSString*)localizationName; +/** + * Not implemented. + */ - (NSString*) pathForResource: (NSString*)name ofType: (NSString*)ext inDirectory: (NSString*)bundlePath @@ -285,6 +304,10 @@ GS_EXPORT NSString* NSLoadedClasses; @end #ifndef NO_GNUSTEP +/** + * Augments [NSBundle], including methods for handling libraries in the GNUstep + * fashion, for rapid localization, and other purposes. + */ @interface NSBundle (GNUstep) /** This method is an experimental GNUstep extension, and @@ -301,15 +324,15 @@ GS_EXPORT NSString* NSLoadedClasses; + (NSString*) _gnustep_target_os; + (NSString*) _library_combo; -/** Find a resource in the "Library" directory */ +/** Find a resource in the "Library" directory. */ + (NSString*) pathForLibraryResource: (NSString*)name ofType: (NSString*)ext inDirectory: (NSString*)bundlePath; -/** Depreciated. Use +bundleForLibrary: instead. */ +/** Deprecated. Use +bundleForLibrary: instead. */ + (NSBundle*) gnustepBundle; -/** Depreciated. Use +pathForLibraryResource:ofType:inDirectory: +/** Deprecated. Use +pathForLibraryResource:ofType:inDirectory: or +bundleForLibrary: instead. */ + (NSString*) pathForGNUstepResource: (NSString*)name ofType: (NSString*)ext diff --git a/Headers/Foundation/NSCalendarDate.h b/Headers/Foundation/NSCalendarDate.h index ccc80abe4..18f43c017 100644 --- a/Headers/Foundation/NSCalendarDate.h +++ b/Headers/Foundation/NSCalendarDate.h @@ -106,7 +106,20 @@ #ifndef NO_GNUSTEP +/** + * Adds -weekOfYear method. + */ @interface NSCalendarDate (GSCategories) +/** + * The ISO standard week of the year is based on the first week of the + * year being that week (starting on monday) for which the thursday + * is on or after the first of january.
+ * This has the effect that, if january first is a friday, saturday or + * sunday, the days of that week (up to and including the sunday) are + * considered to be in week 53 of the preceeding year. Similarly if the + * last day of the year is a monday tuesday or wednesday, these days are + * part of week 1 of the next year. + */ - (int) weekOfYear; @end diff --git a/Headers/Foundation/NSCoder.h b/Headers/Foundation/NSCoder.h index 6b67abd42..4e7dcaa9f 100644 --- a/Headers/Foundation/NSCoder.h +++ b/Headers/Foundation/NSCoder.h @@ -30,51 +30,191 @@ @class NSMutableData, NSData, NSString; +/** + *

Top-level class defining methods for use when archiving (encoding) + * objects to a byte array or file, and when restoring (decoding) objects. + * Generally only subclasses of this class are used directly - [NSArchiver], + * [NSUnarchiver], [NSKeyedArchiver], [NSKeyedUnarchiver], or [NSPortCoder]. + *

+ *

NSPortCoder is used within the distributed objects + * framework. For archiving to/from disk, the Keyed... classes are + * preferred for new implementations, since they provide greater + * forward/backward compatibility in the face of class changes.

+ */ @interface NSCoder : NSObject // Encoding Data +/** + * Encodes array of count structures or objects of given type, which may be + * obtained through the '@encode(...)' compile-time operator. + * Usually this is used for primitives though it can be used for objects as + * well. + */ - (void) encodeArrayOfObjCType: (const char*)type count: (unsigned)count at: (const void*)array; + +/** + * Can be ignored. + */ - (void) encodeBycopyObject: (id)anObject; +/** + * Can be ignored. + */ - (void) encodeByrefObject: (id)anObject; + +/** + * Stores bytes directly into archive. + */ - (void) encodeBytes: (void*)d length: (unsigned)l; + +/** + * Encode object if it is/will be encoded unconditionally by this coder, + * otherwise store a nil. + */ - (void) encodeConditionalObject: (id)anObject; + +/** + * Encode an instance of [NSData]. + */ - (void) encodeDataObject: (NSData*)data; + +/** + * Encodes a generic object. This will usually result in an [NSCoding + * -encodeWithCoder:] message being sent to anObject so it can encode itself. + */ - (void) encodeObject: (id)anObject; + +/** + * Encodes a property list by calling [NSSerializer -serializePropertyList:], + * then encoding the resulting [NSData] object. + */ - (void) encodePropertyList: (id)plist; + +/** + * Encodes a point structure. + */ - (void) encodePoint: (NSPoint)point; + +/** + * Encodes a rectangle structure. + */ - (void) encodeRect: (NSRect)rect; + +/** + * Store object and objects it refers to in archive (i.e., complete object + * graph). + */ - (void) encodeRootObject: (id)rootObject; + +/** + * Encodes a size structure. + */ - (void) encodeSize: (NSSize)size; + +/** + * Encodes structure or object of given type, which may be obtained + * through the '@encode(...)' compile-time operator. Usually + * this is used for primitives though it can be used for objects as well. + */ - (void) encodeValueOfObjCType: (const char*)type at: (const void*)address; + +/** + * Multiple version of [-encodeValueOfObjCType:at:]. + */ - (void) encodeValuesOfObjCTypes: (const char*)types,...; // Decoding Data +/** + * Decodes array of count structures or objects of given type, which may be + * obtained through the '@encode(...)' compile-time operator. + * Usually this is used for primitives though it can be used for objects as + * well. Objects will be retained and you must release them. + */ - (void) decodeArrayOfObjCType: (const char*)type count: (unsigned)count at: (void*)address; + +/** + * Retrieve bytes directly from archive. + */ - (void*) decodeBytesWithReturnedLength: (unsigned*)l; + +/** + * Decode an instance of [NSData]. + */ - (NSData*) decodeDataObject; + +/** + * Decodes a generic object. Usually the class will be read from the + * archive, an object will be created through an alloc call, + * then that class will be sent an [NSCoding -initWithCoder:] message. + */ - (id) decodeObject; + +/** + * Decodes a property list from the archive previously stored through a call + * to [-encodePropertyList:]. + */ - (id) decodePropertyList; + +/** + * Decodes a point structure. + */ - (NSPoint) decodePoint; + +/** + * Decodes a rectangle structure. + */ - (NSRect) decodeRect; + +/** + * Decodes a size structure. + */ - (NSSize) decodeSize; + +/** + * Decodes structure or object of given type, which may be obtained + * through the '@encode(...)' compile-time operator. Usually + * this is used for primitives though it can be used for objects as well, + * in which case you are responsible for releasing them. + */ - (void) decodeValueOfObjCType: (const char*)type at: (void*)address; + +/** + * Multiple version of [-decodeValueOfObjCType:at:]. + */ - (void) decodeValuesOfObjCTypes: (const char*)types,...; // Managing Zones +/** + * Returns zone being used to allocate memory for decoded objects. + */ - (NSZone*) objectZone; + +/** + * Sets zone to use for allocating memory for decoded objects. + */ - (void) setObjectZone: (NSZone*)zone; // Getting a Version +/** + * Returns *Step version, which is not the release version, but a large number, + * by specification <1000 for pre-OpenStep. This implementation returns + * a number based on the GNUstep major, minor, and subminor versions. + */ - (unsigned int) systemVersion; + +/** + * Returns current version of class (when encoding) or version of decoded + * class (decoded). Version comes from [NSObject -getVersion]. + * + */ - (unsigned int) versionForClassName: (NSString*)className; #ifndef STRICT_OPENSTEP @@ -162,7 +302,7 @@ - (void) encodeBool: (BOOL) aBool forKey: (NSString*)aKey; /** - * Encodes the data of the specified length and pointed to by aPointeraBool, + * Encodes the data of the specified length and pointed to by aPointer, * and associates the encoded value with aKey. */ - (void) encodeBytes: (const uint8_t*)aPointer @@ -209,6 +349,9 @@ #ifndef NO_GNUSTEP +/** + * GNUstep extensions to [NSCoder], supporting compatibility with libObjects. + */ @interface NSCoder (GNUstep) /* Compatibility with libObjects */ - (void) decodeArrayOfObjCType: (const char*)type diff --git a/Headers/Foundation/NSConnection.h b/Headers/Foundation/NSConnection.h index b631e7b33..cd92ea998 100644 --- a/Headers/Foundation/NSConnection.h +++ b/Headers/Foundation/NSConnection.h @@ -146,22 +146,41 @@ GS_EXPORT NSString *NSConnectionProxyCount; /* Objects received */ @end -/* - * This catagory contains legacy methods from the original GNU 'Connection' - * class, and useful extensions to NSConnection. +/** + * This category contains legacy methods from the original GNU 'Connection' + * class, and useful extensions to [NSConnection]. */ @interface NSConnection (GNUstepExtensions) +/** + * Alternative convenience constructor, not specified in OpenStep, where you + * registe root anObject under given name in one step. + */ + (NSConnection*) newRegisteringAtName: (NSString*)name withRootObject: (id)anObject; +/** + * Performs local and remote cleanup. + */ - (void) gcFinalize; +/** + * [NSDistantObject -forward::] calls this to send the message over the wire. + */ - (retval_t) forwardForProxy: (NSDistantObject*)object selector: (SEL)sel argFrame: (arglist_t)argframe; + +/** + * [NSDistantObject -forwardInvocation:] calls this to send the message over + * the wire. + */ - (void) forwardInvocation: (NSInvocation *)inv forProxy: (NSDistantObject*)object; + +/** + * Returns type code (@encode()-compatible) for given remote method. + */ - (const char *) typeForSelector: (SEL)sel remoteTarget: (unsigned)target; @end @@ -169,8 +188,8 @@ GS_EXPORT NSString *NSConnectionProxyCount; /* Objects received */ GS_EXPORT NSString *ConnectionBecameInvalidNotification; @interface Object (NSConnectionDelegate) -/* - * This method may be used to ask a delegates permission to create +/** + * This method may be used to ask a delegate's permission to create * a new connection from the old one. * This method should be implemented in preference to the * [makeNewConnection:sender:] which is obsolete. @@ -178,7 +197,7 @@ GS_EXPORT NSString *ConnectionBecameInvalidNotification; - (BOOL) connection: (NSConnection*)parent shouldMakeNewConnection: (NSConnection*)newConnection; -/* +/** * This is the old way of doing the same thing as * [connection:shouldMakeNewConnection:] * It is obsolete - don't use it. @@ -186,7 +205,7 @@ GS_EXPORT NSString *ConnectionBecameInvalidNotification; - (BOOL) makeNewConnection: (NSConnection*)newConnection sender: (NSConnection*)parent; -/* +/** * If the delegate responds to this method, it will be used to ask the * delegate's permission to establish a new connection from the old one. * Often this is used so that the delegate can register for invalidation @@ -197,20 +216,29 @@ GS_EXPORT NSString *ConnectionBecameInvalidNotification; - (NSConnection*) connection: (NSConnection*)ancestorConn didConnect: (NSConnection*)newConn; -/* +/** * These are like the MacOS-X delegate methods, except that we provide the * components in mutable arrays, so that the delegate can alter the data * items in the array. Of course, you must do that WITH CARE. */ - (BOOL) authenticateComponents: (NSMutableArray*)components withData: (NSData*)authenticationData; + +/** + * These are like the MacOS-X delegate methods, except that we provide the + * components in mutable arrays, so that the delegate can alter the data + * items in the array. Of course, you must do that WITH CARE. + */ - (NSData*) authenticationDataForComponents: (NSMutableArray*)components; @end +/** + * This informal protocol allows an object to control the details of how an + * object is sent over the wire in distributed objects Port communications. + */ @interface Object (NSPortCoder) -- (Class) classForPortCoder; -/* +/** * Must return the class that will be created on the remote side * of the connection. If the class to be created is not the same * as that of the object returned by replacementObjectForPortCoder: @@ -221,14 +249,16 @@ GS_EXPORT NSString *ConnectionBecameInvalidNotification; * class is returned. To force bycopy operation the object should * return its own class. */ -- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder; -/* +- (Class) classForPortCoder; + +/** * This message is sent to an object about to be encoded for sending * over the wire. The default action is to return an NSDistantObject * which is a local proxy for the object unless the object is being * sent bycopy, in which case the actual object is returned. - * To force bycopy, an object should return itsself. + * To force bycopy, an object should return itself. */ +- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder; @end diff --git a/Headers/Foundation/NSData.h b/Headers/Foundation/NSData.h index 1064e2924..1275ca127 100644 --- a/Headers/Foundation/NSData.h +++ b/Headers/Foundation/NSData.h @@ -116,13 +116,70 @@ #ifndef NO_GNUSTEP +/** + * Extension methods for the NSData class- mainly conversion utilities. + */ @interface NSData (GSCategories) + +/** + * Returns an NSString object containing an ASCII hexadecimal representation + * of the receiver. This means that the returned object will contain + * exactly twice as many characters as there are bytes as the receiver, + * as each byte in the receiver is represented by two hexadecimal digits.
+ * The high order four bits of each byte is encoded before the low + * order four bits. Capital letters 'A' to 'F' are used to represent + * values from 10 to 15.
+ * If you need the hexadecimal representation as raw byte data, use code + * like - + * + * hexData = [[sourceData hexadecimalRepresentation] + * dataUsingEncoding: NSASCIIStringEncoding]; + * + */ - (NSString*) hexadecimalRepresentation; + +/** + * Initialises the receiver with the supplied string data which contains + * a hexadecimal coding of the bytes. The parsing of the string is + * fairly tolerant, ignoring whitespace and permitting both upper and + * lower case hexadecimal digits (the -hexadecimalRepresentation method + * produces a string using only uppercase digits with no white spaqce).
+ * If the string does not contain one or more pairs of hexadecimal digits + * then an exception is raised. + */ - (id) initWithHexadecimalRepresentation: (NSString*)string; + +/** + * Creates an MD5 digest of the information stored in the receiver and + * returns it as an autoreleased 16 byte NSData object.
+ * If you need to produce a digest of string information, you need to + * decide what character encoding is to be used and convert your string + * to a data object of that encoding type first using the + * [NSString-dataUsingEncoding:] method - + * + * myDigest = [[myString dataUsingEncoding: NSUTF8StringEncoding] md5Digest]; + * + * If you need to use the digest in a human readable form, you will + * probably want it to be seen as 32 hexadecimal digits, and can do that + * using the -hexadecimalRepresentation method. + */ - (NSData*) md5Digest; + +/** + * Decodes the source data from uuencoded and return the result.
+ * Returns the encoded file name in namePtr if it is not null. + * Returns the encoded file mode in modePtr if it is not null. + */ - (BOOL) uudecodeInto: (NSMutableData*)decoded name: (NSString**)namePtr mode: (int*)modePtr; + +/** + * Encode the source data to uuencoded.
+ * Uses the supplied name as the filename in the encoded data, + * and says that the file mode is as specified.
+ * If no name is supplied, uses untitled as the name. + */ - (BOOL) uuencodeInto: (NSMutableData*)encoded name: (NSString*)name mode: (int)mode; diff --git a/Headers/Foundation/NSDateFormatter.h b/Headers/Foundation/NSDateFormatter.h index bbbc9b6b1..783ae24bf 100644 --- a/Headers/Foundation/NSDateFormatter.h +++ b/Headers/Foundation/NSDateFormatter.h @@ -29,6 +29,67 @@ #include +/** + *

Class for generating text representations of [NSDate]s and + * [NSCalendarDate]s, and for converting strings into instances of these + * objects. Note that [NSDate] and [NSCalendarDate] do contain some + * string conversion methods, but using this class provides more control + * over conversion.

+ *

See the [NSFormatter] documentation for description of the basic methods + * for formatting and parsing that are available.

+ *

The basic format of a format string uses "%" codes to represent + * components of the date. Thus, for example, @"%b %d, %Y" + * specifies strings similar to "June 18, 1991". The full list of codes is + * as follows:

+ * + * %% + * a '%' character + * %a + * abbreviated weekday name + * %A + * full weekday name + * %b + * abbreviated month name + * %B + * full month name + * %c + * shorthand for "%X %x", the locale format for date and time + * %d + * day of the month as a decimal number (01-31) + * %e + * same as %d but does not print the leading 0 for days 1 through 9 (unlike strftime(), does not print a leading space) + * %F + * milliseconds as a decimal number (000-999) + * %H + * hour based on a 24-hour clock as a decimal number (00-23) + * %I + * hour based on a 12-hour clock as a decimal number (01-12) + * %j + * day of the year as a decimal number (001-366) + * %m + * month as a decimal number (01-12) + * %M + * minute as a decimal number (00-59) + * %p + * AM/PM designation for the locale + * %S + * second as a decimal number (00-59) + * %w + * weekday as a decimal number (0-6), where Sunday is 0 + * %x + * date using the date representation for the locale, including the time zone (produces different results from strftime()) + * %X + * time using the time representation for the locale (produces different results from strftime()) + * %y + * year without century (00-99) + * %Y + * year with century (such as 1990) + * %Z + * time zone name (such as Pacific Daylight Time; produces different results from strftime()) + * %z + * time zone offset in hours and minutes from GMT (HHMM) + * + */ @interface NSDateFormatter : NSFormatter { NSString *_dateFormat; @@ -36,11 +97,34 @@ } /* Initializing an NSDateFormatter */ + +/** + * Initialize with given specifier string format. See class description for + * how to specify a format string. If flag is YES, string-to-object + * conversion will attempt to process strings as natural language dates, such + * as "yesterday", or "first Tuesday of next month" if straight format-based + * conversion fails. + */ - (id) initWithDateFormat: (NSString *)format allowNaturalLanguage: (BOOL)flag; + /* Determining Attributes */ + +/** + * Returns whether initialized to support natural language formatting. If + * YES, string-to-object conversion will attempt to process strings as + * natural language dates, such as "yesterday", or "first Tuesday of next + * month" if straight format-based conversion fails. + */ - (BOOL) allowsNaturalLanguage; + +/** + * Returns format string initialized with, specifying how dates are formatted, + * for object-to-string conversion, and how they are parsed, for + * string-to-object conversion. For example, @"%b %d, %Y" + * specifies strings similar to "June 18, 1991". + */ - (NSString *) dateFormat; @end diff --git a/Headers/Foundation/NSDebug.h b/Headers/Foundation/NSDebug.h index 3035020f5..6a61f6edc 100644 --- a/Headers/Foundation/NSDebug.h +++ b/Headers/Foundation/NSDebug.h @@ -220,8 +220,9 @@ GS_EXPORT BOOL NSDeallocateZombies;

NSProcess initialises a set of strings that are the names of active debug levels using the '--GNU-Debug=...' command line argument. - Each command-line argument of that form is removed from NSProcessInfos - list of arguments and the variable part (...) is added to the set. + Each command-line argument of that form is removed from + NSProcessInfo's list of arguments and the variable part + (...) is added to the set. This means that as far as the program proper is concerned, it is running with the same arguments as if debugging had not been enabled.

@@ -233,7 +234,7 @@ GS_EXPORT BOOL NSDeallocateZombies;

NSUserDefaults also adds debug levels from the array given by the GNU-Debug key ... but these values will not take effect until the +standardUserDefaults method is called ... so they are useless for - debugging NSUserDefaults itsself or for debugging any code executed + debugging NSUserDefaults itself or for debugging any code executed before the defaults system is used.

To embed debug logging in your code you use the NSDebugLLog() or @@ -395,7 +396,7 @@ GS_EXPORT BOOL NSDeallocateZombies; something that it not necessarily fatal or illegal, but looks like it might be a programming error. eg. attempting to remove 'nil' from an NSArray, which the Spec/documentation does not prohibit, but which a - well written progam should not be attempting (since an NSArray object + well written program should not be attempting (since an NSArray object cannot contain a 'nil').

NB. The 'warn=yes' option is understood by the GNUstep make package @@ -405,7 +406,7 @@ GS_EXPORT BOOL NSDeallocateZombies;

To embed debug logging in your code you use the NSWarnLog() macro.

As a convenience, there are two more logging macros you can use - - NSWarnLog(), and NSWarnMLog(). + NSWarnFLog(), and NSWarnMLog(). These are specifically for use in either functions or methods and prepend information about the file, line and either function or class/method in which the message was generated. diff --git a/Headers/Foundation/NSDecimal.h b/Headers/Foundation/NSDecimal.h index c9fee4cbe..6a2d9d13c 100644 --- a/Headers/Foundation/NSDecimal.h +++ b/Headers/Foundation/NSDecimal.h @@ -50,7 +50,7 @@ typedef enum { NSCalculationDivideByZero } NSCalculationError; -/* +/** * Give a precision of at least 38 decimal digits * requires 128 bits. */ @@ -59,6 +59,21 @@ typedef enum { #define NSDecimalMaxDigit 38 #define NSDecimalNoScale 128 +/** + *

Structure providing equivalent functionality, in conjunction with a set + * of functions, to the [NSDecimalNumber] class.

+ +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]; +} NSDecimal; + +*

Instances can be initialized using the NSDecimalFromString(NSString *) +* function.

+ */ typedef struct { signed char exponent; /* Signed exponent - -128 to 127 */ BOOL isNegative; /* Is this negative? */ diff --git a/Headers/Foundation/NSDecimalNumber.h b/Headers/Foundation/NSDecimalNumber.h index f950e5ffb..d16b98677 100644 --- a/Headers/Foundation/NSDecimalNumber.h +++ b/Headers/Foundation/NSDecimalNumber.h @@ -33,15 +33,87 @@ @class NSDecimalNumber; +/** + * This protocol encapsulates information about how an [NSDecimalNumber] + * should round and process exceptions. Usually you can just create objects + * of the [NSDecimalNumberHandler] class, which implements this protocol, but + * if you don't want to use that class you can create your own implementing + * it. + */ @protocol NSDecimalNumberBehaviors + +/** + *

Specifies behavior when, in the course of applying method to leftOperand + * and rightOperand, an [NSDecimalNumber] instance encounters given error.

+ *

error has four possible constant values:

+ * + * NSCalculationLossOfPrecision + * The number can't be represented in 38 significant digits. + * NSCalculationOverflow + * The number is too large to represent. + * NSCalculationUnderflow + * The number is too small to represent. + * NSCalculationDivideByZero + * The caller tried to divide by 0. + * + * + *

Behavior on error can be one of the following:

+ * + * Raise an exception. + * Return nil. The calling method will return its value as though no + * error had occurred. If error is + * NSCalculationLossOfPrecision, method will return an + * imprecise value, constrained to 38 significant digits. If error is + * NSCalculationUnderflow or + * NSCalculationOverflow, method will return + * NSDecimalNumber's notANumber. You shouldn't + * return nil if error is NSDivideByZero. + * + * Correct the error and return a valid NSDecimalNumber. + * The calling method will use this as its own return value. + * + */ - (NSDecimalNumber*) exceptionDuringOperation: (SEL)method error: (NSCalculationError)error leftOperand: (NSDecimalNumber*)leftOperand rightOperand: (NSDecimalNumber*)rightOperand; + +/** + * Specifies how [NSDecimalNumber]'s decimalNumberBy... methods + * round their return values. This should be set to one of the following + * constants: + * + * NSRoundDown + * Always round down. + * NSRoundUp + * Always round up. + * NSRoundPlain + * Round to the closest possible return value. Halfway (e.g. .5) + * rounds up for positive numbers, down for negative (towards larger absolute + * value). + * NSRoundBankers + * Round to the closest possible return value, but halfway (e.g. .5) + * rounds towards possibility whose last digit is even. + * + */ - (NSRoundingMode) roundingMode; + +/** + * Specifies the precision of the values returned by [NSDecimalNumber]'s + * decimalNumberBy... methods, in terms of the number of + * digits allowed after the decimal point. This can be negative, implying + * that the precision should be, e.g., 100's, 1000's, etc.. For unlimited + * precision, set to NSDecimalNoScale. + */ - (short) scale; @end +/** + * A utility class adopting [NSDecimalNumberBehaviors] protocol. Can be used + * to control [NSDecimalNumber] rounding and exception-handling behavior, by + * passing an instance as an argument to any [NSDecimalNumber] method ending + * with ...Behavior:. + */ @interface NSDecimalNumberHandler : NSObject { NSRoundingMode _roundingMode; @@ -52,7 +124,19 @@ BOOL _raiseOnDivideByZero; } +/** + * Provides an instance implementing the default behavior for the + * [NSDecimalNumber] class. 38 decimal digits, rounded to closest return + * value (NSRoundPlain). Exceptions raised on overflow, + * underflow, and divide by zero. + */ + (id)defaultDecimalNumberHandler; + +/** + * Constructor setting all behavior. (For more precise control over error + * handling, create your own class implementing the [NSDecimalNumberBehaviors] + * protocol.) + */ + (id)decimalNumberHandlerWithRoundingMode:(NSRoundingMode)roundingMode scale:(short)scale raiseOnExactness:(BOOL)raiseOnExactness @@ -60,6 +144,11 @@ raiseOnUnderflow:(BOOL)raiseOnUnderflow raiseOnDivideByZero:(BOOL)raiseOnDivideByZero; +/** + * Initializor setting all behavior. (For more precise control over error + * handling, create your own class implementing the [NSDecimalNumberBehaviors] + * protocol.) + */ - (id)initWithRoundingMode:(NSRoundingMode)roundingMode scale:(short)scale raiseOnExactness:(BOOL)raiseOnExactness @@ -68,67 +157,249 @@ raiseOnDivideByZero:(BOOL)raiseOnDivideByZero; @end +/** + *

Class that implements a number of methods for performing decimal + * arithmetic to arbitrary precision. The behavior in terms of rounding + * choices and exception handling may be customized using the + * [NSDecimalNumberHandler] class, and defaults to + * [NSDecimalNumberHandler+defaultDecimalNumberHandler].

+ * + *

Equivalent functionality to the NSDecimalNumber class may + * be accessed through functions, mostly named NSDecimalXXX, + * e.g., NSDecimalMin(). Both the class and the functions use a structure + * called NSDecimal.

+ * + *

Note that instances of NSDecimalNumber are immutable.

+ */ @interface NSDecimalNumber : NSNumber { NSDecimal data; } +/** + * Returns the default rounding/precision/exception handling behavior, which + * is same as [NSDecimalNumberHandler+defaultDecimalNumberHandler] unless it + * has been explicitly set otherwise. + */ + (id )defaultBehavior; + +/** + * Sets the default rounding/precision/exception handling behavior to the + * given behavior. If this is not called, behavior defaults to + * [NSDecimalNumberHandler+defaultDecimalNumberHandler]. + */ + (void)setDefaultBehavior:(id )behavior; +/** + * Return maximum positive value that can be represented. + */ + (NSDecimalNumber *)maximumDecimalNumber; + +/** + * Return minimum negative value (not the smallest positive value) + * that can be represented. + */ + (NSDecimalNumber *)minimumDecimalNumber; + +/** + * Return a fixed value representing an NaN. + */ + (NSDecimalNumber *)notANumber; + +/** + * Return a constant object with a value of one. + */ + (NSDecimalNumber *)one; + +/** + * Return a constant object with a value of zero. + */ + (NSDecimalNumber *)zero; +/** + * New instance with given value. Note an NSDecimal may be created using the + * function NSDecimalFromString(). + */ + (NSDecimalNumber *)decimalNumberWithDecimal:(NSDecimal)decimal; + +/** + * New instance by component. Note that the precision of this initializer is + * limited. + */ + (NSDecimalNumber *)decimalNumberWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)isNegative; + +/** + * New instance from string. Arbitrary precision is preserved, though calling + * one of the decimalNumberBy... methods will return a result + * constrained by the current scale. Number format + * is parsed according to current default locale. + */ + (NSDecimalNumber *)decimalNumberWithString:(NSString *)numericString; + +/** + * New instance from string. Arbitrary precision is preserved, though calling + * one of the decimalNumberBy... methods will return a result + * constrained by the current scale. Number format + * is parsed according to given locale. + */ + (NSDecimalNumber *)decimalNumberWithString:(NSString *)numericString locale:(NSDictionary *)locale; +/** + * Initialize with given value. Note an NSDecimal may be created using the + * function NSDecimalFromString(). + */ - (id)initWithDecimal:(NSDecimal)decimal; + +/** + * Initialize by component. Note that the precision of this initializer is + * limited. + */ - (id)initWithMantissa:(unsigned long long)mantissa exponent:(short)exponent isNegative:(BOOL)flag; + +/** + * Initialize from string. Arbitrary precision is preserved, though calling + * one of the decimalNumberBy... methods will return a result + * constrained by the current scale. Number format + * is parsed according to current default locale. + */ - (id)initWithString:(NSString *)numberValue; + +/** + * Initialize from string. Arbitrary precision is preserved, though calling + * one of the decimalNumberBy... methods will return a result + * constrained by the current scale. Number format + * is parsed according to given locale. + */ - (id)initWithString:(NSString *)numberValue locale:(NSDictionary *)locale; +/** + * Returns the Objective-C type (@encode(...) compatible) of the + * data contained NSDecimalNumber, which is by convention "d" + * (for double), even though this is not strictly accurate. + */ - (const char *)objCType; +/** + * Return underlying value as an NSDecimal structure. + */ - (NSDecimal)decimalValue; + +/** + * Returns string version of number formatted accordng to locale. + */ - (NSString *)descriptionWithLocale:(NSDictionary *)locale; + +/** + * Returns underlying value as a double, which may be an + * approximation if precision greater than the default of 38. + */ - (double)doubleValue; + +/** + * Compares with other number, returning less, greater, or equal. + */ - (NSComparisonResult)compare:(NSNumber *)decimalNumber; +/** + * Adds self to decimalNumber and returns new result, using +defaultBehavior + * for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByAdding:(NSDecimalNumber *)decimalNumber; + +/** + * Adds self to decimalNumber and returns new result, using given behavior + * for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByAdding:(NSDecimalNumber *)decimalNumber withBehavior:(id)behavior; + +/** + * Divides self by decimalNumber and returns new result, using +defaultBehavior + * for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByDividingBy:(NSDecimalNumber *)decimalNumber; + +/** + * Divides self by decimalNumber and returns new result, using given behavior + * for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByDividingBy:(NSDecimalNumber *)decimalNumber withBehavior:(id )behavior; + +/** + * Multiplies self by decimalNumber and returns new result, using + * +defaultBehavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByMultiplyingBy:(NSDecimalNumber *)decimalNumber; + +/** + * Multiplies self by decimalNumber and returns new result, using given + * behavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByMultiplyingBy:(NSDecimalNumber *)decimalNumber withBehavior:(id )behavior; + +/** + * Multiplies self by given power of 10 and returns new result, using + * +defaultBehavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByMultiplyingByPowerOf10:(short)power; + +/** + * Multiplies self by given power of 10 and returns new result, using given + * behavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByMultiplyingByPowerOf10:(short)power withBehavior:(id )behavior; + +/** + * Raises self to given positive integer power and returns new result, using + * +defaultBehavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByRaisingToPower:(unsigned)power; + +/** + * Raises self to given positive integer power and returns new result, using + * given behavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberByRaisingToPower:(unsigned)power withBehavior:(id )behavior; -- (NSDecimalNumber *)decimalNumberByRoundingAccordingToBehavior:(id )behavior; + +/** + * Subtracts decimalNumber from self and returns new result, using + * +defaultBehavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberBySubtracting:(NSDecimalNumber *)decimalNumber; + +/** + * Subtracts decimalNumber from self and returns new result, using given + * behavior for rounding/precision/error handling. + */ - (NSDecimalNumber *)decimalNumberBySubtracting:(NSDecimalNumber *)decimalNumber withBehavior:(id )behavior; +/** + * Returns rounded version of underlying decimal. + */ +- (NSDecimalNumber *)decimalNumberByRoundingAccordingToBehavior:(id )behavior; + @end +/** + * Interface for obtaining an NSDecimalNumber value from an ordinary + * NSNumber. + */ @interface NSNumber (NSDecimalNumber) +/** + * Obtaining an NSDecimalNumber version of an ordinary NSNumber. + */ - (NSDecimal) decimalValue; @end diff --git a/Headers/Foundation/NSError.h b/Headers/Foundation/NSError.h index f26a2bef0..4e1927466 100644 --- a/Headers/Foundation/NSError.h +++ b/Headers/Foundation/NSError.h @@ -58,8 +58,9 @@ GS_EXPORT NSString* const NSOSStatusErrorDomain; GS_EXPORT NSString* const NSPOSIXErrorDomain; /** - * Error information class + * Error information class. */ +// TODO: document what this is for, especially since it's not in OS X @interface NSError : NSObject { @private @@ -89,7 +90,7 @@ GS_EXPORT NSString* const NSPOSIXErrorDomain; /** * Initialises the receiver using the supplied domain, code, and info.
- * The domain musat be non-nil. + * The domain must be non-nil. */ - (id) initWithDomain: (NSString*)aDomain code: (int)aCode @@ -105,10 +106,11 @@ GS_EXPORT NSString* const NSPOSIXErrorDomain; /** * Return the user info for this instance (or nil if none is set)
- * The NSLocalizedDescriptionKey should locate a human readable description - * in the dictionary.
- * The NSUnderlyingErrorKey key should locate an NSError instance if an - * error is available describing any underlying problem.
+ * The NSLocalizedDescriptionKey should locate a human readable + * description in the dictionary.
+ * The NSUnderlyingErrorKey key should locate an + * NSError instance if an error is available describing any + * underlying problem.
*/ - (NSDictionary*) userInfo; @end diff --git a/Headers/Foundation/NSFileHandle.h b/Headers/Foundation/NSFileHandle.h index 77b77891f..50dac7584 100644 --- a/Headers/Foundation/NSFileHandle.h +++ b/Headers/Foundation/NSFileHandle.h @@ -145,7 +145,7 @@ GS_EXPORT NSString * const NSFileHandleOperationException; - (BOOL) writeInProgress; @end -/* +/** * Where OpenSSL is available, you can use the subclass returned by +sslClass * to handle SSL connections. * The -sslAccept method is used to do SSL handlshake and start an diff --git a/Headers/Foundation/NSFormatter.h b/Headers/Foundation/NSFormatter.h index afe4d741a..c33f7174d 100644 --- a/Headers/Foundation/NSFormatter.h +++ b/Headers/Foundation/NSFormatter.h @@ -31,23 +31,88 @@ @class NSString, NSAttributedString, NSDictionary; +/** + * This abstract class defines the interface for classes that support + * interconversion between strings and objects of various types. GNUstep + * provides two concrete implementations of this class: [NSDateFormatter] + * and [NSNumberFormatter]. Others may be implemented for specialized + * applications. + */ @interface NSFormatter : NSObject { } +/** + * This method calls [-stringForObjectValue:] then marks up the string with + * attributes if it should be displayed specially. For example, in an + * application you may want to display out-of-range dates or numbers in + * italics. This is an optional method and may return nil to indicate that + * an attributed string is not provided. + */ - (NSAttributedString*) attributedStringForObjectValue: (id)anObject withDefaultAttributes: (NSDictionary*)attr; + +/** + * For use in applications where user interactively edits a string. If the + * version of the string for editing purposes should look different from the + * string displayed (returned by [-stringForObjectValue:] or + * [-attributedStringForObjectValue:withDefaultAttributes:]), return that + * here. For example, the edited string may contain formatting codes or + * similar that are not displayed in the final string. The default + * implementation simply returns [-stringForObjectValue:]. + */ - (NSString*) editingStringForObjectValue: (id)anObject; + +/** + * Primary method for converting a string to an object through parsing. + * anObject and error are output parameters; you should allocate memory for + * one pointer each for the variables passed into these methods. The + * returned object will have been created through alloc-init. + * If there is a problem with conversion, a constant-string description of + * what went wrong is returned through error, and NO is returned, otherwise + * YES. + */ - (BOOL) getObjectValue: (id*)anObject forString: (NSString*)string errorDescription: (NSString**)error; + +/** + * Checks whether partialString could, if it were completed, be + * parsed into a valid object. newString and error are output parameters; + * you should allocate memory for one pointer each for the variables passed + * into these methods. This method is set up to be called after every + * keystroke during user editing. If it returns NO, it optionally returns + * newString to replace what the user was editing; if it doesn't, the editor + * should delete the last character the user typed. + */ - (BOOL) isPartialStringValid: (NSString*)partialString newEditingString: (NSString**)newString errorDescription: (NSString**)error; + +/** + * Checks whether a change to a string leaves it a valid string that, if it + * were completed, could be parsed into a valid object. origString contains + * the string before the proposed change, and origSelRange contains the range + * that is updated in the proposed change. partialStringPtr contains the new + * string to validate and proposedSelRangePtr holds the selection range that + * will be used if the string is accepted or replaced. Basically, this method + * returns YES if partialStringPtr is valid, otherwise NO and may replace + * partialStringPtr and proposedSelectedRange with improved values, and may + * report the reason in error. + */ - (BOOL) isPartialStringValid: (NSString**)partialStringPtr proposedSelectedRange: (NSRange*)proposedSelRangePtr originalString: (NSString*)origString originalSelectedRange: (NSRange)originalSelRangePtr errorDescription: (NSString**)error; + + +/** + * Primary method for converting an object to a string through formatting. + * Object will be converted to string according to the formatter's + * implementation and init parameters. There is no default handling if the + * class of anObject is not what the formatter expects, and usually nil + * will be returned in this case. + */ - (NSString*) stringForObjectValue: (id)anObject; @end diff --git a/Headers/Foundation/NSGeometry.h b/Headers/Foundation/NSGeometry.h index 8ccef470c..9785af1e3 100644 --- a/Headers/Foundation/NSGeometry.h +++ b/Headers/Foundation/NSGeometry.h @@ -46,7 +46,12 @@ #define GS_DEFINED_MIN #endif -/* Point definition. */ +/** +{ + float x; + float y; +} +

Represents a 2-d cartesian position.

*/ typedef struct _NSPoint NSPoint; struct _NSPoint { @@ -55,11 +60,17 @@ struct _NSPoint }; #ifndef STRICT_OPENSTEP +/** Array of NSPoint structs. */ typedef NSPoint *NSPointArray; typedef NSPoint *NSPointPointer; #endif -/* Rectangle sizes. */ +/** +{ + float width; + float height; +} +

Floating point rectangle size.

*/ typedef struct _NSSize NSSize; struct _NSSize { @@ -72,7 +83,13 @@ typedef NSSize *NSSizeArray; typedef NSSize *NSSizePointer; #endif -/* Rectangle. */ +/** +{ + NSPoint origin; + NSSize size; +} + +

Rectangle.

*/ typedef struct _NSRect NSRect; struct _NSRect { @@ -81,6 +98,7 @@ struct _NSRect }; #ifndef STRICT_OPENSTEP +/** Array of NSPoint structs. */ typedef NSRect *NSRectArray; typedef NSRect *NSRectPointer; #endif @@ -95,8 +113,11 @@ enum _NSRectEdge NSMaxYEdge }; +/** Point at 0,0 */ static const NSPoint NSZeroPoint __attribute__((unused)); /* Zero point. */ +/** Zero-size rectangle at 0,0 */ static const NSRect NSZeroRect __attribute__((unused)); /* Zero rectangle. */ +/** Zero size */ static const NSSize NSZeroSize __attribute__((unused)); /* Zero size. */ /**** Function Prototypes ****************************************************/ diff --git a/Headers/Foundation/NSHashTable.h b/Headers/Foundation/NSHashTable.h index 2a612c0c8..a67f4bcca 100644 --- a/Headers/Foundation/NSHashTable.h +++ b/Headers/Foundation/NSHashTable.h @@ -47,25 +47,32 @@ typedef void* NSHashTable; */ typedef struct { void *map; void *node; size_t bucket; } NSHashEnumerator; -/** Callback functions.
*/ +/** Callback functions for an NSHashTable. See NSCreateHashTable() .
*/ typedef struct _NSHashTableCallBacks { - /** hash ... Hashing function. NOTE: Elements with equal values must have - * equal hash function values.
*/ + /** unsigned int (*hash)(NSHashTable *, const void *) ... + * Hashing function. NOTE: Elements with equal values must have equal hash + * function values. The default if NULL uses the pointer addresses + * directly.
*/ unsigned int (*hash)(NSHashTable *, const void *); - /** isEqual ... Comparison function.
*/ + /** BOOL (*isEqual)(NSHashTable *, const void *, const void *) + * ... Comparison function. The default if NULL uses '=='. + *
*/ BOOL (*isEqual)(NSHashTable *, const void *, const void *); - /** retain ... Retaining function called when adding elements - * to the table.
*/ + /** void (*retain)(NSHashTable *, const void *) ... + * Retaining function called when adding elements to the table. + * The default if NULL is a no-op (no reference counting).
*/ void (*retain)(NSHashTable *, const void *); - /** release ... Releasing function called when a data element is - * removed from the table.
*/ + /** void (*release)(NSHashTable *, void *) ... Releasing + * function called when a data element is removed from the table. + * The default if NULL is a no-op (no reference counting).
*/ void (*release)(NSHashTable *, void *); - /** describe ... Description function.
*/ + /** NSString *(*describe)(NSHashTable *, const void *) ... + * Description function. The default if NULL prints boilerplate.
*/ NSString *(*describe)(NSHashTable *, const void *); } NSHashTableCallBacks; diff --git a/Headers/Foundation/NSHost.h b/Headers/Foundation/NSHost.h index 71ada8602..9c40d3510 100644 --- a/Headers/Foundation/NSHost.h +++ b/Headers/Foundation/NSHost.h @@ -27,6 +27,10 @@ @class NSString, NSArray, NSSet; +/** + * Instances of this class encapsulate host information. Constructors based + * on host name or numeric address are provided. + */ @interface NSHost : NSObject { @private @@ -34,51 +38,82 @@ NSSet *_addresses; } -/* - * Get a host object. Hosts are cached for efficiency. Only one - * shared instance of a host will exist. - * Addresses must be "Dotted Decimal" strings, e.g. - * - * NSHost aHost = [NSHost hostWithAddress:@"192.42.172.1"]; - * +/** + * Get current host object. */ + (NSHost*) currentHost; + +/** + * Get info for host with given DNS name. + */ + (NSHost*) hostWithName: (NSString*)name; + +/** + * Get a host object. Hosts are cached for efficiency. The address + * must be an IPV4 "dotted decimal" string, e.g. + + NSHost aHost = [NSHost hostWithAddress:@"192.42.172.1"]; + + */ + (NSHost*) hostWithAddress: (NSString*)address; -/* - * Host cache management +/** + * Set host cache management. * If enabled, only one object representing each host will be created, and * a shared instance will be returned by all methods that return a host. */ + (void) setHostCacheEnabled: (BOOL)flag; + +/** + * Return host cache management. + * If enabled, only one object representing each host will be created, and + * a shared instance will be returned by all methods that return a host. + */ + (BOOL) isHostCacheEnabled; + +/** + * Clear cache of host info instances. + */ + (void) flushHostCache; -/* - * Compare hosts +/** + * Compare hosts. * Hosts are equal if they share at least one address */ - (BOOL) isEqualToHost: (NSHost*) aHost; -/* - * Host names. - * "name" will return one name (arbitrarily chosen) if a host has several. +/** + * Return host name. Chosen arbitrarily if a host has more than one. */ - (NSString*) name; + +/** + * Return all known names for host. + */ - (NSArray*) names; -/* - * Host addresses. - * Addresses are represented as "Dotted Decimal" strings, e.g. @"192.42.172.1" - * "address" will return one address (arbitrarily chosen) if there are several. +/** + * Return host address in "dotted decimal" notation, e.g. "192.42.172.1". + * Chosen arbitrarily if a host has more than one. */ - (NSString*) address; + +/** + * Return all known addresses for host in "dotted decimal" notation, + * e.g. "192.42.172.1". + */ - (NSArray*) addresses; @end +/** + * Adds synonym for +currentHost. + */ @interface NSHost (GNUstep) + +/** + * Synonym for +currentHost. + */ + (NSHost*) localHost; /* All local IP addresses */ @end diff --git a/Headers/Foundation/NSKeyedArchiver.h b/Headers/Foundation/NSKeyedArchiver.h index eb6cd474f..9bfdcbd55 100644 --- a/Headers/Foundation/NSKeyedArchiver.h +++ b/Headers/Foundation/NSKeyedArchiver.h @@ -37,7 +37,12 @@ @class NSMutableDictionary, NSMutableData, NSData, NSString; /** - * Keyed archiving class + * Implements keyed archiving of object graphs. This archiver + * should be used instead of [NSArchiver] for new implementations. Classes + * implementing [NSCoding] should check the [NSCoder-allowsKeyedCoding] + * method and if the response is YES, encode/decode their fields using the + * ...forKey: [NSCoder] methods, which provide for more robust + * forwards and backwards compatibility. */ @interface NSKeyedArchiver : NSCoder { @@ -100,16 +105,53 @@ */ - (id) delegate; +/** + * Encodes aBool and associates the encoded value with aKey. + */ - (void) encodeBool: (BOOL)aBool forKey: (NSString*)aKey; + +/** + * Encodes the data of the specified length and pointed to by aPointer, + * and associates the encoded value with aKey. + */ - (void) encodeBytes: (const uint8_t*)aPointer length: (unsigned)length forKey: (NSString*)aKey; + +/** + * Encodes anObject and associates the encoded value with aKey, but only + * if anObject has already been encoded using -encodeObject:forKey: + */ - (void) encodeConditionalObject: (id)anObject forKey: (NSString*)aKey; + +/** + * Encodes aDouble and associates the encoded value with aKey. + */ - (void) encodeDouble: (double)aDouble forKey: (NSString*)aKey; + +/** + * Encodes aFloat and associates the encoded value with aKey. + */ - (void) encodeFloat: (float)aFloat forKey: (NSString*)aKey; + +/** + * Encodes anInteger and associates the encoded value with aKey. + */ - (void) encodeInt: (int)anInteger forKey: (NSString*)aKey; + +/** + * Encodes anInteger and associates the encoded value with aKey. + */ - (void) encodeInt32: (int32_t)anInteger forKey: (NSString*)aKey; + +/** + * Encodes anInteger and associates the encoded value with aKey. + */ - (void) encodeInt64: (int64_t)anInteger forKey: (NSString*)aKey; + +/** + * Encodes anObject and associates the encoded value with aKey. + */ - (void) encodeObject: (id)anObject forKey: (NSString*)aKey; /** @@ -159,7 +201,12 @@ /** - * Keyed unarchiving class. + * Implements keyed unarchiving of object graphs. The keyed archiver + * should be used instead of [NSArchiver] for new implementations. Classes + * implementing [NSCoding] should check the [NSCoder-allowsKeyedCoding] + * method and if the response is YES, encode/decode their fields using the + * ...forKey: [NSCoder] methods, which provide for more robust + * forwards and backwards compatibility. */ @interface NSKeyedUnarchiver : NSCoder { @@ -182,29 +229,132 @@ NSZone *_zone; /* Zone for allocating objs. */ } +/** + * Returns class substituted for class name specified by aString when + * encountered in the archive being decoded from, or nil if there is no + * specific translation mapping. Each instance also maintains a translation + * map, which is searched first for a match during decoding. + */ + (Class) classForClassName: (NSString*)aString; + +/** + * Sets class substituted for class name specified by aString when + * encountered in the archive being decoded from, or nil if there is no + * specific translation mapping. Each instance also maintains a translation + * map, which is searched first for a match during decoding. + */ + (void) setClass: (Class)aClass forClassName: (NSString*)aString; + +/** + * Decodes from byte array in data and returns resulting root object. + */ + (id) unarchiveObjectWithData: (NSData*)data; + +/** + * Decodes from file contents at aPath and returns resulting root object. + */ + (id) unarchiveObjectWithFile: (NSString*)aPath; +/** + * Returns class substituted for class name specified by aString when + * encountered in the archive being decoded from, or nil if there is no + * specific translation mapping. The class as a whole also maintains a + * translation map, which is searched on decoding if no match found here. + */ - (Class) classForClassName: (NSString*)aString; + +/** + * Sets class substituted for class name specified by aString when + * encountered in the archive being decoded from, or nil if there is no + * specific translation mapping. Each instance also maintains a translation + * map, which is searched first for a match during decoding. + */ - (BOOL) containsValueForKey: (NSString*)aKey; + +/** + * Sets class substituted for class name specified by aString when + * encountered in the archive being decoded from, or nil if there is no + * specific translation mapping. Each instance also maintains a translation + * map, which is searched first for a match during decoding. + */ +- (void) setClass: (Class)aClass forClassName: (NSString*)aString; + +/** + * Returns a boolean value associated with aKey. This value must previously + * have been encoded using -encodeBool:forKey: + */ - (BOOL) decodeBoolForKey: (NSString*)aKey; + +/** + * Returns a pointer to a byte array associated with aKey.
+ * Returns the length of the data in aLength.
+ * This value must previously have been encoded using + * -encodeBytes:length:forKey: + */ - (const uint8_t*) decodeBytesForKey: (NSString*)aKey returnedLength: (unsigned*)length; -- (double) decodeDoubleForKey: (NSString*)aKey; -- (float) decodeFloatForKey: (NSString*)aKey; -- (int) decodeIntForKey: (NSString*)aKey; -- (int32_t) decodeInt32ForKey: (NSString*)aKey; -- (int64_t) decodeInt64ForKey: (NSString*)aKey; -- (id) decodeObjectForKey: (NSString*)aKey; + /** - * returns the delegate of the unarchiver. + * Returns a double value associated with aKey. This value must previously + * have been encoded using -encodeDouble:forKey: or -encodeFloat:forKey: + */ +- (double) decodeDoubleForKey: (NSString*)aKey; + +/** + * Returns a float value associated with aKey. This value must previously + * have been encoded using -encodeFloat:forKey: or -encodeDouble:forKey:
+ * Precision may be lost (or an exception raised if the value will not fit + * in a float) if the value was encoded using -encodeDouble:forKey:, + */ +- (float) decodeFloatForKey: (NSString*)aKey; + +/** + * Returns an integer value associated with aKey. This value must previously + * have been encoded using -encodeInt:forKey:, -encodeInt32:forKey:, or + * -encodeInt64:forKey:.
+ * An exception will be raised if the value does not fit in an integer. + */ +- (int) decodeIntForKey: (NSString*)aKey; + +/** + * Returns a 32-bit integer value associated with aKey. This value must + * previously have been encoded using -encodeInt:forKey:, + * -encodeInt32:forKey:, or -encodeInt64:forKey:.
+ * An exception will be raised if the value does not fit in a 32-bit integer. + */ +- (int32_t) decodeInt32ForKey: (NSString*)aKey; + +/** + * Returns a 64-bit integer value associated with aKey. This value must + * previously have been encoded using -encodeInt:forKey:, + * -encodeInt32:forKey:, or -encodeInt64:forKey:. + */ +- (int64_t) decodeInt64ForKey: (NSString*)aKey; + +/** + * Returns an object value associated with aKey. This value must + * previously have been encoded using -encodeObject:forKey: or + * -encodeConditionalObject:forKey: + */ +- (id) decodeObjectForKey: (NSString*)aKey; + +/** + * Returns the delegate of the unarchiver. */ - (id) delegate; + +/** + * Tells receiver that you are done retrieving from archive, so the delegate + * should be allowed to perform close-up operations. + */ - (void) finishDecoding; + +/** + * Prepare to read data from key archive (created by [NSKeyedArchiver]). + * Be sure to call -finishDecoding when done. + */ - (id) initForReadingWithData: (NSData*)data; -- (void) setClass: (Class)aClass forClassName: (NSString*)aString; + /** * Sets the receivers delegate. The delegate should conform to the * NSObject(NSKeyedUnarchiverDelegate) informal protocol.
@@ -215,10 +365,17 @@ @end +/** + * Internal methods. Do not use. + */ @interface NSKeyedArchiver (Internal) - (void) _encodeArrayOfObjects: (NSArray*)anArray forKey: (NSString*)aKey; - (void) _encodePropertyList: (id)anObject forKey: (NSString*)aKey; @end + +/** + * Internal methods. Do not use. + */ @interface NSKeyedUnarchiver (Internal) - (id) _decodeArrayOfObjectsForKey: (NSString*)aKey; - (id) _decodePropertyListForKey: (NSString*)aKey; @@ -231,7 +388,7 @@ GS_EXPORT NSString * const NSInvalidUnarchiveOperationException; /** - * Informal protocol implemented by delegates of [NSKeyedArchiver] + * Informal protocol implemented by delegates of [NSKeyedArchiver]. */ @interface NSObject (NSKeyedArchiverDelegate) @@ -277,7 +434,7 @@ willReplaceObject: (id)anObject /** - * Informal protocol implemented by delegates of [NSKeyedUnarchiver] + * Informal protocol implemented by delegates of [NSKeyedUnarchiver]. */ @interface NSObject (NSKeyedUnarchiverDelegate) @@ -325,7 +482,7 @@ willReplaceObject: (id)anObject /** - * Methods by which a class may control its archiving by the NSKeyedArchiver + * Methods by which a class may control its archiving by the [NSKeyedArchiver]. */ @interface NSObject (NSKeyedArchiverObjectSubstitution) @@ -351,6 +508,10 @@ willReplaceObject: (id)anObject @end +/** + * Methods by which a class may control its unarchiving by the + * [NSKeyedArchiver]. + */ @interface NSObject (NSKeyedUnarchiverObjectSubstitution) /** @@ -363,34 +524,37 @@ willReplaceObject: (id)anObject @end +/** + * Methods for encoding/decoding points, rectangles, and sizes. + */ @interface NSCoder (NSGeometryKeyedCoding) /** - * Encodes an NSPoint object. + * Encodes an NSPoint object. */ - (void) encodePoint: (NSPoint)aPoint forKey: (NSString*)aKey; /** - * Encodes an NSRect object. + * Encodes an NSRect object. */ - (void) encodeRect: (NSRect)aRect forKey: (NSString*)aKey; /** - * Encodes an NSSize object. + * Encodes an NSSize object. */ - (void) encodeSize: (NSSize)aSize forKey: (NSString*)aKey; /** - * Decodes an NSPoint object. + * Decodes an NSPoint object. */ - (NSPoint) decodePointForKey: (NSString*)aKey; /** - * Decodes an NSRect object. + * Decodes an NSRect object. */ - (NSRect) decodeRectForKey: (NSString*)aKey; /** - * Decodes an NSSize object. + * Decodes an NSSize object. */ - (NSSize) decodeSizeForKey: (NSString*)aKey; @end diff --git a/Headers/Foundation/NSLock.h b/Headers/Foundation/NSLock.h index 8968716ff..780891a7b 100644 --- a/Headers/Foundation/NSLock.h +++ b/Headers/Foundation/NSLock.h @@ -33,19 +33,25 @@ #include -/* - * NSLocking protocol +/** + * Protocol defining lock and unlock operations. */ @protocol NSLocking +/** + * Block until acquiring lock. + */ - (void) lock; + +/** + * Relinquish lock. + */ - (void) unlock; @end -/* - * NSLock class - * Simplest lock for protecting critical sections of code +/** + * Simplest lock for protecting critical sections of code. */ @interface NSLock : NSObject { @@ -53,17 +59,32 @@ void *_mutex; } +/** + * Try to acquire lock and return immediately, YES if succeeded, NO if not. + */ - (BOOL) tryLock; + +/** + * Try to acquire lock and return before limit, YES if succeeded, NO if not. + */ - (BOOL) lockBeforeDate: (NSDate*)limit; +/** + * Block until acquiring lock. + */ - (void) lock; + +/** + * Relinquish lock. + */ - (void) unlock; @end -/* - * NSConditionLock - * Allows locking and unlocking to be based upon a condition +/** + * Lock that allows user to request it only when an internal integer + * condition is equal to a particular value. The condition is set on + * initialization and whenever the lock is relinquished. */ @interface NSConditionLock : NSObject { @@ -73,39 +94,74 @@ int _condition_value; } -/* - * Initialize lock with condition +/** + * Initialize lock with given condition. */ - (id) initWithCondition: (int)value; -/* - * Return the current condition of the lock +/** + * Return the current condition of the lock. */ - (int) condition; /* - * Acquiring and release the lock + * Acquiring and releasing the lock. + */ + +/** + * Acquire lock when it is available and the internal condition is equal to + * value. Blocks until this occurs. */ - (void) lockWhenCondition: (int)value; + +/** + * Relinquish the lock, setting internal condition to value. + */ - (void) unlockWithCondition: (int)value; + +/** + * Try to acquire lock regardless of condition and return immediately, YES if + * succeeded, NO if not. + */ - (BOOL) tryLock; + +/** + * Try to acquire lock if condition is equal to value and return immediately + * in any case, YES if succeeded, NO if not. + */ - (BOOL) tryLockWhenCondition: (int)value; /* - * Acquiring the lock with a date condition + * Acquiring the lock with a date condition. + */ + +/** + * Try to acquire lock and return before limit, YES if succeeded, NO if not. */ - (BOOL) lockBeforeDate: (NSDate*)limit; + +/** + * Try to acquire lock, when internal condition is equal to condition_to_meet, + * and return before limit, YES if succeeded, NO if not. + */ - (BOOL) lockWhenCondition: (int)condition_to_meet beforeDate: (NSDate*)limitDate; +/** + * Block until acquiring lock. + */ - (void) lock; + +/** + * Relinquish lock. + */ - (void) unlock; @end -/* - * NSRecursiveLock - * Allows the lock to be recursively acquired by the same thread + +/** + * Allows the lock to be recursively acquired by the same thread. * * If the same thread locks the mutex (n) times then that same * thread must also unlock it (n) times before another thread @@ -117,10 +173,25 @@ void *_mutex; } +/** + * Try to acquire lock regardless of condition and return immediately, YES if + * succeeded, NO if not. + */ - (BOOL) tryLock; + +/** + * Try to acquire lock and return before limit, YES if succeeded, NO if not. + */ - (BOOL) lockBeforeDate: (NSDate*)limit; +/** + * Block until acquiring lock. + */ - (void) lock; + +/** + * Relinquish lock. + */ - (void) unlock; @end @@ -153,11 +224,63 @@ #define GS_INITIALIZED_LOCK(IDENT,CLASSNAME) \ (IDENT != nil ? IDENT : [CLASSNAME newLockAt: &IDENT]) +/** + * Defines the newLockAt: method. + */ @interface NSLock (GSCategories) +/** + * Initializes the id pointed to by location + * with a new instance of the receiver's class + * in a thread safe manner, unless + * it has been previously initialized. + * Returns the contents pointed to by location. + * The location is considered unintialized if it contains nil. + *
+ * 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. + * + * NSLock *my_lock = nil; + * + * void function (void) + * { + * [GS_INITIALIZED_LOCK(my_lock, NSLock) lock]; + * do_work (); + * [my_lock unlock]; + * } + * + * + */ + (id)newLockAt:(id *)location; @end +/** + * Defines the newLockAt: method. + */ @interface NSRecursiveLock (GSCategories) +/** + * Initializes the id pointed to by location + * with a new instance of the receiver's class + * in a thread safe manner, unless + * it has been previously initialized. + * Returns the contents pointed to by location. + * The location is considered unintialized if it contains nil. + *
+ * 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. + * + * NSLock *my_lock = nil; + * + * void function (void) + * { + * [GS_INITIALIZED_LOCK(my_lock, NSRecursiveLock) lock]; + * do_work (); + * [my_lock unlock]; + * } + * + * + */ + (id)newLockAt:(id *)location; @end diff --git a/Headers/Foundation/NSMapTable.h b/Headers/Foundation/NSMapTable.h index bb6803e5c..1c3c72362 100644 --- a/Headers/Foundation/NSMapTable.h +++ b/Headers/Foundation/NSMapTable.h @@ -81,7 +81,7 @@ typedef struct _NSMapTableKeyCallBacks /** * Description function. Generates a string describing the key - * and does not modify the key itsself. + * and does not modify the key itself. */ NSString *(*describe)(NSMapTable *, const void *); @@ -115,7 +115,7 @@ struct _NSMapTableValueCallBacks /** * Description function. Generates a string describing the element - * and does not modify the element itsself. + * and does not modify the element itself. */ NSString *(*describe)(NSMapTable *, const void *); }; diff --git a/Headers/Foundation/NSMethodSignature.h b/Headers/Foundation/NSMethodSignature.h index 23b4e815c..259c2e456 100644 --- a/Headers/Foundation/NSMethodSignature.h +++ b/Headers/Foundation/NSMethodSignature.h @@ -29,12 +29,22 @@ #include #ifndef STRICT_MACOS_X -/* - * Info about layout of arguments. +/** + *

Info about layout of arguments. * Extended from the original OpenStep version to let us know if the - * arg is passed in registers or on the stack. + * arg is passed in registers or on the stack.

* - * NB. This no longer exists in Rhapsody/MacOS. + *

NB. This no longer exists in Rhapsody/MacOS.

+ +typedef struct { + int offset; + unsigned size; + const char *type; + unsigned align; // extension, available only ifndef NO_GNUSTEP + unsigned qual; // extension, available only ifndef NO_GNUSTEP + BOOL isReg; // extension, available only ifndef NO_GNUSTEP +} NSArgumentInfo; + */ typedef struct { int offset; @@ -48,6 +58,19 @@ typedef struct { } NSArgumentInfo; #endif +/** + *

Class encapsulating type information for method arguments and return + * value. It is used as a component of [NSInvocation] to implement message + * forwarding, such as within the distributed objects framework. Instances + * can be obtained from the [NSObject] method + * [NSObject-methodSignatureForSelector:].

+ * + *

Basically, types are represented as Objective-C @encode(...) + * compatible strings, together with size information. The arguments are + * numbered starting from 0, including the implicit arguments + * self (type id, at position 0) and + * _cmd (type SEL, at position 1).

+ */ @interface NSMethodSignature : NSObject { const char *_methodTypes; @@ -60,23 +83,78 @@ typedef struct { #endif } +/** + * Build a method signature directly from string description of return type and + * argument types, using the Objective-C @encode(...) type codes. + */ + (NSMethodSignature*) signatureWithObjCTypes: (const char*)t; #ifndef STRICT_MACOS_X +/** + * Returns full information on given argument. Indices start at 0. Provide + * -1 to get info on return value. + */ - (NSArgumentInfo) argumentInfoAtIndex: (unsigned)index; #endif + +/** + * Number of bytes that the full set of arguments occupies on the stack, which + * is platformt(hardware)-dependent. + */ - (unsigned) frameLength; + +/** + * Returns Objective-C @encode(...) compatible string. Arguments + * are numbered starting from 0, including the implicit arguments + * self (type id, at position 0) and + * _cmd (type SEL, at position 1). + */ - (const char*) getArgumentTypeAtIndex: (unsigned)index; + +/** + * Pertains to distributed objects; method is asynchronous when invoked and + * return should not be waited for. + */ - (BOOL) isOneway; + +/** + * Number of bytes that the return value occupies on the stack, which is + * platformt(hardware)-dependent. + */ - (unsigned) methodReturnLength; + +/** + * Returns Objective-C @encode(...) compatible string. Arguments + * are numbered starting from 0, including the implicit arguments + * self (type id, at position 0) and + * _cmd (type SEL, at position 1). + */ - (const char*) methodReturnType; + +/** + * Returns number of arguments to method, including the implicit + * self and _cmd. + */ - (unsigned) numberOfArguments; @end #ifndef NO_GNUSTEP +/** + * Declares a convenience method for getting the entire array of raw type and + * size information. + */ @interface NSMethodSignature(GNUstep) +/** + * Convenience method for getting the entire array of raw type and size + * information. + */ - (NSArgumentInfo*) methodInfo; + +/** + * Returns a string containing all Objective-C + * @encode(...) compatible type information. + */ - (const char*) methodType; @end #endif diff --git a/Headers/Foundation/NSNotification.h b/Headers/Foundation/NSNotification.h index 390588a43..6bfee5d00 100644 --- a/Headers/Foundation/NSNotification.h +++ b/Headers/Foundation/NSNotification.h @@ -85,19 +85,25 @@ #ifndef NO_GNUSTEP +/** + * Defines some extensions for maximising posting performance - these options + * are NOT adjustable for the default notification center. + * + */ @interface NSNotificationCenter (GNUstep) -/* - * Extensions for maximising posting performance - these options are - * NOT adjustable for the default notification center. - * - * You can disable locking in a multi-threaded program if you KNOW that only - * one thread will ever use the notification center. - * + +/** * You can turn on 'immutability' if you KNOW that the posting of a * notification will never result in an attempt to modify the center. * In this case, the center can optimise delivery of notifications. */ - (BOOL) setImmutableInPost: (BOOL)flag; + +/** + * + * You can disable locking in a multi-threaded program if you KNOW that only + * one thread will ever use the notification center. + */ - (BOOL) setLockingDisabled: (BOOL)flag; @end #endif diff --git a/Headers/Foundation/NSNumberFormatter.h b/Headers/Foundation/NSNumberFormatter.h index ba62cb4cf..7127ff2fa 100644 --- a/Headers/Foundation/NSNumberFormatter.h +++ b/Headers/Foundation/NSNumberFormatter.h @@ -33,6 +33,42 @@ @class NSString, NSAttributedString, NSDictionary; +/** + *

This class is currently not implemented in GNUstep! All set + * methods will work, but stringForObject: will ignore the format completely. + * The documentation below describes what the behavior SHOULD + * be...

+ * + *

A specialization of the [NSFormatter] class for generating string + * representations of numbers ([NSNumber] and [NSDecimalNumber] instances) and + * for parsing numeric values in strings.

+ * + *

See the [NSFormatter] documentation for description of the basic methods + * for formatting and parsing that are available.

+ * + *

There are no convenience initializers or constructors for this class. + * Instead, to obtain an instance, call alloc init and then -setFormat: .

+ * + *

The basic format of a format string uses "#" signs to represent digits, + * and other characters to represent themselves, in a context-dependent way. + * Thus, for example, @"#,###.00" means to print the number + * ending in .00 if it has no decimal part, otherwise print two decimal + * places, and to print one comma if it is greater than 1000. Thus, 1000 + * prints as "1,000.00", and 1444555.979 prints as "1444,555.98" (see + * -setRoundingBehavior:).

+ * + *

After setting the format, you may change the thousands separator and + * decimal point using set methods, or by calling -setLocalizesFormat: .

+ * + *

You may set separate formats to be used for positive numbers, negative + * numbers, and zero independently.

+ * + *

In addition, this class supports attributed strings (see + * [NSAttributedString]), so that you can specify font and color attributes, + * among others, to display aspects of a number. You can assign specific sets + * of attributes for positive and negative numbers, and for specific cases + * including 0, NaN, and nil...

+ */ @interface NSNumberFormatter: NSFormatter { BOOL _hasThousandSeparators; @@ -53,45 +89,207 @@ } // Format +/** + * Returns the format string this instance was initialized with. + */ - (NSString*) format; + +/** + * Sets format string. See class description for more information. + */ - (void) setFormat: (NSString*)aFormat; + +/** + * Returns whether this format should defer to the locale in determining + * thousands separator and decimal point. The default is to NOT localize. + */ - (BOOL) localizesFormat; + +/** + * Set whether this format should defer to the locale in determining thousands + * separator and decimal point. The default is to NOT localize. + */ - (void) setLocalizesFormat: (BOOL)flag; + +/** + * Returns format used for negative numbers. + */ - (NSString*) negativeFormat; + +/** + * Sets format used for negative numbers. See class description for more + * information. + */ - (void) setNegativeFormat: (NSString*)aFormat; + +/** + * Returns format used for positive numbers. + */ - (NSString*) positiveFormat; + +/** + * Sets format used for positive numbers. See class description for more + * information. + */ - (void) setPositiveFormat: (NSString*)aFormat; + // Attributed Strings +/** + * Returns the exact attributed string used for nil values. By default this + * is an empty string. + */ - (NSAttributedString*) attributedStringForNil; + +/** + * Sets the exact attributed string used for nil values. By default this + * is an empty string. + */ - (void) setAttributedStringForNil: (NSAttributedString*)newAttributedString; + +/** + * Returns the exact attributed string used for NaN values. By default this + * is the string "NaN" with no attributes. + */ - (NSAttributedString*) attributedStringForNotANumber; + +/** + * Sets the exact attributed string used for NaN values. By default this + * is the string "NaN" with no attributes. + */ - (void) setAttributedStringForNotANumber: (NSAttributedString*)newAttributedString; + +/** + * Returns the exact attributed string used for zero values. By default this + * is based on the format for zero values, if set, or the format for positive + * values otherwise. + */ - (NSAttributedString*) attributedStringForZero; + +/** + * Sets the exact attributed string used for zero values. By default this + * is based on the format for zero values, if set, or the format for positive + * values otherwise. + */ - (void) setAttributedStringForZero: (NSAttributedString*)newAttributedString; + +/** + * Returns the attributes to apply to negative values (whole string), when + * -attributedStringForObjectValue:withDefaultAttributes: is called. Default + * is none. + */ - (NSDictionary*) textAttributesForNegativeValues; + +/** + * Sets the attributes to apply to negative values (whole string), when + * -attributedStringForObjectValue:withDefaultAttributes: is called. Default + * is none. + */ - (void) setTextAttributesForNegativeValues: (NSDictionary*)newAttributes; + +/** + * Returns the attributes to apply to positive values (whole string), when + * -attributedStringForObjectValue:withDefaultAttributes: is called. Default + * is none. + */ - (NSDictionary*) textAttributesForPositiveValues; + +/** + * Sets the attributes to apply to positive values (whole string), when + * -attributedStringForObjectValue:withDefaultAttributes: is called. Default + * is none. + */ - (void) setTextAttributesForPositiveValues: (NSDictionary*)newAttributes; -// Rounding + +// Rounding.. this should be communicated as id, +// not NSDecimalNumberHandler, but this is the way OpenStep and OS X do it.. + +/** + * Returns object specifying the rounding behavior used when truncating + * decimal digits in formats. Default is + * [NSDecimalNumberHandler+defaultDecimalNumberHandler]. + */ - (NSDecimalNumberHandler*) roundingBehavior; + +/** + * Sets object specifying the rounding behavior used when truncating + * decimal digits in formats. Default is + * [NSDecimalNumberHandler+defaultDecimalNumberHandler]. + */ - (void) setRoundingBehavior: (NSDecimalNumberHandler*)newRoundingBehavior; // Separators + +/** + * Returns whether thousands separator should be used, regardless of whether + * it is set in format. (Default is YES if explicitly set in format.) + */ - (BOOL) hasThousandSeparators; + +/** + * Sets whether thousands separator should be used, regardless of whether + * it is set in format. (Default is YES if explicitly set in format.) + */ - (void) setHasThousandSeparators: (BOOL)flag; + + +/** + * Returns thousands separator used; default is ','. + */ - (NSString*) thousandSeparator; + +/** + * Sets thousands separator used; default is ','. + */ - (void) setThousandSeparator: (NSString*)newSeparator; + +/** + * Returns whether number parsing will accept floating point values or generate + * an exception (only int values are valid). Default is YES. + */ - (BOOL) allowsFloats; + +/** + * Sets whether number parsing will accept floating point values or generate + * an exception (only int values are valid). Default is YES. + */ - (void) setAllowsFloats: (BOOL)flag; + +/** + * Returns thousands separator used; default is '.'. + */ - (NSString*) decimalSeparator; + +/** + * Sets thousands separator used; default is '.'. + */ - (void) setDecimalSeparator: (NSString*)newSeparator; // Maximum/minimum + +/** + * Returns maximum value that will be accepted as valid in number parsing. + * Default is none. + */ - (NSDecimalNumber*) maximum; + +/** + * Sets maximum value that will be accepted as valid in number parsing. + * Default is none. + */ - (void) setMaximum: (NSDecimalNumber*)aMaximum; + +/** + * Returns minimum value that will be accepted as valid in number parsing. + * Default is none. + */ - (NSDecimalNumber*) minimum; + +/** + * Sets minimum value that will be accepted as valid in number parsing. + * Default is none. + */ - (void) setMinimum: (NSDecimalNumber*)aMinimum; @end diff --git a/Headers/Foundation/NSObjCRuntime.h b/Headers/Foundation/NSObjCRuntime.h index ea3eacd09..3353fef38 100644 --- a/Headers/Foundation/NSObjCRuntime.h +++ b/Headers/Foundation/NSObjCRuntime.h @@ -39,9 +39,11 @@ GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr, #ifndef NO_GNUSTEP /* Logging */ -/* OpenStep spec states that log messages go to stderr, but just in case - someone wants them to go somewhere else, they can implement a function - like this */ +/** + * OpenStep spec states that log messages go to stderr, but just in case + * someone wants them to go somewhere else, they can implement a function + * like this. + */ typedef void NSLog_printf_handler (NSString* message); GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler; GS_EXPORT int _NSLogDescriptor; diff --git a/Headers/Foundation/NSObject.h b/Headers/Foundation/NSObject.h index 2c5d3f4c1..df2000774 100644 --- a/Headers/Foundation/NSObject.h +++ b/Headers/Foundation/NSObject.h @@ -140,13 +140,33 @@ * to remote processes via the Distributed Objects mechanism. */ @protocol NSCoding + +/** + * Called when it is time for receiver to be serialized for writing to an + * archive or network connection. Receiver should record all of its instance + * variables using methods on aCoder. See documentation for [NSCoder], + * [NSArchiver], [NSKeyedArchiver], and/or [NSPortCoder] for more information. + */ - (void) encodeWithCoder: (NSCoder*)aCoder; + +/** + * Called on a freshly allocated receiver when it is time to reconstitute from + * serialized bytes in an archive or from a network connection. Receiver + * should load all of its instance variables using methods on aCoder. See + * documentation for [NSCoder], [NSUnarchiver], [NSKeyedUnarchiver], and/or + * [NSPortCoder] for more information. + */ - (id) initWithCoder: (NSCoder*)aDecoder; @end @interface NSObject { + /** + * Points to instance's class. Used by runtime to access method + * implementations, etc.. Set in +alloc, Unlike other instance variables, + * which are cleared there. + */ Class isa; } @@ -260,6 +280,11 @@ NSExtraRefCount(id anObject); GS_EXPORT void NSIncrementExtraRefCount(id anObject); +/** + * Contains values NSOrderedSame, NSOrderedAscending + * NSOrderedDescending, for left hand side equals, less than, or + * greater than right hand side. + */ typedef enum _NSComparisonResult { NSOrderedAscending = -1, NSOrderedSame, NSOrderedDescending @@ -291,11 +316,38 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock; - (id) write: (TypedStream*)aStream; @end +/** + * Provides a number of GNUstep-specific methods that are used to aid + * implementation of the Base library. + */ @interface NSObject (GSCategories) + +/** + * Message sent when an implementation wants to explicitly exclude a method + * (but cannot due to compiler constraint), and wants to make sure it is not + * called by mistake. Default implementation raises an exception at runtime. + */ - notImplemented:(SEL)aSel; + +/** + * Message sent when an implementation wants to explicitly require a subclass + * to implement a method (but cannot at compile time since there is no + * abstract keyword in Objective-C). Default implementation + * raises an exception at runtime to alert developer that he/she forgot to + * override a method. + */ - (id) subclassResponsibility: (SEL)aSel; + +/** + * Message sent when an implementation wants to explicitly exclude a method + * (but cannot due to compiler constraint) and forbid that subclasses + * implement it. Default implementation raises an exception at runtime. If a + * subclass does implement this method, however, the superclass's + * implementation will not be called, so this is not a perfect mechanism. + */ - (id) shouldNotImplement: (SEL)aSel; -/* + +/** WARNING: The -compare: method for NSObject is deprecated due to subclasses declaring the same selector with conflicting signatures. @@ -310,23 +362,53 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock; #endif -/* +/** * Protocol for garbage collection finalization - same as libFoundation * for compatibility. */ @protocol GCFinalization +/** + * Called before receiver is deallocated by garbage collector. If you want + * to do anything special before [NSObject -dealloc] is called, do it here. + */ - (void) gcFinalize; @end #include +/** + * Declares some methods for sending messages to self after a fixed delay. + * (These methods are in OpenStep and OS X.) + */ @interface NSObject (TimedPerformers) + +/** + * Cancels any perform operations set up for the specified target + * in the current run loop. + */ + (void) cancelPreviousPerformRequestsWithTarget: (id)obj; + +/** + * 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.
+ * Matching of the argument may be either by pointer equality or by + * use of the [NSObject-isEqual:] method. + */ + (void) cancelPreviousPerformRequestsWithTarget: (id)obj selector: (SEL)s object: (id)arg; +/** + * Sets given message to be sent to this instance after given delay, + * in any run loop mode. See [NSRunLoop]. + */ - (void) performSelector: (SEL)s withObject: (id)arg afterDelay: (NSTimeInterval)seconds; + +/** + * Sets given message to be sent to this instance after given delay, + * in given run loop modes. See [NSRunLoop]. + */ - (void) performSelector: (SEL)s withObject: (id)arg afterDelay: (NSTimeInterval)seconds diff --git a/Headers/Foundation/NSPort.h b/Headers/Foundation/NSPort.h index 72d9d8c5d..bd40dd65c 100644 --- a/Headers/Foundation/NSPort.h +++ b/Headers/Foundation/NSPort.h @@ -49,38 +49,104 @@ GS_EXPORT NSString * const NSPortTimeoutException; /* OPENSTEP */ +/** + *

NSPort is an abstract class defining interfaces underlying + * communications in the distributed objects framework. Each side of a + * connection will have an NSPort object, responsible for sending + * and receiving [NSPortMessage]s, which are then passed to delegates when + * received. The NSPort must be added to the [NSRunLoop] as an + * input source.

+ * + *

This class also implements the functionality of the + * NSMachPort class on OS X.

+ */ @interface NSPort : NSObject { BOOL _is_valid; id _delegate; } +/** + * Basic constructor returns object capable of send and receive. + */ + (NSPort*) port; + +/** + * NSMachPort compatibility method. + */ + (NSPort*) portWithMachPort: (int)machPort; +/** + * Returns the object that received messages will be passed off to. + */ - (id) delegate; -- (id) init; -- (id) initWithMachPort: (int)machPort; - -- (void) invalidate; -- (BOOL) isValid; -- (int) machPort; +/** + * Sets the object that received messages will be passed off to. + */ - (void) setDelegate: (id)anObject; +/** + * Basic initializer sets up object capable of send and receive. + */ +- (id) init; + +/** + * NSMachPort compatibility method. + */ +- (id) initWithMachPort: (int)machPort; + +/** + * NSMachPort compatibility. + */ +- (int) machPort; + +/** + * Mark port as invalid, deregister with listeners and cease further network + * operations. Subclasses should override and call super. + */ +- (void) invalidate; + +/** + * Returns whether port has been marked invalid. + */ +- (BOOL) isValid; + #ifndef STRICT_OPENSTEP +/** + * Adds to run loop as input source to be notified for input in given mode. + * This method is for use by subclasses. + */ - (void) addConnection: (NSConnection*)aConnection toRunLoop: (NSRunLoop*)aLoop forMode: (NSString*)aMode; + +/** + * Removes from run loop as input source to be notified for input in given mode. + * This method is for use by subclasses. + */ - (void) removeConnection: (NSConnection*)aConnection fromRunLoop: (NSRunLoop*)aLoop forMode: (NSString*)aMode; + +/** + * Returns amount of space used for header info at beginning of messages. + * Subclasses should override (this implementation returns 0). + */ - (unsigned) reservedSpaceLength; + +/** + * Internal method for sending message, for use by subclasses. + */ - (BOOL) sendBeforeDate: (NSDate*)when msgid: (int)msgid components: (NSMutableArray*)components from: (NSPort*)receivingPort reserved: (unsigned)length; + +/** + * Internal method for sending message, for use by subclasses. + */ - (BOOL) sendBeforeDate: (NSDate*)when components: (NSMutableArray*)components from: (NSPort*)receivingPort @@ -89,7 +155,11 @@ GS_EXPORT NSString * const NSPortTimeoutException; /* OPENSTEP */ @end #ifndef NO_GNUSTEP +/** + * Stubs for backward compatibility. Do not use. + */ @interface NSPort (GNUstep) +//PENDING: none of this is implemented.. should it be removed? - (void) close; + (Class) outPacketClass; - (Class) outPacketClass; @@ -105,6 +175,15 @@ GS_EXPORT NSString* NSPortDidBecomeInvalidNotification; typedef SOCKET NSSocketNativeHandle; @class GSTcpHandle; + +/** + *

An [NSPort] implementation for network object communications based on + * BSD sockets. Can be used for interthread/interprocess + * communications between same or different hosts (though on same host + * [NSMessagePort] will be more efficient).

+ * + *

Note that this class is incompatible with the latest OS X version.

+ */ @interface NSSocketPort : NSPort { NSRecursiveLock *myLock; @@ -115,23 +194,76 @@ typedef SOCKET NSSocketNativeHandle; NSMapTable *handles; /* Handles indexed by socket. */ } +/** + * Look up and return an existing NSSocketPort given a host and + * number, or return nil if one has not been created. + */ + (NSSocketPort*) existingPortWithNumber: (gsu16)number onHost: (NSHost*)aHost; + +/** + * This is the preferred initialisation method for NSSocketPort. + *
+ * number should be a TCP/IP port number or may be zero for a port on + * the local host.
+ * aHost should be the host for the port or may be nil for the local + * host.
+ * addr is the IP address that MUST be used for this port - if it is nil + * then, for the local host, the port uses ALL IP addresses, and for a + * remote host, the port will use the first address that works.
+ * shouldListen specifies whether to listen on the port initially. + */ + (NSSocketPort*) portWithNumber: (gsu16)number onHost: (NSHost*)aHost forceAddress: (NSString*)addr listener: (BOOL)shouldListen; +/** + * Setup method: add new send or receive connection handle. + */ - (void) addHandle: (GSTcpHandle*)handle forSend: (BOOL)send; + +/** + * Returns IP address of underlying socket. + */ - (NSString*) address; + +/** + * This is a callback method used by the NSRunLoop class to determine which + * descriptors to watch for the port. + */ - (void) getFds: (int*)fds count: (int*)count; + +/** + * + */ - (GSTcpHandle*) handleForPort: (NSSocketPort*)recvPort beforeDate: (NSDate*)when; + +/** + * Delegates processing of a message. + */ - (void) handlePortMessage: (NSPortMessage*)m; + +/** + * Returns host that the underlying socket is connected to. + */ - (NSHost*) host; + +/** + * Returns port number of underlying socket. + */ - (gsu16) portNumber; + +/** + * This is called when a TCP/IP socket connection is broken. We remove the + * connection handle from this port and, if this was the last handle to a + * remote port, we invalidate the port. + */ - (void) removeHandle: (GSTcpHandle*)handle; + +// This is the OS X interface /* { NSSocketNativeHandle _socket; @@ -169,6 +301,11 @@ typedef SOCKET NSSocketNativeHandle; @class GSMessageHandle; +/** + * An [NSPort] implementation for network object communications based on + * Unix domain sockets. Can be used for interthread/interprocess + * communications on the same host, but not between different hosts. + */ @interface NSMessagePort : NSPort { NSData *name; @@ -179,11 +316,31 @@ typedef SOCKET NSSocketNativeHandle; - (int) _listener; - (const unsigned char *) _name; + +/** + * + * This is the preferred initialisation method for NSMessagePort. + * + * socketName is the name of the socket in the port directory + */ + (NSMessagePort*) _portWithName: (const unsigned char *)socketName listener: (BOOL)shouldListen; +/** + * Setup method: add new send or receive connection handle. + */ - (void) addHandle: (GSMessageHandle*)handle forSend: (BOOL)send; + +/** + * This is called when a socket connection is broken. We remove the + * connection handle from this port and, if this was the last handle to a + * remote port, we invalidate the port. + */ - (void) removeHandle: (GSMessageHandle*)handle; + +/** + * Delegates processing of a message. + */ - (void) handlePortMessage: (NSPortMessage*)m; @end diff --git a/Headers/Foundation/NSPortCoder.h b/Headers/Foundation/NSPortCoder.h index 64ff9255c..5a4c8885c 100644 --- a/Headers/Foundation/NSPortCoder.h +++ b/Headers/Foundation/NSPortCoder.h @@ -31,6 +31,17 @@ @class NSConnection; @class NSPort; +/** + * This class is an [NSCoder] implementation specialized for sending objects + * over network connections for immediate use (as opposed to the archivers + * which persist objects for reconstitution after an indefinite term). It is + * used to help implement the distributed objects framework by the + * [NSConnection] class. Even for highly specialized applications, you + * probably do not need to use this class directly. + */ +//FIXME: the above is what Apple's docs say, but looking at the code the +// NSConnection is actually created by this class rather than the other way +// around, so maybe the docs should be changed.. @interface NSPortCoder : NSCoder { @private @@ -77,18 +88,57 @@ NSZone *_zone; /* Zone for allocating objs. */ } +/** + * Create a new instance for communications over send and recv, and send an + * initial message through send as specified by comp. + */ + (NSPortCoder*) portCoderWithReceivePort: (NSPort*)recv sendPort: (NSPort*)send components: (NSArray*)comp; + +/** + * Initialize a new instance for communications over send and recv, and send an + * initial message through send as specified by comp. + */ - (id) initWithReceivePort: (NSPort*)recv sendPort: (NSPort*)send components: (NSArray*)comp; +/** + * Returns the NSConnection using this instance. + */ - (NSConnection*) connection; + +/** + * Return port object previously encoded by this instance. Mainly for use + * by the ports themselves. + */ - (NSPort*) decodePortObject; + +/** + * Processes and acts upon the initial message the receiver was initialized + * with.. + */ - (void) dispatch; + +/** + * Encodes aPort so it can be sent to the receiving side of the connection. + * Mainly for use by the ports themselves. + */ - (void) encodePortObject: (NSPort*)aPort; + +/** + * Returns YES if receiver is in the process of encoding objects by copying + * them (rather than substituting a proxy). This method is mainly needed + * internally and by subclasses. + */ - (BOOL) isBycopy; + +/** + * Returns YES if receiver will substitute a proxy when encoding objects + * rather than by copying them. This method is mainly needed + * internally and by subclasses. + */ - (BOOL) isByref; @end diff --git a/Headers/Foundation/NSPortMessage.h b/Headers/Foundation/NSPortMessage.h index 66860a6ad..5ad334405 100644 --- a/Headers/Foundation/NSPortMessage.h +++ b/Headers/Foundation/NSPortMessage.h @@ -27,6 +27,15 @@ #include #include +/** + *

The data transported for distributed objects communications is sent over + * the network encapsulated by NSPortMessage objects, which consist of two + * [NSPort]s (sender and receiver, not sent over the network) and a body + * consisting of one or more [NSData] or [NSPort] objects. (Data in the + * [NSData] must be in network byte order.)

+ * + *

See the [NSConnection] and [NSPortCoder] classes.

+ */ @interface NSPortMessage : NSObject { unsigned _msgid; @@ -34,15 +43,59 @@ NSPort *_send; NSMutableArray *_components; } +/** + * OpenStep compatibility. + */ - (id) initWithMachMessage: (void*)buffer; + +/** Initializes to send message described by items (which should + * contain only [NSPort] and/or [NSData] objects, with contents in network + * byte order) over aPort. If/when a reply to the message is sent, it will + * arrive on anotherPort. + */ - (id) initWithSendPort: (NSPort*)aPort receivePort: (NSPort*)anotherPort components: (NSArray*)items; + +/** + * Request that the message be sent before when. Will block until either + * sends it (returns YES) or when expires (returns NO). The latter may occur + * if many messages are queued up (by multiple threads) faster than they can + * be sent over the network. + */ - (BOOL) sendBeforeDate: (NSDate*)when; + +/** + * Returns the message components originally used to constitute this message. + */ - (NSArray*) components; + +/** + * For an outgoing message, returns the port the receiver will send itself + * through. For an incoming message, returns the port replies to the receiver + * should be sent through. + */ - (NSPort*) sendPort; + +/** + * For an outgoing message, returns the port on which a reply to this message + * will arrive. For an incoming message, returns the port this message + * arrived on. + */ - (NSPort*) receivePort; + +/** + * Sets ID for message. This is not used by the distributed objects system, + * but may be used in custom ways by cooperating applications to sort or + * otherwise organize messages. + */ - (void) setMsgid: (unsigned)anId; + +/** + * Returns ID for message. This is not used by the distributed objects + * system, but may be used in custom ways by cooperating applications to sort + * or otherwise organize messages. Set to 0 initially. + */ - (unsigned) msgid; @end diff --git a/Headers/Foundation/NSPropertyList.h b/Headers/Foundation/NSPropertyList.h index af79356ad..dbac5d27c 100644 --- a/Headers/Foundation/NSPropertyList.h +++ b/Headers/Foundation/NSPropertyList.h @@ -76,12 +76,138 @@ typedef enum { /** *

The NSPropertyListSerialization class provides facilities for * serialising and deserializing property list data in a number of - * formats. - *

+ * formats. A property list is roughly an [NSArray] or [NSDictionary] object, + * with these or [NSNumber], [NSData], [NSString], or [NSDate] objects + * as members. (See below.)

*

You do not work with instances of this class, instead you use a - * small number of claass methods to serialized and deserialize + * small number of class methods to serialize and deserialize * property lists. - *

+ *


+ * A property list may only be one of the following classes - + * + * [NSArray] + * + * An array which is either empty or contains only property list + * objects.
+ * An array is delimited by round brackets and its contents are comma + * separated (there is no comma after the last array element). + * + * ( "one", "two", "three" ) + * + * In XML format, an array is an element whose name is array + * and whose content is the array content. + * + * <array><string>one</string><string>two</string><string>three</string></array> + * + *
+ * [NSData] + * + * An array is represented as a series of pairs of hexadecimal characters + * (each pair representing a byte of data) enclosed in angle brackets. + * Spaces are ignored). + * + * < 54637374 696D67 > + * + * In XML format, a data object is an element whose name is + * data and whose content is a stream of base64 encoded bytes. + * + * [NSDate] + * + * Date objects were not traditionally allowed in property lists + * but were added when the XML format was introduced. GNUstep provides + * an extension to the traditional property list format to + * support date objects, but older code will not read + * property lists containing this extension.
+ * This format consists of an asterisk follwed by the letter 'D' then a + * date/time in YYYY-MM-DD HH:MM:SS +/-ZZZZ format, all enclosed within + * angle brackets. + * + * <*D2002-03-22 11:30:00 +0100> + * + * In XML format, a date object is an element whose name is + * date and whose content is a date in the above format. + * + * <date>2002-03-22 11:30:00 +0100</date> + * + *
+ * [NSDictionary] + * + * A dictionary which is either empty or contains only string + * keys and property list objects.
+ * A dictionary is delimited by curly brackets and its contents are + * semicolon terminated (there is a semicolon after each value). + * Each item in the dictionary is a key/value pair with an equals sign + * after the key and before the value. + * + * { + * "key1" = "value1"; + * } + * + * In XML format, a dictionary is an element whose name is + * dictionary and whose content consists of pairs of + * strings and other property list objects. + * + * <dictionary> + * <string>key1</string> + * <string>value1</string> + * </dictionary> + * + *
+ * [NSNumber] + * + * Number objects were not traditionally allowed in property lists + * but were added when the XML format was intoroduced. GNUstep provides + * an extension to the traditional property list format to + * support number objects, but older code will not read + * property lists containing this extension.
+ * Numbers are stored in a variety of formats depending on their values. + * + * boolean ... either <*BY> for YES or + * <*BN> for NO.
+ * In XML format this is either <true /> or + * <false /> + *
+ * integer ... <*INNN> where NNN is an + * integer.
+ * In XML format this is <integer>NNN<integer> + *
+ * real ... <*RNNN> where NNN is a real + * number.
+ * In XML format this is <real>NNN<real> + *
+ *
+ *
+ * [NSString] + * + * A string is either stored literally (if it contains no spaces or special + * characters), or is stored as a quoted string with special characters + * escaped where necessary.
+ * Escape conventions are similar to those normally used in ObjectiveC + * programming, using a backslash followed by - + * + * \ a backslash character + * " a quote character + * b a backspace character + * n a newline character + * r a carriage return character + * t a tab character + * OOO (three octal digits) + * an arbitrary ascii character + * UXXXX (where X is a hexadecimal digit) + * a an arbitrary unicode character + * + * + * "hello world & others" + * + * In XML format, the string is simply stored in UTF8 format as the + * content of a string element, and the only character + * escapes required are those used by XML such as the + * '&lt;' markup representing a '<' character. + * + * <string>hello world &amp; others</string>" + * + *
+ *
*/ @interface NSPropertyListSerialization : NSObject { @@ -108,7 +234,7 @@ typedef enum { * Deserialises dataItem and returns the resulting property list * (or nil if the data does not contain a property list serialised * in a supported format).
- * The argument anOption is ised to control whether the objects making + * The argument anOption is used to control whether the objects making * up the deserialized property list are mutable or not.
* The argument aFormat is either null or a pointer to a location * in which the format of the serialized property list will be returned.
diff --git a/Headers/Foundation/NSRange.h b/Headers/Foundation/NSRange.h index 2b3a93dc7..a6b267f71 100644 --- a/Headers/Foundation/NSRange.h +++ b/Headers/Foundation/NSRange.h @@ -47,6 +47,11 @@ #endif /** + * +{ + unsigned int location; + unsigned int length; +} *

* The NSRange type is used to specify ranges of locations, * typically items in an array, characters in a string, and bytes diff --git a/Headers/Foundation/NSRunLoop.h b/Headers/Foundation/NSRunLoop.h index af2cb88ba..50745e44d 100644 --- a/Headers/Foundation/NSRunLoop.h +++ b/Headers/Foundation/NSRunLoop.h @@ -130,7 +130,7 @@ typedef enum { * These are general purpose methods for letting objects ask * the runloop to watch for events for them. Only one object * at a time may be watching for a particular event in a mode, but - * that object may add itsself as a watcher many times as long as + * that object may add itself as a watcher many times as long as * each addition is matched by a removal (the run loop keeps count). * Alternatively, the 'removeAll' parameter may be set to 'YES' for * [-removeEvent:type:forMode:all:] in order to remove the watcher @@ -165,9 +165,13 @@ typedef enum { all: (BOOL)removeAll; @end -/* xxx This interface will probably change. */ +/** + * Defines implementation-helper method -getFds:count:. + * This interface will probably change. Do not rely on it. + */ +// xxx This interface will probably change. @interface NSObject (OptionalPortRunLoop) -/* If a InPort object responds to this, it is sent just before we are +/** If a InPort object responds to this, it is sent just before we are about to wait listening for input. This interface will probably change. */ - (void) getFds: (int*)fds count: (int*)count; diff --git a/Headers/Foundation/NSSerialization.h b/Headers/Foundation/NSSerialization.h index 9415d38b1..fdad8a3ec 100644 --- a/Headers/Foundation/NSSerialization.h +++ b/Headers/Foundation/NSSerialization.h @@ -30,24 +30,61 @@ @class NSData, NSMutableData; +/** + * Objects that are not standard property list constituents can adopt this + * protocol to allow themselves to be serialized by an [NSSerializer] and + * deserialized by an [NSDeserializer]. Note, this mechanism has been + * deprecated and you should instead use [NSArchiver] and related facilities + * to serialize objects that are not ordinary property lists. + */ @protocol NSObjCTypeSerializationCallBack + +/** + * Decodes an object of given type from data at position cursor. + */ - (void) deserializeObjectAt: (id*)object ofObjCType: (const char *)type fromData: (NSData*)data atCursor: (unsigned*)cursor; + +/** + * Encode the given object of given type into data, using a string not a + * binary representation. + */ - (void) serializeObjectAt: (id*)object ofObjCType: (const char *)type intoData: (NSMutableData*)data; @end +/** + *

This class is deprecated in favor of + * [NSPropertyListSerialization].

+ * + *

It provides a means of producing a byte-array (actually string) + * representation of a property list (NSArray or NSDictionary plus limited + * contents).

+ */ @interface NSSerializer: NSObject + +/** + *

Serialize given property list (NSArray or NSDictionary plus limited + * contents) into byte array.

Deprecated in favor of + * [NSPropertyListSerialization+dataFromPropertyList:format:errorDescription:].

+ */ + (NSData*) serializePropertyList: (id)propertyList; + +/** + *

Serialize given property list (NSArray or NSDictionary plus limited + * contents) into given mutable byte array.

Deprecated in favor of + * [NSPropertyListSerialization+dataFromPropertyList:format:errorDescription:].

+ + */ + (void) serializePropertyList: (id)propertyList intoData: (NSMutableData*)d; @end #ifndef NO_GNUSTEP -/* +/** * GNUstep extends serialization by having the option to make the * resulting data more compact by ensuring that repeated strings * are only stored once. If the property-list has a lot of repeated @@ -60,19 +97,56 @@ * override the default behavior. */ @interface NSSerializer (GNUstep) + +/** + * Specify whether to produce compacted format, with repeated strings only + * written once. + */ + (void) shouldBeCompact: (BOOL)flag; + +/** + * As [NSSerializer+serializePropertyList:intoData:] but specify whether to + * produce compacted format. + */ + (void) serializePropertyList: (id)propertyList intoData: (NSMutableData*)d compact: (BOOL)flag; @end #endif +/** + * This class is deprecated in favor of + * [NSPropertyListSerialization]. It provides a means of recovering a + * property list (NSArray or NSDictionary plus limited contents) from a + * byte-array (actually string) representation. + */ @interface NSDeserializer: NSObject + +/** + * Recover a property list (NSArray or NSDictionary plus limited + * contents) from a byte array. Deprecated in favor of + * [NSPropertyListSerialization+propertyListFromData:mutabilityOption:format:errorDescription:]. + */ + (id) deserializePropertyListFromData: (NSData*)data atCursor: (unsigned int*)cursor mutableContainers: (BOOL)flag; + +/** + * Recover a property list (NSArray or NSDictionary plus limited + * contents) from a byte array. Deprecated in favor of + * [NSPropertyListSerialization+propertyListFromData:mutabilityOption:format:errorDescription:]. + */ + (id) deserializePropertyListFromData: (NSData*)data mutableContainers: (BOOL)flag; + +/** + * Recover a property list (NSArray or NSDictionary plus limited contents) + * from a byte array. If the data at cursor has a length greater than + * length, a proxy is substituted for the actual property list as long as the + * constituent objects of that property list are not accessed. + * Deprecated in favor of + * [NSPropertyListSerialization+propertyListFromData:mutabilityOption:format:errorDescription:]. + */ + (id) deserializePropertyListLazilyFromData: (NSData*)data atCursor: (unsigned*)cursor length: (unsigned)length @@ -81,21 +155,24 @@ @end #ifndef NO_GNUSTEP -/* - * GNUstep extends deserialization by having the option to make the +/** + *

GNUstep extends deserialization by having the option to make the * resulting data more compact by ensuring that repeated strings * are only stored once. If the property-list has a lot of repeated * strings in it, this will be more space efficient but it will be * slower (though other parts of your code may speed up through more * efficient equality testing of uniqued strings). - * The default is NOT to deserialize uniqued strings. + * The default is NOT to deserialize uniqued strings.

* - * The [+uniquing:] method turns uniquing on/off. - * Uniquing is done using a global NSCountedSet - see NSCountedSet for - * details. + *

The [+uniquing:] method turns uniquing on/off. + * Uniquing is done using a global [NSCountedSet] - see its documentation + * for details.

*/ -@class NSMutableSet; @interface NSDeserializer (GNUstep) +/** + * Turns uniquing (collapsing of multiple instances of a single string in the + * output to one full copy plus references) on/off. + */ + (void) uniquing: (BOOL)flag; @end diff --git a/Headers/Foundation/NSSet.h b/Headers/Foundation/NSSet.h index 51041c202..82862dc9e 100644 --- a/Headers/Foundation/NSSet.h +++ b/Headers/Foundation/NSSet.h @@ -98,39 +98,77 @@ #ifndef NO_GNUSTEP -/* +/** * Utility methods for using a counted set to handle uniquing of objects. */ @interface NSCountedSet (GNU_Uniquing) +/** + *

+ * 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 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]; + * + *

+ */ - (id) unique: (id)anObject; @end /* * Functions for managing a global uniquing set. - * + */ + +/* * GSUniquing() turns on/off the action of the GSUnique() function. * if uniquing is turned off, GSUnique() simply returns its argument. * + */ +void GSUniquing(BOOL flag); + +/* * GSUnique() returns an object that is equal to the one passed to it. * If the returned object is not the same object as the object passed in, * the original object is released and the returned object is retained. * Thus, an -init method that wants to implement uniquing simply needs * to end with 'return GSUnique(self);' */ -void GSUniquing(BOOL flag); id GSUnique(id anObject); /* * Management functions - - * + */ + +/* * GSUPurge() can be used to purge infrequently referenced objects from the * set by removing any objec whose count is less than or equal to that given. * + */ +void GSUPurge(unsigned count); + +/* * GSUSet() can be used to artificially set the count for a particular object * Setting the count to zero will remove the object from the global set. */ -void GSUPurge(unsigned count); id GSUSet(id anObject, unsigned count); #endif /* NO_GNUSTEP */ diff --git a/Headers/Foundation/NSString.h b/Headers/Foundation/NSString.h index 61eee6451..05933f653 100644 --- a/Headers/Foundation/NSString.h +++ b/Headers/Foundation/NSString.h @@ -349,10 +349,10 @@ enum { * added for GNUstep, to permit the isa variable to be set to another * class, and GNUstep uses this to avoid conflicts with the default * implementation of NXConstantString in the ObjC runtime library (the - * preprocessor is used to change all occurances of NXConstantString + * preprocessor is used to change all occurences of NXConstantString * in the source code to NSConstantString).

*

Since GNUstep will generally use the GNUstep extension to the - * compiler, you should never refer to the constnat string class by + * compiler, you should never refer to the constant string class by * name, but should use the [NSString+constantStringClass] method to * get the actual class being used for constant strings.

* What follows is a dummy declaration of the class to keep the compiler @@ -377,25 +377,101 @@ extern struct objc_class _NSConstantStringClassReference; - (NSString*) immutableProxy; @end +/** + * Provides some additional (non-standard) utility methods. + */ @interface NSString (GSCategories) +/** + * Alternate way to invoke stringWithFormat if you have or wish + * to build an explicit va_list structure. + */ + (id) stringWithFormat: (NSString*)format arguments: (va_list)argList; + +/** + * Returns a string formed by removing the prefix string from the + * receiver. Raises an exception if the prefix is not present. + */ - (NSString*) stringByDeletingPrefix: (NSString*)prefix; + +/** + * Returns a string formed by removing the suffix string from the + * receiver. Raises an exception if the suffix is not present. + */ - (NSString*) stringByDeletingSuffix: (NSString*)suffix; + +/** + * Returns a string formed by removing leading white space from the + * receiver. + */ - (NSString*) stringByTrimmingLeadSpaces; + +/** + * Returns a string formed by removing trailing white space from the + * receiver. + */ - (NSString*) stringByTrimmingTailSpaces; + +/** + * Returns a string formed by removing both leading and trailing + * white space from the receiver. + */ - (NSString*) stringByTrimmingSpaces; + +/** + * Returns a string in which any (and all) occurrences of + * replace in the receiver have been replaced with by. + * Returns the receiver if replace + * does not occur within the receiver. NB. an empty string is + * not considered to exist within the receiver. + */ - (NSString*) stringByReplacingString: (NSString*)replace withString: (NSString*)by; @end + +/** + * GNUstep specific (non-standard) additions to the NSMutableString class. + */ @interface NSMutableString (GSCategories) + +/** + * Removes the specified suffix from the string. Raises an exception + * if the suffix is not present. + */ - (void) deleteSuffix: (NSString*)suffix; + +/** + * Removes the specified prefix from the string. Raises an exception + * if the prefix is not present. + */ - (void) deletePrefix: (NSString*)prefix; + +/** + * Replaces all occurrances of the string replace with the string by + * in the receiver.
+ * Has no effect if replace does not occur within the + * receiver. NB. an empty string is not considered to exist within + * the receiver.
+ * Calls - replaceOccurrencesOfString:withString:options:range: passing + * zero for the options and a range from 0 with the length of the receiver. + */ - (void) replaceString: (NSString*)replace withString: (NSString*)by; + +/** + * Removes all leading white space from the receiver. + */ - (void) trimLeadSpaces; + +/** + * Removes all trailing white space from the receiver. + */ - (void) trimTailSpaces; + +/** + * Removes all leading or trailing white space from the receiver. + */ - (void) trimSpaces; @end diff --git a/Headers/Foundation/NSURL.h b/Headers/Foundation/NSURL.h index df0dbfc14..964dd5af5 100644 --- a/Headers/Foundation/NSURL.h +++ b/Headers/Foundation/NSURL.h @@ -82,12 +82,27 @@ GS_EXPORT NSString* NSURLFileScheme; @end @interface NSObject (NSURLClient) + +/** + * Some data has become available. Note that this does not mean that all data + * has become available, only that a chunk of data has arrived. + */ - (void) URL: (NSURL*)sender resourceDataDidBecomeAvailable: (NSData*)newBytes; +/** + * Loading of resource data is complete. + */ - (void) URLResourceDidFinishLoading: (NSURL*)sender; + +/** + * Loading of resource data was canceled by programmatic request (not an error). + */ - (void) URLResourceDidCancelLoading: (NSURL*)sender; +/** + * Loading of resource data has failed, for given human-readable reason. + */ - (void) URL: (NSURL*)sender resourceDidFailLoadingWithReason: (NSString*)reason; @end diff --git a/Headers/Foundation/NSURLHandle.h b/Headers/Foundation/NSURLHandle.h index eb488f7b1..b7ec9319d 100644 --- a/Headers/Foundation/NSURLHandle.h +++ b/Headers/Foundation/NSURLHandle.h @@ -58,7 +58,7 @@ typedef enum /** * A protocol to which clients of a handle must conform in order to - * rfeceive notification of events on the handle. + * receive notification of events on the handle. */ @protocol NSURLHandleClient /** diff --git a/Headers/Foundation/NSValue.h b/Headers/Foundation/NSValue.h index c5bcb9741..ca6c3b1a3 100644 --- a/Headers/Foundation/NSValue.h +++ b/Headers/Foundation/NSValue.h @@ -29,105 +29,315 @@ @class NSString; +/** + * The NSValue class can wrap a single primitive value as an + * object so it can be used in the containers and other places where an object + * reference is needed. Once initialized, an NSValue is + * immutable, and there is no NSMutableValue class. You + * initialize it by giving it a pointer to the primitive value, and you should + * be careful this does not get freed until after the NSValue is + * no longer used. + */ @interface NSValue : NSObject // Allocating and Initializing +/** + * Create new instance with specified value (a pointer) of given type, which + * is a string code obtainable through the compile-time operator + * @encode(...). For example: + + NSValue *theValue = [NSValue value: &n withObjCType: @encode(int)]; + + */ + (NSValue*) value: (const void*)value withObjCType: (const char*)type; + +/** + * Create new instance holding anObject. This is useful if you want to add + * anObject to a collection such as [NSArray] but don't want it to be retained + * (a weak reference). + */ + (NSValue*) valueWithNonretainedObject: (id)anObject; + +/** + * Convenience method to create instance holding an NSPoint + * structure. + */ + (NSValue*) valueWithPoint: (NSPoint)point; + +/** + * Convenience method to create instance holding a pointer. Same as + * using @encode(void *) in +value:withObjCType: . + */ + (NSValue*) valueWithPointer: (const void*)pointer; + +/** + * Convenience method to create instance holding an NSRange + * structure. + */ + (NSValue*) valueWithRange: (NSRange)range; + +/** + * Convenience method to create instance holding an NSRect + * structure. + */ + (NSValue*) valueWithRect: (NSRect)rect; + +/** + * Convenience method to create instance holding an NSSize + * structure. + */ + (NSValue*) valueWithSize: (NSSize)size; #ifndef STRICT_OPENSTEP +/** + * Synonym for value:withObjCType: . + */ + (NSValue*) valueWithBytes: (const void*)value objCType: (const char*)type; -/* Designated initializer for all concrete subclasses */ + +/** + * Initialize with value of type, parallel to value:withObjCType: . + */ - (id) initWithBytes: (const void*)data objCType: (const char*)type; + +/** + * Compares this instance to another NSValue. For equality, + * both contents and declared type of the two values must match. + */ - (BOOL) isEqualToValue: (NSValue*)other; #endif // Accessing Data +/** + * Copies bytes from the pointer receiver was initialized with into buffer + * pointed to by value. Number of bytes copied is determined by the type. If + * type was a void * pointer or object id, the memory address itself is + * copied. + */ - (void) getValue: (void*)value; + +/** + * Returns the string @encode(...) compatible type the receiver + * was initialized with. + */ - (const char*) objCType; + +/** + * If receiver was initialized with an object ID, return it, else raises + * NSInternalInconsistencyException. + */ - (id) nonretainedObjectValue; + +/** + * If receiver was initialized with a void * pointer, return it, else raises + * NSInternalInconsistencyException. + */ - (void*) pointerValue; + +/** + * If receiver was initialized with an NSRange value, return it, + * else raises NSInternalInconsistencyException. + */ - (NSRange) rangeValue; + +/** + * If receiver was initialized with an NSRect value, return it, + * else raises NSInternalInconsistencyException. + */ - (NSRect) rectValue; + +/** + * If receiver was initialized with an NSSize value, return it, + * else raises NSInternalInconsistencyException. + */ - (NSSize) sizeValue; + +/** + * If receiver was initialized with an NSPoint value, return it, + * else raises NSInternalInconsistencyException. + */ - (NSPoint) pointValue; @end +/** + * Subclass of [NSValue] offering convenience methods for initializing from + * and accessing as any C primitive numeric type. On access, the value will + * be type-converted if necessary, using standard C conversion rules. + */ @interface NSNumber : NSValue // Allocating and Initializing +/** New instance from boolean value. */ + (NSNumber*) numberWithBool: (BOOL)value; +/** New instance from signed char value. */ + (NSNumber*) numberWithChar: (signed char)value; +/** New instance from double value. */ + (NSNumber*) numberWithDouble: (double)value; +/** New instance from float value. */ + (NSNumber*) numberWithFloat: (float)value; +/** New instance from (signed) int value. */ + (NSNumber*) numberWithInt: (signed int)value; +/** New instance from (signed) long value. */ + (NSNumber*) numberWithLong: (signed long)value; +/** New instance from (signed) long long value. */ + (NSNumber*) numberWithLongLong: (signed long long)value; +/** New instance from (signed) short value. */ + (NSNumber*) numberWithShort: (signed short)value; +/** New instance from unsigned char value. */ + (NSNumber*) numberWithUnsignedChar: (unsigned char)value; +/** New instance from unsigned int value. */ + (NSNumber*) numberWithUnsignedInt: (unsigned int)value; +/** New instance from unsigned long value. */ + (NSNumber*) numberWithUnsignedLong: (unsigned long)value; +/** New instance from unsigned long long value. */ + (NSNumber*) numberWithUnsignedLongLong: (unsigned long long)value; +/** New instance from unsigned short value. */ + (NSNumber*) numberWithUnsignedShort: (unsigned short)value; +/** Initialize from boolean value. */ - (id) initWithBool: (BOOL)value; +/** Initialize from signed char value. */ - (id) initWithChar: (signed char)value; +/** Initialize from double value. */ - (id) initWithDouble: (double)value; +/** Initialize from float value. */ - (id) initWithFloat: (float)value; +/** Initialize from (signed) int value. */ - (id) initWithInt: (signed int)value; +/** Initialize from (signed) long value. */ - (id) initWithLong: (signed long)value; +/** Initialize from (signed) long long value. */ - (id) initWithLongLong: (signed long long)value; +/** Initialize from (signed) short value. */ - (id) initWithShort: (signed short)value; +/** Initialize from unsigned char value. */ - (id) initWithUnsignedChar: (unsigned char)value; +/** Initialize from unsigned int value. */ - (id) initWithUnsignedInt: (unsigned int)value; +/** Initialize from unsigned long value. */ - (id) initWithUnsignedLong: (unsigned long)value; +/** Initialize from unsigned long long value. */ - (id) initWithUnsignedLongLong: (unsigned long long)value; +/** Initialize from unsigned short value. */ - (id) initWithUnsignedShort: (unsigned short)value; // Accessing Data +/** + * Return value as a BOOL; this will in fact be a char value converted + * if necessary from type initialized with; if you wish to consider anything + * nonzero TRUE do not compare directly to YES, but use '!= NO'. + */ - (BOOL) boolValue; +/** Returns value as a signed char, converting if necessary. */ - (signed char) charValue; +/** Returns value as a double, converting if necessary. */ - (double) doubleValue; +/** Returns value as a float, converting if necessary. */ - (float) floatValue; +/** Returns value as a (signed) int, converting if necessary. */ - (signed int) intValue; -- (signed long long) longLongValue; +/** Returns value as a (signed) long, converting if necessary. */ - (signed long) longValue; +/** Returns value as a (signed) long long, converting if necessary. */ +- (signed long long) longLongValue; +/** Returns value as a (signed) short, converting if necessary. */ - (signed short) shortValue; -- (NSString*) stringValue; +/** Returns value as an unsigned char, converting if necessary. */ - (unsigned char) unsignedCharValue; +/** Returns value as an unsigned int, converting if necessary. */ - (unsigned int) unsignedIntValue; -- (unsigned long long) unsignedLongLongValue; +/** Returns value as an unsigned long, converting if necessary. */ - (unsigned long) unsignedLongValue; +/** Returns value as an unsigned long long, converting if necessary. */ +- (unsigned long long) unsignedLongLongValue; +/** Returns value as an unsigned short, converting if necessary. */ - (unsigned short) unsignedShortValue; +/** Returns -description . */ +- (NSString*) stringValue; + +/** + * Returns the string representation of this number using a non-localised + * conversion (decimal point is '.' irrespective of the locale). + */ - (NSString*) description; + +/** + *

+ * 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 - + *

+ * + * char + * %i + * short + * %hi + * int + * %i + * long + * %li + * long long + * %lli + * unsigned char + * %u + * unsigned short + * %hu + * unsigned int + * %u + * unsigned long + * %lu + * unsigned long long + * %llu + * float + * %0.7g + * double + * %0.16g + * + */ - (NSString*) descriptionWithLocale: (NSDictionary*)locale; +/** + * Compares receiver with otherNumber, using C type conversion if necessary, + * and returns NSOrderedAscending, + * NSOrderedDescending, or NSOrderedSame depending + * on whether it is less than, greater than, or equal to otherNumber. + */ - (NSComparisonResult) compare: (NSNumber*)otherNumber; + +/** + * Returns whether receiver and otherNumber represent the same numerical value. + */ - (BOOL) isEqualToNumber: (NSNumber*)otherNumber; @end #ifndef NO_GNUSTEP +/** + * GNUstep specific (non-standard) additions to the NSNumber class. + */ @interface NSNumber(GSCategories) + +/** + * Parses string as a double, int, or unsigned + * int depending on what characters are present. Uses + * atof and atoi which don't report errors, so be + * careful if the string might contain an invalid value. + */ + (NSValue*) valueFromString: (NSString *)string; @end -/* Note: This method is not in the OpenStep spec, but they makes - subclassing easier. */ +/** Note: Defines a method that is not in the OpenStep spec, but makes + subclassing easier. */ @interface NSValue (Subclassing) -/* Used by value: withObjCType: to determine the concrete subclass to alloc */ +/** Used by value: withObjCType: to determine the concrete subclass to alloc. */ + (Class) valueClassWithObjCType: (const char*)type; @end