mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
Patches submitted from May 20 to Aug 28 1997
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@2406 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7b12c4af23
commit
a57d791f91
119 changed files with 16409 additions and 1698 deletions
|
@ -32,7 +32,7 @@ CC = @CC@
|
|||
|
||||
CFLAGS = -Wall -Wno-implicit -Wno-format -g
|
||||
CPPFLAGS =
|
||||
LDFLAGS =
|
||||
LDFLAGS = $(DYNAMIC_LDFLAGS)
|
||||
|
||||
DYNAMIC_BUNDLER_LINKER=@DYNAMIC_BUNDLER_LINKER@
|
||||
DYNAMIC_LDFLAGS=@DYNAMIC_LDFLAGS@
|
||||
|
@ -79,13 +79,20 @@ client.m \
|
|||
string.m \
|
||||
values.m \
|
||||
nsarray.m \
|
||||
nsattributedstring.m \
|
||||
nsbundle.m \
|
||||
nsdata.m \
|
||||
nsdictionary.m \
|
||||
nsfilehandle.m \
|
||||
nshost.m \
|
||||
nsset.m \
|
||||
nsprocessinfo.m \
|
||||
nsarchiver.m \
|
||||
oldclient.m \
|
||||
oldserver.m \
|
||||
invocation.m \
|
||||
diningPhilosophers.m \
|
||||
nsattributedstring.m \
|
||||
nsmaptable.m \
|
||||
nshashtable.m \
|
||||
tcpport-server.m \
|
||||
|
@ -161,13 +168,14 @@ $(DYNAMIC_OFILES): $(DYNAMIC_MFILES) $(DYNAMIC_HFILES)
|
|||
|
||||
$(BUNDLE_NAME).bundle/$(BUNDLE_NAME): $(DYNAMIC_OFILES)
|
||||
-mkdir $(BUNDLE_NAME).bundle
|
||||
-mkdir $(BUNDLE_NAME).bundle/English.lproj
|
||||
-mkdir $(BUNDLE_NAME).bundle/Resources
|
||||
-mkdir $(BUNDLE_NAME).bundle/Resources/English.lproj
|
||||
$(DYNAMIC_BUNDLER_LINKER) -o $(BUNDLE_NAME).bundle/$(BUNDLE_NAME) \
|
||||
$(DYNAMIC_OFILES)
|
||||
cp $(srcdir)/NXStringTable.example $(BUNDLE_NAME).bundle/English.lproj
|
||||
cp $(srcdir)/NXStringTable.example $(BUNDLE_NAME).bundle/Resources/English.lproj
|
||||
|
||||
mostlyclean:
|
||||
rm -f core *~ test08.data textcoder.txt
|
||||
rm -f core *~ *.txt *.dat
|
||||
|
||||
clean: mostlyclean
|
||||
rm -f *$(OEXT) $(EXECS)
|
||||
|
|
|
@ -5,45 +5,9 @@
|
|||
*
|
||||
* Author : John W. M. Stevens
|
||||
|
||||
Notes : See below by date.
|
||||
|
||||
...............................................................................
|
||||
15 April 1997
|
||||
|
||||
NSRange.m
|
||||
|
||||
1) NSMakeRange does an implicit type cast from a float to an
|
||||
unsigned long. This is a nasty spot for hard to find errors.
|
||||
|
||||
2) NSMakeRange, in doing the above, automatically converts negative
|
||||
numbers to unsigned ints, and (of course) produces some very large
|
||||
ints if one of the numbers happens to be a negative number.
|
||||
|
||||
NSData.m
|
||||
|
||||
1) To properly throw an NSRangeException Error in the NSMutableRange
|
||||
replaceBytesInRange method, the NSRange location and length values
|
||||
must be checked against the NSMutableData size attribute.
|
||||
|
||||
Unfortunately, we once again have a type mismatch (see the notes
|
||||
on NSRange.m), as the NSMutableData size attribute is a signed int.
|
||||
Is there any reason not to convert the NSMutableData (NSData) size
|
||||
attribute to an unsigned int? Should the NSRange values be converted
|
||||
to signed ints?
|
||||
|
||||
2) Checking only the summation of location and length (NSMaxRange)
|
||||
against the size of the NSData buffer could generate some false
|
||||
OK's, as the summation of 2's complement -2.0 and 2.0 converted
|
||||
to unsigned ints is of course zero, yet the location value is
|
||||
clearly out of range (being less than zero).
|
||||
|
||||
3) Note that with the current implementation of NSData's getBytes
|
||||
family of methods, the methods getBytes and getBytes:length could
|
||||
throw the NSRangeException. Obviously, it is highly unlikely that
|
||||
getBytes would throw this exception, but it is possible that
|
||||
getBytes:length could, and the documentation does not specify
|
||||
that getBytes:length should return any exceptions. In my opinion,
|
||||
this is an acceptable deviation from the standard.
|
||||
******************************************************************************/
|
||||
|
||||
#include <stdio.h>
|
||||
|
@ -94,7 +58,7 @@ TestNSMutableData(void)
|
|||
* zero.
|
||||
*/
|
||||
NS_DURING
|
||||
range = NSMakeRange(-2.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(-2, strlen( subString ));
|
||||
[nsMutData replaceBytesInRange: range
|
||||
withBytes : subString ];
|
||||
NS_HANDLER
|
||||
|
@ -108,7 +72,7 @@ NS_ENDHANDLER
|
|||
|
||||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
range = NSMakeRange(41.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(41, strlen( subString ));
|
||||
[nsMutData replaceBytesInRange: range
|
||||
withBytes : subString ];
|
||||
NS_HANDLER
|
||||
|
@ -122,7 +86,7 @@ NS_ENDHANDLER
|
|||
|
||||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
range = NSMakeRange(42.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(42, strlen( subString ));
|
||||
[nsMutData replaceBytesInRange: range
|
||||
withBytes : subString ];
|
||||
NS_HANDLER
|
||||
|
@ -152,7 +116,7 @@ NS_ENDHANDLER
|
|||
* zero.
|
||||
*/
|
||||
NS_DURING
|
||||
range = NSMakeRange(-2.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(-2, strlen( subString ));
|
||||
[nsMutData resetBytesInRange: range];
|
||||
NS_HANDLER
|
||||
fprintf(stderr,
|
||||
|
@ -165,7 +129,7 @@ NS_ENDHANDLER
|
|||
|
||||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
range = NSMakeRange(41.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(41, strlen( subString ));
|
||||
[nsMutData resetBytesInRange: range];
|
||||
NS_HANDLER
|
||||
fprintf(stderr,
|
||||
|
@ -178,7 +142,7 @@ NS_ENDHANDLER
|
|||
|
||||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
range = NSMakeRange(42.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(42, strlen( subString ));
|
||||
[nsMutData resetBytesInRange: range];
|
||||
NS_HANDLER
|
||||
fprintf(stderr,
|
||||
|
@ -276,7 +240,7 @@ NS_ENDHANDLER
|
|||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
/* Get piece. */
|
||||
range = NSMakeRange(41.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(41, strlen( subString ));
|
||||
[nsData getBytes: bfr
|
||||
range : range];
|
||||
|
||||
|
@ -294,7 +258,7 @@ NS_ENDHANDLER
|
|||
|
||||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
range = NSMakeRange(42.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(42, strlen( subString ));
|
||||
[nsData getBytes: bfr
|
||||
range : range];
|
||||
|
||||
|
@ -353,7 +317,7 @@ NS_ENDHANDLER
|
|||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
/* Get buffer piece. */
|
||||
range = NSMakeRange(41.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(41, strlen( subString ));
|
||||
newNsData = [nsData subdataWithRange: range];
|
||||
|
||||
/* Print buffer piece. */
|
||||
|
@ -372,7 +336,7 @@ NS_ENDHANDLER
|
|||
/* Attempt to force another Range exception. */
|
||||
NS_DURING
|
||||
/* Get buffer piece. */
|
||||
range = NSMakeRange(42.0, (float) strlen( subString ));
|
||||
range = NSMakeRange(42, strlen( subString ));
|
||||
newNsData = [nsData subdataWithRange: range];
|
||||
|
||||
/* Print buffer piece. */
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
#include <stdio.h>
|
||||
#include <gnustep/base/TcpPort.h>
|
||||
#include <gnustep/base/Connection.h>
|
||||
#include <gnustep/base/Proxy.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSDistantObject.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <Foundation/NSDate.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 "server.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
id a;
|
||||
id p;
|
||||
id callback_receiver = [NSObject new];
|
||||
id o;
|
||||
|
@ -20,10 +21,10 @@ int main(int argc, char *argv[])
|
|||
id c;
|
||||
int j,k;
|
||||
foo f = {99, "cow", 9876543};
|
||||
/* foo f2; */
|
||||
foo f2;
|
||||
foo *fp;
|
||||
const char *n;
|
||||
// int a3[3] = {66,77,88};
|
||||
int a3[3] = {66,77,88};
|
||||
struct myarray ma = {{55,66,77}};
|
||||
double dbl = 3.14159265358979323846264338327;
|
||||
double *dbl_ptr;
|
||||
|
@ -36,23 +37,28 @@ int main(int argc, char *argv[])
|
|||
[BinaryCStream setDebugging:YES];
|
||||
|
||||
#if NeXT_runtime
|
||||
[Proxy setProtocolForProxies:@protocol(AllProxies)];
|
||||
[NSDistantObject setProtocolForProxies:@protocol(AllProxies)];
|
||||
#endif
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
if (argc > 2)
|
||||
p = [Connection rootProxyAtName: [NSString stringWithCString: argv[2]]
|
||||
p = [NSConnection rootProxyAtName: [NSString stringWithCString: argv[2]]
|
||||
onHost: [NSString stringWithCString:argv[1]]];
|
||||
else
|
||||
p = [Connection rootProxyAtName:@"test2server"
|
||||
p = [NSConnection rootProxyAtName:@"test2server"
|
||||
onHost:[NSString stringWithCString:argv[1]]];
|
||||
}
|
||||
else
|
||||
p = [Connection rootProxyAtName:@"test2server"
|
||||
p = [NSConnection rootProxyAtName:@"test2server"
|
||||
onHost:nil];
|
||||
c = [p connectionForProxy];
|
||||
|
||||
[c setRequestTimeout:180.0];
|
||||
[c setReplyTimeout:180.0];
|
||||
localObj = [[NSObject alloc] init];
|
||||
[p outputStats:localObj];
|
||||
[p getLong:&i];
|
||||
[p outputStats:localObj];
|
||||
type = [c typeForSelector:sel_get_any_uid("name")
|
||||
remoteTarget:[p targetForProxy]];
|
||||
printf(">>type = %s\n", type);
|
||||
|
@ -121,7 +127,6 @@ int main(int argc, char *argv[])
|
|||
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++)
|
||||
|
@ -137,7 +142,20 @@ int main(int argc, char *argv[])
|
|||
j, (unsigned)[remote_peer_obj hash]);
|
||||
}
|
||||
|
||||
[RunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 20 * 60]];
|
||||
[p outputStats:localObj];
|
||||
|
||||
o = [c statistics];
|
||||
a = [o allKeys];
|
||||
|
||||
for (j = 0; j < [a count]; j++)
|
||||
{
|
||||
id k = [a objectAtIndex:j];
|
||||
id v = [o objectForKey:k];
|
||||
|
||||
printf("%s - %s\n", [k cString], [[v description] cString]);
|
||||
}
|
||||
|
||||
[NSRunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 20 * 60]];
|
||||
[c invalidate];
|
||||
|
||||
exit(0);
|
||||
|
|
|
@ -12,6 +12,12 @@ int main()
|
|||
{
|
||||
id set;
|
||||
id arp;
|
||||
id arc;
|
||||
id una;
|
||||
id xxx;
|
||||
id apl;
|
||||
|
||||
[NSAutoreleasePool enableDoubleReleaseCheck:YES];
|
||||
|
||||
arp = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
|
@ -27,6 +33,20 @@ int main()
|
|||
printf("%s\n", [o cStringNoCopy]);
|
||||
}
|
||||
|
||||
apl = [[NSAutoreleasePool alloc] init];
|
||||
arc = [[NSArchiver new] autorelease];
|
||||
printf("%u\n", [arc retainCount]);
|
||||
[arc retain];
|
||||
printf("%u\n", [arc retainCount]);
|
||||
[arc release];
|
||||
printf("%u\n", [arc retainCount]);
|
||||
[arc encodeRootObject: set];
|
||||
/* Intentionally dodgy code - autorelease before init to see if init copes. */
|
||||
una = [[[NSUnarchiver alloc] autorelease] initForReadingWithData: [arc archiverData]];
|
||||
xxx = [una decodeObject];
|
||||
[xxx release];
|
||||
[apl release];
|
||||
|
||||
/* Write it to a file */
|
||||
[NSArchiver archiveRootObject: set toFile: @"./nsarchiver.dat"];
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSValue.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
int
|
||||
|
@ -10,12 +11,26 @@ main()
|
|||
id i;
|
||||
id s = @"Hello World\n";
|
||||
id pool;
|
||||
id o1, o2, o3;
|
||||
unsigned int p;
|
||||
|
||||
behavior_set_debug(0);
|
||||
behavior_set_debug(1);
|
||||
|
||||
[NSAutoreleasePool enableDoubleReleaseCheck:YES];
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
o1 = [NSNumber numberWithInt:1];
|
||||
o2 = [NSNumber numberWithInt:2];
|
||||
o3 = [NSNumber numberWithInt:3];
|
||||
a = [[[NSArray arrayWithObject:o1] arrayByAddingObject:o2] arrayByAddingObject:o3];
|
||||
printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]);
|
||||
b = [[a copy] autorelease];
|
||||
printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]);
|
||||
c = [[b mutableCopy] autorelease];
|
||||
printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]);
|
||||
d = [[c copy] autorelease];
|
||||
printf("%u,%u,%u\n", [o1 retainCount], [o2 retainCount], [o3 retainCount]);
|
||||
|
||||
// NSArray tests
|
||||
{
|
||||
// Class methods for allocating and initializing an array
|
||||
|
|
115
Testing/nsattributedstring.m
Normal file
115
Testing/nsattributedstring.m
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
test.m
|
||||
|
||||
Test NSAttributedString and NSMutableAttributedString classes
|
||||
|
||||
Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
|
||||
Written by: ANOQ of the sun <anoq@vip.cybercity.dk>
|
||||
Date: June 1997
|
||||
|
||||
This file is part of ...
|
||||
|
||||
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.
|
||||
|
||||
If you are interested in a warranty or support for this source code,
|
||||
contact Scott Christley <scottc@net-community.com> for more information.
|
||||
|
||||
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 <Foundation/NSString.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSDictionary.h>
|
||||
#include "NSAttributedString.h"
|
||||
#include <stdio.h>
|
||||
|
||||
void printAttrString(NSAttributedString *attrStr)
|
||||
{
|
||||
NSDictionary *tmpAttrDict;
|
||||
NSEnumerator *keyEnumerator;
|
||||
NSString *tmpStr;
|
||||
NSRange effectiveRange;
|
||||
unsigned int tmpLength;
|
||||
|
||||
effectiveRange = NSMakeRange(0,0);
|
||||
tmpLength = [attrStr length];
|
||||
puts("Attributed string looks like this:");
|
||||
while(NSMaxRange(effectiveRange) < tmpLength)
|
||||
{
|
||||
tmpAttrDict = [attrStr attributesAtIndex:NSMaxRange(effectiveRange)
|
||||
effectiveRange:&effectiveRange];
|
||||
printf("String: %s attributes: ",[[attrStr string] cString]);
|
||||
keyEnumerator = [tmpAttrDict keyEnumerator];
|
||||
while((tmpStr = [keyEnumerator nextObject]))
|
||||
printf("%s ",[tmpStr cString]);
|
||||
printf("location: %ld length: %ld\n",
|
||||
(long)effectiveRange.location,
|
||||
(long)effectiveRange.length);
|
||||
}
|
||||
}
|
||||
|
||||
void testAttributedString(void)
|
||||
{
|
||||
NSAttributedString *attrString;
|
||||
NSMutableAttributedString *muAttrString,*muAttrString2;
|
||||
NSMutableDictionary *attributes,*colorAttributes,*twoAttributes;
|
||||
|
||||
attributes = [[[NSMutableDictionary alloc] init] autorelease];
|
||||
[attributes setObject:@"Helvetica 12-point"
|
||||
forKey:NSFontAttributeName];
|
||||
colorAttributes = [[[NSMutableDictionary alloc] init] autorelease];
|
||||
[colorAttributes setObject:@"black NSColor"
|
||||
forKey:NSForegroundColorAttributeName];
|
||||
twoAttributes = [[[NSMutableDictionary alloc] init] autorelease];
|
||||
[twoAttributes addEntriesFromDictionary:attributes];
|
||||
[twoAttributes setObject:@"red NSColor"
|
||||
forKey:NSBackgroundColorAttributeName];
|
||||
|
||||
attrString = [[NSAttributedString alloc]
|
||||
initWithString:@"Attributed string test"
|
||||
attributes:twoAttributes];
|
||||
[attrString autorelease];
|
||||
printAttrString(attrString);
|
||||
|
||||
muAttrString = [[NSMutableAttributedString alloc]
|
||||
initWithString:@"Testing the Mutable version"
|
||||
attributes:colorAttributes];
|
||||
[muAttrString autorelease];
|
||||
printAttrString(muAttrString);
|
||||
|
||||
[muAttrString setAttributes:attributes
|
||||
range:NSMakeRange(2,4)];
|
||||
printAttrString(muAttrString);
|
||||
|
||||
[muAttrString setAttributes:attributes
|
||||
range:NSMakeRange(8,16)];
|
||||
printAttrString(muAttrString);
|
||||
|
||||
[muAttrString addAttributes:colorAttributes
|
||||
range:NSMakeRange(5,12)];
|
||||
printAttrString(muAttrString);
|
||||
|
||||
muAttrString2 = [muAttrString copy];
|
||||
printAttrString(muAttrString2);
|
||||
|
||||
[muAttrString replaceCharactersInRange:NSMakeRange(5,15)
|
||||
withAttributedString:attrString];
|
||||
printAttrString(muAttrString);
|
||||
|
||||
[muAttrString2 replaceCharactersInRange:NSMakeRange(15,5)
|
||||
withAttributedString:attrString];
|
||||
printAttrString(muAttrString2);
|
||||
|
||||
printAttrString([muAttrString2 attributedSubstringFromRange:NSMakeRange(10,7)]);
|
||||
}
|
|
@ -15,9 +15,6 @@
|
|||
#include "SecondClass.h"
|
||||
#include "MyCategory.h"
|
||||
|
||||
/* Realize externals needed by objc-load */
|
||||
char **NSArgv;
|
||||
|
||||
int
|
||||
main(int ac, char *av[])
|
||||
{
|
||||
|
@ -26,8 +23,6 @@ main(int ac, char *av[])
|
|||
NSString *path;
|
||||
id object;
|
||||
|
||||
NSArgv = av;
|
||||
|
||||
main = [NSBundle mainBundle];
|
||||
printf("Looking for main bundle...\n");
|
||||
if (!main) {
|
||||
|
|
20
Testing/nsdata.m
Normal file
20
Testing/nsdata.m
Normal file
|
@ -0,0 +1,20 @@
|
|||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
id d;
|
||||
id pool;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
d = [NSData dataWithContentsOfMappedFile:@"nsdata.m"];
|
||||
if (d == nil)
|
||||
printf("Unable to map file");
|
||||
printf("Mapped %d bytes\n", [d length]);
|
||||
[pool release];
|
||||
|
||||
exit(0);
|
||||
}
|
47
Testing/nsfilehandle.m
Normal file
47
Testing/nsfilehandle.m
Normal file
|
@ -0,0 +1,47 @@
|
|||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSFileHandle.h>
|
||||
#include <Foundation/NSData.h>
|
||||
#include <Foundation/NSString.h>
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
id pool;
|
||||
id src;
|
||||
id dst;
|
||||
id d0;
|
||||
id d1;
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
src = [[NSFileHandle fileHandleForReadingAtPath:@"nsfilehandle.m"] retain];
|
||||
assert(src != nil);
|
||||
dst = [[NSFileHandle fileHandleForWritingAtPath:@"nsfilehandle.dat"] retain];
|
||||
if (dst == nil)
|
||||
{
|
||||
creat("nsfilehandle.dat", 0644);
|
||||
dst = [[NSFileHandle fileHandleForWritingAtPath:@"nsfilehandle.dat"] retain];
|
||||
}
|
||||
assert(dst != nil);
|
||||
|
||||
d0 = [[src readDataToEndOfFile] retain];
|
||||
[dst writeData:d0];
|
||||
[src release];
|
||||
[dst release];
|
||||
[pool release];
|
||||
|
||||
pool = [[NSAutoreleasePool alloc] init];
|
||||
src = [[NSFileHandle fileHandleForReadingAtPath:@"nsfilehandle.dat"] retain];
|
||||
d1 = [[src readDataToEndOfFile] retain];
|
||||
[src release];
|
||||
[pool release];
|
||||
|
||||
unlink("nsfilehandle.dat");
|
||||
|
||||
if ([d0 isEqual:d1])
|
||||
printf("Test passed (length:%d)\n", [d1 length]);
|
||||
else
|
||||
printf("Test failed\n");
|
||||
|
||||
exit (0);
|
||||
}
|
44
Testing/nshost.m
Normal file
44
Testing/nshost.m
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <Foundation/NSArray.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <Foundation/NSHost.h>
|
||||
|
||||
void
|
||||
displayHost(NSHost* h)
|
||||
{
|
||||
NSArray* a;
|
||||
int i;
|
||||
|
||||
printf("\n");
|
||||
a = [h names];
|
||||
for (i = 0; i < [a count]; i++)
|
||||
printf("%s\n", [[a objectAtIndex:i] cStringNoCopy]);
|
||||
a = [h addresses];
|
||||
for (i = 0; i < [a count]; i++)
|
||||
printf("%s\n", [[a objectAtIndex:i] cStringNoCopy]);
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
NSHost* a;
|
||||
NSHost* c;
|
||||
NSHost* n;
|
||||
|
||||
c = [NSHost currentHost];
|
||||
displayHost(c);
|
||||
n = [NSHost hostWithName:[c name]];
|
||||
displayHost(n);
|
||||
a = [NSHost hostWithAddress:[c address]];
|
||||
displayHost(a);
|
||||
|
||||
printf("c:%lx, n:%lx, a:%lx\n", c, n, a);
|
||||
|
||||
[NSHost setHostCacheEnabled:NO];
|
||||
|
||||
[n release];
|
||||
n = [NSHost hostWithName:[c name]];
|
||||
displayHost(n);
|
||||
printf("c:%lx, n:%lx, a:%lx\n", c, n, a);
|
||||
|
||||
exit (0);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include <gnustep/base/RunLoop.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <gnustep/base/Invocation.h>
|
||||
#include <Foundation/NSTimer.h>
|
||||
|
||||
|
@ -52,6 +52,6 @@ int main()
|
|||
[NSTimer scheduledTimerWithTimeInterval: 3.0
|
||||
invocation: inv
|
||||
repeats: YES];
|
||||
[RunLoop run];
|
||||
[NSRunLoop run];
|
||||
exit (0);
|
||||
}
|
||||
|
|
144
Testing/oldclient.m
Normal file
144
Testing/oldclient.m
Normal file
|
@ -0,0 +1,144 @@
|
|||
#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);
|
||||
}
|
64
Testing/oldserver.h
Normal file
64
Testing/oldserver.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
#ifndef _server_h
|
||||
#define _server_h
|
||||
|
||||
#include <gnustep/base/preface.h>
|
||||
#include <gnustep/base/Connection.h>
|
||||
#include <gnustep/base/Array.h>
|
||||
|
||||
typedef struct _small_struct {
|
||||
unsigned char z;
|
||||
} small_struct;
|
||||
|
||||
typedef struct _foo {
|
||||
int i;
|
||||
char *s;
|
||||
unsigned long l;
|
||||
} foo;
|
||||
|
||||
struct myarray {
|
||||
int a[3];
|
||||
};
|
||||
|
||||
@protocol ServerProtocol
|
||||
- (void) addObject: o;
|
||||
- objectAt: (unsigned)i;
|
||||
- (unsigned) count;
|
||||
- print: (const char *)msg;
|
||||
- getLong: (out unsigned long*)i;
|
||||
- (oneway void) shout;
|
||||
- callbackNameOn: obj;
|
||||
- bounce: sender count: (int)c;
|
||||
- (BOOL) doBoolean: (BOOL)b;
|
||||
- getBoolean: (BOOL*)bp;
|
||||
- getUCharPtr: (unsigned char *)ucp;
|
||||
- (foo*) sendStructPtr: (foo*)f;
|
||||
- sendStruct: (foo)f;
|
||||
- sendSmallStruct: (small_struct)small;
|
||||
- (foo) returnStruct;
|
||||
- sendArray: (int[3])a;
|
||||
- sendStructArray: (struct myarray)ma;
|
||||
- sendDouble: (double)d andFloat: (float)f;
|
||||
- (double*) doDoublePointer: (double*)d;
|
||||
- sendCharPtrPtr: (char**)sp;
|
||||
- sendBycopy: (bycopy id)o;
|
||||
- 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;
|
||||
- (float) returnFloat;
|
||||
- (double) returnDouble;
|
||||
@end
|
||||
|
||||
#if NeXT_runtime
|
||||
@protocol AllProxies <ServerProtocol>
|
||||
- (const char *)name;
|
||||
- (unsigned) hash;
|
||||
- self;
|
||||
@end
|
||||
#endif
|
||||
|
||||
@interface Server : NSObject <ServerProtocol>
|
||||
{
|
||||
id the_array;
|
||||
}
|
||||
@end
|
||||
|
||||
#endif /* _server_h */
|
234
Testing/oldserver.m
Normal file
234
Testing/oldserver.m
Normal file
|
@ -0,0 +1,234 @@
|
|||
#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 <Foundation/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);
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#define _server_h
|
||||
|
||||
#include <gnustep/base/preface.h>
|
||||
#include <gnustep/base/Connection.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <gnustep/base/Array.h>
|
||||
|
||||
typedef struct _small_struct {
|
||||
|
@ -31,6 +31,7 @@ struct myarray {
|
|||
- (BOOL) doBoolean: (BOOL)b;
|
||||
- getBoolean: (BOOL*)bp;
|
||||
- getUCharPtr: (unsigned char *)ucp;
|
||||
- (oneway void) outputStats:obj;
|
||||
- (foo*) sendStructPtr: (foo*)f;
|
||||
- sendStruct: (foo)f;
|
||||
- sendSmallStruct: (small_struct)small;
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#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/NSDictionary.h>
|
||||
#include <Foundation/NSConnection.h>
|
||||
#include <Foundation/NSDistantObject.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <gnustep/base/Notification.h>
|
||||
#include <gnustep/base/RunLoop.h>
|
||||
#include <Foundation/NSNotification.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <gnustep/base/Coder.h>
|
||||
#include <gnustep/base/BinaryCStream.h>
|
||||
#include "server.h"
|
||||
|
||||
@implementation Server
|
||||
|
@ -78,6 +79,23 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) outputStats:obj
|
||||
{
|
||||
id c = [obj connectionForProxy];
|
||||
id o = [c statistics];
|
||||
id a = [o allKeys];
|
||||
int j;
|
||||
|
||||
printf("Number of connections - %d\n", [[NSConnection allConnections] count]);
|
||||
printf("This connection -\n");
|
||||
for (j = 0; j < [a count]; j++)
|
||||
{
|
||||
id k = [a objectAtIndex:j];
|
||||
id v = [o objectForKey:k];
|
||||
printf("%s - %s\n", [k cString], [[v description] cString]);
|
||||
}
|
||||
}
|
||||
|
||||
/* This isn't working yet */
|
||||
- (foo*) sendStructPtr: (foo*)f
|
||||
{
|
||||
|
@ -139,7 +157,6 @@
|
|||
- sendBycopy: (bycopy id)o
|
||||
{
|
||||
printf(">> bycopy class is %s\n", object_get_class_name (o));
|
||||
[o release];
|
||||
return self;
|
||||
}
|
||||
- manyArgs: (int)i1 : (int)i2 : (int)i3 : (int)i4 : (int)i5 : (int)i6
|
||||
|
@ -167,7 +184,7 @@
|
|||
- connectionBecameInvalid: notification
|
||||
{
|
||||
id anObj = [notification object];
|
||||
if ([anObj isKindOf:[Connection class]])
|
||||
if ([anObj isKindOf:[NSConnection class]])
|
||||
{
|
||||
int i, count = [the_array count];
|
||||
for (i = count-1; i >= 0; i--)
|
||||
|
@ -185,13 +202,13 @@
|
|||
}
|
||||
return self;
|
||||
}
|
||||
- (Connection*) connection: ancestor didConnect: newConn
|
||||
- (NSConnection*) connection: ancestor didConnect: newConn
|
||||
{
|
||||
printf("%s\n", sel_get_name(_cmd));
|
||||
[NotificationDispatcher
|
||||
addObserver: self
|
||||
selector: @selector(connectionBecameInvalid:)
|
||||
name: ConnectionBecameInvalidNotification
|
||||
name: NSConnectionDidDieNotification
|
||||
object: newConn];
|
||||
[newConn setDelegate: self];
|
||||
return newConn;
|
||||
|
@ -203,23 +220,23 @@ int main(int argc, char *argv[])
|
|||
id l = [[Server alloc] init];
|
||||
id o = [[NSObject alloc] init];
|
||||
double d;
|
||||
Connection *c;
|
||||
NSConnection *c;
|
||||
|
||||
[BinaryCStream setDebugging:YES];
|
||||
|
||||
#if NeXT_runtime
|
||||
[Proxy setProtocolForProxies:@protocol(AllProxies)];
|
||||
[NSDistantObject setProtocolForProxies:@protocol(AllProxies)];
|
||||
#endif
|
||||
if (argc > 1)
|
||||
c = [Connection newRegisteringAtName:
|
||||
c = [NSConnection newRegisteringAtName:
|
||||
[NSString stringWithCString: argv[1]]
|
||||
withRootObject:l];
|
||||
else
|
||||
c = [Connection newRegisteringAtName:@"test2server" withRootObject:l];
|
||||
c = [NSConnection newRegisteringAtName:@"test2server" withRootObject:l];
|
||||
[NotificationDispatcher
|
||||
addObserver: l
|
||||
selector: @selector(connectionBecameInvalid:)
|
||||
name: ConnectionBecameInvalidNotification
|
||||
name: NSConnectionDidDieNotification
|
||||
object: c];
|
||||
[c setDelegate:l];
|
||||
|
||||
|
@ -229,7 +246,7 @@ int main(int argc, char *argv[])
|
|||
printf("list's hash is 0x%x\n", (unsigned)[l hash]);
|
||||
printf("object's hash is 0x%x\n", (unsigned)[o hash]);
|
||||
|
||||
[RunLoop run];
|
||||
[NSRunLoop run];
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include <stdio.h>
|
||||
#include <gnustep/base/TcpPort.h>
|
||||
#include <gnustep/base/RunLoop.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
#include <gnustep/base/Invocation.h>
|
||||
#include <Foundation/NSDate.h>
|
||||
|
||||
|
@ -36,18 +36,18 @@ int main (int argc, char *argv[])
|
|||
initWithObjectFunction: handle_incoming_packet]
|
||||
autorelease]];
|
||||
|
||||
[[RunLoop currentInstance] addPort: in_port
|
||||
forMode: RunLoopDefaultMode];
|
||||
[[NSRunLoop currentRunLoop] addPort: in_port
|
||||
forMode: NSDefaultRunLoopMode];
|
||||
|
||||
for (i = 0; i < 10; i++)
|
||||
{
|
||||
packet = [[TcpOutPacket alloc] initForSendingWithCapacity: 100
|
||||
replyInPort: in_port];
|
||||
[packet writeFormat: @"Here is message number %d", i];
|
||||
[out_port sendPacket: packet];
|
||||
[out_port sendPacket: packet timeout: 10.0];
|
||||
[packet release];
|
||||
|
||||
[RunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]];
|
||||
[NSRunLoop runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 1.0]];
|
||||
}
|
||||
|
||||
[out_port close];
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#include <gnustep/base/TcpPort.h>
|
||||
#include <gnustep/base/Notification.h>
|
||||
#include <gnustep/base/Invocation.h>
|
||||
#include <gnustep/base/RunLoop.h>
|
||||
#include <Foundation/NSRunLoop.h>
|
||||
|
||||
id announce_new_connection (id notification)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ id handle_incoming_packet (TcpInPacket *packet)
|
|||
replyInPort: port];
|
||||
[packet writeFormat: @"Your's was my message number %d",
|
||||
message_count];
|
||||
[reply_port sendPacket: packet];
|
||||
[reply_port sendPacket: packet timeout:10.0];
|
||||
[packet release];
|
||||
return nil;
|
||||
}
|
||||
|
@ -76,9 +76,9 @@ int main (int argc, char *argv[])
|
|||
[[[ObjectFunctionInvocation alloc]
|
||||
initWithObjectFunction: handle_incoming_packet]
|
||||
autorelease]];
|
||||
[[RunLoop currentInstance] addPort: port
|
||||
forMode: RunLoopDefaultMode];
|
||||
[RunLoop run];
|
||||
[[NSRunLoop currentRunLoop] addPort: port
|
||||
forMode: NSDefaultRunLoopMode];
|
||||
[NSRunLoop run];
|
||||
#else
|
||||
{
|
||||
id packet;
|
||||
|
@ -99,7 +99,7 @@ int main (int argc, char *argv[])
|
|||
replyPort: port];
|
||||
[packet writeFormat: @"Your's was my message number %d",
|
||||
message_count];
|
||||
[reply_port sendPacket: packet withTimeout: 20 * 1000];
|
||||
[reply_port sendPacket: packet timeout: 20.0];
|
||||
[packet release];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue