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 int printf (const char *, ...);
14 #include <objc/objc.h>
15 #include "../../objc-obj-c++-shared/runtime.h"
16 #include "../../objc-obj-c++-shared/TestsuiteObject.m"
19 + (bycopy id<MyProtocol>) bycopyMethod;
22 /* This no-op class to keep it compile under broken gcc 3.x */
23 @interface MyObject : TestsuiteObject <MyProtocol>
26 @implementation MyObject
27 + (bycopy id<MyProtocol>) bycopyMethod
29 return [MyObject alloc];
33 /* The following header, together with the implementation included below,
34 emulate functionality provided by the GNU runtime but not available from
36 #include "../../objc-obj-c++-shared/objc-test-suite-next-encode-assist.h"
40 struct objc_method_description method;
41 const char *method_types;
44 /* This no-op command is needed to keep the test compile on broken
46 MyObject *object = [MyObject bycopyMethod];
48 /* Get the protocol object */
49 protocol = @protocol (MyProtocol);
51 /* Ask to the protocol for the description of the method bycopyMethod */
52 method = protocol_getMethodDescription (protocol, @selector (bycopyMethod),
55 /* Get the method types for the method - which encode return type,
57 method_types = method.types;
59 if (method_types == NULL)
61 printf ("Could not find method bycopyMethod in protocol!\n");
65 /* Get the qualifiers for the return type */
66 qualifiers = objc_get_type_qualifiers (method_types);
68 /* If _F_BYCOPY is not there, the compiler is broken */
69 if (! (qualifiers & _F_BYCOPY))
71 printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n");
79 #ifdef __NEXT_RUNTIME__
81 objc_get_type_qualifiers (const char *type)
89 case _C_CONST: res |= _F_CONST; break;
90 case _C_IN: res |= _F_IN; break;
91 case _C_INOUT: res |= _F_INOUT; break;
92 case _C_OUT: res |= _F_OUT; break;
93 case _C_BYCOPY: res |= _F_BYCOPY; break;
94 case _C_BYREF: res |= _F_BYREF; break;
95 case _C_ONEWAY: res |= _F_ONEWAY; break;
96 case _C_GCINVISIBLE: res |= _F_GCINVISIBLE; break;