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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [objc.dg/] [gnu-api-2-ivar.m] - Blame information for rev 716

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

Line No. Rev Author Line
1 704 jeremybenn
/* Test the Modern GNU Objective-C Runtime API.
2
 
3
  This is test 'ivar', covering all functions starting with 'ivar'.  */
4
 
5
/* { dg-do run } */
6
/* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
7
/* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
8
 
9
/* To get the modern GNU Objective-C Runtime API, you include
10
   objc/runtime.h.  */
11
#include <objc/runtime.h>
12
#include <stdlib.h>
13
#include <stdio.h>
14
#include <string.h>
15
 
16
@interface MyRootClass
17
{ Class isa; }
18
+ alloc;
19
- init;
20
+ initialize;
21
@end
22
 
23
@implementation MyRootClass
24
+ alloc { return class_createInstance (self, 0); }
25
- init  { return self; }
26
+ initialize { return self; }
27
@end
28
 
29
@protocol MyProtocol
30
- (id) variable;
31
@end
32
 
33
@protocol MySecondProtocol
34
- (id) setVariable: (id)value;
35
@end
36
 
37
@interface MySubClass : MyRootClass <MyProtocol>
38
{ id variable_ivar; }
39
- (void) setVariable: (id)value;
40
- (id) variable;
41
@end
42
 
43
@implementation MySubClass
44
- (void) setVariable: (id)value { variable_ivar = value; }
45
- (id) variable { return variable_ivar; }
46
@end
47
 
48
 
49
int main(int argc, void **args)
50
{
51
  /* Functions are tested in alphabetical order.  */
52
 
53
  printf ("Testing ivar_getName () ...\n");
54
  {
55
    Ivar ivar = class_getInstanceVariable (objc_getClass ("MySubClass"),
56
                                           "variable_ivar");
57
   if (strcmp (ivar_getName (ivar), "variable_ivar") != 0)
58
      abort ();
59
 
60
   ivar = class_getInstanceVariable (objc_getClass ("MySubClass"),
61
                                     "variable");
62
   if (ivar != 0)
63
      abort ();
64
  }
65
 
66
  printf ("Testing ivar_getOffset () ...\n");
67
  {
68
    Ivar ivar = class_getInstanceVariable (objc_getClass ("MyRootClass"),
69
                                           "isa");
70
    if (ivar_getOffset (ivar) != 0)
71
      abort ();
72
  }
73
 
74
  printf ("Testing ivar_getTypeEncoding () ...\n");
75
  {
76
    Ivar ivar = class_getInstanceVariable (objc_getClass ("MySubClass"),
77
                                           "variable_ivar");
78
    if (strcmp (ivar_getTypeEncoding (ivar), "@") != 0)
79
      abort ();
80
  }
81
 
82
  return 0;
83
}

powered by: WebSVN 2.1.0

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