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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [accessing_ivars.m] - Blame information for rev 307

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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