Removed obsolete files to Old subdirectory

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@7190 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 2000-08-08 14:37:01 +00:00
parent cc36fcd0ee
commit 30730bb37e
45 changed files with 124 additions and 9920 deletions

View file

@ -1,57 +0,0 @@
/* A demonstration of writing and reading GNU Objective C objects to a file. */
#include <base/BinaryCStream.h>
#include <base/Array.h>
#include <base/Dictionary.h>
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <Foundation/NSValue.h>
int main(int argc, char *argv[])
{
id arp;
long l = 0x6543;
int i = 0x1234;
unsigned u = 2;
short s = 0x987;
char c = 0x12;
char *string = "Testing";
float f = 0.1234F;
double d = 0.987654321;
id cstream;
Class cstream_class;
if (argc > 1)
cstream_class = objc_get_class (argv[1]);
else
cstream_class = [BinaryCStream class];
[NSObject enableDoubleReleaseCheck: YES];
arp = [[NSAutoreleasePool alloc] init];
cstream = [[cstream_class alloc]
initForWritingToFile: @"cstream.dat"];
/* Write an integer to a file */
[cstream encodeWithName: @"some values"
valuesOfCTypes: "liIsc*fd",
&l, &i, &u, &s, &c, &string, &f, &d];
printf ("Wrote %d %d %u %d %d %s %g %.15g\n",
(int)l, i, u, (int)s, (int)c, string, f, d);
[[cstream stream] close];
f = d = 0;
cstream = [cstream_class cStreamReadingFromFile: @"cstream.dat"];
[cstream decodeWithName: NULL
valuesOfCTypes: "liIsc*fd",
&l, &i, &u, &s, &c, &string, &f, &d];
printf ("Read %d %d %u %d %d %s %g %.15g\n",
(int)l, i, u, (int)s, (int)c, string, f, d);
[[cstream stream] close];
/* Do the autorelease. */
[arp release];
exit(0);
}

View file

@ -1,107 +0,0 @@
/* A demonstration of writing and reading with NSArchiver */
#include <base/Invocation.h>
#include <base/Array.h>
#include <base/Archiver.h>
#include <Foundation/NSValue.h>
#include <base/TextCStream.h>
#include <Foundation/NSAutoreleasePool.h>
@interface NSNumber (printing)
- (void) print;
- printAddNumber: n;
@end
@implementation NSNumber (printing)
- (void) print
{
printf("%d\n", [self intValue]);
}
- printAddNumber: n
{
printf("%d\n", [self intValue] + [n intValue]);
return self;
}
@end
int main()
{
id obj;
id inv;
id array;
int i;
BOOL b;
NSAutoreleasePool *arp = [NSAutoreleasePool new];
/* Create a simple invocation, and get it's return value. */
obj = [NSObject new];
inv = [[MethodInvocation alloc]
initWithTarget: obj selector: @selector(isInstance)];
[inv invoke];
[inv getReturnValue: &b];
printf ("object is instance %d\n", (int)b);
[inv release];
/* Do a simple invocation on all the contents of a collection. */
array = [Array new];
for (i = 0; i < 5; i++)
[array addObject: [NSNumber numberWithInt: i]];
inv = [[MethodInvocation alloc]
initWithSelector: @selector(print)];
printf ("The numbers\n");
[array withObjectsInvoke: inv];
[inv release];
/* Do an invocation on all the contents of the array, but the
array contents become the first object argument of the invocation,
not the target for the invocation. */
inv = [[ObjectMethodInvocation alloc]
initWithTarget: [NSNumber numberWithInt: 2]
selector: @selector(printAddNumber:), nil];
printf ("The numbers adding 2\n");
[array withObjectsInvoke: inv];
/* Get an int return value in a way that is simpler than -getReturnValue: */
printf ("The target number was %d\n", [inv intReturnValue]);
[inv release];
/* Use a function instead of a selector for the invocation.
Also show the use of filtered enumerating over a collection. */
{
id inv2;
id test_func (id o)
{
printf ("test_func got %d\n", [o intValue]);
return [NSNumber numberWithInt: [o intValue] + 3];
}
inv = [[ObjectFunctionInvocation alloc]
initWithObjectFunction: test_func];
inv2 = [[MethodInvocation alloc] initWithSelector: @selector(print)];
[array withObjectsTransformedByInvoking: inv
invoke: inv2];
[inv release];
[inv2 release];
}
/* Archive the some invocations, read them back and invoke. */
{
inv = [[MethodInvocation alloc]
initWithTarget: array
selector: @selector(withObjectsInvoke:),
[[[MethodInvocation alloc] initWithSelector: @selector(print)]
autorelease]];
printf ("Before archiving\n");
[inv invoke];
[Archiver setDefaultCStreamClass: [TextCStream class]];
[Archiver encodeRootObject: inv withName: NULL toFile: @"invocation.txt"];
[inv release];
printf ("After archiving\n");
inv = [Unarchiver decodeObjectWithName: NULL
fromFile: @"invocation.txt"];
[inv invoke];
}
[arp release];
exit(0);
}

View file

@ -1,181 +0,0 @@
#include <Foundation/NSMethodSignature.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <base/Invocation.h>
#define TYPE char
struct pair {
TYPE i;
TYPE j;
};
@interface Pair: NSObject
- (TYPE)member:(Class)c;
- (TYPE)plus: (struct pair) pair;
- (TYPE)plus_ptr: (struct pair*) pair_ptr;
@end
@implementation Pair
- (TYPE)member:(Class)c
{
if ([self class] == c)
return YES;
else
return NO;
}
- (TYPE)plus: (struct pair) pair
{
return (pair.i + pair.j);
}
- (TYPE)plus_ptr: (struct pair*) pair_ptr
{
return (pair_ptr->i + pair_ptr->j);
}
@end
/* Invocation.m
- initWithTarget: target selector: (SEL)s, ...
[1] Adding CASE_TYPE(_C_CLASS, Class);
[2] Adding default: block
NSInvocation.h
[3] Adding NS_INVOCATION
[4, 5] Adding NS_MESSAGE
NSMethodSignature.m
[6] Modifiying -(NSArgumentInfo)argumentInfoAtIndex:(unsigned)index */
void test1();
void test2();
void test3();
void test4();
void test5();
void test6();
int
main ()
{
id pool = [NSAutoreleasePool new];
test1();
test2();
test3();
test4();
test5();
test6();
[pool release];
}
void
test1()
{
Pair * ipair = [Pair new];
SEL sel = @selector(member:);
Class c = [Pair class];
Invocation * inv;
TYPE result;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, c];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test1 YES == %s\n", result? "YES": "NO");
}
void
test2()
{
Pair * ipair = [Pair new];
SEL sel = @selector(plus:);
SEL sel_ptr = @selector(plus_ptr:);
struct pair pair0;
struct pair * pair0_ptr;
Invocation * inv;
TYPE result;
pair0.i = 3;
pair0.j = 4;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-1 %d == 7\n", result);
pair0_ptr = &pair0;
pair0_ptr->i = 2;
pair0_ptr->j = 3;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel_ptr, &pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-2 %d == 5\n", result);
}
void
test3()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 1;
pair0.j = 2;
inv = NS_INVOCATION(Pair ,
plus:,
pair0);
[inv setTarget: ipair];
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test3 3 == %d\n", x);
}
void
test4()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 3;
pair0.j = 8;
inv = NS_MESSAGE(ipair ,
plus_ptr:,
&pair0); // Method with args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test4 11 == %d\n", x);
}
void
test5()
{
Pair * ipair = [Pair new];
NSInvocation * inv;
int x;
inv = NS_MESSAGE(ipair,
hash); // Method with NO args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test5 hash value of an object == %d\n", x);
}
void
test6()
{
NSObject * foo = [NSObject new];
NSArgumentInfo info;
SEL sel = @selector(isKindOfClass:);
NSMethodSignature * ms = [foo methodSignatureForSelector: sel];
info = [ms argumentInfoAtIndex: 0];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 1];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 2];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
}
#undef TYPE

View file

@ -1,181 +0,0 @@
#include <Foundation/NSMethodSignature.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <base/Invocation.h>
#define TYPE int
struct pair {
TYPE i;
TYPE j;
};
@interface Pair: NSObject
- (TYPE)member:(Class)c;
- (TYPE)plus: (struct pair) pair;
- (TYPE)plus_ptr: (struct pair*) pair_ptr;
@end
@implementation Pair
- (TYPE)member:(Class)c
{
if ([self class] == c)
return YES;
else
return NO;
}
- (TYPE)plus: (struct pair) pair
{
return (pair.i + pair.j);
}
- (TYPE)plus_ptr: (struct pair*) pair_ptr
{
return (pair_ptr->i + pair_ptr->j);
}
@end
/* Invocation.m
- initWithTarget: target selector: (SEL)s, ...
[1] Adding CASE_TYPE(_C_CLASS, Class);
[2] Adding default: block
NSInvocation.h
[3] Adding NS_INVOCATION
[4, 5] Adding NS_MESSAGE
NSMethodSignature.m
[6] Modifiying -(NSArgumentInfo)argumentInfoAtIndex:(unsigned)index */
void test1();
void test2();
void test3();
void test4();
void test5();
void test6();
int
main ()
{
id pool = [NSAutoreleasePool new];
test1();
test2();
test3();
test4();
test5();
test6();
[pool release];
}
void
test1()
{
Pair * ipair = [Pair new];
SEL sel = @selector(member:);
Class c = [Pair class];
Invocation * inv;
TYPE result;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, c];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test1 YES == %s\n", result? "YES": "NO");
}
void
test2()
{
Pair * ipair = [Pair new];
SEL sel = @selector(plus:);
SEL sel_ptr = @selector(plus_ptr:);
struct pair pair0;
struct pair * pair0_ptr;
Invocation * inv;
TYPE result;
pair0.i = 3;
pair0.j = 4;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-1 %d == 7\n", result);
pair0_ptr = &pair0;
pair0_ptr->i = 2;
pair0_ptr->j = 3;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel_ptr, &pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-2 %d == 5\n", result);
}
void
test3()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 1;
pair0.j = 2;
inv = NS_INVOCATION(Pair ,
plus:,
pair0);
[inv setTarget: ipair];
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test3 3 == %d\n", x);
}
void
test4()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 3;
pair0.j = 8;
inv = NS_MESSAGE(ipair ,
plus_ptr:,
&pair0); // Method with args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test4 11 == %d\n", x);
}
void
test5()
{
Pair * ipair = [Pair new];
NSInvocation * inv;
int x;
inv = NS_MESSAGE(ipair,
hash); // Method with NO args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test5 hash value of an object == %d\n", x);
}
void
test6()
{
NSObject * foo = [NSObject new];
NSArgumentInfo info;
SEL sel = @selector(isKindOfClass:);
NSMethodSignature * ms = [foo methodSignatureForSelector: sel];
info = [ms argumentInfoAtIndex: 0];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 1];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 2];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
}
#undef TYPE

View file

@ -1,181 +0,0 @@
#include <Foundation/NSMethodSignature.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <base/Invocation.h>
#define TYPE long
struct pair {
TYPE i;
TYPE j;
};
@interface Pair: NSObject
- (TYPE)member:(Class)c;
- (TYPE)plus: (struct pair) pair;
- (TYPE)plus_ptr: (struct pair*) pair_ptr;
@end
@implementation Pair
- (TYPE)member:(Class)c
{
if ([self class] == c)
return YES;
else
return NO;
}
- (TYPE)plus: (struct pair) pair
{
return (pair.i + pair.j);
}
- (TYPE)plus_ptr: (struct pair*) pair_ptr
{
return (pair_ptr->i + pair_ptr->j);
}
@end
/* Invocation.m
- initWithTarget: target selector: (SEL)s, ...
[1] Adding CASE_TYPE(_C_CLASS, Class);
[2] Adding default: block
NSInvocation.h
[3] Adding NS_INVOCATION
[4, 5] Adding NS_MESSAGE
NSMethodSignature.m
[6] Modifiying -(NSArgumentInfo)argumentInfoAtIndex:(unsigned)index */
void test1();
void test2();
void test3();
void test4();
void test5();
void test6();
int
main ()
{
id pool = [NSAutoreleasePool new];
test1();
test2();
test3();
test4();
test5();
test6();
[pool release];
}
void
test1()
{
Pair * ipair = [Pair new];
SEL sel = @selector(member:);
Class c = [Pair class];
Invocation * inv;
TYPE result;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, c];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test1 YES == %s\n", result? "YES": "NO");
}
void
test2()
{
Pair * ipair = [Pair new];
SEL sel = @selector(plus:);
SEL sel_ptr = @selector(plus_ptr:);
struct pair pair0;
struct pair * pair0_ptr;
Invocation * inv;
TYPE result;
pair0.i = 3;
pair0.j = 4;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-1 %d == 7\n", result);
pair0_ptr = &pair0;
pair0_ptr->i = 2;
pair0_ptr->j = 3;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel_ptr, &pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-2 %d == 5\n", result);
}
void
test3()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 1;
pair0.j = 2;
inv = NS_INVOCATION(Pair ,
plus:,
pair0);
[inv setTarget: ipair];
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test3 3 == %d\n", x);
}
void
test4()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 3;
pair0.j = 8;
inv = NS_MESSAGE(ipair ,
plus_ptr:,
&pair0); // Method with args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test4 11 == %d\n", x);
}
void
test5()
{
Pair * ipair = [Pair new];
NSInvocation * inv;
int x;
inv = NS_MESSAGE(ipair,
hash); // Method with NO args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test5 hash value of an object == %d\n", x);
}
void
test6()
{
NSObject * foo = [NSObject new];
NSArgumentInfo info;
SEL sel = @selector(isKindOfClass:);
NSMethodSignature * ms = [foo methodSignatureForSelector: sel];
info = [ms argumentInfoAtIndex: 0];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 1];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 2];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
}
#undef TYPE

View file

@ -1,179 +0,0 @@
#include <Foundation/NSMethodSignature.h>
#include <Foundation/NSInvocation.h>
#include <Foundation/NSString.h>
#include <Foundation/NSAutoreleasePool.h>
#include <base/Invocation.h>
#define TYPE short
struct pair {
TYPE i;
TYPE j;
};
@interface Pair: NSObject
- (TYPE)member:(Class)c;
- (TYPE)plus: (struct pair) pair;
- (TYPE)plus_ptr: (struct pair*) pair_ptr;
@end
@implementation Pair
- (TYPE)member:(Class)c
{
if ([self class] == c)
return YES;
else
return NO;
}
- (TYPE)plus: (struct pair) pair
{
return (pair.i + pair.j);
}
- (TYPE)plus_ptr: (struct pair*) pair_ptr
{
return (pair_ptr->i + pair_ptr->j);
}
@end
/* Invocation.m
- initWithTarget: target selector: (SEL)s, ...
[1] Adding CASE_TYPE(_C_CLASS, Class);
[2] Adding default: block
NSInvocation.h
[3] Adding NS_INVOCATION
[4, 5] Adding NS_MESSAGE
NSMethodSignature.m
[6] Modifiying -(NSArgumentInfo)argumentInfoAtIndex:(unsigned)index */
void test1();
void test2();
void test3();
void test4();
void test5();
void test6();
int
main ()
{
test1();
test2();
test3();
test4();
test5();
test6();
}
void
test1()
{
Pair * ipair = [Pair new];
SEL sel = @selector(member:);
Class c = [Pair class];
Invocation * inv;
TYPE result;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, c];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test1 YES == %s\n", result? "YES": "NO");
}
void
test2()
{
Pair * ipair = [Pair new];
SEL sel = @selector(plus:);
SEL sel_ptr = @selector(plus_ptr:);
struct pair pair0;
struct pair * pair0_ptr;
Invocation * inv;
TYPE result;
pair0.i = 3;
pair0.j = 4;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel, pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-1 %d == 7\n", result);
pair0_ptr = &pair0;
pair0_ptr->i = 2;
pair0_ptr->j = 3;
inv = [[MethodInvocation alloc]
initWithTarget: ipair
selector: sel_ptr, &pair0];
[inv invoke];
[inv getReturnValue: &result];
fprintf(stderr, "test2-2 %d == 5\n", result);
}
void
test3()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 1;
pair0.j = 2;
inv = NS_INVOCATION(Pair ,
plus:,
pair0);
[inv setTarget: ipair];
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test3 3 == %d\n", x);
}
void
test4()
{
Pair * ipair = [Pair new];
struct pair pair0;
NSInvocation * inv;
TYPE x;
pair0.i = 3;
pair0.j = 8;
inv = NS_MESSAGE(ipair ,
plus_ptr:,
&pair0); // Method with args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test4 11 == %d\n", x);
}
void
test5()
{
Pair * ipair = [Pair new];
NSInvocation * inv;
int x;
inv = NS_MESSAGE(ipair,
hash); // Method with NO args
[inv invoke];
[inv getReturnValue: &x];
fprintf(stderr, "test5 hash value of an object == %d\n", x);
}
void
test6()
{
NSObject * foo = [NSObject new];
NSArgumentInfo info;
SEL sel = @selector(isKindOfClass:);
NSMethodSignature * ms = [foo methodSignatureForSelector: sel];
info = [ms argumentInfoAtIndex: 0];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 1];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
info = [ms argumentInfoAtIndex: 2];
fprintf(stderr, "test6 (%d, %d, %s)\n", info.offset, info.size, info.type);
}
#undef TYPE

View file

@ -1,17 +0,0 @@
#include <base/StdioStream.h>
#include <Foundation/NSString.h>
int main()
{
char b[100];
int len;
id s = [[StdioStream alloc] initWithPipeFrom: @"cat /etc/group | sort"];
while ((len = [s readBytes:b length:99]) > 0)
{
b[len] = '\0';
printf("[%d]: %s\n", len, b);
}
exit(0);
}