OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc/] [execute/] [class-14.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 - Tue Mar  6 23:05:53 CET 2001 */
2
 
3
#include "../../objc-obj-c++-shared/next-mapping.h"
4
#include <objc/objc.h>
5
#include <objc/objc-api.h>
6
 
7
/* Tests creating a root class and a subclass with a class accessor
8
   methods and a subclass overriding the superclass' implementation,
9
   and using self to call another method of itself */
10
 
11
@interface RootClass
12
{
13
  Class isa;
14
}
15
@end
16
 
17
@implementation RootClass
18
#ifdef __NEXT_RUNTIME__                                   
19
+ initialize { return self; }
20
#endif
21
@end
22
 
23
static int class_variable = 0;
24
 
25
@interface SubClass : RootClass
26
+ (void) setState: (int)number;
27
+ (int) state;
28
@end
29
 
30
@implementation SubClass
31
+ (void) setState: (int)number
32
{
33
  class_variable = number;
34
}
35
+ (int) state
36
{
37
  return class_variable;
38
}
39
@end
40
 
41
@interface SubSubClass : SubClass
42
+ (int) shift;
43
@end
44
 
45
@implementation SubSubClass
46
+ (int) state
47
{
48
  return class_variable + [self shift];
49
}
50
+ (int) shift
51
{
52
  return 1;
53
}
54
@end
55
 
56
#include "class-tests-1.h"
57
#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
58
#include "class-tests-2.h"
59
 
60
int main (void)
61
{
62
  Class class, sub_class;
63
 
64
  test_class_with_superclass ("SubClass", "RootClass");
65
  test_that_class_has_class_method ("SubClass", @selector (setState:));
66
  test_that_class_has_class_method ("SubClass", @selector (state));
67
 
68
  test_class_with_superclass ("SubSubClass", "SubClass");
69
  test_that_class_has_class_method ("SubSubClass", @selector (setState:));
70
  test_that_class_has_class_method ("SubSubClass", @selector (state));
71
  test_that_class_has_class_method ("SubSubClass", @selector (shift));
72
 
73
  class = objc_lookup_class ("SubClass");
74
  test_accessor_method (class, 0, -1, -1, 1, 1);
75
 
76
  sub_class = objc_lookup_class ("SubSubClass");
77
  class_variable = 0;
78
  test_accessor_method (sub_class, 1, -1, 0, 1, 2);
79
 
80
  return 0;
81
}

powered by: WebSVN 2.1.0

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