Some cleanup in preparation for next release.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@22618 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2006-03-08 11:28:59 +00:00
parent 172bfc67ef
commit c2e8c881e7
88 changed files with 570 additions and 425 deletions

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library 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.
*/
#include "config.h"
@ -30,6 +31,137 @@
/* Test for ASCII whitespace which is safe for unicode characters */
#define space(C) ((C) > 127 ? NO : isspace(C))
@implementation NSArray (GSCategories)
- (unsigned) 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;
}
- (unsigned) 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
@implementation NSAttributedString (GSCategories)
- (NSAttributedString*) attributedSubstringWithRange: (NSRange)aRange
{
GSOnceMLog(@"This method is deprecated, use -attributedSubstringFromRange:");
return [self attributedSubstringFromRange: aRange];
}
@end
/**
* Extension methods for the NSCalendarDate class
*/

View file

@ -17,12 +17,22 @@
You should have received a copy of the GNU Library 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.
*/
#ifndef __GSPortPrivate_h_
#define __GSPortPrivate_h_
/*
* Nameserver deregistration methods
*/
@interface NSPortNameServer (GNUstep)
- (NSArray*) namesForPort: (NSPort*)port; /* return all names for port */
- (BOOL) removePort: (NSPort*)port; /* remove all names for port */
- (BOOL) removePort: (NSPort*)port forName: (NSString*)name;
@end
#if defined(__MINGW32__)
@interface NSMessagePort(Private)
+ (id) newWithName: (NSString*)name;

View file

@ -17,7 +17,8 @@
You should have received a copy of the GNU Library 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.
*/
#ifndef __GSPrivate_h_

View file

@ -1980,138 +1980,3 @@ compare(id elem1, id elem2, void* context)
}
@end
/**
* [NSArray] enhancements provided by GNUstep.
*/
@implementation NSArray (GNUstep)
/**
* Locate the correct insertion position for item where the receiver is
* a sorted array witch was sorted using the sorter function.<br />
* The comparator function takes two items as arguments, the first is the
* item to be added, the second is the item already in the array.
* The function should return NSOrderedAscending if the item to be
* added is 'less than' the item in the array, NSOrderedDescending
* if it is greater, and NSOrderedSame if it is equal.
*/
- (unsigned) insertionPosition: (id)item
usingFunction: (NSComparisonResult (*)(id, id, void *))sorter
context: (void *)context
{
unsigned count = [self count];
unsigned upper = count;
unsigned lower = 0;
unsigned index;
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"];
}
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;
}
/**
* Locate the correct insertion position for item where the receiver is
* a sorted array which was sorted using the comp selector.
*/
- (unsigned) insertionPosition: (id)item
usingSelector: (SEL)comp
{
unsigned count = [self count];
unsigned upper = count;
unsigned lower = 0;
unsigned index;
NSComparisonResult (*imp)(id, SEL, id);
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"];
}
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

View file

@ -604,14 +604,6 @@ static Class GSMutableAttributedStringClass;
return newAttrString;
}
/**
* Synonym for [-attributedSubstringFromRange:].
*/
- (NSAttributedString*) attributedSubstringWithRange: (NSRange)aRange
{
return [self attributedSubstringFromRange: aRange];
}
@end //NSAttributedString
/**

View file

@ -371,12 +371,22 @@ _find_framework(NSString *name)
}
@interface NSBundle (Private)
+ (NSString *) _absolutePathOfExecutable: (NSString *)path;
+ (void) _addFrameworkFromClass: (Class)frameworkClass;
- (NSArray *) _bundleClasses;
+ (NSString*) _gnustep_target_cpu;
+ (NSString*) _gnustep_target_dir;
+ (NSString*) _gnustep_target_os;
+ (NSString*) _library_combo;
@end
@implementation NSBundle (Private)
+ (NSString *) _absolutePathOfExecutable: (NSString *)path
{
return AbsolutePathOfExecutable(path, NO);
}
/* Nicola & Mirko:
Frameworks can be used in an application in two different ways:
@ -615,6 +625,26 @@ _find_framework(NSString *name)
return _bundleClasses;
}
+ (NSString*) _gnustep_target_cpu
{
return gnustep_target_cpu;
}
+ (NSString*) _gnustep_target_dir
{
return gnustep_target_dir;
}
+ (NSString*) _gnustep_target_os
{
return gnustep_target_os;
}
+ (NSString*) _library_combo
{
return library_combo;
}
@end
/*
@ -1883,19 +1913,6 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
return nil;
}
+ (NSString *) _absolutePathOfExecutable: (NSString *)path
{
return AbsolutePathOfExecutable(path, NO);
}
+ (NSBundle *) gnustepBundle
{
/* Deprecated since 1.7.0 */
GSOnceMLog(@"Warning: Deprecated method %@ called. Use +bundleForLibrary: instead",
NSStringFromSelector(_cmd));
return _gnustep_bundle;
}
+ (NSString *) pathForLibraryResource: (NSString *)name
ofType: (NSString *)ext
inDirectory: (NSString *)bundlePath
@ -1922,36 +1939,5 @@ _bundle_load_callback(Class theClass, struct objc_category *theCategory)
return path;
}
+ (NSString *) pathForGNUstepResource: (NSString *)name
ofType: (NSString *)ext
inDirectory: (NSString *)bundlePath
{
/* Deprecated since 1.7.0 */
GSOnceMLog(@"Warning: Deprecated method %@ called. Use +pathForLibraryResource:ofType:inDirectory: or +bundleForLibrary: instead",
NSStringFromSelector(_cmd));
return [self pathForLibraryResource: name ofType: ext
inDirectory: bundlePath];
}
+ (NSString*) _gnustep_target_cpu
{
return gnustep_target_cpu;
}
+ (NSString*) _gnustep_target_dir
{
return gnustep_target_dir;
}
+ (NSString*) _gnustep_target_os
{
return gnustep_target_os;
}
+ (NSString*) _library_combo
{
return library_combo;
}
@end

View file

@ -28,6 +28,7 @@
#include "config.h"
#include "GNUstepBase/preface.h"
#include "Foundation/NSData.h"
#include "Foundation/NSDebug.h"
#include "Foundation/NSCoder.h"
#include "Foundation/NSSerialization.h"
@ -414,6 +415,7 @@
at: (void*)buf
withName: (id*)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
if (name)
{
*name = [self decodeObject];
@ -429,11 +431,13 @@
*/
- (void) decodeIndent
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
}
- (void) decodeObjectAt: (id*)anObject
withName: (id*)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
[self decodeValueOfObjCType: @encode(id) at: anObject withName: name];
}
@ -441,6 +445,7 @@
at: (void*)buf
withName: (id*)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
[self decodeValueOfObjCType: type at: buf withName: name];
}
@ -448,6 +453,7 @@
at: (void*)buf
withName: (id*)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
if (name != 0)
{
*name = [self decodeObject];
@ -464,6 +470,7 @@
at: (const void*)buf
withName: (id)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
[self encodeObject: name];
[self encodeArrayOfObjCType: type count: count at: buf];
}
@ -472,12 +479,14 @@
*/
- (void) encodeIndent
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
}
- (void) encodeValueOfCType: (const char*)type
at: (const void*)buf
withName: (id)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
[self encodeValueOfObjCType: type at: buf withName: name];
}
@ -485,6 +494,7 @@
at: (const void*)buf
withName: (id)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
[self encodeObject: name];
[self encodeValueOfObjCType: type at: buf];
}
@ -492,6 +502,7 @@
- (void) encodeObjectAt: (id*)anObject
withName: (id)name
{
GSOnceMLog(@"Deprecated, use NSKeyedArchiver methods");
[self encodeValueOfObjCType: @encode(id) at: anObject withName: name];
}

View file

@ -77,11 +77,29 @@
#include "Foundation/NSNotification.h"
#include "Foundation/NSDebug.h"
#include "GSInvocation.h"
#include "GSPortPrivate.h"
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
@interface NSPortCoder (Private)
- (NSMutableArray*) _components;
@end
@interface NSPortMessage (Private)
- (NSMutableArray*) _components;
@end
@interface NSConnection (GNUstepExtensions) <GCFinalization>
- (void) gcFinalize;
- (retval_t) forwardForProxy: (NSDistantObject*)object
selector: (SEL)sel
argFrame: (arglist_t)argframe;
- (void) forwardInvocation: (NSInvocation *)inv
forProxy: (NSDistantObject*)object;
- (const char *) typeForSelector: (SEL)sel remoteTarget: (unsigned)target;
@end
extern NSRunLoop *GSRunLoopForThread(NSThread*);
#define F_LOCK(X) {NSDebugFLLog(@"GSConnection",@"Lock %@",X);[X lock];}
@ -1628,6 +1646,8 @@ static NSLock *cached_proxies_gate = nil;
{
NSConnection *conn;
GSOnceMLog(@"This method is deprecated, use standard initialisation");
conn = [[self alloc] initWithReceivePort: [NSPort port]
sendPort: nil];
[conn setRootObject: anObject];

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library 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>NSDistantObject class reference</title>
$Date$ $Revision$
@ -38,6 +39,14 @@
#include "Foundation/NSInvocation.h"
#include <objc/Protocol.h>
@interface NSDistantObject(GNUstepExtensions) <GCFinalization>
- (Class) classForPortCoder;
- (const char *) selectorTypeForProxy: (SEL)selector;
- (id) forward: (SEL)aSel :(arglist_t)frame;
- (void) gcFinalize;
@end
#define DO_FORWARD_INVOCATION(_SELX, _ARG1) ({ \
sig = [self methodSignatureForSelector: @selector(_SELX)]; \
if (sig != nil) \

View file

@ -759,6 +759,23 @@ _arg_addr(NSInvocation *inv, int index)
*/
@implementation NSInvocation (GNUstep)
- (BOOL) sendsToSuper
{
return _sendToSuper;
}
- (void) setSendsToSuper: (BOOL)flag
{
_sendToSuper = flag;
}
@end
/**
* These methods are for internal use only ... not public API<br />
* They are used by the NS_INVOCATION() and NS_MESSAGE() macros to help
* create invocations.
*/
@implementation NSInvocation (MacroSetup)
/**
* Internal use.<br />
* Initialises the receiver with a known selector and argument list
@ -930,33 +947,6 @@ _arg_addr(NSInvocation *inv, int index)
return NULL;
}
/**
* Returns the status of the flag set by -setSendsToSuper:
*/
- (BOOL) sendsToSuper
{
return _sendToSuper;
}
/**
* Sets the flag to tell the invocation that it should actually invoke a
* method in the superclass of the target rather than the method of the
* target itself.<br />
* This extension permits an invocation to act like a regular method
* call sent to <em>super</em> in the method of a class.
*/
- (void) setSendsToSuper: (BOOL)flag
{
_sendToSuper = flag;
}
@end
/**
* These methods are for internal use only ... not public API<br />
* They are used by the NS_INVOCATION() and NS_MESSAGE() macros to help
* create invocations.
*/
@implementation NSInvocation (MacroSetup)
+ (id) _newProxyForInvocation: (id)target
{
return [GSInvocationProxy _newWithTarget: target];

View file

@ -16,7 +16,8 @@
You should have received a copy of the GNU Library 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>NSMessagePortNameServer class reference</title>
$Date$ $Revision$

View file

@ -22,7 +22,8 @@
You should have received a copy of the GNU Library 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>NSNotificationCenter class reference</title>
$Date$ $Revision$
@ -33,6 +34,7 @@
#include "Foundation/NSException.h"
#include "Foundation/NSLock.h"
#include "Foundation/NSThread.h"
#include "Foundation/NSDebug.h"
#include "GNUstepBase/GSLock.h"
@ -1146,6 +1148,7 @@ static NSNotificationCenter *default_center = nil;
{
BOOL old;
GSOnceMLog(@"This method is deprecated");
lockNCTable(TABLE);
if (self == default_center)
{

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library 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>NSNull class reference</title>
$Date$ $Revision$

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library 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>NSPortNameServer class reference</title>
$Date$ $Revision$
@ -27,11 +28,12 @@
#include "config.h"
#include "Foundation/NSString.h"
#include "Foundation/NSException.h"
#include "Foundation/NSPort.h"
#include "Foundation/NSPortNameServer.h"
#include "Foundation/NSDebug.h"
#include "Foundation/NSLock.h"
#include "Foundation/NSUserDefaults.h"
#include "GSPrivate.h"
#include "GSPortPrivate.h"
/**

View file

@ -19,7 +19,8 @@
You should have received a copy of the GNU Library 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>NSProcessInfo class reference</title>
$Date$ $Revision$
@ -100,6 +101,10 @@
#include "GSPrivate.h"
@interface NSBundle (Private)
+ (NSString*) _gnustep_target_os;
@end
/* This error message should be called only if the private main function
* was not executed successfully. This may happen ONLY if another library
* or kit defines its own main function (as gnustep-base does).

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library 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.
$Date$ $Revision$
*/
@ -42,6 +43,9 @@
#include "Foundation/NSPathUtilities.h"
#include "Foundation/NSPortNameServer.h"
#include "Foundation/NSDebug.h"
#include "GSPortPrivate.h"
#ifdef __MINGW32__
#include <winsock2.h>
#include <wininet.h>

View file

@ -101,6 +101,13 @@
#define NOFILE 256
#endif
@interface NSBundle(Private)
+ (NSString *) _absolutePathOfExecutable: (NSString *)path;
+ (NSString*) _gnustep_target_cpu;
+ (NSString*) _gnustep_target_dir;
+ (NSString*) _gnustep_target_os;
+ (NSString*) _library_combo;
@end
static NSRecursiveLock *tasksLock = nil;
static NSMapTable *activeTasks = 0;

View file

@ -55,6 +55,10 @@
#include "GSRunLoopCtxt.h"
@interface NSAutoreleasePool (NSThread)
+ (void) _endThread: (NSThread*)thread;
@end
typedef struct { @defs(NSThread) } NSThread_ivars;
static Class threadClass = Nil;

View file

@ -18,7 +18,8 @@
You should have received a copy of the GNU Library 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.
*/
/* These functions can be used for dissecting and making method calls