Massive tidy up

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6862 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-07-03 11:47:17 +00:00
parent dae20769ac
commit 7617609b41
17 changed files with 745 additions and 379 deletions

View file

@ -1,3 +1,19 @@
2000-07-03 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSConnection.m: Cache coders fro performance.
* Source/GSPortCoder.m: support re-use.
* Source/GSTcpPort.m: tidy locking.
* Source/NSData.m: optimize +new
* Source/NSGCString.m: optimize -hash
* Source/NSGDictionary.m: optimize string hashing
* SourceNSObject.m: Call GSBuildStrings() for global constants.
* Source/NSPort.m: Create GSTcpPort by default.
* Source/externs.m: GSBuildStrings() now used to make string
constants that support cached hash values
* Tools/client.m: Added simple benchmarking.
* Tools/server.m: Added method for simple benchmarking.
* Tools/server.h: Added method for simple benchmarking.
2000-07-02 Richard Frith-Macdonald <rfm@gnu.org> 2000-07-02 Richard Frith-Macdonald <rfm@gnu.org>
* Source/GSConnection.m: Implementation almost complete * Source/GSConnection.m: Implementation almost complete

View file

@ -82,6 +82,8 @@ GS_EXPORT NSString *NSConnectionProxyCount; /* Objects received */
NSMutableArray *_requestQueue; NSMutableArray *_requestQueue;
id _delegate; id _delegate;
NSRecursiveLock *_refGate; NSRecursiveLock *_refGate;
NSPortCoder *_cachedDecoder;
NSPortCoder *_cachedEncoder;
} }
+ (NSArray*) allConnections; + (NSArray*) allConnections;

View file

@ -1,4 +1,4 @@
/* Interface for GSPortCoder object for distributed objects /* Interface for NSPortCoder object for distributed objects
Copyright (C) 2000 Free Software Foundation, Inc. Copyright (C) 2000 Free Software Foundation, Inc.
Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk> Written by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
@ -21,15 +21,15 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
*/ */
#ifndef __GSPortCoder_h #ifndef __NSPortCoder_h
#define __GSPortCoder_h #define __NSPortCoder_h
#include <Foundation/NSCoder.h> #include <Foundation/NSCoder.h>
@class NSConnection; @class NSConnection;
@class NSPort; @class NSPort;
@interface GSPortCoder : NSCoder @interface NSPortCoder : NSCoder
{ {
@private @private
NSMutableArray *_comp; NSMutableArray *_comp;
@ -72,10 +72,10 @@
#ifndef _IN_PORT_CODER_M #ifndef _IN_PORT_CODER_M
#undef GSIArray #undef GSIArray
#endif #endif
NSMutableArray *_cInfo; /* Class version information. */
unsigned _cursor; /* Position in data buffer. */ unsigned _cursor; /* Position in data buffer. */
unsigned _version; /* Version of archiver used. */ unsigned _version; /* Version of archiver used. */
NSZone *_zone; /* Zone for allocating objs. */ NSZone *_zone; /* Zone for allocating objs. */
NSMutableDictionary *_cInfo; /* Class information store. */
} }
+ (NSPortCoder*) portCoderWithReceivePort: (NSPort*)recv + (NSPortCoder*) portCoderWithReceivePort: (NSPort*)recv
@ -99,4 +99,4 @@
@end @end
#endif /* __GSPortCoder_h */ #endif /* __NSPortCoder_h */

View file

@ -62,9 +62,14 @@ GS_EXPORT NSString *NSPortTimeoutException; /* OPENSTEP */
forMode: (NSString*)aMode; forMode: (NSString*)aMode;
- (unsigned) reservedSpaceLength; - (unsigned) reservedSpaceLength;
- (BOOL) sendBeforeDate: (NSDate*)when - (BOOL) sendBeforeDate: (NSDate*)when
msgid: (int)msgid
components: (NSMutableArray*)components components: (NSMutableArray*)components
from: (NSPort*)receivingPort from: (NSPort*)receivingPort
reserved: (unsigned) length; reserved: (unsigned)length;
- (BOOL) sendBeforeDate: (NSDate*)when
components: (NSMutableArray*)components
from: (NSPort*)receivingPort
reserved: (unsigned)length;
#endif #endif
@end @end

View file

@ -234,7 +234,6 @@ NSPipe.m \
NSPort.m \ NSPort.m \
GSTcpPort.m \ GSTcpPort.m \
NSPortCoder.m \ NSPortCoder.m \
GSPortCoder.m \
NSPortMessage.m \ NSPortMessage.m \
NSPortNameServer.m \ NSPortNameServer.m \
NSProcessInfo.m \ NSProcessInfo.m \
@ -330,7 +329,6 @@ Foundation/NSObject.h \
Foundation/NSPathUtilities.h \ Foundation/NSPathUtilities.h \
Foundation/NSPort.h \ Foundation/NSPort.h \
Foundation/NSPortCoder.h \ Foundation/NSPortCoder.h \
Foundation/GSPortCoder.h \
Foundation/NSPortMessage.h \ Foundation/NSPortMessage.h \
Foundation/NSPortNameServer.h \ Foundation/NSPortNameServer.h \
Foundation/NSProcessInfo.h \ Foundation/NSProcessInfo.h \

View file

@ -202,9 +202,11 @@ static unsigned local_object_counter = 0;
- (void) handlePortMessage: (NSPortMessage*)msg; - (void) handlePortMessage: (NSPortMessage*)msg;
- _getReplyRmc: (int)n; - _getReplyRmc: (int)n;
- (NSPortCoder*) _makeRmc: (int)sequence; - (void) _doneInRmc: (NSPortCoder*)c;
- (NSPortCoder*) _makeInRmc: (NSMutableArray*)components;
- (NSPortCoder*) _makeOutRmc: (int)sequence;
- (int) _newMsgNumber; - (int) _newMsgNumber;
- (void) _sendRmc: (NSPortCoder*)c type: (int)msgid; - (void) _sendOutRmc: (NSPortCoder*)c type: (int)msgid;
- (void) _service_forwardForProxy: (NSPortCoder*)rmc; - (void) _service_forwardForProxy: (NSPortCoder*)rmc;
- (void) _service_release: (NSPortCoder*)rmc; - (void) _service_release: (NSPortCoder*)rmc;
@ -1010,11 +1012,12 @@ static int messages_received_count;
NSParameterAssert(_isValid); NSParameterAssert(_isValid);
seq_num = [self _newMsgNumber]; seq_num = [self _newMsgNumber];
op = [self _makeRmc: seq_num]; op = [self _makeOutRmc: seq_num];
[self _sendRmc: op type: ROOTPROXY_REQUEST]; [self _sendOutRmc: op type: ROOTPROXY_REQUEST];
ip = [self _getReplyRmc: seq_num]; ip = [self _getReplyRmc: seq_num];
[ip decodeValueOfObjCType: @encode(id) at: &newProxy]; [ip decodeValueOfObjCType: @encode(id) at: &newProxy];
DESTROY(ip);
return AUTORELEASE(newProxy); return AUTORELEASE(newProxy);
} }
@ -1187,6 +1190,9 @@ static int messages_received_count;
_replyMap = 0; _replyMap = 0;
} }
DESTROY(_cachedDecoder);
DESTROY(_cachedEncoder);
DESTROY(_refGate); DESTROY(_refGate);
RELEASE(arp); RELEASE(arp);
} }
@ -1250,7 +1256,7 @@ static int messages_received_count;
NSParameterAssert(*type); NSParameterAssert(*type);
seq_num = [self _newMsgNumber]; seq_num = [self _newMsgNumber];
op = [self _makeRmc: seq_num]; op = [self _makeOutRmc: seq_num];
if (debug_connection > 4) if (debug_connection > 4)
NSLog(@"building packet seq %d", seq_num); NSLog(@"building packet seq %d", seq_num);
@ -1268,7 +1274,7 @@ static int messages_received_count;
won't be right for this machine! */ won't be right for this machine! */
out_parameters = mframe_dissect_call (argframe, type, encoder); out_parameters = mframe_dissect_call (argframe, type, encoder);
[self _sendRmc: op type: METHOD_REQUEST]; [self _sendOutRmc: op type: METHOD_REQUEST];
if (debug_connection > 1) if (debug_connection > 1)
NSLog(@"Sent message to 0x%x", (gsaddr)self); NSLog(@"Sent message to 0x%x", (gsaddr)self);
@ -1284,8 +1290,10 @@ static int messages_received_count;
{ {
if (ip != nil) if (ip != nil)
{ {
DESTROY(ip);
/* this must be here to avoid trashing alloca'ed retframe */ /* this must be here to avoid trashing alloca'ed retframe */
ip = (id)-1; ip = (id)-1;
_repInCount++; /* received a reply */
} }
return; return;
} }
@ -1308,6 +1316,7 @@ static int messages_received_count;
/* Decode the exception object, and raise it. */ /* Decode the exception object, and raise it. */
id exc; id exc;
[ip decodeValueOfObjCType: @encode(id) at: &exc]; [ip decodeValueOfObjCType: @encode(id) at: &exc];
DESTROY(ip);
ip = (id)-1; ip = (id)-1;
/* xxx Is there anything else to clean up in /* xxx Is there anything else to clean up in
dissect_method_return()? */ dissect_method_return()? */
@ -1332,7 +1341,6 @@ static int messages_received_count;
if mframe_build_return() never called DECODER(), i.e. when if mframe_build_return() never called DECODER(), i.e. when
we are just returning (void).*/ we are just returning (void).*/
NSAssert(ip == (id)-1 || ip == nil, NSInternalInconsistencyException); NSAssert(ip == (id)-1 || ip == nil, NSInternalInconsistencyException);
_repInCount++; /* received a reply */
return retframe; return retframe;
} }
} }
@ -1347,12 +1355,13 @@ static int messages_received_count;
NSParameterAssert(_receivePort); NSParameterAssert(_receivePort);
NSParameterAssert (_isValid); NSParameterAssert (_isValid);
seq_num = [self _newMsgNumber]; seq_num = [self _newMsgNumber];
op = [self _makeRmc: seq_num]; op = [self _makeOutRmc: seq_num];
[op encodeValueOfObjCType: ":" at: &sel]; [op encodeValueOfObjCType: ":" at: &sel];
[op encodeValueOfObjCType: @encode(unsigned) at: &target]; [op encodeValueOfObjCType: @encode(unsigned) at: &target];
[self _sendRmc: op type: METHODTYPE_REQUEST]; [self _sendOutRmc: op type: METHODTYPE_REQUEST];
ip = [self _getReplyRmc: seq_num]; ip = [self _getReplyRmc: seq_num];
[ip decodeValueOfObjCType: @encode(char*) at: &type]; [ip decodeValueOfObjCType: @encode(char*) at: &type];
DESTROY(ip);
return type; return type;
} }
@ -1440,9 +1449,8 @@ static int messages_received_count;
} }
} }
rmc = [NSPortCoder portCoderWithReceivePort: rp rmc = [conn _makeInRmc: components];
sendPort: sp
components: components];
switch (type) switch (type)
{ {
case ROOTPROXY_REQUEST: case ROOTPROXY_REQUEST:
@ -1486,12 +1494,10 @@ static int messages_received_count;
while (conn->_requestDepth == 0 && [conn->_requestQueue count] > 0) while (conn->_requestDepth == 0 && [conn->_requestQueue count] > 0)
{ {
rmc = [conn->_requestQueue objectAtIndex: 0]; rmc = [conn->_requestQueue objectAtIndex: 0];
RETAIN(rmc);
[conn->_requestQueue removeObjectAtIndex: 0]; [conn->_requestQueue removeObjectAtIndex: 0];
M_UNLOCK(conn->_queueGate); M_UNLOCK(conn->_queueGate);
[conn _service_forwardForProxy: rmc]; [conn _service_forwardForProxy: rmc];
M_LOCK(conn->_queueGate); M_LOCK(conn->_queueGate);
RELEASE(rmc);
} }
M_UNLOCK(conn->_queueGate); M_UNLOCK(conn->_queueGate);
break; break;
@ -1554,6 +1560,7 @@ static int messages_received_count;
"-awake..." methods will get sent before the __builtin_apply! */ "-awake..." methods will get sent before the __builtin_apply! */
if (argnum == -1 && datum == 0 && type == 0) if (argnum == -1 && datum == 0 && type == 0)
{ {
[self _doneInRmc: aRmc];
return; return;
} }
@ -1579,7 +1586,7 @@ static int messages_received_count;
back to the remote application! */ back to the remote application! */
if (!_isValid) if (!_isValid)
return; return;
op = [self _makeRmc: reply_sequence_number]; op = [self _makeOutRmc: reply_sequence_number];
[op encodeValueOfObjCType: @encode(BOOL) at: &is_exception]; [op encodeValueOfObjCType: @encode(BOOL) at: &is_exception];
} }
switch (*type) switch (*type)
@ -1621,7 +1628,7 @@ static int messages_received_count;
mframe_do_call (forward_type, decoder, encoder); mframe_do_call (forward_type, decoder, encoder);
if (op != nil) if (op != nil)
{ {
[self _sendRmc: op type: METHOD_REPLY]; [self _sendOutRmc: op type: METHOD_REPLY];
} }
} }
@ -1635,11 +1642,11 @@ static int messages_received_count;
{ {
NS_DURING NS_DURING
{ {
op = [self _makeRmc: reply_sequence_number]; op = [self _makeOutRmc: reply_sequence_number];
[op encodeValueOfObjCType: @encode(BOOL) [op encodeValueOfObjCType: @encode(BOOL)
at: &is_exception]; at: &is_exception];
[op encodeBycopyObject: localException]; [op encodeBycopyObject: localException];
[self _sendRmc: op type: METHOD_REPLY]; [self _sendOutRmc: op type: METHOD_REPLY];
} }
NS_HANDLER NS_HANDLER
{ {
@ -1667,9 +1674,10 @@ static int messages_received_count;
NSParameterAssert([rmc connection] == self); NSParameterAssert([rmc connection] == self);
[rmc decodeValueOfObjCType: @encode(int) at: &sequence]; [rmc decodeValueOfObjCType: @encode(int) at: &sequence];
op = [self _makeRmc: sequence]; [self _doneInRmc: rmc];
op = [self _makeOutRmc: sequence];
[op encodeObject: rootObject]; [op encodeObject: rootObject];
[self _sendRmc: op type: ROOTPROXY_REPLY]; [self _sendOutRmc: op type: ROOTPROXY_REPLY];
} }
- (void) _service_release: (NSPortCoder*)rmc - (void) _service_release: (NSPortCoder*)rmc
@ -1702,6 +1710,7 @@ static int messages_received_count;
NSLog(@"releasing object with target (0x%x) on (0x%x) - nothing to do", NSLog(@"releasing object with target (0x%x) on (0x%x) - nothing to do",
target, (gsaddr)self); target, (gsaddr)self);
} }
[self _doneInRmc: rmc];
} }
- (void) _service_retain: (NSPortCoder*)rmc - (void) _service_retain: (NSPortCoder*)rmc
@ -1713,9 +1722,10 @@ static int messages_received_count;
NSParameterAssert (_isValid); NSParameterAssert (_isValid);
[rmc decodeValueOfObjCType: @encode(int) at: &sequence]; [rmc decodeValueOfObjCType: @encode(int) at: &sequence];
op = [self _makeRmc: sequence]; op = [self _makeOutRmc: sequence];
[rmc decodeValueOfObjCType: @encode(typeof(target)) at: &target]; [rmc decodeValueOfObjCType: @encode(typeof(target)) at: &target];
[self _doneInRmc: rmc];
if (debug_connection > 3) if (debug_connection > 3)
NSLog(@"looking to retain local object with target (0x%x) on (0x%x)", NSLog(@"looking to retain local object with target (0x%x) on (0x%x)",
@ -1773,7 +1783,7 @@ static int messages_received_count;
target, self); target, self);
} }
[self _sendRmc: op type: RETAIN_REPLY]; [self _sendOutRmc: op type: RETAIN_REPLY];
} }
- (void) shutdown - (void) shutdown
@ -1782,13 +1792,14 @@ static int messages_received_count;
NSParameterAssert(_receivePort); NSParameterAssert(_receivePort);
NSParameterAssert (_isValid); NSParameterAssert (_isValid);
op = [self _makeRmc: [self _newMsgNumber]]; op = [self _makeOutRmc: [self _newMsgNumber]];
[self _sendRmc: op type: CONNECTION_SHUTDOWN]; [self _sendOutRmc: op type: CONNECTION_SHUTDOWN];
} }
- (void) _service_shutdown: (NSPortCoder*)rmc - (void) _service_shutdown: (NSPortCoder*)rmc
{ {
NSParameterAssert (_isValid); NSParameterAssert (_isValid);
[self _doneInRmc: rmc];
[self invalidate]; [self invalidate];
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"connection waiting for request was shut down"]; format: @"connection waiting for request was shut down"];
@ -1809,10 +1820,11 @@ static int messages_received_count;
NSParameterAssert (_isValid); NSParameterAssert (_isValid);
[rmc decodeValueOfObjCType: @encode(int) at: &sequence]; [rmc decodeValueOfObjCType: @encode(int) at: &sequence];
op = [self _makeRmc: sequence]; op = [self _makeOutRmc: sequence];
[rmc decodeValueOfObjCType: ":" at: &sel]; [rmc decodeValueOfObjCType: ":" at: &sel];
[rmc decodeValueOfObjCType: @encode(unsigned) at: &target]; [rmc decodeValueOfObjCType: @encode(unsigned) at: &target];
[self _doneInRmc: rmc];
p = [self includesLocalTarget: target]; p = [self includesLocalTarget: target];
o = [p localForProxy]; o = [p localForProxy];
@ -1827,7 +1839,7 @@ static int messages_received_count;
else else
type = ""; type = "";
[op encodeValueOfObjCType: @encode(char*) at: &type]; [op encodeValueOfObjCType: @encode(char*) at: &type];
[self _sendRmc: op type: METHODTYPE_REPLY]; [self _sendOutRmc: op type: METHODTYPE_REPLY];
} }
@ -1869,23 +1881,15 @@ static int messages_received_count;
} }
M_LOCK(_queueGate); M_LOCK(_queueGate);
} }
if (rmc != nil)
{
RETAIN(rmc);
NSMapRemove(_replyMap, (void*)sn);
}
M_UNLOCK(_queueGate); M_UNLOCK(_queueGate);
return rmc; return rmc;
} }
- (NSPortCoder*) _makeRmc: (int)sequence
{
NSPortCoder *coder;
NSParameterAssert(_isValid);
coder = [NSPortCoder portCoderWithReceivePort: [self receivePort]
sendPort: [self sendPort]
components: nil];
[coder encodeValueOfObjCType: @encode(int) at: &sequence];
return coder;
}
- (int) _newMsgNumber - (int) _newMsgNumber
{ {
int n; int n;
@ -1897,9 +1901,74 @@ static int messages_received_count;
return n; return n;
} }
- (void) _sendRmc: (NSPortCoder*)c type: (int)msgid - (void) _doneInRmc: (NSPortCoder*)c
{
M_LOCK(_refGate);
if (_cachedDecoder == nil)
{
_cachedDecoder = c;
[c dispatch]; /* make coder release connection */
}
else
{
RELEASE(c);
}
M_UNLOCK(_refGate);
}
- (NSPortCoder*) _makeInRmc: (NSMutableArray*)components
{
NSPortCoder *coder;
NSParameterAssert(_isValid);
M_LOCK(_refGate);
if (_cachedDecoder == nil)
{
coder = [NSPortCoder allocWithZone: NSDefaultMallocZone()];
}
else
{
coder = _cachedDecoder;
_cachedDecoder = nil;
}
M_UNLOCK(_refGate);
coder = [coder initWithReceivePort: _receivePort
sendPort: _sendPort
components: components];
return coder;
}
- (NSPortCoder*) _makeOutRmc: (int)sequence
{
NSPortCoder *coder;
NSParameterAssert(_isValid);
M_LOCK(_refGate);
if (_cachedEncoder == nil)
{
coder = [NSPortCoder allocWithZone: NSDefaultMallocZone()];
}
else
{
coder = _cachedEncoder;
_cachedEncoder = nil;
}
M_UNLOCK(_refGate);
coder = [coder initWithReceivePort: _receivePort
sendPort: _sendPort
components: nil];
[coder encodeValueOfObjCType: @encode(int) at: &sequence];
return coder;
}
- (void) _sendOutRmc: (NSPortCoder*)c type: (int)msgid
{ {
NSDate *limit; NSDate *limit;
BOOL sent = NO;
BOOL raiseException = NO; BOOL raiseException = NO;
NSMutableArray *components = [c _components]; NSMutableArray *components = [c _components];
@ -1910,17 +1979,32 @@ static int messages_received_count;
d = [[self delegate] authenticationDataForComponents: components]; d = [[self delegate] authenticationDataForComponents: components];
if (d == nil) if (d == nil)
{ {
RELEASE(c);
[NSException raise: NSGenericException [NSException raise: NSGenericException
format: @"Bad authentication data provided by delegate"]; format: @"Bad authentication data provided by delegate"];
} }
[components addObject: d]; [components addObject: d];
} }
limit = [NSDate dateWithTimeIntervalSinceNow: [self requestTimeout]]; limit = [NSDate dateWithTimeIntervalSinceNow: [self requestTimeout]];
if ([_sendPort sendBeforeDate: limit sent = [_sendPort sendBeforeDate: limit
msgid: msgid msgid: msgid
components: components components: components
from: _receivePort from: _receivePort
reserved: [_sendPort reservedSpaceLength]] == NO) reserved: [_sendPort reservedSpaceLength]];
M_LOCK(_refGate);
if (_cachedEncoder == nil)
{
_cachedEncoder = c;
[c dispatch]; /* make coder release connection */
}
else
{
RELEASE(c);
}
M_UNLOCK(_refGate);
if (sent == NO)
{ {
NSString *text; NSString *text;
@ -2115,7 +2199,7 @@ static int messages_received_count;
unsigned i; unsigned i;
int sequence = [self _newMsgNumber]; int sequence = [self _newMsgNumber];
op = [self _makeRmc: sequence]; op = [self _makeOutRmc: sequence];
[op encodeValueOfObjCType: @encode(unsigned) at: &number]; [op encodeValueOfObjCType: @encode(unsigned) at: &number];
@ -2127,7 +2211,7 @@ static int messages_received_count;
list[i], (gsaddr)self); list[i], (gsaddr)self);
} }
[self _sendRmc: op type: PROXY_RELEASE]; [self _sendOutRmc: op type: PROXY_RELEASE];
} }
} }
NS_HANDLER NS_HANDLER
@ -2153,12 +2237,13 @@ static int messages_received_count;
id result; id result;
int seq_num = [self _newMsgNumber]; int seq_num = [self _newMsgNumber];
op = [self _makeRmc: seq_num]; op = [self _makeOutRmc: seq_num];
[op encodeValueOfObjCType: @encode(typeof(target)) at: &target]; [op encodeValueOfObjCType: @encode(typeof(target)) at: &target];
[self _sendRmc: op type: PROXY_RETAIN]; [self _sendOutRmc: op type: PROXY_RETAIN];
ip = [self _getReplyRmc: seq_num]; ip = [self _getReplyRmc: seq_num];
[ip decodeValueOfObjCType: @encode(id) at: &result]; [ip decodeValueOfObjCType: @encode(id) at: &result];
DESTROY(ip);
if (result != nil) if (result != nil)
NSLog(@"failed to retain target - %@", result); NSLog(@"failed to retain target - %@", result);
} }

View file

@ -240,8 +240,10 @@ typeCheck(char t1, char t2)
@public @public
Class class; Class class;
unsigned version; unsigned version;
NSString *name;
} }
+ (id) newWithClass: (Class)c andVersion: (unsigned)v; + (id) newWithClass: (Class)c andVersion: (unsigned)v;
- (NSString*) className;
@end @end
@implementation GSClassInfo @implementation GSClassInfo
@ -257,8 +259,17 @@ typeCheck(char t1, char t2)
} }
return info; return info;
} }
- (NSString*) className
{
if (name == nil)
{
name = RETAIN(NSStringFromClass(class));
}
return name;
}
- (void) dealloc - (void) dealloc
{ {
TEST_RELEASE(name);
NSDeallocateObject(self); NSDeallocateObject(self);
} }
@end @end
@ -278,8 +289,6 @@ typeCheck(char t1, char t2)
classes: (unsigned)c classes: (unsigned)c
objects: (unsigned)o objects: (unsigned)o
pointers: (unsigned)p; pointers: (unsigned)p;
- (id) _setupForDecoding;
- (id) _setupForEncoding;
@end @end
@ -622,7 +631,6 @@ typeCheck(char t1, char t2)
while ((info & _GSC_MASK) == _GSC_CLASS) while ((info & _GSC_MASK) == _GSC_CLASS)
{ {
unsigned cver; unsigned cver;
NSString *className;
if (xref != GSIArrayCount(_clsAry)) if (xref != GSIArrayCount(_clsAry))
{ {
@ -637,14 +645,9 @@ typeCheck(char t1, char t2)
[NSException raise: NSInternalInconsistencyException [NSException raise: NSInternalInconsistencyException
format: @"decoded nil class"]; format: @"decoded nil class"];
} }
className = NSStringFromClass(c); classInfo = [GSClassInfo newWithClass: c andVersion: cver];
classInfo = [_cInfo objectForKey: className]; [_cInfo addObject: classInfo];
if (classInfo == nil) RELEASE(classInfo);
{
classInfo = [GSClassInfo newWithClass: c andVersion: cver];
[_cInfo setObject: classInfo forKey: className];
RELEASE(classInfo);
}
GSIArrayAddItem(_clsAry, (GSIArrayItem)classInfo); GSIArrayAddItem(_clsAry, (GSIArrayItem)classInfo);
*(Class*)address = classInfo->class; *(Class*)address = classInfo->class;
/* /*
@ -985,6 +988,12 @@ typeCheck(char t1, char t2)
- (void) dispatch - (void) dispatch
{ {
/*
* Get ready for re-use
* Make sure that we don't retain the connection - or it might never be
* released if it is keeping this coder in a cache.
*/
DESTROY(_conn);
} }
- (void) encodeArrayOfObjCType: (const char*)type - (void) encodeArrayOfObjCType: (const char*)type
@ -1610,24 +1619,180 @@ typeCheck(char t1, char t2)
sendPort: (NSPort*)send sendPort: (NSPort*)send
components: (NSArray*)comp components: (NSArray*)comp
{ {
self = [super init]; BOOL firstTime;
if (self != nil)
_conn = RETAIN([NSConnection connectionWithReceivePort: recv
sendPort: send]);
if (_comp == nil)
{ {
firstTime = YES;
_version = [super systemVersion]; _version = [super systemVersion];
_zone = NSDefaultMallocZone(); _zone = NSDefaultMallocZone();
_conn = RETAIN([NSConnection connectionWithReceivePort: recv }
sendPort: send]); else
{
NSAssert(recv == [_conn receivePort] && send == [_conn sendPort],
NSInvalidArgumentException);
/*
* Re-initialising - destroy old components.
*/
firstTime = NO;
}
if (comp == nil) if (comp == nil)
{
NS_DURING
{ {
_comp = [NSMutableArray new]; _encodingRoot = NO;
self = [self _setupForEncoding]; _initialPass = NO;
_xRefC = 0;
_xRefO = 0;
_xRefP = 0;
_cursor = [send reservedSpaceLength];
if (firstTime == YES)
{
/*
* Set up mutable data object to encode into - reserve space at
* the start for use by the port when the encoded data is sent.
* Make the data item the first component of the array.
*/
_comp = [NSMutableArray new];
_dst = [_fastCls._NSMutableDataMalloc allocWithZone: _zone];
_dst = [_dst initWithLength: _cursor];
[_comp addObject: _dst];
RELEASE(_dst);
/*
* Cache method implementations for writing into data object etc
*/
_eSerImp = [_dst methodForSelector: eSerSel];
_eTagImp = [_dst methodForSelector: eTagSel];
_xRefImp = [_dst methodForSelector: xRefSel];
_eObjImp = [self methodForSelector: eObjSel];
_eValImp = [self methodForSelector: eValSel];
/*
* Set up map tables.
*/
_clsMap
= (GSIMapTable)NSZoneMalloc(_zone, sizeof(GSIMapTable_t)*4);
_cIdMap = &_clsMap[1];
_uIdMap = &_clsMap[2];
_ptrMap = &_clsMap[3];
GSIMapInitWithZoneAndCapacity(_clsMap, _zone, 100);
GSIMapInitWithZoneAndCapacity(_cIdMap, _zone, 10);
GSIMapInitWithZoneAndCapacity(_uIdMap, _zone, 200);
GSIMapInitWithZoneAndCapacity(_ptrMap, _zone, 100);
}
else
{
unsigned count;
/*
* If re-initialising, we just need to empty the old stuff.
*/
count = [_comp count];
while (count-- > 1)
{
[_comp removeObjectAtIndex: count];
}
[_dst setLength: _cursor];
GSIMapCleanMap(_clsMap);
GSIMapCleanMap(_cIdMap);
GSIMapCleanMap(_uIdMap);
GSIMapCleanMap(_ptrMap);
}
/*
* Write dummy header
*/
[self _serializeHeaderAt: _cursor
version: 0
classes: 0
objects: 0
pointers: 0];
} }
else NS_HANDLER
{ {
_comp = [comp mutableCopy]; NSLog(@"Exception setting up port coder for encoding - %@",
self = [self _setupForDecoding]; localException);
DESTROY(self);
} }
NS_ENDHANDLER
}
else
{
RELEASE(_comp);
_comp = [comp mutableCopy];
NS_DURING
{
unsigned sizeC;
unsigned sizeO;
unsigned sizeP;
if (firstTime == YES)
{
_dValImp = [self methodForSelector: dValSel];
}
_src = [_comp objectAtIndex: 0];
_dDesImp = [_src methodForSelector: dDesSel];
_dTagImp = (void (*)(id, SEL, unsigned char*, unsigned*, unsigned*))
[_src methodForSelector: dTagSel];
/*
* _cInfo is a dictionary of objects for keeping track of the
* version numbers that the classes were encoded with.
*/
if (firstTime == YES)
{
_cInfo
= [[NSMutableArray allocWithZone: _zone] initWithCapacity: 16];
}
else
{
[_cInfo removeAllObjects];
}
/*
* Read header including version and crossref table sizes.
*/
_cursor = 0;
[self _deserializeHeaderAt: &_cursor
version: &_version
classes: &sizeC
objects: &sizeO
pointers: &sizeP];
/*
* Allocate and initialise arrays to build crossref maps in.
*/
if (firstTime == YES)
{
_clsAry = NSZoneMalloc(_zone, sizeof(GSIArray_t)*3);
_objAry = &_clsAry[1];
_ptrAry = &_clsAry[2];
GSIArrayInitWithZoneAndCapacity(_clsAry, _zone, sizeC);
GSIArrayInitWithZoneAndCapacity(_objAry, _zone, sizeO);
GSIArrayInitWithZoneAndCapacity(_ptrAry, _zone, sizeP);
}
else
{
GSIArrayRemoveAllItems(_clsAry);
GSIArrayRemoveAllItems(_objAry);
GSIArrayRemoveAllItems(_ptrAry);
}
GSIArrayAddItem(_clsAry, (GSIArrayItem)0);
GSIArrayAddItem(_objAry, (GSIArrayItem)0);
GSIArrayAddItem(_ptrAry, (GSIArrayItem)0);
}
NS_HANDLER
{
NSLog(@"Exception setting up port coder for decoding - %@",
localException);
DESTROY(self);
}
NS_ENDHANDLER
} }
return self; return self;
} }
@ -1661,11 +1826,15 @@ typeCheck(char t1, char t2)
{ {
GSClassInfo *info; GSClassInfo *info;
unsigned version = NSNotFound; unsigned version = NSNotFound;
unsigned count = [_cInfo count];
info = [_cInfo objectForKey: className]; while (--count > 0)
if (info != nil)
{ {
version = info->version; info = [_cInfo objectAtIndex: count];
if ([[info className] isEqual: className] == YES)
{
version = info->version;
}
} }
return version; return version;
} }
@ -1734,122 +1903,5 @@ typeCheck(char t1, char t2)
} }
} }
- (id) _setupForDecoding
{
NS_DURING
{
unsigned sizeC;
unsigned sizeO;
unsigned sizeP;
_dValImp = [self methodForSelector: dValSel];
_src = [_comp objectAtIndex: 0];
_dDesImp = [_src methodForSelector: dDesSel];
_dTagImp = (void (*)(id, SEL, unsigned char*, unsigned*, unsigned*))
[_src methodForSelector: dTagSel];
/*
* _cInfo is a dictionary of objects for keeping track of the
* version numbers that the classes were encoded with.
*/
_cInfo
= [[NSMutableDictionary allocWithZone: _zone] initWithCapacity: 200];
/*
* Read header including version and crossref table sizes.
*/
_cursor = 0;
[self _deserializeHeaderAt: &_cursor
version: &_version
classes: &sizeC
objects: &sizeO
pointers: &sizeP];
/*
* Allocate and initialise arrays to build crossref maps in.
*/
_clsAry = NSZoneMalloc(_zone, sizeof(GSIArray_t)*3);
GSIArrayInitWithZoneAndCapacity(_clsAry, _zone, sizeC);
GSIArrayAddItem(_clsAry, (GSIArrayItem)0);
_objAry = &_clsAry[1];
GSIArrayInitWithZoneAndCapacity(_objAry, _zone, sizeO);
GSIArrayAddItem(_objAry, (GSIArrayItem)0);
_ptrAry = &_clsAry[2];
GSIArrayInitWithZoneAndCapacity(_ptrAry, _zone, sizeP);
GSIArrayAddItem(_ptrAry, (GSIArrayItem)0);
}
NS_HANDLER
{
NSLog(@"Exception setting up port coder for decoding - %@",
localException);
DESTROY(self);
}
NS_ENDHANDLER
return self;
}
- (id) _setupForEncoding
{
NS_DURING
{
/*
* Set up mutable data object to encode into - reserve space at the
* start for use by the port when the encoded data is sent.
* Make the data item the first component of the array.
*/
_cursor = [[_conn sendPort] reservedSpaceLength];
_dst = [_fastCls._NSMutableDataMalloc allocWithZone: fastZone(self)];
_dst = [_dst initWithLength: _cursor];
[_comp addObject: _dst];
RELEASE(_dst);
/*
* Cache method implementations for writing into data object etc
*/
_eSerImp = [_dst methodForSelector: eSerSel];
_eTagImp = [_dst methodForSelector: eTagSel];
_xRefImp = [_dst methodForSelector: xRefSel];
_eObjImp = [self methodForSelector: eObjSel];
_eValImp = [self methodForSelector: eValSel];
_encodingRoot = NO;
_initialPass = NO;
_xRefC = 0;
_xRefO = 0;
_xRefP = 0;
/*
* Set up map tables.
*/
_clsMap = (GSIMapTable)NSZoneMalloc(_zone, sizeof(GSIMapTable_t)*4);
_cIdMap = &_clsMap[1];
_uIdMap = &_clsMap[2];
_ptrMap = &_clsMap[3];
GSIMapInitWithZoneAndCapacity(_clsMap, _zone, 100);
GSIMapInitWithZoneAndCapacity(_cIdMap, _zone, 10);
GSIMapInitWithZoneAndCapacity(_uIdMap, _zone, 200);
GSIMapInitWithZoneAndCapacity(_ptrMap, _zone, 100);
/*
* Write dummy header
*/
[self _serializeHeaderAt: _cursor
version: 0
classes: 0
objects: 0
pointers: 0];
}
NS_HANDLER
{
NSLog(@"Exception setting up port coder for encoding - %@",
localException);
DESTROY(self);
}
NS_ENDHANDLER
return self;
}
@end @end

View file

@ -254,7 +254,7 @@ decodePort(NSData *data)
} }
static NSData* static NSData*
encodePort(GSTcpPort *port) newDataWithEncodedPort(GSTcpPort *port)
{ {
GSPortItemHeader *pih; GSPortItemHeader *pih;
GSPortInfo *pi; GSPortInfo *pi;
@ -288,7 +288,7 @@ encodePort(GSTcpPort *port)
} }
} }
plen = [addr cStringLength] + 3; plen = [addr cStringLength] + 3;
data = [NSMutableData dataWithLength: sizeof(GSPortItemHeader) + plen]; data = [[NSMutableData alloc] initWithLength: sizeof(GSPortItemHeader)+plen];
pih = (GSPortItemHeader*)[data mutableBytes]; pih = (GSPortItemHeader*)[data mutableBytes];
pih->type = GSSwapHostI32ToBig(GSP_PORT); pih->type = GSSwapHostI32ToBig(GSP_PORT);
pih->length = GSSwapHostI32ToBig(plen); pih->length = GSSwapHostI32ToBig(plen);
@ -488,13 +488,15 @@ encodePort(GSTcpPort *port)
{ {
NSPortMessage *pm; NSPortMessage *pm;
pm = [[NSPortMessage alloc] initWithSendPort: [self sendPort] pm = [NSPortMessage allocWithZone: NSDefaultMallocZone()];
receivePort: [self recvPort] pm = [pm initWithSendPort: [self sendPort]
components: rItems]; receivePort: [self recvPort]
components: rItems];
[pm setMsgid: rId]; [pm setMsgid: rId];
rId = 0; rId = 0;
DESTROY(rItems); DESTROY(rItems);
[[self recvPort] handlePortMessage: AUTORELEASE(pm)]; [[self recvPort] handlePortMessage: pm];
RELEASE(pm);
} }
- (void) gcFinalize - (void) gcFinalize
@ -596,7 +598,7 @@ encodePort(GSTcpPort *port)
[self invalidate]; [self invalidate];
return; return;
} }
else if (errno != EINTR) else if (errno != EINTR && errno != EAGAIN)
{ {
NSLog(@"read attempt failed - %s", strerror(errno)); NSLog(@"read attempt failed - %s", strerror(errno));
[self invalidate]; [self invalidate];
@ -634,6 +636,8 @@ encodePort(GSTcpPort *port)
} }
else if (rType == GSP_DATA && l == 0) else if (rType == GSP_DATA && l == 0)
{ {
NSData *d;
/* /*
* For a zero-length data chunk, we create an empty * For a zero-length data chunk, we create an empty
* data object and add it to the current message. * data object and add it to the current message.
@ -644,7 +648,9 @@ encodePort(GSTcpPort *port)
memcpy(bytes, bytes + rWant, rLength); memcpy(bytes, bytes + rWant, rLength);
} }
rWant = sizeof(GSPortItemHeader); rWant = sizeof(GSPortItemHeader);
[rItems addObject: [NSData data]]; d = [NSData new];
[rItems addObject: d];
RELEASE(d);
if (nItems == [rItems count]) if (nItems == [rItems count])
{ {
[self dispatch]; [self dispatch];
@ -799,7 +805,7 @@ encodePort(GSTcpPort *port)
} }
else else
{ {
NSData *d = encodePort([self recvPort]); NSData *d = newDataWithEncodedPort([self recvPort]);
len = write(desc, [d bytes], [d length]); len = write(desc, [d bytes], [d length]);
if (len == [d length]) if (len == [d length])
@ -812,6 +818,7 @@ encodePort(GSTcpPort *port)
state = GS_H_UNCON; state = GS_H_UNCON;
NSLog(@"connect write attempt failed - %s", strerror(errno)); NSLog(@"connect write attempt failed - %s", strerror(errno));
} }
RELEASE(d);
} }
} }
else else
@ -840,7 +847,7 @@ encodePort(GSTcpPort *port)
res = write(desc, b + wLength, l - wLength); res = write(desc, b + wLength, l - wLength);
if (res < 0) if (res < 0)
{ {
if (errno != EINTR) if (errno != EINTR && errno != EAGAIN)
{ {
NSLog(@"write attempt failed - %s", strerror(errno)); NSLog(@"write attempt failed - %s", strerror(errno));
[self invalidate]; [self invalidate];
@ -1631,7 +1638,7 @@ static NSMapTable *tcpPortMap = 0;
NSMutableData *d; NSMutableData *d;
pack = NO; pack = NO;
d = [NSMutableData dataWithLength: l + h]; d = [[NSMutableData alloc] initWithLength: l + h];
b = [d mutableBytes]; b = [d mutableBytes];
pih = (GSPortItemHeader*)b; pih = (GSPortItemHeader*)b;
memcpy(b+h, [o bytes], l); memcpy(b+h, [o bytes], l);
@ -1639,11 +1646,12 @@ static NSMapTable *tcpPortMap = 0;
pih->length = GSSwapHostI32ToBig(l); pih->length = GSSwapHostI32ToBig(l);
[components replaceObjectAtIndex: i [components replaceObjectAtIndex: i
withObject: d]; withObject: d];
RELEASE(d);
} }
} }
else if ([o isKindOfClass: [GSTcpPort class]]) else if ([o isKindOfClass: [GSTcpPort class]])
{ {
NSData *d = encodePort(o); NSData *d = newDataWithEncodedPort(o);
unsigned dLength = [d length]; unsigned dLength = [d length];
if (pack == YES && hLength + dLength <= NETBLOCK) if (pack == YES && hLength + dLength <= NETBLOCK)
@ -1663,6 +1671,7 @@ static NSMapTable *tcpPortMap = 0;
pack = NO; pack = NO;
[components replaceObjectAtIndex: i withObject: d]; [components replaceObjectAtIndex: i withObject: d];
} }
RELEASE(d);
} }
} }

View file

@ -107,6 +107,7 @@
* these are set up at process startup or in [NSData +initialize] * these are set up at process startup or in [NSData +initialize]
*/ */
static SEL appendSel = @selector(appendBytes:length:); static SEL appendSel = @selector(appendBytes:length:);
static Class dataStatic;
static Class dataMalloc; static Class dataMalloc;
static Class mutableDataMalloc; static Class mutableDataMalloc;
static IMP appendImp; static IMP appendImp;
@ -326,6 +327,7 @@ failure:
if (self == [NSData class]) if (self == [NSData class])
{ {
dataMalloc = [NSDataMalloc class]; dataMalloc = [NSDataMalloc class];
dataStatic = [NSDataStatic class];
mutableDataMalloc = [NSMutableDataMalloc class]; mutableDataMalloc = [NSMutableDataMalloc class];
appendImp = [mutableDataMalloc instanceMethodForSelector: appendSel]; appendImp = [mutableDataMalloc instanceMethodForSelector: appendSel];
} }
@ -397,6 +399,15 @@ failure:
return AUTORELEASE(d); return AUTORELEASE(d);
} }
+ (id) new
{
NSData *d;
d = [dataMalloc allocWithZone: NSDefaultMallocZone()];
d = [d initWithBytesNoCopy: 0 length: 0 fromZone: NSDefaultMallocZone()];
return d;
}
- (id) init - (id) init
{ {
return [self initWithBytesNoCopy: 0 length: 0]; return [self initWithBytesNoCopy: 0 length: 0];
@ -1335,6 +1346,15 @@ failure:
return AUTORELEASE(d); return AUTORELEASE(d);
} }
+ (id) new
{
NSMutableData *d;
d = [mutableDataMalloc allocWithZone: NSDefaultMallocZone()];
d = [d initWithCapacity: 0];
return d;
}
- (const void*) bytes - (const void*) bytes
{ {
return [self mutableBytes]; return [self mutableBytes];

View file

@ -101,7 +101,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
return NSAllocateObject(self, 0, NSDefaultMallocZone()); return NSAllocateObject(self, 0, NSDefaultMallocZone());
} }
- (void)dealloc - (void) dealloc
{ {
if (_zone) if (_zone)
{ {
@ -114,9 +114,7 @@ static IMP msInitImp; /* designated initialiser for mutable */
- (unsigned) hash - (unsigned) hash
{ {
if (_hash == 0) if (_hash == 0)
{ _hash = _fastImp._NSString_hash(self, @selector(hash));
_hash = _fastImp._NSString_hash(self, @selector(hash));
}
return _hash; return _hash;
} }
@ -1276,7 +1274,35 @@ stringDecrementCountAndFillHoleAt(NSGMutableCStringStruct *self,
- (unsigned) hash - (unsigned) hash
{ {
return _fastImp._NSString_hash(self, @selector(hash)); unsigned ret = 0;
int len = _count;
if (len > NSHashStringLength)
len = NSHashStringLength;
if (len)
{
const unsigned char *p;
unsigned char_count = 0;
p = _contents_chars;
while (*p && char_count++ < NSHashStringLength)
{
ret = (ret << 5) + ret + *p++;
}
/*
* The hash caching in our concrete string classes uses zero to denote
* an empty cache value, so we MUST NOT return a hash of zero.
*/
if (ret == 0)
ret = 0xffffffff;
}
else
{
ret = 0xfffffffe; /* Hash for an empty string. */
}
return ret;
} }
- (BOOL) isEqual: (id)anObject - (BOOL) isEqual: (id)anObject

View file

@ -63,7 +63,14 @@ myHash(id obj)
} }
else if (c == _fastCls._NXConstantString) else if (c == _fastCls._NXConstantString)
{ {
return _fastImp._NSString_hash(obj, @selector(hash)); static unsigned (*myImp)(id,SEL) = 0;
if (myImp == 0)
{
myImp = (unsigned (*)(id,SEL))
[obj methodForSelector: @selector(hash)];
}
return (*myImp)(obj, @selector(hash));
} }
} }
return [obj hash]; return [obj hash];

View file

@ -595,6 +595,7 @@ static BOOL double_release_check_enabled = NO;
{ {
if (self == [NSObject class]) if (self == [NSObject class])
{ {
extern void GSBuildStrings(); // See externs.m
#ifdef __FreeBSD__ #ifdef __FreeBSD__
// Manipulate the FPU to add the exception mask. (Fixes SIGFPE // Manipulate the FPU to add the exception mask. (Fixes SIGFPE
// problems on *BSD) // problems on *BSD)
@ -621,6 +622,7 @@ static BOOL double_release_check_enabled = NO;
fastMallocOffset = 0; fastMallocOffset = 0;
#endif #endif
_fastBuildCache(); _fastBuildCache();
GSBuildStrings();
[[NSNotificationCenter defaultCenter] [[NSNotificationCenter defaultCenter]
addObserver: self addObserver: self
selector: @selector(_becomeMultiThreaded:) selector: @selector(_becomeMultiThreaded:)

View file

@ -35,17 +35,22 @@
@implementation NSPort @implementation NSPort
Class _abstractClass;
Class _concreteClass; Class _concreteClass;
+ (id) allocWithZone: (NSZone*)aZone + (id) allocWithZone: (NSZone*)aZone
{ {
return [super allocWithZone: aZone]; if (self == _abstractClass)
return NSAllocateObject(_concreteClass, 0, aZone);
else
return [super allocWithZone: aZone];
} }
+ (void) initialize + (void) initialize
{ {
if (self == [NSPort class]) if (self == [NSPort class])
{ {
_abstractClass = self;
_concreteClass = [GSTcpPort class]; _concreteClass = [GSTcpPort class];
} }
} }
@ -148,7 +153,7 @@ Class _concreteClass;
- (void) setDelegate: (id) anObject - (void) setDelegate: (id) anObject
{ {
NSAssert([anObject respondsToSelector: @selector(handlePortMessage:)], NSAssert([anObject respondsToSelector: @selector(handlePortMessage:)],
NSInvalidArgumentException); NSInvalidArgumentException);
_delegate = anObject; _delegate = anObject;
} }

View file

@ -22,86 +22,69 @@
*/ */
#include <config.h> #include <config.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSString.h> #include <Foundation/NSString.h>
#include <Foundation/NSArray.h>
#include <Foundation/NSException.h> #include <Foundation/NSException.h>
#include <Foundation/NSMapTable.h> #include <Foundation/NSMapTable.h>
#include "NSCallBacks.h" #include "NSCallBacks.h"
#include <Foundation/NSHashTable.h> #include <Foundation/NSHashTable.h>
#include <Foundation/NSLock.h>
/* Global lock to be used by classes when operating on any global /* Global lock to be used by classes when operating on any global
data that invoke other methods which also access global; thus, data that invoke other methods which also access global; thus,
creating the potential for deadlock. */ creating the potential for deadlock. */
@class NSRecursiveLock;
NSRecursiveLock *gnustep_global_lock = nil; NSRecursiveLock *gnustep_global_lock = nil;
/* /*
* Connection Notification Strings. * Connection Notification Strings.
*/ */
NSString* const NSConnectionDidDieNotification NSString *NSConnectionDidDieNotification;
= @"NSConnectionDidDieNotification"; NSString *NSConnectionDidInitializeNotification;
NSString* const NSConnectionDidInitializeNotification
= @"NSConnectionDidInitializeNotification";
/* /*
* NSThread Notifications * NSThread Notifications
*/ */
NSString* const NSWillBecomeMultiThreadedNotification NSString *NSWillBecomeMultiThreadedNotification;
= @"NSWillBecomeMultiThreadedNotification"; NSString *NSThreadWillExitNotification;
NSString* const NSThreadWillExitNotification
= @"NSThreadWillExitNotification";
/* /*
* Port Notifications * Port Notifications
*/ */
NSString* const PortBecameInvalidNotification = NSString *PortBecameInvalidNotification;
@"PortBecameInvalidNotification"; NSString *InPortClientBecameInvalidNotification;
NSString* const InPortClientBecameInvalidNotification = NSString *InPortAcceptedClientNotification;
@"InPortClientBecameInvalidNotification";
NSString* const InPortAcceptedClientNotification =
@"InPortAcceptedClientNotification";
NSString* const NSPortDidBecomeInvalidNotification NSString *NSPortDidBecomeInvalidNotification;
= @"NSPortDidBecomeInvalidNotification";
/* RunLoop modes */ /* RunLoop modes */
NSString* const NSDefaultRunLoopMode NSString *NSDefaultRunLoopMode;
= @"NSDefaultRunLoopMode"; NSString *NSConnectionReplyMode;
NSString* const NSConnectionReplyMode
= @"NSConnectionReplyMode";
/* Exceptions */ /* Exceptions */
NSString* const NSCharacterConversionException NSString *NSCharacterConversionException;
= @"NSCharacterConversionException"; NSString *NSFailedAuthenticationException;
NSString* const NSFailedAuthenticationException NSString *NSGenericException;
= @"NSFailedAuthenticationException"; NSString *NSInconsistentArchiveException;
NSString* const NSGenericException NSString *NSInternalInconsistencyException;
= @"NSGenericException"; NSString *NSInvalidArgumentException;
NSString* const NSInconsistentArchiveException NSString *NSMallocException;
= @"NSInconsistentArchiveException"; NSString *NSPortTimeoutException;
NSString* const NSInternalInconsistencyException NSString *NSRangeException;
= @"NSInternalInconsistencyException";
NSString* const NSInvalidArgumentException
= @"NSInvalidArgumentException";
NSString* const NSMallocException
= @"NSMallocException";
NSString* const NSPortTimeoutException
= @"NSPortTimeoutException";
NSString* const NSRangeException
= @"NSRangeException";
/* Exception handler */ /* Exception handler */
NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler; NSUncaughtExceptionHandler *_NSUncaughtExceptionHandler;
/* NSBundle */ /* NSBundle */
NSString* const NSBundleDidLoadNotification = @"NSBundleDidLoadNotification"; NSString *NSBundleDidLoadNotification;
NSString* const NSShowNonLocalizedStrings = @"NSShowNonLocalizedStrings"; NSString *NSShowNonLocalizedStrings;
NSString* const NSLoadedClasses = @"NSLoadedClasses"; NSString *NSLoadedClasses;
/* Stream */ /* Stream */
NSString* const StreamException = @"StreamException"; NSString *StreamException;
/* /*
* File attributes names * File attributes names
@ -109,141 +92,271 @@ NSString* const StreamException = @"StreamException";
/* File Attributes */ /* File Attributes */
NSString* const NSFileDeviceIdentifier NSString *NSFileDeviceIdentifier;
= @"NSFileDeviceIdentifier"; NSString *NSFileGroupOwnerAccountName;
NSString* const NSFileGroupOwnerAccountName NSString *NSFileGroupOwnerAccountNumber;
= @"NSFileGroupOwnerAccountName"; NSString *NSFileModificationDate;
NSString* const NSFileGroupOwnerAccountNumber NSString *NSFileOwnerAccountName;
= @"NSFileGroupOwnerAccountNumber"; NSString *NSFileOwnerAccountNumber;
NSString* const NSFileModificationDate NSString *NSFilePosixPermissions;
= @"NSFileModificationDate"; NSString *NSFileReferenceCount;
NSString* const NSFileOwnerAccountName NSString *NSFileSize;
= @"NSFileOwnerAccountName"; NSString *NSFileSystemFileNumber;
NSString* const NSFileOwnerAccountNumber NSString *NSFileSystemNumber;
= @"NSFileOwnerAccountNumber"; NSString *NSFileType;
NSString* const NSFilePosixPermissions
= @"NSFilePosixPermissions";
NSString* const NSFileReferenceCount
= @"NSFileReferenceCount";
NSString* const NSFileSize
= @"NSFileSize";
NSString* const NSFileSystemFileNumber
= @"NSFileSystemFileNumber";
NSString* const NSFileSystemNumber
= @"NSFileSystemNumber";
NSString* const NSFileType
= @"NSFileType";
/* File Types */ /* File Types */
NSString* const NSFileTypeDirectory NSString *NSFileTypeDirectory;
= @"NSFileTypeDirectory"; NSString *NSFileTypeRegular;
NSString* const NSFileTypeRegular NSString *NSFileTypeSymbolicLink;
= @"NSFileTypeRegular"; NSString *NSFileTypeSocket;
NSString* const NSFileTypeSymbolicLink NSString *NSFileTypeFifo;
= @"NSFileTypeSymbolicLink"; NSString *NSFileTypeCharacterSpecial;
NSString* const NSFileTypeSocket NSString *NSFileTypeBlockSpecial;
= @"NSFileTypeSocket"; NSString *NSFileTypeUnknown;
NSString* const NSFileTypeFifo
= @"NSFileTypeFifo";
NSString* const NSFileTypeCharacterSpecial
= @"NSFileTypeCharacterSpecial";
NSString* const NSFileTypeBlockSpecial
= @"NSFileTypeBlockSpecial";
NSString* const NSFileTypeUnknown
= @"NSFileTypeUnknown";
/* FileSystem Attributes */ /* FileSystem Attributes */
NSString* const NSFileSystemSize NSString *NSFileSystemSize;
= @"NSFileSystemSize"; NSString *NSFileSystemFreeSize;
NSString* const NSFileSystemFreeSize NSString *NSFileSystemNodes;
= @"NSFileSystemFreeSize"; NSString *NSFileSystemFreeNodes;
NSString* const NSFileSystemNodes
= @"NSFileSystemNodes";
NSString* const NSFileSystemFreeNodes
= @"NSFileSystemFreeNodes";
/* Standard domains */ /* Standard domains */
NSString* const NSArgumentDomain NSString *NSArgumentDomain;
= @"NSArgumentDomain"; NSString *NSGlobalDomain;
NSString* const NSGlobalDomain NSString *NSRegistrationDomain;
= @"NSGlobalDomain";
NSString* const NSRegistrationDomain
= @"NSRegistrationDomain";
/* Public notification */ /* Public notification */
NSString* const NSUserDefaultsDidChangeNotification NSString *NSUserDefaultsDidChangeNotification;
= @"NSUserDefaultsDidChangeNotification";
/* Keys for language-dependent information */ /* Keys for language-dependent information */
NSString* const NSWeekDayNameArray NSString *NSWeekDayNameArray;
= @"NSWeekDayNameArray"; NSString *NSShortWeekDayNameArray;
NSString* const NSShortWeekDayNameArray NSString *NSMonthNameArray;
= @"NSShortWeekDayNameArray"; NSString *NSShortMonthNameArray;
NSString* const NSMonthNameArray NSString *NSTimeFormatString;
= @"NSMonthNameArray"; NSString *NSDateFormatString;
NSString* const NSShortMonthNameArray NSString *NSTimeDateFormatString;
= @"NSShortMonthNameArray"; NSString *NSShortTimeDateFormatString;
NSString* const NSTimeFormatString NSString *NSCurrencySymbol;
= @"NSTimeFormatString"; NSString *NSDecimalSeparator;
NSString* const NSDateFormatString NSString *NSThousandsSeparator;
= @"NSDateFormatString"; NSString *NSInternationalCurrencyString;
NSString* const NSTimeDateFormatString NSString *NSCurrencyString;
= @"NSTimeDateFormatString"; NSString *NSDecimalDigits;
NSString* const NSShortTimeDateFormatString NSString *NSAMPMDesignation;
= @"NSShortTimeDateFormatString";
NSString* const NSCurrencySymbol
= @"NSCurrencySymbol";
NSString* const NSDecimalSeparator
= @"NSDecimalSeparator";
NSString* const NSThousandsSeparator
= @"NSThousandsSeparator";
NSString* const NSInternationalCurrencyString
= @"NSInternationalCurrencyString";
NSString* const NSCurrencyString
= @"NSCurrencyString";
NSString* const NSDecimalDigits
= @"NSDecimalDigits";
NSString* const NSAMPMDesignation
= @"NSAMPMDesignation";
NSString* const NSHourNameDesignations NSString *NSHourNameDesignations;
= @"NSHourNameDesignations"; NSString *NSYearMonthWeekDesignations;
NSString* const NSYearMonthWeekDesignations NSString *NSEarlierTimeDesignations;
= @"NSYearMonthWeekDesignations"; NSString *NSLaterTimeDesignations;
NSString* const NSEarlierTimeDesignations NSString *NSThisDayDesignations;
= @"NSEarlierTimeDesignations"; NSString *NSNextDayDesignations;
NSString* const NSLaterTimeDesignations NSString *NSNextNextDayDesignations;
= @"NSLaterTimeDesignations"; NSString *NSPriorDayDesignations;
NSString* const NSThisDayDesignations NSString *NSDateTimeOrdering;
= @"NSThisDayDesignations";
NSString* const NSNextDayDesignations
= @"NSNextDayDesignations";
NSString* const NSNextNextDayDesignations
= @"NSNextNextDayDesignations";
NSString* const NSPriorDayDesignations
= @"NSPriorDayDesignations";
NSString* const NSDateTimeOrdering
= @"NSDateTimeOrdering";
/* /*
* Keys for the NSDictionary returned by [NSConnection -statistics] * Keys for the NSDictionary returned by [NSConnection -statistics]
*/ */
/* These in OPENSTEP 4.2 */ /* These in OPENSTEP 4.2 */
NSString* const NSConnectionRepliesReceived NSString *NSConnectionRepliesReceived;
= @"NSConnectionRepliesReceived"; NSString *NSConnectionRepliesSent;
NSString* const NSConnectionRepliesSent NSString *NSConnectionRequestsReceived;
= @"NSConnectionRepliesSent"; NSString *NSConnectionRequestsSent;
NSString* const NSConnectionRequestsReceived
= @"NSConnectionRequestsReceived";
NSString* const NSConnectionRequestsSent
= @"NSConnectionRequestsSent";
/* These Are GNUstep extras */ /* These Are GNUstep extras */
NSString* const NSConnectionLocalCount NSString *NSConnectionLocalCount;
= @"NSConnectionLocalCount"; NSString *NSConnectionProxyCount;
NSString* const NSConnectionProxyCount
= @"NSConnectionProxyCount"; /*
* Setup function called when NSObject is initialised.
* We make all the constant strings not be NXConstantString so they can
* cache their hash values and be used much more efficiently as keys in
* dictionaries etc.
*/
void
GSBuildStrings()
{
static BOOL beenHere = NO;
if (beenHere == NO)
{
beenHere = YES;
InPortAcceptedClientNotification
= [[NSString alloc] initWithCString:
"InPortAcceptedClientNotification"];
InPortClientBecameInvalidNotification
= [[NSString alloc] initWithCString:
"InPortClientBecameInvalidNotification"];
NSAMPMDesignation
= [[NSString alloc] initWithCString: "NSAMPMDesignation"];
NSArgumentDomain
= [[NSString alloc] initWithCString: "NSArgumentDomain"];
NSBundleDidLoadNotification
= [[NSString alloc] initWithCString: "NSBundleDidLoadNotification"];
NSCharacterConversionException
= [[NSString alloc] initWithCString: "NSCharacterConversionException"];
NSConnectionDidDieNotification
= [[NSString alloc] initWithCString: "NSConnectionDidDieNotification"];
NSConnectionDidInitializeNotification
= [[NSString alloc] initWithCString:
"NSConnectionDidInitializeNotification"];
NSConnectionLocalCount
= [[NSString alloc] initWithCString: "NSConnectionLocalCount"];
NSConnectionProxyCount
= [[NSString alloc] initWithCString: "NSConnectionProxyCount"];
NSConnectionRepliesReceived
= [[NSString alloc] initWithCString: "NSConnectionRepliesReceived"];
NSConnectionRepliesSent
= [[NSString alloc] initWithCString: "NSConnectionRepliesSent"];
NSConnectionReplyMode
= [[NSString alloc] initWithCString: "NSConnectionReplyMode"];
NSConnectionRequestsReceived
= [[NSString alloc] initWithCString: "NSConnectionRequestsReceived"];
NSConnectionRequestsSent
= [[NSString alloc] initWithCString: "NSConnectionRequestsSent"];
NSCurrencyString
= [[NSString alloc] initWithCString: "NSCurrencyString"];
NSCurrencySymbol
= [[NSString alloc] initWithCString: "NSCurrencySymbol"];
NSDateFormatString
= [[NSString alloc] initWithCString: "NSDateFormatString"];
NSDateTimeOrdering
= [[NSString alloc] initWithCString: "NSDateTimeOrdering"];
NSDecimalDigits
= [[NSString alloc] initWithCString: "NSDecimalDigits"];
NSDecimalSeparator
= [[NSString alloc] initWithCString: "NSDecimalSeparator"];
NSDefaultRunLoopMode
= [[NSString alloc] initWithCString: "NSDefaultRunLoopMode"];
NSEarlierTimeDesignations
= [[NSString alloc] initWithCString: "NSEarlierTimeDesignations"];
NSFailedAuthenticationException
= [[NSString alloc] initWithCString: "NSFailedAuthenticationException"];
NSFileDeviceIdentifier
= [[NSString alloc] initWithCString: "NSFileDeviceIdentifier"];
NSFileGroupOwnerAccountName
= [[NSString alloc] initWithCString: "NSFileGroupOwnerAccountName"];
NSFileGroupOwnerAccountNumber
= [[NSString alloc] initWithCString: "NSFileGroupOwnerAccountNumber"];
NSFileModificationDate
= [[NSString alloc] initWithCString: "NSFileModificationDate"];
NSFileOwnerAccountName
= [[NSString alloc] initWithCString: "NSFileOwnerAccountName"];
NSFileOwnerAccountNumber
= [[NSString alloc] initWithCString: "NSFileOwnerAccountNumber"];
NSFilePosixPermissions
= [[NSString alloc] initWithCString: "NSFilePosixPermissions"];
NSFileReferenceCount
= [[NSString alloc] initWithCString: "NSFileReferenceCount"];
NSFileSize
= [[NSString alloc] initWithCString: "NSFileSize"];
NSFileSystemFileNumber
= [[NSString alloc] initWithCString: "NSFileSystemFileNumber"];
NSFileSystemFreeNodes
= [[NSString alloc] initWithCString: "NSFileSystemFreeNodes"];
NSFileSystemFreeSize
= [[NSString alloc] initWithCString: "NSFileSystemFreeSize"];
NSFileSystemNodes
= [[NSString alloc] initWithCString: "NSFileSystemNodes"];
NSFileSystemNumber
= [[NSString alloc] initWithCString: "NSFileSystemNumber"];
NSFileSystemSize
= [[NSString alloc] initWithCString: "NSFileSystemSize"];
NSFileType
= [[NSString alloc] initWithCString: "NSFileType"];
NSFileTypeBlockSpecial
= [[NSString alloc] initWithCString: "NSFileTypeBlockSpecial"];
NSFileTypeCharacterSpecial
= [[NSString alloc] initWithCString: "NSFileTypeCharacterSpecial"];
NSFileTypeDirectory
= [[NSString alloc] initWithCString: "NSFileTypeDirectory"];
NSFileTypeFifo
= [[NSString alloc] initWithCString: "NSFileTypeFifo"];
NSFileTypeRegular
= [[NSString alloc] initWithCString: "NSFileTypeRegular"];
NSFileTypeSocket
= [[NSString alloc] initWithCString: "NSFileTypeSocket"];
NSFileTypeSymbolicLink
= [[NSString alloc] initWithCString: "NSFileTypeSymbolicLink"];
NSFileTypeUnknown
= [[NSString alloc] initWithCString: "NSFileTypeUnknown"];
NSGenericException
= [[NSString alloc] initWithCString: "NSGenericException"];
NSGlobalDomain
= [[NSString alloc] initWithCString: "NSGlobalDomain"];
NSHourNameDesignations
= [[NSString alloc] initWithCString: "NSHourNameDesignations"];
NSInconsistentArchiveException
= [[NSString alloc] initWithCString: "NSInconsistentArchiveException"];
NSInternalInconsistencyException
= [[NSString alloc] initWithCString:
"NSInternalInconsistencyException"];
NSInternationalCurrencyString
= [[NSString alloc] initWithCString: "NSInternationalCurrencyString"];
NSInvalidArgumentException
= [[NSString alloc] initWithCString: "NSInvalidArgumentException"];
NSLaterTimeDesignations
= [[NSString alloc] initWithCString: "NSLaterTimeDesignations"];
NSLoadedClasses
= [[NSString alloc] initWithCString: "NSLoadedClasses"];
NSMallocException
= [[NSString alloc] initWithCString: "NSMallocException"];
NSMonthNameArray
= [[NSString alloc] initWithCString: "NSMonthNameArray"];
NSNextDayDesignations
= [[NSString alloc] initWithCString: "NSNextDayDesignations"];
NSNextNextDayDesignations
= [[NSString alloc] initWithCString: "NSNextNextDayDesignations"];
NSPortDidBecomeInvalidNotification
= [[NSString alloc] initWithCString:
"NSPortDidBecomeInvalidNotification"];
NSPortTimeoutException
= [[NSString alloc] initWithCString: "NSPortTimeoutException"];
NSPriorDayDesignations
= [[NSString alloc] initWithCString: "NSPriorDayDesignations"];
NSRangeException
= [[NSString alloc] initWithCString: "NSRangeException"];
NSRegistrationDomain
= [[NSString alloc] initWithCString: "NSRegistrationDomain"];
NSShortMonthNameArray
= [[NSString alloc] initWithCString: "NSShortMonthNameArray"];
NSShortTimeDateFormatString
= [[NSString alloc] initWithCString: "NSShortTimeDateFormatString"];
NSShortWeekDayNameArray
= [[NSString alloc] initWithCString: "NSShortWeekDayNameArray"];
NSShowNonLocalizedStrings
= [[NSString alloc] initWithCString: "NSShowNonLocalizedStrings"];
NSThisDayDesignations
= [[NSString alloc] initWithCString: "NSThisDayDesignations"];
NSThousandsSeparator
= [[NSString alloc] initWithCString: "NSThousandsSeparator"];
NSThreadWillExitNotification
= [[NSString alloc] initWithCString: "NSThreadWillExitNotification"];
NSTimeDateFormatString
= [[NSString alloc] initWithCString: "NSTimeDateFormatString"];
NSTimeFormatString
= [[NSString alloc] initWithCString: "NSTimeFormatString"];
NSUserDefaultsDidChangeNotification
= [[NSString alloc] initWithCString:
"NSUserDefaultsDidChangeNotification"];
NSWeekDayNameArray
= [[NSString alloc] initWithCString: "NSWeekDayNameArray"];
NSWillBecomeMultiThreadedNotification
= [[NSString alloc] initWithCString:
"NSWillBecomeMultiThreadedNotification"];
NSYearMonthWeekDesignations
= [[NSString alloc] initWithCString: "NSYearMonthWeekDesignations"];
PortBecameInvalidNotification
= [[NSString alloc] initWithCString: "PortBecameInvalidNotification"];
StreamException
= [[NSString alloc] initWithCString: "StreamException"];
}
}
/* Standard MapTable callbacks */ /* Standard MapTable callbacks */

View file

@ -175,6 +175,21 @@ printf("oneway %d\n", _F_ONEWAY);
printf("%s - %s\n", [k cString], [[v description] cString]); printf("%s - %s\n", [k cString], [[v description] cString]);
} }
{
NSDate *d = [NSDate date];
[NSConnection setDebug: 0];
[NSDistantObject setDebug: 0];
[NSPort setDebug: 0];
for (j = 0; j < 10000; j++)
{
[p echoObject: localObj];
}
NSLog(@"Delay is %f", [d timeIntervalSinceNow]);
exit(0);
}
[arp release]; [arp release];
arp = [NSAutoreleasePool new]; arp = [NSAutoreleasePool new];
printf("%d\n", [c retainCount]); printf("%d\n", [c retainCount]);

View file

@ -51,6 +51,7 @@ struct myarray {
: (int)i7 : (int)i8 : (int)i9 : (int)i10 : (int)i11 : (int)i12; : (int)i7 : (int)i8 : (int)i9 : (int)i10 : (int)i11 : (int)i12;
- (float) returnFloat; - (float) returnFloat;
- (double) returnDouble; - (double) returnDouble;
- (id) echoObject: (id)obj;
@end @end
#if NeXT_runtime #if NeXT_runtime

View file

@ -79,6 +79,16 @@
return self; return self;
} }
- (id) echoObject: (id)obj
{
static BOOL debugging = YES;
if (debugging)
{
[BinaryCStream setDebugging:NO];
}
return obj;
}
- (void) outputStats:obj - (void) outputStats:obj
{ {
id c = [obj connectionForProxy]; id c = [obj connectionForProxy];