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-property.m] - Blame information for rev 704

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 'property', covering all functions starting with 'property'.  */
4
 
5
/* { dg-do run } */
6
/* { dg-skip-if "No API#2 pre-Darwin9" { *-*-darwin[5-8]* } { "-fnext-runtime" } { "" } } */
7
 
8
/* To get the modern GNU Objective-C Runtime API, you include
9
   objc/runtime.h.  */
10
#include <objc/runtime.h>
11
#include <stdlib.h>
12
#include <stdio.h>
13
#include <string.h>
14
 
15
@interface MyRootClass
16
{ Class isa; }
17
+ alloc;
18
- init;
19
+ initialize;
20
@end
21
 
22
@implementation MyRootClass
23
+ alloc { return class_createInstance (self, 0); }
24
- init  { return self; }
25
+ initialize { return self; }
26
@end
27
 
28
@interface MySubClass : MyRootClass
29
{
30
  id propertyA;
31
  id propertyB;
32
}
33
@property (assign, getter=getP, setter=setP:) id propertyA;
34
@property (assign, nonatomic) id propertyB;
35
@end
36
 
37
@implementation MySubClass
38
@synthesize propertyA;
39
@synthesize propertyB;
40
@end
41
 
42
 
43
int main(int argc, void **args)
44
{
45
  /* Functions are tested in alphabetical order.  */
46
 
47
  printf ("Testing property_getAttributes () ...\n");
48
  {
49
    /* The Apple/NeXT runtime seems to crash on the following.  */
50
#ifdef __GNU_LIBOBJC__
51
    if (property_getAttributes (NULL) != NULL)
52
      abort ();
53
#endif
54
 
55
    /* The GNU runtime doesn't support looking up properties at
56
       runtime yet.  */
57
#ifdef __OBJC2__
58
    {
59
      objc_property_t property;
60
 
61
      property = class_getProperty (objc_getClass ("MySubClass"), "propertyA");
62
      if (strcmp (property_getAttributes (property),
63
                  "T@,GgetP,SsetP:,VpropertyA") != 0)
64
        abort ();
65
 
66
      property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
67
      if (strcmp (property_getAttributes (property),
68
                  "T@,N,VpropertyB") != 0)
69
        abort ();
70
    }
71
#endif    
72
  }
73
 
74
  printf ("Testing property_getName () ...\n");
75
  {
76
    /* The Apple/NeXT runtime seems to crash on the following.  */
77
#ifdef __GNU_LIBOBJC__
78
    if (property_getName (NULL) != NULL)
79
      abort ();
80
#endif
81
 
82
    /* The GNU runtime doesn't support looking up properties at
83
       runtime yet.  */
84
#ifdef __OBJC2__
85
    {
86
      objc_property_t property;
87
 
88
      property = class_getProperty (objc_getClass ("MySubClass"), "propertyA");
89
      if (strcmp (property_getName (property), "propertyA") != 0)
90
        abort ();
91
 
92
      property = class_getProperty (objc_getClass ("MySubClass"), "propertyB");
93
      if (strcmp (property_getName (property), "propertyB") != 0)
94
        abort ();
95
    }
96
#endif
97
  }
98
 
99
  return 0;
100
}

powered by: WebSVN 2.1.0

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