Remove redundant classes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2861 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 1998-07-21 17:56:48 +00:00
parent 961e3f726e
commit 1981f6a34b
41 changed files with 189 additions and 3485 deletions

View file

@ -1,3 +1,40 @@
Tue Jul 21 09:15:32 1998 Adam Fedor <fedor@ultra.doc.com>
* src/GNUmakefile: Removed redundant classes.
* src/Connection: Removed.
* src/Lock: Likewise.
* src/Notification: Likewise.
* src/Proxy: Likewise.
* src/include/Connection.h, src/include/Lock.h,
src/include/Notification.h, src/include/Proxy.h: Likewise.
* src/include/RetainingNotifier.h: Removed.
* src/libgnustep-base.def: Removed reference to redundant classes.
* src/include/ConnectedCoder.h: Likewise
* src/include/NSConnection.h: Likewise
* src/include/NSNotification.h: Likewise
* src/include/NSPort.h: Likewise
* src/include/all.h: Likewise
* src/ConnectedCoder.m: Likewise
* src/Makefile.postamble: Likewise
* src/MachPort.m: Likewise
* src/NSConnection.m: Likewise
* src/NotificationDispatcher.m: Likewise
* src/NSNotification.m: Likewise
* src/Port.m: Likewise
* src/TcpPort.m: Likewise
* src/behavior.m: Likewise
* src/NSThread.m: Likewise
* src/UdpPort.m: Likewise
* examples/first-client.m, examples/first-server.h,
examples/first-server.m, examples/second-client.h,
examples/second-client.m, examples/second-server.h,
examples/second-server.m: Removed.
* src/NSRunLoop.m: Add time.h (For GNU/Linux-2.0)
* src/TcpPort.m: Likewise.
* src/UdpPort.m: Likewise.
* sec/UnixFileHandle.m: Likewise.
Wed Jul 20 21:25:00 1998 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* src/Decoder.m: ([-decodeClass]) modified to ensure correct decoding

View file

@ -36,27 +36,16 @@ include ../config.mak
TEST_TOOL_NAME = \
dictionary \
stdio-stream \
textcoding \
first-server \
first-client \
second-server \
second-client
textcoding
# The Objective-C source files to be compiled
dictionary_OBJC_FILES = dictionary.m
stdio-stream_OBJC_FILES = stdio-stream.m
textcoding_OBJC_FILES = textcoding.m
first-server_OBJC_FILES = first-server.m
first-client_OBJC_FILES = first-client.m
second-server_OBJC_FILES = second-server.m
second-client_OBJC_FILES = second-client.m
SRCS = $(TEST_TOOL_NAME:=.m)
HDRS = \
first-server.h \
second-server.h \
second-client.h
HDRS =
DIST_FILES = $(SRCS) $(HDRS) GNUmakefile Makefile.postamble Makefile.preamble \
custom-zone.m

View file

@ -1,39 +0,0 @@
#include <gnustep/base/Connection.h>
#include <gnustep/base/Proxy.h>
#include "first-server.h"
#include <Foundation/NSString.h>
int main(int argc, char *argv[])
{
id s;
if (argc > 2)
{
printf("Looking for connection named `firstserver' on host `%s'...\n",
argv[2]);
s = [Connection rootProxyAtName:@"firstserver"
onHost:[NSString stringWithCString:argv[2]]];
}
else
{
printf("Looking for connection named `firstserver' on localhost...\n");
s = [Connection rootProxyAtName:@"firstserver"];
}
printf("Found connection named `firstserver'\n");
printf("Saying hello to the server\n");
if (argc > 1)
[s sayHiTo:argv[1]];
else
[s sayHiTo:"out there"];
printf("Shutting down my connection to the server\n");
[[s connectionForProxy] invalidate];
/* Although this isn't strictly necessary. The server will recognize
that we are gone, and handle it, if we just exit (or if we crash). */
exit(0);
}

View file

@ -1,13 +0,0 @@
#ifndef _first_server_h
#define _first_server_h
#include <Foundation/NSObject.h>
@interface FirstServer : NSObject
- sayHiTo: (char *)name;
@end
#endif /* _first_server_h */

View file

@ -1,77 +0,0 @@
#include <gnustep/base/Connection.h>
#include "first-server.h"
#include <Foundation/NSString.h>
#include <Foundation/NSRunLoop.h>
#include <sys/file.h>
@interface MyIo: NSObject <FdListening,FdSpeaking>
{
id runLoop;
id mode;
char c;
}
- initForRunLoop: r andMode: m;
- (void) readyForReadingOnFileDescriptor: (int)fd;
- (void) readyForWritingOnFileDescriptor: (int)fd;
@end
@implementation MyIo
- initForRunLoop: r andMode: m
{
runLoop = r;
mode = m;
return self;
}
- (void) readyForReadingOnFileDescriptor: (int)fd
{
if (read(fd, &c, 1) == 1) {
[runLoop addWriteDescriptor: 1 object: self forMode: mode];
[runLoop removeReadDescriptor: fd forMode: mode];
}
}
- (void) readyForWritingOnFileDescriptor: (int)fd
{
if (write(fd, &c, 1) == 1) {
[runLoop addReadDescriptor: 0 object: self forMode: mode];
[runLoop removeWriteDescriptor: fd forMode: mode];
}
}
@end
@implementation FirstServer
- sayHiTo: (char *)name
{
printf("Hello, %s.\n", name);
return self;
}
@end
int main()
{
id s, c;
MyIo* myIo;
NSString* m;
id r;
r = [NSRunLoop currentInstance];
m = [NSRunLoop currentMode];
myIo = [[MyIo alloc] initForRunLoop: r andMode: m];
[r addReadDescriptor: 0 object: myIo forMode: m];
/* Create our server object */
s = [[FirstServer alloc] init];
/* Register a connection that provides the server object to the network */
printf("Registering a connection for the server using name `firstserver'\n");
c = [Connection newRegisteringAtName:@"firstserver"
withRootObject:s];
/* Run the connection */
printf("Running the connection... (until you interrupt with control-C)\n");
[c runConnection]; /* This runs until interrupt. */
exit(0);
}

View file

@ -1,30 +0,0 @@
#ifndef second_client_h
#define second_client_h
#include <gnustep/base/Connection.h>
#include <gnustep/base/Proxy.h>
#include "second-server.h"
@interface AppellationObject : NSObject
{
const char *appellation;
}
@end
@implementation AppellationObject
- setAppellation: (const char *)n
{
appellation = n;
return self;
}
- (const char *) appellation
{
return appellation;
}
@end
#endif

View file

@ -1,95 +0,0 @@
#include "second-client.h"
#include <Foundation/NSString.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/Invocation.h>
#include <Foundation/NSRunLoop.h>
#include <Foundation/NSDate.h>
#include <Foundation/NSException.h>
id announce_new_connection (id notification)
{
#if 0
id connection = [notification object];
printf ("Created Connection 0x%x to %@\n",
(unsigned)connection, [[connection outPort] description]);
#endif
return nil;
}
int main(int argc, char *argv[])
{
static id server;
id a1;
id remote_array;
char namebuf[16];
printf("Looking up server object on localhost with name `secondserver'\n");
if (argc > 1)
server = [Connection rootProxyAtName:
[NSString stringWithCString: argv[1]]];
else
server = [Connection rootProxyAtName: @"secondserver"];
printf("Found server.\n");
[NotificationDispatcher
addInvocation: [[ObjectFunctionInvocation alloc]
initWithObjectFunction: announce_new_connection]
name: ConnectionWasCreatedNotification
object: nil];
/* Create an AppellationObject */
a1 = [[AppellationObject alloc] init];
sprintf(namebuf, "%d", (int)getpid());
[a1 setAppellation: namebuf];
printf("This client has appellation %s\n", [a1 appellation]);
/* Let the server know about object a1. */
[server addRemoteObject: a1];
/* Get the server's array of all other AppellationObject's */
remote_array = [server array];
/* Print all the appellations; this will involve making connections
to the other clients of the server. */
{
int i, count;
const char *s;
id a2; /* appellation object from server's list */
count = [remote_array count];
for (i = 0; i < count; i++)
{
a2 = [remote_array objectAtIndex: i];
s = [a2 appellation];
printf(">>>Server knows about client with appellation %s<<<\n", s);
if ([a2 isProxy])
(*objc_free)((void*)s);
}
}
/* Cause an exception in the server, and watch it return to us. */
NS_DURING
{
[remote_array objectAtIndex: 99];
}
NS_HANDLER
{
printf("Exceptions are working; caught exception:\n"
"NAME: %s\n"
"REASON: %s\n",
[[localException name] cStringNoCopy],
[[localException reason] cStringNoCopy]);
[localException release];
}
NS_ENDHANDLER
/* Run, exiting as soon as there are 30 minutes with no requests */
[NSRunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 30 * 60]];
/* Clean up, to let the server know we're going away; (although
this isn't strictly necessary because the remote port will
detect that the connection has been severed). */
[[server connectionForProxy] invalidate];
exit(0);
}

View file

@ -1,18 +0,0 @@
#ifndef second_server_h
#define second_server_h
#include <Foundation/NSObject.h>
#include <gnustep/base/Array.h>
@interface SecondServer : NSObject
{
Array *array;
}
- init;
- addRemoteObject: o;
- array;
@end
#endif

View file

@ -1,154 +0,0 @@
#include "second-server.h"
#include "second-client.h"
#include <gnustep/base/Connection.h>
#include <gnustep/base/TcpPort.h>
#include <Foundation/NSString.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/Invocation.h>
/* This function will be called by an Invocation object that will be
registered to fire every time an InPort accepts a new client. */
id announce_new_port (id notification)
{
id in_port = [notification object];
id out_port = [notification userInfo];
printf ("{%s}\n\tconnected to\n\t{%s}\n",
[[out_port description] cStringNoCopy],
[[in_port description] cStringNoCopy]);
printf ("Now servicing %d connection(s).\n",
[in_port numberOfConnectedOutPorts]);
return nil;
}
/* This function will be called by an Invocation object that will be
registered to fire every time an InPort client disconnects. */
id announce_broken_port (id notification)
{
id in_port = [notification object];
id out_port = [notification userInfo];
printf ("{%s}\n\tdisconnected from\n\t{%s}\n",
[[out_port description] cStringNoCopy],
[[in_port description] cStringNoCopy]);
printf ("Now servicing %d connection(s).\n",
[in_port numberOfConnectedOutPorts]);
return nil;
}
/* The implementation of the object that will be registered with D.O.
as the server. */
@implementation SecondServer
- init
{
[super init];
array = [[Array alloc] init];
return self;
}
- addRemoteObject: o
{
const char *s;
[array addObject:o];
/* This next line is a callback */
s = [o appellation];
printf("Added remote object with appellation %s\n", s);
return self;
}
- array
{
return array;
}
- (Connection*) connection: ancestor didConnect: newConn
{
printf(">>>>New connection 0x%x created\n", (unsigned)newConn);
[NotificationDispatcher
addObserver: self
selector: @selector(connectionBecameInvalid:)
name: ConnectionBecameInvalidNotification
object: newConn];
[newConn setDelegate: self];
return newConn;
}
- connectionBecameInvalid: notification
{
id connection = [notification object];
if ([connection isKindOf: [Connection class]])
{
int arrayCount = [array count];
int i;
printf(">>> Connection 0x%x invalidated\n", (unsigned)connection);
/* Remember to avoid calling -isEqual: on the proxies of the
invalidated Connection. */
for (i = arrayCount-1; i >= 0; i--)
{
id o = [array objectAtIndex: i];
if ([o isProxy]
&& [o connectionForProxy] == connection)
{
printf(">>> Removing proxy 0x%x\n", (unsigned)o);
[array removeObjectAtIndex: i];
}
}
}
else
{
[self error:"non-Connection sent invalidation"];
}
return self;
}
@end
int main(int argc, char *argv[])
{
id s;
id c;
[NSObject enableDoubleReleaseCheck: YES];
s = [[SecondServer alloc] init];
[NotificationDispatcher
addInvocation: [[ObjectFunctionInvocation alloc]
initWithObjectFunction: announce_broken_port]
name: InPortClientBecameInvalidNotification
object: nil];
[NotificationDispatcher
addInvocation: [[ObjectFunctionInvocation alloc]
initWithObjectFunction: announce_new_port]
name: InPortAcceptedClientNotification
object: nil];
if (argc > 1)
{
c = [Connection newRegisteringAtName:
[NSString stringWithCString: argv[1]]
withRootObject:s];
printf("Regsitered server object on localhost with "
"name `%s'\n", argv[1]);
}
else
{
c = [Connection newRegisteringAtName: @"secondserver" withRootObject: s];
printf("Regsitered server object on localhost with "
"name `secondserver'\n");
}
[c setDelegate:s];
[NotificationDispatcher
addObserver: s
selector: @selector(connectionBecameInvalid:)
name: ConnectionBecameInvalidNotification
object: c];
[c runConnection];
exit(0);
}

View file

@ -39,16 +39,16 @@ enum {
METHODTYPE_REPLY
};
@class Connection;
@class NSConnection;
@interface ConnectedEncoder : Encoder
{
Connection *connection;
NSConnection *connection;
unsigned sequence_number;
int identifier;
}
+ newForWritingWithConnection: (Connection*)c
+ newForWritingWithConnection: (NSConnection*)c
sequenceNumber: (int)n
identifier: (int)i;
- (void) dismiss;
@ -61,14 +61,14 @@ enum {
@interface ConnectedDecoder : Decoder
{
Connection *connection;
NSConnection *connection;
unsigned sequence_number;
int identifier;
}
+ newDecodingWithPacket: (InPacket*)packet
connection: (Connection*)c;
+ newDecodingWithConnection: (Connection*)c
connection: (NSConnection*)c;
+ newDecodingWithConnection: (NSConnection*)c
timeout: (int) timeout;
- (void) dismiss;

View file

@ -1,223 +0,0 @@
/* Interface for GNU Objective-C connection for remote object messaging
Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: July 1994
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __Connection_h_GNUSTEP_BASE_INCLUDE
#define __Connection_h_GNUSTEP_BASE_INCLUDE
#include <gnustep/base/preface.h>
#include <stdlib.h>
#include <stdarg.h>
#include <gnustep/base/Lock.h>
#include <gnustep/base/Collecting.h>
#include <gnustep/base/Dictionary.h>
#include <Foundation/NSString.h>
#include <Foundation/NSMapTable.h>
@class Proxy;
@class InPort, OutPort;
@interface Connection : NSObject
{
unsigned is_valid:1;
unsigned delay_dialog_interruptions:1;
unsigned connection_filler:6;
unsigned retain_count:24;
unsigned reply_depth;
InPort *in_port;
OutPort *out_port;
unsigned message_count;
NSMapTable *local_targets;
NSMapTable *remote_proxies;
int in_timeout;
int out_timeout;
Class in_port_class;
Class out_port_class;
Class encoding_class;
NSMapTable *incoming_xref_2_const_ptr;
NSMapTable *outgoing_const_ptr_2_xref;
id delegate;
}
/* Setting and getting class configuration */
+ (Class) defaultInPortClass;
+ (void) setDefaultInPortClass: (Class) aPortClass;
+ (Class) defaultOutPortClass;
+ (void) setDefaultOutPortClass: (Class) aPortClass;
+ (Class) defaultProxyClass;
+ (void) setDefaultProxyClass: (Class) aClass;
+ (int) defaultOutTimeout;
+ (void) setDefaultOutTimeout: (int)to;
+ (int) defaultInTimeout;
+ (void) setDefaultInTimeout: (int)to;
/* Querying the state of all the connections */
+ (int) messagesReceived;
+ (id <Collecting>) allConnections;
+ (unsigned) connectionsCount;
+ (unsigned) connectionsCountWithInPort: (InPort*)aPort;
/* Use these when you're release'ing an object that may have been vended
or registered for invalidation notification */
+ (void) removeLocalObject: anObj;
/* 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 Connection that already
registered with that name. */
+ (Connection*) newWithRootObject: anObj;
+ (Connection*) newRegisteringAtName: (NSString*)n withRootObject: anObj;
/* Get a proxy to a remote server object.
A new connection is created if necessary. */
+ (Proxy*) rootProxyAtName: (NSString*)name onHost: (NSString*)host;
+ (Proxy*) rootProxyAtName: (NSString*)name;
+ (Proxy*) rootProxyAtPort: (OutPort*)anOutPort;
+ (Proxy*) rootProxyAtPort: (OutPort*)anOutPort withInPort: (InPort*)anInPort;
/* This is the designated initializer for the Connection class.
You don't need to call it yourself. */
+ (Connection*) newForInPort: (InPort*)anInPort outPort: (OutPort*)anOutPort
ancestorConnection: (Connection*)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;
/* When you get an invalidation notification from a connection, use
this method in order to find out if any of the proxy objects you're
using are going away. */
- (id <Collecting>) proxies;
/* If you somehow have a connection to a server, but don't have it's
a proxy to its root object yet, you can use this to get it. */
- (Proxy*) rootProxy;
/* For getting the root object of a connection or port */
- rootObject;
+ rootObjectForInPort: (InPort*)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: (InPort*)aPort;
- setRootObject: anObj;
/* Querying and setting some instance variables */
- (int) outTimeout;
- (int) inTimeout;
- (void) setOutTimeout: (int)to;
- (void) setInTimeout: (int)to;
- (Class) inPortClass;
- (Class) outPortClass;
- (void) setInPortClass: (Class)aPortClass;
- (void) setOutPortClass: (Class)aPortClass;
- (Class) proxyClass;
- (Class) encodingClass;
- (Class) decodingClass;
- outPort;
- inPort;
- delegate;
- (void) setDelegate: anObj;
- (void) invalidate;
- (BOOL) isValid;
/* Only subclassers and power-users need worry about these */
- (Proxy*) proxyForTarget: (unsigned)target;
- (void) addProxy: (Proxy*)aProxy;
- (BOOL) includesProxyForTarget: (unsigned)target;
- (void) removeProxy: (Proxy*)aProxy;
- (id <Collecting>) localObjects;
- (void) addLocalObject: anObj;
- (BOOL) includesLocalObject: anObj;
- (void) removeLocalObject: anObj;
- (retval_t) forwardForProxy: (Proxy*)object
selector: (SEL)sel
argFrame: (arglist_t)frame;
- (const char *) typeForSelector: (SEL)sel remoteTarget: (unsigned)target;
- (unsigned) _encoderReferenceForConstPtr: (const void*)ptr;
- (const void*) _decoderConstPtrAtReference: (unsigned)xref;
- (unsigned) _encoderCreateReferenceForConstPtr: (const void*)ptr;
- (unsigned) _decoderCreateReferenceForConstPtr: (const void*)ptr;
@end
extern NSString *ConnectionBecameInvalidNotification;
@protocol ConnectedSelfCoding
+ (void) encodeObject: anObj withConnectedCoder: aRmc;
@end
@interface Object (ConnectionDelegate)
- (BOOL) makeNewConnection: c sender: parent;
- (Connection*) connection: ancestorConn didConnect: 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.
Normally return newConn. */
@end
#if 0 /* Put in Coder.m until ObjC runtime category-loading bug is fixed */
@interface Object (ConnectionRequests)
- classForConnectedCoder: aRmc;
/* Must return the class that will be created on the remote side
of the connection.
Used by the remote objects system to determine how the receiver
should be encoded across the network.
In general, you can:
return [Proxy class] to send a proxy of the receiver;
return [self class] to send the receiver bycopy.
The Object class implementation returns [Proxy class]. */
+ (void) encodeObject: anObject withConnectedCoder: aRmc;
/* This message is sent to the class returned by -classForConnectedCoder:
The Proxy class implementation encodes a proxy for anObject.
The Object class implementation encodes the receiver itself. */
@end
@interface Object (Retaining) <Retaining>
/* Make sure objects don't crash when you send them <Retaining> messages.
These implementations, however, do nothing. */
@end
#endif /* 0 Put in Coder.m */
#define CONNECTION_DEFAULT_TIMEOUT 15000 /* in milliseconds */
extern NSString *ConnectionBecameInvalidNotification;
extern NSString *ConnectionWasCreatedNotification;
extern NSString *RunLoopConnectionReplyMode;
#endif /* __Connection_h_GNUSTEP_BASE_INCLUDE */

View file

@ -1,35 +0,0 @@
/* Interface for GNU Objective-C mutex lock
Copyright (C) 1993,1994 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Date: July 1994
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __Lock_h_GNUSTEP_BASE_INCLUDE
#define __Lock_h_GNUSTEP_BASE_INCLUDE
#include <gnustep/base/preface.h>
#include <gnustep/base/Locking.h>
@interface Lock : NSObject <Locking>
{
}
@end
#endif /* __Lock_h_GNUSTEP_BASE_INCLUDE */

View file

@ -28,7 +28,6 @@
#include <gnustep/base/preface.h>
#include <stdlib.h>
#include <stdarg.h>
#include <gnustep/base/Lock.h>
#include <gnustep/base/Collecting.h>
#include <gnustep/base/Dictionary.h>
#include <Foundation/NSString.h>

View file

@ -24,28 +24,29 @@
#ifndef __NSNotification_h_GNUSTEP_BASE_INCLUDE
#define __NSNotification_h_GNUSTEP_BASE_INCLUDE
#include <gnustep/base/preface.h>
#include <gnustep/base/Notification.h>
#include <Foundation/NSObject.h>
@class NSString;
@class NSDictionary;
@interface NSNotification : NSObject
{
/* Make the instance size of this class match exactly the instance
size of Notification. Thus, behavior_class_add_class() will not
have to increase the instance size of NSNotification, and
NSNotification can safely be subclassed. */
char _NSNotification_placeholder[(sizeof(struct Notification)
- sizeof(struct NSObject))];
}
@protocol Notifying
- (NSString*) name;
- object;
- userInfo;
@end
/* Put this in a category to avoid unimportant errors due to behaviors. */
@interface NSNotification (GNUstep) <NSCopying>
@protocol NotificationPosting
- (void) postNotification: (id <Notifying>)notification;
@end
@interface NSNotification : NSObject <Notifying,NSCopying>
{
id _name;
id _object;
id _info;
}
/* Creating a Notification Object */
+ (NSNotification*) notificationWithName: (NSString*)name
object: object;

View file

@ -49,6 +49,14 @@ extern NSString *NSPortTimeoutException; /* OPENSTEP */
@end
@interface NSPort (GNUstep)
- (void) close;
+ (Class) outPacketClass;
- (Class) outPacketClass;
@end
extern NSString* NSPortDidBecomeInvalidNotification;
#define PortBecameInvalidNotification NSPortDidBecomeInvalidNotification

View file

@ -1,58 +0,0 @@
/* Interface for holding and dispatching notifications
Copyright (C) 1996 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: March 1996
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __Notification_h_GNUSTEP_BASE_INCLUDE
#define __Notification_h_GNUSTEP_BASE_INCLUDE
#include <gnustep/base/preface.h>
#include <Foundation/NSString.h>
#include <gnustep/base/KeyedCollecting.h>
#include <gnustep/base/NotificationDispatcher.h>
@protocol Notifying
- (NSString*) name;
- object;
- userInfo;
@end
@protocol NotificationPosting
- (void) postNotification: (id <Notifying>)notification;
@end
@interface Notification : NSObject <Notifying>
{
id _name;
id _object;
id _info;
}
+ notificationWithName: (NSString*)name
object: object;
+ notificationWithName: (NSString*)name
object: object
userInfo: info;
@end
#endif /* __Notification_h_GNUSTEP_BASE_INCLUDE */

View file

@ -1,82 +0,0 @@
/* Interface for GNU Objective-C proxy for remote objects messaging
Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: July 1994
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __Proxy_h_GNUSTEP_BASE_INCLUDE
#define __Proxy_h_GNUSTEP_BASE_INCLUDE
#include <gnustep/base/preface.h>
#include <gnustep/base/Connection.h>
#include <gnustep/base/Retaining.h>
@class ConnectedCoder;
@interface Proxy <Retaining>
{
@public
struct objc_class *isa;
unsigned _target;
Connection *_connection;
unsigned _retain_count;
#if NeXT_runtime
coll_cache_ptr _method_types;
Protocol *protocol;
#endif
}
/* xxx Change name to newForTarget:connection: */
+ newForRemoteTarget: (unsigned)target connection: (Connection*)c;
- self;
#if NeXT_runtime
+ class;
#else
+ (Class) class;
#endif
- (void) invalidateProxy;
- (BOOL) isProxy;
- (unsigned) targetForProxy;
- connectionForProxy;
- forward: (SEL)aSel :(arglist_t)frame;
- classForConnectedCoder: aRmc;
+ (void) encodeObject: anObject withConnectedCoder: aRmc;
+ newWithCoder: aCoder;
- (void) encodeWithCoder: aCoder;
/* Only needed with NeXT runtime. */
- (const char *) selectorTypeForProxy: (SEL)selector;
@end
@interface Object (IsProxy)
- (BOOL) isProxy;
@end
@interface Protocol (RemoteSelfCoding)
- classForConnectedCoder: aRmc;
@end
#endif /* __Proxy_h_GNUSTEP_BASE_INCLUDE */

View file

@ -1,57 +0,0 @@
/* Interface for reference-counted invalidation notifer object
Copyright (C) 1993, 1994, 1996 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: July 1994
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* Reference Counted object with invalidation notification
This object is just temporary. Eventually, we should separate
reference counting functionality from notification functionality */
/* xxx March 1995: Now that we have a root object that handles retaining,
we should create a plain Notifier class. */
#ifndef __RetainingNotifier_h
#define __RetainingNotifier_h
#include <gnustep/base/preface.h>
#include <gnustep/base/Lock.h>
#include <gnustep/base/InvalidationListening.h>
#include <gnustep/base/Retaining.h>
@interface RetainingNotifier : NSObject <Retaining>
{
Lock *refGate;
id *notificationList;
BOOL isValid;
int retain_count;
}
- init;
- (unsigned) retainCount;
- registerForInvalidationNotification: (id <InvalidationListening>)anObject;
- unregisterForInvalidationNotification: (id <InvalidationListening>)anObject;
- (BOOL) isValid;
- invalidate;
- copy;
@end
#endif /* __RetainingNotifier_h */

View file

@ -65,8 +65,6 @@
#include <gnustep/base/Port.h>
/* Remote messaging support objects */
#include <gnustep/base/Connection.h>
#include <gnustep/base/Proxy.h>
#include <gnustep/base/ConnectedCoder.h>
#include <gnustep/base/Invocation.h>

View file

@ -28,8 +28,8 @@
#include <gnustep/base/CStream.h>
#include <gnustep/base/Port.h>
#include <gnustep/base/MemoryStream.h>
#include <gnustep/base/Connection.h>
#include <gnustep/base/Proxy.h>
#include <Foundation/NSConnection.h>
#include <Foundation/NSProxy.h>
#include <assert.h>
#define PTR2LONG(P) (((char*)(P))-(char*)0)
@ -48,13 +48,13 @@ static BOOL debug_connected_coder = NO;
return;
}
- _initForWritingWithConnection: (Connection*)c
- _initForWritingWithConnection: (NSConnection*)c
sequenceNumber: (int)n
identifier: (int)i
{
OutPacket* packet = [[[[c outPort] outPacketClass] alloc]
OutPacket* packet = [[[[c sendPort] outPacketClass] alloc]
initForSendingWithCapacity: DEFAULT_SIZE
replyInPort: [c inPort]];
replyInPort: [c receivePort]];
[super initForWritingToStream: packet];
[packet release];
connection = c;
@ -69,7 +69,7 @@ static BOOL debug_connected_coder = NO;
return self;
}
+ newForWritingWithConnection: (Connection*)c
+ newForWritingWithConnection: (NSConnection*)c
sequenceNumber: (int)n
identifier: (int)i
{
@ -83,7 +83,7 @@ static BOOL debug_connected_coder = NO;
- (void) dismiss
{
id packet = [cstream stream];
[[connection outPort] sendPacket: packet timeout:15.0];
[[connection sendPort] sendPacket: packet timeout:15.0];
if (debug_connected_coder)
fprintf(stderr, "dismiss 0x%x: #=%d i=%d %d\n",
(unsigned)self, sequence_number, identifier,
@ -148,7 +148,7 @@ static BOOL debug_connected_coder = NO;
}
+ newDecodingWithConnection: (Connection*)c
+ newDecodingWithConnection: (NSConnection*)c
timeout: (int) timeout
{
ConnectedDecoder *cd;
@ -157,7 +157,7 @@ static BOOL debug_connected_coder = NO;
id reply_port;
/* Try to get a packet. */
in_port = [c inPort];
in_port = [c receivePort];
packet = [in_port receivePacketWithTimeout: timeout];
if (!packet)
return nil; /* timeout */
@ -166,7 +166,7 @@ static BOOL debug_connected_coder = NO;
cd = [self newReadingFromStream: packet];
[packet release];
reply_port = [packet replyPort];
cd->connection = [Connection newForInPort: in_port
cd->connection = [NSConnection newForInPort: in_port
outPort: reply_port
ancestorConnection: c];
@ -185,19 +185,19 @@ static BOOL debug_connected_coder = NO;
}
+ newDecodingWithPacket: (InPacket*)packet
connection: (Connection*)c
connection: (NSConnection*)c
{
ConnectedDecoder *cd;
id in_port;
id reply_port;
in_port = [c inPort];
in_port = [c receivePort];
/* Create the new ConnectedDecoder */
cd = [self newReadingFromStream: packet];
[packet release];
reply_port = [packet replyOutPort];
cd->connection = [Connection newForInPort: in_port
cd->connection = [NSConnection newForInPort: in_port
outPort: reply_port
ancestorConnection: c];

File diff suppressed because it is too large Load diff

View file

@ -76,7 +76,6 @@ BinaryTreeNode.m \
CircularArray.m \
Collection.m \
ConnectedCoder.m \
Connection.m \
Coder.m \
CStream.m \
Decoder.m \
@ -91,23 +90,17 @@ Invocation.m \
KeyedCollection.m \
LinkedList.m \
LinkedListNode.m \
Lock.m \
MachPort.m \
Magnitude.m \
MallocAddress.m \
MappedCollector.m \
MemoryStream.m \
Notification.m \
NotificationDispatcher.m \
OrderedCollection.m \
Port.m \
Proxy.m \
Queue.m \
RawCStream.m \
RBTree.m \
RBTreeNode.m \
RNGAdditiveCongruential.m \
RNGBerkeley.m \
Set.m \
SplayTree.m \
Stack.m \
@ -115,10 +108,10 @@ StdioStream.m \
Stream.m \
TcpPort.m \
TextCStream.m \
Time.m \
UdpPort.m \
Unicode.m \
UnixFileHandle.m \
$(GNU_EXTRAS_MFILES) \
behavior.m \
lex.pl.m \
lex.sf.m \
@ -147,7 +140,12 @@ stringsfile.tab.m \
mframe.m \
objc-gnu2next.m
#Random.m \
GNU_EXTRAS_MFILES = \
Magnitude.m \
Random.m \
RNGAdditiveCongruential.m \
RNGBerkeley.m \
Time.m
GNU_CFILES = \
md5.c \
@ -187,7 +185,6 @@ Collecting.h \
Collection.h \
CollectionPrivate.h \
ConnectedCoder.h \
Connection.h \
CStream.h \
CStreaming.h \
DelegatePool.h \
@ -207,20 +204,17 @@ KeyedCollecting.h \
KeyedCollection.h \
LinkedList.h \
LinkedListNode.h \
Lock.h \
Locking.h \
MachPort.h \
Magnitude.h \
MallocAddress.h \
MappedCollector.h \
MemoryStream.h \
Notification.h \
NotificationDispatcher.h \
Ordering.h \
OrderedCollecting.h \
OrderedCollection.h \
Port.h \
Proxy.h \
Queue.h \
RBTree.h \
RBTreeNode.h \
@ -229,7 +223,6 @@ RNGBerkeley.h \
RandomGenerating.h \
RawCStream.h \
Retaining.h \
RetainingNotifier.h \
RunLoop.h \
Set.h \
SplayTree.h \

View file

@ -1,47 +0,0 @@
/* Implementation of Objective-C Lock object
Copyright (C) 1993,1994 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Date: July 1994
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#include <gnustep/base/Lock.h>
/* It doesn't make sense to implement this until
we get a thread-safe runtime. */
@implementation Lock
- (void) lock
{
return;
}
- (void) unlock
{
return;
}
- (BOOL) tryLock
{
return YES;
}
@end

View file

@ -27,21 +27,20 @@
#include <config.h>
#include <gnustep/base/MachPort.h>
#include <gnustep/base/Connection.h>
#include <gnustep/base/Lock.h>
#include <Foundation/NSLock.h>
#include <gnustep/base/Set.h>
#include <mach/cthreads.h>
#include <mach/notify.h>
static Dictionary *portDictionary;
static Lock *portDictionaryGate;
static NSLock *portDictionaryGate;
@implementation MachPort
+ initialize
{
portDictionaryGate = [Lock new];
portDictionaryGate = [NSLock new];
assert(sizeof(int) == sizeof(port_t));
portDictionary = [[Dictionary alloc]
initWithType:@encode(id)

View file

@ -88,7 +88,7 @@ after-distclean::
gnustep/base: FORCE
if [ ! -d gnustep ]; then \
mkdir gnustep; \
cd gnustep ; $(LN_S) ../include base;
cd gnustep ; $(LN_S) ../include base; \
fi
# Make necessary links to source headers if compiling in seperate dir
# These are separate directories because one contains the .h files

View file

@ -35,7 +35,7 @@
#include <Foundation/DistributedObjects.h>
#include <gnustep/base/TcpPort.h>
#include <gnustep/base/mframe.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/NotificationDispatcher.h>
#include <gnustep/base/MallocAddress.h>
#include <Foundation/NSRunLoop.h>
#include <Foundation/NSArray.h>
@ -44,7 +44,9 @@
#include <Foundation/NSString.h>
#include <Foundation/NSDate.h>
#include <Foundation/NSException.h>
#include <Foundation/NSLock.h>
#include <Foundation/NSThread.h>
#include <Foundation/NSNotification.h>
#include <assert.h>
NSString* NSConnectionReplyMode = @"NSConnectionReplyMode";
@ -246,10 +248,10 @@ static int debug_connection = 0;
/* We could write -hash and -isEqual implementations for NSConnection */
static NSMutableArray *connection_array;
static NSMutableArray *not_owned;
static Lock *connection_array_gate;
static NSLock *connection_array_gate;
static NSMutableDictionary *root_object_dictionary;
static Lock *root_object_dictionary_gate;
static NSLock *root_object_dictionary_gate;
static NSMapTable *receive_port_2_ancestor;
@ -258,9 +260,9 @@ static NSMapTable *all_connections_local_cached = NULL;
/* rmc handling */
static NSMutableArray *received_request_rmc_queue;
static Lock *received_request_rmc_queue_gate;
static NSLock *received_request_rmc_queue_gate;
static NSMutableArray *received_reply_rmc_queue;
static Lock *received_reply_rmc_queue_gate;
static NSLock *received_reply_rmc_queue_gate;
static int messages_received_count;
@ -320,7 +322,7 @@ static int messages_received_count;
{
not_owned = [[NSMutableArray alloc] initWithCapacity:8];
connection_array = [[NSMutableArray alloc] initWithCapacity:8];
connection_array_gate = [Lock new];
connection_array_gate = [NSLock new];
/* xxx When NSHashTable's are working, change this. */
all_connections_local_targets =
NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks,
@ -329,11 +331,11 @@ static int messages_received_count;
NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks,
NSObjectMapValueCallBacks, 0);
received_request_rmc_queue = [[NSMutableArray alloc] initWithCapacity:32];
received_request_rmc_queue_gate = [Lock new];
received_request_rmc_queue_gate = [NSLock new];
received_reply_rmc_queue = [[NSMutableArray alloc] initWithCapacity:32];
received_reply_rmc_queue_gate = [Lock new];
received_reply_rmc_queue_gate = [NSLock new];
root_object_dictionary = [[NSMutableDictionary alloc] initWithCapacity:8];
root_object_dictionary_gate = [Lock new];
root_object_dictionary_gate = [NSLock new];
receive_port_2_ancestor =
NSCreateMapTable (NSNonOwnedPointerMapKeyCallBacks,
NSNonOwnedPointerMapValueCallBacks, 0);

View file

@ -23,17 +23,81 @@
#include <config.h>
#include <Foundation/NSNotification.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/behavior.h>
@implementation NSNotification
/* This class is fully implemented in GNU's Notification. */
+ (void) initialize
/* This is the designated initializer. */
- initWithName: (NSString*)name
object: object
userInfo: info
{
if (self == [NSNotification class])
class_add_behavior (self, [Notification class]);
[super init];
_name = [name retain];
_object = [object retain];
_info = [info retain];
return self;
}
- (void) dealloc
{
[_name release];
[_object release];
[_info release];
[super dealloc];
}
/* Creating autoreleased Notification objects. */
+ notificationWithName: (NSString*)name
object: object
userInfo: info
{
return [[[self alloc] initWithName: name
object: object
userInfo: info]
autorelease];
}
+ notificationWithName: (NSString*)name
object: object
{
return [self notificationWithName: name
object: object
userInfo: nil];
}
/* Querying a Notification object. */
- (NSString*) name
{
return _name;
}
- object
{
return _object;
}
- userInfo
{
return _info;
}
/* NSCopying protocol. */
- copyWithZone: (NSZone*)zone
{
if (NSShouldRetainWithZone (self, zone))
return [self retain];
/* xxx How deep should the copy go? Should we copy _name, etc.? */
return [[[self class] allocWithZone: zone]
initWithName: _name
object: _object
userInfo: _info];
}
@end

View file

@ -66,6 +66,7 @@
#include <sys/types.h>
#ifndef __WIN32__
#include <time.h>
#include <sys/time.h>
#endif /* !__WIN32__ */
#include <limits.h>

View file

@ -27,7 +27,7 @@
#include <Foundation/NSLock.h>
#include <Foundation/NSString.h>
#include <gnustep/base/o_map.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/NotificationDispatcher.h>
// Class variables

View file

@ -1,103 +0,0 @@
/* Implementation of object for holding a notification
Copyright (C) 1996 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: March 1996
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#include <gnustep/base/Notification.h>
@implementation Notification
/* This is the designated initializer. */
- initWithName: (NSString*)name
object: object
userInfo: info
{
[super init];
_name = [name retain];
_object = [object retain];
_info = [info retain];
return self;
}
- (void) dealloc
{
[_name release];
[_object release];
[_info release];
[super dealloc];
}
/* Creating autoreleased Notification objects. */
+ notificationWithName: (NSString*)name
object: object
userInfo: info
{
return [[[self alloc] initWithName: name
object: object
userInfo: info]
autorelease];
}
+ notificationWithName: (NSString*)name
object: object
{
return [self notificationWithName: name
object: object
userInfo: nil];
}
/* Querying a Notification object. */
- (NSString*) name
{
return _name;
}
- object
{
return _object;
}
- userInfo
{
return _info;
}
/* NSCopying protocol. */
- copyWithZone: (NSZone*)zone
{
if (NSShouldRetainWithZone (self, zone))
return [self retain];
/* xxx How deep should the copy go? Should we copy _name, etc.? */
return [[[self class] allocWithZone: zone]
initWithName: _name
object: _object
userInfo: _info];
}
@end

View file

@ -29,10 +29,10 @@
#include <config.h>
#include <gnustep/base/NotificationDispatcher.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/LinkedListNode.h>
#include <gnustep/base/Array.h>
#include <gnustep/base/Invocation.h>
#include <Foundation/NSNotification.h>
#include <Foundation/NSException.h>
@ -558,8 +558,7 @@ static NotificationDispatcher *default_notification_dispatcher = nil;
- (void) postNotification: notification
{
/* This cast avoids complaints about different types for the -name method. */
id notification_name = [(Notification*)notification name];
id notification_name = [notification name];
id notification_object = [notification object];
id nr;
LinkedList *nr_list;
@ -647,7 +646,7 @@ static NotificationDispatcher *default_notification_dispatcher = nil;
- (void) postNotificationName: (NSString*)name
object: object
{
[self postNotification: [Notification notificationWithName: name
[self postNotification: [NSNotification notificationWithName: name
object: object]];
}
@ -655,7 +654,7 @@ static NotificationDispatcher *default_notification_dispatcher = nil;
object: object
userInfo: info
{
[self postNotification: [Notification notificationWithName: name
[self postNotification: [NSNotification notificationWithName: name
object: object
userInfo: info]];
}

View file

@ -24,7 +24,7 @@
#include <config.h>
#include <gnustep/base/Port.h>
#include <gnustep/base/Coder.h> /* for Coding protocol in Object category */
#include <gnustep/base/Notification.h>
#include <gnustep/base/NotificationDispatcher.h>
@implementation Port

View file

@ -1,493 +0,0 @@
/* Implementation of GNU Objective-C Proxy for remote object messaging
Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Date: July 1994
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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <config.h>
#include <stdlib.h>
#include <stdarg.h>
#include <gnustep/base/preface.h>
#include <gnustep/base/Proxy.h>
#include <gnustep/base/Connection.h>
#include <gnustep/base/Port.h>
#include <gnustep/base/TcpPort.h>
#include <gnustep/base/ConnectedCoder.h>
#include <Foundation/NSException.h>
#include <assert.h>
static int debug_proxy = 0;
#if NeXT_runtime
static id tmp_kludge_protocol = nil;
#endif
@implementation Proxy
/* Required by NeXT runtime */
+ (void) initialize
{
return;
}
#if NeXT_runtime
+ setProtocolForProxies: (Protocol*)p
{
tmp_kludge_protocol = p;
return self;
}
#endif
/* This is the designated initializer. */
+ newForRemoteTarget: (unsigned)target connection: (Connection*)connection
{
Proxy *new_proxy;
assert ([connection isValid]);
/* If there already is a proxy for this target/connection combination,
don't create a new one, just return the old one. */
if ((new_proxy = [connection proxyForTarget: target]))
{
return new_proxy;
}
/* There isn't one already created; make a new proxy object,
and set its ivars. */
new_proxy = class_create_instance (self);
new_proxy->_target = target;
new_proxy->_connection = connection;
new_proxy->_retain_count = 0;
#if NeXT_runtime
new_proxy->_method_types = coll_hash_new(32,
elt_hash_void_ptr,
elt_compare_void_ptrs);
new_proxy->protocol = nil;
#endif
if (debug_proxy)
printf("Created new proxy=0x%x target 0x%x conn 0x%x\n",
(unsigned)new_proxy,
(unsigned)new_proxy->_target,
(unsigned)connection);
/* Register this proxy with the connection. */
[connection addProxy: new_proxy];
return new_proxy;
}
- notImplemented: (SEL)aSel
{
[NSException raise: NSGenericException
format: @"Proxy notImplemented %s", sel_get_name(aSel)];
return self;
}
- self
{
return self;
}
- awakeAfterUsingCoder: aDecoder
{
return self;
}
#if NeXT_runtime
+ class
{
return self;
}
#else
+ (Class) class
{
return (Class)self;
}
#endif
- (void) invalidateProxy
{
/* xxx Who calls this? */
/* xxx What should go here? */
[_connection removeProxy: self];
}
- (BOOL) isProxy
{
return YES;
}
- (void) encodeWithCoder: aRmc
{
if (![_connection isValid])
[NSException
raise: NSGenericException
format: @"Trying to encode an invalid Proxy.\n"
@"You should request ConnectionBecameInvalidNotification's and\n"
@"remove all references to the Proxy's of invalid Connections."];
[[self classForConnectedCoder: aRmc]
encodeObject: self withConnectedCoder: aRmc];
}
- classForConnectedCoder: aRmc;
{
return object_get_class (self);
}
static inline BOOL class_is_kind_of (Class self, Class aClassObject)
{
Class class;
for (class = self; class!=Nil; class = class_get_super_class(class))
if (class==aClassObject)
return YES;
return NO;
}
/* Encoding and Decoding Proxies on the wire. */
/* This is the proxy tag; it indicates where the local object is,
and determines whether the reply port to the Connection-where-the-
proxy-is-local needs to encoded/decoded or not. */
enum
{
PROXY_LOCAL_FOR_RECEIVER = 0,
PROXY_LOCAL_FOR_SENDER,
PROXY_REMOTE_FOR_BOTH
};
+ (void) encodeObject: anObject withConnectedCoder: aRmc
{
unsigned proxy_target;
unsigned char proxy_tag;
Connection *encoder_connection;
encoder_connection = [aRmc connection];
assert (encoder_connection);
if (![encoder_connection isValid])
[NSException
raise: NSGenericException
format: @"Trying to encode to an invalid Connection.\n"
@"You should request ConnectionBecameInvalidNotification's and\n"
@"remove all references to the Proxy's of invalid Connections."];
/* Find out if anObject is a proxy or not. */
if (class_is_kind_of (object_get_class (anObject), self))
{
/* anObject is a Proxy, or a Proxy subclass */
Connection *proxy_connection = [anObject connectionForProxy];
proxy_target = [anObject targetForProxy];
if (encoder_connection == proxy_connection)
{
/* This proxy is a local object on the other side */
proxy_tag = PROXY_LOCAL_FOR_RECEIVER;
if (debug_proxy)
fprintf(stderr, "Sending a proxy, will be local 0x%x "
"connection 0x%x\n",
[anObject targetForProxy],
(unsigned)proxy_connection);
[aRmc encodeValueOfCType: @encode(typeof(proxy_tag))
at: &proxy_tag
withName: @"Proxy is local for receiver"];
[aRmc encodeValueOfCType: @encode(typeof(proxy_target))
at: &proxy_target
withName: @"Proxy target"];
}
else
{
/* This proxy will still be remote on the other side */
OutPort *proxy_connection_out_port = [proxy_connection outPort];
assert (proxy_connection_out_port);
assert ([proxy_connection_out_port isValid]);
assert (proxy_connection_out_port != [encoder_connection outPort]);
/* xxx Remove this after debugging, because it won't be true
for connections across different hosts. */
assert ([(id)proxy_connection_out_port portNumber]
!= [(id)[encoder_connection outPort] portNumber]);
assert ([proxy_connection inPort] == [encoder_connection inPort]);
proxy_tag = PROXY_REMOTE_FOR_BOTH;
if (debug_proxy)
fprintf(stderr, "Sending triangle-connection proxy 0x%x "
"proxy-conn 0x%x to-conn 0x%x\n",
[anObject targetForProxy],
(unsigned)proxy_connection, (unsigned)encoder_connection);
/* It's remote here, so we need to tell other side where to form
triangle connection to */
[aRmc encodeValueOfCType: @encode(typeof(proxy_tag))
at: &proxy_tag
withName: @"Proxy is remote for both sender and receiver"];
[aRmc encodeValueOfCType: @encode(typeof(proxy_target))
at: &proxy_target
withName: @"Proxy target"];
[aRmc encodeBycopyObject: proxy_connection_out_port
withName: @"Proxy outPort"];
}
}
else
{
/* anObject is a non-Proxy object, e.g. NSObject. */
/* But now were sending this object across the wire in proxy form. */
proxy_target = PTR2LONG(anObject);
proxy_tag = PROXY_LOCAL_FOR_SENDER;
if (debug_proxy)
fprintf(stderr, "Sending a proxy for local 0x%x\n",
(unsigned)anObject);
/* Let the connection know that we're going; this also retains anObj;
it's OK to send -addLocalObject: more than once for the same
object, because it will only really get added and retained once. */
[[aRmc connection] addLocalObject: anObject];
[aRmc encodeValueOfCType: @encode(typeof(proxy_tag))
at: &proxy_tag
withName: @"Proxy is local for the sender"];
[aRmc encodeValueOfCType: @encode(typeof(proxy_target))
at: &proxy_target
withName: @"Proxy target"];
}
}
+ newWithCoder: aRmc
{
unsigned char proxy_tag;
unsigned target;
id decoder_connection;
if ([aRmc class] != [ConnectedDecoder class])
[NSException
raise: NSGenericException
format: @"Proxy objects only decode with ConnectedDecoder class"];
decoder_connection = [aRmc connection];
assert (decoder_connection);
/* First get the tag, so we know what values need to be decoded. */
[aRmc decodeValueOfCType: @encode(typeof(proxy_tag))
at: &proxy_tag
withName: NULL];
switch (proxy_tag)
{
case PROXY_LOCAL_FOR_RECEIVER:
/* This was a proxy on the other side of the connection, but
here it's local. Just get the target address, make sure
that it is indeed the address of a local object that we
vended to the remote connection, then simply return the target
casted to (id). */
[aRmc decodeValueOfCType: @encode(typeof(target))
at: &target
withName: NULL];
if (debug_proxy)
fprintf(stderr, "Receiving a proxy for local object 0x%x "
"connection 0x%x\n", target, (unsigned)decoder_connection);
if (![[decoder_connection class] includesLocalObject: (id)target])
[NSException raise: @"ProxyDecodedBadTarget"
format: @"No local object with given address"];
return (id) target;
case PROXY_LOCAL_FOR_SENDER:
/* This was a local object on the other side of the connection,
but here it's a proxy object. Get the target address, and
send [Proxy +newForRemoteTarget:connection:]; this will return
the proxy object we already created for this target, or create
a new proxy object if necessary. */
[aRmc decodeValueOfCType: @encode(typeof(target))
at: &target
withName: NULL];
if (debug_proxy)
fprintf(stderr, "Receiving a proxy, was local 0x%x connection 0x%x\n",
(unsigned)target, (unsigned)decoder_connection);
return [self newForRemoteTarget: target
connection: decoder_connection];
case PROXY_REMOTE_FOR_BOTH:
/* This was a proxy on the other side of the connection, and it
will be a proxy on this side too; that is, the local version
of this object is not on this host, not on the host the
ConnectedDecoder is connected to, but on a *third* host.
This is why I call this a "triangle connection". In addition
to decoding the target, we decode the OutPort object that we
will use to talk directly to this third host. We send
[Connection +newForInPort:outPort:ancestorConnection:]; this
will either return the connection already created for this
inPort/outPort pair, or create a new connection if necessary. */
{
Connection *proxy_connection;
id proxy_connection_out_port = nil;
[aRmc decodeValueOfCType: @encode(typeof(target))
at: &target
withName: NULL];
[aRmc decodeObjectAt: &proxy_connection_out_port
withName: NULL];
assert (proxy_connection_out_port);
proxy_connection = [[decoder_connection class]
newForInPort: [decoder_connection inPort]
outPort: proxy_connection_out_port
ancestorConnection: decoder_connection];
if (debug_proxy)
fprintf(stderr, "Receiving a triangle-connection proxy 0x%x "
"connection 0x%x\n", target, (unsigned)proxy_connection);
assert (proxy_connection != decoder_connection);
assert ([proxy_connection isValid]);
return [self newForRemoteTarget: target
connection: proxy_connection];
}
default:
/* xxx This should be something different than NSGenericException. */
[NSException raise: NSGenericException
format: @"Bad proxy tag"];
}
/* Not reached. */
return nil;
}
- (unsigned) targetForProxy
{
return _target;
}
- connectionForProxy
{
return _connection;
}
- (const char *) selectorTypeForProxy: (SEL)selector
{
#if NeXT_runtime
#if 0
{
/* This is bogosity. You are required to include all methods sent
by any proxies in the protocol you pass to
+setProtocolForProxy: */
struct objc_method_description *md;
md = [tmp_kludge_protocol descriptionForInstanceMethod:selector];
if (md)
return md->types;
else
return NULL;
}
#elif 0
{
/* This is disgusting bogosity. This only works if some other
class in the executable responds to this method. */
/* xxx Look in the class hash table at all classes... */
}
#else
{
elt e;
const char *t;
e = coll_hash_value_for_key(_method_types, selector);
t = e.char_ptr_u;
if (!t)
{
/* This isn't what we want, unless the remote machine has
the same architecture as us. */
t = [connection _typeForSelector:selector remoteTarget:target];
coll_hash_add(&_method_types, (void*)selector, t);
}
return t;
}
#endif /* 1 */
#else /* NeXT_runtime */
return sel_get_type (selector);
#endif
}
/* xxx Clean up all this junk below */
- (oneway void) release
{
if (!_retain_count--)
{
[self invalidateProxy];
[self dealloc];
}
}
- retain
{
_retain_count++;
return self;
}
- (void) dealloc
{
#if NeXT_runtime
coll_hash_delete (_method_types);
object_dispose ((Object*)self);
#else
NSDeallocateObject ((id)self);
#endif
}
- forward: (SEL)aSel :(arglist_t)frame
{
if (debug_proxy)
printf("Proxy forwarding %s\n", sel_get_name(aSel));
if (![_connection isValid])
[NSException
raise: NSGenericException
format: @"Trying to send message to an invalid Proxy.\n"
@"You should request ConnectionBecameInvalidNotification's and\n"
@"remove all references to the Proxy's of invalid Connections."];
return [_connection forwardForProxy: self
selector: aSel
argFrame: frame];
}
/* We need to make an effort to pass errors back from the server
to the client */
- (unsigned) retainCount
{
return _retain_count + 1;
}
- autorelease
{
/* xxx Problems here if the Connection goes away? */
[[NSObject autoreleaseClass] addObject: self];
return self;
}
- (NSZone*) zone
{
return NULL; /* xxx Fix this. */
}
@end
@implementation Protocol (RemoteSelfCoding)
/* Perhaps Protocol's should be sent bycopy? */
- classForConnectedCoder: aRmc;
{
return [Proxy class];
}
@end

View file

@ -37,7 +37,7 @@
#include <gnustep/base/preface.h>
#include <gnustep/base/TcpPort.h>
#include <gnustep/base/Array.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/NotificationDispatcher.h>
#include <gnustep/base/NSException.h>
#include <Foundation/NSRunLoop.h>
#include <gnustep/base/Invocation.h>
@ -76,6 +76,7 @@
#endif /* !__WIN32__ */
#include <string.h> /* for memset() and strchr() */
#ifndef __WIN32__
#include <time.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/errno.h>

View file

@ -25,11 +25,10 @@
#include <config.h>
#include <gnustep/base/UdpPort.h>
#include <gnustep/base/Lock.h>
#include <gnustep/base/Connection.h>
#include <gnustep/base/Coder.h>
#include <gnustep/base/ConnectedCoder.h>
#include <gnustep/base/Array.h>
#include <Foundation/NSLock.h>
#include <assert.h>
#ifndef __WIN32__
#include <unistd.h>
@ -40,6 +39,7 @@
#endif /* _AIX */
#ifndef __WIN32__
#include <netdb.h>
#include <time.h>
#include <sys/time.h>
#endif /* !__WIN32__ */
@ -62,7 +62,7 @@
#define MAX_PACKET_SIZE 2048
/* Make this a hashtable? */
static Lock* udp_port_gate = nil;
static NSLock* udp_port_gate = nil;
static BOOL udp_port_debug = NO;

View file

@ -38,6 +38,8 @@
#ifdef WIN32
#include <Windows32/Sockets.h>
#else
#include <time.h>
#include <sys/time.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>

View file

@ -95,8 +95,7 @@ behavior_class_add_class (Class class, Class behavior)
@"have subclassed the class. There are two solutions:\n"
@"(1) Don't subclass it; (2) Add placeholder instance\n"
@"variables to the class, so the behavior-addition code\n"
@"will not have to increase the instance size, (see\n"
@"Foundation/NSNotification.h for a clean way to do this).");
@"will not have to increase the instance size\n");
class->instance_size = behavior->instance_size;
}

View file

@ -51,7 +51,6 @@ __objc_class_name_ConnectedEncoder
__objc_category_name_Coder_NSArchiverCompatibility
__objc_category_name_Coder_NSCoderCompatibility
__objc_class_name_Coder
__objc_class_name_Connection
__objc_class_name_CStream
__objc_class_name_Decoder
__objc_class_name_DelegatePool
@ -73,7 +72,6 @@ __objc_class_name_KeyEnumerator
__objc_class_name_KeyedCollection
__objc_class_name_LinkedList
__objc_class_name_LinkedListNode
__objc_class_name_Lock
__objc_class_name_Magnitude
__objc_class_name_MallocAddress
__objc_class_name_MappedCollector
@ -81,7 +79,6 @@ __objc_class_name_MemoryStream
inchar_func
outchar_func
unchar_func
__objc_class_name_Notification
__objc_category_name_NotificationDispatcher_OpenStepCompat
__objc_class_name_NotificationDispatcher
__objc_class_name_NotificationInvocation
@ -95,7 +92,6 @@ __objc_class_name_OutPort
__objc_class_name_Port
__objc_category_name_NSObject_ForProxy
__objc_category_name_Protocol_RemoteSelfCoding
__objc_class_name_Proxy
__objc_class_name_Queue
__objc_class_name_Random
__objc_class_name_RawCStream

View file

@ -38,7 +38,6 @@ test01 \
test02 \
heap \
nxst \
randoms \
prepend \
pipes \
server \
@ -55,8 +54,6 @@ nshost \
nsset \
nsprocessinfo \
nsarchiver \
oldclient \
oldserver \
invocation \
invocation2 \
diningPhilosophers \

View file

@ -1,144 +0,0 @@
#include <stdio.h>
#include <gnustep/base/TcpPort.h>
#include <gnustep/base/Connection.h>
#include <gnustep/base/Proxy.h>
#include <gnustep/base/Coder.h>
#include <gnustep/base/BinaryCStream.h>
#include <Foundation/NSString.h>
#include <gnustep/base/RunLoop.h>
#include <Foundation/NSDate.h>
#include <assert.h>
#include "oldserver.h"
int main(int argc, char *argv[])
{
id p;
id callback_receiver = [NSObject new];
id o;
id localObj;
unsigned long i = 4;
id c;
int j,k;
foo f = {99, "cow", 9876543};
foo f2;
foo *fp;
const char *n;
int a3[3] = {66,77,88};
struct myarray ma = {{55,66,77}};
double dbl = 3.14159265358979323846264338327;
double *dbl_ptr;
char *string = "Hello from the client";
small_struct small = {12};
BOOL b;
const char *type;
[Coder setDebugging:YES];
[BinaryCStream setDebugging:YES];
#if NeXT_runtime
[Proxy setProtocolForProxies:@protocol(AllProxies)];
#endif
if (argc > 1)
{
if (argc > 2)
p = [Connection rootProxyAtName: [NSString stringWithCString: argv[2]]
onHost: [NSString stringWithCString:argv[1]]];
else
p = [Connection rootProxyAtName:@"test2server"
onHost:[NSString stringWithCString:argv[1]]];
}
else
p = [Connection rootProxyAtName:@"test2server"
onHost:nil];
c = [p connectionForProxy];
type = [c typeForSelector:sel_get_any_uid("name")
remoteTarget:[p targetForProxy]];
printf(">>type = %s\n", type);
printf(">>list proxy's hash is 0x%x\n",
(unsigned)[p hash]);
printf(">>list proxy's self is 0x%x = 0x%x\n",
(unsigned)[p self], (unsigned)p);
n = [p name];
printf(">>proxy's name is (%s)\n", n);
[p print:">>This is a message from the client."];
printf(">>getLong:(out) to server i = %lu\n", i);
[p getLong:&i];
printf(">>getLong:(out) from server i = %lu\n", i);
assert(i == 3);
o = [p objectAt:0];
printf(">>object proxy's hash is 0x%x\n", (unsigned)[o hash]);
[p shout];
[p callbackNameOn:callback_receiver];
/* this next line doesn't actually test callbacks, it tests
sending the same object twice in the same message. */
[p callbackNameOn:p];
b = [p doBoolean:YES];
printf(">>BOOL value is '%c' (0x%x)\n", b, (int)b);
#if 0
/* Both these cause problems because GCC encodes them as "*",
indistinguishable from strings. */
b = NO;
[p getBoolean:&b];
printf(">>BOOL reference is '%c' (0x%x)\n", b, (int)b);
b = NO;
[p getUCharPtr:&b];
printf(">>UCHAR reference is '%c' (0x%x)\n", b, (int)b);
#endif
fp = [p sendStructPtr:&f];
fp->i = 11;
[p sendStruct:f];
[p sendSmallStruct:small];
[p sendStructArray:ma];
#if 0
/* returning structures isn't working yet. */
f2 = [p returnStruct];
printf(">>returned foo: i=%d s=%s l=%lu\n",
f2.i, f2.s, f2.l);
#endif
{
float f = 98.6f;
printf(">>sending double %f, float %f\n", dbl, f);
[p sendDouble:dbl andFloat:f];
}
dbl_ptr = [p doDoublePointer:&dbl];
printf(">>got double %f from server\n", *dbl_ptr);
[p sendCharPtrPtr:&string];
/* testing "-perform:" */
if (p != [p perform:sel_get_any_uid("self")])
[NSObject error:"trying perform:"];
/* testing "bycopy" */
/* reverse the order on these next two and it doesn't crash,
however, having manyArgs called always seems to crash.
Was this problem here before object forward references?
Check a snapshot.
Hmm. It seems like a runtime selector-handling bug. */
if (![p isProxy])
[p manyArgs:1 :2 :3 :4 :5 :6 :7 :8 :9 :10 :11 :12];
[p sendBycopy:callback_receiver];
printf(">>returned float %f\n", [p returnFloat]);
printf(">>returned double %f\n", [p returnDouble]);
localObj = [[NSObject alloc] init];
[p addObject:localObj];
k = [p count];
for (j = 0; j < k; j++)
{
id remote_peer_obj = [p objectAt:j];
printf("triangle %d object proxy's hash is 0x%x\n",
j, (unsigned)[remote_peer_obj hash]);
/* xxx look at this again after we use release/retain everywhere */
if ([remote_peer_obj isProxy])
[remote_peer_obj release];
remote_peer_obj = [p objectAt:j];
printf("repeated triangle %d object proxy's hash is 0x%x\n",
j, (unsigned)[remote_peer_obj hash]);
}
[RunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 20 * 60]];
[c invalidate];
exit(0);
}

View file

@ -1,234 +0,0 @@
#include <gnustep/base/preface.h>
#include <stdio.h>
#include <gnustep/base/TcpPort.h>
#include <gnustep/base/BinaryCStream.h>
#include <gnustep/base/Connection.h>
#include <gnustep/base/Proxy.h>
#include <Foundation/NSString.h>
#include <gnustep/base/Notification.h>
#include <gnustep/base/RunLoop.h>
#include "oldserver.h"
@implementation Server
- init
{
the_array = [[Array alloc] init];
return self;
}
- (unsigned) count
{
return [the_array count];
}
- (void) addObject: o
{
[the_array addObject:o];
}
- objectAt: (unsigned)i
{
return [the_array objectAtIndex: i];
}
- print: (const char *)msg
{
printf(">>%s\n", msg);
return self;
}
- getLong: (out unsigned long*)i
{
printf(">>getLong:(out) from client %lu\n", *i);
*i = 3;
printf(">>getLong:(out) to client %lu\n", *i);
return self;
}
- (oneway void) shout
{
printf(">>Ahhhhh\n");
return;
}
- callbackNameOn: obj
{
printf (">>callback name is (%s)\n", object_get_class_name (obj));
return self;
}
/* sender must also respond to 'bounce:count:' */
- bounce: sender count: (int)c
{
if (--c)
[sender bounce:self count:c];
return self;
}
- (BOOL) doBoolean: (BOOL)b
{
printf(">> got boolean '%c' (0x%x) from client\n", b, (unsigned int)b);
return YES;
}
/* This causes problems, because the runtime encodes this as "*",
a string! */
- getBoolean: (BOOL*)bp
{
printf(">> got boolean pointer '%c' (0x%x) from client\n",
*bp, (unsigned int)*bp);
return self;
}
/* This also causes problems, because the runtime also encodes this as "*",
a string! */
- getUCharPtr: (unsigned char *)ucp
{
printf(">> got unsignec char pointer '%c' (0x%x) from client\n",
*ucp, (unsigned int)*ucp);
return self;
}
/* This isn't working yet */
- (foo*) sendStructPtr: (foo*)f
{
printf(">>reference: i=%d s=%s l=%lu\n",
f->i, f->s, f->l);
f->i = 88;
return f;
}
- sendStruct: (foo)f
{
printf(">>value: i=%d s=%s l=%lu\n",
f.i, f.s, f.l);
f.i = 88;
return self;
}
- sendSmallStruct: (small_struct)small
{
printf(">>small value struct: z=%d\n", small.z);
return self;
}
/* Doesn't work. GCC __builtin_return doesn't let you return structs? */
- (foo) returnStruct
{
foo f = {1, "horse", 987654};
return f;
}
/* Doesn't work because GCC generates the wrong encoding: "@0@+8:+12^i+16" */
- sendArray: (int[3])a
{
printf(">> array %d %d %d\n", a[0], a[1], a[2]);
return self;
}
- sendStructArray: (struct myarray)ma
{
printf(">>struct array %d %d %d\n", ma.a[0], ma.a[1], ma.a[2]);
return self;
}
- sendDouble: (double)d andFloat: (float)f
{
printf(">> double %f, float %f\n", d, f);
return self;
}
- (double*) doDoublePointer: (double*)d
{
printf(">> got double %f from client\n", *d);
*d = 1.234567;
printf(">> returning double %f to client\n", *d);
return d;
}
- sendCharPtrPtr: (char**)sp
{
printf(">> got char**, string %s\n", *sp);
return self;
}
- sendBycopy: (bycopy id)o
{
printf(">> bycopy class is %s\n", object_get_class_name (o));
return self;
}
- manyArgs: (int)i1 : (int)i2 : (int)i3 : (int)i4 : (int)i5 : (int)i6
: (int)i7 : (int)i8 : (int)i9 : (int)i10 : (int)i11 : (int)i12
{
printf(">> manyArgs: %d %d %d %d %d %d %d %d %d %d %d %d\n",
i1, i2, i3, i4, i5, i6, i7, i8, i9, i10, i11, i12);
return self;
}
- (float) returnFloat
{
static float f = 2.3456789f;
return f;
}
- (double) returnDouble
{
/* static <This is crashing gcc ss-940902 config'ed for irix5.1,
but running on irix5.2> */
double d = 4.567891234;
return d;
}
- connectionBecameInvalid: notification
{
id anObj = [notification object];
if ([anObj isKindOf:[Connection class]])
{
int i, count = [the_array count];
for (i = count-1; i >= 0; i--)
{
id o = [the_array objectAtIndex: i];
if ([o isProxy] && [o connectionForProxy] == anObj)
[the_array removeObjectAtIndex: i];
}
if (count != [the_array count])
printf("$$$$$ connectionBecameInvalid: removed from the_array\n");
}
else
{
[self error:"non Connection is invalid"];
}
return self;
}
- (Connection*) connection: ancestor didConnect: newConn
{
printf("%s\n", sel_get_name(_cmd));
[NotificationDispatcher
addObserver: self
selector: @selector(connectionBecameInvalid:)
name: ConnectionBecameInvalidNotification
object: newConn];
[newConn setDelegate: self];
return newConn;
}
@end
int main(int argc, char *argv[])
{
id l = [[Server alloc] init];
id o = [[NSObject alloc] init];
double d;
Connection *c;
[BinaryCStream setDebugging:YES];
#if NeXT_runtime
[Proxy setProtocolForProxies:@protocol(AllProxies)];
#endif
if (argc > 1)
c = [Connection newRegisteringAtName:
[NSString stringWithCString: argv[1]]
withRootObject:l];
else
c = [Connection newRegisteringAtName:@"test2server" withRootObject:l];
[NotificationDispatcher
addObserver: l
selector: @selector(connectionBecameInvalid:)
name: ConnectionBecameInvalidNotification
object: c];
[c setDelegate:l];
[l addObject: o];
d = [l returnDouble];
printf("got double %f\n", d);
printf("list's hash is 0x%x\n", (unsigned)[l hash]);
printf("object's hash is 0x%x\n", (unsigned)[o hash]);
[RunLoop run];
exit(0);
}