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

Subversion Repositories openrisc

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 702 jeremybenn
/* Contributed by Nicola Pero - Thu Mar  8 16:27:46 CET 2001 */
2
#include <stdlib.h>
3
#include "../../objc-obj-c++-shared/TestsuiteObject.m"
4
 
5
/* Test that by using -> we can access ivars of other objects of the same
6
   class */
7
 
8
@interface TestClass : TestsuiteObject
9
{
10
  int value;
11
}
12
- (int) value;
13
- (void) setValue: (int)number;
14
- (void) takeValueFrom: (TestClass *)object;
15
@end
16
 
17
@implementation TestClass : TestsuiteObject
18
{
19
  int value;
20
}
21
- (int) value
22
{
23
  return value;
24
}
25
- (void) setValue: (int)number
26
{
27
  value = number;
28
}
29
- (void) takeValueFrom: (TestClass *)object
30
{
31
  value = object->value;
32
}
33
@end
34
 
35
int main (void)
36
{
37
  TestClass *a;
38
  TestClass *b;
39
 
40
  a = [TestClass new];
41
  [a setValue: 10];
42
 
43
  b = [TestClass new];
44
  [b setValue: -10];
45
 
46
  [b takeValueFrom: a];
47
 
48
  if ([b value] != [a value])
49
    {
50
      abort ();
51
    }
52
 
53
  return 0;
54
}
55
 

powered by: WebSVN 2.1.0

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