mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Move methods to Additions for use with gdl2 on MacOSX
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15723 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
a6531e014c
commit
485132bf15
16 changed files with 173 additions and 125 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2003-01-26 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Compiling gdl2 on MacOSX.
|
||||
* Headers/gnustep/base/NSObject.h (-notImplemented:,
|
||||
-subclassResponsibility:, -shouldNotImplement:, -compare:): Move
|
||||
to GSCategories category.
|
||||
* Headers/gnustep/base/NSString.h (-stringByDeletingPrefix:,
|
||||
-stringByDeletingSuffix:, -deleteSuffix:, -deletePrefix:): Idem.
|
||||
* Source/NSObject: Move methods to Additions/GSCategories.m
|
||||
* Source/NSString: Idem.
|
||||
|
||||
* Source/Additions/GSCompatibility.h (GetEncodingName): Add.
|
||||
* Source/Additions/GSCompatibility.m (GetEncodingName): Cocoa
|
||||
implementation.
|
||||
|
||||
2003-01-24 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/Additions/GSCategories.m: Changed name of md5 digest method
|
||||
|
|
|
@ -272,7 +272,6 @@ enum {NSNotFound = 0x7fffffff};
|
|||
|
||||
@interface NSObject (NEXTSTEP)
|
||||
- error:(const char *)aString, ...;
|
||||
- notImplemented:(SEL)aSel;
|
||||
/* - (const char *) name;
|
||||
Removed because OpenStep has -(NSString*)name; */
|
||||
@end
|
||||
|
@ -283,11 +282,8 @@ enum {NSNotFound = 0x7fffffff};
|
|||
GS_EXPORT NSRecursiveLock *gnustep_global_lock;
|
||||
|
||||
@interface NSObject (GNU)
|
||||
- (NSComparisonResult) compare: (id)anObject;
|
||||
- (id) makeImmutableCopyOnFail: (BOOL)force;
|
||||
- (Class) transmuteClassTo: (Class)aClassObject;
|
||||
- (id) subclassResponsibility: (SEL)aSel;
|
||||
- (id) shouldNotImplement: (SEL)aSel;
|
||||
+ (Class) autoreleaseClass;
|
||||
+ (void) setAutoreleaseClass: (Class)aClass;
|
||||
+ (void) enableDoubleReleaseCheck: (BOOL)enable;
|
||||
|
@ -295,6 +291,14 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock;
|
|||
- (id) write: (TypedStream*)aStream;
|
||||
@end
|
||||
|
||||
@interface NSObject (GSCategories)
|
||||
- notImplemented:(SEL)aSel;
|
||||
- (id) subclassResponsibility: (SEL)aSel;
|
||||
- (id) shouldNotImplement: (SEL)aSel;
|
||||
|
||||
- (NSComparisonResult) compare: (id)anObject;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
|
@ -362,9 +362,12 @@ extern struct objc_class _NSConstantStringClassReference;
|
|||
|
||||
#ifndef NO_GNUSTEP
|
||||
|
||||
@interface NSString (GNUstep)
|
||||
@interface NSString (GSCategories)
|
||||
- (NSString*) stringByDeletingPrefix: (NSString*)prefix;
|
||||
- (NSString*) stringByDeletingSuffix: (NSString*)suffix;
|
||||
@end
|
||||
|
||||
@interface NSString (GNUstep)
|
||||
- (NSString*) stringByReplacingString: (NSString*)replace
|
||||
withString: (NSString*)by;
|
||||
- (NSString*) stringByTrimmingLeadSpaces;
|
||||
|
@ -372,9 +375,12 @@ extern struct objc_class _NSConstantStringClassReference;
|
|||
- (NSString*) stringByTrimmingSpaces;
|
||||
@end
|
||||
|
||||
@interface NSMutableString (GNUstep)
|
||||
@interface NSMutableString (GSCategories)
|
||||
- (void) deleteSuffix: (NSString*)suffix;
|
||||
- (void) deletePrefix: (NSString*)prefix;
|
||||
@end
|
||||
|
||||
@interface NSMutableString (GNUstep)
|
||||
- (NSString*) immutableProxy;
|
||||
- (void) replaceString: (NSString*)replace
|
||||
withString: (NSString*)by;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSRange.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
/**
|
||||
|
@ -421,4 +421,130 @@ static void MD5Transform (unsigned long buf[4], unsigned long const in[16])
|
|||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Extension methods for the NSObject class
|
||||
*/
|
||||
@implementation NSObject (GSCategories)
|
||||
|
||||
- (id) notImplemented: (SEL)aSel
|
||||
{
|
||||
[NSException
|
||||
raise: NSGenericException
|
||||
format: @"method %s not implemented in %s(%s)",
|
||||
aSel ? sel_get_name(aSel) : "(null)",
|
||||
object_get_class_name(self),
|
||||
GSObjCIsInstance(self) ? "instance" : "class"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) shouldNotImplement: (SEL)aSel
|
||||
{
|
||||
[NSException
|
||||
raise: NSGenericException
|
||||
format: @"%s(%s) should not implement %s",
|
||||
object_get_class_name(self),
|
||||
GSObjCIsInstance(self) ? "instance" : "class",
|
||||
aSel ? sel_get_name(aSel) : "(null)"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) subclassResponsibility: (SEL)aSel
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"subclass %s(%s) should override %s",
|
||||
object_get_class_name(self),
|
||||
GSObjCIsInstance(self) ? "instance" : "class",
|
||||
aSel ? sel_get_name(aSel) : "(null)"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the receiver with anObject to see which is greater.
|
||||
* The default implementation orders by memory location.
|
||||
*/
|
||||
- (int) compare: (id)anObject
|
||||
{
|
||||
if (anObject == self)
|
||||
{
|
||||
return NSOrderedSame;
|
||||
}
|
||||
if (anObject == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"nil argument for compare:"];
|
||||
}
|
||||
if ([self isEqual: anObject])
|
||||
{
|
||||
return NSOrderedSame;
|
||||
}
|
||||
/*
|
||||
* Ordering objects by their address is pretty useless,
|
||||
* so subclasses should override this is some useful way.
|
||||
*/
|
||||
if (self > anObject)
|
||||
{
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* Extension methods for the NSObject class
|
||||
*/
|
||||
@implementation NSString (GSCategories)
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
NSCAssert2([self hasPrefix: prefix],
|
||||
@"'%@' does not have the prefix '%@'", self, prefix);
|
||||
return [self substringFromIndex: [prefix length]];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
NSCAssert2([self hasSuffix: suffix],
|
||||
@"'%@' does not have the suffix '%@'", self, suffix);
|
||||
return [self substringToIndex: ([self length] - [suffix length])];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSMutableString (GSCategories)
|
||||
|
||||
/**
|
||||
* Removes the specified suffix from the string. Raises an exception
|
||||
* if the suffix is not present.
|
||||
*/
|
||||
- (void) deleteSuffix: (NSString*)suffix
|
||||
{
|
||||
NSCAssert2([self hasSuffix: suffix],
|
||||
@"'%@' does not have the suffix '%@'", self, suffix);
|
||||
[self deleteCharactersInRange:
|
||||
NSMakeRange([self length] - [suffix length], [suffix length])];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified prefix from the string. Raises an exception
|
||||
* if the prefix is not present.
|
||||
*/
|
||||
- (void) deletePrefix: (NSString*)prefix
|
||||
{
|
||||
NSCAssert2([self hasPrefix: prefix],
|
||||
@"'%@' does not have the prefix '%@'", self, prefix);
|
||||
[self deleteCharactersInRange: NSMakeRange(0, [prefix length])];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -65,6 +65,8 @@ typedef enum _NSGNUstepStringEncoding
|
|||
NSBIG5StringEncoding // Traditional chinese
|
||||
} NSGNUstepStringEncoding;
|
||||
|
||||
NSString *GetEncodingName(NSStringEncoding availableEncodingValue);
|
||||
|
||||
#define GS_RANGE_CHECK(RANGE, SIZE) \
|
||||
if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
|
||||
[NSException raise: NSRangeException \
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
/* FIXME: Need to initialize this */
|
||||
NSRecursiveLock *gnustep_global_lock = NULL;
|
||||
|
||||
NSString *GetEncodingName(NSStringEncoding availableEncodingValue)
|
||||
{
|
||||
return (NSString *)CFStringGetNameOfEncoding(CFStringConvertNSStringEncodingToEncoding(availableEncodingValue));
|
||||
}
|
||||
|
||||
@implementation NSArray (GSCompatibility)
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <gnustep/base/GSMime.h>
|
||||
#include <gnustep/base/GSCategories.h>
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <base/preface.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
</chapter>
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include "GSCompatibility.h"
|
||||
|
||||
#ifdef HAVE_LIBXML
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <base/preface.h>
|
||||
#include <base/behavior.h>
|
||||
|
|
|
@ -1877,17 +1877,6 @@ static BOOL double_release_check_enabled = NO;
|
|||
return self;
|
||||
}
|
||||
|
||||
- (id) notImplemented: (SEL)aSel
|
||||
{
|
||||
[NSException
|
||||
raise: NSGenericException
|
||||
format: @"method %s not implemented in %s(%s)",
|
||||
aSel ? sel_get_name(aSel) : "(null)",
|
||||
object_get_class_name(self),
|
||||
GSObjCIsInstance(self) ? "instance" : "class"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) doesNotRecognize: (SEL)aSel
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
|
@ -1957,39 +1946,6 @@ static BOOL double_release_check_enabled = NO;
|
|||
double_release_check_enabled = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the receiver with anObject to see which is greater.
|
||||
* The default implementation orders by memory location.
|
||||
*/
|
||||
- (int) compare: (id)anObject
|
||||
{
|
||||
if (anObject == self)
|
||||
{
|
||||
return NSOrderedSame;
|
||||
}
|
||||
if (anObject == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"nil argument for compare:"];
|
||||
}
|
||||
if ([self isEqual: anObject])
|
||||
{
|
||||
return NSOrderedSame;
|
||||
}
|
||||
/*
|
||||
* Ordering objects by their address is pretty useless,
|
||||
* so subclasses should override this is some useful way.
|
||||
*/
|
||||
if (self > anObject)
|
||||
{
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The default (NSObject) implementation of this method simply calls
|
||||
* the -description method and discards the locale
|
||||
|
@ -2111,27 +2067,6 @@ static BOOL double_release_check_enabled = NO;
|
|||
return 0;
|
||||
}
|
||||
|
||||
- (id) subclassResponsibility: (SEL)aSel
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"subclass %s(%s) should override %s",
|
||||
object_get_class_name(self),
|
||||
GSObjCIsInstance(self) ? "instance" : "class",
|
||||
aSel ? sel_get_name(aSel) : "(null)"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) shouldNotImplement: (SEL)aSel
|
||||
{
|
||||
[NSException
|
||||
raise: NSGenericException
|
||||
format: @"%s(%s) should not implement %s",
|
||||
object_get_class_name(self),
|
||||
GSObjCIsInstance(self) ? "instance" : "class",
|
||||
aSel ? sel_get_name(aSel) : "(null)"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (int) streamVersion: (TypedStream*)aStream
|
||||
{
|
||||
#ifndef NeXT_RUNTIME
|
||||
|
|
|
@ -4262,29 +4262,6 @@ handle_printf_atsign (FILE *stream,
|
|||
* The methods in this category are not available in MacOS-X
|
||||
*/
|
||||
@implementation NSString (GNUstep)
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
NSCAssert2([self hasPrefix: prefix],
|
||||
@"'%@' does not have the prefix '%@'", self, prefix);
|
||||
return [self substringFromIndex: [prefix length]];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
NSCAssert2([self hasSuffix: suffix],
|
||||
@"'%@' does not have the suffix '%@'", self, suffix);
|
||||
return [self substringToIndex: ([self length] - [suffix length])];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string formed by removing leading white space from the
|
||||
* receiver.
|
||||
|
@ -4419,28 +4396,6 @@ handle_printf_atsign (FILE *stream,
|
|||
@implementation NSMutableString (GNUstep)
|
||||
@class NSImmutableString;
|
||||
@class GSImmutableString;
|
||||
/**
|
||||
* Removes the specified suffix from the string. Raises an exception
|
||||
* if the suffix is not present.
|
||||
*/
|
||||
- (void) deleteSuffix: (NSString*)suffix
|
||||
{
|
||||
NSCAssert2([self hasSuffix: suffix],
|
||||
@"'%@' does not have the suffix '%@'", self, suffix);
|
||||
[self deleteCharactersInRange:
|
||||
NSMakeRange([self length] - [suffix length], [suffix length])];
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified prefix from the string. Raises an exception
|
||||
* if the prefix is not present.
|
||||
*/
|
||||
- (void) deletePrefix: (NSString*)prefix
|
||||
{
|
||||
NSCAssert2([self hasPrefix: prefix],
|
||||
@"'%@' does not have the prefix '%@'", self, prefix);
|
||||
[self deleteCharactersInRange: NSMakeRange(0, [prefix length])];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a proxy to the receiver which will allow access to the
|
||||
|
|
Loading…
Reference in a new issue