mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Fix up additions compatibility with MacOSX and add additional methods
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@15821 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
5069165647
commit
17d906ff14
9 changed files with 302 additions and 24 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2003-01-31 Stephane Corthesy <stephane@sente.ch>
|
||||
Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Headers/gnustep/base/GSCategories.h: Moved
|
||||
NSString(GSCategories), NSMutableString(GSCategories), and copied
|
||||
NSObject(GSCategories) to here
|
||||
* Headers/gnustep/base/NSString.h, Headers/gnustep/base/NSObject:
|
||||
From here.
|
||||
* Headers/gnustep/base/GSMime.h: Include Foundation on MacOSX.
|
||||
|
||||
* Source/Additions/GSCategories.m: Fix includes.
|
||||
* Source/Additions/GSCompatibility.h: Defined DebugLog, WarnLog
|
||||
macros. Add Additional NSObject, NSInvocation, NSString and
|
||||
NSProcessInfo methods. Add NSStandardLibraryPaths.
|
||||
* Source/Additions/GSCompatibility.m: Idem.
|
||||
|
||||
2003-01-30 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/libgnustep-base.def.in: Regenerated
|
||||
|
|
|
@ -28,14 +28,16 @@
|
|||
|
||||
#ifndef NO_GNUSTEP
|
||||
|
||||
#ifdef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
@interface NSCalendarDate (GSCategories)
|
||||
|
||||
- (int) weekOfYear;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
@interface NSData (GSCategories)
|
||||
|
||||
- (NSString*) hexadecimalRepresentation;
|
||||
|
@ -44,5 +46,27 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface NSString (GSCategories)
|
||||
- (NSString*) stringByDeletingPrefix: (NSString*)prefix;
|
||||
- (NSString*) stringByDeletingSuffix: (NSString*)suffix;
|
||||
@end
|
||||
|
||||
@interface NSMutableString (GSCategories)
|
||||
- (void) deleteSuffix: (NSString*)suffix;
|
||||
- (void) deletePrefix: (NSString*)prefix;
|
||||
@end
|
||||
|
||||
/* This is also defined in NSObject.h, but added here for use with the
|
||||
additions library */
|
||||
#ifndef NSOBJECT_GSCATEGORIES_INTERFACE
|
||||
@interface NSObject (GSCategories)
|
||||
- notImplemented:(SEL)aSel;
|
||||
- (id) subclassResponsibility: (SEL)aSel;
|
||||
- (id) shouldNotImplement: (SEL)aSel;
|
||||
|
||||
- (NSComparisonResult) compare: (id)anObject;
|
||||
@end
|
||||
#endif
|
||||
|
||||
#endif /* NO_GNUSTEP */
|
||||
#endif /* INCLUDED_GS_CATEGORIES_H */
|
||||
|
|
|
@ -28,7 +28,11 @@
|
|||
#ifndef __GSMIME_H__
|
||||
#define __GSMIME_H__
|
||||
|
||||
#ifdef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/Foundation.h>
|
||||
#else
|
||||
#include <Foundation/NSObject.h>
|
||||
#endif
|
||||
|
||||
@class NSArray;
|
||||
@class NSMutableArray;
|
||||
|
|
|
@ -291,6 +291,7 @@ GS_EXPORT NSRecursiveLock *gnustep_global_lock;
|
|||
- (id) write: (TypedStream*)aStream;
|
||||
@end
|
||||
|
||||
#define NSOBJECT_GSCATEGORIES_INTERFACE
|
||||
@interface NSObject (GSCategories)
|
||||
- notImplemented:(SEL)aSel;
|
||||
- (id) subclassResponsibility: (SEL)aSel;
|
||||
|
|
|
@ -366,11 +366,6 @@ extern struct objc_class _NSConstantStringClassReference;
|
|||
|
||||
#ifndef NO_GNUSTEP
|
||||
|
||||
@interface NSString (GSCategories)
|
||||
- (NSString*) stringByDeletingPrefix: (NSString*)prefix;
|
||||
- (NSString*) stringByDeletingSuffix: (NSString*)suffix;
|
||||
@end
|
||||
|
||||
@interface NSString (GNUstep)
|
||||
- (NSString*) stringByReplacingString: (NSString*)replace
|
||||
withString: (NSString*)by;
|
||||
|
@ -379,11 +374,6 @@ extern struct objc_class _NSConstantStringClassReference;
|
|||
- (NSString*) stringByTrimmingSpaces;
|
||||
@end
|
||||
|
||||
@interface NSMutableString (GSCategories)
|
||||
- (void) deleteSuffix: (NSString*)suffix;
|
||||
- (void) deletePrefix: (NSString*)prefix;
|
||||
@end
|
||||
|
||||
@interface NSMutableString (GNUstep)
|
||||
- (NSString*) immutableProxy;
|
||||
- (void) replaceString: (NSString*)replace
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSRange.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
|
|
@ -22,7 +22,9 @@
|
|||
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <string.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <gnustep/base/GSCategories.h>
|
||||
#include "GSCompatibility.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,12 +28,91 @@
|
|||
#ifdef NeXT_Foundation_LIBRARY
|
||||
#include <string.h>
|
||||
#include <Foundation/Foundation.h>
|
||||
#include "gnustep/base/preface.h"
|
||||
#include "gnustep/base/GSObjCRuntime.h"
|
||||
#include "gnustep/base/GNUstep.h"
|
||||
#include <CoreFoundation/CFString.h>
|
||||
#include <gnustep/base/preface.h>
|
||||
#include <gnustep/base/GSObjCRuntime.h>
|
||||
#include <gnustep/base/GNUstep.h>
|
||||
|
||||
#define NSDebugMLLog(a, args...)
|
||||
@class NSMutableSet;
|
||||
|
||||
// Following are also defined in gnustep-base/Headers/gnustep/base/NSObject.h
|
||||
#define IF_NO_GC(x) \
|
||||
x
|
||||
|
||||
// Following are also defined in gnustep-base/Headers/gnustep/base/NSDebug.h
|
||||
#ifdef DEBUG
|
||||
#define NSDebugLLog(level, format, args...) \
|
||||
do { if (GSDebugSet(level) == YES) \
|
||||
NSLog(format , ## args); } while (0)
|
||||
|
||||
#define NSDebugLog(format, args...) \
|
||||
do { if (GSDebugSet(@"dflt") == YES) \
|
||||
NSLog(format , ## args); } while (0)
|
||||
|
||||
#define NSDebugFLLog(level, format, args...) \
|
||||
do { if (GSDebugSet(level) == YES) { \
|
||||
NSString *fmt = GSDebugFunctionMsg( \
|
||||
__PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
|
||||
NSLog(fmt , ## args); }} while (0)
|
||||
|
||||
#define NSDebugFLog(format, args...) \
|
||||
do { if (GSDebugSet(@"dflt") == YES) { \
|
||||
NSString *fmt = GSDebugFunctionMsg( \
|
||||
__PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
|
||||
NSLog(fmt , ## args); }} while (0)
|
||||
|
||||
#define NSDebugMLLog(level, format, args...) \
|
||||
do { if (GSDebugSet(level) == YES) { \
|
||||
NSString *fmt = GSDebugMethodMsg( \
|
||||
self, _cmd, __FILE__, __LINE__, format); \
|
||||
NSLog(fmt , ## args); }} while (0)
|
||||
|
||||
#define NSDebugMLog(format, args...) \
|
||||
do { if (GSDebugSet(@"dflt") == YES) { \
|
||||
NSString *fmt = GSDebugMethodMsg( \
|
||||
self, _cmd, __FILE__, __LINE__, format); \
|
||||
NSLog(fmt , ## args); }} while (0)
|
||||
|
||||
#else
|
||||
#define NSDebugLLog(level, format, args...)
|
||||
#define NSDebugLog(format, args...)
|
||||
#define NSDebugFLLog(level, format, args...)
|
||||
#define NSDebugFLog(format, args...)
|
||||
#define NSDebugMLLog(level, format, args...)
|
||||
#define NSDebugMLog(format, args...)
|
||||
#endif /* DEBUG */
|
||||
|
||||
#ifdef GSWARN
|
||||
#define NSWarnLog(format, args...) \
|
||||
do { if (GSDebugSet(@"NoWarn") == NO) { \
|
||||
NSLog(format , ## args); }} while (0)
|
||||
|
||||
#define NSWarnFLog(format, args...) \
|
||||
do { if (GSDebugSet(@"NoWarn") == NO) { \
|
||||
NSString *fmt = GSDebugFunctionMsg( \
|
||||
__PRETTY_FUNCTION__, __FILE__, __LINE__, format); \
|
||||
NSLog(fmt , ## args); }} while (0)
|
||||
|
||||
#define NSWarnMLog(format, args...) \
|
||||
do { if (GSDebugSet(@"NoWarn") == NO) { \
|
||||
NSString *fmt = GSDebugMethodMsg( \
|
||||
self, _cmd, __FILE__, __LINE__, format); \
|
||||
NSLog(fmt , ## args); }} while (0)
|
||||
#else
|
||||
#define NSWarnLog(format, args...)
|
||||
#define NSWarnFLog(format, args...)
|
||||
#define NSWarnMLog(format, args...)
|
||||
#endif /* GSWARN */
|
||||
|
||||
#define GS_RANGE_CHECK(RANGE, SIZE) \
|
||||
if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
|
||||
[NSException raise: NSRangeException \
|
||||
format: @"in %s, range { %u, %u } extends beyond size (%u)", \
|
||||
sel_get_name(_cmd), RANGE.location, RANGE.length, SIZE]
|
||||
|
||||
GS_EXPORT NSRecursiveLock *gnustep_global_lock;
|
||||
|
||||
/* Taken from gnustep-base/Headers/gnustep/base/NSString.h */
|
||||
typedef enum _NSGNUstepStringEncoding
|
||||
{
|
||||
/* NB. Must not have an encoding with value zero - so we can use zero to
|
||||
|
@ -64,20 +143,37 @@ typedef enum _NSGNUstepStringEncoding
|
|||
NSBIG5StringEncoding // Traditional chinese
|
||||
} NSGNUstepStringEncoding;
|
||||
|
||||
NSString *GetEncodingName(NSStringEncoding availableEncodingValue);
|
||||
@interface NSObject(GNUStepGlue)
|
||||
+ (id) notImplemented:(SEL)selector;
|
||||
- (BOOL) isInstance;
|
||||
@end
|
||||
|
||||
#define GS_RANGE_CHECK(RANGE, SIZE) \
|
||||
if (RANGE.location > SIZE || RANGE.length > (SIZE - RANGE.location)) \
|
||||
[NSException raise: NSRangeException \
|
||||
format: @"in %s, range { %u, %u } extends beyond size (%u)", \
|
||||
sel_get_name(_cmd), RANGE.location, RANGE.length, SIZE]
|
||||
// Used only in EOFault.m, -[EOFault forward::], for Object compatibility
|
||||
@interface NSInvocation(GNUStepGlue)
|
||||
- (retval_t) returnFrame:(arglist_t)args;
|
||||
- (id) initWithArgframe:(arglist_t)args selector:(SEL)selector;
|
||||
@end
|
||||
|
||||
GS_EXPORT NSRecursiveLock *gnustep_global_lock;
|
||||
GS_EXPORT NSArray *NSStandardLibraryPaths();
|
||||
GS_EXPORT NSString *GetEncodingName(NSStringEncoding availableEncodingValue);
|
||||
|
||||
@interface NSString(GNUStepGlue)
|
||||
- (BOOL) boolValue;
|
||||
@end
|
||||
|
||||
GS_EXPORT BOOL GSDebugSet(NSString *level);
|
||||
@interface NSProcessInfo(GNUStepGlue)
|
||||
- (NSMutableSet *) debugSet;
|
||||
@end
|
||||
|
||||
GS_EXPORT NSString *GSDebugMethodMsg(id obj, SEL sel, const char *file, int line, NSString *fmt);
|
||||
GS_EXPORT NSString *GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt);
|
||||
|
||||
@interface NSArray (GSCompatibility)
|
||||
- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy;
|
||||
@end
|
||||
|
||||
|
||||
#endif /* NexT_FOUNDATION_LIB */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Adam Fedor <fedor@gnu.org>
|
||||
Written by: Stephane Corthesy on Sat Nov 16 2002.
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
|
@ -22,6 +23,7 @@
|
|||
|
||||
*/
|
||||
#include "config.h"
|
||||
#include <objc/objc-class.h>
|
||||
#include "GSCompatibility.h"
|
||||
|
||||
/* FIXME: Need to initialize this */
|
||||
|
@ -32,6 +34,39 @@ NSString *GetEncodingName(NSStringEncoding availableEncodingValue)
|
|||
return (NSString *)CFStringGetNameOfEncoding(CFStringConvertNSStringEncodingToEncoding(availableEncodingValue));
|
||||
}
|
||||
|
||||
NSArray *NSStandardLibraryPaths()
|
||||
{
|
||||
return NSSearchPathForDirectoriesInDomains(NSAllLibrariesDirectory, NSAllDomainsMask, YES);
|
||||
}
|
||||
|
||||
// Defined in NSDebug.m
|
||||
NSString*
|
||||
GSDebugMethodMsg(id obj, SEL sel, const char *file, int line, NSString *fmt)
|
||||
{
|
||||
NSString *message;
|
||||
Class cls = (Class)obj;
|
||||
char c = '+';
|
||||
|
||||
if ([obj isInstance] == YES)
|
||||
{
|
||||
c = '-';
|
||||
cls = [obj class];
|
||||
}
|
||||
message = [NSString stringWithFormat: @"File %s: %d. In [%@ %c%@] %@",
|
||||
file, line, NSStringFromClass(cls), c, NSStringFromSelector(sel), fmt];
|
||||
return message;
|
||||
}
|
||||
|
||||
NSString*
|
||||
GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt)
|
||||
{
|
||||
NSString *message;
|
||||
|
||||
message = [NSString stringWithFormat: @"File %s: %d. In %s %@",
|
||||
file, line, func, fmt];
|
||||
return message;
|
||||
}
|
||||
|
||||
@implementation NSArray (GSCompatibility)
|
||||
|
||||
/**
|
||||
|
@ -71,3 +106,112 @@ return (NSString *)CFStringGetNameOfEncoding(CFStringConvertNSStringEncodingToEn
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSProcessInfo(GNUStepGlue)
|
||||
|
||||
static NSMutableSet *_debug_set = nil;
|
||||
|
||||
BOOL GSDebugSet(NSString *level)
|
||||
// From GNUStep's
|
||||
{
|
||||
static IMP debugImp = 0;
|
||||
static SEL debugSel;
|
||||
|
||||
if (debugImp == 0)
|
||||
{
|
||||
debugSel = @selector(member:);
|
||||
if (_debug_set == nil)
|
||||
{
|
||||
[[NSProcessInfo processInfo] debugSet];
|
||||
}
|
||||
debugImp = [_debug_set methodForSelector: debugSel];
|
||||
}
|
||||
if ((*debugImp)(_debug_set, debugSel, level) == nil)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSMutableSet *) debugSet
|
||||
// Derived from GNUStep's
|
||||
{
|
||||
if(_debug_set == nil){
|
||||
int argc = [[self arguments] count];
|
||||
NSMutableSet *mySet;
|
||||
int i;
|
||||
|
||||
mySet = [NSMutableSet new];
|
||||
for (i = 0; i < argc; i++)
|
||||
{
|
||||
NSString *str = [[self arguments] objectAtIndex:i];
|
||||
|
||||
if ([str hasPrefix: @"--GNU-Debug="])
|
||||
[mySet addObject: [str substringFromIndex: 12]];
|
||||
}
|
||||
_debug_set = mySet;
|
||||
}
|
||||
|
||||
return _debug_set;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSString(GNUStepGlue)
|
||||
|
||||
// From GNUStep
|
||||
/**
|
||||
* If the string consists of the words 'true' or 'yes' (case insensitive)
|
||||
* or begins with a non-zero numeric value, return YES, otherwise return
|
||||
* NO.
|
||||
*/
|
||||
- (BOOL) boolValue
|
||||
{
|
||||
if ([self caseInsensitiveCompare: @"YES"] == NSOrderedSame)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
if ([self caseInsensitiveCompare: @"true"] == NSOrderedSame)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
return [self intValue] != 0 ? YES : NO;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSInvocation(GNUStepGlue)
|
||||
- (retval_t) returnFrame:(arglist_t)args
|
||||
{
|
||||
#warning (stephane@sente.ch) Not implemented
|
||||
return (retval_t)[self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
- (id) initWithArgframe:(arglist_t)args selector:(SEL)selector
|
||||
{
|
||||
#warning (stephane@sente.ch) Not implemented
|
||||
return [self notImplemented:_cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSObject(GNUStepGlue)
|
||||
|
||||
+ (id) notImplemented:(SEL)selector
|
||||
{
|
||||
#warning (stephane@sente.ch) Not implemented
|
||||
[NSException raise: NSGenericException
|
||||
format: @"method %s not implemented in %s(class)",
|
||||
selector ? sel_get_name(selector) : "(null)",
|
||||
object_get_class_name(self)];
|
||||
return nil;
|
||||
}
|
||||
|
||||
// In NSObject.m, category GNU
|
||||
- (BOOL) isInstance
|
||||
{
|
||||
return GSObjCIsInstance(self);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Loading…
Reference in a new issue