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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [class_self-2.m] - Blame information for rev 154

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

Line No. Rev Author Line
1 149 jeremybenn
/* Contributed by Nicola Pero - Fri Oct 26 22:39:32 BST 2001 */
2
#include <objc/objc.h>
3
 
4
/* Test calling a class method on self where self has been redefined
5
   to be another class - the call requires a cast */
6
 
7
 
8
/* The first class */
9
struct d
10
{
11
  int a;
12
};
13
 
14
@interface ClassA
15
{
16
  Class isa;
17
}
18
+ (Class) class;
19
+ (struct d) method;
20
@end
21
 
22
@implementation ClassA
23
+ (Class) class
24
{
25
  return self;
26
}
27
 
28
+ (struct d) method
29
{
30
  struct d u;
31
  u.a = 5;
32
 
33
  return u;
34
}
35
#ifdef __NEXT_RUNTIME__                                   
36
+ initialize { return self; }
37
#endif
38
@end
39
 
40
/* The second class */
41
@interface TestClass
42
{
43
  Class isa;
44
}
45
+ (void) test;
46
@end
47
 
48
@implementation TestClass
49
+ (void) test
50
{
51
  self = [ClassA class];
52
 
53
 
54
  if ([(Class)self method].a != 5)
55
    {
56
      abort ();
57
    }
58
}
59
 
60
#ifdef __NEXT_RUNTIME__                                   
61
+ initialize { return self; }
62
#endif
63
@end
64
 
65
 
66
int main (void)
67
{
68
  [TestClass test];
69
 
70
  return 0;
71
}

powered by: WebSVN 2.1.0

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