diff --git a/Examples/nx-client.m b/Examples/nx-client.m new file mode 100644 index 000000000..4ff025c2c --- /dev/null +++ b/Examples/nx-client.m @@ -0,0 +1,20 @@ +#include +#include +#include + +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); +} diff --git a/Examples/nx-server.m b/Examples/nx-server.m new file mode 100644 index 000000000..dfc5f5b7f --- /dev/null +++ b/Examples/nx-server.m @@ -0,0 +1,15 @@ +#include +#include + +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); +} diff --git a/Testing/beh.m b/Testing/beh.m new file mode 100644 index 000000000..bf66a5dd0 --- /dev/null +++ b/Testing/beh.m @@ -0,0 +1,98 @@ +#include +#include +#include + +@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: +*/ diff --git a/config/config.builtin_apply.c b/config/config.builtin_apply.c new file mode 100644 index 000000000..0f27beaa8 --- /dev/null +++ b/config/config.builtin_apply.c @@ -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); +}