Initial revision

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@749 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-01-22 23:04:48 +00:00
parent a22c8553df
commit fe7cb5d7ef
4 changed files with 184 additions and 0 deletions

20
Examples/nx-client.m Normal file
View file

@ -0,0 +1,20 @@
#include <remote/NXConnection.h>
#include <remote/NXProxy.h>
#include <objc/List.h>
int main(int argc, char *argv[])
{
id s;
s = [NXConnection connectToName:"nxserver"];
printf("Server has class name `%s'\n",
[s name]);
printf("First object in server has class name `%s'\n",
[[s objectAt:0] name]);
/* Be nice and shut down the connection */
[[s connectionForProxy] free];
exit(0);
}

15
Examples/nx-server.m Normal file
View file

@ -0,0 +1,15 @@
#include <remote/NXConnection.h>
#include <objc/List.h>
int main(int argc, char *argv[])
{
id s = [[List alloc] init];
id c;
[s addObject:[Object new]];
c = [NXConnection registerRoot:s withName:"nxserver"];
[c run];
exit(0);
}

98
Testing/beh.m Normal file
View file

@ -0,0 +1,98 @@
#include <objects/stdobjects.h>
#include <objects/behavior.h>
#include <Foundation/NSCoder.h>
@interface Foo : NSObject
+ fooClass;
- foo;
- (void) encodeWithCoder: c;
@end
@interface Foo2 : NSObject
+ foo2Class;
- foo2;
@end
@interface Foo2Sub : Foo2
+ foo2SubClass;
- foo2Sub;
@end
@implementation Foo
+ (void) initialize
{
class_add_behavior([Foo class], [Foo2Sub class]);
}
+ fooClass
{
printf("fooClass\n");
return self;
}
- foo
{
printf("foo\n");
return self;
}
- duplicate
{
printf("Foo duplicate\n");
return self;
}
- (void) encodeWithCoder: c
{
(void) &c;
}
@end
@implementation Foo2
+ foo2Class
{
printf("foo2Class\n");
return self;
}
- foo2
{
printf("foo2\n");
return self;
}
- duplicate
{
printf("Foo2 duplicate\n");
return self;
}
@end
@implementation Foo2Sub
+ foo2SubClass
{
printf("foo2SubClass\n");
return self;
}
- foo2Sub
{
printf("foo2Sub\n");
return self;
}
@end
int main()
{
id f = [Foo new];
[f encodeWithCoder:nil];
set_behavior_debug(1);
[f foo2];
[[f class] foo2Class];
[f foo2Sub];
[[f class] foo2SubClass];
[f duplicate];
exit(0);
}
/*
Local Variables:
compile-command: "gcc beh.m -I.. -L.. -lobjects -lobjc -o beh"
End:
*/

View file

@ -0,0 +1,51 @@
typedef void(*apply_t)(void); /* function pointer */
typedef union {
char *arg_ptr;
char arg_regs[sizeof (char*)];
} *arglist_t; /* argument frame */
double ret_double3(int i, int j)
{
static double d = 1.23456;
return d;
}
double ret_double2(int i, int j)
{
double d = 0.0 + i + j;
return d;
}
double ret_double(int i, int j)
{
arglist_t argframe;
int stack_argsize;
int reg_argsize;
void *ret;
void *(*imp)();
imp = ret_double3;
/* void *args = __builtin_apply_args(); */
stack_argsize = 0;
reg_argsize = 8;
argframe = (arglist_t) alloca(sizeof(char*) + reg_argsize);
if (stack_argsize)
argframe->arg_ptr = alloca(stack_argsize);
else
argframe->arg_ptr = 0;
ret = __builtin_apply(imp, argframe, 0);
__builtin_return(ret);
}
int main()
{
double d;
d = ret_double3(2, 3);
printf("got %f\n", d);
d = ret_double(2, 3);
printf("got %f\n", d);
exit(0);
}