2 * Contributed by Nicola Pero <nicola@brainstorm.co.uk>
3 * Wed Feb 28 12:27:03 CET 2001
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. */
12 extern void exit (int) __attribute__ ((noreturn));
13 extern int printf (const char *, ...);
15 #include <objc/Protocol.h>
17 #ifndef __NEXT_RUNTIME__
18 #include <objc/encoding.h>
22 + (bycopy id<MyProtocol>) bycopyMethod;
25 /* This no-op class to keep it compile under broken gcc 3.x */
26 @interface MyObject : Object <MyProtocol>
35 @implementation MyObject
36 + (bycopy id<MyProtocol>) bycopyMethod
38 return [MyObject alloc];
41 + initialize {return self;}
42 + alloc { return class_createInstance (self, 0);}
43 + new { return [[self alloc] init]; }
48 /* The following header, together with the implementation included below,
49 emulate functionality provided by the GNU runtime but not available from
51 #include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist.h"
55 struct objc_method_description *method;
56 const char *method_types;
59 /* This no-op command is needed to keep the test compile on broken
61 MyObject *object = [MyObject bycopyMethod];
63 /* Get the protocol object */
64 protocol = @protocol (MyProtocol);
66 /* Ask to the protocol for the description of the method bycopyMethod */
67 method = [protocol descriptionForClassMethod: @selector (bycopyMethod)];
70 printf ("Could not find method bycopyMethod in protocol!\n");
74 /* Get the method types for the method - which encode return type,
76 method_types = method->types;
78 /* Get the qualifiers for the return type */
79 qualifiers = objc_get_type_qualifiers (method_types);
81 /* If _F_BYCOPY is not there, the compiler is broken */
82 if (! (qualifiers & _F_BYCOPY))
84 printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n");
92 #ifdef __NEXT_RUNTIME__
94 objc_get_type_qualifiers (const char *type)
102 case _C_CONST: res |= _F_CONST; break;
103 case _C_IN: res |= _F_IN; break;
104 case _C_INOUT: res |= _F_INOUT; break;
105 case _C_OUT: res |= _F_OUT; break;
106 case _C_BYCOPY: res |= _F_BYCOPY; break;
107 case _C_BYREF: res |= _F_BYREF; break;
108 case _C_ONEWAY: res |= _F_ONEWAY; break;
109 case _C_GCINVISIBLE: res |= _F_GCINVISIBLE; break;