1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). |
4 | ** Contact: http://www.qt-project.org/ |
5 | ** |
6 | ** This file is part of the QtCore module of the Qt Toolkit. |
7 | ** |
8 | ** $QT_BEGIN_LICENSE:LGPL$ |
9 | ** GNU Lesser General Public License Usage |
10 | ** This file may be used under the terms of the GNU Lesser General Public |
11 | ** License version 2.1 as published by the Free Software Foundation and |
12 | ** appearing in the file LICENSE.LGPL included in the packaging of this |
13 | ** file. Please review the following information to ensure the GNU Lesser |
14 | ** General Public License version 2.1 requirements will be met: |
15 | ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
16 | ** |
17 | ** In addition, as a special exception, Nokia gives you certain additional |
18 | ** rights. These rights are described in the Nokia Qt LGPL Exception |
19 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
20 | ** |
21 | ** GNU General Public License Usage |
22 | ** Alternatively, this file may be used under the terms of the GNU General |
23 | ** Public License version 3.0 as published by the Free Software Foundation |
24 | ** and appearing in the file LICENSE.GPL included in the packaging of this |
25 | ** file. Please review the following information to ensure the GNU General |
26 | ** Public License version 3.0 requirements will be met: |
27 | ** http://www.gnu.org/copyleft/gpl.html. |
28 | ** |
29 | ** Other Usage |
30 | ** Alternatively, this file may be used in accordance with the terms and |
31 | ** conditions contained in a signed written agreement between you and Nokia. |
32 | ** |
33 | ** |
34 | ** |
35 | ** |
36 | ** |
37 | ** |
38 | ** $QT_END_LICENSE$ |
39 | ** |
40 | ****************************************************************************/ |
41 | |
42 | #ifndef QGLOBAL_H |
43 | #define QGLOBAL_H |
44 | |
45 | #include <stddef.h> |
46 | |
47 | #define QT_VERSION_STR "4.8.3" |
48 | /* |
49 | QT_VERSION is (major << 16) + (minor << 8) + patch. |
50 | */ |
51 | #define QT_VERSION 0x040803 |
52 | /* |
53 | can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0)) |
54 | */ |
55 | #define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch)) |
56 | |
57 | #define QT_PACKAGEDATE_STR "2012-09-11" |
58 | |
59 | #define QT_PACKAGE_TAG "a07ce9dcc0edd088cf48f44324ff4f82a9abe0c6" |
60 | |
61 | #if !defined(QT_BUILD_MOC) |
62 | #include <QtCore/qconfig.h> |
63 | #endif |
64 | |
65 | #ifdef __cplusplus |
66 | |
67 | #ifndef QT_NO_STL |
68 | #include <algorithm> |
69 | #endif |
70 | |
71 | #ifndef QT_NAMESPACE /* user namespace */ |
72 | |
73 | # define QT_PREPEND_NAMESPACE(name) ::name |
74 | # define QT_USE_NAMESPACE |
75 | # define QT_BEGIN_NAMESPACE |
76 | # define QT_END_NAMESPACE |
77 | # define QT_BEGIN_INCLUDE_NAMESPACE |
78 | # define QT_END_INCLUDE_NAMESPACE |
79 | # define QT_BEGIN_MOC_NAMESPACE |
80 | # define QT_END_MOC_NAMESPACE |
81 | # define QT_FORWARD_DECLARE_CLASS(name) class name; |
82 | # define QT_FORWARD_DECLARE_STRUCT(name) struct name; |
83 | # define QT_MANGLE_NAMESPACE(name) name |
84 | |
85 | #else /* user namespace */ |
86 | |
87 | # define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name |
88 | # define QT_USE_NAMESPACE using namespace ::QT_NAMESPACE; |
89 | # define QT_BEGIN_NAMESPACE namespace QT_NAMESPACE { |
90 | # define QT_END_NAMESPACE } |
91 | # define QT_BEGIN_INCLUDE_NAMESPACE } |
92 | # define QT_END_INCLUDE_NAMESPACE namespace QT_NAMESPACE { |
93 | # define QT_BEGIN_MOC_NAMESPACE QT_USE_NAMESPACE |
94 | # define QT_END_MOC_NAMESPACE |
95 | # define QT_FORWARD_DECLARE_CLASS(name) \ |
96 | QT_BEGIN_NAMESPACE class name; QT_END_NAMESPACE \ |
97 | using QT_PREPEND_NAMESPACE(name); |
98 | |
99 | # define QT_FORWARD_DECLARE_STRUCT(name) \ |
100 | QT_BEGIN_NAMESPACE struct name; QT_END_NAMESPACE \ |
101 | using QT_PREPEND_NAMESPACE(name); |
102 | |
103 | # define QT_MANGLE_NAMESPACE0(x) x |
104 | # define QT_MANGLE_NAMESPACE1(a, b) a##_##b |
105 | # define QT_MANGLE_NAMESPACE2(a, b) QT_MANGLE_NAMESPACE1(a,b) |
106 | # define QT_MANGLE_NAMESPACE(name) QT_MANGLE_NAMESPACE2( \ |
107 | QT_MANGLE_NAMESPACE0(name), QT_MANGLE_NAMESPACE0(QT_NAMESPACE)) |
108 | |
109 | namespace QT_NAMESPACE {} |
110 | |
111 | # ifndef QT_BOOTSTRAPPED |
112 | # ifndef QT_NO_USING_NAMESPACE |
113 | /* |
114 | This expands to a "using QT_NAMESPACE" also in _header files_. |
115 | It is the only way the feature can be used without too much |
116 | pain, but if people _really_ do not want it they can add |
117 | DEFINES += QT_NO_USING_NAMESPACE to their .pro files. |
118 | */ |
119 | QT_USE_NAMESPACE |
120 | # endif |
121 | # endif |
122 | |
123 | #endif /* user namespace */ |
124 | |
125 | #else /* __cplusplus */ |
126 | |
127 | # define QT_BEGIN_NAMESPACE |
128 | # define QT_END_NAMESPACE |
129 | # define QT_USE_NAMESPACE |
130 | # define QT_BEGIN_INCLUDE_NAMESPACE |
131 | # define QT_END_INCLUDE_NAMESPACE |
132 | |
133 | #endif /* __cplusplus */ |
134 | |
135 | #if defined(Q_OS_MAC) && !defined(Q_CC_INTEL) |
136 | #define QT_BEGIN_HEADER extern "C++" { |
137 | #define QT_END_HEADER } |
138 | #define QT_BEGIN_INCLUDE_HEADER } |
139 | #define QT_END_INCLUDE_HEADER extern "C++" { |
140 | #else |
141 | #define QT_BEGIN_HEADER |
142 | #define QT_END_HEADER |
143 | #define QT_BEGIN_INCLUDE_HEADER |
144 | #define QT_END_INCLUDE_HEADER extern "C++" |
145 | #endif |
146 | |
147 | /* |
148 | The operating system, must be one of: (Q_OS_x) |
149 | |
150 | DARWIN - Darwin OS (synonym for Q_OS_MAC) |
151 | SYMBIAN - Symbian |
152 | MSDOS - MS-DOS and Windows |
153 | OS2 - OS/2 |
154 | OS2EMX - XFree86 on OS/2 (not PM) |
155 | WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008) |
156 | WINCE - WinCE (Windows CE 5.0) |
157 | CYGWIN - Cygwin |
158 | SOLARIS - Sun Solaris |
159 | HPUX - HP-UX |
160 | ULTRIX - DEC Ultrix |
161 | LINUX - Linux |
162 | FREEBSD - FreeBSD |
163 | NETBSD - NetBSD |
164 | OPENBSD - OpenBSD |
165 | BSDI - BSD/OS |
166 | IRIX - SGI Irix |
167 | OSF - HP Tru64 UNIX |
168 | SCO - SCO OpenServer 5 |
169 | UNIXWARE - UnixWare 7, Open UNIX 8 |
170 | AIX - AIX |
171 | HURD - GNU Hurd |
172 | DGUX - DG/UX |
173 | RELIANT - Reliant UNIX |
174 | DYNIX - DYNIX/ptx |
175 | QNX - QNX |
176 | LYNX - LynxOS |
177 | BSD4 - Any BSD 4.4 system |
178 | UNIX - Any UNIX BSD/SYSV system |
179 | */ |
180 | |
181 | #if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__)) |
182 | # define Q_OS_DARWIN |
183 | # define Q_OS_BSD4 |
184 | # ifdef __LP64__ |
185 | # define Q_OS_DARWIN64 |
186 | # else |
187 | # define Q_OS_DARWIN32 |
188 | # endif |
189 | #elif defined(__SYMBIAN32__) || defined(SYMBIAN) |
190 | # define Q_OS_SYMBIAN |
191 | # define Q_NO_POSIX_SIGNALS |
192 | # define QT_NO_GETIFADDRS |
193 | #elif defined(__CYGWIN__) |
194 | # define Q_OS_CYGWIN |
195 | #elif defined(MSDOS) || defined(_MSDOS) |
196 | # define Q_OS_MSDOS |
197 | #elif defined(__OS2__) |
198 | # if defined(__EMX__) |
199 | # define Q_OS_OS2EMX |
200 | # else |
201 | # define Q_OS_OS2 |
202 | # endif |
203 | #elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__)) |
204 | # define Q_OS_WIN32 |
205 | # define Q_OS_WIN64 |
206 | #elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__)) |
207 | # if defined(WINCE) || defined(_WIN32_WCE) |
208 | # define Q_OS_WINCE |
209 | # else |
210 | # define Q_OS_WIN32 |
211 | # endif |
212 | #elif defined(__MWERKS__) && defined(__INTEL__) |
213 | # define Q_OS_WIN32 |
214 | #elif defined(__sun) || defined(sun) |
215 | # define Q_OS_SOLARIS |
216 | #elif defined(hpux) || defined(__hpux) |
217 | # define Q_OS_HPUX |
218 | #elif defined(__ultrix) || defined(ultrix) |
219 | # define Q_OS_ULTRIX |
220 | #elif defined(sinix) |
221 | # define Q_OS_RELIANT |
222 | #elif defined(__native_client__) |
223 | # define Q_OS_NACL |
224 | #elif defined(__linux__) || defined(__linux) |
225 | # define Q_OS_LINUX |
226 | #elif defined(__FreeBSD__) || defined(__DragonFly__) |
227 | # define Q_OS_FREEBSD |
228 | # define Q_OS_BSD4 |
229 | #elif defined(__NetBSD__) |
230 | # define Q_OS_NETBSD |
231 | # define Q_OS_BSD4 |
232 | #elif defined(__OpenBSD__) |
233 | # define Q_OS_OPENBSD |
234 | # define Q_OS_BSD4 |
235 | #elif defined(__bsdi__) |
236 | # define Q_OS_BSDI |
237 | # define Q_OS_BSD4 |
238 | #elif defined(__sgi) |
239 | # define Q_OS_IRIX |
240 | #elif defined(__osf__) |
241 | # define Q_OS_OSF |
242 | #elif defined(_AIX) |
243 | # define Q_OS_AIX |
244 | #elif defined(__Lynx__) |
245 | # define Q_OS_LYNX |
246 | #elif defined(__GNU__) |
247 | # define Q_OS_HURD |
248 | #elif defined(__DGUX__) |
249 | # define Q_OS_DGUX |
250 | #elif defined(__QNXNTO__) |
251 | # define Q_OS_QNX |
252 | #elif defined(_SEQUENT_) |
253 | # define Q_OS_DYNIX |
254 | #elif defined(_SCO_DS) /* SCO OpenServer 5 + GCC */ |
255 | # define Q_OS_SCO |
256 | #elif defined(__USLC__) /* all SCO platforms + UDK or OUDK */ |
257 | # define Q_OS_UNIXWARE |
258 | #elif defined(__svr4__) && defined(i386) /* Open UNIX 8 + GCC */ |
259 | # define Q_OS_UNIXWARE |
260 | #elif defined(__INTEGRITY) |
261 | # define Q_OS_INTEGRITY |
262 | #elif defined(VXWORKS) /* there is no "real" VxWorks define - this has to be set in the mkspec! */ |
263 | # define Q_OS_VXWORKS |
264 | #elif defined(__MAKEDEPEND__) |
265 | #else |
266 | # error "Qt has not been ported to this OS - talk to qt-bugs@trolltech.com" |
267 | #endif |
268 | |
269 | #if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE) |
270 | # define Q_OS_WIN |
271 | #endif |
272 | |
273 | #if defined(Q_OS_DARWIN) |
274 | # define Q_OS_MAC /* Q_OS_MAC is mostly for compatibility, but also more clear */ |
275 | # define Q_OS_MACX /* Q_OS_MACX is only for compatibility.*/ |
276 | # if defined(Q_OS_DARWIN64) |
277 | # define Q_OS_MAC64 |
278 | # elif defined(Q_OS_DARWIN32) |
279 | # define Q_OS_MAC32 |
280 | # endif |
281 | #endif |
282 | |
283 | #ifdef QT_AUTODETECT_COCOA |
284 | # ifdef Q_OS_MAC64 |
285 | # define QT_MAC_USE_COCOA 1 |
286 | # define QT_BUILD_KEY QT_BUILD_KEY_COCOA |
287 | # else |
288 | # define QT_BUILD_KEY QT_BUILD_KEY_CARBON |
289 | # endif |
290 | #endif |
291 | |
292 | #if defined(Q_WS_MAC64) && !defined(QT_MAC_USE_COCOA) && !defined(QT_BUILD_QMAKE) && !defined(QT_BOOTSTRAPPED) |
293 | #error "You are building a 64-bit application, but using a 32-bit version of Qt. Check your build configuration." |
294 | #endif |
295 | |
296 | #if defined(Q_OS_MSDOS) || defined(Q_OS_OS2) || defined(Q_OS_WIN) |
297 | # undef Q_OS_UNIX |
298 | #elif !defined(Q_OS_UNIX) |
299 | # define Q_OS_UNIX |
300 | #endif |
301 | |
302 | #if defined(Q_OS_DARWIN) && !defined(QT_LARGEFILE_SUPPORT) |
303 | # define QT_LARGEFILE_SUPPORT 64 |
304 | #endif |
305 | |
306 | #ifdef Q_OS_DARWIN |
307 | # ifdef MAC_OS_X_VERSION_MIN_REQUIRED |
308 | # undef MAC_OS_X_VERSION_MIN_REQUIRED |
309 | # endif |
310 | # define MAC_OS_X_VERSION_MIN_REQUIRED MAC_OS_X_VERSION_10_4 |
311 | # include <AvailabilityMacros.h> |
312 | # if !defined(MAC_OS_X_VERSION_10_3) |
313 | # define MAC_OS_X_VERSION_10_3 MAC_OS_X_VERSION_10_2 + 1 |
314 | # endif |
315 | # if !defined(MAC_OS_X_VERSION_10_4) |
316 | # define MAC_OS_X_VERSION_10_4 MAC_OS_X_VERSION_10_3 + 1 |
317 | # endif |
318 | # if !defined(MAC_OS_X_VERSION_10_5) |
319 | # define MAC_OS_X_VERSION_10_5 MAC_OS_X_VERSION_10_4 + 1 |
320 | # endif |
321 | # if !defined(MAC_OS_X_VERSION_10_6) |
322 | # define MAC_OS_X_VERSION_10_6 MAC_OS_X_VERSION_10_5 + 1 |
323 | # endif |
324 | # if !defined(MAC_OS_X_VERSION_10_7) |
325 | # define MAC_OS_X_VERSION_10_7 MAC_OS_X_VERSION_10_6 + 1 |
326 | # endif |
327 | # if !defined(MAC_OS_X_VERSION_10_8) |
328 | # define MAC_OS_X_VERSION_10_8 MAC_OS_X_VERSION_10_7 + 1 |
329 | # endif |
330 | # if (MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_8) |
331 | # warning "This version of Mac OS X is unsupported" |
332 | # endif |
333 | #endif |
334 | |
335 | #ifdef __LSB_VERSION__ |
336 | # if __LSB_VERSION__ < 40 |
337 | # error "This version of the Linux Standard Base is unsupported" |
338 | # endif |
339 | #ifndef QT_LINUXBASE |
340 | # define QT_LINUXBASE |
341 | #endif |
342 | #endif |
343 | |
344 | /* |
345 | The compiler, must be one of: (Q_CC_x) |
346 | |
347 | SYM - Digital Mars C/C++ (used to be Symantec C++) |
348 | MWERKS - Metrowerks CodeWarrior |
349 | MSVC - Microsoft Visual C/C++, Intel C++ for Windows |
350 | BOR - Borland/Turbo C++ |
351 | WAT - Watcom C++ |
352 | GNU - GNU C++ |
353 | COMEAU - Comeau C++ |
354 | EDG - Edison Design Group C++ |
355 | OC - CenterLine C++ |
356 | SUN - Forte Developer, or Sun Studio C++ |
357 | MIPS - MIPSpro C++ |
358 | DEC - DEC C++ |
359 | HPACC - HP aC++ |
360 | USLC - SCO OUDK and UDK |
361 | CDS - Reliant C++ |
362 | KAI - KAI C++ |
363 | INTEL - Intel C++ for Linux, Intel C++ for Windows |
364 | HIGHC - MetaWare High C/C++ |
365 | PGI - Portland Group C++ |
366 | GHS - Green Hills Optimizing C++ Compilers |
367 | GCCE - GCCE (Symbian GCCE builds) |
368 | RVCT - ARM Realview Compiler Suite |
369 | NOKIAX86 - Nokia x86 (Symbian WINSCW builds) |
370 | CLANG - C++ front-end for the LLVM compiler |
371 | |
372 | |
373 | Should be sorted most to least authoritative. |
374 | */ |
375 | |
376 | #if defined(__ghs) |
377 | # define Q_OUTOFLINE_TEMPLATE inline |
378 | |
379 | /* the following are necessary because the GHS C++ name mangling relies on __*/ |
380 | # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \ |
381 | static const int AFUNC ## _init_variable_ = AFUNC(); |
382 | # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC) |
383 | # define Q_DESTRUCTOR_FUNCTION0(AFUNC) \ |
384 | class AFUNC ## _dest_class_ { \ |
385 | public: \ |
386 | inline AFUNC ## _dest_class_() { } \ |
387 | inline ~ AFUNC ## _dest_class_() { AFUNC(); } \ |
388 | } AFUNC ## _dest_instance_; |
389 | # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) |
390 | |
391 | #endif |
392 | |
393 | /* Symantec C++ is now Digital Mars */ |
394 | #if defined(__DMC__) || defined(__SC__) |
395 | # define Q_CC_SYM |
396 | /* "explicit" semantics implemented in 8.1e but keyword recognized since 7.5 */ |
397 | # if defined(__SC__) && __SC__ < 0x750 |
398 | # define Q_NO_EXPLICIT_KEYWORD |
399 | # endif |
400 | # define Q_NO_USING_KEYWORD |
401 | |
402 | #elif defined(__MWERKS__) |
403 | # define Q_CC_MWERKS |
404 | # if defined(__EMU_SYMBIAN_OS__) |
405 | # define Q_CC_NOKIAX86 |
406 | # endif |
407 | /* "explicit" recognized since 4.0d1 */ |
408 | |
409 | #elif defined(_MSC_VER) |
410 | # define Q_CC_MSVC |
411 | # define Q_CC_MSVC_NET |
412 | # define Q_CANNOT_DELETE_CONSTANT |
413 | # define Q_OUTOFLINE_TEMPLATE inline |
414 | # define Q_NO_TEMPLATE_FRIENDS |
415 | # define Q_ALIGNOF(type) __alignof(type) |
416 | # define Q_DECL_ALIGN(n) __declspec(align(n)) |
417 | /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ |
418 | # if defined(__INTEL_COMPILER) |
419 | # define Q_CC_INTEL |
420 | # endif |
421 | /* MSVC does not support SSE/MMX on x64 */ |
422 | # if (defined(Q_CC_MSVC) && defined(_M_X64)) |
423 | # undef QT_HAVE_SSE |
424 | # undef QT_HAVE_MMX |
425 | # undef QT_HAVE_3DNOW |
426 | # endif |
427 | |
428 | #if defined(Q_CC_MSVC) && _MSC_VER >= 1600 |
429 | # define Q_COMPILER_RVALUE_REFS |
430 | # define Q_COMPILER_AUTO_TYPE |
431 | # define Q_COMPILER_LAMBDA |
432 | # define Q_COMPILER_DECLTYPE |
433 | // MSCV has std::initilizer_list, but do not support the braces initialization |
434 | //# define Q_COMPILER_INITIALIZER_LISTS |
435 | # endif |
436 | |
437 | |
438 | #elif defined(__BORLANDC__) || defined(__TURBOC__) |
439 | # define Q_CC_BOR |
440 | # define Q_INLINE_TEMPLATE |
441 | # if __BORLANDC__ < 0x502 |
442 | # define Q_NO_BOOL_TYPE |
443 | # define Q_NO_EXPLICIT_KEYWORD |
444 | # endif |
445 | # define Q_NO_USING_KEYWORD |
446 | |
447 | #elif defined(__WATCOMC__) |
448 | # define Q_CC_WAT |
449 | |
450 | /* Symbian GCCE */ |
451 | #elif defined(__GCCE__) |
452 | # define Q_CC_GCCE |
453 | # define QT_VISIBILITY_AVAILABLE |
454 | # if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) |
455 | # define QT_HAVE_ARMV6 |
456 | # endif |
457 | |
458 | /* ARM Realview Compiler Suite |
459 | RVCT compiler also defines __EDG__ and __GNUC__ (if --gnu flag is given), |
460 | so check for it before that */ |
461 | #elif defined(__ARMCC__) || defined(__CC_ARM) |
462 | # define Q_CC_RVCT |
463 | # if __TARGET_ARCH_ARM >= 6 |
464 | # define QT_HAVE_ARMV6 |
465 | # endif |
466 | /* work-around for missing compiler intrinsics */ |
467 | # define __is_empty(X) false |
468 | # define __is_pod(X) false |
469 | #elif defined(__GNUC__) |
470 | # define Q_CC_GNU |
471 | # define Q_C_CALLBACKS |
472 | # if defined(__MINGW32__) |
473 | # define Q_CC_MINGW |
474 | # endif |
475 | # if defined(__INTEL_COMPILER) |
476 | /* Intel C++ also masquerades as GCC 3.2.0 */ |
477 | # define Q_CC_INTEL |
478 | # endif |
479 | # if defined(__clang__) |
480 | /* Clang also masquerades as GCC 4.2.1 */ |
481 | # define Q_CC_CLANG |
482 | # endif |
483 | # ifdef __APPLE__ |
484 | # define Q_NO_DEPRECATED_CONSTRUCTORS |
485 | # endif |
486 | # if __GNUC__ == 2 && __GNUC_MINOR__ <= 7 |
487 | # define Q_FULL_TEMPLATE_INSTANTIATION |
488 | # endif |
489 | /* GCC 2.95 knows "using" but does not support it correctly */ |
490 | # if __GNUC__ == 2 && __GNUC_MINOR__ <= 95 |
491 | # define Q_NO_USING_KEYWORD |
492 | # define QT_NO_STL_WCHAR |
493 | # endif |
494 | # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95) |
495 | # define Q_ALIGNOF(type) __alignof__(type) |
496 | # define Q_TYPEOF(expr) __typeof__(expr) |
497 | # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) |
498 | # endif |
499 | # if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) |
500 | # define Q_LIKELY(expr) __builtin_expect(!!(expr), true) |
501 | # define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false) |
502 | # endif |
503 | /* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */ |
504 | # if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1 |
505 | # define Q_WRONG_SB_CTYPE_MACROS |
506 | # endif |
507 | /* GCC <= 3.3 cannot handle template friends */ |
508 | # if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ <= 3) |
509 | # define Q_NO_TEMPLATE_FRIENDS |
510 | # endif |
511 | /* Apple's GCC 3.1 chokes on our streaming qDebug() */ |
512 | # if defined(Q_OS_DARWIN) && __GNUC__ == 3 && (__GNUC_MINOR__ >= 1 && __GNUC_MINOR__ < 3) |
513 | # define Q_BROKEN_DEBUG_STREAM |
514 | # endif |
515 | # if (defined(Q_CC_GNU) || defined(Q_CC_INTEL)) && !defined(QT_MOC_CPP) |
516 | # define Q_PACKED __attribute__ ((__packed__)) |
517 | # define Q_NO_PACKED_REFERENCE |
518 | # ifndef __ARM_EABI__ |
519 | # define QT_NO_ARM_EABI |
520 | # endif |
521 | # endif |
522 | # if defined(__GXX_EXPERIMENTAL_CXX0X__) |
523 | # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 |
524 | /* C++0x features supported in GCC 4.3: */ |
525 | # define Q_COMPILER_RVALUE_REFS |
526 | # define Q_COMPILER_DECLTYPE |
527 | # endif |
528 | # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 |
529 | /* C++0x features supported in GCC 4.4: */ |
530 | # define Q_COMPILER_VARIADIC_TEMPLATES |
531 | # define Q_COMPILER_AUTO_TYPE |
532 | # define Q_COMPILER_EXTERN_TEMPLATES |
533 | # define Q_COMPILER_DEFAULT_DELETE_MEMBERS |
534 | # define Q_COMPILER_CLASS_ENUM |
535 | # define Q_COMPILER_INITIALIZER_LISTS |
536 | # endif |
537 | # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 |
538 | /* C++0x features supported in GCC 4.5: */ |
539 | # define Q_COMPILER_LAMBDA |
540 | # define Q_COMPILER_UNICODE_STRINGS |
541 | # endif |
542 | # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 |
543 | /* C++0x features supported in GCC 4.6: */ |
544 | # define Q_COMPILER_CONSTEXPR |
545 | # endif |
546 | |
547 | # endif |
548 | |
549 | /* IBM compiler versions are a bit messy. There are actually two products: |
550 | the C product, and the C++ product. The C++ compiler is always packaged |
551 | with the latest version of the C compiler. Version numbers do not always |
552 | match. This little table (I'm not sure it's accurate) should be helpful: |
553 | |
554 | C++ product C product |
555 | |
556 | C Set 3.1 C Compiler 3.0 |
557 | ... ... |
558 | C++ Compiler 3.6.6 C Compiler 4.3 |
559 | ... ... |
560 | Visual Age C++ 4.0 ... |
561 | ... ... |
562 | Visual Age C++ 5.0 C Compiler 5.0 |
563 | ... ... |
564 | Visual Age C++ 6.0 C Compiler 6.0 |
565 | |
566 | Now: |
567 | __xlC__ is the version of the C compiler in hexadecimal notation |
568 | is only an approximation of the C++ compiler version |
569 | __IBMCPP__ is the version of the C++ compiler in decimal notation |
570 | but it is not defined on older compilers like C Set 3.1 */ |
571 | #elif defined(__xlC__) |
572 | # define Q_CC_XLC |
573 | # define Q_FULL_TEMPLATE_INSTANTIATION |
574 | # if __xlC__ < 0x400 |
575 | # define Q_NO_BOOL_TYPE |
576 | # define Q_NO_EXPLICIT_KEYWORD |
577 | # define Q_NO_USING_KEYWORD |
578 | # define Q_TYPENAME |
579 | # define Q_OUTOFLINE_TEMPLATE inline |
580 | # define Q_BROKEN_TEMPLATE_SPECIALIZATION |
581 | # define Q_CANNOT_DELETE_CONSTANT |
582 | # elif __xlC__ >= 0x0600 |
583 | # define Q_ALIGNOF(type) __alignof__(type) |
584 | # define Q_TYPEOF(expr) __typeof__(expr) |
585 | # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) |
586 | # define Q_PACKED __attribute__((__packed__)) |
587 | # endif |
588 | |
589 | /* Older versions of DEC C++ do not define __EDG__ or __EDG - observed |
590 | on DEC C++ V5.5-004. New versions do define __EDG__ - observed on |
591 | Compaq C++ V6.3-002. |
592 | This compiler is different enough from other EDG compilers to handle |
593 | it separately anyway. */ |
594 | #elif defined(__DECCXX) || defined(__DECC) |
595 | # define Q_CC_DEC |
596 | /* Compaq C++ V6 compilers are EDG-based but I'm not sure about older |
597 | DEC C++ V5 compilers. */ |
598 | # if defined(__EDG__) |
599 | # define Q_CC_EDG |
600 | # endif |
601 | /* Compaq have disabled EDG's _BOOL macro and use _BOOL_EXISTS instead |
602 | - observed on Compaq C++ V6.3-002. |
603 | In any case versions prior to Compaq C++ V6.0-005 do not have bool. */ |
604 | # if !defined(_BOOL_EXISTS) |
605 | # define Q_NO_BOOL_TYPE |
606 | # endif |
607 | /* Spurious (?) error messages observed on Compaq C++ V6.5-014. */ |
608 | # define Q_NO_USING_KEYWORD |
609 | /* Apply to all versions prior to Compaq C++ V6.0-000 - observed on |
610 | DEC C++ V5.5-004. */ |
611 | # if __DECCXX_VER < 60060000 |
612 | # define Q_TYPENAME |
613 | # define Q_BROKEN_TEMPLATE_SPECIALIZATION |
614 | # define Q_CANNOT_DELETE_CONSTANT |
615 | # endif |
616 | /* avoid undefined symbol problems with out-of-line template members */ |
617 | # define Q_OUTOFLINE_TEMPLATE inline |
618 | |
619 | /* The Portland Group C++ compiler is based on EDG and does define __EDG__ |
620 | but the C compiler does not */ |
621 | #elif defined(__PGI) |
622 | # define Q_CC_PGI |
623 | # if defined(__EDG__) |
624 | # define Q_CC_EDG |
625 | # endif |
626 | |
627 | /* Compilers with EDG front end are similar. To detect them we test: |
628 | __EDG documented by SGI, observed on MIPSpro 7.3.1.1 and KAI C++ 4.0b |
629 | __EDG__ documented in EDG online docs, observed on Compaq C++ V6.3-002 |
630 | and PGI C++ 5.2-4 */ |
631 | #elif !defined(Q_OS_HPUX) && (defined(__EDG) || defined(__EDG__)) |
632 | # define Q_CC_EDG |
633 | /* From the EDG documentation (does not seem to apply to Compaq C++): |
634 | _BOOL |
635 | Defined in C++ mode when bool is a keyword. The name of this |
636 | predefined macro is specified by a configuration flag. _BOOL |
637 | is the default. |
638 | __BOOL_DEFINED |
639 | Defined in Microsoft C++ mode when bool is a keyword. */ |
640 | # if !defined(_BOOL) && !defined(__BOOL_DEFINED) |
641 | # define Q_NO_BOOL_TYPE |
642 | # endif |
643 | |
644 | /* The Comeau compiler is based on EDG and does define __EDG__ */ |
645 | # if defined(__COMO__) |
646 | # define Q_CC_COMEAU |
647 | # define Q_C_CALLBACKS |
648 | |
649 | /* The `using' keyword was introduced to avoid KAI C++ warnings |
650 | but it's now causing KAI C++ errors instead. The standard is |
651 | unclear about the use of this keyword, and in practice every |
652 | compiler is using its own set of rules. Forget it. */ |
653 | # elif defined(__KCC) |
654 | # define Q_CC_KAI |
655 | # define Q_NO_USING_KEYWORD |
656 | |
657 | /* Using the `using' keyword avoids Intel C++ for Linux warnings */ |
658 | # elif defined(__INTEL_COMPILER) |
659 | # define Q_CC_INTEL |
660 | |
661 | /* Uses CFront, make sure to read the manual how to tweak templates. */ |
662 | # elif defined(__ghs) |
663 | # define Q_CC_GHS |
664 | |
665 | # elif defined(__DCC__) |
666 | # define Q_CC_DIAB |
667 | # undef Q_NO_BOOL_TYPE |
668 | # if !defined(__bool) |
669 | # define Q_NO_BOOL_TYPE |
670 | # endif |
671 | |
672 | /* The UnixWare 7 UDK compiler is based on EDG and does define __EDG__ */ |
673 | # elif defined(__USLC__) && defined(__SCO_VERSION__) |
674 | # define Q_CC_USLC |
675 | /* The latest UDK 7.1.1b does not need this, but previous versions do */ |
676 | # if !defined(__SCO_VERSION__) || (__SCO_VERSION__ < 302200010) |
677 | # define Q_OUTOFLINE_TEMPLATE inline |
678 | # endif |
679 | # define Q_NO_USING_KEYWORD /* ### check "using" status */ |
680 | |
681 | /* Never tested! */ |
682 | # elif defined(CENTERLINE_CLPP) || defined(OBJECTCENTER) |
683 | # define Q_CC_OC |
684 | # define Q_NO_USING_KEYWORD |
685 | |
686 | /* CDS++ defines __EDG__ although this is not documented in the Reliant |
687 | documentation. It also follows conventions like _BOOL and this documented */ |
688 | # elif defined(sinix) |
689 | # define Q_CC_CDS |
690 | # define Q_NO_USING_KEYWORD |
691 | |
692 | /* The MIPSpro compiler defines __EDG */ |
693 | # elif defined(__sgi) |
694 | # define Q_CC_MIPS |
695 | # define Q_NO_USING_KEYWORD /* ### check "using" status */ |
696 | # define Q_NO_TEMPLATE_FRIENDS |
697 | # if defined(_COMPILER_VERSION) && (_COMPILER_VERSION >= 740) |
698 | # define Q_OUTOFLINE_TEMPLATE inline |
699 | # pragma set woff 3624,3625,3649 /* turn off some harmless warnings */ |
700 | # endif |
701 | # endif |
702 | |
703 | /* VxWorks' DIAB toolchain has an additional EDG type C++ compiler |
704 | (see __DCC__ above). This one is for C mode files (__EDG is not defined) */ |
705 | #elif defined(_DIAB_TOOL) |
706 | # define Q_CC_DIAB |
707 | |
708 | /* Never tested! */ |
709 | #elif defined(__HIGHC__) |
710 | # define Q_CC_HIGHC |
711 | |
712 | #elif defined(__SUNPRO_CC) || defined(__SUNPRO_C) |
713 | # define Q_CC_SUN |
714 | /* 5.0 compiler or better |
715 | 'bool' is enabled by default but can be disabled using -features=nobool |
716 | in which case _BOOL is not defined |
717 | this is the default in 4.2 compatibility mode triggered by -compat=4 */ |
718 | # if __SUNPRO_CC >= 0x500 |
719 | # define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS |
720 | /* see http://developers.sun.com/sunstudio/support/Ccompare.html */ |
721 | # if __SUNPRO_CC >= 0x590 |
722 | # define Q_ALIGNOF(type) __alignof__(type) |
723 | # define Q_TYPEOF(expr) __typeof__(expr) |
724 | # define Q_DECL_ALIGN(n) __attribute__((__aligned__(n))) |
725 | # endif |
726 | # if __SUNPRO_CC >= 0x550 |
727 | # define Q_DECL_EXPORT __global |
728 | # endif |
729 | # if __SUNPRO_CC < 0x5a0 |
730 | # define Q_NO_TEMPLATE_FRIENDS |
731 | # endif |
732 | # if !defined(_BOOL) |
733 | # define Q_NO_BOOL_TYPE |
734 | # endif |
735 | # if defined(__SUNPRO_CC_COMPAT) && (__SUNPRO_CC_COMPAT <= 4) |
736 | # define Q_NO_USING_KEYWORD |
737 | # endif |
738 | # define Q_C_CALLBACKS |
739 | /* 4.2 compiler or older */ |
740 | # else |
741 | # define Q_NO_BOOL_TYPE |
742 | # define Q_NO_EXPLICIT_KEYWORD |
743 | # define Q_NO_USING_KEYWORD |
744 | # endif |
745 | |
746 | /* CDS++ does not seem to define __EDG__ or __EDG according to Reliant |
747 | documentation but nevertheless uses EDG conventions like _BOOL */ |
748 | #elif defined(sinix) |
749 | # define Q_CC_EDG |
750 | # define Q_CC_CDS |
751 | # if !defined(_BOOL) |
752 | # define Q_NO_BOOL_TYPE |
753 | # endif |
754 | # define Q_BROKEN_TEMPLATE_SPECIALIZATION |
755 | |
756 | #elif defined(Q_OS_HPUX) |
757 | /* __HP_aCC was not defined in first aCC releases */ |
758 | # if defined(__HP_aCC) || __cplusplus >= 199707L |
759 | # define Q_NO_TEMPLATE_FRIENDS |
760 | # define Q_CC_HPACC |
761 | # if __HP_aCC-0 < 060000 |
762 | # define QT_NO_TEMPLATE_TEMPLATE_PARAMETERS |
763 | # define Q_DECL_EXPORT __declspec(dllexport) |
764 | # define Q_DECL_IMPORT __declspec(dllimport) |
765 | # endif |
766 | # if __HP_aCC-0 >= 061200 |
767 | # define Q_DECL_ALIGN(n) __attribute__((aligned(n))) |
768 | # endif |
769 | # if __HP_aCC-0 >= 062000 |
770 | # define Q_DECL_EXPORT __attribute__((visibility("default"))) |
771 | # define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) |
772 | # define Q_DECL_IMPORT Q_DECL_EXPORT |
773 | # endif |
774 | # else |
775 | # define Q_CC_HP |
776 | # define Q_NO_BOOL_TYPE |
777 | # define Q_FULL_TEMPLATE_INSTANTIATION |
778 | # define Q_BROKEN_TEMPLATE_SPECIALIZATION |
779 | # define Q_NO_EXPLICIT_KEYWORD |
780 | # endif |
781 | # define Q_NO_USING_KEYWORD /* ### check "using" status */ |
782 | |
783 | #elif defined(__WINSCW__) && !defined(Q_CC_NOKIAX86) |
784 | # define Q_CC_NOKIAX86 |
785 | |
786 | #else |
787 | # error "Qt has not been tested with this compiler - talk to qt-bugs@trolltech.com" |
788 | #endif |
789 | |
790 | |
791 | #ifdef Q_CC_INTEL |
792 | # if __INTEL_COMPILER < 1200 |
793 | # define Q_NO_TEMPLATE_FRIENDS |
794 | # endif |
795 | # if defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__) |
796 | # if __INTEL_COMPILER >= 1100 |
797 | # define Q_COMPILER_RVALUE_REFS |
798 | # define Q_COMPILER_EXTERN_TEMPLATES |
799 | # define Q_COMPILER_DECLTYPE |
800 | # elif __INTEL_COMPILER >= 1200 |
801 | # define Q_COMPILER_VARIADIC_TEMPLATES |
802 | # define Q_COMPILER_AUTO_TYPE |
803 | # define Q_COMPILER_DEFAULT_DELETE_MEMBERS |
804 | # define Q_COMPILER_CLASS_ENUM |
805 | # define Q_COMPILER_LAMBDA |
806 | # endif |
807 | # endif |
808 | #endif |
809 | |
810 | #ifndef Q_PACKED |
811 | # define Q_PACKED |
812 | # undef Q_NO_PACKED_REFERENCE |
813 | #endif |
814 | |
815 | #ifndef Q_LIKELY |
816 | # define Q_LIKELY(x) (x) |
817 | #endif |
818 | #ifndef Q_UNLIKELY |
819 | # define Q_UNLIKELY(x) (x) |
820 | #endif |
821 | |
822 | #ifndef Q_CONSTRUCTOR_FUNCTION |
823 | # define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \ |
824 | static const int AFUNC ## __init_variable__ = AFUNC(); |
825 | # define Q_CONSTRUCTOR_FUNCTION(AFUNC) Q_CONSTRUCTOR_FUNCTION0(AFUNC) |
826 | #endif |
827 | |
828 | #ifndef Q_DESTRUCTOR_FUNCTION |
829 | # define Q_DESTRUCTOR_FUNCTION0(AFUNC) \ |
830 | class AFUNC ## __dest_class__ { \ |
831 | public: \ |
832 | inline AFUNC ## __dest_class__() { } \ |
833 | inline ~ AFUNC ## __dest_class__() { AFUNC(); } \ |
834 | } AFUNC ## __dest_instance__; |
835 | # define Q_DESTRUCTOR_FUNCTION(AFUNC) Q_DESTRUCTOR_FUNCTION0(AFUNC) |
836 | #endif |
837 | |
838 | #ifndef Q_REQUIRED_RESULT |
839 | # if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) |
840 | # define Q_REQUIRED_RESULT __attribute__ ((warn_unused_result)) |
841 | # else |
842 | # define Q_REQUIRED_RESULT |
843 | # endif |
844 | #endif |
845 | |
846 | #ifndef Q_COMPILER_MANGLES_RETURN_TYPE |
847 | # if defined(Q_CC_MSVC) |
848 | # define Q_COMPILER_MANGLES_RETURN_TYPE |
849 | # endif |
850 | #endif |
851 | |
852 | #ifdef __cplusplus |
853 | # if defined(Q_OS_QNX) || defined(Q_OS_BLACKBERRY) |
854 | # include <utility> |
855 | # if defined(_YVALS) || defined(_LIBCPP_VER) |
856 | // QNX: libcpp (Dinkumware-based) doesn't have the <initializer_list> |
857 | // header, so the feature is useless, even if the compiler supports |
858 | // it. Disable. |
859 | # ifdef Q_COMPILER_INITIALIZER_LISTS |
860 | # undef Q_COMPILER_INITIALIZER_LISTS |
861 | # endif |
862 | # endif |
863 | # endif |
864 | #endif |
865 | |
866 | /* |
867 | The window system, must be one of: (Q_WS_x) |
868 | |
869 | MACX - Mac OS X |
870 | MAC9 - Mac OS 9 |
871 | QWS - Qt for Embedded Linux |
872 | WIN32 - Windows |
873 | X11 - X Window System |
874 | S60 - Symbian S60 |
875 | PM - unsupported |
876 | WIN16 - unsupported |
877 | */ |
878 | |
879 | #if defined(Q_OS_MSDOS) |
880 | # define Q_WS_WIN16 |
881 | # error "Qt requires Win32 and does not work with Windows 3.x" |
882 | #elif defined(_WIN32_X11_) |
883 | # define Q_WS_X11 |
884 | #elif defined(Q_OS_WIN32) |
885 | # define Q_WS_WIN32 |
886 | # if defined(Q_OS_WIN64) |
887 | # define Q_WS_WIN64 |
888 | # endif |
889 | #elif defined(Q_OS_WINCE) |
890 | # define Q_WS_WIN32 |
891 | # define Q_WS_WINCE |
892 | # if defined(Q_OS_WINCE_WM) |
893 | # define Q_WS_WINCE_WM |
894 | # endif |
895 | #elif defined(Q_OS_OS2) |
896 | # define Q_WS_PM |
897 | # error "Qt does not work with OS/2 Presentation Manager or Workplace Shell" |
898 | #elif defined(Q_OS_UNIX) |
899 | # if defined(Q_OS_MAC) && !defined(__USE_WS_X11__) && !defined(Q_WS_QWS) && !defined(Q_WS_QPA) |
900 | # define Q_WS_MAC |
901 | # define Q_WS_MACX |
902 | # if defined(Q_OS_MAC64) |
903 | # define Q_WS_MAC64 |
904 | # elif defined(Q_OS_MAC32) |
905 | # define Q_WS_MAC32 |
906 | # endif |
907 | # elif defined(Q_OS_SYMBIAN) |
908 | # if !defined(QT_NO_S60) |
909 | # define Q_WS_S60 |
910 | # endif |
911 | # elif !defined(Q_WS_QWS) && !defined(Q_WS_QPA) |
912 | # define Q_WS_X11 |
913 | # endif |
914 | #endif |
915 | |
916 | #if defined(Q_WS_WIN16) || defined(Q_WS_WIN32) || defined(Q_WS_WINCE) |
917 | # define Q_WS_WIN |
918 | #endif |
919 | |
920 | QT_BEGIN_HEADER |
921 | QT_BEGIN_NAMESPACE |
922 | |
923 | /* |
924 | Size-dependent types (architechture-dependent byte order) |
925 | |
926 | Make sure to update QMetaType when changing these typedefs |
927 | */ |
928 | |
929 | typedef signed char qint8; /* 8 bit signed */ |
930 | typedef unsigned char quint8; /* 8 bit unsigned */ |
931 | typedef short qint16; /* 16 bit signed */ |
932 | typedef unsigned short quint16; /* 16 bit unsigned */ |
933 | typedef int qint32; /* 32 bit signed */ |
934 | typedef unsigned int quint32; /* 32 bit unsigned */ |
935 | #if defined(Q_OS_WIN) && !defined(Q_CC_GNU) && !defined(Q_CC_MWERKS) |
936 | # define Q_INT64_C(c) c ## i64 /* signed 64 bit constant */ |
937 | # define Q_UINT64_C(c) c ## ui64 /* unsigned 64 bit constant */ |
938 | typedef __int64 qint64; /* 64 bit signed */ |
939 | typedef unsigned __int64 quint64; /* 64 bit unsigned */ |
940 | #else |
941 | # define Q_INT64_C(c) static_cast<long long>(c ## LL) /* signed 64 bit constant */ |
942 | # define Q_UINT64_C(c) static_cast<unsigned long long>(c ## ULL) /* unsigned 64 bit constant */ |
943 | typedef long long qint64; /* 64 bit signed */ |
944 | typedef unsigned long long quint64; /* 64 bit unsigned */ |
945 | #endif |
946 | |
947 | typedef qint64 qlonglong; |
948 | typedef quint64 qulonglong; |
949 | |
950 | #ifndef QT_POINTER_SIZE |
951 | # if defined(Q_OS_WIN64) |
952 | # define QT_POINTER_SIZE 8 |
953 | # elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN) |
954 | # define QT_POINTER_SIZE 4 |
955 | # endif |
956 | #endif |
957 | |
958 | #define Q_INIT_RESOURCE_EXTERN(name) \ |
959 | extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); |
960 | |
961 | #define Q_INIT_RESOURCE(name) \ |
962 | do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \ |
963 | QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0) |
964 | #define Q_CLEANUP_RESOURCE(name) \ |
965 | do { extern int QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); \ |
966 | QT_MANGLE_NAMESPACE(qCleanupResources_ ## name) (); } while (0) |
967 | |
968 | #if defined(__cplusplus) |
969 | |
970 | /* |
971 | quintptr and qptrdiff is guaranteed to be the same size as a pointer, i.e. |
972 | |
973 | sizeof(void *) == sizeof(quintptr) |
974 | && sizeof(void *) == sizeof(qptrdiff) |
975 | */ |
976 | template <int> struct QIntegerForSize; |
977 | template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; }; |
978 | template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; }; |
979 | template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; }; |
980 | template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; }; |
981 | template <class T> struct QIntegerForSizeof: QIntegerForSize<sizeof(T)> { }; |
982 | typedef QIntegerForSizeof<void*>::Unsigned quintptr; |
983 | typedef QIntegerForSizeof<void*>::Signed qptrdiff; |
984 | |
985 | /* |
986 | Useful type definitions for Qt |
987 | */ |
988 | |
989 | QT_BEGIN_INCLUDE_NAMESPACE |
990 | typedef unsigned char uchar; |
991 | typedef unsigned short ushort; |
992 | typedef unsigned int uint; |
993 | typedef unsigned long ulong; |
994 | QT_END_INCLUDE_NAMESPACE |
995 | |
996 | #if defined(Q_NO_BOOL_TYPE) |
997 | #error "Compiler doesn't support the bool type" |
998 | #endif |
999 | |
1000 | /* |
1001 | Constant bool values |
1002 | */ |
1003 | |
1004 | #ifndef QT_LINUXBASE /* the LSB defines TRUE and FALSE for us */ |
1005 | /* Symbian OS defines TRUE = 1 and FALSE = 0, |
1006 | redefine to built-in booleans to make autotests work properly */ |
1007 | #ifdef Q_OS_SYMBIAN |
1008 | #include <e32def.h> /* Symbian OS defines */ |
1009 | |
1010 | #undef TRUE |
1011 | #undef FALSE |
1012 | #endif |
1013 | # ifndef TRUE |
1014 | # define TRUE true |
1015 | # define FALSE false |
1016 | # endif |
1017 | #endif |
1018 | |
1019 | /* |
1020 | Proper for-scoping in MIPSpro CC |
1021 | */ |
1022 | #ifndef QT_NO_KEYWORDS |
1023 | # if defined(Q_CC_MIPS) || (defined(Q_CC_HPACC) && defined(__ia64)) |
1024 | # define for if(0){}else for |
1025 | # endif |
1026 | #endif |
1027 | |
1028 | /* |
1029 | Workaround for static const members on MSVC++. |
1030 | */ |
1031 | |
1032 | #if defined(Q_CC_MSVC) |
1033 | # define QT_STATIC_CONST static |
1034 | # define QT_STATIC_CONST_IMPL |
1035 | #else |
1036 | # define QT_STATIC_CONST static const |
1037 | # define QT_STATIC_CONST_IMPL const |
1038 | #endif |
1039 | |
1040 | /* |
1041 | Warnings and errors when using deprecated methods |
1042 | */ |
1043 | #if defined(Q_MOC_RUN) |
1044 | # define Q_DECL_DEPRECATED Q_DECL_DEPRECATED |
1045 | #elif (defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && (__GNUC__ - 0 > 3 || (__GNUC__ - 0 == 3 && __GNUC_MINOR__ - 0 >= 2))) || defined(Q_CC_RVCT) |
1046 | # define Q_DECL_DEPRECATED __attribute__ ((__deprecated__)) |
1047 | #elif defined(Q_CC_MSVC) |
1048 | # define Q_DECL_DEPRECATED __declspec(deprecated) |
1049 | # if defined (Q_CC_INTEL) |
1050 | # define Q_DECL_VARIABLE_DEPRECATED |
1051 | # else |
1052 | # endif |
1053 | #else |
1054 | # define Q_DECL_DEPRECATED |
1055 | #endif |
1056 | #ifndef Q_DECL_VARIABLE_DEPRECATED |
1057 | # define Q_DECL_VARIABLE_DEPRECATED Q_DECL_DEPRECATED |
1058 | #endif |
1059 | #ifndef Q_DECL_CONSTRUCTOR_DEPRECATED |
1060 | # if defined(Q_MOC_RUN) |
1061 | # define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_CONSTRUCTOR_DEPRECATED |
1062 | # elif defined(Q_NO_DEPRECATED_CONSTRUCTORS) |
1063 | # define Q_DECL_CONSTRUCTOR_DEPRECATED |
1064 | # else |
1065 | # define Q_DECL_CONSTRUCTOR_DEPRECATED Q_DECL_DEPRECATED |
1066 | # endif |
1067 | #endif |
1068 | |
1069 | #if defined(QT_NO_DEPRECATED) |
1070 | /* disable Qt3 support as well */ |
1071 | # undef QT3_SUPPORT_WARNINGS |
1072 | # undef QT3_SUPPORT |
1073 | # undef QT_DEPRECATED |
1074 | # undef QT_DEPRECATED_VARIABLE |
1075 | # undef QT_DEPRECATED_CONSTRUCTOR |
1076 | #elif defined(QT_DEPRECATED_WARNINGS) |
1077 | # ifdef QT3_SUPPORT |
1078 | /* enable Qt3 support warnings as well */ |
1079 | # undef QT3_SUPPORT_WARNINGS |
1080 | # define QT3_SUPPORT_WARNINGS |
1081 | # endif |
1082 | # undef QT_DEPRECATED |
1083 | # define QT_DEPRECATED Q_DECL_DEPRECATED |
1084 | # undef QT_DEPRECATED_VARIABLE |
1085 | # define QT_DEPRECATED_VARIABLE Q_DECL_VARIABLE_DEPRECATED |
1086 | # undef QT_DEPRECATED_CONSTRUCTOR |
1087 | # define QT_DEPRECATED_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED |
1088 | #else |
1089 | # undef QT_DEPRECATED |
1090 | # define QT_DEPRECATED |
1091 | # undef QT_DEPRECATED_VARIABLE |
1092 | # define QT_DEPRECATED_VARIABLE |
1093 | # undef QT_DEPRECATED_CONSTRUCTOR |
1094 | # define QT_DEPRECATED_CONSTRUCTOR |
1095 | #endif |
1096 | |
1097 | #if defined(QT3_SUPPORT_WARNINGS) |
1098 | # if !defined(QT_COMPAT_WARNINGS) /* also enable compat */ |
1099 | # define QT_COMPAT_WARNINGS |
1100 | # endif |
1101 | # undef QT3_SUPPORT |
1102 | # define QT3_SUPPORT Q_DECL_DEPRECATED |
1103 | # undef QT3_SUPPORT_VARIABLE |
1104 | # define QT3_SUPPORT_VARIABLE Q_DECL_VARIABLE_DEPRECATED |
1105 | # undef QT3_SUPPORT_CONSTRUCTOR |
1106 | # define QT3_SUPPORT_CONSTRUCTOR explicit Q_DECL_CONSTRUCTOR_DEPRECATED |
1107 | #elif defined(QT3_SUPPORT) /* define back to nothing */ |
1108 | # if !defined(QT_COMPAT) /* also enable qt3 support */ |
1109 | # define QT_COMPAT |
1110 | # endif |
1111 | # undef QT3_SUPPORT |
1112 | # define QT3_SUPPORT |
1113 | # undef QT3_SUPPORT_VARIABLE |
1114 | # define QT3_SUPPORT_VARIABLE |
1115 | # undef QT3_SUPPORT_CONSTRUCTOR |
1116 | # define QT3_SUPPORT_CONSTRUCTOR explicit |
1117 | #endif |
1118 | |
1119 | /* moc compats (signals/slots) */ |
1120 | #ifndef QT_MOC_COMPAT |
1121 | # if defined(QT3_SUPPORT) |
1122 | # define QT_MOC_COMPAT QT3_SUPPORT |
1123 | # else |
1124 | # define QT_MOC_COMPAT |
1125 | # endif |
1126 | #else |
1127 | # undef QT_MOC_COMPAT |
1128 | # define QT_MOC_COMPAT |
1129 | #endif |
1130 | |
1131 | #ifdef QT_ASCII_CAST_WARNINGS |
1132 | # define QT_ASCII_CAST_WARN Q_DECL_DEPRECATED |
1133 | # if defined(Q_CC_GNU) && __GNUC__ < 4 |
1134 | /* gcc < 4 doesn't like Q_DECL_DEPRECATED in front of constructors */ |
1135 | # define QT_ASCII_CAST_WARN_CONSTRUCTOR |
1136 | # else |
1137 | # define QT_ASCII_CAST_WARN_CONSTRUCTOR Q_DECL_CONSTRUCTOR_DEPRECATED |
1138 | # endif |
1139 | #else |
1140 | # define QT_ASCII_CAST_WARN |
1141 | # define QT_ASCII_CAST_WARN_CONSTRUCTOR |
1142 | #endif |
1143 | |
1144 | #if defined(__i386__) || defined(_WIN32) || defined(_WIN32_WCE) |
1145 | # if defined(Q_CC_GNU) |
1146 | #if !defined(Q_CC_INTEL) && ((100*(__GNUC__ - 0) + 10*(__GNUC_MINOR__ - 0) + __GNUC_PATCHLEVEL__) >= 332) |
1147 | # define QT_FASTCALL __attribute__((regparm(3))) |
1148 | #else |
1149 | # define QT_FASTCALL |
1150 | #endif |
1151 | # elif defined(Q_CC_MSVC) |
1152 | # define QT_FASTCALL __fastcall |
1153 | # else |
1154 | # define QT_FASTCALL |
1155 | # endif |
1156 | #else |
1157 | # define QT_FASTCALL |
1158 | #endif |
1159 | |
1160 | #ifdef Q_COMPILER_CONSTEXPR |
1161 | # define Q_DECL_CONSTEXPR constexpr |
1162 | #else |
1163 | # define Q_DECL_CONSTEXPR |
1164 | #endif |
1165 | |
1166 | //defines the type for the WNDPROC on windows |
1167 | //the alignment needs to be forced for sse2 to not crash with mingw |
1168 | #if defined(Q_WS_WIN) |
1169 | # if defined(Q_CC_MINGW) |
1170 | # define QT_ENSURE_STACK_ALIGNED_FOR_SSE __attribute__ ((force_align_arg_pointer)) |
1171 | # else |
1172 | # define QT_ENSURE_STACK_ALIGNED_FOR_SSE |
1173 | # endif |
1174 | # define QT_WIN_CALLBACK CALLBACK QT_ENSURE_STACK_ALIGNED_FOR_SSE |
1175 | #endif |
1176 | |
1177 | typedef int QNoImplicitBoolCast; |
1178 | |
1179 | #if defined(QT_ARCH_ARM) || defined(QT_ARCH_ARMV6) || defined(QT_ARCH_AVR32) || (defined(QT_ARCH_MIPS) && (defined(Q_WS_QWS) || defined(Q_WS_QPA) || defined(Q_OS_WINCE))) || defined(QT_ARCH_SH) || defined(QT_ARCH_SH4A) |
1180 | #define QT_NO_FPU |
1181 | #endif |
1182 | |
1183 | // This logic must match the one in qmetatype.h |
1184 | #if defined(QT_COORD_TYPE) |
1185 | typedef QT_COORD_TYPE qreal; |
1186 | #elif defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) |
1187 | typedef float qreal; |
1188 | #else |
1189 | typedef double qreal; |
1190 | #endif |
1191 | |
1192 | /* |
1193 | Utility macros and inline functions |
1194 | */ |
1195 | |
1196 | template <typename T> |
1197 | Q_DECL_CONSTEXPR inline T qAbs(const T &t) { return t >= 0 ? t : -t; } |
1198 | |
1199 | Q_DECL_CONSTEXPR inline int qRound(qreal d) |
1200 | { return d >= qreal(0.0) ? int(d + qreal(0.5)) : int(d - int(d-1) + qreal(0.5)) + int(d-1); } |
1201 | |
1202 | #if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE) || defined(QT_ARCH_SYMBIAN) |
1203 | Q_DECL_CONSTEXPR inline qint64 qRound64(double d) |
1204 | { return d >= 0.0 ? qint64(d + 0.5) : qint64(d - qreal(qint64(d-1)) + 0.5) + qint64(d-1); } |
1205 | #else |
1206 | Q_DECL_CONSTEXPR inline qint64 qRound64(qreal d) |
1207 | { return d >= qreal(0.0) ? qint64(d + qreal(0.5)) : qint64(d - qreal(qint64(d-1)) + qreal(0.5)) + qint64(d-1); } |
1208 | #endif |
1209 | |
1210 | template <typename T> |
1211 | Q_DECL_CONSTEXPR inline const T &qMin(const T &a, const T &b) { return (a < b) ? a : b; } |
1212 | template <typename T> |
1213 | Q_DECL_CONSTEXPR inline const T &qMax(const T &a, const T &b) { return (a < b) ? b : a; } |
1214 | template <typename T> |
1215 | Q_DECL_CONSTEXPR inline const T &qBound(const T &min, const T &val, const T &max) |
1216 | { return qMax(min, qMin(max, val)); } |
1217 | |
1218 | #ifdef QT3_SUPPORT |
1219 | typedef qint8 Q_INT8; |
1220 | typedef quint8 Q_UINT8; |
1221 | typedef qint16 Q_INT16; |
1222 | typedef quint16 Q_UINT16; |
1223 | typedef qint32 Q_INT32; |
1224 | typedef quint32 Q_UINT32; |
1225 | typedef qint64 Q_INT64; |
1226 | typedef quint64 Q_UINT64; |
1227 | |
1228 | typedef qint64 Q_LLONG; |
1229 | typedef quint64 Q_ULLONG; |
1230 | #if defined(Q_OS_WIN64) |
1231 | typedef __int64 Q_LONG; /* word up to 64 bit signed */ |
1232 | typedef unsigned __int64 Q_ULONG; /* word up to 64 bit unsigned */ |
1233 | #else |
1234 | typedef long Q_LONG; /* word up to 64 bit signed */ |
1235 | typedef unsigned long Q_ULONG; /* word up to 64 bit unsigned */ |
1236 | #endif |
1237 | |
1238 | # define QABS(a) qAbs(a) |
1239 | # define QMAX(a, b) qMax((a), (b)) |
1240 | # define QMIN(a, b) qMin((a), (b)) |
1241 | #endif |
1242 | |
1243 | /* |
1244 | Data stream functions are provided by many classes (defined in qdatastream.h) |
1245 | */ |
1246 | |
1247 | class QDataStream; |
1248 | |
1249 | #ifndef QT_BUILD_KEY |
1250 | #define QT_BUILD_KEY "unspecified" |
1251 | #endif |
1252 | |
1253 | #if defined(Q_WS_MAC) |
1254 | # ifndef QMAC_QMENUBAR_NO_EVENT |
1255 | # define QMAC_QMENUBAR_NO_EVENT |
1256 | # endif |
1257 | #endif |
1258 | |
1259 | #if !defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1260 | # define QT_NO_COP |
1261 | #endif |
1262 | |
1263 | #if defined(Q_OS_VXWORKS) |
1264 | # define QT_NO_CRASHHANDLER // no popen |
1265 | # define QT_NO_PROCESS // no exec*, no fork |
1266 | # define QT_NO_LPR |
1267 | # define QT_NO_SHAREDMEMORY // only POSIX, no SysV and in the end... |
1268 | # define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space |
1269 | # define QT_NO_QWS_MULTIPROCESS // no processes |
1270 | #endif |
1271 | |
1272 | # include <QtCore/qfeatures.h> |
1273 | |
1274 | #define QT_SUPPORTS(FEATURE) (!defined(QT_NO_##FEATURE)) |
1275 | |
1276 | #if defined(Q_OS_LINUX) && defined(Q_CC_RVCT) |
1277 | # define Q_DECL_EXPORT __attribute__((visibility("default"))) |
1278 | # define Q_DECL_IMPORT __attribute__((visibility("default"))) |
1279 | # define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) |
1280 | #endif |
1281 | |
1282 | #ifndef Q_DECL_EXPORT |
1283 | # if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) |
1284 | # define Q_DECL_EXPORT __declspec(dllexport) |
1285 | # elif defined(QT_VISIBILITY_AVAILABLE) |
1286 | # define Q_DECL_EXPORT __attribute__((visibility("default"))) |
1287 | # define Q_DECL_HIDDEN __attribute__((visibility("hidden"))) |
1288 | # endif |
1289 | # ifndef Q_DECL_EXPORT |
1290 | # define Q_DECL_EXPORT |
1291 | # endif |
1292 | #endif |
1293 | #ifndef Q_DECL_IMPORT |
1294 | # if defined(Q_OS_WIN) || defined(Q_CC_NOKIAX86) || defined(Q_CC_RVCT) |
1295 | # define Q_DECL_IMPORT __declspec(dllimport) |
1296 | # else |
1297 | # define Q_DECL_IMPORT |
1298 | # endif |
1299 | #endif |
1300 | #ifndef Q_DECL_HIDDEN |
1301 | # define Q_DECL_HIDDEN |
1302 | #endif |
1303 | |
1304 | |
1305 | /* |
1306 | Create Qt DLL if QT_DLL is defined (Windows and Symbian only) |
1307 | */ |
1308 | |
1309 | #if defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN) |
1310 | # if defined(QT_NODLL) |
1311 | # undef QT_MAKEDLL |
1312 | # undef QT_DLL |
1313 | # elif defined(QT_MAKEDLL) /* create a Qt DLL library */ |
1314 | # if defined(QT_DLL) |
1315 | # undef QT_DLL |
1316 | # endif |
1317 | # if defined(QT_BUILD_CORE_LIB) |
1318 | # define Q_CORE_EXPORT Q_DECL_EXPORT |
1319 | # else |
1320 | # define Q_CORE_EXPORT Q_DECL_IMPORT |
1321 | # endif |
1322 | # if defined(QT_BUILD_GUI_LIB) |
1323 | # define Q_GUI_EXPORT Q_DECL_EXPORT |
1324 | # else |
1325 | # define Q_GUI_EXPORT Q_DECL_IMPORT |
1326 | # endif |
1327 | # if defined(QT_BUILD_SQL_LIB) |
1328 | # define Q_SQL_EXPORT Q_DECL_EXPORT |
1329 | # else |
1330 | # define Q_SQL_EXPORT Q_DECL_IMPORT |
1331 | # endif |
1332 | # if defined(QT_BUILD_NETWORK_LIB) |
1333 | # define Q_NETWORK_EXPORT Q_DECL_EXPORT |
1334 | # else |
1335 | # define Q_NETWORK_EXPORT Q_DECL_IMPORT |
1336 | # endif |
1337 | # if defined(QT_BUILD_SVG_LIB) |
1338 | # define Q_SVG_EXPORT Q_DECL_EXPORT |
1339 | # else |
1340 | # define Q_SVG_EXPORT Q_DECL_IMPORT |
1341 | # endif |
1342 | # if defined(QT_BUILD_DECLARATIVE_LIB) |
1343 | # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT |
1344 | # else |
1345 | # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT |
1346 | # endif |
1347 | # if defined(QT_BUILD_OPENGL_LIB) |
1348 | # define Q_OPENGL_EXPORT Q_DECL_EXPORT |
1349 | # else |
1350 | # define Q_OPENGL_EXPORT Q_DECL_IMPORT |
1351 | # endif |
1352 | # if defined(QT_BUILD_MULTIMEDIA_LIB) |
1353 | # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT |
1354 | # else |
1355 | # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT |
1356 | # endif |
1357 | # if defined(QT_BUILD_OPENVG_LIB) |
1358 | # define Q_OPENVG_EXPORT Q_DECL_EXPORT |
1359 | # else |
1360 | # define Q_OPENVG_EXPORT Q_DECL_IMPORT |
1361 | # endif |
1362 | # if defined(QT_BUILD_XML_LIB) |
1363 | # define Q_XML_EXPORT Q_DECL_EXPORT |
1364 | # else |
1365 | # define Q_XML_EXPORT Q_DECL_IMPORT |
1366 | # endif |
1367 | # if defined(QT_BUILD_XMLPATTERNS_LIB) |
1368 | # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT |
1369 | # else |
1370 | # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT |
1371 | # endif |
1372 | # if defined(QT_BUILD_SCRIPT_LIB) |
1373 | # define Q_SCRIPT_EXPORT Q_DECL_EXPORT |
1374 | # else |
1375 | # define Q_SCRIPT_EXPORT Q_DECL_IMPORT |
1376 | # endif |
1377 | # if defined(QT_BUILD_SCRIPTTOOLS_LIB) |
1378 | # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT |
1379 | # else |
1380 | # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT |
1381 | # endif |
1382 | # if defined(QT_BUILD_CANVAS_LIB) |
1383 | # define Q_CANVAS_EXPORT Q_DECL_EXPORT |
1384 | # else |
1385 | # define Q_CANVAS_EXPORT Q_DECL_IMPORT |
1386 | # endif |
1387 | # if defined(QT_BUILD_COMPAT_LIB) |
1388 | # define Q_COMPAT_EXPORT Q_DECL_EXPORT |
1389 | # else |
1390 | # define Q_COMPAT_EXPORT Q_DECL_IMPORT |
1391 | # endif |
1392 | # if defined(QT_BUILD_DBUS_LIB) |
1393 | # define Q_DBUS_EXPORT Q_DECL_EXPORT |
1394 | # else |
1395 | # define Q_DBUS_EXPORT Q_DECL_IMPORT |
1396 | # endif |
1397 | # define Q_TEMPLATEDLL |
1398 | # elif defined(QT_DLL) /* use a Qt DLL library */ |
1399 | # define Q_CORE_EXPORT Q_DECL_IMPORT |
1400 | # define Q_GUI_EXPORT Q_DECL_IMPORT |
1401 | # define Q_SQL_EXPORT Q_DECL_IMPORT |
1402 | # define Q_NETWORK_EXPORT Q_DECL_IMPORT |
1403 | # define Q_SVG_EXPORT Q_DECL_IMPORT |
1404 | # define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT |
1405 | # define Q_CANVAS_EXPORT Q_DECL_IMPORT |
1406 | # define Q_OPENGL_EXPORT Q_DECL_IMPORT |
1407 | # define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT |
1408 | # define Q_OPENVG_EXPORT Q_DECL_IMPORT |
1409 | # define Q_XML_EXPORT Q_DECL_IMPORT |
1410 | # define Q_XMLPATTERNS_EXPORT Q_DECL_IMPORT |
1411 | # define Q_SCRIPT_EXPORT Q_DECL_IMPORT |
1412 | # define Q_SCRIPTTOOLS_EXPORT Q_DECL_IMPORT |
1413 | # define Q_COMPAT_EXPORT Q_DECL_IMPORT |
1414 | # define Q_DBUS_EXPORT Q_DECL_IMPORT |
1415 | # define Q_TEMPLATEDLL |
1416 | # endif |
1417 | # define Q_NO_DECLARED_NOT_DEFINED |
1418 | #else |
1419 | # if defined(Q_OS_LINUX) && defined(Q_CC_BOR) |
1420 | # define Q_TEMPLATEDLL |
1421 | # define Q_NO_DECLARED_NOT_DEFINED |
1422 | # endif |
1423 | # undef QT_MAKEDLL /* ignore these for other platforms */ |
1424 | # undef QT_DLL |
1425 | #endif |
1426 | |
1427 | #if !defined(Q_CORE_EXPORT) |
1428 | # if defined(QT_SHARED) |
1429 | # define Q_CORE_EXPORT Q_DECL_EXPORT |
1430 | # define Q_GUI_EXPORT Q_DECL_EXPORT |
1431 | # define Q_SQL_EXPORT Q_DECL_EXPORT |
1432 | # define Q_NETWORK_EXPORT Q_DECL_EXPORT |
1433 | # define Q_SVG_EXPORT Q_DECL_EXPORT |
1434 | # define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT |
1435 | # define Q_OPENGL_EXPORT Q_DECL_EXPORT |
1436 | # define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT |
1437 | # define Q_OPENVG_EXPORT Q_DECL_EXPORT |
1438 | # define Q_XML_EXPORT Q_DECL_EXPORT |
1439 | # define Q_XMLPATTERNS_EXPORT Q_DECL_EXPORT |
1440 | # define Q_SCRIPT_EXPORT Q_DECL_EXPORT |
1441 | # define Q_SCRIPTTOOLS_EXPORT Q_DECL_EXPORT |
1442 | # define Q_COMPAT_EXPORT Q_DECL_EXPORT |
1443 | # define Q_DBUS_EXPORT Q_DECL_EXPORT |
1444 | # else |
1445 | # define Q_CORE_EXPORT |
1446 | # define Q_GUI_EXPORT |
1447 | # define Q_SQL_EXPORT |
1448 | # define Q_NETWORK_EXPORT |
1449 | # define Q_SVG_EXPORT |
1450 | # define Q_DECLARATIVE_EXPORT |
1451 | # define Q_OPENGL_EXPORT |
1452 | # define Q_MULTIMEDIA_EXPORT |
1453 | # define Q_OPENVG_EXPORT |
1454 | # define Q_XML_EXPORT |
1455 | # define Q_XMLPATTERNS_EXPORT |
1456 | # define Q_SCRIPT_EXPORT |
1457 | # define Q_SCRIPTTOOLS_EXPORT |
1458 | # define Q_COMPAT_EXPORT |
1459 | # define Q_DBUS_EXPORT |
1460 | # endif |
1461 | #endif |
1462 | |
1463 | // Functions marked as Q_GUI_EXPORT_INLINE were exported and inlined by mistake. |
1464 | // Compilers like MinGW complain that the import attribute is ignored. |
1465 | #if defined(Q_CC_MINGW) |
1466 | # if defined(QT_BUILD_CORE_LIB) |
1467 | # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline |
1468 | # else |
1469 | # define Q_CORE_EXPORT_INLINE inline |
1470 | # endif |
1471 | # if defined(QT_BUILD_GUI_LIB) |
1472 | # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline |
1473 | # else |
1474 | # define Q_GUI_EXPORT_INLINE inline |
1475 | # endif |
1476 | # if defined(QT_BUILD_COMPAT_LIB) |
1477 | # define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline |
1478 | # else |
1479 | # define Q_COMPAT_EXPORT_INLINE inline |
1480 | # endif |
1481 | #elif defined(Q_CC_RVCT) |
1482 | // we force RVCT not to export inlines by passing --visibility_inlines_hidden |
1483 | // so we need to just inline it, rather than exporting and inlining |
1484 | // note: this affects the contents of the DEF files (ie. these functions do not appear) |
1485 | # define Q_CORE_EXPORT_INLINE inline |
1486 | # define Q_GUI_EXPORT_INLINE inline |
1487 | # define Q_COMPAT_EXPORT_INLINE inline |
1488 | #else |
1489 | # define Q_CORE_EXPORT_INLINE Q_CORE_EXPORT inline |
1490 | # define Q_GUI_EXPORT_INLINE Q_GUI_EXPORT inline |
1491 | # define Q_COMPAT_EXPORT_INLINE Q_COMPAT_EXPORT inline |
1492 | #endif |
1493 | |
1494 | /* |
1495 | No, this is not an evil backdoor. QT_BUILD_INTERNAL just exports more symbols |
1496 | for Qt's internal unit tests. If you want slower loading times and more |
1497 | symbols that can vanish from version to version, feel free to define QT_BUILD_INTERNAL. |
1498 | */ |
1499 | #if defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_MAKEDLL) |
1500 | # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT |
1501 | #elif defined(QT_BUILD_INTERNAL) && (defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_DLL) |
1502 | # define Q_AUTOTEST_EXPORT Q_DECL_IMPORT |
1503 | #elif defined(QT_BUILD_INTERNAL) && !(defined(Q_OS_WIN) || defined(Q_OS_SYMBIAN)) && defined(QT_SHARED) |
1504 | # define Q_AUTOTEST_EXPORT Q_DECL_EXPORT |
1505 | #else |
1506 | # define Q_AUTOTEST_EXPORT |
1507 | #endif |
1508 | |
1509 | inline void qt_noop(void) {} |
1510 | |
1511 | /* These wrap try/catch so we can switch off exceptions later. |
1512 | |
1513 | Beware - do not use more than one QT_CATCH per QT_TRY, and do not use |
1514 | the exception instance in the catch block. |
1515 | If you can't live with those constraints, don't use these macros. |
1516 | Use the QT_NO_EXCEPTIONS macro to protect your code instead. |
1517 | */ |
1518 | |
1519 | #ifdef QT_BOOTSTRAPPED |
1520 | # define QT_NO_EXCEPTIONS |
1521 | #endif |
1522 | #if !defined(QT_NO_EXCEPTIONS) && defined(Q_CC_GNU) && !defined (__EXCEPTIONS) && !defined(Q_MOC_RUN) |
1523 | # define QT_NO_EXCEPTIONS |
1524 | #endif |
1525 | |
1526 | #ifdef QT_NO_EXCEPTIONS |
1527 | # define QT_TRY if (true) |
1528 | # define QT_CATCH(A) else |
1529 | # define QT_THROW(A) qt_noop() |
1530 | # define QT_RETHROW qt_noop() |
1531 | #else |
1532 | # define QT_TRY try |
1533 | # define QT_CATCH(A) catch (A) |
1534 | # define QT_THROW(A) throw A |
1535 | # define QT_RETHROW throw |
1536 | #endif |
1537 | |
1538 | /* |
1539 | System information |
1540 | */ |
1541 | |
1542 | class QString; |
1543 | class Q_CORE_EXPORT QSysInfo { |
1544 | public: |
1545 | enum Sizes { |
1546 | WordSize = (sizeof(void *)<<3) |
1547 | }; |
1548 | |
1549 | #if defined(QT_BUILD_QMAKE) |
1550 | enum Endian { |
1551 | BigEndian, |
1552 | LittleEndian |
1553 | }; |
1554 | /* needed to bootstrap qmake */ |
1555 | static const int ByteOrder; |
1556 | #elif defined(Q_BYTE_ORDER) |
1557 | enum Endian { |
1558 | BigEndian, |
1559 | LittleEndian |
1560 | |
1561 | # ifdef qdoc |
1562 | , ByteOrder = <platform-dependent> |
1563 | # elif Q_BYTE_ORDER == Q_BIG_ENDIAN |
1564 | , ByteOrder = BigEndian |
1565 | # elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
1566 | , ByteOrder = LittleEndian |
1567 | # else |
1568 | # error "Undefined byte order" |
1569 | # endif |
1570 | }; |
1571 | #else |
1572 | # error "Qt not configured correctly, please run configure" |
1573 | #endif |
1574 | #if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN) |
1575 | enum WinVersion { |
1576 | WV_32s = 0x0001, |
1577 | WV_95 = 0x0002, |
1578 | WV_98 = 0x0003, |
1579 | WV_Me = 0x0004, |
1580 | WV_DOS_based= 0x000f, |
1581 | |
1582 | /* codenames */ |
1583 | WV_NT = 0x0010, |
1584 | WV_2000 = 0x0020, |
1585 | WV_XP = 0x0030, |
1586 | WV_2003 = 0x0040, |
1587 | WV_VISTA = 0x0080, |
1588 | WV_WINDOWS7 = 0x0090, |
1589 | WV_WINDOWS8 = 0x00a0, |
1590 | WV_NT_based = 0x00f0, |
1591 | |
1592 | /* version numbers */ |
1593 | WV_4_0 = WV_NT, |
1594 | WV_5_0 = WV_2000, |
1595 | WV_5_1 = WV_XP, |
1596 | WV_5_2 = WV_2003, |
1597 | WV_6_0 = WV_VISTA, |
1598 | WV_6_1 = WV_WINDOWS7, |
1599 | WV_6_2 = WV_WINDOWS8, |
1600 | |
1601 | WV_CE = 0x0100, |
1602 | WV_CENET = 0x0200, |
1603 | WV_CE_5 = 0x0300, |
1604 | WV_CE_6 = 0x0400, |
1605 | WV_CE_based = 0x0f00 |
1606 | }; |
1607 | static const WinVersion WindowsVersion; |
1608 | static WinVersion windowsVersion(); |
1609 | |
1610 | #endif |
1611 | #ifdef Q_OS_MAC |
1612 | enum MacVersion { |
1613 | MV_Unknown = 0x0000, |
1614 | |
1615 | /* version */ |
1616 | MV_9 = 0x0001, |
1617 | MV_10_0 = 0x0002, |
1618 | MV_10_1 = 0x0003, |
1619 | MV_10_2 = 0x0004, |
1620 | MV_10_3 = 0x0005, |
1621 | MV_10_4 = 0x0006, |
1622 | MV_10_5 = 0x0007, |
1623 | MV_10_6 = 0x0008, |
1624 | MV_10_7 = 0x0009, |
1625 | MV_10_8 = 0x000A, |
1626 | |
1627 | /* codenames */ |
1628 | MV_CHEETAH = MV_10_0, |
1629 | MV_PUMA = MV_10_1, |
1630 | MV_JAGUAR = MV_10_2, |
1631 | MV_PANTHER = MV_10_3, |
1632 | MV_TIGER = MV_10_4, |
1633 | MV_LEOPARD = MV_10_5, |
1634 | MV_SNOWLEOPARD = MV_10_6, |
1635 | MV_LION = MV_10_7, |
1636 | MV_MOUNTAINLION = MV_10_8 |
1637 | }; |
1638 | static const MacVersion MacintoshVersion; |
1639 | #endif |
1640 | #ifdef Q_OS_SYMBIAN |
1641 | enum SymbianVersion { |
1642 | SV_Unknown = 1000000, // Assume unknown is something newer than what is supported |
1643 | //These are the Symbian Ltd versions 9.2-9.4 |
1644 | SV_9_2 = 10, |
1645 | SV_9_3 = 20, |
1646 | SV_9_4 = 30, |
1647 | //Following values are the symbian foundation versions, i.e. Symbian^1 == SV_SF_1 |
1648 | SV_SF_1 = SV_9_4, |
1649 | SV_SF_2 = 40, |
1650 | SV_SF_3 = 50, |
1651 | SV_SF_4 = 60, // Deprecated |
1652 | SV_API_5_3 = 70, |
1653 | SV_API_5_4 = 80, |
1654 | SV_API_5_5 = 90 |
1655 | }; |
1656 | static SymbianVersion symbianVersion(); |
1657 | enum S60Version { |
1658 | SV_S60_None = 0, |
1659 | SV_S60_Unknown = SV_Unknown, |
1660 | SV_S60_3_1 = SV_9_2, |
1661 | SV_S60_3_2 = SV_9_3, |
1662 | SV_S60_5_0 = SV_9_4, |
1663 | SV_S60_5_1 = SV_SF_2, // Deprecated |
1664 | SV_S60_5_2 = SV_SF_3, |
1665 | SV_S60_5_3 = SV_API_5_3, |
1666 | SV_S60_5_4 = SV_API_5_4, |
1667 | SV_S60_5_5 = SV_API_5_5 |
1668 | }; |
1669 | static S60Version s60Version(); |
1670 | #endif |
1671 | }; |
1672 | |
1673 | Q_CORE_EXPORT const char *qVersion(); |
1674 | Q_CORE_EXPORT bool qSharedBuild(); |
1675 | |
1676 | #if defined(Q_OS_MAC) |
1677 | inline int qMacVersion() { return QSysInfo::MacintoshVersion; } |
1678 | #endif |
1679 | |
1680 | #ifdef QT3_SUPPORT |
1681 | inline QT3_SUPPORT bool qSysInfo(int *wordSize, bool *bigEndian) |
1682 | { |
1683 | *wordSize = QSysInfo::WordSize; |
1684 | *bigEndian = (QSysInfo::ByteOrder == QSysInfo::BigEndian); |
1685 | return true; |
1686 | } |
1687 | #endif |
1688 | |
1689 | #if defined(Q_WS_WIN) || defined(Q_OS_CYGWIN) |
1690 | #if defined(QT3_SUPPORT) |
1691 | inline QT3_SUPPORT bool qt_winUnicode() { return true; } |
1692 | inline QT3_SUPPORT int qWinVersion() { return QSysInfo::WindowsVersion; } |
1693 | #endif |
1694 | |
1695 | // ### Qt 5: remove Win9x support macros QT_WA and QT_WA_INLINE. |
1696 | #define QT_WA(unicode, ansi) unicode |
1697 | #define QT_WA_INLINE(unicode, ansi) (unicode) |
1698 | |
1699 | #endif /* Q_WS_WIN */ |
1700 | |
1701 | #ifndef Q_OUTOFLINE_TEMPLATE |
1702 | # define Q_OUTOFLINE_TEMPLATE |
1703 | #endif |
1704 | #ifndef Q_INLINE_TEMPLATE |
1705 | # define Q_INLINE_TEMPLATE inline |
1706 | #endif |
1707 | |
1708 | #ifndef Q_TYPENAME |
1709 | # define Q_TYPENAME typename |
1710 | #endif |
1711 | |
1712 | /* |
1713 | Avoid "unused parameter" warnings |
1714 | */ |
1715 | |
1716 | #if defined(Q_CC_INTEL) && !defined(Q_OS_WIN) || defined(Q_CC_RVCT) |
1717 | template <typename T> |
1718 | inline void qUnused(T &x) { (void)x; } |
1719 | # define Q_UNUSED(x) qUnused(x); |
1720 | #else |
1721 | # define Q_UNUSED(x) (void)x; |
1722 | #endif |
1723 | |
1724 | /* |
1725 | Debugging and error handling |
1726 | */ |
1727 | |
1728 | /* |
1729 | On Symbian we do not know beforehand whether we are compiling in |
1730 | release or debug mode, so check the Symbian build define here, |
1731 | and set the QT_NO_DEBUG define appropriately. |
1732 | */ |
1733 | #if defined(Q_OS_SYMBIAN) && defined(NDEBUG) && !defined(QT_NO_DEBUG) |
1734 | # define QT_NO_DEBUG |
1735 | #endif |
1736 | |
1737 | #if !defined(QT_NO_DEBUG) && !defined(QT_DEBUG) |
1738 | # define QT_DEBUG |
1739 | #endif |
1740 | |
1741 | #ifndef qPrintable |
1742 | # define qPrintable(string) QString(string).toLocal8Bit().constData() |
1743 | #endif |
1744 | |
1745 | Q_CORE_EXPORT void qDebug(const char *, ...) /* print debug message */ |
1746 | #if defined(Q_CC_GNU) && !defined(__INSURE__) |
1747 | __attribute__ ((format (printf, 1, 2))) |
1748 | #endif |
1749 | ; |
1750 | |
1751 | Q_CORE_EXPORT void qWarning(const char *, ...) /* print warning message */ |
1752 | #if defined(Q_CC_GNU) && !defined(__INSURE__) |
1753 | __attribute__ ((format (printf, 1, 2))) |
1754 | #endif |
1755 | ; |
1756 | |
1757 | class QString; |
1758 | Q_CORE_EXPORT QString qt_error_string(int errorCode = -1); |
1759 | Q_CORE_EXPORT void qCritical(const char *, ...) /* print critical message */ |
1760 | #if defined(Q_CC_GNU) && !defined(__INSURE__) |
1761 | __attribute__ ((format (printf, 1, 2))) |
1762 | #endif |
1763 | ; |
1764 | Q_CORE_EXPORT void qFatal(const char *, ...) /* print fatal message and exit */ |
1765 | #if defined(Q_CC_GNU) && !defined(__INSURE__) |
1766 | __attribute__ ((format (printf, 1, 2))) |
1767 | #endif |
1768 | ; |
1769 | |
1770 | #ifdef QT3_SUPPORT |
1771 | Q_CORE_EXPORT QT3_SUPPORT void qSystemWarning(const char *msg, int code = -1); |
1772 | #endif /* QT3_SUPPORT */ |
1773 | Q_CORE_EXPORT void qErrnoWarning(int code, const char *msg, ...); |
1774 | Q_CORE_EXPORT void qErrnoWarning(const char *msg, ...); |
1775 | |
1776 | #if (defined(QT_NO_DEBUG_OUTPUT) || defined(QT_NO_TEXTSTREAM)) && !defined(QT_NO_DEBUG_STREAM) |
1777 | #define QT_NO_DEBUG_STREAM |
1778 | #endif |
1779 | |
1780 | /* |
1781 | Forward declarations only. |
1782 | |
1783 | In order to use the qDebug() stream, you must #include<QDebug> |
1784 | */ |
1785 | class QDebug; |
1786 | class QNoDebug; |
1787 | #ifndef QT_NO_DEBUG_STREAM |
1788 | Q_CORE_EXPORT_INLINE QDebug qDebug(); |
1789 | Q_CORE_EXPORT_INLINE QDebug qWarning(); |
1790 | Q_CORE_EXPORT_INLINE QDebug qCritical(); |
1791 | #else |
1792 | inline QNoDebug qDebug(); |
1793 | #endif |
1794 | |
1795 | #ifdef QT_NO_WARNING_OUTPUT |
1796 | inline QNoDebug qWarning(); |
1797 | #endif |
1798 | |
1799 | #define QT_NO_QDEBUG_MACRO while (false) qDebug |
1800 | #ifdef QT_NO_DEBUG_OUTPUT |
1801 | # define qDebug QT_NO_QDEBUG_MACRO |
1802 | #endif |
1803 | #define QT_NO_QWARNING_MACRO while (false) qWarning |
1804 | #ifdef QT_NO_WARNING_OUTPUT |
1805 | # define qWarning QT_NO_QWARNING_MACRO |
1806 | #endif |
1807 | |
1808 | |
1809 | Q_CORE_EXPORT void qt_assert(const char *assertion, const char *file, int line); |
1810 | |
1811 | #if !defined(Q_ASSERT) |
1812 | # ifndef QT_NO_DEBUG |
1813 | # define Q_ASSERT(cond) ((!(cond)) ? qt_assert(#cond,__FILE__,__LINE__) : qt_noop()) |
1814 | # else |
1815 | # define Q_ASSERT(cond) qt_noop() |
1816 | # endif |
1817 | #endif |
1818 | |
1819 | #if defined(QT_NO_DEBUG) && !defined(QT_PAINT_DEBUG) |
1820 | #define QT_NO_PAINT_DEBUG |
1821 | #endif |
1822 | |
1823 | Q_CORE_EXPORT void qt_assert_x(const char *where, const char *what, const char *file, int line); |
1824 | |
1825 | #if !defined(Q_ASSERT_X) |
1826 | # ifndef QT_NO_DEBUG |
1827 | # define Q_ASSERT_X(cond, where, what) ((!(cond)) ? qt_assert_x(where, what,__FILE__,__LINE__) : qt_noop()) |
1828 | # else |
1829 | # define Q_ASSERT_X(cond, where, what) qt_noop() |
1830 | # endif |
1831 | #endif |
1832 | |
1833 | Q_CORE_EXPORT void qt_check_pointer(const char *, int); |
1834 | Q_CORE_EXPORT void qBadAlloc(); |
1835 | |
1836 | #ifdef QT_NO_EXCEPTIONS |
1837 | # if defined(QT_NO_DEBUG) |
1838 | # define Q_CHECK_PTR(p) qt_noop() |
1839 | # else |
1840 | # define Q_CHECK_PTR(p) do {if(!(p))qt_check_pointer(__FILE__,__LINE__);} while (0) |
1841 | # endif |
1842 | #else |
1843 | # define Q_CHECK_PTR(p) do { if (!(p)) qBadAlloc(); } while (0) |
1844 | #endif |
1845 | |
1846 | template <typename T> |
1847 | inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; } |
1848 | |
1849 | #if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB) |
1850 | # define Q_FUNC_INFO __PRETTY_FUNCTION__ |
1851 | #elif defined(_MSC_VER) |
1852 | # define Q_FUNC_INFO __FUNCSIG__ |
1853 | #else |
1854 | # if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN) || defined(Q_OS_INTEGRITY) |
1855 | # define Q_FUNC_INFO __FILE__ "(line number unavailable)" |
1856 | # else |
1857 | /* These two macros makes it possible to turn the builtin line expander into a |
1858 | * string literal. */ |
1859 | # define QT_STRINGIFY2(x) #x |
1860 | # define QT_STRINGIFY(x) QT_STRINGIFY2(x) |
1861 | # define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__) |
1862 | # endif |
1863 | /* The MIPSpro and RVCT compilers postpones macro expansion, |
1864 | and therefore macros must be in scope when being used. */ |
1865 | # if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT) && !defined(Q_CC_NOKIAX86) |
1866 | # undef QT_STRINGIFY2 |
1867 | # undef QT_STRINGIFY |
1868 | # endif |
1869 | #endif |
1870 | |
1871 | enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg }; |
1872 | |
1873 | Q_CORE_EXPORT void qt_message_output(QtMsgType, const char *buf); |
1874 | |
1875 | typedef void (*QtMsgHandler)(QtMsgType, const char *); |
1876 | Q_CORE_EXPORT QtMsgHandler qInstallMsgHandler(QtMsgHandler); |
1877 | |
1878 | #ifdef QT3_SUPPORT |
1879 | inline QT3_SUPPORT void qSuppressObsoleteWarnings(bool = true) {} |
1880 | inline QT3_SUPPORT void qObsolete(const char *, const char * = 0, const char * = 0) {} |
1881 | #endif |
1882 | |
1883 | #if defined(QT_NO_THREAD) |
1884 | |
1885 | template <typename T> |
1886 | class QGlobalStatic |
1887 | { |
1888 | public: |
1889 | T *pointer; |
1890 | inline QGlobalStatic(T *p) : pointer(p) { } |
1891 | inline ~QGlobalStatic() { pointer = 0; } |
1892 | }; |
1893 | |
1894 | #define Q_GLOBAL_STATIC(TYPE, NAME) \ |
1895 | static TYPE *NAME() \ |
1896 | { \ |
1897 | static TYPE thisVariable; \ |
1898 | static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \ |
1899 | return thisGlobalStatic.pointer; \ |
1900 | } |
1901 | |
1902 | #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ |
1903 | static TYPE *NAME() \ |
1904 | { \ |
1905 | static TYPE thisVariable ARGS; \ |
1906 | static QGlobalStatic<TYPE > thisGlobalStatic(&thisVariable); \ |
1907 | return thisGlobalStatic.pointer; \ |
1908 | } |
1909 | |
1910 | #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \ |
1911 | static TYPE *NAME() \ |
1912 | { \ |
1913 | static TYPE thisVariable; \ |
1914 | static QGlobalStatic<TYPE > thisGlobalStatic(0); \ |
1915 | if (!thisGlobalStatic.pointer) { \ |
1916 | TYPE *x = thisGlobalStatic.pointer = &thisVariable; \ |
1917 | INITIALIZER; \ |
1918 | } \ |
1919 | return thisGlobalStatic.pointer; \ |
1920 | } |
1921 | |
1922 | #else |
1923 | |
1924 | // forward declaration, since qatomic.h needs qglobal.h |
1925 | template <typename T> class QBasicAtomicPointer; |
1926 | |
1927 | // POD for Q_GLOBAL_STATIC |
1928 | template <typename T> |
1929 | class QGlobalStatic |
1930 | { |
1931 | public: |
1932 | QBasicAtomicPointer<T> pointer; |
1933 | bool destroyed; |
1934 | }; |
1935 | |
1936 | // Created as a function-local static to delete a QGlobalStatic<T> |
1937 | template <typename T> |
1938 | class QGlobalStaticDeleter |
1939 | { |
1940 | public: |
1941 | QGlobalStatic<T> &globalStatic; |
1942 | QGlobalStaticDeleter(QGlobalStatic<T> &_globalStatic) |
1943 | : globalStatic(_globalStatic) |
1944 | { } |
1945 | |
1946 | inline ~QGlobalStaticDeleter() |
1947 | { |
1948 | delete globalStatic.pointer; |
1949 | globalStatic.pointer = 0; |
1950 | globalStatic.destroyed = true; |
1951 | } |
1952 | }; |
1953 | |
1954 | #define Q_GLOBAL_STATIC_INIT(TYPE, NAME) \ |
1955 | static QGlobalStatic<TYPE > this_ ## NAME \ |
1956 | = { Q_BASIC_ATOMIC_INITIALIZER(0), false } |
1957 | |
1958 | #define Q_GLOBAL_STATIC(TYPE, NAME) \ |
1959 | static TYPE *NAME() \ |
1960 | { \ |
1961 | Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \ |
1962 | if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \ |
1963 | TYPE *x = new TYPE; \ |
1964 | if (!this__StaticVar_.pointer.testAndSetOrdered(0, x)) \ |
1965 | delete x; \ |
1966 | else \ |
1967 | static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \ |
1968 | } \ |
1969 | return this__StaticVar_.pointer; \ |
1970 | } |
1971 | |
1972 | #define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \ |
1973 | static TYPE *NAME() \ |
1974 | { \ |
1975 | Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \ |
1976 | if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \ |
1977 | TYPE *x = new TYPE ARGS; \ |
1978 | if (!this__StaticVar_.pointer.testAndSetOrdered(0, x)) \ |
1979 | delete x; \ |
1980 | else \ |
1981 | static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \ |
1982 | } \ |
1983 | return this__StaticVar_.pointer; \ |
1984 | } |
1985 | |
1986 | #define Q_GLOBAL_STATIC_WITH_INITIALIZER(TYPE, NAME, INITIALIZER) \ |
1987 | static TYPE *NAME() \ |
1988 | { \ |
1989 | Q_GLOBAL_STATIC_INIT(TYPE, _StaticVar_); \ |
1990 | if (!this__StaticVar_.pointer && !this__StaticVar_.destroyed) { \ |
1991 | QScopedPointer<TYPE > x(new TYPE); \ |
1992 | INITIALIZER; \ |
1993 | if (this__StaticVar_.pointer.testAndSetOrdered(0, x.data())) { \ |
1994 | static QGlobalStaticDeleter<TYPE > cleanup(this__StaticVar_); \ |
1995 | x.take(); \ |
1996 | } \ |
1997 | } \ |
1998 | return this__StaticVar_.pointer; \ |
1999 | } |
2000 | |
2001 | #endif |
2002 | |
2003 | class QBool |
2004 | { |
2005 | bool b; |
2006 | |
2007 | public: |
2008 | inline explicit QBool(bool B) : b(B) {} |
2009 | inline operator const void *() const |
2010 | { return b ? static_cast<const void *>(this) : static_cast<const void *>(0); } |
2011 | }; |
2012 | |
2013 | inline bool operator==(QBool b1, bool b2) { return !b1 == !b2; } |
2014 | inline bool operator==(bool b1, QBool b2) { return !b1 == !b2; } |
2015 | inline bool operator==(QBool b1, QBool b2) { return !b1 == !b2; } |
2016 | inline bool operator!=(QBool b1, bool b2) { return !b1 != !b2; } |
2017 | inline bool operator!=(bool b1, QBool b2) { return !b1 != !b2; } |
2018 | inline bool operator!=(QBool b1, QBool b2) { return !b1 != !b2; } |
2019 | |
2020 | Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) |
2021 | { |
2022 | return (qAbs(p1 - p2) <= 0.000000000001 * qMin(qAbs(p1), qAbs(p2))); |
2023 | } |
2024 | |
2025 | Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) |
2026 | { |
2027 | return (qAbs(p1 - p2) <= 0.00001f * qMin(qAbs(p1), qAbs(p2))); |
2028 | } |
2029 | |
2030 | /*! |
2031 | \internal |
2032 | */ |
2033 | Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) |
2034 | { |
2035 | return qAbs(d) <= 0.000000000001; |
2036 | } |
2037 | |
2038 | /*! |
2039 | \internal |
2040 | */ |
2041 | Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) |
2042 | { |
2043 | return qAbs(f) <= 0.00001f; |
2044 | } |
2045 | |
2046 | /* |
2047 | This function tests a double for a null value. It doesn't |
2048 | check whether the actual value is 0 or close to 0, but whether |
2049 | it is binary 0. |
2050 | */ |
2051 | static inline bool qIsNull(double d) |
2052 | { |
2053 | union U { |
2054 | double d; |
2055 | quint64 u; |
2056 | }; |
2057 | U val; |
2058 | val.d = d; |
2059 | return val.u == quint64(0); |
2060 | } |
2061 | |
2062 | /* |
2063 | This function tests a float for a null value. It doesn't |
2064 | check whether the actual value is 0 or close to 0, but whether |
2065 | it is binary 0. |
2066 | */ |
2067 | static inline bool qIsNull(float f) |
2068 | { |
2069 | union U { |
2070 | float f; |
2071 | quint32 u; |
2072 | }; |
2073 | U val; |
2074 | val.f = f; |
2075 | return val.u == 0u; |
2076 | } |
2077 | |
2078 | /* |
2079 | Compilers which follow outdated template instantiation rules |
2080 | require a class to have a comparison operator to exist when |
2081 | a QList of this type is instantiated. It's not actually |
2082 | used in the list, though. Hence the dummy implementation. |
2083 | Just in case other code relies on it we better trigger a warning |
2084 | mandating a real implementation. |
2085 | */ |
2086 | |
2087 | #ifdef Q_FULL_TEMPLATE_INSTANTIATION |
2088 | # define Q_DUMMY_COMPARISON_OPERATOR(C) \ |
2089 | bool operator==(const C&) const { \ |
2090 | qWarning(#C"::operator==(const "#C"&) was called"); \ |
2091 | return false; \ |
2092 | } |
2093 | #else |
2094 | # define Q_DUMMY_COMPARISON_OPERATOR(C) |
2095 | #endif |
2096 | |
2097 | |
2098 | /* |
2099 | QTypeInfo - type trait functionality |
2100 | qIsDetached - data sharing functionality |
2101 | */ |
2102 | |
2103 | /* |
2104 | The catch-all template. |
2105 | */ |
2106 | |
2107 | template <typename T> inline bool qIsDetached(T &) { return true; } |
2108 | |
2109 | template <typename T> |
2110 | class QTypeInfo |
2111 | { |
2112 | public: |
2113 | enum { |
2114 | isPointer = false, |
2115 | isComplex = true, |
2116 | isStatic = true, |
2117 | isLarge = (sizeof(T)>sizeof(void*)), |
2118 | isDummy = false |
2119 | }; |
2120 | }; |
2121 | |
2122 | template <typename T> |
2123 | class QTypeInfo<T*> |
2124 | { |
2125 | public: |
2126 | enum { |
2127 | isPointer = true, |
2128 | isComplex = false, |
2129 | isStatic = false, |
2130 | isLarge = false, |
2131 | isDummy = false |
2132 | }; |
2133 | }; |
2134 | |
2135 | /* |
2136 | Specialize a specific type with: |
2137 | |
2138 | Q_DECLARE_TYPEINFO(type, flags); |
2139 | |
2140 | where 'type' is the name of the type to specialize and 'flags' is |
2141 | logically-OR'ed combination of the flags below. |
2142 | */ |
2143 | enum { /* TYPEINFO flags */ |
2144 | Q_COMPLEX_TYPE = 0, |
2145 | Q_PRIMITIVE_TYPE = 0x1, |
2146 | Q_STATIC_TYPE = 0, |
2147 | Q_MOVABLE_TYPE = 0x2, |
2148 | Q_DUMMY_TYPE = 0x4 |
2149 | }; |
2150 | |
2151 | #define Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) \ |
2152 | class QTypeInfo<TYPE > \ |
2153 | { \ |
2154 | public: \ |
2155 | enum { \ |
2156 | isComplex = (((FLAGS) & Q_PRIMITIVE_TYPE) == 0), \ |
2157 | isStatic = (((FLAGS) & (Q_MOVABLE_TYPE | Q_PRIMITIVE_TYPE)) == 0), \ |
2158 | isLarge = (sizeof(TYPE)>sizeof(void*)), \ |
2159 | isPointer = false, \ |
2160 | isDummy = (((FLAGS) & Q_DUMMY_TYPE) != 0) \ |
2161 | }; \ |
2162 | static inline const char *name() { return #TYPE; } \ |
2163 | } |
2164 | |
2165 | #define Q_DECLARE_TYPEINFO(TYPE, FLAGS) \ |
2166 | template<> \ |
2167 | Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS) |
2168 | |
2169 | |
2170 | template <typename T> |
2171 | inline void qSwap(T &value1, T &value2) |
2172 | { |
2173 | #ifdef QT_NO_STL |
2174 | const T t = value1; |
2175 | value1 = value2; |
2176 | value2 = t; |
2177 | #else |
2178 | using std::swap; |
2179 | swap(value1, value2); |
2180 | #endif |
2181 | } |
2182 | |
2183 | /* |
2184 | Specialize a shared type with: |
2185 | |
2186 | Q_DECLARE_SHARED(type); |
2187 | |
2188 | where 'type' is the name of the type to specialize. NOTE: shared |
2189 | types must declare a 'bool isDetached(void) const;' member for this |
2190 | to work. |
2191 | */ |
2192 | #ifdef QT_NO_STL |
2193 | #define Q_DECLARE_SHARED_STL(TYPE) |
2194 | #else |
2195 | #define Q_DECLARE_SHARED_STL(TYPE) \ |
2196 | QT_END_NAMESPACE \ |
2197 | namespace std { \ |
2198 | template<> inline void swap<QT_PREPEND_NAMESPACE(TYPE)>(QT_PREPEND_NAMESPACE(TYPE) &value1, QT_PREPEND_NAMESPACE(TYPE) &value2) \ |
2199 | { swap(value1.data_ptr(), value2.data_ptr()); } \ |
2200 | } \ |
2201 | QT_BEGIN_NAMESPACE |
2202 | #endif |
2203 | |
2204 | #define Q_DECLARE_SHARED(TYPE) \ |
2205 | template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \ |
2206 | template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \ |
2207 | { qSwap(value1.data_ptr(), value2.data_ptr()); } \ |
2208 | Q_DECLARE_SHARED_STL(TYPE) |
2209 | |
2210 | /* |
2211 | QTypeInfo primitive specializations |
2212 | */ |
2213 | Q_DECLARE_TYPEINFO(bool, Q_PRIMITIVE_TYPE); |
2214 | Q_DECLARE_TYPEINFO(char, Q_PRIMITIVE_TYPE); |
2215 | Q_DECLARE_TYPEINFO(signed char, Q_PRIMITIVE_TYPE); |
2216 | Q_DECLARE_TYPEINFO(uchar, Q_PRIMITIVE_TYPE); |
2217 | Q_DECLARE_TYPEINFO(short, Q_PRIMITIVE_TYPE); |
2218 | Q_DECLARE_TYPEINFO(ushort, Q_PRIMITIVE_TYPE); |
2219 | Q_DECLARE_TYPEINFO(int, Q_PRIMITIVE_TYPE); |
2220 | Q_DECLARE_TYPEINFO(uint, Q_PRIMITIVE_TYPE); |
2221 | Q_DECLARE_TYPEINFO(long, Q_PRIMITIVE_TYPE); |
2222 | Q_DECLARE_TYPEINFO(ulong, Q_PRIMITIVE_TYPE); |
2223 | Q_DECLARE_TYPEINFO(qint64, Q_PRIMITIVE_TYPE); |
2224 | Q_DECLARE_TYPEINFO(quint64, Q_PRIMITIVE_TYPE); |
2225 | Q_DECLARE_TYPEINFO(float, Q_PRIMITIVE_TYPE); |
2226 | Q_DECLARE_TYPEINFO(double, Q_PRIMITIVE_TYPE); |
2227 | #ifndef Q_OS_DARWIN |
2228 | Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE); |
2229 | #endif |
2230 | |
2231 | /* |
2232 | These functions make it possible to use standard C++ functions with |
2233 | a similar name from Qt header files (especially template classes). |
2234 | */ |
2235 | Q_CORE_EXPORT void *qMalloc(size_t size); |
2236 | Q_CORE_EXPORT void qFree(void *ptr); |
2237 | Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size); |
2238 | Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment); |
2239 | Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment); |
2240 | Q_CORE_EXPORT void qFreeAligned(void *ptr); |
2241 | Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n); |
2242 | Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n); |
2243 | |
2244 | |
2245 | /* |
2246 | Avoid some particularly useless warnings from some stupid compilers. |
2247 | To get ALL C++ compiler warnings, define QT_CC_WARNINGS or comment out |
2248 | the line "#define QT_NO_WARNINGS". |
2249 | */ |
2250 | #if !defined(QT_CC_WARNINGS) |
2251 | # define QT_NO_WARNINGS |
2252 | #endif |
2253 | #if defined(QT_NO_WARNINGS) |
2254 | # if defined(Q_CC_MSVC) |
2255 | # pragma warning(disable: 4251) /* class 'A' needs to have dll interface for to be used by clients of class 'B'. */ |
2256 | # pragma warning(disable: 4244) /* 'conversion' conversion from 'type1' to 'type2', possible loss of data */ |
2257 | # pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */ |
2258 | # pragma warning(disable: 4514) /* unreferenced inline/local function has been removed */ |
2259 | # pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */ |
2260 | # pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */ |
2261 | # pragma warning(disable: 4706) /* assignment within conditional expression */ |
2262 | # pragma warning(disable: 4786) /* truncating debug info after 255 characters */ |
2263 | # pragma warning(disable: 4660) /* template-class specialization 'identifier' is already instantiated */ |
2264 | # pragma warning(disable: 4355) /* 'this' : used in base member initializer list */ |
2265 | # pragma warning(disable: 4231) /* nonstandard extension used : 'extern' before template explicit instantiation */ |
2266 | # pragma warning(disable: 4710) /* function not inlined */ |
2267 | # pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify -GX */ |
2268 | # elif defined(Q_CC_BOR) |
2269 | # pragma option -w-inl |
2270 | # pragma option -w-aus |
2271 | # pragma warn -inl |
2272 | # pragma warn -pia |
2273 | # pragma warn -ccc |
2274 | # pragma warn -rch |
2275 | # pragma warn -sig |
2276 | # endif |
2277 | #endif |
2278 | |
2279 | class Q_CORE_EXPORT QFlag |
2280 | { |
2281 | int i; |
2282 | public: |
2283 | inline QFlag(int i); |
2284 | inline operator int() const { return i; } |
2285 | }; |
2286 | |
2287 | inline QFlag::QFlag(int ai) : i(ai) {} |
2288 | |
2289 | class Q_CORE_EXPORT QIncompatibleFlag |
2290 | { |
2291 | int i; |
2292 | public: |
2293 | inline explicit QIncompatibleFlag(int i); |
2294 | inline operator int() const { return i; } |
2295 | }; |
2296 | |
2297 | inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {} |
2298 | |
2299 | |
2300 | #ifndef Q_NO_TYPESAFE_FLAGS |
2301 | |
2302 | template<typename Enum> |
2303 | class QFlags |
2304 | { |
2305 | typedef void **Zero; |
2306 | int i; |
2307 | public: |
2308 | typedef Enum enum_type; |
2309 | Q_DECL_CONSTEXPR inline QFlags(const QFlags &f) : i(f.i) {} |
2310 | Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {} |
2311 | Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {} |
2312 | inline QFlags(QFlag f) : i(f) {} |
2313 | |
2314 | inline QFlags &operator=(const QFlags &f) { i = f.i; return *this; } |
2315 | inline QFlags &operator&=(int mask) { i &= mask; return *this; } |
2316 | inline QFlags &operator&=(uint mask) { i &= mask; return *this; } |
2317 | inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; } |
2318 | inline QFlags &operator|=(Enum f) { i |= f; return *this; } |
2319 | inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; } |
2320 | inline QFlags &operator^=(Enum f) { i ^= f; return *this; } |
2321 | |
2322 | Q_DECL_CONSTEXPR inline operator int() const { return i; } |
2323 | |
2324 | Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); } |
2325 | Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); } |
2326 | Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); } |
2327 | Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); } |
2328 | Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); } |
2329 | Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); } |
2330 | Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); } |
2331 | Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); } |
2332 | |
2333 | Q_DECL_CONSTEXPR inline bool operator!() const { return !i; } |
2334 | |
2335 | inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); } |
2336 | }; |
2337 | |
2338 | #define Q_DECLARE_FLAGS(Flags, Enum)\ |
2339 | typedef QFlags<Enum> Flags; |
2340 | |
2341 | #define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \ |
2342 | inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \ |
2343 | { return QIncompatibleFlag(int(f1) | f2); } |
2344 | |
2345 | #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \ |
2346 | Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \ |
2347 | { return QFlags<Flags::enum_type>(f1) | f2; } \ |
2348 | Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \ |
2349 | { return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) |
2350 | |
2351 | |
2352 | #else /* Q_NO_TYPESAFE_FLAGS */ |
2353 | |
2354 | #define Q_DECLARE_FLAGS(Flags, Enum)\ |
2355 | typedef uint Flags; |
2356 | #define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) |
2357 | |
2358 | #endif /* Q_NO_TYPESAFE_FLAGS */ |
2359 | |
2360 | #if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT) |
2361 | /* make use of typeof-extension */ |
2362 | template <typename T> |
2363 | class QForeachContainer { |
2364 | public: |
2365 | inline QForeachContainer(const T& t) : c(t), brk(0), i(c.begin()), e(c.end()) { } |
2366 | const T c; |
2367 | int brk; |
2368 | typename T::const_iterator i, e; |
2369 | }; |
2370 | |
2371 | #define Q_FOREACH(variable, container) \ |
2372 | for (QForeachContainer<__typeof__(container)> _container_(container); \ |
2373 | !_container_.brk && _container_.i != _container_.e; \ |
2374 | __extension__ ({ ++_container_.brk; ++_container_.i; })) \ |
2375 | for (variable = *_container_.i;; __extension__ ({--_container_.brk; break;})) |
2376 | |
2377 | #else |
2378 | |
2379 | struct QForeachContainerBase {}; |
2380 | |
2381 | template <typename T> |
2382 | class QForeachContainer : public QForeachContainerBase { |
2383 | public: |
2384 | inline QForeachContainer(const T& t): c(t), brk(0), i(c.begin()), e(c.end()){}; |
2385 | const T c; |
2386 | mutable int brk; |
2387 | mutable typename T::const_iterator i, e; |
2388 | inline bool condition() const { return (!brk++ && i != e); } |
2389 | }; |
2390 | |
2391 | template <typename T> inline T *qForeachPointer(const T &) { return 0; } |
2392 | |
2393 | template <typename T> inline QForeachContainer<T> qForeachContainerNew(const T& t) |
2394 | { return QForeachContainer<T>(t); } |
2395 | |
2396 | template <typename T> |
2397 | inline const QForeachContainer<T> *qForeachContainer(const QForeachContainerBase *base, const T *) |
2398 | { return static_cast<const QForeachContainer<T> *>(base); } |
2399 | |
2400 | #if defined(Q_CC_MIPS) |
2401 | /* |
2402 | Proper for-scoping in MIPSpro CC |
2403 | */ |
2404 | # define Q_FOREACH(variable,container) \ |
2405 | if(0){}else \ |
2406 | for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ |
2407 | qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \ |
2408 | ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \ |
2409 | for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \ |
2410 | qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \ |
2411 | --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk) |
2412 | |
2413 | #elif defined(Q_CC_DIAB) |
2414 | // VxWorks DIAB generates unresolvable symbols, if container is a function call |
2415 | # define Q_FOREACH(variable,container) \ |
2416 | if(0){}else \ |
2417 | for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ |
2418 | qForeachContainer(&_container_, (__typeof__(container) *) 0)->condition(); \ |
2419 | ++qForeachContainer(&_container_, (__typeof__(container) *) 0)->i) \ |
2420 | for (variable = *qForeachContainer(&_container_, (__typeof__(container) *) 0)->i; \ |
2421 | qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk; \ |
2422 | --qForeachContainer(&_container_, (__typeof__(container) *) 0)->brk) |
2423 | |
2424 | #else |
2425 | # define Q_FOREACH(variable, container) \ |
2426 | for (const QForeachContainerBase &_container_ = qForeachContainerNew(container); \ |
2427 | qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->condition(); \ |
2428 | ++qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i) \ |
2429 | for (variable = *qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->i; \ |
2430 | qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk; \ |
2431 | --qForeachContainer(&_container_, true ? 0 : qForeachPointer(container))->brk) |
2432 | #endif // MSVC6 || MIPSpro |
2433 | |
2434 | #endif |
2435 | |
2436 | #define Q_FOREVER for(;;) |
2437 | #ifndef QT_NO_KEYWORDS |
2438 | # ifndef foreach |
2439 | # define foreach Q_FOREACH |
2440 | # endif |
2441 | # ifndef forever |
2442 | # define forever Q_FOREVER |
2443 | # endif |
2444 | #endif |
2445 | |
2446 | #if 0 |
2447 | /* tell gcc to use its built-in methods for some common functions */ |
2448 | #if defined(QT_NO_DEBUG) && defined(Q_CC_GNU) |
2449 | # define qMemCopy __builtin_memcpy |
2450 | # define qMemSet __builtin_memset |
2451 | #endif |
2452 | #endif |
2453 | |
2454 | template <typename T> static inline T *qGetPtrHelper(T *ptr) { return ptr; } |
2455 | template <typename Wrapper> static inline typename Wrapper::pointer qGetPtrHelper(const Wrapper &p) { return p.data(); } |
2456 | |
2457 | #define Q_DECLARE_PRIVATE(Class) \ |
2458 | inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(qGetPtrHelper(d_ptr)); } \ |
2459 | inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(qGetPtrHelper(d_ptr)); } \ |
2460 | friend class Class##Private; |
2461 | |
2462 | #define Q_DECLARE_PRIVATE_D(Dptr, Class) \ |
2463 | inline Class##Private* d_func() { return reinterpret_cast<Class##Private *>(Dptr); } \ |
2464 | inline const Class##Private* d_func() const { return reinterpret_cast<const Class##Private *>(Dptr); } \ |
2465 | friend class Class##Private; |
2466 | |
2467 | #define Q_DECLARE_PUBLIC(Class) \ |
2468 | inline Class* q_func() { return static_cast<Class *>(q_ptr); } \ |
2469 | inline const Class* q_func() const { return static_cast<const Class *>(q_ptr); } \ |
2470 | friend class Class; |
2471 | |
2472 | #define Q_D(Class) Class##Private * const d = d_func() |
2473 | #define Q_Q(Class) Class * const q = q_func() |
2474 | |
2475 | #define QT_TR_NOOP(x) (x) |
2476 | #define QT_TR_NOOP_UTF8(x) (x) |
2477 | #define QT_TRANSLATE_NOOP(scope, x) (x) |
2478 | #define QT_TRANSLATE_NOOP_UTF8(scope, x) (x) |
2479 | #define QT_TRANSLATE_NOOP3(scope, x, comment) {x, comment} |
2480 | #define QT_TRANSLATE_NOOP3_UTF8(scope, x, comment) {x, comment} |
2481 | |
2482 | #ifndef QT_NO_TRANSLATION // ### This should enclose the NOOPs above |
2483 | |
2484 | // Defined in qcoreapplication.cpp |
2485 | // The better name qTrId() is reserved for an upcoming function which would |
2486 | // return a much more powerful QStringFormatter instead of a QString. |
2487 | Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1); |
2488 | |
2489 | #define QT_TRID_NOOP(id) id |
2490 | |
2491 | #endif // QT_NO_TRANSLATION |
2492 | |
2493 | #define QDOC_PROPERTY(text) |
2494 | |
2495 | /* |
2496 | When RTTI is not available, define this macro to force any uses of |
2497 | dynamic_cast to cause a compile failure. |
2498 | */ |
2499 | |
2500 | #ifdef QT_NO_DYNAMIC_CAST |
2501 | # define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check) |
2502 | |
2503 | template<typename T, typename X> |
2504 | T qt_dynamic_cast_check(X, T* = 0) |
2505 | { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; } |
2506 | #endif |
2507 | |
2508 | /* |
2509 | Some classes do not permit copies to be made of an object. These |
2510 | classes contains a private copy constructor and assignment |
2511 | operator to disable copying (the compiler gives an error message). |
2512 | */ |
2513 | #define Q_DISABLE_COPY(Class) \ |
2514 | Class(const Class &); \ |
2515 | Class &operator=(const Class &); |
2516 | |
2517 | class QByteArray; |
2518 | Q_CORE_EXPORT QByteArray qgetenv(const char *varName); |
2519 | Q_CORE_EXPORT bool qputenv(const char *varName, const QByteArray& value); |
2520 | |
2521 | inline int qIntCast(double f) { return int(f); } |
2522 | inline int qIntCast(float f) { return int(f); } |
2523 | |
2524 | /* |
2525 | Reentrant versions of basic rand() functions for random number generation |
2526 | */ |
2527 | Q_CORE_EXPORT void qsrand(uint seed); |
2528 | Q_CORE_EXPORT int qrand(); |
2529 | |
2530 | /* |
2531 | Compat functions that were generated by configure |
2532 | */ |
2533 | #ifdef QT3_SUPPORT |
2534 | #ifndef QT_PRODUCT_LICENSEE |
2535 | # define QT_PRODUCT_LICENSEE QLibraryInfo::licensee() |
2536 | #endif |
2537 | #ifndef QT_PRODUCT_LICENSE |
2538 | # define QT_PRODUCT_LICENSE QLibraryInfo::licensedProducts() |
2539 | #endif |
2540 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPath(); |
2541 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathDocs(); |
2542 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathHeaders(); |
2543 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathLibs(); |
2544 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathBins(); |
2545 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathPlugins(); |
2546 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathData(); |
2547 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathTranslations(); |
2548 | QT3_SUPPORT Q_CORE_EXPORT const char *qInstallPathSysconf(); |
2549 | #endif |
2550 | |
2551 | #if defined(Q_OS_SYMBIAN) |
2552 | |
2553 | #ifdef SYMBIAN_BUILD_GCE |
2554 | #define Q_SYMBIAN_SUPPORTS_SURFACES |
2555 | //RWsPointerCursor is fixed, so don't use low performance sprites |
2556 | #define Q_SYMBIAN_FIXED_POINTER_CURSORS |
2557 | #define Q_SYMBIAN_HAS_EXTENDED_BITMAP_TYPE |
2558 | #define Q_SYMBIAN_WINDOW_SIZE_CACHE |
2559 | #define QT_SYMBIAN_SUPPORTS_ADVANCED_POINTER |
2560 | |
2561 | //enabling new graphics resources |
2562 | #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE |
2563 | # define QT_SYMBIAN_SUPPORTS_SGIMAGE |
2564 | #endif |
2565 | |
2566 | #ifdef SYMBIAN_GRAPHICS_SET_SURFACE_TRANSPARENCY_AVAILABLE |
2567 | # define Q_SYMBIAN_SEMITRANSPARENT_BG_SURFACE |
2568 | #endif |
2569 | |
2570 | #ifdef SYMBIAN_GRAPHICS_TRANSITION_EFFECTS_SIGNALING_AVAILABLE |
2571 | # define Q_SYMBIAN_TRANSITION_EFFECTS |
2572 | #endif |
2573 | #endif |
2574 | |
2575 | #ifdef SYMBIAN_WSERV_AND_CONE_MULTIPLE_SCREENS |
2576 | #define Q_SYMBIAN_SUPPORTS_MULTIPLE_SCREENS |
2577 | #endif |
2578 | |
2579 | #ifdef SYMBIAN_GRAPHICS_FIXNATIVEORIENTATION |
2580 | #define Q_SYMBIAN_SUPPORTS_FIXNATIVEORIENTATION |
2581 | #endif |
2582 | |
2583 | //Symbian does not support data imports from a DLL |
2584 | #define Q_NO_DATA_RELOCATION |
2585 | |
2586 | // Winscw compiler is unable to compile QtConcurrent. |
2587 | #ifdef Q_CC_NOKIAX86 |
2588 | #ifndef QT_NO_CONCURRENT |
2589 | #define QT_NO_CONCURRENT |
2590 | #endif |
2591 | #ifndef QT_NO_QFUTURE |
2592 | #define QT_NO_QFUTURE |
2593 | #endif |
2594 | #endif |
2595 | |
2596 | QT_END_NAMESPACE |
2597 | // forward declare std::exception |
2598 | #ifdef __cplusplus |
2599 | namespace std { class exception; } |
2600 | #endif |
2601 | QT_BEGIN_NAMESPACE |
2602 | Q_CORE_EXPORT void qt_symbian_throwIfError(int error); |
2603 | Q_CORE_EXPORT void qt_symbian_exception2LeaveL(const std::exception& ex); |
2604 | Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex); |
2605 | |
2606 | #define QT_TRAP_THROWING(_f) \ |
2607 | { \ |
2608 | TInt ____error; \ |
2609 | TRAP(____error, _f); \ |
2610 | qt_symbian_throwIfError(____error); \ |
2611 | } |
2612 | |
2613 | #define QT_TRYCATCH_ERROR(_err, _f) \ |
2614 | { \ |
2615 | _err = KErrNone; \ |
2616 | try { \ |
2617 | _f; \ |
2618 | } catch (const std::exception &____ex) { \ |
2619 | _err = qt_symbian_exception2Error(____ex); \ |
2620 | } \ |
2621 | } |
2622 | |
2623 | #define QT_TRYCATCH_LEAVING(_f) \ |
2624 | { \ |
2625 | TInt ____err; \ |
2626 | QT_TRYCATCH_ERROR(____err, _f) \ |
2627 | User::LeaveIfError(____err); \ |
2628 | } |
2629 | #endif |
2630 | |
2631 | |
2632 | /* |
2633 | This gives us the possibility to check which modules the user can |
2634 | use. These are purely compile time checks and will generate no code. |
2635 | */ |
2636 | |
2637 | /* Qt modules */ |
2638 | #define QT_MODULE_CORE 0x00001 |
2639 | #define QT_MODULE_GUI 0x00002 |
2640 | #define QT_MODULE_NETWORK 0x00004 |
2641 | #define QT_MODULE_OPENGL 0x00008 |
2642 | #define QT_MODULE_SQL 0x00010 |
2643 | #define QT_MODULE_XML 0x00020 |
2644 | #define QT_MODULE_QT3SUPPORTLIGHT 0x00040 |
2645 | #define QT_MODULE_QT3SUPPORT 0x00080 |
2646 | #define QT_MODULE_SVG 0x00100 |
2647 | #define QT_MODULE_ACTIVEQT 0x00200 |
2648 | #define QT_MODULE_GRAPHICSVIEW 0x00400 |
2649 | #define QT_MODULE_SCRIPT 0x00800 |
2650 | #define QT_MODULE_XMLPATTERNS 0x01000 |
2651 | #define QT_MODULE_HELP 0x02000 |
2652 | #define QT_MODULE_TEST 0x04000 |
2653 | #define QT_MODULE_DBUS 0x08000 |
2654 | #define QT_MODULE_SCRIPTTOOLS 0x10000 |
2655 | #define QT_MODULE_OPENVG 0x20000 |
2656 | #define QT_MODULE_MULTIMEDIA 0x40000 |
2657 | #define QT_MODULE_DECLARATIVE 0x80000 |
2658 | |
2659 | /* Qt editions */ |
2660 | #define QT_EDITION_CONSOLE (QT_MODULE_CORE \ |
2661 | | QT_MODULE_NETWORK \ |
2662 | | QT_MODULE_SQL \ |
2663 | | QT_MODULE_SCRIPT \ |
2664 | | QT_MODULE_MULTIMEDIA \ |
2665 | | QT_MODULE_XML \ |
2666 | | QT_MODULE_XMLPATTERNS \ |
2667 | | QT_MODULE_TEST \ |
2668 | | QT_MODULE_DBUS) |
2669 | #define QT_EDITION_DESKTOPLIGHT (QT_MODULE_CORE \ |
2670 | | QT_MODULE_GUI \ |
2671 | | QT_MODULE_QT3SUPPORTLIGHT \ |
2672 | | QT_MODULE_TEST \ |
2673 | | QT_MODULE_DBUS) |
2674 | #define QT_EDITION_OPENSOURCE (QT_MODULE_CORE \ |
2675 | | QT_MODULE_GUI \ |
2676 | | QT_MODULE_NETWORK \ |
2677 | | QT_MODULE_OPENGL \ |
2678 | | QT_MODULE_OPENVG \ |
2679 | | QT_MODULE_SQL \ |
2680 | | QT_MODULE_MULTIMEDIA \ |
2681 | | QT_MODULE_XML \ |
2682 | | QT_MODULE_XMLPATTERNS \ |
2683 | | QT_MODULE_SCRIPT \ |
2684 | | QT_MODULE_SCRIPTTOOLS \ |
2685 | | QT_MODULE_QT3SUPPORTLIGHT \ |
2686 | | QT_MODULE_QT3SUPPORT \ |
2687 | | QT_MODULE_SVG \ |
2688 | | QT_MODULE_DECLARATIVE \ |
2689 | | QT_MODULE_GRAPHICSVIEW \ |
2690 | | QT_MODULE_HELP \ |
2691 | | QT_MODULE_TEST \ |
2692 | | QT_MODULE_DBUS \ |
2693 | | QT_MODULE_ACTIVEQT) |
2694 | #define QT_EDITION_DESKTOP (QT_EDITION_OPENSOURCE) |
2695 | #define QT_EDITION_UNIVERSAL QT_EDITION_DESKTOP |
2696 | #define QT_EDITION_ACADEMIC QT_EDITION_DESKTOP |
2697 | #define QT_EDITION_EDUCATIONAL QT_EDITION_DESKTOP |
2698 | #define QT_EDITION_EVALUATION QT_EDITION_DESKTOP |
2699 | |
2700 | /* Determine which modules can be used */ |
2701 | #ifndef QT_EDITION |
2702 | # ifdef QT_BUILD_QMAKE |
2703 | # define QT_EDITION QT_EDITION_DESKTOP |
2704 | # else |
2705 | # error "Qt not configured correctly, please run configure" |
2706 | # endif |
2707 | #endif |
2708 | |
2709 | #define QT_LICENSED_MODULE(x) \ |
2710 | enum QtValidLicenseFor##x##Module { Licensed##x = true }; |
2711 | |
2712 | /* qdoc is really unhappy with the following block of preprocessor checks, |
2713 | making it difficult to document classes properly after this point. */ |
2714 | |
2715 | #if (QT_EDITION & QT_MODULE_CORE) |
2716 | QT_LICENSED_MODULE(Core) |
2717 | #endif |
2718 | #if (QT_EDITION & QT_MODULE_GUI) |
2719 | QT_LICENSED_MODULE(Gui) |
2720 | #endif |
2721 | #if (QT_EDITION & QT_MODULE_NETWORK) |
2722 | QT_LICENSED_MODULE(Network) |
2723 | #endif |
2724 | #if (QT_EDITION & QT_MODULE_OPENGL) |
2725 | QT_LICENSED_MODULE(OpenGL) |
2726 | #endif |
2727 | #if (QT_EDITION & QT_MODULE_OPENVG) |
2728 | QT_LICENSED_MODULE(OpenVG) |
2729 | #endif |
2730 | #if (QT_EDITION & QT_MODULE_SQL) |
2731 | QT_LICENSED_MODULE(Sql) |
2732 | #endif |
2733 | #if (QT_EDITION & QT_MODULE_MULTIMEDIA) |
2734 | QT_LICENSED_MODULE(Multimedia) |
2735 | #endif |
2736 | #if (QT_EDITION & QT_MODULE_XML) |
2737 | QT_LICENSED_MODULE(Xml) |
2738 | #endif |
2739 | #if (QT_EDITION & QT_MODULE_XMLPATTERNS) |
2740 | QT_LICENSED_MODULE(XmlPatterns) |
2741 | #endif |
2742 | #if (QT_EDITION & QT_MODULE_HELP) |
2743 | QT_LICENSED_MODULE(Help) |
2744 | #endif |
2745 | #if (QT_EDITION & QT_MODULE_SCRIPT) || defined(QT_BUILD_QMAKE) |
2746 | QT_LICENSED_MODULE(Script) |
2747 | #endif |
2748 | #if (QT_EDITION & QT_MODULE_SCRIPTTOOLS) |
2749 | QT_LICENSED_MODULE(ScriptTools) |
2750 | #endif |
2751 | #if (QT_EDITION & QT_MODULE_QT3SUPPORTLIGHT) |
2752 | QT_LICENSED_MODULE(Qt3SupportLight) |
2753 | #endif |
2754 | #if (QT_EDITION & QT_MODULE_QT3SUPPORT) |
2755 | QT_LICENSED_MODULE(Qt3Support) |
2756 | #endif |
2757 | #if (QT_EDITION & QT_MODULE_SVG) |
2758 | QT_LICENSED_MODULE(Svg) |
2759 | #endif |
2760 | #if (QT_EDITION & QT_MODULE_DECLARATIVE) |
2761 | QT_LICENSED_MODULE(Declarative) |
2762 | #endif |
2763 | #if (QT_EDITION & QT_MODULE_ACTIVEQT) |
2764 | QT_LICENSED_MODULE(ActiveQt) |
2765 | #endif |
2766 | #if (QT_EDITION & QT_MODULE_TEST) |
2767 | QT_LICENSED_MODULE(Test) |
2768 | #endif |
2769 | #if (QT_EDITION & QT_MODULE_DBUS) |
2770 | QT_LICENSED_MODULE(DBus) |
2771 | #endif |
2772 | |
2773 | #define QT_MODULE(x) \ |
2774 | typedef QtValidLicenseFor##x##Module Qt##x##Module; |
2775 | |
2776 | #ifdef QT_NO_CONCURRENT |
2777 | # define QT_NO_QFUTURE |
2778 | #endif |
2779 | |
2780 | // gcc 3 version has problems with some of the |
2781 | // map/filter overloads. |
2782 | #if defined(Q_CC_GNU) && (__GNUC__ < 4) |
2783 | # define QT_NO_CONCURRENT_MAP |
2784 | # define QT_NO_CONCURRENT_FILTER |
2785 | #endif |
2786 | |
2787 | #if defined (__ELF__) |
2788 | # if defined (Q_OS_LINUX) || defined (Q_OS_SOLARIS) || defined (Q_OS_FREEBSD) || defined (Q_OS_OPENBSD) || defined (Q_OS_IRIX) |
2789 | # define Q_OF_ELF |
2790 | # endif |
2791 | #endif |
2792 | |
2793 | #if !(defined(Q_WS_WIN) && !defined(Q_WS_WINCE)) \ |
2794 | && !(defined(Q_WS_MAC) && defined(QT_MAC_USE_COCOA)) \ |
2795 | && !(defined(Q_WS_X11) && !defined(QT_NO_FREETYPE)) \ |
2796 | && !(defined(Q_WS_QPA)) |
2797 | # define QT_NO_RAWFONT |
2798 | #endif |
2799 | |
2800 | namespace QtPrivate { |
2801 | //like std::enable_if |
2802 | template <bool B, typename T = void> struct QEnableIf; |
2803 | template <typename T> struct QEnableIf<true, T> { typedef T Type; }; |
2804 | } |
2805 | |
2806 | QT_END_NAMESPACE |
2807 | QT_END_HEADER |
2808 | |
2809 | #endif /* __cplusplus */ |
2810 | |
2811 | #endif /* QGLOBAL_H */ |
2812 | |