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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [objc/] [execute/] [bycopy-3.m] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/*
2
 * Contributed by Nicola Pero <nicola@brainstorm.co.uk>
3
 * Wed Feb 28 12:27:03 CET 2001
4
 */
5
 
6
/*
7
 * This test contains some no-op code which is needed to keep it
8
 * compile on broken gcc 3.x.  Anyway, the no-op code does not
9
 * interfere with what we are testing, which is that the `bycopy'
10
 * keyword generates the _F_BYCOPY qualifier for the return type.  */
11
 
12
#include <objc/objc.h>
13
#include <objc/Object.h>
14
#include <objc/Protocol.h>
15
 
16
#ifndef __NEXT_RUNTIME__
17
#include <objc/encoding.h>
18
#endif
19
#include "next_mapping.h"
20
 
21
@protocol MyProtocol
22
+ (bycopy id<MyProtocol>) bycopyMethod;
23
@end
24
 
25
/* This no-op class to keep it compile under broken gcc 3.x */
26
@interface MyObject : Object <MyProtocol>
27
@end
28
 
29
@implementation MyObject
30
+ (bycopy id<MyProtocol>) bycopyMethod
31
{
32
  return [MyObject alloc];
33
}
34
@end
35
 
36
int main (void)
37
{
38
  struct objc_method_description *method;
39
  const char *method_types;
40
  unsigned qualifiers;
41
  Protocol *protocol;
42
  /* This no-op command is needed to keep the test compile on broken
43
     gcc 3.x */
44
  MyObject *object = [MyObject bycopyMethod];
45
 
46
  /* Get the protocol object */
47
  protocol = @protocol (MyProtocol);
48
 
49
  /* Ask to the protocol for the description of the method bycopyMethod */
50
  method = [protocol descriptionForClassMethod: @selector (bycopyMethod)];
51
  if (method == NULL)
52
    {
53
      printf ("Could not find method bycopyMethod in protocol!\n");
54
      exit (1);
55
    }
56
 
57
  /* Get the method types for the method - which encode return type,
58
     arguments etc. */
59
  method_types = method->types;
60
 
61
  /* Get the qualifiers for the return type */
62
  qualifiers = objc_get_type_qualifiers (method_types);
63
 
64
  /* If _F_BYCOPY is not there, the compiler is broken */
65
  if (! (qualifiers & _F_BYCOPY))
66
    {
67
      printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n");
68
      exit (1);
69
    }
70
 
71
  /* Else, happy end */
72
  return 0;
73
}

powered by: WebSVN 2.1.0

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