Debian Codegraph @

gcc/testsuite/objc-obj-c++-shared/GNUStep/Foundation/NSObjCRuntime.h

raw
1 /** Interface to ObjC runtime for GNUStep
2 Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
3
4 Written by: Andrew Kachites McCallum <[email protected]>
5 Date: 1995
6
7 This file is part of the GNUstep Base Library.
8
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version.
13
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free
21 Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 Boston, MA 02111 USA.
23
24 AutogsdocSource: NSObjCRuntime.m
25 AutogsdocSource: NSLog.m
26
27 */
28
29 #ifndef __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
30 #define __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE
31
32 /* Allow the elaborated enum use in _GS_NAMED_ENUM. */
33 #pragma GCC system_header
34
35 #ifdef __cplusplus
36 #ifndef __STDC_LIMIT_MACROS
37 #define __STDC_LIMIT_MACROS 1
38 #endif
39 #endif
40
41 #import "../GNUstepBase/GSVersionMacros.h"
42 #import "../GNUstepBase/GSConfig.h"
43 #import "../GNUstepBase/GNUstep.h"
44 #if __BLOCKS__
45 #import "../GNUstepBase/GSBlocks.h"
46 #endif
47
48 #include <stdarg.h>
49 #include <limits.h>
50 #include <float.h>
51
52 /* PA HP-UX kludge. */
53 #if defined(__hppa__) && defined(__hpux__) && !defined(PRIuPTR)
54 #define PRIuPTR "lu"
55 #endif
56
57 /* IRIX kludge. */
58 #if defined(__sgi)
59 /* IRIX 6.5 <inttypes.h> provides all definitions, but only for C99
60 compilations. */
61 #define PRId8 "hhd"
62 #define PRIu8 "hhu"
63 #if (_MIPS_SZLONG == 32)
64 #define PRId64 "lld"
65 #define PRIu64 "llu"
66 #endif
67 /* This doesn't match <inttypes.h>, which always has "lld" here, but the
68 arguments are uint64_t, int64_t, which are unsigned long, long for
69 64-bit in <sgidefs.h>. */
70 #if (_MIPS_SZLONG == 64)
71 #define PRId64 "ld"
72 #define PRIu64 "lu"
73 #endif
74 /* This doesn't match <inttypes.h>, which has "u" here, but the arguments
75 are uintptr_t, which is always unsigned long. */
76 #define PRIuPTR "lu"
77 #endif
78
79 /* Solaris < 10 kludge. */
80 #if defined(__sun__) && defined(__svr4__) && !defined(PRIuPTR)
81 #if defined(__arch64__) || defined (__x86_64__)
82 #define PRIuPTR "lu"
83 #define PRIdPTR "ld"
84 #define PRIxPTR "lx"
85 #else
86 #define PRIuPTR "u"
87 #define PRIdPTR "d"
88 #define PRIxPTR "x"
89 #endif
90 #endif
91
92
93 /* These typedefs must be in place before GSObjCRuntime.h is imported.
94 */
95
96 #if !defined(NSINTEGER_DEFINED)
97 typedef intptr_t NSInteger;
98 typedef uintptr_t NSUInteger;
99 # define NSIntegerMax INTPTR_MAX
100 # define NSIntegerMin INTPTR_MIN
101 # define NSUIntegerMax UINTPTR_MAX
102 #endif /* !defined(NSINTEGER_DEFINED) */
103
104 #if !defined(CGFLOAT_DEFINED)
105 #if GS_SIZEOF_VOIDP == 8
106 #define CGFLOAT_IS_DBL 1
107 typedef double CGFloat;
108 #define CGFLOAT_MIN DBL_MIN
109 #define CGFLOAT_MAX DBL_MAX
110 #else
111 typedef float CGFloat;
112 #define CGFLOAT_MIN FLT_MIN
113 #define CGFLOAT_MAX FLT_MAX
114 #endif
115 #endif /* !defined(CGFLOAT_DEFINED) */
116
117 #define NSINTEGER_DEFINED 1
118 #define CGFLOAT_DEFINED 1
119 #ifndef NS_AUTOMATED_REFCOUNT_UNAVAILABLE
120 # if __has_feature(objc_arc)
121 # define NS_AUTOMATED_REFCOUNT_UNAVAILABLE \
122 __attribute__((unavailable("Not available with automatic reference counting")))
123 # else
124 # define NS_AUTOMATED_REFCOUNT_UNAVAILABLE
125 # endif
126 #endif
127
128
129 #if defined(__cplusplus)
130 extern "C" {
131 #endif
132
133
134 /*
135 * We can have strongly typed enums in C++11 mode or when the objc_fixed_enum
136 * feature is availble.
137 */
138 #if (__has_feature(objc_fixed_enum) || (__cplusplus && (__cplusplus > 199711L) && __has_extension(cxx_strong_enums)))
139 # define _GS_NAMED_ENUM(ty, name) enum name : ty name; enum name : ty
140 # define _GS_ANON_ENUM(ty) enum : ty
141 # if __cplusplus
142 # define NS_OPTIONS(ty,name) ty name; enum : ty
143 # else
144 # define NS_OPTIONS(ty,name) NS_ENUM(ty,name)
145 # endif
146 #else // this provides less information, but works with older compilers
147 # define _GS_NAMED_ENUM(ty, name) ty name; enum
148 # define _GS_ANON_ENUM(ty) enum
149 # define NS_OPTIONS(ty, name) NS_ENUM(ty, name)
150 #endif
151 // A bit of fairy dust to expand NS_ENUM to the correct variant
152 #define _GS_GET_ENUM_MACRO(_first,_second,NAME,...) NAME
153 /* The trick here is that placing the variadic args first will push the name
154 * that the _GS_GET_ENUM_MACRO expands to into the correct position.
155 */
156 #define NS_ENUM(...) _GS_GET_ENUM_MACRO(__VA_ARGS__,_GS_NAMED_ENUM,_GS_ANON_ENUM)(__VA_ARGS__)
157
158 /*
159 * If the compiler supports nullability qualifiers, we define the macros for
160 * non-null sections.
161 */
162 #if __has_feature(nullability)
163 # define NS_ASSUME_NONNULL_BEGIN _Pragma("clang assume_nonnull begin")
164 # define NS_ASSUME_NONNULL_END _Pragma("clang assume_nonnull end")
165 #else
166 # define NS_ASSUME_NONNULL_BEGIN
167 # define NS_ASSUME_NONNULL_END
168 #endif
169
170 /*
171 * Backwards compatibility macro for instance type.
172 */
173 #if !__has_feature(objc_instancetype)
174 # define instancetype id
175 #endif
176
177 /*
178 * Backwards compatibility macros for Objective-C lightweight generics.
179 */
180 #if __has_feature(objc_generics)
181 # define GS_GENERIC_CLASS(clz, ...) clz<__VA_ARGS__>
182 # define GS_GENERIC_TYPE_F(typeRef, fallback) typeRef
183 #else
184 # define GS_GENERIC_CLASS(clz, ...) clz
185 # define GS_GENERIC_TYPE_F(typeRef, fallback) fallback
186 #endif
187 #define GS_GENERIC_TYPE(typeRef) GS_GENERIC_TYPE_F(typeRef, id)
188
189 /**
190 * Backwards compatibility macro for the objc_designated_initializer attribute
191 */
192 #if __has_attribute(objc_designated_initializer)
193 # define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
194 #else
195 # define NS_DESIGNATED_INITIALIZER
196 #endif
197
198 /** Bitfield used to specify options to control enumeration over collections.
199 */
200 typedef NS_OPTIONS(NSUInteger, NSEnumerationOptions)
201 {
202 NSEnumerationConcurrent = (1UL << 0), /** Specifies that the enumeration
203 * is concurrency-safe. Note that this does not mean that it will be
204 * carried out in a concurrent manner, only that it can be.
205 */
206
207 NSEnumerationReverse = (1UL << 1) /** Specifies that the enumeration should
208 * happen in the opposite of the natural order of the collection.
209 */
210 };
211
212
213 /** Bitfield used to specify options to control the sorting of collections.
214 */
215 typedef NS_OPTIONS(NSUInteger, NSSortOptions)
216 {
217 NSSortConcurrent = (1UL << 0), /** Specifies that the sort
218 * is concurrency-safe. Note that this does not mean that it will be
219 * carried out in a concurrent manner, only that it can be.
220 */
221 NSSortStable = (1UL << 4) /** Specifies that the sort should keep
222 * equal objects in the same order in the collection.
223 */
224 };
225
226
227 #import "../GNUstepBase/GSObjCRuntime.h"
228
229 #if OS_API_VERSION(MAC_OS_X_VERSION_10_5,GS_API_LATEST)
230 GS_EXPORT NSString *NSStringFromProtocol(Protocol *aProtocol);
231 GS_EXPORT Protocol *NSProtocolFromString(NSString *aProtocolName);
232 #endif
233 GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
234 GS_EXPORT NSString *NSStringFromSelector(SEL aSelector);
235 GS_EXPORT SEL NSSelectorFromString(NSString *aSelectorName);
236 GS_EXPORT Class NSClassFromString(NSString *aClassName);
237 GS_EXPORT NSString *NSStringFromClass(Class aClass);
238 GS_EXPORT const char *NSGetSizeAndAlignment(const char *typePtr,
239 NSUInteger *sizep, NSUInteger *alignp);
240
241 #if OS_API_VERSION(GS_API_NONE, GS_API_NONE)
242 /* Logging */
243 /**
244 * OpenStep spec states that log messages go to stderr, but just in case
245 * someone wants them to go somewhere else, they can implement a function
246 * like this and assign a pointer to it to _NSLog_printf_handler.
247 */
248 typedef void NSLog_printf_handler (NSString* message);
249 GS_EXPORT NSLog_printf_handler *_NSLog_printf_handler;
250 GS_EXPORT int _NSLogDescriptor;
251 @class NSRecursiveLock;
252 GS_EXPORT NSRecursiveLock *GSLogLock(void);
253 #endif
254
255 GS_EXPORT void NSLog(NSString *format, ...) NS_FORMAT_FUNCTION(1,2);
256 GS_EXPORT void NSLogv(NSString *format, va_list args) NS_FORMAT_FUNCTION(1,0);
257
258 #ifndef YES
259 #define YES 1
260 #endif
261 #ifndef NO
262 #define NO 0
263 #endif
264 #ifndef nil
265 #define nil 0
266 #endif
267
268 /**
269 * Contains values <code>NSOrderedSame</code>, <code>NSOrderedAscending</code>
270 * <code>NSOrderedDescending</code>, for left hand side equals, less than, or
271 * greater than right hand side.
272 */
273 typedef NS_ENUM(NSInteger, NSComparisonResult)
274 {
275 NSOrderedAscending = (NSInteger)-1, NSOrderedSame, NSOrderedDescending
276 };
277
278 enum {NSNotFound = NSIntegerMax};
279
280 #if __BLOCKS__
281 DEFINE_BLOCK_TYPE(NSComparator, NSComparisonResult, id, id);
282 #endif
283
284 /**
285 * Declare the foundation export macro as an alias to GS_EXPORT
286 */
287 #define FOUNDATION_EXPORT GS_EXPORT
288
289 #if defined(__cplusplus)
290 }
291 #endif
292
293 /**
294 * Declare Apple availability macros for compatibility purposes as no-ops.
295 */
296 #define NS_CLASS_AVAILABLE(...)
297 #define NS_AVAILABLE(...)
298 #define NS_AVAILABLE_MAC(...)
299 #define NS_DEPRECATED(...)
300 #define NS_DEPRECATED_MAC(...)
301 #define NS_ENUM_AVAILABLE(...)
302 #define NS_ENUM_AVAILABLE_MAC(...)
303 #define NS_ENUM_DEPRECATED(...)
304 #define NS_ENUM_DEPRECATED_MAC(...)
305 #define NS_CLASS_AVAILABLE(...)
306 #define NS_CLASS_DEPRECATED(...)
307 #define NS_CLASS_AVAILABLE_MAC(...)
308 #define NS_CLASS_DEPRECATED_MAC(...)
309 #define NS_UNAVAILABLE
310
311 /* Define root class NS macro */
312 #ifndef NS_ROOT_CLASS
313 #if __has_attribute(objc_root_class)
314 #define NS_ROOT_CLASS __attribute__((objc_root_class))
315 #else
316 #define NS_ROOT_CLASS
317 #endif
318 #endif
319
320 #endif /* __NSObjCRuntime_h_GNUSTEP_BASE_INCLUDE */