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-7.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 an ivar and
8
   accessor methods; accessor methods implemented in a separate
9
   category */
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
@interface SubClass : RootClass
24
{
25
  int state;
26
}
27
@end
28
 
29
@implementation SubClass
30
@end
31
 
32
@interface SubClass (Additions)
33
- (void) setState: (int)number;
34
- (int) state;
35
@end
36
 
37
@implementation SubClass (Additions)
38
- (void) setState: (int)number
39
{
40
  state = number;
41
}
42
- (int) state
43
{
44
  return state;
45
}
46
@end
47
 
48
#include "class-tests-1.h"
49
#define TYPE_OF_OBJECT_WITH_ACCESSOR_METHOD SubClass *
50
#include "class-tests-2.h"
51
 
52
int main (void)
53
{
54
  SubClass *object;
55
 
56
  test_class_with_superclass ("SubClass", "RootClass");
57
 
58
  /* The NeXT runtime's category implementation is lazy: categories are not attached
59
     to classes until the class is initialized (at +initialize time).  */
60
#ifdef __NEXT_RUNTIME__
61
  [SubClass initialize];
62
#endif
63
 
64
  test_that_class_has_instance_method ("SubClass", @selector (setState:));
65
  test_that_class_has_instance_method ("SubClass", @selector (state));
66
 
67
  object = class_create_instance (objc_lookup_class ("SubClass"));
68
  test_accessor_method (object, 0, 1, 1, -3, -3);
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.