summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@nokia.com>2012-04-16 12:04:34 +0200
committerLars Knoll <lars.knoll@nokia.com>2012-04-16 12:04:34 +0200
commit9bd032355163d92cda5e7e59ecd21214b131f187 (patch)
tree002fa12558505683143c7eb08949a3d225bf0712 /src/corelib/global
parentd037d25c3d5236623371cf051aaf6a9e59792ba7 (diff)
parent41673c45dde2eb95ee21dd918235218399f2be2c (diff)
Merge remote-tracking branch 'origin/master' into api_changes
Conflicts: configure src/corelib/io/qurl.cpp src/gui/kernel/qwindow.cpp src/tools/moc/generator.cpp src/widgets/kernel/qwidget_qpa.cpp src/widgets/styles/qstyle.h src/widgets/widgets/qtabbar.cpp tests/auto/corelib/codecs/utf8/tst_utf8.cpp Change-Id: Ia457228d6f684ec8184e13e8fcc9d25857b1751e
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/global.pri3
-rw-r--r--src/corelib/global/qcompilerdetection.h6
-rw-r--r--src/corelib/global/qflags.h139
-rw-r--r--src/corelib/global/qglobal.cpp13
-rw-r--r--src/corelib/global/qglobal.h86
-rw-r--r--src/corelib/global/qlibraryinfo.h2
-rw-r--r--src/corelib/global/qnamespace.h2
-rw-r--r--src/corelib/global/qsysinfo.h2
8 files changed, 162 insertions, 91 deletions
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 58cff6b81c..28a1a390b7 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -13,7 +13,8 @@ HEADERS += \
global/qtypeinfo.h \
global/qsysinfo.h \
global/qisenum.h \
- global/qtypetraits.h
+ global/qtypetraits.h \
+ global/qflags.h
SOURCES += \
global/qglobal.cpp \
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index 315f53cbb4..6d7635ef67 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -157,8 +157,10 @@
# define Q_UNREACHABLE() __builtin_unreachable()
# else
/* Plain GCC */
-# define Q_ASSUME(expr) if (expr){} else __builtin_unreachable()
-# define Q_UNREACHABLE() __builtin_unreachable()
+# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
+# define Q_ASSUME(expr) if (expr){} else __builtin_unreachable()
+# define Q_UNREACHABLE() __builtin_unreachable()
+# endif
# endif
# define Q_ALIGNOF(type) __alignof__(type)
diff --git a/src/corelib/global/qflags.h b/src/corelib/global/qflags.h
new file mode 100644
index 0000000000..349f227002
--- /dev/null
+++ b/src/corelib/global/qflags.h
@@ -0,0 +1,139 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QFLAGS_H
+#define QFLAGS_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QFlag
+{
+ int i;
+public:
+ inline QFlag(int i);
+ inline operator int() const { return i; }
+};
+
+inline QFlag::QFlag(int ai) : i(ai) {}
+
+class QIncompatibleFlag
+{
+ int i;
+public:
+ inline explicit QIncompatibleFlag(int i);
+ inline operator int() const { return i; }
+};
+
+inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
+
+
+#ifndef Q_NO_TYPESAFE_FLAGS
+
+template<typename Enum>
+class QFlags
+{
+ typedef void **Zero;
+ int i;
+public:
+ typedef Enum enum_type;
+ // compiler-generated copy/move ctor/assignment operators are fine!
+#ifdef qdoc
+ inline QFlags(const QFlags &other);
+ inline QFlags &operator=(const QFlags &other);
+#endif
+ Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
+ Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
+ inline QFlags(QFlag f) : i(f) {}
+
+ inline QFlags &operator&=(int mask) { i &= mask; return *this; }
+ inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
+ inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
+ inline QFlags &operator|=(Enum f) { i |= f; return *this; }
+ inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
+ inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
+
+ Q_DECL_CONSTEXPR inline operator int() const { return i; }
+
+ Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
+ Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); }
+ Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
+ Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); }
+ Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
+ Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
+ Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); }
+ Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
+
+ Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
+
+ inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
+};
+
+#define Q_DECLARE_FLAGS(Flags, Enum)\
+typedef QFlags<Enum> Flags;
+
+#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
+inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
+{ return QIncompatibleFlag(int(f1) | f2); }
+
+#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
+Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
+{ return QFlags<Flags::enum_type>(f1) | f2; } \
+Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
+{ return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
+
+
+#else /* Q_NO_TYPESAFE_FLAGS */
+
+#define Q_DECLARE_FLAGS(Flags, Enum)\
+typedef uint Flags;
+#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
+
+#endif /* Q_NO_TYPESAFE_FLAGS */
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QFLAGS_H
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 51849d701a..74c65d2504 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1711,6 +1711,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_VISTA;
} else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 1) {
winver = QSysInfo::WV_WINDOWS7;
+ } else if (osver.dwMajorVersion == 6 && osver.dwMinorVersion == 2) {
+ winver = QSysInfo::WV_WINDOWS8;
} else {
qWarning("Qt: Untested Windows version %d.%d detected!",
int(osver.dwMajorVersion), int(osver.dwMinorVersion));
@@ -1742,6 +1744,8 @@ QSysInfo::WinVersion QSysInfo::windowsVersion()
winver = QSysInfo::WV_VISTA;
else if (override == "WINDOWS7")
winver = QSysInfo::WV_WINDOWS7;
+ else if (override == "WINDOWS8")
+ winver = QSysInfo::WV_WINDOWS8;
}
#endif
@@ -2511,7 +2515,9 @@ int qrand()
\list
\li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old
- data) type with no constructor or destructor.
+ data) type with no constructor or destructor, or else a type where
+ every bit pattern is a valid object and memcpy() creates a valid
+ independent copy of the object.
\li \c Q_MOVABLE_TYPE specifies that \a Type has a constructor
and/or a destructor but can be moved in memory using \c
memcpy().
@@ -2524,6 +2530,11 @@ int qrand()
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 38
+ An example of a non-POD "primitive" type is QUuid: Even though
+ QUuid has constructors (and therefore isn't POD), every bit
+ pattern still represents a valid object, and memcpy() can be used
+ to create a valid independent copy of a QUuid object.
+
Example of a movable type:
\snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp 39
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 0648b08d1f..0828a3dac3 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -1231,90 +1231,6 @@ Q_CORE_EXPORT void qFreeAligned(void *ptr);
# endif
#endif
-class Q_CORE_EXPORT QFlag
-{
- int i;
-public:
- inline QFlag(int i);
- inline operator int() const { return i; }
-};
-
-inline QFlag::QFlag(int ai) : i(ai) {}
-
-class Q_CORE_EXPORT QIncompatibleFlag
-{
- int i;
-public:
- inline explicit QIncompatibleFlag(int i);
- inline operator int() const { return i; }
-};
-
-inline QIncompatibleFlag::QIncompatibleFlag(int ai) : i(ai) {}
-
-
-#ifndef Q_NO_TYPESAFE_FLAGS
-
-template<typename Enum>
-class QFlags
-{
- typedef void **Zero;
- int i;
-public:
- typedef Enum enum_type;
- // compiler-generated copy/move ctor/assignment operators are fine!
-#ifdef qdoc
- inline QFlags(const QFlags &other);
- inline QFlags &operator=(const QFlags &other);
-#endif
- Q_DECL_CONSTEXPR inline QFlags(Enum f) : i(f) {}
- Q_DECL_CONSTEXPR inline QFlags(Zero = 0) : i(0) {}
- inline QFlags(QFlag f) : i(f) {}
-
- inline QFlags &operator&=(int mask) { i &= mask; return *this; }
- inline QFlags &operator&=(uint mask) { i &= mask; return *this; }
- inline QFlags &operator|=(QFlags f) { i |= f.i; return *this; }
- inline QFlags &operator|=(Enum f) { i |= f; return *this; }
- inline QFlags &operator^=(QFlags f) { i ^= f.i; return *this; }
- inline QFlags &operator^=(Enum f) { i ^= f; return *this; }
-
- Q_DECL_CONSTEXPR inline operator int() const { return i; }
-
- Q_DECL_CONSTEXPR inline QFlags operator|(QFlags f) const { return QFlags(Enum(i | f.i)); }
- Q_DECL_CONSTEXPR inline QFlags operator|(Enum f) const { return QFlags(Enum(i | f)); }
- Q_DECL_CONSTEXPR inline QFlags operator^(QFlags f) const { return QFlags(Enum(i ^ f.i)); }
- Q_DECL_CONSTEXPR inline QFlags operator^(Enum f) const { return QFlags(Enum(i ^ f)); }
- Q_DECL_CONSTEXPR inline QFlags operator&(int mask) const { return QFlags(Enum(i & mask)); }
- Q_DECL_CONSTEXPR inline QFlags operator&(uint mask) const { return QFlags(Enum(i & mask)); }
- Q_DECL_CONSTEXPR inline QFlags operator&(Enum f) const { return QFlags(Enum(i & f)); }
- Q_DECL_CONSTEXPR inline QFlags operator~() const { return QFlags(Enum(~i)); }
-
- Q_DECL_CONSTEXPR inline bool operator!() const { return !i; }
-
- inline bool testFlag(Enum f) const { return (i & f) == f && (f != 0 || i == int(f) ); }
-};
-
-#define Q_DECLARE_FLAGS(Flags, Enum)\
-typedef QFlags<Enum> Flags;
-
-#define Q_DECLARE_INCOMPATIBLE_FLAGS(Flags) \
-inline QIncompatibleFlag operator|(Flags::enum_type f1, int f2) \
-{ return QIncompatibleFlag(int(f1) | f2); }
-
-#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags) \
-Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, Flags::enum_type f2) \
-{ return QFlags<Flags::enum_type>(f1) | f2; } \
-Q_DECL_CONSTEXPR inline QFlags<Flags::enum_type> operator|(Flags::enum_type f1, QFlags<Flags::enum_type> f2) \
-{ return f2 | f1; } Q_DECLARE_INCOMPATIBLE_FLAGS(Flags)
-
-
-#else /* Q_NO_TYPESAFE_FLAGS */
-
-#define Q_DECLARE_FLAGS(Flags, Enum)\
-typedef uint Flags;
-#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
-
-#endif /* Q_NO_TYPESAFE_FLAGS */
-
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_RVCT)
/* make use of typeof-extension */
template <typename T>
@@ -1495,7 +1411,7 @@ QT_END_HEADER
// qDebug and friends
#include <QtCore/qlogging.h>
-
+#include <QtCore/qflags.h>
#include <QtCore/qsysinfo.h>
#include <QtCore/qtypeinfo.h>
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index d180e63198..5666afbad8 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -88,7 +88,7 @@ public:
#endif
SettingsPath = 100
};
- static QString location(LibraryLocation); // ### Qt 5: consider renaming it to path()
+ static QString location(LibraryLocation); // ### Qt 6: consider renaming it to path()
#ifdef QT_BUILD_QMAKE
static QString rawLocation(LibraryLocation);
#endif
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index edf8a165a0..c238e9a5f3 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -153,7 +153,7 @@ public:
NoButton = 0x00000000,
LeftButton = 0x00000001,
RightButton = 0x00000002,
- MidButton = 0x00000004, // ### Qt 5: remove me
+ MidButton = 0x00000004, // ### Qt 6: remove me
MiddleButton = MidButton,
XButton1 = 0x00000008,
BackButton = XButton1,
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index 74c8d1de7f..2c9ce39430 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -96,6 +96,7 @@ public:
WV_2003 = 0x0040,
WV_VISTA = 0x0080,
WV_WINDOWS7 = 0x0090,
+ WV_WINDOWS8 = 0x00a0,
WV_NT_based = 0x00f0,
/* version numbers */
@@ -105,6 +106,7 @@ public:
WV_5_2 = WV_2003,
WV_6_0 = WV_VISTA,
WV_6_1 = WV_WINDOWS7,
+ WV_6_2 = WV_WINDOWS8,
WV_CE = 0x0100,
WV_CENET = 0x0200,