* ubsan.c (ubsan_expand_null_ifn): Use _v1 suffixed type mismatch
[official-gcc.git] / gcc / testsuite / objc-obj-c++-shared / runtime.h
blob4d7d1c30b96278b51cff120ad780364720189182
1 /* Wrapper around <objc/runtime.h>
2 Copyright (C) 2011 Free Software Foundation, Inc.
3 Contributed by Nicola Pero
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
21 #ifndef _TESTSUITE_RUNTIME_H_
22 #define _TESTSUITE_RUNTIME_H_
24 /* Include this file where you'd normally include <objc/runtime.h>.
26 Older versions of the NeXT runtime do not have <objc/runtime.h> and
27 you need to include <objc/objc-runtime.h> instead. This file takes
28 care of figuring out if that's the case. */
30 #ifndef __NEXT_RUNTIME__
33 GNU Objective-C runtime (libobjc).
35 # include <objc/runtime.h>
37 #else
40 NeXT Objective-C runtime.
43 /* Include next-abi.h to determine which version of the runtime we are
44 dealing with. TODO: If this is the only place including it, maybe
45 it could be copied here ? */
46 # include "next-abi.h"
48 # ifdef NEXT_OBJC_USE_NEW_INTERFACE
50 /* New NeXT runtime, with an API that should be basically identical to
51 the GNU Objective-C one. */
52 # include <objc/runtime.h>
54 # else
56 /* Old NeXT runtime, with an API similar, but not identical to the new
57 one. To start with, different headers need to be included. */
58 # include <objc/objc-class.h>
59 # include <objc/objc-runtime.h>
61 /* Not all functions are available in the old NeXT runtime. A few
62 that we need are not, and here we provide an implementation on top
63 of the old NeXT API. */
65 # define class_isMetaClass(C) (CLS_GETINFO((struct objc_class *)C, CLS_META)? YES: NO)
66 # define class_getName(C) object_getClassName(C)
67 # define class_getSuperclass(C) (((struct objc_class *)C)->super_class)
68 # define method_getImplementation(M) (((Method)M)->method_imp)
69 # define method_getTypeEncoding(M) (((Method)M)->method_types)
70 # define object_getClass(O) (*(struct objc_class **)O)
72 #include <objc/Protocol.h>
73 BOOL class_conformsToProtocol (Class class_, Protocol *protocol)
75 struct objc_protocol_list *p;
76 int i;
77 for (p = class_->protocols; p; p = p->next)
78 for (i = 0; i < p->count; i++)
79 if ([p->list[i] conformsTo: protocol])
80 return YES;
81 return NO;
84 #define protocol_getName(P) [P name]
85 #define protocol_isEqual(P,Q) [P isEqual: Q]
87 struct objc_method_description protocol_getMethodDescription (Protocol *protocol,
88 SEL selector,
89 BOOL requiredMethod,
90 BOOL instanceMethod)
92 struct objc_method_description *tmp;
93 struct objc_method_description result;
95 if (instanceMethod)
96 tmp = [protocol descriptionForInstanceMethod: selector];
97 else
98 tmp = [protocol descriptionForClassMethod: selector];
100 if (tmp)
101 result = *tmp;
102 else
104 result.name = (SEL)0;
105 result.types = (char *)0;
108 return result;
111 # endif /* NEXT_OBJC_USE_NEW_INTERFACE */
113 # endif /* __NEXT_RUNTIME__ */
115 #endif /* _TESTSUITE_RUNTIME_H_ */