mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-29 16:01:38 +00:00
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:
parent
130dfd071f
commit
3246db28c8
41 changed files with 189 additions and 3485 deletions
|
@ -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 \
|
||||
|
|
|
@ -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);
|
||||
}
|
|
@ -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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue