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>
29 @implementation MyObject
30 + (bycopy id<MyProtocol>) bycopyMethod
32 return [MyObject alloc];
36 /* The following header, together with the implementation included below,
37 emulate functionality provided by the GNU runtime but not available from
39 #include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist.h"
43 struct objc_method_description *method;
44 const char *method_types;
47 /* This no-op command is needed to keep the test compile on broken
49 MyObject *object = [MyObject bycopyMethod];
51 /* Get the protocol object */
52 protocol = @protocol (MyProtocol);
54 /* Ask to the protocol for the description of the method bycopyMethod */
55 method = [protocol descriptionForClassMethod: @selector (bycopyMethod)];
58 printf ("Could not find method bycopyMethod in protocol!\n");
62 /* Get the method types for the method - which encode return type,
64 method_types = method->types;
66 /* Get the qualifiers for the return type */
67 qualifiers = objc_get_type_qualifiers (method_types);
69 /* If _F_BYCOPY is not there, the compiler is broken */
70 if (! (qualifiers & _F_BYCOPY))
72 printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n");
80 #ifdef __NEXT_RUNTIME__
82 objc_get_type_qualifiers (const char *type)
90 case _C_CONST: res |= _F_CONST; break;
91 case _C_IN: res |= _F_IN; break;
92 case _C_INOUT: res |= _F_INOUT; break;
93 case _C_OUT: res |= _F_OUT; break;
94 case _C_BYCOPY: res |= _F_BYCOPY; break;
95 case _C_BYREF: res |= _F_BYREF; break;
96 case _C_ONEWAY: res |= _F_ONEWAY; break;
97 case _C_GCINVISIBLE: res |= _F_GCINVISIBLE; break;