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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc/] [execute/] [class_self-2.m] - Blame information for rev 378

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

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

powered by: WebSVN 2.1.0

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