Merge from mainline (160224:163495).
[official-gcc/graphite-test-results.git] / gcc / testsuite / objc / execute / forward-1.m
blob258a9164999f6e42dcc9ead9df79e451aaf7e281
1 /* See if -forward::/-performv:: is able to work. */
3 #include <stdio.h>
4 #include <stdlib.h>
6 #import "../../objc-obj-c++-shared/Object1.h"
7 #import "../../objc-obj-c++-shared/next-mapping.h"
8 #include <objc/objc-api.h>
10 #define VALUETOUSE 1234567890
12 id forwarder, receiver;
14 @interface Forwarder: Object
16     id receiver;
19 -initWithReceiver:theReceiver;
21 @end
23 @interface Receiver:Object
25     int foo;
27 -display;
28 -initWithFoo:(int)theFoo;
29 @end
30 @implementation Receiver
32 -initWithFoo: (int)theFoo
34     foo = theFoo;
35     return self;
38 -display
40     /* Check to see if we are really the reciever. */
41     if (self != receiver)
42         abort ();
43     /* And the value of foo is set correctly. */
44     if (foo != VALUETOUSE)
45       abort ();
46     return self;
49 @end
51 @implementation Forwarder
52 -initWithReceiver: theReceiver
54     [super init];
55     receiver = theReceiver;
56     return self;
58 #ifdef __NEXT_RUNTIME__
59 - forward: (SEL)theSel: (marg_list)theArgFrame
60 #else
61 -(retval_t) forward: (SEL)theSel: (arglist_t)theArgFrame
62 #endif
64   /* If we have a reciever try to perform on that object */
65     if (receiver)
66         return [receiver performv: theSel: theArgFrame];
67     return [self doesNotRecognize:theSel];
69 @end
70 int main()
72     /* Init the reciever. */
73     receiver = [[Receiver alloc] initWithFoo: VALUETOUSE];
74     /* Init the fowarder. */
75     forwarder = [[Forwarder alloc] initWithReceiver: receiver];
76     /* Call display on the forwarder which in turns calls display on
77        the reciever. */
78     [forwarder display];
79     exit(0);