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:
fedor 2003-01-31 18:25:41 +00:00
parent 85eeae90e8
commit 82fe8ffca0
9 changed files with 302 additions and 24 deletions

View file

@ -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