OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc/] [execute/] [forward-1.m] - Blame information for rev 862

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 307 jeremybenn
/* See if -forward::/-performv:: is able to work. */
2
 
3
#include <stdio.h>
4
#include <stdlib.h>
5
 
6
#import "../../objc-obj-c++-shared/Object1.h"
7
#import "../../objc-obj-c++-shared/next-mapping.h"
8
#include <objc/objc-api.h>
9
 
10
#define VALUETOUSE 1234567890
11
 
12
id forwarder, receiver;
13
 
14
@interface Forwarder: Object
15
{
16
    id receiver;
17
}
18
 
19
-initWithReceiver:theReceiver;
20
 
21
@end
22
 
23
@interface Receiver:Object
24
{
25
    int foo;
26
}
27
-display;
28
-initWithFoo:(int)theFoo;
29
@end
30
@implementation Receiver
31
 
32
-initWithFoo: (int)theFoo
33
{
34
    foo = theFoo;
35
    return self;
36
}
37
 
38
-display
39
{
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;
47
}
48
 
49
@end
50
 
51
@implementation Forwarder
52
-initWithReceiver: theReceiver
53
{
54
    [super init];
55
    receiver = theReceiver;
56
    return self;
57
}
58
#ifdef __NEXT_RUNTIME__
59
- forward: (SEL)theSel: (marg_list)theArgFrame
60
#else
61
-(retval_t) forward: (SEL)theSel: (arglist_t)theArgFrame
62
#endif
63
{
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];
68
}
69
@end
70
int main()
71
{
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);
80
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.