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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc/] [execute/] [class-7.m] - Blame information for rev 702

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 702 jeremybenn
/* Contributed by Nicola Pero - Tue Mar  6 23:05:53 CET 2001 */
2
 
3
#include <objc/objc.h>
4
 
5
/* Tests creating a root class and a subclass with an ivar and
6
   accessor methods; accessor methods implemented in a separate
7
   category */
8
 
9
@interface RootClass
10
{
11
  Class isa;
12
}
13
@end
14
 
15
@implementation RootClass
16
+ initialize { return self; }
17
@end
18
 
19
@interface SubClass : RootClass
20
{
21
  int state;
22
}
23
@end
24
 
25
@implementation SubClass
26
@end
27
 
28
@interface SubClass (Additions)
29
- (void) setState: (int)number;
30
- (int) state;
31
@end
32
 
33
@implementation SubClass (Additions)
34
- (void) setState: (int)number
35
{
36
  state = number;
37
}
38
- (int) state
39
{
40
  return state;
41
}
42
@end
43
 
44
#include "class-tests-1.h"
45
#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
46
#include "class-tests-2.h"
47
 
48
int main (void)
49
{
50
  SubClass *object;
51
 
52
  test_class_with_superclass ("SubClass", "RootClass");
53
 
54
  /* The NeXT runtime's category implementation is lazy: categories are not attached
55
     to classes until the class is initialized (at +initialize time).  */
56
#ifdef __NEXT_RUNTIME__
57
  [SubClass initialize];
58
#endif
59
 
60
  test_that_class_has_instance_method ("SubClass", @selector (setState:));
61
  test_that_class_has_instance_method ("SubClass", @selector (state));
62
 
63
  object = class_createInstance (objc_getClass ("SubClass"), 0);
64
  test_accessor_method (object, 0, 1, 1, -3, -3);
65
 
66
  return 0;
67
}

powered by: WebSVN 2.1.0

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