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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [objc/] [execute/] [class-13.m] - Blame information for rev 826

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
   but reusing it with super */
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
@end
43
 
44
@implementation SubSubClass
45
+ (int) state
46
{
47
  return [super state] + 1;
48
}
49
@end
50
 
51
#include "class-tests-1.h"
52
#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD Class
53
#include "class-tests-2.h"
54
 
55
int main (void)
56
{
57
  Class class;
58
  Class sub_class;
59
 
60
  test_class_with_superclass ("SubClass", "RootClass");
61
  test_that_class_has_class_method ("SubClass", @selector (setState:));
62
  test_that_class_has_class_method ("SubClass", @selector (state));
63
 
64
  test_class_with_superclass ("SubSubClass", "SubClass");
65
  test_that_class_has_class_method ("SubSubClass", @selector (setState:));
66
  test_that_class_has_class_method ("SubSubClass", @selector (state));
67
 
68
  class = objc_lookup_class ("SubClass");
69
  test_accessor_method (class, 0, -1, -1, 1, 1);
70
 
71
  sub_class = objc_lookup_class ("SubSubClass");
72
  class_variable = 0;
73
  test_accessor_method (sub_class, 1, -1, 0, 1, 2);
74
 
75
  return 0;
76
}

powered by: WebSVN 2.1.0

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