mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Port message tidyup
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6121 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
907ca9f867
commit
64d219c10c
4 changed files with 38 additions and 22 deletions
|
@ -1,3 +1,9 @@
|
|||
Sun Feb 27 08:37:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Headers/gnustep/base/NSPortMessage.m: use separate ivars for ports.
|
||||
* Source/NSPortMessage.m: modified to use separate ivars for send and
|
||||
receive ports so that we can easily pass mutable array for send.
|
||||
|
||||
Fri Feb 25 12:56:00 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
|
||||
* Source/NSPort.m: provide default implementations for methods dealing
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
@interface NSPortMessage : NSObject
|
||||
{
|
||||
unsigned _msgid;
|
||||
NSPort *_recv;
|
||||
NSPort *_send;
|
||||
NSMutableArray *_components;
|
||||
}
|
||||
- (id) initWithMachMessage: (void*)buffer;
|
||||
|
|
|
@ -713,8 +713,11 @@ static NSMapTable *tcpHandleTable = 0;
|
|||
* the header - so add it to the rItems array.
|
||||
*/
|
||||
rWant -= sizeof(GSPortMsgHeader);
|
||||
d = [NSData dataWithBytes: bytes + sizeof(GSPortMsgHeader)
|
||||
length: rWant];
|
||||
d = [NSData alloc];
|
||||
d = [d initWithBytes: bytes + sizeof(GSPortMsgHeader)
|
||||
length: rWant];
|
||||
[rItems addObject: d];
|
||||
RELEASE(d);
|
||||
rWant += sizeof(GSPortMsgHeader);
|
||||
rLength -= rWant;
|
||||
if (rLength > 0)
|
||||
|
@ -722,7 +725,6 @@ static NSMapTable *tcpHandleTable = 0;
|
|||
memcpy(bytes, bytes + rWant, rLength);
|
||||
}
|
||||
rWant = sizeof(GSPortItemHeader);
|
||||
[rItems addObject: rData];
|
||||
if (nItems == 1)
|
||||
{
|
||||
[self dispatch];
|
||||
|
@ -748,8 +750,9 @@ static NSMapTable *tcpHandleTable = 0;
|
|||
NSData *d;
|
||||
|
||||
rType = GSP_NONE;
|
||||
d = [NSData dataWithBytes: bytes length: rWant];
|
||||
[rItems addObject: rData];
|
||||
d = [[NSData alloc] initWithBytes: bytes length: rWant];
|
||||
[rItems addObject: d];
|
||||
RELEASE(d);
|
||||
rLength -= rWant;
|
||||
if (rLength > 0)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* Implementation of NSPortMessage for GNUstep
|
||||
Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998,2000 Free Software Foundation, Inc.
|
||||
|
||||
Written by: Richard frith-Macdonald <richard@brainstorm.co.Ik>
|
||||
Created: October 1998
|
||||
|
@ -32,10 +32,19 @@
|
|||
|
||||
- (void) dealloc
|
||||
{
|
||||
RELEASE(_recv);
|
||||
RELEASE(_send);
|
||||
RELEASE(_components);
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (NSString*) description
|
||||
{
|
||||
return [NSString stringWithFormat:
|
||||
@"NSPortMessage (Id %u)\n Send: %@\n Recv: %@\n Components -\n%@",
|
||||
_msgid, _send, _recv, _components];
|
||||
}
|
||||
|
||||
/* PortMessages MUST be initialised with ports and data. */
|
||||
- (id) init
|
||||
{
|
||||
|
@ -43,6 +52,7 @@
|
|||
return nil;
|
||||
}
|
||||
|
||||
/* PortMessages MUST be initialised with ports and data. */
|
||||
- (id) initWithMachMessage: (void*)buffer
|
||||
{
|
||||
[self shouldNotImplement: _cmd];
|
||||
|
@ -55,13 +65,12 @@
|
|||
components: (NSArray*)items
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
if (self != nil)
|
||||
{
|
||||
_send = RETAIN(aPort);
|
||||
_recv = RETAIN(anotherPort);
|
||||
_components = [[NSMutableArray allocWithZone: [self zone]]
|
||||
initWithCapacity: [items count] + 2];
|
||||
[_components addObject: aPort];
|
||||
[_components addObject: anotherPort];
|
||||
[_components addObjectsFromArray: items];
|
||||
initWithArray: items];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -76,9 +85,7 @@
|
|||
|
||||
- (NSArray*) components
|
||||
{
|
||||
NSRange r = NSMakeRange(2, [_components count]-2);
|
||||
|
||||
return [_components subarrayWithRange: r];
|
||||
return AUTORELEASE([_components copy]);
|
||||
}
|
||||
|
||||
- (unsigned) msgid
|
||||
|
@ -88,22 +95,20 @@
|
|||
|
||||
- (NSPort*) receivePort
|
||||
{
|
||||
return [_components objectAtIndex: 1];
|
||||
return _recv;
|
||||
}
|
||||
|
||||
- (BOOL) sendBeforeDate: (NSDate*)when
|
||||
{
|
||||
NSPort *port = [self sendPort];
|
||||
|
||||
return [port sendBeforeDate: when
|
||||
components: [self components]
|
||||
from: [self receivePort]
|
||||
reserved: [port reservedSpaceLength]];
|
||||
return [_send sendBeforeDate: when
|
||||
components: _components
|
||||
from: _recv
|
||||
reserved: 0];
|
||||
}
|
||||
|
||||
- (NSPort*) sendPort
|
||||
{
|
||||
return [_components objectAtIndex: 0];
|
||||
return _send;
|
||||
}
|
||||
|
||||
- (void) setMsgid: (unsigned)anId
|
||||
|
|
Loading…
Reference in a new issue