mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
Various tidyups and additions for DO stuff under development
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@6837 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
c83a32e580
commit
26fef76e05
10 changed files with 2604 additions and 36 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2000-06-28 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
Various minor tidyups for distributed objects - and included development
|
||||
code for NSConnection rewrite.
|
||||
* Headers/gnustep/base/DistributedObjects.h: removed obsolete methods
|
||||
* Headers/gnustep/base/GSConnection.h: temporary (development) class
|
||||
* Headers/gnustep/base/GSPortCoder.h: private method for GSConnection
|
||||
* Headers/gnustep/base/NSConnection.h: tidied
|
||||
* Source/GSConnection.m: temporary (development) class
|
||||
* Source/GSPortCoder.m: private method for GSConnection
|
||||
* Source/NSConnection.m: tidied a little - retain/release fixes
|
||||
* Source/NSDistantObject.m: tidied a little - use OPENSTEP method
|
||||
for creating new connection.
|
||||
* Source/NSPortCoder.m: tidied to work without GNU specific code.
|
||||
|
||||
2000-06-27 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Fixes on solaris/gcc 2.8.0
|
||||
|
|
|
@ -71,16 +71,12 @@ enum {
|
|||
* by NSDistantObject et al for implementation of Distributed objects.
|
||||
*/
|
||||
@interface NSConnection (Internal)
|
||||
+ (NSConnection*) connectionByInPort: (NSPort*)ip
|
||||
outPort: (NSPort*)op;
|
||||
+ (NSConnection*) connectionByOutPort: (NSPort*)op;
|
||||
+ (NSDistantObject*) includesLocalTarget: (unsigned)target;
|
||||
- (NSDistantObject*) includesLocalTarget: (unsigned)target;
|
||||
- (NSDistantObject*) localForObject: (id)object;
|
||||
- (NSDistantObject*) localForTarget: (unsigned)target;
|
||||
- (NSDistantObject*) proxyForTarget: (unsigned)target;
|
||||
- (void) retainTarget: (unsigned)target;
|
||||
- (void) setNotOwned;
|
||||
@end
|
||||
|
||||
|
||||
|
|
273
Headers/gnustep/base/GSConnection.h
Normal file
273
Headers/gnustep/base/GSConnection.h
Normal file
|
@ -0,0 +1,273 @@
|
|||
/* Interface for GNU Objective-C version of NSConnection
|
||||
Copyright (C) 1997,2000 Free Software Foundation, Inc.
|
||||
|
||||
Original by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
|
||||
Version for OPENSTEP by: Richard Frith-Macdonald <richard@brainstorm.co.uk>
|
||||
Created: August 1997, updated June 2000
|
||||
|
||||
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 Library 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 Library General Public
|
||||
License along with this library; if not, write to the Free
|
||||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
*/
|
||||
|
||||
#ifndef __NSConnection_h_GNUSTEP_BASE_INCLUDE
|
||||
#define __NSConnection_h_GNUSTEP_BASE_INCLUDE
|
||||
|
||||
#include <Foundation/NSObject.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSMapTable.h>
|
||||
|
||||
@class NSDistantObject;
|
||||
@class NSPort;
|
||||
@class NSData;
|
||||
|
||||
/*
|
||||
* Keys for the NSDictionary returned by [NSConnection -statistics]
|
||||
*/
|
||||
/* These in OPENSTEP 4.2 */
|
||||
GS_EXPORT NSString *NSConnectionRepliesReceived;
|
||||
GS_EXPORT NSString *NSConnectionRepliesSent;
|
||||
GS_EXPORT NSString *NSConnectionRequestsReceived;
|
||||
GS_EXPORT NSString *NSConnectionRequestsSent;
|
||||
/* These Are GNUstep extras */
|
||||
GS_EXPORT NSString *NSConnectionLocalCount; /* Objects sent out */
|
||||
GS_EXPORT NSString *NSConnectionProxyCount; /* Objects received */
|
||||
|
||||
|
||||
/*
|
||||
* NSConnection class interface.
|
||||
*
|
||||
* A few methods are in the specification but not yet implemented.
|
||||
*/
|
||||
@interface NSConnection : NSObject
|
||||
{
|
||||
@private
|
||||
BOOL is_valid;
|
||||
BOOL independent_queueing;
|
||||
unsigned request_depth;
|
||||
NSPort *receive_port;
|
||||
NSPort *send_port;
|
||||
unsigned message_count;
|
||||
unsigned req_out_count;
|
||||
unsigned req_in_count;
|
||||
unsigned rep_out_count;
|
||||
unsigned rep_in_count;
|
||||
NSMapTable *local_objects;
|
||||
NSMapTable *local_targets;
|
||||
NSMapTable *remote_proxies;
|
||||
NSTimeInterval reply_timeout;
|
||||
NSTimeInterval request_timeout;
|
||||
id delegate;
|
||||
NSMutableArray *request_modes;
|
||||
NSMutableArray *run_loops;
|
||||
}
|
||||
|
||||
+ (NSArray*) allConnections;
|
||||
+ (NSConnection*) connectionWithReceivePort: (NSPort*)r
|
||||
sendPort: (NSPort*)s;
|
||||
+ (NSConnection*) connectionWithRegisteredName: (NSString*)n
|
||||
host: (NSString*)h;
|
||||
+ (NSConnection*) connectionWithRegisteredName: (NSString*)n
|
||||
host: (NSString*)h
|
||||
usingNameServer: (NSPortNameServer*)s;
|
||||
+ (id) currentConversation;
|
||||
+ (NSConnection*) defaultConnection;
|
||||
+ (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)name
|
||||
host: (NSString*)host;
|
||||
+ (NSDistantObject*) rootProxyForConnectionWithRegisteredName: (NSString*)name
|
||||
host: (NSString*)host usingNameServer: (NSPortNameServer*)s;
|
||||
|
||||
|
||||
- (void) addRequestMode: (NSString*)mode;
|
||||
- (void) addRunLoop: (NSRunLoop*)runloop;
|
||||
- (id) delegate;
|
||||
- (void) enableMultipleThreads;
|
||||
- (BOOL) independentConversationQueueing;
|
||||
- (id) initWithReceivePort: (NSPort*)r
|
||||
sendPort: (NSPort*)s;
|
||||
- (void) invalidate;
|
||||
- (BOOL) isValid;
|
||||
- (NSArray*)localObjects;
|
||||
- (BOOL) multipleThreadsEnabled;
|
||||
- (NSPort*) receivePort;
|
||||
- (BOOL) registerName: (NSString*)name;
|
||||
- (NSArray*) remoteObjects;
|
||||
- (void) removeRequestMode: (NSString*)mode;
|
||||
- (void) removeRunLoop: (NSRunLoop *)runloop;
|
||||
- (NSTimeInterval) replyTimeout;
|
||||
- (NSArray*) requestModes;
|
||||
- (NSTimeInterval) requestTimeout;
|
||||
- (id) rootObject;
|
||||
- (NSDistantObject*) rootProxy;
|
||||
- (void) runInNewThread;
|
||||
- (NSPort*) sendPort;
|
||||
- (void) setDelegate: anObj;
|
||||
- (void) setIndependentConversationQueueing: (BOOL)flag;
|
||||
- (void) setReplyTimeout: (NSTimeInterval)seconds;
|
||||
- (void) setRequestMode: (NSString*)mode;
|
||||
- (void) setRequestTimeout: (NSTimeInterval)seconds;
|
||||
- (void) setRootObject: anObj;
|
||||
- (NSDictionary*) statistics;
|
||||
@end
|
||||
|
||||
|
||||
/*
|
||||
* This catagory contains legacy methods from the original GNU 'Connection'
|
||||
* class, and useful extensions to NSConnection.
|
||||
*/
|
||||
@interface NSConnection (GNUstepExtensions) <GCFinalization>
|
||||
|
||||
- (void) gcFinalize;
|
||||
|
||||
/* Registering your server object on the network.
|
||||
These methods create a new connection object that must be "run" in order
|
||||
to start handling requests from clients.
|
||||
These method names may change when we get the capability to register
|
||||
ports with names after the ports have been created. */
|
||||
/* I want the second method name to clearly indicate that we're not
|
||||
connecting to a pre-existing registration name, we're registering a
|
||||
new name, and this method will fail if that name has already been
|
||||
registered. This is why I don't like "newWithRegisteredName:" ---
|
||||
it's unclear if we're connecting to another NSConnection that already
|
||||
registered with that name. */
|
||||
+ (NSConnection*) newWithRootObject: anObj;
|
||||
+ (NSConnection*) newRegisteringAtName: (NSString*)n
|
||||
withRootObject: anObj;
|
||||
+ (NSConnection*) newRegisteringAtName: (NSString*)n
|
||||
atPort: (int)portn
|
||||
withRootObject: anObj;
|
||||
|
||||
/* Get a proxy to a remote server object.
|
||||
A new connection is created if necessary. */
|
||||
+ (NSDistantObject*) rootProxyAtName: (NSString*)name
|
||||
onHost: (NSString*)host;
|
||||
+ (NSDistantObject*) rootProxyAtName: (NSString*)name;
|
||||
+ (NSDistantObject*) rootProxyAtPort: (NSPort*)anOutPort;
|
||||
+ (NSDistantObject*) rootProxyAtPort: (NSPort*)anOutPort
|
||||
withInPort: (NSPort*)anInPort;
|
||||
|
||||
/* This is the designated initializer for the NSConnection class.
|
||||
You don't need to call it yourself. */
|
||||
+ (NSConnection*) newForInPort: (NSPort*)anInPort
|
||||
outPort: (NSPort*)anOutPort
|
||||
ancestorConnection: (NSConnection*)ancestor;
|
||||
|
||||
/* Make a connection object start listening for incoming requests. After
|
||||
after DATE. */
|
||||
- (void) runConnectionUntilDate: date;
|
||||
|
||||
/* Same as above, but never time out. */
|
||||
- (void) runConnection;
|
||||
|
||||
|
||||
|
||||
/* For getting the root object of a connection or port */
|
||||
+ rootObjectForInPort: (NSPort*)aPort;
|
||||
|
||||
/* Used for setting the root object of a connection that we
|
||||
created without one, or changing the root object of a connection
|
||||
that already has one. */
|
||||
+ (void) setRootObject: anObj forInPort: (NSPort*)aPort;
|
||||
|
||||
/* Only subclassers and power-users need worry about these */
|
||||
- (void) addProxy: (NSDistantObject*)aProxy;
|
||||
- (id) includesProxyForTarget: (gsu32)target;
|
||||
- (void) removeProxy: (NSDistantObject*)aProxy;
|
||||
|
||||
// It seems to be a non pure-OPENSTEP definition...
|
||||
//
|
||||
// new def :
|
||||
- (void) addLocalObject: anObj;
|
||||
- (id) includesLocalObject: anObj;
|
||||
- (void) removeLocalObject: anObj;
|
||||
- (retval_t) forwardForProxy: (NSDistantObject*)object
|
||||
selector: (SEL)sel
|
||||
argFrame: (arglist_t)frame;
|
||||
- (const char *) typeForSelector: (SEL)sel remoteTarget: (unsigned)target;
|
||||
|
||||
@end
|
||||
|
||||
GS_EXPORT NSString *ConnectionBecameInvalidNotification;
|
||||
|
||||
@interface Object (NSConnectionDelegate)
|
||||
- (BOOL) connection: (NSConnection*)parent
|
||||
shouldMakeNewConnection: (NSConnection*)newConnection;
|
||||
/*
|
||||
* This method may be used to ask a delegates permission to create
|
||||
* a new connection from the old one.
|
||||
* This method should be implemented in preference to the
|
||||
* [makeNewConnection:sender:] which is obsolete.
|
||||
*/
|
||||
- (BOOL) makeNewConnection: (NSConnection*)newConnection
|
||||
sender: (NSConnection*)parent;
|
||||
/*
|
||||
* This is the old way of doing the same thing as
|
||||
* [connection:shouldMakeNewConnection:]
|
||||
* It is obsolete - don't use it.
|
||||
*/
|
||||
- (NSConnection*) connection: (NSConnection*)ancestorConn
|
||||
didConnect: (NSConnection*)newConn;
|
||||
/*
|
||||
* If the delegate responds to this method, it will be used to ask the
|
||||
* delegate's permission to establish a new connection from the old one.
|
||||
* Often this is used so that the delegate can register for invalidation
|
||||
* notification on new child connections.
|
||||
* This is a GNUstep extension
|
||||
* Normally return newConn.
|
||||
*/
|
||||
@end
|
||||
|
||||
@interface Object (NSPortCoder)
|
||||
- (Class) classForPortCoder;
|
||||
/*
|
||||
* Must return the class that will be created on the remote side
|
||||
* of the connection. If the class to be created is not the same
|
||||
* as that of the object returned by replacementObjectForPortCoder:
|
||||
* then the class must be capable of recognising the object it
|
||||
* actually gets in its initWithCoder: method.
|
||||
* The default operation is to return NSDistantObject unless the
|
||||
* object is being sent bycopy, in which case the objects actual
|
||||
* class is returned. To force bycopy operation the object should
|
||||
* return its own class.
|
||||
*/
|
||||
- (id) replacementObjectForPortCoder: (NSPortCoder*)aCoder;
|
||||
/*
|
||||
* This message is sent to an object about to be encoded for sending
|
||||
* over the wire. The default action is to return an NSDistantObject
|
||||
* which is a local proxy for the object unless the object is being
|
||||
* sent bycopy, in which case the actual object is returned.
|
||||
* To force bycopy, an object should return itsself.
|
||||
*/
|
||||
|
||||
|
||||
- (BOOL) authenticateComponents: (NSArray*)components
|
||||
withData: (NSData*)authenticationData;
|
||||
- (NSData*) authenticationDataForComponents: (NSArray*)components;
|
||||
|
||||
@end
|
||||
|
||||
#define CONNECTION_DEFAULT_TIMEOUT 15.0 /* in seconds */
|
||||
|
||||
/*
|
||||
* NSRunLoop mode, NSNotification name and NSException strings.
|
||||
*/
|
||||
GS_EXPORT NSString *NSConnectionReplyMode;
|
||||
GS_EXPORT NSString *NSConnectionDidDieNotification;
|
||||
GS_EXPORT NSString *NSConnectionDidInitializeNotification; /* OPENSTEP*/
|
||||
|
||||
#endif /* __NSConnection_h_GNUSTEP_BASE_INCLUDE */
|
|
@ -94,5 +94,9 @@
|
|||
|
||||
@end
|
||||
|
||||
@interface NSPortCoder (Private)
|
||||
- (NSArray*) _components;
|
||||
@end
|
||||
|
||||
|
||||
#endif /* __GSPortCoder_h */
|
||||
|
|
|
@ -173,6 +173,7 @@ GS_EXPORT NSString *NSConnectionProxyCount; /* Objects received */
|
|||
atPort: (int)portn
|
||||
withRootObject: anObj;
|
||||
|
||||
+ (NSConnection*) connectionByOutPort: (NSPort*)aPort;
|
||||
/* Get a proxy to a remote server object.
|
||||
A new connection is created if necessary. */
|
||||
+ (NSDistantObject*) rootProxyAtName: (NSString*)name onHost: (NSString*)host;
|
||||
|
|
2304
Source/GSConnection.m
Normal file
2304
Source/GSConnection.m
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1641,6 +1641,11 @@ typeCheck(char t1, char t2)
|
|||
|
||||
@implementation GSPortCoder (Private)
|
||||
|
||||
- (NSArray*) _components
|
||||
{
|
||||
return _comp;
|
||||
}
|
||||
|
||||
- (void) _deserializeHeaderAt: (unsigned*)pos
|
||||
version: (unsigned*)v
|
||||
classes: (unsigned*)c
|
||||
|
|
|
@ -306,7 +306,6 @@ static int messages_received_count;
|
|||
newPort = [default_receive_port_class newForReceiving];
|
||||
c = [c initWithReceivePort: newPort sendPort: nil];
|
||||
RELEASE(newPort);
|
||||
return c;
|
||||
[d setObject: c forKey: tkey];
|
||||
RELEASE(c);
|
||||
}
|
||||
|
@ -454,15 +453,6 @@ static int messages_received_count;
|
|||
return [NSConnection defaultConnection];
|
||||
}
|
||||
|
||||
/*
|
||||
* Keep track of connections created by DO system but not necessarily
|
||||
* ever retained by users code. These must be retained now for later
|
||||
* release when invalidated.
|
||||
*/
|
||||
- (void) setNotOwned
|
||||
{
|
||||
}
|
||||
|
||||
/* xxx This needs locks */
|
||||
- (void) invalidate
|
||||
{
|
||||
|
|
|
@ -439,24 +439,8 @@ enum
|
|||
* automatically when no proxies are left on it.
|
||||
*/
|
||||
proxy_connection = [[decoder_connection class]
|
||||
connectionByInPort:
|
||||
[decoder_connection receivePort]
|
||||
outPort:
|
||||
proxy_connection_out_port];
|
||||
if (proxy_connection == nil)
|
||||
{
|
||||
proxy_connection = [[decoder_connection class]
|
||||
connectionByOutPort: proxy_connection_out_port];
|
||||
}
|
||||
if (proxy_connection == nil)
|
||||
{
|
||||
proxy_connection = [[decoder_connection class]
|
||||
newForInPort: [decoder_connection receivePort]
|
||||
outPort: proxy_connection_out_port
|
||||
ancestorConnection: decoder_connection];
|
||||
[proxy_connection setNotOwned];
|
||||
[proxy_connection autorelease];
|
||||
}
|
||||
connectionWithReceivePort: [decoder_connection receivePort]
|
||||
sendPort: proxy_connection_out_port];
|
||||
|
||||
if (debug_proxy)
|
||||
NSLog(@"Receiving a triangle-connection proxy 0x%x "
|
||||
|
|
|
@ -272,8 +272,6 @@ static BOOL debug_connected_coder = NO;
|
|||
outPort: reply_port
|
||||
ancestorConnection: c];
|
||||
|
||||
[cd->connection setNotOwned];
|
||||
|
||||
/* Decode the PortDecoder's ivars. */
|
||||
[cd decodeValueOfCType: @encode(typeof(cd->sequence_number))
|
||||
at: &(cd->sequence_number)
|
||||
|
@ -305,8 +303,6 @@ static BOOL debug_connected_coder = NO;
|
|||
outPort: reply_port
|
||||
ancestorConnection: c];
|
||||
|
||||
[cd->connection setNotOwned];
|
||||
|
||||
/* Decode the PortDecoder's ivars. */
|
||||
[cd decodeValueOfCType: @encode(typeof(cd->sequence_number))
|
||||
at: &(cd->sequence_number)
|
||||
|
|
Loading…
Reference in a new issue