mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 00:30:53 +00:00
merge back reorganisation branch
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29615 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d0b66e510d
commit
f13d56d8ec
263 changed files with 5577 additions and 4170 deletions
|
@ -24,19 +24,19 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#include <string.h>
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSRange.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSRange.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#include "GNUstepBase/GCObject.h"
|
||||
#include "GNUstepBase/GNUstep.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepBase/GCObject.h"
|
||||
#import "GNUstepBase/GNUstep.h"
|
||||
|
||||
@implementation GCArray
|
||||
|
||||
|
|
|
@ -24,17 +24,17 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#include "GNUstepBase/GCObject.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepBase/GCObject.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
|
||||
typedef struct {
|
||||
id object;
|
||||
|
|
|
@ -28,18 +28,19 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSThread.h>
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GCObject.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#import "GNUstepBase/GCObject.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# src makefile for the GNUstep Base Library
|
||||
#
|
||||
# Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
# Copyright (C) 199a-2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# Written by: Scott Christley <scottc@net-community.com>
|
||||
#
|
||||
|
@ -32,7 +32,6 @@ include ../../config.mak
|
|||
SUBPROJECT_NAME = Additions
|
||||
|
||||
Additions_OBJC_FILES =\
|
||||
GSCategories.m \
|
||||
GSObjCRuntime.m \
|
||||
GCObject.m \
|
||||
GCArray.m \
|
||||
|
@ -42,6 +41,22 @@ Additions_OBJC_FILES =\
|
|||
GSXML.m \
|
||||
GSFunctions.m \
|
||||
GSInsensitiveDictionary.m \
|
||||
NSArray+GNUstepBase.m \
|
||||
NSAttributedString+GNUstepBase.m \
|
||||
NSBundle+GNUstepBase.m \
|
||||
NSCalendarDate+GNUstepBase.m \
|
||||
NSData+GNUstepBase.m \
|
||||
NSError+GNUstepBase.m \
|
||||
NSFileHandle+GNUstepBase.m \
|
||||
NSInvocation+GNUstepBase.m \
|
||||
NSLock+GNUstepBase.m \
|
||||
NSMutableString+GNUstepBase.m \
|
||||
NSNumber+GNUstepBase.m \
|
||||
NSObject+GNUstepBase.m \
|
||||
NSProcessInfo+GNUstepBase.m \
|
||||
NSString+GNUstepBase.m \
|
||||
NSTask+GNUstepBase.m \
|
||||
NSURL+GNUstepBase.m \
|
||||
behavior.m
|
||||
|
||||
ifneq ($(OBJC_RUNTIME_LIB), gnu)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -23,10 +23,9 @@
|
|||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#include <objc/objc-class.h>
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#include "GNUstepBase/GCObject.h"
|
||||
#import "GNUstepBase/GCObject.h"
|
||||
|
||||
/* Avoid compiler warnings about internal method
|
||||
*/
|
||||
|
@ -88,429 +87,3 @@ GSDebugFunctionMsg(const char *func, const char *file, int line, NSString *fmt)
|
|||
return message;
|
||||
}
|
||||
|
||||
@implementation NSArray (GSCompatibility)
|
||||
|
||||
/**
|
||||
* Initialize the receiver with the contents of array.
|
||||
* The order of array is preserved.<br />
|
||||
* If shouldCopy is YES then the objects are copied
|
||||
* rather than simply retained.<br />
|
||||
* Invokes -initWithObjects:count:
|
||||
*/
|
||||
- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy
|
||||
{
|
||||
unsigned c = [array count];
|
||||
id objects[c];
|
||||
|
||||
if ([array isProxy])
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
objects[i] = [array objectAtIndex: i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[array getObjects: objects];
|
||||
}
|
||||
if (shouldCopy == YES)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
objects[i] = [objects[i] copy];
|
||||
}
|
||||
self = [self initWithObjects: objects count: c];
|
||||
#if GS_WITH_GC == 0
|
||||
while (i > 0)
|
||||
{
|
||||
[objects[--i] release];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
self = [self initWithObjects: objects count: c];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@interface NSDistantObject (GSCategoriesRevealed)
|
||||
// This method is implemented in MacOS X 10.2.4, but is not public
|
||||
+ (void) _enableLogging:(BOOL)flag;
|
||||
@end
|
||||
|
||||
@implementation NSDistantObject (GSCompatibility)
|
||||
|
||||
+ (void) setDebug: (int)val
|
||||
{
|
||||
if ([self respondsToSelector:@selector(_enableLogging:)])
|
||||
[self _enableLogging:!!val];
|
||||
}
|
||||
@end
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@implementation NSFileHandle(GSCompatibility)
|
||||
// From GSFileHandle.m
|
||||
|
||||
static BOOL
|
||||
getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||
{
|
||||
const char *proto = "tcp";
|
||||
struct servent *sp;
|
||||
|
||||
if (pcl)
|
||||
{
|
||||
proto = [pcl lossyCString];
|
||||
}
|
||||
memset(sin, '\0', sizeof(*sin));
|
||||
sin->sin_family = AF_INET;
|
||||
|
||||
/*
|
||||
* If we were given a hostname, we use any address for that host.
|
||||
* Otherwise we expect the given name to be an address unless it is
|
||||
* a null (any address).
|
||||
*/
|
||||
if (name)
|
||||
{
|
||||
NSHost* host = [NSHost hostWithName: name];
|
||||
|
||||
if (host != nil)
|
||||
{
|
||||
name = [host address];
|
||||
}
|
||||
#ifndef HAVE_INET_ATON
|
||||
sin->sin_addr.s_addr = inet_addr([name lossyCString]);
|
||||
if (sin->sin_addr.s_addr == INADDR_NONE)
|
||||
#else
|
||||
if (inet_aton([name lossyCString], &sin->sin_addr) == 0)
|
||||
#endif
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sin->sin_addr.s_addr = NSSwapHostIntToBig(INADDR_ANY);
|
||||
}
|
||||
if (svc == nil)
|
||||
{
|
||||
sin->sin_port = 0;
|
||||
return YES;
|
||||
}
|
||||
else if ((sp = getservbyname([svc lossyCString], proto)) == 0)
|
||||
{
|
||||
const char* ptr = [svc lossyCString];
|
||||
int val = atoi(ptr);
|
||||
|
||||
while (isdigit(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
if (*ptr == '\0' && val <= 0xffff)
|
||||
{
|
||||
unsigned short v = val;
|
||||
|
||||
sin->sin_port = NSSwapHostShortToBig(v);
|
||||
return YES;
|
||||
}
|
||||
else if (strcmp(ptr, "gdomap") == 0)
|
||||
{
|
||||
unsigned short v;
|
||||
#ifdef GDOMAP_PORT_OVERRIDE
|
||||
v = GDOMAP_PORT_OVERRIDE;
|
||||
#else
|
||||
v = 538; // IANA allocated port
|
||||
#endif
|
||||
sin->sin_port = NSSwapHostShortToBig(v);
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sin->sin_port = sp->s_port;
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initAsServerAtAddress: (NSString*)a
|
||||
service: (NSString*)s
|
||||
protocol: (NSString*)p
|
||||
{
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
int status = 1;
|
||||
#endif
|
||||
int net;
|
||||
struct sockaddr_in sin;
|
||||
int size = sizeof(sin);
|
||||
|
||||
if (getAddr(a, s, p, &sin) == NO)
|
||||
{
|
||||
RELEASE(self);
|
||||
NSLog(@"bad address-service-protocol combination");
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0)
|
||||
{
|
||||
NSLog(@"unable to create socket - %@", [NSError _last]);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this process exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
setsockopt(net, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status));
|
||||
#endif
|
||||
|
||||
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
|
||||
NSSwapBigShortToHost(sin.sin_port), [NSError _last]);
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (listen(net, 5) < 0)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %@", [NSError _last]);
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (getsockname(net, (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %@", [NSError _last]);
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
self = [self initWithFileDescriptor: net closeOnDealloc: YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (id) fileHandleAsServerAtAddress: (NSString*)address
|
||||
service: (NSString*)service
|
||||
protocol: (NSString*)protocol
|
||||
{
|
||||
id o = [self allocWithZone: NSDefaultMallocZone()];
|
||||
|
||||
return AUTORELEASE([o initAsServerAtAddress: address
|
||||
service: service
|
||||
protocol: protocol]);
|
||||
}
|
||||
|
||||
- (NSString*) socketAddress
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
int size = sizeof(sin);
|
||||
|
||||
if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %@", [NSError _last]);
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [[[NSString alloc] initWithCString: (char*)inet_ntoa(sin.sin_addr)]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSProcessInfo(GSCompatibility)
|
||||
|
||||
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(GSCompatibility)
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
/**
|
||||
* Returns YES when scanning the receiver's text from left to right finds a
|
||||
* digit in the range 1-9 or a letter in the set ('Y', 'y', 'T', 't').<br />
|
||||
* Any trailing characters are ignored.<br />
|
||||
* Any leading whitespace or zeros or signs are also ignored.<br />
|
||||
* Returns NO if the above conditions are not met.
|
||||
*/
|
||||
- (BOOL) boolValue
|
||||
{
|
||||
static NSCharacterSet *yes = nil;
|
||||
|
||||
if (yes == nil)
|
||||
{
|
||||
yes = RETAIN([NSCharacterSet characterSetWithCharactersInString:
|
||||
@"123456789yYtT"]);
|
||||
}
|
||||
if ([self rangeOfCharacterFromSet: yes].length > 0)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
- (NSString*) substringFromRange:(NSRange)range
|
||||
{
|
||||
return [self substringWithRange:range];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSInvocation(GSCompatibility)
|
||||
- (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(GSCompatibility)
|
||||
|
||||
+ (id) notImplemented:(SEL)selector
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"method %s not implemented in %s(class)",
|
||||
selector ? GSNameFromSelector(selector) : "(null)",
|
||||
GSClassNameFromObject(self)];
|
||||
return nil;
|
||||
}
|
||||
|
||||
// In NSObject.m, category GNU
|
||||
- (BOOL) isInstance
|
||||
{
|
||||
return GSObjCIsInstance(self);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSBundle(GSCompatibility)
|
||||
|
||||
// In NSBundle.m
|
||||
+ (NSString *) pathForLibraryResource: (NSString *)name
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath
|
||||
{
|
||||
NSString *path = nil;
|
||||
NSString *bundle_path = nil;
|
||||
NSArray *paths;
|
||||
NSBundle *bundle;
|
||||
NSEnumerator *enumerator;
|
||||
|
||||
/* Gather up the paths */
|
||||
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
||||
NSAllDomainsMask, YES);
|
||||
|
||||
enumerator = [paths objectEnumerator];
|
||||
while ((path == nil) && (bundle_path = [enumerator nextObject]))
|
||||
{
|
||||
bundle = [self bundleWithPath: bundle_path];
|
||||
path = [bundle pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation NSURL (GSCompatibility)
|
||||
- (NSString*) fullPath
|
||||
{
|
||||
NSRange r;
|
||||
NSString *s;
|
||||
|
||||
s = [self absoluteString];
|
||||
if ((r = [s rangeOfString: @";"]).length > 0)
|
||||
{
|
||||
s = [s substringToIndex: r.location];
|
||||
}
|
||||
else if ((r = [s rangeOfString: @"?"]).length > 0)
|
||||
{
|
||||
s = [s substringToIndex: r.location];
|
||||
}
|
||||
r = [s rangeOfString: @"//"];
|
||||
s = [s substringFromIndex: NSMaxRange(r)];
|
||||
r = [s rangeOfString: @"/"];
|
||||
s = [s substringFromIndex: r.location];
|
||||
return s;
|
||||
}
|
||||
@end
|
||||
|
|
|
@ -19,17 +19,26 @@
|
|||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
<title>NSPathUtilities function reference</title>
|
||||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSFunctions.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#include "Foundation/Foundation.h"
|
||||
#import "config.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSFunctions.h"
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#else
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
NSString *
|
||||
GSFindNamedFile(NSArray *paths, NSString *aName, NSString *anExtension)
|
||||
|
|
|
@ -23,19 +23,19 @@
|
|||
*/
|
||||
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSEnumerator.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSPortCoder.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#import "config.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSPortCoder.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
#import "Foundation/NSKeyedArchiver.h"
|
||||
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -25,14 +25,15 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSThread.h>
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "GNUstepBase/GNUstep.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_GSLock_IVARS 1
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "GNUstepBase/GNUstep.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
|
||||
/**
|
||||
* This implements a class which, when used in single-threaded mode,
|
||||
|
|
|
@ -51,17 +51,33 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_GSMimeDocument_IVARS 1
|
||||
#define EXPOSE_GSMimeHeader_IVARS 1
|
||||
#define EXPOSE_GSMimeParser_IVARS 1
|
||||
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSCharacterSet.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSScanner.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "GNUstepBase/GSMime.h"
|
||||
#import "GNUstepBase/GSXML.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
#import "GNUstepBase/NSData+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
#import "GNUstepBase/Unicode.h"
|
||||
|
||||
#include "../GSPrivate.h"
|
||||
#import "../GSPrivate.h"
|
||||
|
||||
static NSCharacterSet *whitespace = nil;
|
||||
static NSCharacterSet *rfc822Specials = nil;
|
||||
|
|
|
@ -29,30 +29,30 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#import "config.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSEnumerator.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSMethodSignature.h>
|
||||
#include <Foundation/NSNull.h>
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
#include <Foundation/NSSet.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSMethodSignature.h"
|
||||
#import "Foundation/NSNull.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#include "GNUstepBase/GNUstep.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepBase/GNUstep.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
|
||||
#include "../GSPrivate.h"
|
||||
#import "../GSPrivate.h"
|
||||
|
||||
#include <objc/Protocol.h>
|
||||
|
||||
|
@ -1405,8 +1405,8 @@ GSObjCAddClassBehavior(Class receiver, Class behavior)
|
|||
|
||||
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSKeyValueCoding.h>
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "Foundation/NSKeyValueCoding.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -40,19 +40,22 @@
|
|||
</chapter>
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#include "GNUstepBase/Unicode.h"
|
||||
#import "config.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
#import "GNUstepBase/Unicode.h"
|
||||
|
||||
|
||||
#ifdef HAVE_LIBXML
|
||||
|
||||
// #undef HAVE_LIBXML_SAX2_H
|
||||
|
||||
#include "GNUstepBase/GSMime.h"
|
||||
#include "GNUstepBase/GSXML.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#import "GNUstepBase/GSMime.h"
|
||||
#import "GNUstepBase/GSXML.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSString.h"
|
||||
|
||||
/* Avoid problems on systems where the xml headers use 'id'
|
||||
*/
|
||||
|
@ -4100,12 +4103,12 @@ static BOOL warned = NO; if (warned == NO) { warned = YES; NSLog(@"WARNING, use
|
|||
#else
|
||||
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSObjCRuntime.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#include <Foundation/NSInvocation.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSInvocation.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
201
Source/Additions/NSArray+GNUstepBase.m
Normal file
201
Source/Additions/NSArray+GNUstepBase.m
Normal file
|
@ -0,0 +1,201 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSArray+GNUstepBase.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
@implementation NSArray (GNUstepBase)
|
||||
|
||||
/**
|
||||
* Initialize the receiver with the contents of array.
|
||||
* The order of array is preserved.<br />
|
||||
* If shouldCopy is YES then the objects are copied
|
||||
* rather than simply retained.<br />
|
||||
* Invokes -initWithObjects:count:
|
||||
*/
|
||||
- (id) initWithArray: (NSArray*)array copyItems: (BOOL)shouldCopy
|
||||
{
|
||||
unsigned c = [array count];
|
||||
GS_BEGINIDBUF(objects, c);
|
||||
|
||||
if ([array isProxy])
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
objects[i] = [array objectAtIndex: i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
[array getObjects: objects];
|
||||
}
|
||||
if (shouldCopy == YES)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
for (i = 0; i < c; i++)
|
||||
{
|
||||
objects[i] = [objects[i] copy];
|
||||
}
|
||||
self = [self initWithObjects: objects count: c];
|
||||
#if GS_WITH_GC == 0
|
||||
while (i > 0)
|
||||
{
|
||||
[objects[--i] release];
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
self = [self initWithObjects: objects count: c];
|
||||
}
|
||||
GS_ENDIDBUF();
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSUInteger) insertionPosition: (id)item
|
||||
usingFunction: (NSComparisonResult (*)(id, id, void *))sorter
|
||||
context: (void *)context
|
||||
{
|
||||
unsigned count = [self count];
|
||||
unsigned upper = count;
|
||||
unsigned lower = 0;
|
||||
unsigned index;
|
||||
SEL oaiSel;
|
||||
IMP oai;
|
||||
|
||||
if (item == nil)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Attempt to find position for nil object in array"];
|
||||
}
|
||||
if (sorter == 0)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Attempt to find position with null comparator"];
|
||||
}
|
||||
|
||||
oaiSel = @selector(objectAtIndex:);
|
||||
oai = [self methodForSelector: oaiSel];
|
||||
/*
|
||||
* Binary search for an item equal to the one to be inserted.
|
||||
*/
|
||||
for (index = upper/2; upper != lower; index = lower+(upper-lower)/2)
|
||||
{
|
||||
NSComparisonResult comparison;
|
||||
|
||||
comparison = (*sorter)(item, (*oai)(self, oaiSel, index), context);
|
||||
if (comparison == NSOrderedAscending)
|
||||
{
|
||||
upper = index;
|
||||
}
|
||||
else if (comparison == NSOrderedDescending)
|
||||
{
|
||||
lower = index + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Now skip past any equal items so the insertion point is AFTER any
|
||||
* items that are equal to the new one.
|
||||
*/
|
||||
while (index < count && (*sorter)(item, (*oai)(self, oaiSel, index), context)
|
||||
!= NSOrderedAscending)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
- (NSUInteger) insertionPosition: (id)item
|
||||
usingSelector: (SEL)comp
|
||||
{
|
||||
unsigned count = [self count];
|
||||
unsigned upper = count;
|
||||
unsigned lower = 0;
|
||||
unsigned index;
|
||||
NSComparisonResult (*imp)(id, SEL, id);
|
||||
SEL oaiSel;
|
||||
IMP oai;
|
||||
|
||||
if (item == nil)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Attempt to find position for nil object in array"];
|
||||
}
|
||||
if (comp == 0)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Attempt to find position with null comparator"];
|
||||
}
|
||||
imp = (NSComparisonResult (*)(id, SEL, id))[item methodForSelector: comp];
|
||||
if (imp == 0)
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"Attempt to find position with unknown method"];
|
||||
}
|
||||
|
||||
oaiSel = @selector(objectAtIndex:);
|
||||
oai = [self methodForSelector: oaiSel];
|
||||
/*
|
||||
* Binary search for an item equal to the one to be inserted.
|
||||
*/
|
||||
for (index = upper/2; upper != lower; index = lower+(upper-lower)/2)
|
||||
{
|
||||
NSComparisonResult comparison;
|
||||
|
||||
comparison = (*imp)(item, comp, (*oai)(self, oaiSel, index));
|
||||
if (comparison == NSOrderedAscending)
|
||||
{
|
||||
upper = index;
|
||||
}
|
||||
else if (comparison == NSOrderedDescending)
|
||||
{
|
||||
lower = index + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Now skip past any equal items so the insertion point is AFTER any
|
||||
* items that are equal to the new one.
|
||||
*/
|
||||
while (index < count
|
||||
&& (*imp)(item, comp, (*oai)(self, oaiSel, index)) != NSOrderedAscending)
|
||||
{
|
||||
index++;
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
@end
|
36
Source/Additions/NSAttributedString+GNUstepBase.m
Normal file
36
Source/Additions/NSAttributedString+GNUstepBase.m
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSAttributedString+GNUstepBase.h"
|
||||
|
||||
@implementation NSAttributedString (GNUstepBase)
|
||||
- (NSAttributedString*) attributedSubstringWithRange: (NSRange)aRange
|
||||
{
|
||||
GSOnceMLog(@"This method is deprecated, use -attributedSubstringFromRange:");
|
||||
return [self attributedSubstringFromRange: aRange];
|
||||
}
|
||||
@end
|
65
Source/Additions/NSBundle+GNUstepBase.m
Normal file
65
Source/Additions/NSBundle+GNUstepBase.m
Normal file
|
@ -0,0 +1,65 @@
|
|||
|
||||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
#import "GNUstepBase/NSBundle+GNUstepBase.h"
|
||||
|
||||
@implementation NSBundle(GNUstepBase)
|
||||
|
||||
// In NSBundle.m
|
||||
+ (NSString *) pathForLibraryResource: (NSString *)name
|
||||
ofType: (NSString *)ext
|
||||
inDirectory: (NSString *)bundlePath
|
||||
{
|
||||
NSString *path = nil;
|
||||
NSString *bundle_path = nil;
|
||||
NSArray *paths;
|
||||
NSBundle *bundle;
|
||||
NSEnumerator *enumerator;
|
||||
|
||||
/* Gather up the paths */
|
||||
paths = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,
|
||||
NSAllDomainsMask, YES);
|
||||
|
||||
enumerator = [paths objectEnumerator];
|
||||
while ((path == nil) && (bundle_path = [enumerator nextObject]))
|
||||
{
|
||||
bundle = [self bundleWithPath: bundle_path];
|
||||
path = [bundle pathForResource: name
|
||||
ofType: ext
|
||||
inDirectory: bundlePath];
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
90
Source/Additions/NSCalendarDate+GNUstepBase.m
Normal file
90
Source/Additions/NSCalendarDate+GNUstepBase.m
Normal file
|
@ -0,0 +1,90 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "GNUstepBase/NSCalendarDate+GNUstepBase.h"
|
||||
|
||||
/**
|
||||
* Extension methods for the NSCalendarDate class
|
||||
*/
|
||||
@implementation 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.<br />
|
||||
* 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 preceding 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.
|
||||
*/
|
||||
- (NSInteger) weekOfYear
|
||||
{
|
||||
NSInteger dayOfWeek = [self dayOfWeek];
|
||||
NSInteger dayOfYear;
|
||||
|
||||
/*
|
||||
* Whether a week is considered to be in a year or not depends on its
|
||||
* thursday ... so find thursday for the receivers week.
|
||||
* NB. this may result in a date which is not in the same year as the
|
||||
* receiver.
|
||||
*/
|
||||
if (dayOfWeek != 4)
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSCalendarDate *thursday;
|
||||
|
||||
/*
|
||||
* A week starts on monday ... so adjust from 0 to 7 so that a
|
||||
* sunday is counted as the last day of the week.
|
||||
*/
|
||||
if (dayOfWeek == 0)
|
||||
{
|
||||
dayOfWeek = 7;
|
||||
}
|
||||
thursday = [self dateByAddingYears: 0
|
||||
months: 0
|
||||
days: 4 - dayOfWeek
|
||||
hours: 0
|
||||
minutes: 0
|
||||
seconds: 0];
|
||||
dayOfYear = [thursday dayOfYear];
|
||||
RELEASE(arp);
|
||||
}
|
||||
else
|
||||
{
|
||||
dayOfYear = [self dayOfYear];
|
||||
}
|
||||
|
||||
/*
|
||||
* Round up to a week boundary, so that when we divide by seven we
|
||||
* get a result in the range 1 to 53 as mandated by the ISO standard.
|
||||
*/
|
||||
dayOfYear += (7 - dayOfYear % 7);
|
||||
return dayOfYear / 7;
|
||||
}
|
||||
|
||||
@end
|
706
Source/Additions/NSData+GNUstepBase.m
Normal file
706
Source/Additions/NSData+GNUstepBase.m
Normal file
|
@ -0,0 +1,706 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSData+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
|
||||
/**
|
||||
* Extension methods for the NSData class.
|
||||
*/
|
||||
@implementation NSData (GNUstepBase)
|
||||
|
||||
/**
|
||||
* 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.<br />
|
||||
* 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.<br />
|
||||
* If you need the hexadecimal representation as raw byte data, use code
|
||||
* like -
|
||||
* <example>
|
||||
* hexData = [[sourceData hexadecimalRepresentation]
|
||||
* dataUsingEncoding: NSASCIIStringEncoding];
|
||||
* </example>
|
||||
*/
|
||||
- (NSString*) hexadecimalRepresentation
|
||||
{
|
||||
static const char *hexChars = "0123456789ABCDEF";
|
||||
unsigned slen = [self length];
|
||||
unsigned dlen = slen * 2;
|
||||
const unsigned char *src = (const unsigned char *)[self bytes];
|
||||
char *dst = (char*)NSZoneMalloc(NSDefaultMallocZone(), dlen);
|
||||
unsigned spos = 0;
|
||||
unsigned dpos = 0;
|
||||
NSData *data;
|
||||
NSString *string;
|
||||
|
||||
while (spos < slen)
|
||||
{
|
||||
unsigned char c = src[spos++];
|
||||
|
||||
dst[dpos++] = hexChars[(c >> 4) & 0x0f];
|
||||
dst[dpos++] = hexChars[c & 0x0f];
|
||||
}
|
||||
data = [NSData allocWithZone: NSDefaultMallocZone()];
|
||||
data = [data initWithBytesNoCopy: dst length: dlen];
|
||||
string = [[NSString alloc] initWithData: data
|
||||
encoding: NSASCIIStringEncoding];
|
||||
RELEASE(data);
|
||||
return AUTORELEASE(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 space).<br />
|
||||
* If the string does not contain one or more pairs of hexadecimal digits
|
||||
* then an exception is raised.
|
||||
*/
|
||||
- (id) initWithHexadecimalRepresentation: (NSString*)string
|
||||
{
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSData *d;
|
||||
const char *src;
|
||||
const char *end;
|
||||
unsigned char *dst;
|
||||
unsigned int pos = 0;
|
||||
unsigned char byte = 0;
|
||||
BOOL high = NO;
|
||||
|
||||
d = [string dataUsingEncoding: NSASCIIStringEncoding
|
||||
allowLossyConversion: YES];
|
||||
src = (const char*)[d bytes];
|
||||
end = src + [d length];
|
||||
dst = NSZoneMalloc(NSDefaultMallocZone(), [d length]/2 + 1);
|
||||
|
||||
while (src < end)
|
||||
{
|
||||
char c = *src++;
|
||||
unsigned char v;
|
||||
|
||||
if (isspace(c))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (c >= '0' && c <= '9')
|
||||
{
|
||||
v = c - '0';
|
||||
}
|
||||
else if (c >= 'A' && c <= 'F')
|
||||
{
|
||||
v = c - 'A' + 10;
|
||||
}
|
||||
else if (c >= 'a' && c <= 'f')
|
||||
{
|
||||
v = c - 'a' + 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = 0;
|
||||
break;
|
||||
}
|
||||
if (high == NO)
|
||||
{
|
||||
byte = v << 4;
|
||||
high = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
byte |= v;
|
||||
high = NO;
|
||||
dst[pos++] = byte;
|
||||
}
|
||||
}
|
||||
if (pos > 0 && high == NO)
|
||||
{
|
||||
self = [self initWithBytes: dst length: pos];
|
||||
}
|
||||
else
|
||||
{
|
||||
DESTROY(self);
|
||||
}
|
||||
NSZoneFree(NSDefaultMallocZone(), dst);
|
||||
RELEASE(arp);
|
||||
if (self == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@: invalid hexadeciaml string data",
|
||||
NSStringFromSelector(_cmd)];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
struct MD5Context
|
||||
{
|
||||
uint32_t buf[4];
|
||||
uint32_t bits[2];
|
||||
uint8_t in[64];
|
||||
};
|
||||
static void MD5Init (struct MD5Context *context);
|
||||
static void MD5Update (struct MD5Context *context, unsigned char const *buf,
|
||||
unsigned len);
|
||||
static void MD5Final (unsigned char digest[16], struct MD5Context *context);
|
||||
static void MD5Transform (uint32_t buf[4], uint32_t const in[16]);
|
||||
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Ensure data is little-endian
|
||||
*/
|
||||
static void littleEndian (void *buf, unsigned words)
|
||||
{
|
||||
if (NSHostByteOrder() == NS_BigEndian)
|
||||
{
|
||||
while (words-- > 0)
|
||||
{
|
||||
union swap {
|
||||
uint32_t num;
|
||||
uint8_t byt[4];
|
||||
} tmp;
|
||||
uint8_t b0;
|
||||
uint8_t b1;
|
||||
|
||||
tmp.num = ((uint32_t*)buf)[words];
|
||||
b0 = tmp.byt[0];
|
||||
b1 = tmp.byt[1];
|
||||
tmp.byt[0] = tmp.byt[3];
|
||||
tmp.byt[1] = tmp.byt[2];
|
||||
tmp.byt[2] = b1;
|
||||
tmp.byt[3] = b0;
|
||||
((uint32_t*)buf)[words] = tmp.num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
* initialization constants.
|
||||
*/
|
||||
static void MD5Init (struct MD5Context *ctx)
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bits[0] = 0;
|
||||
ctx->bits[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
static void MD5Update (struct MD5Context *ctx, unsigned char const *buf,
|
||||
unsigned len)
|
||||
{
|
||||
uint32_t t;
|
||||
|
||||
/* Update bitcount */
|
||||
|
||||
t = ctx->bits[0];
|
||||
if ((ctx->bits[0] = t + ((uint32_t) len << 3)) < t)
|
||||
ctx->bits[1]++; /* Carry from low to high */
|
||||
ctx->bits[1] += len >> 29;
|
||||
|
||||
t = (t >> 3) & 0x3f; /* Bytes already in shsInfo->data */
|
||||
|
||||
/* Handle any leading odd-sized chunks */
|
||||
|
||||
if (t)
|
||||
{
|
||||
unsigned char *p = (unsigned char *) ctx->in + t;
|
||||
|
||||
t = 64 - t;
|
||||
if (len < t)
|
||||
{
|
||||
memcpy (p, buf, len);
|
||||
return;
|
||||
}
|
||||
memcpy (p, buf, t);
|
||||
littleEndian (ctx->in, 16);
|
||||
MD5Transform (ctx->buf, (uint32_t *) ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
}
|
||||
/* Process data in 64-byte chunks */
|
||||
|
||||
while (len >= 64)
|
||||
{
|
||||
memcpy (ctx->in, buf, 64);
|
||||
littleEndian (ctx->in, 16);
|
||||
MD5Transform (ctx->buf, (uint32_t *) ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
|
||||
memcpy (ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
static void MD5Final (unsigned char digest[16], struct MD5Context *ctx)
|
||||
{
|
||||
unsigned count;
|
||||
unsigned char *p;
|
||||
|
||||
/* Compute number of bytes mod 64 */
|
||||
count = (ctx->bits[0] >> 3) & 0x3F;
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
p = ctx->in + count;
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 64 bytes */
|
||||
count = 64 - 1 - count;
|
||||
|
||||
/* Pad out to 56 mod 64 */
|
||||
if (count < 8)
|
||||
{
|
||||
/* Two lots of padding: Pad the first block to 64 bytes */
|
||||
memset (p, 0, count);
|
||||
littleEndian (ctx->in, 16);
|
||||
MD5Transform (ctx->buf, (uint32_t *) ctx->in);
|
||||
|
||||
/* Now fill the next block with 56 bytes */
|
||||
memset (ctx->in, 0, 56);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Pad block to 56 bytes */
|
||||
memset (p, 0, count - 8);
|
||||
}
|
||||
littleEndian (ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
((uint32_t *) ctx->in)[14] = ctx->bits[0];
|
||||
((uint32_t *) ctx->in)[15] = ctx->bits[1];
|
||||
|
||||
MD5Transform (ctx->buf, (uint32_t *) ctx->in);
|
||||
littleEndian ((unsigned char *) ctx->buf, 4);
|
||||
memcpy (digest, ctx->buf, 16);
|
||||
memset (ctx, 0, sizeof (ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
/* The four core functions - F1 is optimized somewhat */
|
||||
|
||||
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define F2(x, y, z) F1(z, x, y)
|
||||
#define F3(x, y, z) (x ^ y ^ z)
|
||||
#define F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f, w, x, y, z, data, s) \
|
||||
(w += f(x, y, z) + data, w = w<<s | w>>(32-s), w += x)
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
* reflect the addition of 16 43bit words of new data. MD5Update blocks
|
||||
* the data and converts bytes into 43bit words for this routine.
|
||||
*/
|
||||
static void MD5Transform (uint32_t buf[4], uint32_t const in[16])
|
||||
{
|
||||
register uint32_t a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP (F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP (F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP (F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP (F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP (F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP (F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP (F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP (F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP (F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP (F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP (F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP (F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP (F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP (F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP (F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP (F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP (F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP (F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP (F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP (F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP (F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP (F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP (F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP (F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP (F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP (F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP (F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP (F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP (F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP (F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP (F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP (F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP (F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP (F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP (F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP (F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP (F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP (F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP (F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP (F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP (F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP (F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP (F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP (F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP (F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP (F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP (F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP (F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP (F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP (F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP (F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP (F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP (F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP (F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP (F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP (F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP (F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP (F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP (F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP (F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP (F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP (F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP (F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP (F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an MD5 digest of the information stored in the receiver and
|
||||
* returns it as an autoreleased 16 byte NSData object.<br />
|
||||
* 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 -
|
||||
* <example>
|
||||
* myDigest = [[myString dataUsingEncoding: NSUTF8StringEncoding] md5Digest];
|
||||
* </example>
|
||||
* 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
|
||||
{
|
||||
struct MD5Context ctx;
|
||||
unsigned char digest[16];
|
||||
|
||||
MD5Init(&ctx);
|
||||
MD5Update(&ctx, [self bytes], [self length]);
|
||||
MD5Final(digest, &ctx);
|
||||
return [NSData dataWithBytes: digest length: 16];
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the source data from uuencoded and return the result.<br />
|
||||
* 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: (NSInteger*)modePtr
|
||||
{
|
||||
const unsigned char *bytes = (const unsigned char*)[self bytes];
|
||||
unsigned length = [self length];
|
||||
unsigned decLength = [decoded length];
|
||||
unsigned pos = 0;
|
||||
NSString *name = nil;
|
||||
|
||||
if (namePtr != 0)
|
||||
{
|
||||
*namePtr = nil;
|
||||
}
|
||||
if (modePtr != 0)
|
||||
{
|
||||
*modePtr = 0;
|
||||
}
|
||||
|
||||
#define DEC(c) (((c) - ' ') & 077)
|
||||
|
||||
for (pos = 0; pos < length; pos++)
|
||||
{
|
||||
if (bytes[pos] == '\n')
|
||||
{
|
||||
if (name != nil)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int lineLength;
|
||||
unsigned char *decPtr;
|
||||
|
||||
lineLength = DEC(bytes[i++]);
|
||||
if (lineLength <= 0)
|
||||
{
|
||||
break; // Got line length zero or less.
|
||||
}
|
||||
|
||||
[decoded setLength: decLength + lineLength];
|
||||
decPtr = [decoded mutableBytes];
|
||||
|
||||
while (lineLength > 0)
|
||||
{
|
||||
unsigned char tmp[4];
|
||||
int c;
|
||||
|
||||
/*
|
||||
* In case the data is corrupt, we need to copy into
|
||||
* a temporary buffer avoiding buffer overrun in the
|
||||
* main buffer.
|
||||
*/
|
||||
tmp[0] = bytes[i++];
|
||||
if (i < pos)
|
||||
{
|
||||
tmp[1] = bytes[i++];
|
||||
if (i < pos)
|
||||
{
|
||||
tmp[2] = bytes[i++];
|
||||
if (i < pos)
|
||||
{
|
||||
tmp[3] = bytes[i++];
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp[2] = 0;
|
||||
tmp[3] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp[1] = 0;
|
||||
tmp[2] = 0;
|
||||
tmp[3] = 0;
|
||||
}
|
||||
if (lineLength >= 1)
|
||||
{
|
||||
c = DEC(tmp[0]) << 2 | DEC(tmp[1]) >> 4;
|
||||
decPtr[decLength++] = (unsigned char)c;
|
||||
}
|
||||
if (lineLength >= 2)
|
||||
{
|
||||
c = DEC(tmp[1]) << 4 | DEC(tmp[2]) >> 2;
|
||||
decPtr[decLength++] = (unsigned char)c;
|
||||
}
|
||||
if (lineLength >= 3)
|
||||
{
|
||||
c = DEC(tmp[2]) << 6 | DEC(tmp[3]);
|
||||
decPtr[decLength++] = (unsigned char)c;
|
||||
}
|
||||
lineLength -= 3;
|
||||
}
|
||||
}
|
||||
else if (pos > 6 && strncmp((const char*)bytes, "begin ", 6) == 0)
|
||||
{
|
||||
unsigned off = 6;
|
||||
unsigned end = pos;
|
||||
int mode = 0;
|
||||
NSData *d;
|
||||
|
||||
if (end > off && bytes[end-1] == '\r')
|
||||
{
|
||||
end--;
|
||||
}
|
||||
while (off < end && bytes[off] >= '0' && bytes[off] <= '7')
|
||||
{
|
||||
mode *= 8;
|
||||
mode += bytes[off] - '0';
|
||||
off++;
|
||||
}
|
||||
if (modePtr != 0)
|
||||
{
|
||||
*modePtr = mode;
|
||||
}
|
||||
while (off < end && bytes[off] == ' ')
|
||||
{
|
||||
off++;
|
||||
}
|
||||
d = [NSData dataWithBytes: &bytes[off] length: end - off];
|
||||
name = [[NSString alloc] initWithData: d
|
||||
encoding: NSASCIIStringEncoding];
|
||||
IF_NO_GC(AUTORELEASE(name);)
|
||||
if (namePtr != 0)
|
||||
{
|
||||
*namePtr = name;
|
||||
}
|
||||
}
|
||||
pos++;
|
||||
bytes += pos;
|
||||
length -= pos;
|
||||
}
|
||||
}
|
||||
if (name == nil)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode the source data to uuencoded.<br />
|
||||
* Uses the supplied name as the filename in the encoded data,
|
||||
* and says that the file mode is as specified.<br />
|
||||
* If no name is supplied, uses <code>untitled</code> as the name.
|
||||
*/
|
||||
- (BOOL) uuencodeInto: (NSMutableData*)encoded
|
||||
name: (NSString*)name
|
||||
mode: (NSInteger)mode
|
||||
{
|
||||
const unsigned char *bytes = (const unsigned char*)[self bytes];
|
||||
int length = [self length];
|
||||
unsigned char buf[64];
|
||||
unsigned i;
|
||||
|
||||
name = [name stringByTrimmingSpaces];
|
||||
if ([name length] == 0)
|
||||
{
|
||||
name = @"untitled";
|
||||
}
|
||||
/*
|
||||
* The header is a line of the form 'begin mode filename'
|
||||
*/
|
||||
sprintf((char*)buf, "begin %03o ", (int)mode);
|
||||
[encoded appendBytes: buf length: strlen((const char*)buf)];
|
||||
[encoded appendData: [name dataUsingEncoding: NSASCIIStringEncoding]];
|
||||
[encoded appendBytes: "\n" length: 1];
|
||||
|
||||
#define ENC(c) ((c) > 0 ? ((c) & 077) + ' ': '`')
|
||||
|
||||
while (length > 0)
|
||||
{
|
||||
int count;
|
||||
unsigned pos;
|
||||
|
||||
/*
|
||||
* We want up to 45 bytes in a line ... and we record the
|
||||
* number of bytes as the initial output character.
|
||||
*/
|
||||
count = length;
|
||||
if (count > 45)
|
||||
{
|
||||
count = 45;
|
||||
}
|
||||
i = 0;
|
||||
buf[i++] = ENC(count);
|
||||
|
||||
/*
|
||||
* Now we encode the actual data for the line.
|
||||
*/
|
||||
for (pos = 0; count > 0; count -= 3)
|
||||
{
|
||||
unsigned char tmp[3];
|
||||
int c;
|
||||
|
||||
/*
|
||||
* Copy data into a temporary buffer ensuring we don't
|
||||
* overrun the end of the original buffer risking access
|
||||
* violation.
|
||||
*/
|
||||
tmp[0] = bytes[pos++];
|
||||
if (pos < length)
|
||||
{
|
||||
tmp[1] = bytes[pos++];
|
||||
if (pos < length)
|
||||
{
|
||||
tmp[2] = bytes[pos++];
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp[2] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp[1] = 0;
|
||||
tmp[2] = 0;
|
||||
}
|
||||
|
||||
c = tmp[0] >> 2;
|
||||
buf[i++] = ENC(c);
|
||||
c = ((tmp[0] << 4) & 060) | ((tmp[1] >> 4) & 017);
|
||||
buf[i++] = ENC(c);
|
||||
c = ((tmp[1] << 2) & 074) | ((tmp[2] >> 6) & 03);
|
||||
buf[i++] = ENC(c);
|
||||
c = tmp[2] & 077;
|
||||
buf[i++] = ENC(c);
|
||||
}
|
||||
bytes += pos;
|
||||
length -= pos;
|
||||
buf[i++] = '\n';
|
||||
[encoded appendBytes: buf length: i];
|
||||
}
|
||||
|
||||
/*
|
||||
* Encode a line of length zero followed by 'end' as the terminator.
|
||||
*/
|
||||
[encoded appendBytes: "`\nend\n" length: 6];
|
||||
return YES;
|
||||
}
|
||||
@end
|
144
Source/Additions/NSError+GNUstepBase.m
Normal file
144
Source/Additions/NSError+GNUstepBase.m
Normal file
|
@ -0,0 +1,144 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSError.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
#if !defined(__MINGW32__)
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GNUstep specific (non-standard) additions to the NSError class.
|
||||
* Possibly to be made public
|
||||
*/
|
||||
@implementation NSError(GSCategories)
|
||||
|
||||
|
||||
#if !defined(__MINGW32__)
|
||||
#if !defined(HAVE_STRERROR_R)
|
||||
#if defined(HAVE_STRERROR)
|
||||
static int
|
||||
strerror_r(int eno, char *buf, int len)
|
||||
{
|
||||
const char *ptr;
|
||||
int result;
|
||||
|
||||
[gnustep_global_lock lock];
|
||||
ptr = strerror(eno);
|
||||
if (ptr == 0)
|
||||
{
|
||||
strncpy(buf, "unknown error number", len);
|
||||
result = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(buf, strerror(eno), len);
|
||||
result = 0;
|
||||
}
|
||||
[gnustep_global_lock unlock];
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
static int
|
||||
strerror_r(int eno, char *buf, int len)
|
||||
{
|
||||
extern char *sys_errlist[];
|
||||
extern int sys_nerr;
|
||||
|
||||
if (eno < 0 || eno >= sys_nerr)
|
||||
{
|
||||
strncpy(buf, "unknown error number", len);
|
||||
return -1;
|
||||
}
|
||||
strncpy(buf, sys_errlist[eno], len);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Returns an NSError instance encapsulating the last system error.
|
||||
* The user info dictionary of this object will be mutable, so that
|
||||
* additional information can be placed in it by higher level code.
|
||||
*/
|
||||
+ (NSError*) _last
|
||||
{
|
||||
int eno;
|
||||
#if defined(__MINGW32__)
|
||||
eno = GetLastError();
|
||||
if (eno == 0) eno = errno;
|
||||
#else
|
||||
eno = errno;
|
||||
#endif
|
||||
return [self _systemError: eno];
|
||||
}
|
||||
|
||||
+ (NSError*) _systemError: (long)code
|
||||
{
|
||||
NSError *error;
|
||||
NSString *domain;
|
||||
NSDictionary *info;
|
||||
#if defined(__MINGW32__)
|
||||
LPVOID lpMsgBuf;
|
||||
NSString *message;
|
||||
|
||||
domain = NSOSStatusErrorDomain;
|
||||
FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, code, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPWSTR) &lpMsgBuf, 0, NULL );
|
||||
message = [NSString stringWithCharacters: lpMsgBuf length: wcslen(lpMsgBuf)];
|
||||
LocalFree(lpMsgBuf);
|
||||
info = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
message, NSLocalizedDescriptionKey,
|
||||
nil];
|
||||
#else
|
||||
NSString *message;
|
||||
char buf[BUFSIZ];
|
||||
|
||||
/* FIXME ... not all are POSIX, should we use NSMachErrorDomain for some? */
|
||||
domain = NSPOSIXErrorDomain;
|
||||
if (strerror_r(code, buf, BUFSIZ) < 0)
|
||||
{
|
||||
sprintf(buf, "%ld", code);
|
||||
}
|
||||
message = [NSString stringWithCString: buf
|
||||
encoding: [NSString defaultCStringEncoding]];
|
||||
/* FIXME ... can we do better localisation? */
|
||||
info = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
message, NSLocalizedDescriptionKey,
|
||||
nil];
|
||||
#endif
|
||||
|
||||
/* NB we use a mutable dictionary so that calling code can add extra
|
||||
* information to the dictionary before passing it up to higher level
|
||||
* code.
|
||||
*/
|
||||
error = [self errorWithDomain: domain code: code userInfo: info];
|
||||
return error;
|
||||
}
|
||||
@end
|
213
Source/Additions/NSFileHandle+GNUstepBase.m
Normal file
213
Source/Additions/NSFileHandle+GNUstepBase.m
Normal file
|
@ -0,0 +1,213 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSHost.h"
|
||||
#import "GSNetwork.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSFileHandle+GNUstepBase.h"
|
||||
|
||||
|
||||
@implementation NSFileHandle(GNUstepBase)
|
||||
// From GSFileHandle.m
|
||||
|
||||
static BOOL
|
||||
getAddr(NSString* name, NSString* svc, NSString* pcl, struct sockaddr_in *sin)
|
||||
{
|
||||
const char *proto = "tcp";
|
||||
struct servent *sp;
|
||||
|
||||
if (pcl)
|
||||
{
|
||||
proto = [pcl lossyCString];
|
||||
}
|
||||
memset(sin, '\0', sizeof(*sin));
|
||||
sin->sin_family = AF_INET;
|
||||
|
||||
/*
|
||||
* If we were given a hostname, we use any address for that host.
|
||||
* Otherwise we expect the given name to be an address unless it is
|
||||
* a null (any address).
|
||||
*/
|
||||
if (name)
|
||||
{
|
||||
NSHost* host = [NSHost hostWithName: name];
|
||||
|
||||
if (host != nil)
|
||||
{
|
||||
name = [host address];
|
||||
}
|
||||
#ifndef HAVE_INET_ATON
|
||||
sin->sin_addr.s_addr = inet_addr([name lossyCString]);
|
||||
if (sin->sin_addr.s_addr == INADDR_NONE)
|
||||
#else
|
||||
if (inet_aton([name lossyCString], &sin->sin_addr) == 0)
|
||||
#endif
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sin->sin_addr.s_addr = NSSwapHostIntToBig(INADDR_ANY);
|
||||
}
|
||||
if (svc == nil)
|
||||
{
|
||||
sin->sin_port = 0;
|
||||
return YES;
|
||||
}
|
||||
else if ((sp = getservbyname([svc lossyCString], proto)) == 0)
|
||||
{
|
||||
const char* ptr = [svc lossyCString];
|
||||
int val = atoi(ptr);
|
||||
|
||||
while (isdigit(*ptr))
|
||||
{
|
||||
ptr++;
|
||||
}
|
||||
if (*ptr == '\0' && val <= 0xffff)
|
||||
{
|
||||
unsigned short v = val;
|
||||
|
||||
sin->sin_port = NSSwapHostShortToBig(v);
|
||||
return YES;
|
||||
}
|
||||
else if (strcmp(ptr, "gdomap") == 0)
|
||||
{
|
||||
unsigned short v;
|
||||
#ifdef GDOMAP_PORT_OVERRIDE
|
||||
v = GDOMAP_PORT_OVERRIDE;
|
||||
#else
|
||||
v = 538; // IANA allocated port
|
||||
#endif
|
||||
sin->sin_port = NSSwapHostShortToBig(v);
|
||||
return YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sin->sin_port = sp->s_port;
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (id) initAsServerAtAddress: (NSString*)a
|
||||
service: (NSString*)s
|
||||
protocol: (NSString*)p
|
||||
{
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
int status = 1;
|
||||
#endif
|
||||
int net;
|
||||
struct sockaddr_in sin;
|
||||
unsigned int size = sizeof(sin);
|
||||
|
||||
if (getAddr(a, s, p, &sin) == NO)
|
||||
{
|
||||
RELEASE(self);
|
||||
NSLog(@"bad address-service-protocol combination");
|
||||
return nil;
|
||||
}
|
||||
|
||||
if ((net = socket(AF_INET, SOCK_STREAM, PF_UNSPEC)) < 0)
|
||||
{
|
||||
NSLog(@"unable to create socket - %@", [NSError _last]);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
#ifndef BROKEN_SO_REUSEADDR
|
||||
/*
|
||||
* Under decent systems, SO_REUSEADDR means that the port can be reused
|
||||
* immediately that this process exits. Under some it means
|
||||
* that multiple processes can serve the same port simultaneously.
|
||||
* We don't want that broken behavior!
|
||||
*/
|
||||
setsockopt(net, SOL_SOCKET, SO_REUSEADDR, (char *)&status, sizeof(status));
|
||||
#endif
|
||||
|
||||
if (bind(net, (struct sockaddr *)&sin, sizeof(sin)) < 0)
|
||||
{
|
||||
NSLog(@"unable to bind to port %s:%d - %@", inet_ntoa(sin.sin_addr),
|
||||
NSSwapBigShortToHost(sin.sin_port), [NSError _last]);
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (listen(net, 5) < 0)
|
||||
{
|
||||
NSLog(@"unable to listen on port - %@", [NSError _last]);
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (getsockname(net, (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %@", [NSError _last]);
|
||||
(void) close(net);
|
||||
RELEASE(self);
|
||||
return nil;
|
||||
}
|
||||
|
||||
self = [self initWithFileDescriptor: net closeOnDealloc: YES];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
+ (id) fileHandleAsServerAtAddress: (NSString*)address
|
||||
service: (NSString*)service
|
||||
protocol: (NSString*)protocol
|
||||
{
|
||||
id o = [self allocWithZone: NSDefaultMallocZone()];
|
||||
|
||||
return AUTORELEASE([o initAsServerAtAddress: address
|
||||
service: service
|
||||
protocol: protocol]);
|
||||
}
|
||||
|
||||
- (NSString*) socketAddress
|
||||
{
|
||||
struct sockaddr_in sin;
|
||||
unsigned int size = sizeof(sin);
|
||||
|
||||
if (getsockname([self fileDescriptor], (struct sockaddr*)&sin, &size) < 0)
|
||||
{
|
||||
NSLog(@"unable to get socket name - %@", [NSError _last]);
|
||||
return nil;
|
||||
}
|
||||
|
||||
return [[[NSString alloc] initWithCString: (char*)inet_ntoa(sin.sin_addr)]
|
||||
autorelease];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
42
Source/Additions/NSInvocation+GNUstepBase.m
Normal file
42
Source/Additions/NSInvocation+GNUstepBase.m
Normal file
|
@ -0,0 +1,42 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "GNUstepBase/NSInvocation+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@implementation NSInvocation(GSCompatibility)
|
||||
- (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
|
104
Source/Additions/NSLock+GNUstepBase.m
Normal file
104
Source/Additions/NSLock+GNUstepBase.m
Normal file
|
@ -0,0 +1,104 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSLock+GNUstepBase.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
|
||||
/**
|
||||
* GNUstep specific (non-standard) additions to the NSLock class.
|
||||
*/
|
||||
|
||||
static GSLazyRecursiveLock *local_lock = nil;
|
||||
|
||||
/*
|
||||
This class only exists to provide
|
||||
a thread safe mechanism to initialize local_lock
|
||||
as +initialize is called under a lock in ObjC runtimes.
|
||||
User code should resort to GS_INITIALIZED_LOCK(),
|
||||
which uses the +newLockAt: extension.
|
||||
*/
|
||||
|
||||
@interface _GSLockInitializer : NSObject
|
||||
@end
|
||||
@implementation _GSLockInitializer
|
||||
+ (void) initialize
|
||||
{
|
||||
if (local_lock == nil)
|
||||
{
|
||||
/* As we do not know whether creating custom locks
|
||||
may implicitly create other locks,
|
||||
we use a recursive lock. */
|
||||
local_lock = [GSLazyRecursiveLock new];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
GS_STATIC_INLINE id
|
||||
newLockAt(Class self, SEL _cmd, id *location)
|
||||
{
|
||||
if (location == 0)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"'%@' called with nil location",
|
||||
NSStringFromSelector(_cmd)];
|
||||
}
|
||||
|
||||
if (*location == nil)
|
||||
{
|
||||
if (local_lock == nil)
|
||||
{
|
||||
[_GSLockInitializer class];
|
||||
}
|
||||
|
||||
[local_lock lock];
|
||||
|
||||
if (*location == nil)
|
||||
{
|
||||
*location = [[(id)self alloc] init];
|
||||
}
|
||||
|
||||
[local_lock unlock];
|
||||
}
|
||||
|
||||
return *location;
|
||||
}
|
||||
|
||||
|
||||
@implementation NSLock (GSCategories)
|
||||
+ (id) newLockAt: (id *)location
|
||||
{
|
||||
return newLockAt(self, _cmd, location);
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation NSRecursiveLock (GSCategories)
|
||||
+ (id) newLockAt: (id *)location
|
||||
{
|
||||
return newLockAt(self, _cmd, location);
|
||||
}
|
||||
@end
|
||||
|
373
Source/Additions/NSMutableString+GNUstepBase.m
Normal file
373
Source/Additions/NSMutableString+GNUstepBase.m
Normal file
|
@ -0,0 +1,373 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#include <string.h>
|
||||
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
|
||||
|
||||
/* Test for ASCII whitespace which is safe for unicode characters */
|
||||
#define space(C) ((C) > 127 ? NO : isspace(C))
|
||||
|
||||
/* This private cass is used for the -immutableProxy method in the category
|
||||
* on NSMutableString.
|
||||
* It is needed for [NSAttributedString-string] and [NSTextStorage-string]
|
||||
*/
|
||||
@interface GSImmutableString : NSString
|
||||
{
|
||||
NSString *_parent;
|
||||
}
|
||||
- (id) initWithString: (NSString*)parent;
|
||||
@end
|
||||
|
||||
@implementation GSImmutableString
|
||||
|
||||
- (BOOL) canBeConvertedToEncoding: (NSStringEncoding)enc
|
||||
{
|
||||
return [_parent canBeConvertedToEncoding: enc];
|
||||
}
|
||||
|
||||
- (unichar) characterAtIndex: (NSUInteger)index
|
||||
{
|
||||
return [_parent characterAtIndex: index];
|
||||
}
|
||||
|
||||
- (NSComparisonResult) compare: (NSString*)aString
|
||||
options: (NSUInteger)mask
|
||||
range: (NSRange)aRange
|
||||
{
|
||||
return [_parent compare: aString options: mask range: aRange];
|
||||
}
|
||||
|
||||
- (const char *) cString
|
||||
{
|
||||
return [_parent cString];
|
||||
}
|
||||
|
||||
- (const char *) cStringUsingEncoding: (NSStringEncoding)encoding
|
||||
{
|
||||
return [_parent cStringUsingEncoding: encoding];
|
||||
}
|
||||
|
||||
- (NSUInteger) cStringLength
|
||||
{
|
||||
return [_parent cStringLength];
|
||||
}
|
||||
|
||||
- (NSData*) dataUsingEncoding: (NSStringEncoding)encoding
|
||||
allowLossyConversion: (BOOL)flag
|
||||
{
|
||||
return [_parent dataUsingEncoding: encoding allowLossyConversion: flag];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_parent);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
return [_parent copyWithZone: z];
|
||||
}
|
||||
|
||||
- (id) mutableCopyWithZone: (NSZone*)z
|
||||
{
|
||||
return [_parent mutableCopyWithZone: z];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder*)aCoder
|
||||
{
|
||||
[_parent encodeWithCoder: aCoder];
|
||||
}
|
||||
|
||||
- (NSStringEncoding) fastestEncoding
|
||||
{
|
||||
return [_parent fastestEncoding];
|
||||
}
|
||||
|
||||
- (void) getCharacters: (unichar*)buffer
|
||||
{
|
||||
[_parent getCharacters: buffer];
|
||||
}
|
||||
|
||||
- (void) getCharacters: (unichar*)buffer range: (NSRange)aRange
|
||||
{
|
||||
[_parent getCharacters: buffer range: aRange];
|
||||
}
|
||||
|
||||
- (void) getCString: (char*)buffer
|
||||
{
|
||||
[_parent getCString: buffer];
|
||||
}
|
||||
|
||||
- (void) getCString: (char*)buffer
|
||||
maxLength: (NSUInteger)maxLength
|
||||
{
|
||||
[_parent getCString: buffer maxLength: maxLength];
|
||||
}
|
||||
|
||||
- (BOOL) getCString: (char*)buffer
|
||||
maxLength: (NSUInteger)maxLength
|
||||
encoding: (NSStringEncoding)encoding
|
||||
{
|
||||
return [_parent getCString: buffer maxLength: maxLength encoding: encoding];
|
||||
}
|
||||
|
||||
- (void) getCString: (char*)buffer
|
||||
maxLength: (NSUInteger)maxLength
|
||||
range: (NSRange)aRange
|
||||
remainingRange: (NSRange*)leftoverRange
|
||||
{
|
||||
[_parent getCString: buffer
|
||||
maxLength: maxLength
|
||||
range: aRange
|
||||
remainingRange: leftoverRange];
|
||||
}
|
||||
|
||||
- (NSUInteger) hash
|
||||
{
|
||||
return [_parent hash];
|
||||
}
|
||||
|
||||
- (id) initWithString: (NSString*)parent
|
||||
{
|
||||
_parent = RETAIN(parent);
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL) isEqual: (id)anObject
|
||||
{
|
||||
return [_parent isEqual: anObject];
|
||||
}
|
||||
|
||||
- (BOOL) isEqualToString: (NSString*)anObject
|
||||
{
|
||||
return [_parent isEqualToString: anObject];
|
||||
}
|
||||
|
||||
- (NSUInteger) length
|
||||
{
|
||||
return [_parent length];
|
||||
}
|
||||
|
||||
- (NSUInteger) lengthOfBytesUsingEncoding: (NSStringEncoding)encoding
|
||||
{
|
||||
return [_parent lengthOfBytesUsingEncoding: encoding];
|
||||
}
|
||||
|
||||
- (const char*) lossyCString
|
||||
{
|
||||
return [_parent lossyCString];
|
||||
}
|
||||
|
||||
- (NSUInteger) maximumLengthOfBytesUsingEncoding: (NSStringEncoding)encoding
|
||||
{
|
||||
return [_parent maximumLengthOfBytesUsingEncoding: encoding];
|
||||
}
|
||||
|
||||
- (NSRange) rangeOfComposedCharacterSequenceAtIndex: (NSUInteger)anIndex
|
||||
{
|
||||
return [_parent rangeOfComposedCharacterSequenceAtIndex: anIndex];
|
||||
}
|
||||
|
||||
- (NSRange) rangeOfCharacterFromSet: (NSCharacterSet*)aSet
|
||||
options: (NSUInteger)mask
|
||||
range: (NSRange)aRange
|
||||
{
|
||||
return [_parent rangeOfCharacterFromSet: aSet options: mask range: aRange];
|
||||
}
|
||||
|
||||
- (NSRange) rangeOfString: (NSString*)aString
|
||||
options: (NSUInteger)mask
|
||||
range: (NSRange)aRange
|
||||
{
|
||||
return [_parent rangeOfString: aString options: mask range: aRange];
|
||||
}
|
||||
|
||||
- (NSStringEncoding) smallestEncoding
|
||||
{
|
||||
return [_parent smallestEncoding];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
* GNUstep specific (non-standard) additions to the NSMutableString class.
|
||||
*/
|
||||
@implementation NSMutableString (GNUstepBase)
|
||||
|
||||
/**
|
||||
* 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
|
||||
* receiver as an NSString, but which will not allow any of the
|
||||
* extra NSMutableString methods to be used. You can use this method
|
||||
* to provide other code with read-only access to a mutable string
|
||||
* you own.
|
||||
*/
|
||||
- (NSString*) immutableProxy
|
||||
{
|
||||
return AUTORELEASE([[GSImmutableString alloc] initWithString: self]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces all occurrences of the string replace with the string by
|
||||
* in the receiver.<br />
|
||||
* Has no effect if replace does not occur within the
|
||||
* receiver. NB. an empty string is not considered to exist within
|
||||
* the receiver.<br />
|
||||
* Calls - replaceOccurrencesOfString:withString:options:range: passing
|
||||
* zero for the options and a range from 0 with the length of the receiver.
|
||||
*
|
||||
* Note that is has to work for
|
||||
* [tmp replaceString: @"&" withString: @"&amp;"];
|
||||
*/
|
||||
- (void) replaceString: (NSString*)replace
|
||||
withString: (NSString*)by
|
||||
{
|
||||
NSRange range;
|
||||
unsigned int count = 0;
|
||||
unsigned int newEnd;
|
||||
NSRange searchRange;
|
||||
|
||||
if (replace == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ nil search string", NSStringFromSelector(_cmd)];
|
||||
}
|
||||
if (by == nil)
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"%@ nil replace string", NSStringFromSelector(_cmd)];
|
||||
}
|
||||
|
||||
searchRange = NSMakeRange(0, [self length]);
|
||||
range = [self rangeOfString: replace options: 0 range: searchRange];
|
||||
|
||||
if (range.length > 0)
|
||||
{
|
||||
unsigned byLen = [by length];
|
||||
|
||||
do
|
||||
{
|
||||
count++;
|
||||
[self replaceCharactersInRange: range
|
||||
withString: by];
|
||||
|
||||
newEnd = NSMaxRange(searchRange) + byLen - range.length;
|
||||
searchRange.location = range.location + byLen;
|
||||
searchRange.length = newEnd - searchRange.location;
|
||||
|
||||
range = [self rangeOfString: replace
|
||||
options: 0
|
||||
range: searchRange];
|
||||
}
|
||||
while (range.length > 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all leading white space from the receiver.
|
||||
*/
|
||||
- (void) trimLeadSpaces
|
||||
{
|
||||
unsigned length = [self length];
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned start = 0;
|
||||
unichar (*caiImp)(NSString*, SEL, NSUInteger);
|
||||
SEL caiSel = @selector(characterAtIndex:);
|
||||
|
||||
caiImp = (unichar (*)())[self methodForSelector: caiSel];
|
||||
while (start < length && space((*caiImp)(self, caiSel, start)))
|
||||
{
|
||||
start++;
|
||||
}
|
||||
if (start > 0)
|
||||
{
|
||||
[self deleteCharactersInRange: NSMakeRange(0, start)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all trailing white space from the receiver.
|
||||
*/
|
||||
- (void) trimTailSpaces
|
||||
{
|
||||
unsigned length = [self length];
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned end = length;
|
||||
unichar (*caiImp)(NSString*, SEL, NSUInteger);
|
||||
SEL caiSel = @selector(characterAtIndex:);
|
||||
|
||||
caiImp = (unichar (*)())[self methodForSelector: caiSel];
|
||||
while (end > 0 && space((*caiImp)(self, caiSel, end - 1)))
|
||||
{
|
||||
end--;
|
||||
}
|
||||
if (end < length)
|
||||
{
|
||||
[self deleteCharactersInRange: NSMakeRange(end, length - end)];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all leading or trailing white space from the receiver.
|
||||
*/
|
||||
- (void) trimSpaces
|
||||
{
|
||||
[self trimTailSpaces];
|
||||
[self trimLeadSpaces];
|
||||
}
|
||||
|
||||
@end
|
||||
|
49
Source/Additions/NSNumber+GNUstepBase.m
Normal file
49
Source/Additions/NSNumber+GNUstepBase.m
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "GNUstepBase/NSNumber+GNUstepBase.h"
|
||||
|
||||
/**
|
||||
* GNUstep specific (non-standard) additions to the NSNumber class.
|
||||
*/
|
||||
@implementation NSNumber(GNUstepBase)
|
||||
|
||||
+ (NSValue*) valueFromString: (NSString*)string
|
||||
{
|
||||
/* FIXME: implement this better */
|
||||
const char *str;
|
||||
|
||||
str = [string cString];
|
||||
if (strchr(str, '.') >= 0 || strchr(str, 'e') >= 0
|
||||
|| strchr(str, 'E') >= 0)
|
||||
return [NSNumber numberWithDouble: atof(str)];
|
||||
else if (strchr(str, '-') >= 0)
|
||||
return [NSNumber numberWithInt: atoi(str)];
|
||||
else
|
||||
return [NSNumber numberWithUnsignedInt: atoi(str)];
|
||||
return [NSNumber numberWithInt: 0];
|
||||
}
|
||||
|
||||
@end
|
121
Source/Additions/NSObject+GNUstepBase.m
Normal file
121
Source/Additions/NSObject+GNUstepBase.m
Normal file
|
@ -0,0 +1,121 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
/**
|
||||
* Extension methods for the NSObject class
|
||||
*/
|
||||
@implementation NSObject (GNUstepBase)
|
||||
|
||||
+ (id) notImplemented: (SEL)selector
|
||||
{
|
||||
[NSException raise: NSGenericException
|
||||
format: @"method %@ not implemented in %s(class)",
|
||||
selector ? (id)NSStringFromSelector(selector) : (id)@"(null)",
|
||||
NSStringFromClass(self)];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (BOOL) isInstance
|
||||
{
|
||||
return GSObjCIsInstance(self);
|
||||
}
|
||||
|
||||
- (id) notImplemented: (SEL)aSel
|
||||
{
|
||||
[NSException
|
||||
raise: NSGenericException
|
||||
format: @"method %@ not implemented in %@(%s)",
|
||||
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)",
|
||||
NSStringFromClass([self class]),
|
||||
GSObjCIsInstance(self) ? "instance" : "class"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) shouldNotImplement: (SEL)aSel
|
||||
{
|
||||
[NSException
|
||||
raise: NSGenericException
|
||||
format: @"%@(%s) should not implement %@",
|
||||
NSStringFromClass([self class]),
|
||||
GSObjCIsInstance(self) ? "instance" : "class",
|
||||
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (id) subclassResponsibility: (SEL)aSel
|
||||
{
|
||||
[NSException raise: NSInvalidArgumentException
|
||||
format: @"subclass %@(%s) should override %@",
|
||||
NSStringFromClass([self class]),
|
||||
GSObjCIsInstance(self) ? "instance" : "class",
|
||||
aSel ? (id)NSStringFromSelector(aSel) : (id)@"(null)"];
|
||||
return nil;
|
||||
}
|
||||
|
||||
/**
|
||||
* WARNING: The -compare: method for NSObject is deprecated
|
||||
* due to subclasses declaring the same selector with
|
||||
* conflicting signatures.
|
||||
* Comparison of arbitrary objects is not just meaningless
|
||||
* but also dangerous as most concrete implementations
|
||||
* expect comparable objects as arguments often accessing
|
||||
* instance variables directly.
|
||||
* This method will be removed in a future release.
|
||||
*/
|
||||
- (NSComparisonResult) compare: (id)anObject
|
||||
{
|
||||
NSLog(@"WARNING: The -compare: method for NSObject is deprecated.");
|
||||
|
||||
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 ((id)self > anObject)
|
||||
{
|
||||
return NSOrderedDescending;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NSOrderedAscending;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
116
Source/Additions/NSProcessInfo+GNUstepBase.m
Normal file
116
Source/Additions/NSProcessInfo+GNUstepBase.m
Normal file
|
@ -0,0 +1,116 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
|
||||
|
||||
#import "config.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "GNUstepBase/NSProcessInfo+GNUstepBase.h"
|
||||
|
||||
@implementation NSProcessInfo(GNUstepBase)
|
||||
|
||||
static NSMutableSet *_debug_set = nil;
|
||||
static BOOL debugTemporarilyDisabled = NO;
|
||||
|
||||
|
||||
BOOL GSDebugSet(NSString *level)
|
||||
{
|
||||
static IMP debugImp = 0;
|
||||
static SEL debugSel;
|
||||
|
||||
if (debugTemporarilyDisabled == YES)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
if (debugImp == 0)
|
||||
{
|
||||
debugSel = @selector(member:);
|
||||
if (_debug_set == nil)
|
||||
{
|
||||
[[NSProcessInfo processInfo] debugSet];
|
||||
}
|
||||
debugImp = [_debug_set methodForSelector: debugSel];
|
||||
if (debugImp == 0)
|
||||
{
|
||||
fprintf(stderr, "Unable to set up with [NSProcessInfo-debugSet]\n");
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
if ((*debugImp)(_debug_set, debugSel, level) == nil)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL) debugLoggingEnabled
|
||||
{
|
||||
if (debugTemporarilyDisabled == YES)
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
else
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSMutableSet *) debugSet
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
- (void) setDebugLoggingEnabled: (BOOL)flag
|
||||
{
|
||||
if (flag == NO)
|
||||
{
|
||||
debugTemporarilyDisabled = YES;
|
||||
}
|
||||
else
|
||||
{
|
||||
debugTemporarilyDisabled = NO;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
229
Source/Additions/NSString+GNUstepBase.m
Normal file
229
Source/Additions/NSString+GNUstepBase.m
Normal file
|
@ -0,0 +1,229 @@
|
|||
/* Implementation of extension methods for base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#include <string.h>
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
|
||||
|
||||
/* Test for ASCII whitespace which is safe for unicode characters */
|
||||
#define space(C) ((C) > 127 ? NO : isspace(C))
|
||||
|
||||
/**
|
||||
* GNUstep specific (non-standard) additions to the NSString class.
|
||||
*/
|
||||
@implementation NSString (GNUstepBase)
|
||||
|
||||
/**
|
||||
* Returns an autoreleased string initialized with -initWithFormat:arguments:.
|
||||
*/
|
||||
+ (id) stringWithFormat: (NSString*)format
|
||||
arguments: (va_list)argList
|
||||
{
|
||||
return AUTORELEASE([[self allocWithZone: NSDefaultMallocZone()]
|
||||
initWithFormat: format arguments: argList]);
|
||||
}
|
||||
|
||||
#ifndef MAC_OS_X_VERSION_10_5
|
||||
/**
|
||||
* Returns YES when scanning the receiver's text from left to right finds a
|
||||
* digit in the range 1-9 or a letter in the set ('Y', 'y', 'T', 't').<br />
|
||||
* Any trailing characters are ignored.<br />
|
||||
* Any leading whitespace or zeros or signs are also ignored.<br />
|
||||
* Returns NO if the above conditions are not met.
|
||||
*/
|
||||
- (BOOL) boolValue
|
||||
{
|
||||
static NSCharacterSet *yes = nil;
|
||||
|
||||
if (yes == nil)
|
||||
{
|
||||
yes = RETAIN([NSCharacterSet characterSetWithCharactersInString:
|
||||
@"123456789yYtT"]);
|
||||
}
|
||||
if ([self rangeOfCharacterFromSet: yes].length > 0)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
- (NSString*) stringByTrimmingLeadSpaces
|
||||
{
|
||||
unsigned length = [self length];
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned start = 0;
|
||||
unichar (*caiImp)(NSString*, SEL, NSUInteger);
|
||||
SEL caiSel = @selector(characterAtIndex:);
|
||||
|
||||
caiImp = (unichar (*)())[self methodForSelector: caiSel];
|
||||
while (start < length && space((*caiImp)(self, caiSel, start)))
|
||||
{
|
||||
start++;
|
||||
}
|
||||
if (start > 0)
|
||||
{
|
||||
return [self substringFromIndex: start];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string formed by removing trailing white space from the
|
||||
* receiver.
|
||||
*/
|
||||
- (NSString*) stringByTrimmingTailSpaces
|
||||
{
|
||||
unsigned length = [self length];
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned end = length;
|
||||
unichar (*caiImp)(NSString*, SEL, NSUInteger);
|
||||
SEL caiSel = @selector(characterAtIndex:);
|
||||
|
||||
caiImp = (unichar (*)())[self methodForSelector: caiSel];
|
||||
while (end > 0)
|
||||
{
|
||||
if (!space((*caiImp)(self, caiSel, end - 1)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
end--;
|
||||
}
|
||||
if (end < length)
|
||||
{
|
||||
return [self substringToIndex: end];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string formed by removing both leading and trailing
|
||||
* white space from the receiver.
|
||||
*/
|
||||
- (NSString*) stringByTrimmingSpaces
|
||||
{
|
||||
unsigned length = [self length];
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
unsigned start = 0;
|
||||
unsigned end = length;
|
||||
unichar (*caiImp)(NSString*, SEL, NSUInteger);
|
||||
SEL caiSel = @selector(characterAtIndex:);
|
||||
|
||||
caiImp = (unichar (*)())[self methodForSelector: caiSel];
|
||||
while (start < length && space((*caiImp)(self, caiSel, start)))
|
||||
{
|
||||
start++;
|
||||
}
|
||||
while (end > start)
|
||||
{
|
||||
if (!space((*caiImp)(self, caiSel, end - 1)))
|
||||
{
|
||||
break;
|
||||
}
|
||||
end--;
|
||||
}
|
||||
if (start > 0 || end < length)
|
||||
{
|
||||
if (start < end)
|
||||
{
|
||||
return [self substringFromRange:
|
||||
NSMakeRange(start, end - start)];
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString string];
|
||||
}
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
NSRange range = [self rangeOfString: replace];
|
||||
|
||||
if (range.length > 0)
|
||||
{
|
||||
NSMutableString *tmp = [self mutableCopy];
|
||||
NSString *str;
|
||||
|
||||
[tmp replaceString: replace withString: by];
|
||||
str = AUTORELEASE([tmp copy]);
|
||||
RELEASE(tmp);
|
||||
return str;
|
||||
}
|
||||
else
|
||||
return self;
|
||||
}
|
||||
|
||||
- (NSString*) substringFromRange:(NSRange)range
|
||||
{
|
||||
return [self substringWithRange:range];
|
||||
}
|
||||
|
||||
@end
|
122
Source/Additions/NSTask+GNUstepBase.m
Normal file
122
Source/Additions/NSTask+GNUstepBase.m
Normal file
|
@ -0,0 +1,122 @@
|
|||
/* Implementation of extension methods for base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
#import "config.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#import "Foundation/NSProcessInfo.h"
|
||||
#import "GNUstepBase/NSTask+GNUstepBase.h"
|
||||
|
||||
@implementation NSTask (GSCategories)
|
||||
|
||||
static NSString*
|
||||
executablePath(NSFileManager *mgr, NSString *path)
|
||||
{
|
||||
#if defined(__MINGW32__)
|
||||
NSString *tmp;
|
||||
|
||||
if ([mgr isExecutableFileAtPath: path])
|
||||
{
|
||||
return path;
|
||||
}
|
||||
tmp = [path stringByAppendingPathExtension: @"exe"];
|
||||
if ([mgr isExecutableFileAtPath: tmp])
|
||||
{
|
||||
return tmp;
|
||||
}
|
||||
tmp = [path stringByAppendingPathExtension: @"com"];
|
||||
if ([mgr isExecutableFileAtPath: tmp])
|
||||
{
|
||||
return tmp;
|
||||
}
|
||||
tmp = [path stringByAppendingPathExtension: @"cmd"];
|
||||
if ([mgr isExecutableFileAtPath: tmp])
|
||||
{
|
||||
return tmp;
|
||||
}
|
||||
#else
|
||||
if ([mgr isExecutableFileAtPath: path])
|
||||
{
|
||||
return path;
|
||||
}
|
||||
#endif
|
||||
return nil;
|
||||
}
|
||||
|
||||
+ (NSString*) launchPathForTool: (NSString*)name
|
||||
{
|
||||
NSEnumerator *enumerator;
|
||||
NSDictionary *env;
|
||||
NSString *pathlist;
|
||||
NSString *path;
|
||||
NSFileManager *mgr;
|
||||
|
||||
mgr = [NSFileManager defaultManager];
|
||||
|
||||
#if defined(GNUSTEP)
|
||||
enumerator = [NSSearchPathForDirectoriesInDomains(
|
||||
GSToolsDirectory, NSAllDomainsMask, YES) objectEnumerator];
|
||||
while ((path = [enumerator nextObject]) != nil)
|
||||
{
|
||||
path = [path stringByAppendingPathComponent: name];
|
||||
if ((path = executablePath(mgr, path)) != nil)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
enumerator = [NSSearchPathForDirectoriesInDomains(
|
||||
GSAdminToolsDirectory, NSAllDomainsMask, YES) objectEnumerator];
|
||||
while ((path = [enumerator nextObject]) != nil)
|
||||
{
|
||||
path = [path stringByAppendingPathComponent: name];
|
||||
if ((path = executablePath(mgr, path)) != nil)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
env = [[NSProcessInfo processInfo] environment];
|
||||
pathlist = [env objectForKey:@"PATH"];
|
||||
#if defined(__MINGW32__)
|
||||
/* Windows 2000 and perhaps others have "Path" not "PATH" */
|
||||
if (pathlist == nil)
|
||||
{
|
||||
pathlist = [env objectForKey: @"Path"];
|
||||
}
|
||||
enumerator = [[pathlist componentsSeparatedByString: @";"] objectEnumerator];
|
||||
#else
|
||||
enumerator = [[pathlist componentsSeparatedByString: @":"] objectEnumerator];
|
||||
#endif
|
||||
while ((path = [enumerator nextObject]) != nil)
|
||||
{
|
||||
path = [path stringByAppendingPathComponent: name];
|
||||
if ((path = executablePath(mgr, path)) != nil)
|
||||
{
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
@end
|
56
Source/Additions/NSURL+GNUstepBase.m
Normal file
56
Source/Additions/NSURL+GNUstepBase.m
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* Implementation of extension methods to base additions
|
||||
|
||||
Copyright (C) 2010 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
This file is part of the GNUstep Base Library.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef GNUSTEP
|
||||
|
||||
#import "config.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "GNUstepBase/NSURL+GNUstepBase.h"
|
||||
|
||||
@implementation NSURL (GNUstepBase)
|
||||
- (NSString*) fullPath
|
||||
{
|
||||
NSRange r;
|
||||
NSString *s;
|
||||
|
||||
s = [self absoluteString];
|
||||
if ((r = [s rangeOfString: @";"]).length > 0)
|
||||
{
|
||||
s = [s substringToIndex: r.location];
|
||||
}
|
||||
else if ((r = [s rangeOfString: @"?"]).length > 0)
|
||||
{
|
||||
s = [s substringToIndex: r.location];
|
||||
}
|
||||
r = [s rangeOfString: @"//"];
|
||||
s = [s substringFromIndex: NSMaxRange(r)];
|
||||
r = [s rangeOfString: @"/"];
|
||||
s = [s substringFromIndex: r.location];
|
||||
return s;
|
||||
}
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
|
@ -28,26 +28,27 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSBundle.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSError.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSLock.h>
|
||||
#include <Foundation/NSPathUtilities.h>
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSBundle.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSError.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "GNUstepBase/GSMime.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#include "GNUstepBase/Unicode.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "GNUstepBase/GSMime.h"
|
||||
#import "GNUstepBase/NSLock+GNUstepBase.h"
|
||||
#import "GNUstepBase/Unicode.h"
|
||||
|
||||
#import "../GSPrivate.h"
|
||||
|
||||
#include "../GSPrivate.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA.
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
/* A Behavior can be seen as a "Protocol with an implementation" or a
|
||||
|
@ -48,15 +49,15 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#include <stdio.h>
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/behavior.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/behavior.h"
|
||||
#ifndef NeXT_Foundation_LIBRARY
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#else
|
||||
#include <Foundation/Foundation.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#endif
|
||||
|
||||
static BOOL class_is_kind_of(Class self, Class class);
|
||||
|
|
|
@ -136,15 +136,35 @@ NSZone.h
|
|||
BaseAdditions_AGSDOC_FILES = \
|
||||
../Documentation/BaseAdditions.gsdoc \
|
||||
GNUstep.h \
|
||||
GSBlocks.h \
|
||||
GSVersionMacros.h \
|
||||
GSObjCRuntime.h \
|
||||
GSCategories.h \
|
||||
GSFileHandle.h \
|
||||
GSUnion.h \
|
||||
GSIArray.h \
|
||||
GSIMap.h \
|
||||
GCObject.h \
|
||||
GSLock.h \
|
||||
GSFunctions.h \
|
||||
GSMime.h \
|
||||
GSObjCRuntime.h \
|
||||
GSUnion.h \
|
||||
GSVersionMacros.h \
|
||||
GSXML.h \
|
||||
GSLocale.h \
|
||||
NSArray+GNUstepBase.h \
|
||||
NSAttributedString+GNUstepBase.h \
|
||||
NSBundle+GNUstepBase.h \
|
||||
NSCalendarDate+GNUstepBase.h \
|
||||
NSData+GNUstepBase.h \
|
||||
NSFileHandle+GNUstepBase.h \
|
||||
NSInvocation+GNUstepBase.h \
|
||||
NSLock+GNUstepBase.h \
|
||||
NSMutableString+GNUstepBase.h \
|
||||
NSNumber+GNUstepBase.h \
|
||||
NSObject+GNUstepBase.h \
|
||||
NSProcessInfo+GNUstepBase.h \
|
||||
NSString+GNUstepBase.h \
|
||||
NSTask+GNUstepBase.h \
|
||||
NSURL+GNUstepBase.h \
|
||||
behavior.h \
|
||||
Unicode.h \
|
||||
GCObject.h \
|
||||
|
|
|
@ -126,11 +126,26 @@ GSFunctions.h \
|
|||
GSMime.h \
|
||||
GSXML.h \
|
||||
GSLocale.h \
|
||||
NSTask+GS.h \
|
||||
NSArray+GNUstepBase.h \
|
||||
NSAttributedString+GNUstepBase.h \
|
||||
NSBundle+GNUstepBase.h \
|
||||
NSCalendarDate+GNUstepBase.h \
|
||||
NSData+GNUstepBase.h \
|
||||
NSFileHandle+GNUstepBase.h \
|
||||
NSInvocation+GNUstepBase.h \
|
||||
NSLock+GNUstepBase.h \
|
||||
NSMutableString+GNUstepBase.h \
|
||||
NSNumber+GNUstepBase.h \
|
||||
NSObject+GNUstepBase.h \
|
||||
NSProcessInfo+GNUstepBase.h \
|
||||
NSString+GNUstepBase.h \
|
||||
NSTask+GNUstepBase.h \
|
||||
NSURL+GNUstepBase.h \
|
||||
Unicode.h \
|
||||
GNUstep.h \
|
||||
behavior.h \
|
||||
preface.h \
|
||||
Additions.h
|
||||
|
||||
GNU_HEADERS = $(ADD_HEADERS)
|
||||
|
||||
|
@ -471,7 +486,7 @@ libgnustep-baseadd_NEEDS_GUI = NO
|
|||
# can be guaranteed that they'll never be built together, this could
|
||||
# be removed.
|
||||
SUBPROJECTS = Additions
|
||||
|
||||
|
||||
-include Makefile.preamble
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/aggregate.make
|
||||
|
|
|
@ -412,7 +412,9 @@ static Class GSInlineArrayClass;
|
|||
}
|
||||
- (id) initWithObjects: (id*)objects count: (unsigned)count
|
||||
{
|
||||
_contents_array = (id*)&self[1];
|
||||
_contents_array
|
||||
= (id*)(((void*)self) + class_getInstanceSize([self class]));
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
unsigned i;
|
||||
|
@ -1148,7 +1150,8 @@ static Class GSInlineArrayClass;
|
|||
[aCoder decodeValueOfObjCType: @encode(unsigned) at: &c];
|
||||
a = (id)NSAllocateObject(GSInlineArrayClass,
|
||||
sizeof(id)*c, GSObjCZone(self));
|
||||
a->_contents_array = (id*)&a[1];
|
||||
a->_contents_array
|
||||
= (id*)(((void*)a) + class_getInstanceSize([a class]));
|
||||
#endif
|
||||
if (c > 0)
|
||||
{
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#import "config.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "GNUstepBase/NSMutableString+GNUstepBase.h"
|
||||
#import "Foundation/NSAttributedString.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSRange.h"
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
// FIXME: We should be using the new interfaces, not exposing the old ones.
|
||||
# define __OBJC_LEGACY_GNU_MODE__
|
||||
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSDistantObject.h"
|
||||
|
@ -30,8 +34,6 @@
|
|||
#import <config.h>
|
||||
#import <objc/objc-api.h>
|
||||
#if HAVE_OBJC_RUNTIME_H
|
||||
// FIXME: We should be using the new interfaces, not exposing the old ones.
|
||||
# define __OBJC_LEGACY_GNU_MODE__
|
||||
# import <objc/runtime.h>
|
||||
#endif
|
||||
#import <pthread.h>
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
#import "config.h"
|
||||
|
||||
#define EXPOSE_GSFileHandle_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSData.h"
|
||||
|
@ -43,6 +43,7 @@
|
|||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#import "../Tools/gdomap.h"
|
||||
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#import "Foundation/NSValue.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "GNUstepBase/GSMime.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSData+GNUstepBase.h"
|
||||
|
||||
|
||||
static NSMutableDictionary *domainMap = nil;
|
||||
|
|
|
@ -45,6 +45,8 @@
|
|||
#import "Foundation/NSValue.h"
|
||||
#import "GNUstepBase/GSMime.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
#import "GNUstepBase/NSURL+GNUstepBase.h"
|
||||
#import "NSCallBacks.h"
|
||||
#import "GSURLPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
|
|
|
@ -47,15 +47,17 @@
|
|||
* Instance variables are referenced using the 'internal->ivar' suntax or
|
||||
* the GSIV(classname,object,ivar) macro.
|
||||
*
|
||||
* If built with CLANG (assumed to support non-fragile instance variables)
|
||||
* ARGH FIXME ... the following idea doesn't work ... need to rethink/rwrite.
|
||||
*
|
||||
* If built with CLANG, with support for non-fragile instance variables,
|
||||
* rather than GCC, the compiler/runtime can simply declare instance variables
|
||||
* within the implementation file so that they are not part of the public ABI,
|
||||
* in which case the macros here mostly reduce to nothing and the generated
|
||||
* code can be much more efficient.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
#if 1 || !__has_feature(objc_nonfragile_abi)
|
||||
|
||||
/* Code for GCC.
|
||||
/* Code for when we don't have non-fragine instance variables
|
||||
*/
|
||||
|
||||
/* Start declaration of internal ivars.
|
||||
|
@ -88,20 +90,16 @@ DESTROY(_internal);
|
|||
#undef GSIVar
|
||||
#define GSIVar(X,Y) (((GSInternal*)(X->_internal))->Y)
|
||||
|
||||
#else /* defined(__GNUC__) */
|
||||
#else /* !__has_feature(objc_nonfragile_abi) */
|
||||
|
||||
/* Not GCC, so we assume this is CLANG with support for non-fragile ivars
|
||||
/* We have support for non-fragile ivars
|
||||
*/
|
||||
|
||||
#define GS_BEGIN_INTERNAL(name) \
|
||||
@interface name \
|
||||
{
|
||||
#define GS_BEGIN_INTERNAL(name) @interface name () {
|
||||
|
||||
/* Finish declaration of internal ivars.
|
||||
*/
|
||||
#define GS_END_INTERNAL(name) \
|
||||
} \
|
||||
@end
|
||||
#define GS_END_INTERNAL(name) } @end
|
||||
|
||||
/* Create holder for internal ivars (nothing to do).
|
||||
*/
|
||||
|
@ -116,6 +114,6 @@ DESTROY(_internal);
|
|||
#undef GSIVar
|
||||
#define GSIVar(X,Y) ((X)->Y)
|
||||
|
||||
#endif /* defined(__GNUC__) */
|
||||
#endif /* !__has_feature(objc_nonfragile_abi) */
|
||||
|
||||
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include <sys/un.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#ifndef AF_LOCAL
|
||||
#define AF_LOCAL AF_UNIX
|
||||
|
|
|
@ -161,6 +161,7 @@ typedef union {
|
|||
*/
|
||||
@interface GSString : NSString
|
||||
{
|
||||
@public
|
||||
GSCharPtr _contents;
|
||||
unsigned int _count;
|
||||
struct {
|
||||
|
@ -179,10 +180,8 @@ typedef union {
|
|||
*/
|
||||
@interface GSMutableString : NSMutableString
|
||||
{
|
||||
union {
|
||||
unichar *u;
|
||||
unsigned char *c;
|
||||
} _contents;
|
||||
@public
|
||||
GSCharPtr _contents;
|
||||
unsigned int _count;
|
||||
struct {
|
||||
unsigned int wide: 1;
|
||||
|
@ -195,14 +194,7 @@ typedef union {
|
|||
}
|
||||
@end
|
||||
|
||||
/*
|
||||
* Typedef for access to internals of concrete string objects.
|
||||
*/
|
||||
typedef struct {
|
||||
@defs(GSMutableString)
|
||||
} GSStr_t;
|
||||
typedef GSStr_t *GSStr;
|
||||
|
||||
typedef GSMutableString *GSStr;
|
||||
|
||||
/*
|
||||
* Enumeration for MacOS-X compatibility user defaults settings.
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GSRunLoopWatcher.h"
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSPort.h>
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSPort.h"
|
||||
|
||||
@implementation GSRunLoopWatcher
|
||||
|
||||
|
|
|
@ -24,21 +24,22 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSByteOrder.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSHost.h>
|
||||
#import <Foundation/NSLock.h>
|
||||
#import <Foundation/NSRunLoop.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSHost.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSRunLoop.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
|
||||
#import "GSPrivate.h"
|
||||
#import "GSStream.h"
|
||||
#import "GSSocketStream.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#ifndef SHUT_RD
|
||||
# ifdef SD_RECEIVE
|
||||
|
|
|
@ -24,20 +24,21 @@
|
|||
|
||||
#include "config.h"
|
||||
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSByteOrder.h>
|
||||
#import <Foundation/NSData.h>
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSEnumerator.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSHost.h>
|
||||
#import <Foundation/NSRunLoop.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSHost.h"
|
||||
#import "Foundation/NSRunLoop.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
|
||||
#import "GSStream.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GSSocketStream.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
NSString * const NSStreamDataWrittenToMemoryStreamKey
|
||||
= @"NSStreamDataWrittenToMemoryStreamKey";
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSKeyedArchiver.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
#include <limits.h>
|
||||
|
||||
#import "GSPrivate.h"
|
||||
|
@ -169,10 +170,6 @@ instance.
|
|||
}
|
||||
@end
|
||||
|
||||
typedef struct {
|
||||
@defs(GSCSubString)
|
||||
} GSSubstringStruct;
|
||||
|
||||
/*
|
||||
* Include sequence handling code with instructions to generate search
|
||||
* and compare functions for NSString objects.
|
||||
|
@ -658,7 +655,8 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
{
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass, length,
|
||||
GSObjCZone(self));
|
||||
me->_contents.c = (unsigned char*)&((GSCInlineString*)me)[1];
|
||||
me->_contents.c = (unsigned char*)
|
||||
(((void*)me)+class_getInstanceSize(GSCInlineStringClass));
|
||||
me->_count = length;
|
||||
me->_flags.wide = 0;
|
||||
me->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
|
@ -740,8 +738,8 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
locale: (NSDictionary*)locale
|
||||
arguments: (va_list)argList
|
||||
{
|
||||
GSStr f;
|
||||
unsigned char buf[2048];
|
||||
GSStr_t f;
|
||||
unichar fbuf[1024];
|
||||
unichar *fmt = fbuf;
|
||||
size_t len;
|
||||
|
@ -765,55 +763,58 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
* Now set up 'f' as a GSMutableString object whose initial buffer is
|
||||
* allocated on the stack. The GSPrivateFormat function can write into it.
|
||||
*/
|
||||
f.isa = GSMutableStringClass;
|
||||
f._zone = NSDefaultMallocZone();
|
||||
f._contents.c = buf;
|
||||
f._capacity = sizeof(buf);
|
||||
f._count = 0;
|
||||
f._flags.wide = 0;
|
||||
f._flags.owned = 0;
|
||||
GSPrivateFormat(&f, fmt, argList, locale);
|
||||
f = (GSStr)alloca(class_getInstanceSize(GSMutableStringClass));
|
||||
object_setClass(f, GSMutableStringClass);
|
||||
f->_zone = NSDefaultMallocZone();
|
||||
f->_contents.c = buf;
|
||||
f->_capacity = sizeof(buf);
|
||||
f->_count = 0;
|
||||
f->_flags.wide = 0;
|
||||
f->_flags.owned = 0;
|
||||
GSPrivateFormat(f, fmt, argList, locale);
|
||||
if (fmt != fbuf)
|
||||
{
|
||||
NSZoneFree(NSDefaultMallocZone(), fmt);
|
||||
}
|
||||
|
||||
/*
|
||||
* Don't use noCopy because f._contents.u may be memory on the stack,
|
||||
* and even if it wasn't f._capacity may be greater than f._count so
|
||||
* Don't use noCopy because f->_contents.u may be memory on the stack,
|
||||
* and even if it wasn't f->_capacity may be greater than f->_count so
|
||||
* we could be wasting quite a bit of space. Better to accept a
|
||||
* performance hit due to copying data (and allocating/deallocating
|
||||
* the temporary buffer) for large strings. For most strings, the
|
||||
* on-stack memory will have been used, so we will get better performance.
|
||||
*/
|
||||
if (f._flags.wide == 1)
|
||||
if (f->_flags.wide == 1)
|
||||
{
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
f._count*sizeof(unichar), GSObjCZone(self));
|
||||
me->_contents.u = (unichar*)&((GSUnicodeInlineString*)me)[1];
|
||||
me->_count = f._count;
|
||||
f->_count*sizeof(unichar), GSObjCZone(self));
|
||||
me->_contents.u = (unichar*)
|
||||
(((void*)me)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
me->_count = f->_count;
|
||||
me->_flags.wide = 1;
|
||||
me->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
memcpy(me->_contents.u, f._contents.u, f._count*sizeof(unichar));
|
||||
memcpy(me->_contents.u, f->_contents.u, f->_count*sizeof(unichar));
|
||||
}
|
||||
else
|
||||
{
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass, f._count,
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass, f->_count,
|
||||
GSObjCZone(self));
|
||||
me->_contents.c = (unsigned char*)&((GSCInlineString*)me)[1];
|
||||
me->_count = f._count;
|
||||
me->_contents.c = (unsigned char*)
|
||||
(((void*)me)+class_getInstanceSize(GSCInlineStringClass));
|
||||
me->_count = f->_count;
|
||||
me->_flags.wide = 0;
|
||||
me->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
memcpy(me->_contents.c, f._contents.c, f._count);
|
||||
memcpy(me->_contents.c, f->_contents.c, f->_count);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the string had to grow beyond the initial buffer size, we must
|
||||
* release any allocated memory.
|
||||
*/
|
||||
if (f._flags.owned == 1)
|
||||
if (f->_flags.owned == 1)
|
||||
{
|
||||
NSZoneFree(f._zone, f._contents.c);
|
||||
NSZoneFree(f->_zone, f->_contents.c);
|
||||
}
|
||||
return (id)me;
|
||||
}
|
||||
|
@ -847,7 +848,8 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
*/
|
||||
me = (GSStr)NSAllocateObject(GSCInlineStringClass,
|
||||
length, GSObjCZone(self));
|
||||
me->_contents.c = (unsigned char*)&((GSCInlineString*)me)[1];
|
||||
me->_contents.c = (unsigned char*)
|
||||
(((void*)me)+class_getInstanceSize(GSCInlineStringClass));
|
||||
me->_count = length;
|
||||
me->_flags.wide = 0;
|
||||
me->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
|
@ -862,7 +864,8 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
*/
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
length*sizeof(unichar), GSObjCZone(self));
|
||||
me->_contents.u = (unichar*)&((GSUnicodeInlineString*)me)[1];
|
||||
me->_contents.u = (unichar*)
|
||||
(((void*)me)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
me->_count = length;
|
||||
me->_flags.wide = 1;
|
||||
me->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
|
@ -877,7 +880,8 @@ fixBOM(unsigned char **bytes, NSUInteger*length, BOOL *owned,
|
|||
*/
|
||||
me = (GSStr)NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
length*sizeof(unichar), GSObjCZone(self));
|
||||
me->_contents.u = (unichar*)&((GSUnicodeInlineString*)me)[1];
|
||||
me->_contents.u = (unichar*)
|
||||
(((void*)me)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
me->_count = length;
|
||||
me->_flags.wide = 1;
|
||||
me->_flags.owned = 1; // Ignored on dealloc, but means we own buffer
|
||||
|
@ -1658,19 +1662,22 @@ getCString_c(GSStr self, char *buffer, unsigned int maxLength,
|
|||
*/
|
||||
if (externalEncoding != internalEncoding)
|
||||
{
|
||||
struct {
|
||||
@defs(GSMutableString)
|
||||
} o;
|
||||
|
||||
memset(&o, '\0', sizeof(o));
|
||||
o._count = self->_count;
|
||||
o._capacity = self->_count;
|
||||
o._contents.c = self->_contents.c;
|
||||
GSStrWiden((GSStr)&o);
|
||||
getCString_u((GSStr)&o, buffer, maxLength, aRange, leftoverRange);
|
||||
if (o._flags.owned == 1)
|
||||
GSMutableString *o
|
||||
= (GSMutableString*)alloca(class_getInstanceSize(GSMutableStringClass));
|
||||
object_setClass(o, GSMutableStringClass);
|
||||
o->_count = self->_count;
|
||||
o->_flags.wide = 0;
|
||||
o->_flags.owned = 0;
|
||||
o->_flags.unused = 0;
|
||||
o->_flags.hash = 0;
|
||||
o->_capacity = self->_count;
|
||||
o->_contents.c = self->_contents.c;
|
||||
o->_zone = 0;
|
||||
GSStrWiden(o);
|
||||
getCString_u(o, buffer, maxLength, aRange, leftoverRange);
|
||||
if (o->_flags.owned == 1)
|
||||
{
|
||||
NSZoneFree(o._zone, o._contents.u);
|
||||
NSZoneFree(o->_zone, o->_contents.u);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -2318,7 +2325,7 @@ static void GSStrMakeSpace(GSStr s, unsigned size)
|
|||
#if GS_WITH_GC
|
||||
s->_zone = GSAtomicMallocZone();
|
||||
#else
|
||||
if (s->isa == 0)
|
||||
if (object_getClass(s) == 0)
|
||||
{
|
||||
s->_zone = NSDefaultMallocZone();
|
||||
}
|
||||
|
@ -2386,7 +2393,7 @@ static void GSStrWiden(GSStr s)
|
|||
#if GS_WITH_GC
|
||||
s->_zone = GSAtomicMallocZone();
|
||||
#else
|
||||
if (s->isa == 0)
|
||||
if (object_getClass(s) == 0)
|
||||
{
|
||||
s->_zone = NSDefaultMallocZone();
|
||||
}
|
||||
|
@ -2654,7 +2661,7 @@ rangeOfString_u(GSStr self, NSString *aString, unsigned mask, NSRange aRange)
|
|||
static inline NSString*
|
||||
substring_c(GSStr self, NSRange aRange)
|
||||
{
|
||||
GSSubstringStruct *o;
|
||||
GSCSubString *o;
|
||||
|
||||
if (aRange.length == 0)
|
||||
{
|
||||
|
@ -2673,7 +2680,7 @@ substring_c(GSStr self, NSRange aRange)
|
|||
static inline NSString*
|
||||
substring_u(GSStr self, NSRange aRange)
|
||||
{
|
||||
GSSubstringStruct *o;
|
||||
GSCSubString *o;
|
||||
|
||||
if (aRange.length == 0)
|
||||
{
|
||||
|
@ -3201,12 +3208,11 @@ agree, create a new GSCInlineString otherwise.
|
|||
{
|
||||
if (!_flags.owned || NSShouldRetainWithZone(self, z) == NO)
|
||||
{
|
||||
struct {
|
||||
@defs(GSCInlineString)
|
||||
} *o;
|
||||
GSCInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||
o->_contents.c = (unsigned char*)&o[1];
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
|
@ -3252,12 +3258,11 @@ agree, create a new GSCInlineString otherwise.
|
|||
*/
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
struct {
|
||||
@defs(GSCInlineString)
|
||||
} *o;
|
||||
GSCInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||
o->_contents.c = (unsigned char*)&o[1];
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
|
@ -3525,13 +3530,12 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
{
|
||||
if (!_flags.owned || NSShouldRetainWithZone(self, z) == NO)
|
||||
{
|
||||
struct {
|
||||
@defs(GSUnicodeInlineString)
|
||||
} *o;
|
||||
GSUnicodeInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), z);
|
||||
o->_contents.u = (unichar*)&o[1];
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.u, _contents.u, _count * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
|
@ -3577,13 +3581,12 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
*/
|
||||
- (id) copyWithZone: (NSZone*)z
|
||||
{
|
||||
struct {
|
||||
@defs(GSUnicodeInlineString)
|
||||
} *o;
|
||||
GSUnicodeInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), z);
|
||||
o->_contents.u = (unichar*)&o[1];
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.u, _contents.u, _count * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
|
@ -3707,13 +3710,12 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
{
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
struct {
|
||||
@defs(GSUnicodeInlineString)
|
||||
} *o;
|
||||
GSUnicodeInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
_count * sizeof(unichar), z);
|
||||
o->_contents.u = (unichar*)&o[1];
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.u, _contents.u, _count * sizeof(unichar));
|
||||
o->_flags.wide = 1;
|
||||
|
@ -3722,12 +3724,11 @@ agree, create a new GSUnicodeInlineString otherwise.
|
|||
}
|
||||
else
|
||||
{
|
||||
struct {
|
||||
@defs(GSCInlineString)
|
||||
} *o;
|
||||
GSCInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass, _count, z);
|
||||
o->_contents.c = (unsigned char*)&o[1];
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
o->_count = _count;
|
||||
memcpy(o->_contents.c, _contents.c, _count);
|
||||
o->_flags.wide = 0;
|
||||
|
@ -4488,13 +4489,12 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
}
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
struct {
|
||||
@defs(GSUnicodeInlineString)
|
||||
} *o;
|
||||
GSUnicodeInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
aRange.length * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)&o[1];
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
o->_count = aRange.length;
|
||||
memcpy(o->_contents.u, _contents.u + aRange.location,
|
||||
aRange.length * sizeof(unichar));
|
||||
|
@ -4504,13 +4504,12 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
}
|
||||
else
|
||||
{
|
||||
struct {
|
||||
@defs(GSCInlineString)
|
||||
} *o;
|
||||
GSCInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
aRange.length, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)&o[1];
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
o->_count = aRange.length;
|
||||
memcpy(o->_contents.c, _contents.c + aRange.location, aRange.length);
|
||||
o->_flags.wide = 0;
|
||||
|
@ -4529,13 +4528,12 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
}
|
||||
if (_flags.wide == 1)
|
||||
{
|
||||
struct {
|
||||
@defs(GSUnicodeInlineString)
|
||||
} *o;
|
||||
GSUnicodeInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSUnicodeInlineStringClass,
|
||||
aRange.length * sizeof(unichar), NSDefaultMallocZone());
|
||||
o->_contents.u = (unichar*)&o[1];
|
||||
o->_contents.u = (unichar*)
|
||||
(((void*)o)+class_getInstanceSize(GSUnicodeInlineStringClass));
|
||||
o->_count = aRange.length;
|
||||
memcpy(o->_contents.u, _contents.u + aRange.location,
|
||||
aRange.length * sizeof(unichar));
|
||||
|
@ -4545,13 +4543,12 @@ NSAssert(_flags.owned == 1 && _zone != 0, NSInternalInconsistencyException);
|
|||
}
|
||||
else
|
||||
{
|
||||
struct {
|
||||
@defs(GSCInlineString)
|
||||
} *o;
|
||||
GSCInlineString *o;
|
||||
|
||||
o = (typeof(o))NSAllocateObject(GSCInlineStringClass,
|
||||
aRange.length, NSDefaultMallocZone());
|
||||
o->_contents.c = (unsigned char*)&o[1];
|
||||
o->_contents.c = (unsigned char*)
|
||||
(((void*)o)+class_getInstanceSize(GSCInlineStringClass));
|
||||
o->_count = aRange.length;
|
||||
memcpy(o->_contents.c, _contents.c + aRange.location, aRange.length);
|
||||
o->_flags.wide = 0;
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
#import "config.h"
|
||||
#include <math.h>
|
||||
|
||||
#define EXPOSE_NSAffineTransform_IVARS 1
|
||||
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSString.h"
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
*/
|
||||
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSArchiver_IVARS 1
|
||||
#define EXPOSE_NSUnarchiver_IVARS 1
|
||||
/*
|
||||
* Setup for inline operation of pointer map tables.
|
||||
*/
|
||||
|
|
|
@ -52,7 +52,7 @@
|
|||
#import "Foundation/NSIndexSet.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#import "Foundation/NSKeyedArchiver.h"
|
||||
#import "GNUstepBase/GSCategories.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GSFastEnumeration.h"
|
||||
|
||||
|
|
|
@ -48,14 +48,15 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/Unicode.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/Unicode.h"
|
||||
|
||||
#include "Foundation/NSAttributedString.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSPortCoder.h"
|
||||
#include "Foundation/NSRange.h"
|
||||
#import "Foundation/NSAttributedString.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSPortCoder.h"
|
||||
#import "Foundation/NSRange.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@class GSAttributedString;
|
||||
@interface GSAttributedString : NSObject // Help the compiler
|
||||
|
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#define EXPOSE_NSAutoreleasePool_IVARS 1
|
||||
#define EXPOSE_NSThread_IVARS 1
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSGarbageCollector.h"
|
||||
|
@ -48,8 +50,7 @@ static unsigned pool_count_warning_threshhold = UINT_MAX;
|
|||
#define BEGINNING_POOL_SIZE 32
|
||||
|
||||
/* Easy access to the thread variables belonging to NSAutoreleasePool. */
|
||||
typedef struct { @defs(NSThread) } *TInfo;
|
||||
#define ARP_THREAD_VARS (&(((TInfo)GSCurrentThread())->_autorelease_vars))
|
||||
#define ARP_THREAD_VARS (&((GSCurrentThread())->_autorelease_vars))
|
||||
|
||||
|
||||
@interface NSAutoreleasePool (Private)
|
||||
|
@ -231,7 +232,7 @@ static IMP initImp;
|
|||
|
||||
+ (void) addObject: (id)anObj
|
||||
{
|
||||
TInfo t = (TInfo)GSCurrentThread();
|
||||
NSThread *t = GSCurrentThread();
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
pool = t->_autorelease_vars.current_pool;
|
||||
|
@ -250,7 +251,7 @@ static IMP initImp;
|
|||
|
||||
if (anObj != nil)
|
||||
{
|
||||
NSLog(@"autorelease called without pool for object (%x) "
|
||||
NSLog(@"autorelease called without pool for object (%p) "
|
||||
@"of class %@ in thread %@", anObj,
|
||||
NSStringFromClass([anObj class]), [NSThread currentThread]);
|
||||
}
|
||||
|
@ -474,7 +475,7 @@ static IMP initImp;
|
|||
struct autorelease_thread_vars *tv;
|
||||
NSAutoreleasePool *pool;
|
||||
|
||||
tv = &(((TInfo)thread)->_autorelease_vars);
|
||||
tv = &((thread)->_autorelease_vars);
|
||||
|
||||
/* First release any objects in the pool... bearing in mind that
|
||||
* releasing any object could cause other objects to be added to
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#define EXPOSE_NSBundle_IVARS 1
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "objc-load.h"
|
||||
#include "Foundation/NSBundle.h"
|
||||
|
@ -52,6 +53,7 @@
|
|||
#include "Foundation/NSPathUtilities.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
|
||||
|
@ -763,10 +765,6 @@ _find_main_bundle_for_tool(NSString *toolName)
|
|||
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
@defs(NSBundle)
|
||||
} *bptr;
|
||||
|
||||
static void
|
||||
_bundle_load_callback(Class theClass, struct objc_category *theCategory)
|
||||
{
|
||||
|
@ -800,7 +798,7 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
|
|||
}
|
||||
|
||||
/* Store classes (but don't store categories) */
|
||||
[((bptr)_loadingBundle)->_bundleClasses addObject:
|
||||
[(_loadingBundle)->_bundleClasses addObject:
|
||||
[NSValue valueWithPointer: (void*)theClass]];
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
#import "config.h"
|
||||
|
||||
#define EXPOSE_GSCACHE_IVARS 1
|
||||
#define EXPOSE_NSCache_IVARS 1
|
||||
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSCache.h"
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#define EXPOSE_NSCachedURLResponse_IVARS 1
|
||||
#include "GSURLPrivate.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
|
||||
|
@ -33,10 +34,7 @@ typedef struct {
|
|||
NSURLCacheStoragePolicy storagePolicy;
|
||||
} Internal;
|
||||
|
||||
typedef struct {
|
||||
@defs(NSCachedURLResponse)
|
||||
} priv;
|
||||
#define this ((Internal*)(((priv*)self)->_NSCachedURLResponseInternal))
|
||||
#define this ((Internal*)(self->_NSCachedURLResponseInternal))
|
||||
|
||||
|
||||
@implementation NSCachedURLResponse
|
||||
|
|
|
@ -28,24 +28,25 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSCalendarDate_IVARS 1
|
||||
#include <math.h>
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSCalendarDate.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSDate.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSTimeZone.h"
|
||||
#include "Foundation/NSUserDefaults.h"
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSCalendarDate.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDate.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSTimeZone.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
#ifdef HAVE_SYS_TIME_H
|
||||
#include <sys/time.h>
|
||||
|
|
|
@ -27,19 +27,20 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSIndexSet.h"
|
||||
#include "Foundation/NSThread.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSCharacterSet.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSIndexSet.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSCharacterSet.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#define GNUSTEP_INDEX_CHARSET 1
|
||||
//#undef GNUSTEP_INDEX_CHARSET
|
||||
|
|
|
@ -25,17 +25,17 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "Foundation/NSClassDescription.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
#include "Foundation/NSMapTable.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSClassDescription.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSMapTable.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
|
||||
|
||||
/**
|
||||
* Each instance of this class provides descriptive information for an
|
||||
* Objective C class. This is used for key-value coding, a framework
|
||||
* used in Cocoa for scripting with Objective-C objects. Scripting is
|
||||
* available in GNUstep using Guile, however that implementation does
|
||||
* available in GNUstep in many ways, however those implementations do
|
||||
* not make use of class descriptions. Therefore the primary purpose
|
||||
* of this class is to smooth the process of porting between GNUstep
|
||||
* and other OpenStep-derived systems.
|
||||
|
|
|
@ -26,12 +26,14 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSSerialization.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSCoder_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSSerialization.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@implementation NSCoder
|
||||
|
||||
|
@ -422,7 +424,7 @@
|
|||
|
||||
|
||||
|
||||
#include "GSPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
@implementation _NSKeyedCoderOldStyleArray
|
||||
- (const void*) bytes
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
$Date: 2008-06-08 11:38:33 +0100 (Sun, 08 Jun 2008) $ $Revision: 26606 $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
|
@ -41,6 +41,7 @@
|
|||
#import "NSConcretePointerFunctions.h"
|
||||
#import "NSCallBacks.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
static Class concreteClass = Nil;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
$Date: 2008-06-08 11:38:33 +0100 (Sun, 08 Jun 2008) $ $Revision: 26606 $
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
|
@ -40,6 +40,7 @@
|
|||
|
||||
#import "NSConcretePointerFunctions.h"
|
||||
#import "NSCallBacks.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
static Class concreteClass = Nil;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSValue.h>
|
||||
#import "Foundation/NSValue.h"
|
||||
|
||||
@interface NSBoolNumber : NSNumber
|
||||
{
|
||||
|
|
|
@ -22,15 +22,15 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSConfig.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "NSConcreteNumber.h"
|
||||
#include "GSPrivate.h"
|
||||
#import "config.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSConfig.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "NSConcreteNumber.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
#define TYPE_ORDER 0
|
||||
#include "NSConcreteNumberTemplate.m"
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
#import "config.h"
|
||||
|
||||
#define EXPOSE_NSConnection_IVARS 1
|
||||
#define EXPOSE_NSDistantObject_IVARS 1
|
||||
|
||||
#ifdef HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
#endif
|
||||
|
@ -39,6 +42,7 @@
|
|||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
/*
|
||||
* Setup for inline operation of pointer map tables.
|
||||
|
@ -140,13 +144,6 @@ NSString * const NSObjectInaccessibleException =
|
|||
NSString * const NSObjectNotAvailableException =
|
||||
@"NSObjectNotAvailableException";
|
||||
|
||||
/*
|
||||
* Set up a type to permit us to have direct access into an NSDistantObject
|
||||
*/
|
||||
typedef struct {
|
||||
@defs(NSDistantObject)
|
||||
} ProxyStruct;
|
||||
|
||||
/*
|
||||
* Cache various class pointers.
|
||||
*/
|
||||
|
@ -796,7 +793,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
NSDistantObject *obj = [item obj];
|
||||
|
||||
NSMapRemove(targetToCached,
|
||||
(void*)(uintptr_t)((ProxyStruct*)obj)->_handle);
|
||||
(void*)(uintptr_t)obj->_handle);
|
||||
}
|
||||
}
|
||||
if ([cached_locals count] == 0)
|
||||
|
@ -2292,7 +2289,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
rmc = [conn _makeInRmc: components];
|
||||
if (debug_connection > 5)
|
||||
{
|
||||
NSLog(@"made rmc 0x%x for %d", rmc, type);
|
||||
NSLog(@"made rmc %p for %d", rmc, type);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
|
@ -2913,11 +2910,11 @@ static NSLock *cached_proxies_gate = nil;
|
|||
for (pos = 0; pos < count; pos++)
|
||||
{
|
||||
unsigned target;
|
||||
ProxyStruct *prox;
|
||||
NSDistantObject *prox;
|
||||
|
||||
[rmc decodeValueOfObjCType: @encode(typeof(target)) at: &target];
|
||||
|
||||
prox = (ProxyStruct*)[self includesLocalTarget: target];
|
||||
prox = [self includesLocalTarget: target];
|
||||
if (prox != 0)
|
||||
{
|
||||
if (debug_connection > 3)
|
||||
|
@ -2985,7 +2982,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
}
|
||||
else
|
||||
{
|
||||
((ProxyStruct*)local)->_counter++; // Vended on connection.
|
||||
local->_counter++; // Vended on connection.
|
||||
}
|
||||
M_UNLOCK(IrefGate);
|
||||
|
||||
|
@ -3038,7 +3035,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
[rmc decodeValueOfObjCType: @encode(unsigned) at: &target];
|
||||
[self _doneInRmc: rmc];
|
||||
p = [self includesLocalTarget: target];
|
||||
o = (p != nil) ? ((ProxyStruct*)p)->_object : nil;
|
||||
o = (p != nil) ? p->_object : nil;
|
||||
|
||||
/* xxx We should make sure that TARGET is a valid object. */
|
||||
/* Not actually a Proxy, but we avoid the warnings "id" would have made. */
|
||||
|
@ -3249,7 +3246,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
M_LOCK(IrefGate);
|
||||
if (debug_connection > 5)
|
||||
{
|
||||
NSLog(@"done rmc 0x%x", c);
|
||||
NSLog(@"done rmc %p", c);
|
||||
}
|
||||
if (cacheCoders == YES && IcachedDecoders != nil)
|
||||
{
|
||||
|
@ -3274,7 +3271,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
}
|
||||
if (debug_connection > 5)
|
||||
{
|
||||
NSLog(@"fail rmc 0x%x", c);
|
||||
NSLog(@"fail rmc %p", c);
|
||||
}
|
||||
[c dispatch]; /* Tell NSPortCoder to release the connection. */
|
||||
RELEASE(c);
|
||||
|
@ -3492,15 +3489,15 @@ static NSLock *cached_proxies_gate = nil;
|
|||
M_LOCK(IrefGate);
|
||||
NSParameterAssert (IisValid);
|
||||
|
||||
object = ((ProxyStruct*)anObj)->_object;
|
||||
target = ((ProxyStruct*)anObj)->_handle;
|
||||
object = anObj->_object;
|
||||
target = anObj->_handle;
|
||||
|
||||
/*
|
||||
* If there is no target allocated to the proxy, we add one.
|
||||
*/
|
||||
if (target == 0)
|
||||
{
|
||||
((ProxyStruct*)anObj)->_handle = target = ++local_object_counter;
|
||||
anObj->_handle = target = ++local_object_counter;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -3557,7 +3554,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
GSIMapNode node;
|
||||
|
||||
M_LOCK(IrefGate);
|
||||
anObj = ((ProxyStruct*)prox)->_object;
|
||||
anObj = prox->_object;
|
||||
node = GSIMapNodeForKey(IlocalObjects, (GSIMapKey)anObj);
|
||||
|
||||
/*
|
||||
|
@ -3567,7 +3564,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
*/
|
||||
if (node != 0 && node->value.obj == prox)
|
||||
{
|
||||
target = ((ProxyStruct*)prox)->_handle;
|
||||
target = prox->_handle;
|
||||
|
||||
/*
|
||||
* If this proxy has been vended onwards to another process
|
||||
|
@ -3575,11 +3572,11 @@ static NSLock *cached_proxies_gate = nil;
|
|||
* to the local object around for a while in case that other
|
||||
* process needs it.
|
||||
*/
|
||||
if ((((ProxyStruct*)prox)->_counter) != 0)
|
||||
if ((prox->_counter) != 0)
|
||||
{
|
||||
CachedLocalObject *item;
|
||||
|
||||
(((ProxyStruct*)prox)->_counter) = 0;
|
||||
(prox->_counter) = 0;
|
||||
M_LOCK(cached_proxies_gate);
|
||||
if (timer == nil)
|
||||
{
|
||||
|
@ -3689,7 +3686,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
* Found in cache ... add to this connection as the object
|
||||
* is no longer in use by any connection.
|
||||
*/
|
||||
ASSIGN(((ProxyStruct*)proxy)->_connection, self);
|
||||
ASSIGN(proxy->_connection, self);
|
||||
[self addLocalObject: proxy];
|
||||
NSMapRemove(targetToCached, (void*)(uintptr_t)target);
|
||||
if (debug_connection > 3)
|
||||
|
@ -3734,12 +3731,12 @@ static NSLock *cached_proxies_gate = nil;
|
|||
* order to handle connection shutdown cleanly.
|
||||
*/
|
||||
proxy = node->value.obj;
|
||||
local = RETAIN(((ProxyStruct*)proxy)->_object);
|
||||
local = RETAIN(proxy->_object);
|
||||
proxy = [NSDistantObject proxyWithLocal: local
|
||||
connection: self];
|
||||
nTarget = ((ProxyStruct*)proxy)->_handle;
|
||||
nTarget = proxy->_handle;
|
||||
GSIMapRemoveKey(IlocalTargets, (GSIMapKey)nTarget);
|
||||
((ProxyStruct*)proxy)->_handle = target;
|
||||
proxy->_handle = target;
|
||||
GSIMapAddPair(IlocalTargets, (GSIMapKey)target,
|
||||
(GSIMapVal)((id)proxy));
|
||||
}
|
||||
|
@ -3763,7 +3760,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
- (void) vendLocal: (NSDistantObject*)aProxy
|
||||
{
|
||||
M_LOCK(IrefGate);
|
||||
((ProxyStruct*)aProxy)->_counter++;
|
||||
aProxy->_counter++;
|
||||
M_UNLOCK(IrefGate);
|
||||
}
|
||||
|
||||
|
@ -3834,7 +3831,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
unsigned count = 1;
|
||||
GSIMapNode node;
|
||||
|
||||
target = ((ProxyStruct*)aProxy)->_handle;
|
||||
target = aProxy->_handle;
|
||||
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)target);
|
||||
|
||||
/*
|
||||
|
@ -3843,7 +3840,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
*/
|
||||
if (node != 0 && node->value.obj == aProxy)
|
||||
{
|
||||
count = ((ProxyStruct*)aProxy)->_counter;
|
||||
count = aProxy->_counter;
|
||||
GSIMapRemoveKey(IremoteProxies, (GSIMapKey)target);
|
||||
/*
|
||||
* Tell the remote application that we have removed our proxy and
|
||||
|
@ -3881,7 +3878,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
NSParameterAssert(aTarget > 0);
|
||||
NSParameterAssert(aProxy==nil || aProxy->isa == distantObjectClass);
|
||||
NSParameterAssert(aProxy==nil || [aProxy connectionForProxy] == self);
|
||||
NSParameterAssert(aProxy==nil || aTarget == ((ProxyStruct*)aProxy)->_handle);
|
||||
NSParameterAssert(aProxy==nil || aTarget == aProxy->_handle);
|
||||
|
||||
M_LOCK(IrefGate);
|
||||
node = GSIMapNodeForKey(IremoteProxies, (GSIMapKey)aTarget);
|
||||
|
@ -3907,7 +3904,7 @@ static NSLock *cached_proxies_gate = nil;
|
|||
*/
|
||||
if (p != nil)
|
||||
{
|
||||
((ProxyStruct*)p)->_counter++;
|
||||
p->_counter++;
|
||||
}
|
||||
M_UNLOCK(IrefGate);
|
||||
return p;
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@class GSCountedSet;
|
||||
@interface GSCountedSet : NSObject // Help the compiler
|
||||
|
|
|
@ -68,22 +68,23 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSByteOrder.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSPathUtilities.h"
|
||||
#include "Foundation/NSRange.h"
|
||||
#include "Foundation/NSURL.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
#include "GSPrivate.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#import "Foundation/NSRange.h"
|
||||
#import "Foundation/NSURL.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h> /* for memset() */
|
||||
#ifdef HAVE_UNISTD_H
|
||||
|
@ -240,7 +241,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
#endif
|
||||
if (tmp == 0)
|
||||
{
|
||||
NSLog(@"Malloc failed for file (%@) of length %d - %@", path,
|
||||
NSLog(@"Malloc failed for file (%@) of length %ld - %@", path,
|
||||
fileLength + c, [NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
|
@ -257,7 +258,7 @@ readContentsOfFile(NSString* path, void** buf, unsigned int* len, NSZone* zone)
|
|||
#endif
|
||||
if (tmp == 0)
|
||||
{
|
||||
NSLog(@"Malloc failed for file (%@) of length %d - %@", path,
|
||||
NSLog(@"Malloc failed for file (%@) of length %ld - %@", path,
|
||||
fileLength, [NSError _last]);
|
||||
goto failure;
|
||||
}
|
||||
|
|
|
@ -27,24 +27,25 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSCalendarDate.h"
|
||||
#include "Foundation/NSCharacterSet.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSDate.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSPortCoder.h"
|
||||
#include "Foundation/NSScanner.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSTimeZone.h"
|
||||
#include "Foundation/NSUserDefaults.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "config.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSCalendarDate.h"
|
||||
#import "Foundation/NSCharacterSet.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSDate.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSPortCoder.h"
|
||||
#import "Foundation/NSScanner.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSTimeZone.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
#include <math.h>
|
||||
|
||||
|
|
|
@ -26,13 +26,14 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSDate.h"
|
||||
#include "Foundation/NSCalendarDate.h"
|
||||
#include "Foundation/NSTimeZone.h"
|
||||
#include "Foundation/NSFormatter.h"
|
||||
#include "Foundation/NSDateFormatter.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#define EXPOSE_NSNSDateFormatter_IVARS 1
|
||||
#import "Foundation/NSDate.h"
|
||||
#import "Foundation/NSCalendarDate.h"
|
||||
#import "Foundation/NSTimeZone.h"
|
||||
#import "Foundation/NSFormatter.h"
|
||||
#import "Foundation/NSDateFormatter.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
|
||||
@implementation NSDateFormatter
|
||||
|
||||
|
|
|
@ -31,10 +31,10 @@
|
|||
#if !defined(__APPLE__) || !defined(GNU_RUNTIME)
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
#include "Foundation/NSDecimal.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/NSDecimal.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
|
||||
#ifndef NAN
|
||||
#define NAN 0.0
|
||||
|
|
|
@ -30,13 +30,14 @@
|
|||
#define _ISOC99_SOURCE
|
||||
#include <math.h>
|
||||
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSDecimal.h"
|
||||
#include "Foundation/NSDecimalNumber.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSPortCoder.h"
|
||||
#define EXPOSE_NSNSDecimalNumber_IVARS 1
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSDecimal.h"
|
||||
#import "Foundation/NSDecimalNumber.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSPortCoder.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
#ifdef fpclassify
|
||||
#define GSIsNAN(n) (fpclassify(n) == FP_NAN)
|
||||
|
|
|
@ -27,23 +27,23 @@
|
|||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSKeyValueCoding.h"
|
||||
#include "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "Foundation/NSKeyValueCoding.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
// For private method _decodeArrayOfObjectsForKey:
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
#include "GNUstepBase/GSCategories.h"
|
||||
#include "GSPrivate.h"
|
||||
#import "Foundation/NSKeyedArchiver.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
static BOOL GSMacOSXCompatiblePropertyLists(void)
|
||||
{
|
||||
|
|
|
@ -26,19 +26,20 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/DistributedObjects.h"
|
||||
#include "GNUstepBase/GSObjCRuntime.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
#include "Foundation/NSPort.h"
|
||||
#include "Foundation/NSMethodSignature.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#include "Foundation/NSInvocation.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSDistantObject_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/DistributedObjects.h"
|
||||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSPort.h"
|
||||
#import "Foundation/NSMethodSignature.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
#import "Foundation/NSInvocation.h"
|
||||
#include <objc/Protocol.h>
|
||||
#include "GSInvocation.h"
|
||||
#import "GSInvocation.h"
|
||||
|
||||
|
||||
@interface NSDistantObject(GNUstepExtensions)
|
||||
|
@ -221,7 +222,7 @@ enum proxyLocation
|
|||
{
|
||||
if (debug_proxy)
|
||||
{
|
||||
NSLog(@"Local object is 0x%x (0x%x)\n",
|
||||
NSLog(@"Local object is %p (%p)\n",
|
||||
(uintptr_t)o, (uintptr_t)o ? ((NSDO*)o)->_object : 0);
|
||||
}
|
||||
return RETAIN(((NSDO*)o)->_object);
|
||||
|
|
|
@ -25,14 +25,15 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#include <string.h>
|
||||
#include "Foundation/NSDistributedLock.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "GSPrivate.h"
|
||||
#define EXPOSE_NSDistributedLock_IVARS 1
|
||||
#import "Foundation/NSDistributedLock.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
*/
|
||||
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSNSDistributedNotificationCenter_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSConnection.h"
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -22,10 +22,11 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSError.h>
|
||||
#include <Foundation/NSCoder.h>
|
||||
#define EXPOSE_NSError_IVARS 1
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSError.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
|
||||
NSString* const NSFilePathErrorKey = @"NSFilePathErrorKey";
|
||||
NSString* const NSLocalizedDescriptionKey = @"NSLocalizedDescriptionKey";
|
||||
|
|
|
@ -25,10 +25,11 @@
|
|||
*/
|
||||
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSException_IVARS 1
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import <Foundation/NSDebug.h>
|
||||
#import <Foundation/NSBundle.h>
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSBundle.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSString.h"
|
||||
|
@ -39,6 +40,8 @@
|
|||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_BACKTRACE
|
||||
|
|
|
@ -25,15 +25,17 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "Foundation/NSObject.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSFileHandle.h"
|
||||
#include "Foundation/NSPathUtilities.h"
|
||||
#include "Foundation/NSBundle.h"
|
||||
#include "GNUstepBase/GSFileHandle.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSFileHandle_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSFileHandle.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#import "Foundation/NSBundle.h"
|
||||
#import "GNUstepBase/GSFileHandle.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
// GNUstep Notification names
|
||||
|
||||
|
|
|
@ -42,25 +42,27 @@
|
|||
which default to pre POSIX declaration. */
|
||||
#define _POSIX_PTHREAD_SEMANTICS
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSBundle.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSDate.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSEnumerator.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
#include "Foundation/NSPathUtilities.h"
|
||||
#include "Foundation/NSProcessInfo.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "GSPrivate.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSFileManager_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSBundle.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDate.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#import "Foundation/NSProcessInfo.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
|
|
@ -25,8 +25,9 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSFormatter.h"
|
||||
#import "config.h"
|
||||
#import "Foundation/NSFormatter.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@implementation NSFormatter
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "GSURLPrivate.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#define EXPOSE_NSHTTPCookie_IVARS 1
|
||||
#import "GSURLPrivate.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
NSString * const NSHTTPCookieComment = @"NSHTTPCookieComment";
|
||||
NSString * const NSHTTPCookieCommentURL = @"NSHTTPCookieCommentURL";
|
||||
|
@ -44,11 +46,8 @@ typedef struct {
|
|||
NSDictionary *_properties;
|
||||
} Internal;
|
||||
|
||||
typedef struct {
|
||||
@defs(NSHTTPCookie)
|
||||
} priv;
|
||||
#define this ((Internal*)(((priv*)self)->_NSHTTPCookieInternal))
|
||||
#define inst ((Internal*)(((priv*)o)->_NSHTTPCookieInternal))
|
||||
#define this ((Internal*)(self->_NSHTTPCookieInternal))
|
||||
#define inst ((Internal*)(o->_NSHTTPCookieInternal))
|
||||
|
||||
@implementation NSHTTPCookie
|
||||
|
||||
|
|
|
@ -22,8 +22,10 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "GSURLPrivate.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#define EXPOSE_NSHTTPCookieStorage_IVARS 1
|
||||
#import "GSURLPrivate.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
NSString * const NSHTTPCookieManagerAcceptPolicyChangedNotification
|
||||
= @"NSHTTPCookieManagerAcceptPolicyChangedNotification";
|
||||
|
@ -37,11 +39,8 @@ typedef struct {
|
|||
NSMutableSet *_cookies;
|
||||
} Internal;
|
||||
|
||||
typedef struct {
|
||||
@defs(NSHTTPCookieStorage)
|
||||
} priv;
|
||||
#define this ((Internal*)(((priv*)self)->_NSHTTPCookieStorageInternal))
|
||||
#define inst ((Internal*)(((priv*)o)->_NSHTTPCookieStorageInternal))
|
||||
#define this ((Internal*)(self->_NSHTTPCookieStorageInternal))
|
||||
#define inst ((Internal*)(o->_NSHTTPCookieStorageInternal))
|
||||
|
||||
|
||||
/* FIXME
|
||||
|
|
|
@ -24,18 +24,19 @@
|
|||
* $Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSObject.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSPointerFunctions.h"
|
||||
#include "Foundation/NSSet.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
#include "Foundation/NSHashTable.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "NSCallBacks.h"
|
||||
#include "GSPrivate.h"
|
||||
#import "config.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSPointerFunctions.h"
|
||||
#import "Foundation/NSSet.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
#import "Foundation/NSHashTable.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "NSCallBacks.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@interface NSConcreteHashTable : NSHashTable
|
||||
@end
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
*/
|
||||
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSHost_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSHost.h"
|
||||
|
|
|
@ -23,16 +23,17 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "Foundation/NSObject.h"
|
||||
#include "Foundation/NSByteOrder.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSHashTable.h"
|
||||
#include "Foundation/NSIndexPath.h"
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#define EXPOSE_NSIndexPath_IVARS 1
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSHashTable.h"
|
||||
#import "Foundation/NSIndexPath.h"
|
||||
#import "Foundation/NSKeyedArchiver.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
|
||||
static NSLock *lock = nil;
|
||||
static NSHashTable *shared = 0;
|
||||
|
|
|
@ -23,11 +23,12 @@
|
|||
|
||||
*/
|
||||
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSIndexSet.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
#define EXPOSE_NSIndexSet_IVARS 1
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSIndexSet.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
|
||||
#define GSI_ARRAY_TYPE NSRange
|
||||
|
||||
|
|
|
@ -26,12 +26,15 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSInvocation.h"
|
||||
#include "GSInvocation.h"
|
||||
#include "config.h"
|
||||
#include "GSPrivate.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSInvocation_IVARS 1
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSInvocation.h"
|
||||
#import "GSInvocation.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#if defined(USE_LIBFFI)
|
||||
#include "cifframe.h"
|
||||
#elif defined(USE_FFCALL)
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#import "GNUstepBase/GSObjCRuntime.h"
|
||||
#import "GNUstepBase/Unicode.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
#import "GSInvocation.h"
|
||||
|
||||
/*
|
||||
|
|
|
@ -23,14 +23,16 @@
|
|||
|
||||
*/
|
||||
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSException.h>
|
||||
#include <Foundation/NSScanner.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#define EXPOSE_NSKeyedArchiver_IVARS 1
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSScanner.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
|
||||
@class GSString;
|
||||
|
||||
|
@ -61,7 +63,7 @@ static GC_descr nodeDesc; // Type descriptor for map node.
|
|||
|
||||
|
||||
#define _IN_NSKEYEDARCHIVER_M 1
|
||||
#include <Foundation/NSKeyedArchiver.h>
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
#undef _IN_NSKEYEDARCHIVER_M
|
||||
|
||||
/* Exceptions */
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
|
||||
*/
|
||||
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSKeyedUnarchiver_IVARS 1
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
|
@ -32,7 +34,6 @@
|
|||
#import "Foundation/NSValue.h"
|
||||
|
||||
#import "GSPrivate.h"
|
||||
#import "config.h"
|
||||
|
||||
/*
|
||||
* Setup for inline operation of arrays.
|
||||
|
@ -50,7 +51,7 @@
|
|||
#include "GNUstepBase/GSIArray.h"
|
||||
|
||||
#define _IN_NSKEYEDUNARCHIVER_M 1
|
||||
#include <Foundation/NSKeyedArchiver.h>
|
||||
#include "Foundation/NSKeyedArchiver.h"
|
||||
#undef _IN_NSKEYEDUNARCHIVER_M
|
||||
|
||||
@interface NilMarker: NSObject
|
||||
|
|
|
@ -31,6 +31,10 @@
|
|||
#import "GNUstepBase/GSConfig.h"
|
||||
#define gs_cond_t pthread_cond_t
|
||||
#define gs_mutex_t pthread_mutex_t
|
||||
#define EXPOSE_NSLock_IVARS 1
|
||||
#define EXPOSE_NSRecursiveLock_IVARS 1
|
||||
#define EXPOSE_NSCondition_IVARS 1
|
||||
#define EXPOSE_NSConditionLock_IVARS 1
|
||||
#import "Foundation/NSLock.h"
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
@ -88,7 +92,7 @@
|
|||
}\
|
||||
if (EDEADLK == err)\
|
||||
{\
|
||||
_NSLockError(self, _cmd);\
|
||||
_NSLockError(self, _cmd, YES);\
|
||||
}\
|
||||
}
|
||||
#define MLOCKBEFOREDATE \
|
||||
|
@ -129,12 +133,13 @@ static pthread_mutexattr_t attr_recursive;
|
|||
/*
|
||||
* OS X 10.5 compatibility function to allow debugging deadlock conditions.
|
||||
*/
|
||||
void _NSLockError(id obj, SEL _cmd)
|
||||
void _NSLockError(id obj, SEL _cmd, BOOL stop)
|
||||
{
|
||||
NSLog(@"*** -[%@ %@]: deadlock (%@)", [obj class],
|
||||
NSStringFromSelector(_cmd), obj);
|
||||
NSLog(@"*** Break on _NSLockError() to debug.");
|
||||
pthread_mutex_lock(&deadlock);
|
||||
if (YES == stop)
|
||||
pthread_mutex_lock(&deadlock);
|
||||
}
|
||||
|
||||
// Exceptions
|
||||
|
@ -200,7 +205,25 @@ MFINALIZE
|
|||
}
|
||||
|
||||
MLOCK
|
||||
MLOCKBEFOREDATE
|
||||
|
||||
- (BOOL) lockBeforeDate: (NSDate*)limit
|
||||
{
|
||||
do
|
||||
{
|
||||
int err = pthread_mutex_trylock(&_mutex);
|
||||
if (0 == err)
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
if (EDEADLK == err)
|
||||
{
|
||||
_NSLockError(self, _cmd, NO);
|
||||
}
|
||||
sched_yield();
|
||||
} while([limit timeIntervalSinceNow] < 0);
|
||||
return NO;
|
||||
}
|
||||
|
||||
MNAME
|
||||
MTRYLOCK
|
||||
MUNLOCK
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSThread.h"
|
||||
#import "GNUstepBase/NSString+GNUstepBase.h"
|
||||
|
||||
#ifdef HAVE_SYSLOG_H
|
||||
#include <syslog.h>
|
||||
|
|
|
@ -24,17 +24,18 @@
|
|||
* $Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSObject.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSPointerFunctions.h"
|
||||
#include "Foundation/NSZone.h"
|
||||
#include "Foundation/NSMapTable.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "NSCallBacks.h"
|
||||
#import "config.h"
|
||||
#import "Foundation/NSObject.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSPointerFunctions.h"
|
||||
#import "Foundation/NSZone.h"
|
||||
#import "Foundation/NSMapTable.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "NSCallBacks.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@interface NSConcreteMapTable : NSMapTable
|
||||
@end
|
||||
|
|
|
@ -22,30 +22,32 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "GNUstepBase/GSLock.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSRunLoop.h"
|
||||
#include "Foundation/NSByteOrder.h"
|
||||
#include "Foundation/NSData.h"
|
||||
#include "Foundation/NSDate.h"
|
||||
#include "Foundation/NSMapTable.h"
|
||||
#include "Foundation/NSPortMessage.h"
|
||||
#include "Foundation/NSPortNameServer.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
#include "Foundation/NSThread.h"
|
||||
#include "Foundation/NSConnection.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSPathUtilities.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSProcessInfo.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSPort_IVARS 1
|
||||
#define EXPOSE_NSMessagePort_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "GNUstepBase/GSLock.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSRunLoop.h"
|
||||
#import "Foundation/NSByteOrder.h"
|
||||
#import "Foundation/NSData.h"
|
||||
#import "Foundation/NSDate.h"
|
||||
#import "Foundation/NSMapTable.h"
|
||||
#import "Foundation/NSPortMessage.h"
|
||||
#import "Foundation/NSPortNameServer.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#import "Foundation/NSConnection.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSProcessInfo.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
#include "GSPortPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GSPortPrivate.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
|
@ -23,22 +23,22 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "Foundation/NSPortNameServer.h"
|
||||
#import "Foundation/NSPortNameServer.h"
|
||||
|
||||
#include "Foundation/NSAutoreleasePool.h"
|
||||
#include "Foundation/NSDebug.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSLock.h"
|
||||
#include "Foundation/NSDistributedLock.h"
|
||||
#include "Foundation/NSMapTable.h"
|
||||
#include "Foundation/NSPathUtilities.h"
|
||||
#include "Foundation/NSPort.h"
|
||||
#include "Foundation/NSFileManager.h"
|
||||
#include "Foundation/NSValue.h"
|
||||
#include "Foundation/NSThread.h"
|
||||
#include "GNUstepBase/GSMime.h"
|
||||
#import "Foundation/NSAutoreleasePool.h"
|
||||
#import "Foundation/NSDebug.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
#import "Foundation/NSDistributedLock.h"
|
||||
#import "Foundation/NSMapTable.h"
|
||||
#import "Foundation/NSPathUtilities.h"
|
||||
#import "Foundation/NSPort.h"
|
||||
#import "Foundation/NSFileManager.h"
|
||||
#import "Foundation/NSValue.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#import "GNUstepBase/GSMime.h"
|
||||
|
||||
#include "GSPortPrivate.h"
|
||||
#import "GSPortPrivate.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
|
|
@ -27,15 +27,16 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSMethodSignature_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
|
||||
#include "Foundation/NSMethodSignature.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSMethodSignature.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
|
||||
#include "GSInvocation.h"
|
||||
#import "GSInvocation.h"
|
||||
|
||||
/* The objc runtime library objc_skip_offset() is buggy on some compiler
|
||||
* versions, so we use our own alternative implementation.
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#define EXPOSE_NSNetServices_IVARS 1
|
||||
#import "Foundation/NSNetServices.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSEnumerator.h"
|
||||
|
|
|
@ -25,11 +25,13 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSNotification_IVARS 1
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@class GSNotification;
|
||||
@interface GSNotification : NSObject // Help the compiler
|
||||
|
|
|
@ -29,7 +29,8 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSNotificationCenter_IVARS 1
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSLock.h"
|
||||
|
|
|
@ -28,17 +28,18 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "Foundation/NSRunLoop.h"
|
||||
#include "Foundation/NSNotificationQueue.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSArray.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSThread.h"
|
||||
#import "config.h"
|
||||
#define EXPOSE_NSNotificationQueue_IVARS 1
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSRunLoop.h"
|
||||
#import "Foundation/NSNotificationQueue.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSArray.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
|
||||
#include "GSPrivate.h"
|
||||
#import "GSPrivate.h"
|
||||
/* NotificationQueueList by Richard Frith-Macdonald
|
||||
These objects are used to maintain lists of NSNotificationQueue objects.
|
||||
There is one list per NSThread, with the first object in the list stored
|
||||
|
|
|
@ -29,19 +29,20 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "GNUstepBase/preface.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSNotification.h"
|
||||
#include "Foundation/NSMapTable.h"
|
||||
#include "Foundation/NSThread.h"
|
||||
#include "Foundation/NSCoder.h"
|
||||
#include "Foundation/NSPortCoder.h"
|
||||
#include "Foundation/NSObjCRuntime.h"
|
||||
#import "config.h"
|
||||
#import "GNUstepBase/preface.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSNotification.h"
|
||||
#import "Foundation/NSMapTable.h"
|
||||
#import "Foundation/NSThread.h"
|
||||
#import "Foundation/NSCoder.h"
|
||||
#import "Foundation/NSPortCoder.h"
|
||||
#import "Foundation/NSObjCRuntime.h"
|
||||
|
||||
#include "NSConcreteNumber.h"
|
||||
#include "GSPrivate.h"
|
||||
#import "NSConcreteNumber.h"
|
||||
#import "GSPrivate.h"
|
||||
#import "GNUstepBase/NSObject+GNUstepBase.h"
|
||||
|
||||
@interface GSCachedBool : NSBoolNumber
|
||||
@end
|
||||
|
|
|
@ -27,16 +27,17 @@
|
|||
$Date$ $Revision$
|
||||
*/
|
||||
|
||||
#include "Foundation/NSAttributedString.h"
|
||||
#include "Foundation/NSDecimalNumber.h"
|
||||
#include "Foundation/NSDictionary.h"
|
||||
#include "Foundation/NSException.h"
|
||||
#include "Foundation/NSNumberFormatter.h"
|
||||
#include "Foundation/NSString.h"
|
||||
#include "Foundation/NSUserDefaults.h"
|
||||
#include "Foundation/NSCharacterSet.h"
|
||||
#define EXPOSE_NSNumberFormatter_IVARS 1
|
||||
#import "Foundation/NSAttributedString.h"
|
||||
#import "Foundation/NSDecimalNumber.h"
|
||||
#import "Foundation/NSDictionary.h"
|
||||
#import "Foundation/NSException.h"
|
||||
#import "Foundation/NSNumberFormatter.h"
|
||||
#import "Foundation/NSString.h"
|
||||
#import "Foundation/NSUserDefaults.h"
|
||||
#import "Foundation/NSCharacterSet.h"
|
||||
|
||||
#include "GNUstepBase/GSLocale.h"
|
||||
#import "GNUstepBase/GSLocale.h"
|
||||
|
||||
@implementation NSNumberFormatter
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue