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 #include <objc/objc.h>
13 #include <objc/Object.h>
14 #include <objc/Protocol.h>
16 #ifndef __NEXT_RUNTIME__
17 #include <objc/encoding.h>
19 #include "next_mapping.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];
38 struct objc_method_description *method;
39 const char *method_types;
42 /* This no-op command is needed to keep the test compile on broken
44 MyObject *object = [MyObject bycopyMethod];
46 /* Get the protocol object */
47 protocol = @protocol (MyProtocol);
49 /* Ask to the protocol for the description of the method bycopyMethod */
50 method = [protocol descriptionForClassMethod: @selector (bycopyMethod)];
53 printf ("Could not find method bycopyMethod in protocol!\n");
57 /* Get the method types for the method - which encode return type,
59 method_types = method->types;
61 /* Get the qualifiers for the return type */
62 qualifiers = objc_get_type_qualifiers (method_types);
64 /* If _F_BYCOPY is not there, the compiler is broken */
65 if (! (qualifiers & _F_BYCOPY))
67 printf ("Failed - selector does not contain _F_BYCOPY qualifier!\n");