[Development] Qt 5.2 header diff: QtCore
Thiago Macieira
thiago.macieira at intel.com
Tue Nov 5 01:07:32 CET 2013
Pastebin URL (expires in 24 hours):
http://paste.fedoraproject.org/51625/61016513
---
diff --git a/src/corelib/arch/qatomic_alpha.h b/src/corelib/arch/qatomic_alpha.h
index 71cb112..5008a1a 100644
--- a/src/corelib/arch/qatomic_alpha.h
+++ b/src/corelib/arch/qatomic_alpha.h
@@ -114,7 +114,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
inline bool QBasicAtomicInt::ref()
{
- register int old, tmp;
+ int old, tmp;
asm volatile("1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
"addl %0,1,%1\n" /* tmp=old+1; */
@@ -131,7 +131,7 @@ inline bool QBasicAtomicInt::ref()
inline bool QBasicAtomicInt::deref()
{
- register int old, tmp;
+ int old, tmp;
asm volatile("1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
"subl %0,1,%1\n" /* tmp=old-1; */
@@ -148,7 +148,7 @@ inline bool QBasicAtomicInt::deref()
inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
- register int ret;
+ int ret;
asm volatile("1:\n"
"ldl_l %0,%1\n" /* ret=*ptr; */
"cmpeq %0,%2,%0\n"/* if (ret==expected) ret=0; else ret=1; */
@@ -167,7 +167,7 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
{
- register int ret;
+ int ret;
asm volatile("1:\n"
"ldl_l %0,%1\n" /* ret=*ptr; */
"cmpeq %0,%2,%0\n"/* if (ret==expected) ret=0; else ret=1; */
@@ -187,7 +187,7 @@ inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
{
- register int ret;
+ int ret;
asm volatile("mb\n"
"1:\n"
"ldl_l %0,%1\n" /* ret=*ptr; */
@@ -207,7 +207,7 @@ inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
{
- register int old, tmp;
+ int old, tmp;
asm volatile("1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
"mov %3,%1\n" /* tmp=newval; */
@@ -224,7 +224,7 @@ inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
{
- register int old, tmp;
+ int old, tmp;
asm volatile("1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
"mov %3,%1\n" /* tmp=newval; */
@@ -242,7 +242,7 @@ inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
{
- register int old, tmp;
+ int old, tmp;
asm volatile("mb\n"
"1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
@@ -260,7 +260,7 @@ inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
{
- register int old, tmp;
+ int old, tmp;
asm volatile("1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
"addl %0,%3,%1\n"/* tmp=old+value; */
@@ -277,7 +277,7 @@ inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
{
- register int old, tmp;
+ int old, tmp;
asm volatile("1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
"addl %0,%3,%1\n"/* tmp=old+value; */
@@ -295,7 +295,7 @@ inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
{
- register int old, tmp;
+ int old, tmp;
asm volatile("mb\n"
"1:\n"
"ldl_l %0,%2\n" /* old=*ptr; */
@@ -314,7 +314,7 @@ inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
- register void *ret;
+ void *ret;
asm volatile("1:\n"
"ldq_l %0,%1\n" /* ret=*ptr; */
"cmpeq %0,%2,%0\n"/* if (ret==expected) tmp=0; else tmp=1; */
@@ -334,7 +334,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
{
- register void *ret;
+ void *ret;
asm volatile("1:\n"
"ldq_l %0,%1\n" /* ret=*ptr; */
"cmpeq %0,%2,%0\n"/* if (ret==expected) tmp=0; else tmp=1; */
@@ -355,7 +355,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
{
- register void *ret;
+ void *ret;
asm volatile("mb\n"
"1:\n"
"ldq_l %0,%1\n" /* ret=*ptr; */
@@ -376,7 +376,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
{
- register T *old, *tmp;
+ T *old, *tmp;
asm volatile("1:\n"
"ldq_l %0,%2\n" /* old=*ptr; */
"mov %3,%1\n" /* tmp=newval; */
@@ -394,7 +394,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
{
- register T *old, *tmp;
+ T *old, *tmp;
asm volatile("1:\n"
"ldq_l %0,%2\n" /* old=*ptr; */
"mov %3,%1\n" /* tmp=newval; */
@@ -413,7 +413,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
{
- register T *old, *tmp;
+ T *old, *tmp;
asm volatile("mb\n"
"1:\n"
"ldq_l %0,%2\n" /* old=*ptr; */
@@ -432,7 +432,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
{
- register T *old, *tmp;
+ T *old, *tmp;
asm volatile("1:\n"
"ldq_l %0,%2\n" /* old=*ptr; */
"addq %0,%3,%1\n"/* tmp=old+value; */
@@ -450,7 +450,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueTo
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
{
- register T *old, *tmp;
+ T *old, *tmp;
asm volatile("1:\n"
"ldq_l %0,%2\n" /* old=*ptr; */
"addq %0,%3,%1\n"/* tmp=old+value; */
@@ -469,7 +469,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueTo
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
{
- register T *old, *tmp;
+ T *old, *tmp;
asm volatile("mb\n"
"1:\n"
"ldq_l %0,%2\n" /* old=*ptr; */
diff --git a/src/corelib/arch/qatomic_armv5.h b/src/corelib/arch/qatomic_armv5.h
index e0a50b3..b583ec6 100644
--- a/src/corelib/arch/qatomic_armv5.h
+++ b/src/corelib/arch/qatomic_armv5.h
@@ -114,8 +114,8 @@ template <typename T> struct QAtomicOps : QBasicAtomicOps<sizeof(T)>
template<> template<typename T> inline
bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
do {
originalValue = _q_value;
newValue = originalValue + 1;
@@ -126,8 +126,8 @@ bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
do {
originalValue = _q_value;
newValue = originalValue - 1;
@@ -138,7 +138,7 @@ bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
- register T originalValue;
+ T originalValue;
do {
originalValue = _q_value;
if (originalValue != expectedValue)
@@ -165,7 +165,7 @@ template<> template <typename T> inline
T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
#if defined(__thumb__)
- register T originalValue;
+ T originalValue;
do {
originalValue = _q_value;
} while (_q_cmpxchg(originalValue, newValue, &_q_value) != 0);
@@ -184,8 +184,8 @@ T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR
template<> template <typename T> inline
T QBasicAtomicOps<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
do {
originalValue = _q_value;
newValue = originalValue + valueToAdd;
diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h
index 7f5939e..08b2b02 100644
--- a/src/corelib/arch/qatomic_armv6.h
+++ b/src/corelib/arch/qatomic_armv6.h
@@ -117,8 +117,8 @@ template <typename T> struct QAtomicOps : QBasicAtomicOps<sizeof(T)>
template<> template<typename T> inline
bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrex %[newValue], [%[_q_value]]\n"
"add %[newValue], %[newValue], #1\n"
@@ -136,8 +136,8 @@ bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrex %[newValue], [%[_q_value]]\n"
"sub %[newValue], %[newValue], #1\n"
@@ -155,7 +155,7 @@ bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
- register int result;
+ int result;
asm volatile("0:\n"
"ldrex %[result], [%[_q_value]]\n"
"eors %[result], %[result], %[expectedValue]\n"
@@ -175,8 +175,8 @@ bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa
template<> template <typename T> inline
T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
- register T originalValue;
- register int result;
+ T originalValue;
+ int result;
asm volatile("0:\n"
"ldrex %[originalValue], [%[_q_value]]\n"
"strex %[result], %[newValue], [%[_q_value]]\n"
@@ -194,9 +194,9 @@ T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR
template<> template <typename T> inline
T QBasicAtomicOps<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
- register int result;
+ T originalValue;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrex %[originalValue], [%[_q_value]]\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
@@ -256,8 +256,8 @@ template<> struct QAtomicIntegerTraits<char32_t> { enum { IsInteger = 1 }; };
template<> template<typename T> inline
bool QBasicAtomicOps<1>::ref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexb %[newValue], [%[_q_value]]\n"
"add %[newValue], %[newValue], #1\n"
@@ -275,8 +275,8 @@ bool QBasicAtomicOps<1>::ref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<1>::deref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexb %[newValue], [%[_q_value]]\n"
"sub %[newValue], %[newValue], #1\n"
@@ -294,7 +294,7 @@ bool QBasicAtomicOps<1>::deref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<1>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
- register T result;
+ T result;
asm volatile("0:\n"
"ldrexb %[result], [%[_q_value]]\n"
"eors %[result], %[result], %[expectedValue]\n"
@@ -314,8 +314,8 @@ bool QBasicAtomicOps<1>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa
template<> template <typename T> inline
T QBasicAtomicOps<1>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
- register T originalValue;
- register int result;
+ T originalValue;
+ int result;
asm volatile("0:\n"
"ldrexb %[originalValue], [%[_q_value]]\n"
"strexb %[result], %[newValue], [%[_q_value]]\n"
@@ -333,9 +333,9 @@ T QBasicAtomicOps<1>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR
template<> template <typename T> inline
T QBasicAtomicOps<1>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
- register int result;
+ T originalValue;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexb %[originalValue], [%[_q_value]]\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
@@ -355,8 +355,8 @@ T QBasicAtomicOps<1>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveTy
template<> template<typename T> inline
bool QBasicAtomicOps<2>::ref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexh %[newValue], [%[_q_value]]\n"
"add %[newValue], %[newValue], #1\n"
@@ -374,8 +374,8 @@ bool QBasicAtomicOps<2>::ref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<2>::deref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexh %[newValue], [%[_q_value]]\n"
"sub %[newValue], %[newValue], #1\n"
@@ -393,7 +393,7 @@ bool QBasicAtomicOps<2>::deref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
- register T result;
+ T result;
asm volatile("0:\n"
"ldrexh %[result], [%[_q_value]]\n"
"eors %[result], %[result], %[expectedValue]\n"
@@ -413,8 +413,8 @@ bool QBasicAtomicOps<2>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa
template<> template <typename T> inline
T QBasicAtomicOps<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
- register T originalValue;
- register int result;
+ T originalValue;
+ int result;
asm volatile("0:\n"
"ldrexh %[originalValue], [%[_q_value]]\n"
"strexh %[result], %[newValue], [%[_q_value]]\n"
@@ -432,9 +432,9 @@ T QBasicAtomicOps<2>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR
template<> template <typename T> inline
T QBasicAtomicOps<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
- register int result;
+ T originalValue;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexh %[originalValue], [%[_q_value]]\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
@@ -462,8 +462,8 @@ T QBasicAtomicOps<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveTy
template<> template<typename T> inline
bool QBasicAtomicOps<8>::ref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexd %[newValue], %H[newValue], [%[_q_value]]\n"
"adds %Q[newValue], %Q[newValue], #1\n"
@@ -482,8 +482,8 @@ bool QBasicAtomicOps<8>::ref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<8>::deref(T &_q_value) Q_DECL_NOTHROW
{
- register T newValue;
- register int result;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexd %[newValue], %H[newValue], [%[_q_value]]\n"
"subs %Q[newValue], %Q[newValue], #1\n"
@@ -502,7 +502,7 @@ bool QBasicAtomicOps<8>::deref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
- register T result;
+ T result;
asm volatile("0:\n"
"ldrexd %[result], %H[result], [%[_q_value]]\n"
"eor %[result], %[result], %[expectedValue]\n"
@@ -524,8 +524,8 @@ bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa
template<> template <typename T> inline
T QBasicAtomicOps<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
- register T originalValue;
- register int result;
+ T originalValue;
+ int result;
asm volatile("0:\n"
"ldrexd %[originalValue], %H[originalValue], [%[_q_value]]\n"
"strexd %[result], %[newValue], %H[newValue], [%[_q_value]]\n"
@@ -543,9 +543,9 @@ T QBasicAtomicOps<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR
template<> template <typename T> inline
T QBasicAtomicOps<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
- register int result;
+ T originalValue;
+ T newValue;
+ int result;
asm volatile("0:\n"
"ldrexd %[originalValue], %H[originalValue], [%[_q_value]]\n"
"adds %Q[newValue], %Q[originalValue], %Q[valueToAdd]\n"
@@ -588,8 +588,8 @@ T QBasicAtomicOps<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveTy
inline bool QBasicAtomicInt::ref() Q_DECL_NOTHROW
{
- register int newValue;
- register int result;
+ int newValue;
+ int result;
retry:
__asm {
ldrex newValue, [&_q_value]
@@ -603,8 +603,8 @@ inline bool QBasicAtomicInt::ref() Q_DECL_NOTHROW
inline bool QBasicAtomicInt::deref() Q_DECL_NOTHROW
{
- register int newValue;
- register int result;
+ int newValue;
+ int result;
retry:
__asm {
ldrex newValue, [&_q_value]
@@ -618,7 +618,7 @@ inline bool QBasicAtomicInt::deref() Q_DECL_NOTHROW
inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue) Q_DECL_NOTHROW
{
- register int result;
+ int result;
retry:
__asm {
ldrex result, [&_q_value]
@@ -632,8 +632,8 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) Q_DECL_NOTHROW
{
- register int originalValue;
- register int result;
+ int originalValue;
+ int result;
retry:
__asm {
ldrex originalValue, [&_q_value]
@@ -646,9 +646,9 @@ inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue) Q_DECL_NOTHROW
inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) Q_DECL_NOTHROW
{
- register int originalValue;
- register int newValue;
- register int result;
+ int originalValue;
+ int newValue;
+ int result;
retry:
__asm {
ldrex originalValue, [&_q_value]
@@ -663,7 +663,7 @@ inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd) Q_DECL_NOTHROW
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue) Q_DECL_NOTHROW
{
- register T *result;
+ T *result;
retry:
__asm {
ldrex result, [&_q_value]
@@ -678,8 +678,8 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) Q_DECL_NOTHROW
{
- register T *originalValue;
- register int result;
+ T *originalValue;
+ int result;
retry:
__asm {
ldrex originalValue, [&_q_value]
@@ -693,9 +693,9 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue) Q
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd) Q_DECL_NOTHROW
{
- register T *originalValue;
- register T *newValue;
- register int result;
+ T *originalValue;
+ T *newValue;
+ int result;
retry:
__asm {
ldrex originalValue, [&_q_value]
diff --git a/src/corelib/arch/qatomic_cxx11.h b/src/corelib/arch/qatomic_cxx11.h
index 3119eda..55e71e1 100644
--- a/src/corelib/arch/qatomic_cxx11.h
+++ b/src/corelib/arch/qatomic_cxx11.h
@@ -105,56 +105,56 @@ template<> struct QAtomicIntegerTraits<char32_t> { enum { IsInteger = 1 }; };
#define Q_ATOMIC_INT64_FETCH_AND_STORE_IS_ALWAYS_NATIVE
#define Q_ATOMIC_INT64_FETCH_AND_ADD_IS_ALWAYS_NATIVE
-template <typename T> struct QAtomicOps
+template <typename X> struct QAtomicOps
{
- typedef std::atomic<T> Type;
- typedef typename QAtomicAdditiveType<T>::AdditiveT _AdditiveType;
- static const int AddScale = QAtomicAdditiveType<T>::AddScale;
+ typedef std::atomic<X> Type;
- static inline
- T load(const Type &_q_value) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T load(const std::atomic<T> &_q_value) Q_DECL_NOTHROW
{
return _q_value.load(std::memory_order_relaxed);
}
- static inline
- T load(const volatile Type &_q_value) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T load(const volatile std::atomic<T> &_q_value) Q_DECL_NOTHROW
{
return _q_value.load(std::memory_order_relaxed);
}
- static inline
- T loadAcquire(const Type &_q_value) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T loadAcquire(const std::atomic<T> &_q_value) Q_DECL_NOTHROW
{
return _q_value.load(std::memory_order_acquire);
}
- static inline
- T loadAcquire(const volatile Type &_q_value) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T loadAcquire(const volatile std::atomic<T> &_q_value) Q_DECL_NOTHROW
{
return _q_value.load(std::memory_order_acquire);
}
- static inline
- void store(Type &_q_value, T newValue) Q_DECL_NOTHROW
+ template <typename T> static inline
+ void store(std::atomic<T> &_q_value, T newValue) Q_DECL_NOTHROW
{
_q_value.store(newValue, std::memory_order_relaxed);
}
- static inline
- void storeRelease(Type &_q_value, T newValue) Q_DECL_NOTHROW
+ template <typename T> static inline
+ void storeRelease(std::atomic<T> &_q_value, T newValue) Q_DECL_NOTHROW
{
_q_value.store(newValue, std::memory_order_release);
}
static inline Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return true; }
static inline Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return false; }
- static inline bool ref(Type &_q_value)
+ template <typename T>
+ static inline bool ref(std::atomic<T> &_q_value)
{
return ++_q_value != 0;
}
- static inline bool deref(Type &_q_value) Q_DECL_NOTHROW
+ template <typename T>
+ static inline bool deref(std::atomic<T> &_q_value) Q_DECL_NOTHROW
{
return --_q_value != 0;
}
@@ -162,22 +162,25 @@ template <typename T> struct QAtomicOps
static inline Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
- static
+ template <typename T> static
bool testAndSetRelaxed(Type &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
return _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_relaxed);
}
+ template <typename T>
static bool testAndSetAcquire(Type &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
return _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acquire);
}
+ template <typename T>
static bool testAndSetRelease(Type &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
return _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_release);
}
+ template <typename T>
static bool testAndSetOrdered(Type &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
return _q_value.compare_exchange_strong(expectedValue, newValue, std::memory_order_acq_rel);
@@ -186,22 +189,26 @@ template <typename T> struct QAtomicOps
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndStoreWaitFree() Q_DECL_NOTHROW { return false; }
- static T fetchAndStoreRelaxed(Type &_q_value, T newValue) Q_DECL_NOTHROW
+ template <typename T>
+ static T fetchAndStoreRelaxed(std::atomic<T> &_q_value, T newValue) Q_DECL_NOTHROW
{
return _q_value.exchange(newValue, std::memory_order_relaxed);
}
- static T fetchAndStoreAcquire(Type &_q_value, T newValue) Q_DECL_NOTHROW
+ template <typename T>
+ static T fetchAndStoreAcquire(std::atomic<T> &_q_value, T newValue) Q_DECL_NOTHROW
{
return _q_value.exchange(newValue, std::memory_order_acquire);
}
- static T fetchAndStoreRelease(Type &_q_value, T newValue) Q_DECL_NOTHROW
+ template <typename T>
+ static T fetchAndStoreRelease(std::atomic<T> &_q_value, T newValue) Q_DECL_NOTHROW
{
return _q_value.exchange(newValue, std::memory_order_release);
}
- static T fetchAndStoreOrdered(Type &_q_value, T newValue) Q_DECL_NOTHROW
+ template <typename T>
+ static T fetchAndStoreOrdered(std::atomic<T> &_q_value, T newValue) Q_DECL_NOTHROW
{
return _q_value.exchange(newValue, std::memory_order_acq_rel);
}
@@ -209,32 +216,28 @@ template <typename T> struct QAtomicOps
static inline Q_DECL_CONSTEXPR bool isFetchAndAddNative() Q_DECL_NOTHROW { return false; }
static inline Q_DECL_CONSTEXPR bool isFetchAndAddWaitFree() Q_DECL_NOTHROW { return false; }
- static
- T fetchAndAddRelaxed(Type &_q_value, _AdditiveType valueToAdd) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T fetchAndAddRelaxed(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * AddScale,
- std::memory_order_relaxed);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_relaxed);
}
- static
- T fetchAndAddAcquire(Type &_q_value, _AdditiveType valueToAdd) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T fetchAndAddAcquire(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * AddScale,
- std::memory_order_acquire);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_acquire);
}
- static
- T fetchAndAddRelease(Type &_q_value, _AdditiveType valueToAdd) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T fetchAndAddRelease(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * AddScale,
- std::memory_order_release);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_release);
}
- static
- T fetchAndAddOrdered(Type &_q_value, _AdditiveType valueToAdd) Q_DECL_NOTHROW
+ template <typename T> static inline
+ T fetchAndAddOrdered(std::atomic<T> &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- return _q_value.fetch_add(valueToAdd * AddScale,
- std::memory_order_acq_rel);
+ return _q_value.fetch_add(valueToAdd, std::memory_order_acq_rel);
}
};
diff --git a/src/corelib/arch/qatomic_gcc.h b/src/corelib/arch/qatomic_gcc.h
index bd29605..61e7096 100644
--- a/src/corelib/arch/qatomic_gcc.h
+++ b/src/corelib/arch/qatomic_gcc.h
@@ -75,16 +75,17 @@ template<> struct QAtomicIntegerTraits<char32_t> { enum { IsInteger = 1 }; };
#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
-template <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> >
+template <typename X> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<X> >
{
// The GCC intrinsics all have fully-ordered memory semantics, so we define
// only the xxxRelaxed functions. The exception is __sync_lock_and_test,
// which has acquire semantics, so we need to define the Release and
// Ordered versions too.
- typedef T Type;
+ typedef X Type;
#ifndef __ia64__
+ template <typename T>
static T loadAcquire(const T &_q_value) Q_DECL_NOTHROW
{
T tmp = _q_value;
@@ -92,6 +93,7 @@ template <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> >
return tmp;
}
+ template <typename T>
static void storeRelease(T &_q_value, T newValue) Q_DECL_NOTHROW
{
__sync_synchronize();
@@ -101,28 +103,32 @@ template <typename T> struct QAtomicOps: QGenericAtomicOps<QAtomicOps<T> >
static Q_DECL_CONSTEXPR bool isTestAndSetNative() Q_DECL_NOTHROW { return false; }
static Q_DECL_CONSTEXPR bool isTestAndSetWaitFree() Q_DECL_NOTHROW { return false; }
+ template <typename T>
static bool testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
return __sync_bool_compare_and_swap(&_q_value, expectedValue, newValue);
}
+ template <typename T>
static T fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
return __sync_lock_test_and_set(&_q_value, newValue);
}
+ template <typename T>
static T fetchAndStoreRelease(T &_q_value, T newValue) Q_DECL_NOTHROW
{
__sync_synchronize();
return __sync_lock_test_and_set(&_q_value, newValue);
}
+ template <typename T>
static T fetchAndStoreOrdered(T &_q_value, T newValue) Q_DECL_NOTHROW
{
return fetchAndStoreRelease(_q_value, newValue);
}
- static
+ template <typename T> static
T fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
return __sync_fetch_and_add(&_q_value, valueToAdd * QAtomicAdditiveType<T>::AddScale);
diff --git a/src/corelib/arch/qatomic_ia64.h b/src/corelib/arch/qatomic_ia64.h
index ed72036..98937c7 100644
--- a/src/corelib/arch/qatomic_ia64.h
+++ b/src/corelib/arch/qatomic_ia64.h
@@ -192,7 +192,7 @@ template <typename T> struct QAtomicOps : QBasicAtomicOps<sizeof(T)>
typedef T Type;
};
-inline bool _q_ia64_fetchadd_immediate(register int value)
+inline bool _q_ia64_fetchadd_immediate(int value)
{
return value == 1 || value == -1
|| value == 4 || value == -4
@@ -218,7 +218,7 @@ inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
- register int expectedValueCopy = expectedValue;
+ int expectedValueCopy = expectedValue;
return (static_cast<int>(_InterlockedCompareExchange(&_q_value,
newValue,
expectedValueCopy))
@@ -227,7 +227,7 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
{
- register int expectedValueCopy = expectedValue;
+ int expectedValueCopy = expectedValue;
return (static_cast<int>(_InterlockedCompareExchange_acq(reinterpret_cast<volatile uint *>(&_q_value),
newValue,
expectedValueCopy))
@@ -236,7 +236,7 @@ inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
{
- register int expectedValueCopy = expectedValue;
+ int expectedValueCopy = expectedValue;
return (static_cast<int>(_InterlockedCompareExchange_rel(reinterpret_cast<volatile uint *>(&_q_value),
newValue,
expectedValueCopy))
@@ -285,7 +285,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
- register T *expectedValueCopy = expectedValue;
+ T *expectedValueCopy = expectedValue;
return (_InterlockedCompareExchangePointer(reinterpret_cast<void * volatile*>(&_q_value),
newValue,
expectedValueCopy)
@@ -300,7 +300,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValu
volatile unsigned long *p;
};
x = &_q_value;
- register T *expectedValueCopy = expectedValue;
+ T *expectedValueCopy = expectedValue;
return (_InterlockedCompareExchange64_acq(p, quintptr(newValue), quintptr(expectedValueCopy))
== quintptr(expectedValue));
}
@@ -313,7 +313,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValu
volatile unsigned long *p;
};
x = &_q_value;
- register T *expectedValueCopy = expectedValue;
+ T *expectedValueCopy = expectedValue;
return (_InterlockedCompareExchange64_rel(p, quintptr(newValue), quintptr(expectedValueCopy))
== quintptr(expectedValue));
}
@@ -912,7 +912,7 @@ T QBasicAtomicOps<1>::fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveTy
{
valueToAdd *= QAtomicAdditiveType<T>::AddScale;
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (quint8)old, FENCE);
@@ -926,7 +926,7 @@ template<> template <typename T> inline
T QBasicAtomicOps<1>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (quint8)old, FENCE);
@@ -941,7 +941,7 @@ T QBasicAtomicOps<2>::fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveTy
{
valueToAdd *= QAtomicAdditiveType<T>::AddScale;
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (quint16)old, FENCE);
@@ -955,7 +955,7 @@ template<> template <typename T> inline
T QBasicAtomicOps<2>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (quint16)old, FENCE);
@@ -970,7 +970,7 @@ T QBasicAtomicOps<4>::fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveTy
{
valueToAdd *= QAtomicAdditiveType<T>::AddScale;
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (unsigned)old, FENCE);
@@ -984,7 +984,7 @@ template<> template <typename T> inline
T QBasicAtomicOps<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (unsigned)old, FENCE);
@@ -999,7 +999,7 @@ T QBasicAtomicOps<8>::fetchAndAddAcquire(T &_q_value, typename QAtomicAdditiveTy
{
valueToAdd *= QAtomicAdditiveType<T>::AddScale;
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (quint64)old, FENCE);
@@ -1013,7 +1013,7 @@ template<> template <typename T> inline
T QBasicAtomicOps<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
// implement the test-and-set loop
- register T old, ret;
+ T old, ret;
do {
old = _q_value;
_Asm_mov_to_ar((_Asm_app_reg)_AREG_CCV, (quint64)old, FENCE);
diff --git a/src/corelib/arch/qatomic_mips.h b/src/corelib/arch/qatomic_mips.h
index 7716750..6eb9613 100644
--- a/src/corelib/arch/qatomic_mips.h
+++ b/src/corelib/arch/qatomic_mips.h
@@ -137,8 +137,8 @@ void QBasicAtomicOps<size>::orderedMemoryFence(const T &) Q_DECL_NOTHROW
template<> template<typename T> inline
bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
asm volatile("0:\n"
"ll %[originalValue], %[_q_value]\n"
"addiu %[newValue], %[originalValue], %[one]\n"
@@ -156,8 +156,8 @@ bool QBasicAtomicOps<4>::ref(T &_q_value) Q_DECL_NOTHROW
template<> template<typename T> inline
bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
asm volatile("0:\n"
"ll %[originalValue], %[_q_value]\n"
"addiu %[newValue], %[originalValue], %[minusOne]\n"
@@ -175,8 +175,8 @@ bool QBasicAtomicOps<4>::deref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
- register T result;
- register T tempValue;
+ T result;
+ T tempValue;
asm volatile("0:\n"
"ll %[result], %[_q_value]\n"
"xor %[result], %[result], %[expectedValue]\n"
@@ -199,8 +199,8 @@ bool QBasicAtomicOps<4>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa
template<> template <typename T> inline
T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
- register T originalValue;
- register T tempValue;
+ T originalValue;
+ T tempValue;
asm volatile("0:\n"
"ll %[originalValue], %[_q_value]\n"
"move %[tempValue], %[newValue]\n"
@@ -218,8 +218,8 @@ T QBasicAtomicOps<4>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR
template<> template <typename T> inline
T QBasicAtomicOps<4>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
asm volatile("0:\n"
"ll %[originalValue], %[_q_value]\n"
"addu %[newValue], %[originalValue], %[valueToAdd]\n"
@@ -254,8 +254,8 @@ template<> struct QAtomicIntegerTraits<char32_t> { enum { IsInteger = 1 }; };
template<> template<typename T> inline
bool QBasicAtomicOps<8>::ref(T &_q_value) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
asm volatile("0:\n"
"lld %[originalValue], %[_q_value]\n"
"addiu %[newValue], %[originalValue], %[one]\n"
@@ -273,8 +273,8 @@ bool QBasicAtomicOps<8>::ref(T &_q_value) Q_DECL_NOTHROW
template<> template<typename T> inline
bool QBasicAtomicOps<8>::deref(T &_q_value) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
asm volatile("0:\n"
"lld %[originalValue], %[_q_value]\n"
"addiu %[newValue], %[originalValue], %[minusOne]\n"
@@ -292,8 +292,8 @@ bool QBasicAtomicOps<8>::deref(T &_q_value) Q_DECL_NOTHROW
template<> template <typename T> inline
bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newValue) Q_DECL_NOTHROW
{
- register T result;
- register T tempValue;
+ T result;
+ T tempValue;
asm volatile("0:\n"
"lld %[result], %[_q_value]\n"
"xor %[result], %[result], %[expectedValue]\n"
@@ -316,8 +316,8 @@ bool QBasicAtomicOps<8>::testAndSetRelaxed(T &_q_value, T expectedValue, T newVa
template<> template <typename T> inline
T QBasicAtomicOps<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHROW
{
- register T originalValue;
- register T tempValue;
+ T originalValue;
+ T tempValue;
asm volatile("0:\n"
"lld %[originalValue], %[_q_value]\n"
"move %[tempValue], %[newValue]\n"
@@ -335,8 +335,8 @@ T QBasicAtomicOps<8>::fetchAndStoreRelaxed(T &_q_value, T newValue) Q_DECL_NOTHR
template<> template <typename T> inline
T QBasicAtomicOps<8>::fetchAndAddRelaxed(T &_q_value, typename QAtomicAdditiveType<T>::AdditiveT valueToAdd) Q_DECL_NOTHROW
{
- register T originalValue;
- register T newValue;
+ T originalValue;
+ T newValue;
asm volatile("0:\n"
"lld %[originalValue], %[_q_value]\n"
"addu %[newValue], %[originalValue], %[valueToAdd]\n"
diff --git a/src/corelib/arch/qatomic_power.h b/src/corelib/arch/qatomic_power.h
index ad1c619..3ddd303 100644
--- a/src/corelib/arch/qatomic_power.h
+++ b/src/corelib/arch/qatomic_power.h
@@ -124,8 +124,8 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
inline bool QBasicAtomicInt::ref()
{
- register int originalValue;
- register int newValue;
+ int originalValue;
+ int newValue;
asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
"addi %[newValue], %[originalValue], %[one]\n"
"stwcx. %[newValue]," _Q_VALUE "\n"
@@ -141,8 +141,8 @@ inline bool QBasicAtomicInt::ref()
inline bool QBasicAtomicInt::deref()
{
- register int originalValue;
- register int newValue;
+ int originalValue;
+ int newValue;
asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
"addi %[newValue], %[originalValue], %[minusOne]\n"
"stwcx. %[newValue]," _Q_VALUE "\n"
@@ -158,7 +158,7 @@ inline bool QBasicAtomicInt::deref()
inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
- register int result;
+ int result;
asm volatile("lwarx %[result]," _Q_VALUE "\n"
"xor. %[result], %[result], %[expectedValue]\n"
"bne $+12\n"
@@ -175,7 +175,7 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
{
- register int result;
+ int result;
asm volatile("lwarx %[result]," _Q_VALUE "\n"
"xor. %[result], %[result], %[expectedValue]\n"
"bne $+16\n"
@@ -193,7 +193,7 @@ inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
{
- register int result;
+ int result;
asm volatile("eieio\n"
"lwarx %[result]," _Q_VALUE "\n"
"xor. %[result], %[result], %[expectedValue]\n"
@@ -211,7 +211,7 @@ inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
{
- register int originalValue;
+ int originalValue;
asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
"stwcx. %[newValue]," _Q_VALUE "\n"
"bne- $-8\n"
@@ -225,7 +225,7 @@ inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
{
- register int originalValue;
+ int originalValue;
asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
"stwcx. %[newValue]," _Q_VALUE "\n"
"bne- $-8\n"
@@ -240,7 +240,7 @@ inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
{
- register int originalValue;
+ int originalValue;
asm volatile("eieio\n"
"lwarx %[originalValue]," _Q_VALUE "\n"
"stwcx. %[newValue]," _Q_VALUE "\n"
@@ -255,8 +255,8 @@ inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
{
- register int originalValue;
- register int newValue;
+ int originalValue;
+ int newValue;
asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
"stwcx. %[newValue]," _Q_VALUE "\n"
@@ -272,8 +272,8 @@ inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
{
- register int originalValue;
- register int newValue;
+ int originalValue;
+ int newValue;
asm volatile("lwarx %[originalValue]," _Q_VALUE "\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
"stwcx. %[newValue]," _Q_VALUE "\n"
@@ -290,8 +290,8 @@ inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
{
- register int originalValue;
- register int newValue;
+ int originalValue;
+ int newValue;
asm volatile("eieio\n"
"lwarx %[originalValue]," _Q_VALUE "\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
@@ -317,7 +317,7 @@ inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
- register void *result;
+ void *result;
asm volatile(LPARX" %[result]," _Q_VALUE "\n"
"xor. %[result], %[result], %[expectedValue]\n"
"bne $+12\n"
@@ -335,7 +335,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
{
- register void *result;
+ void *result;
asm volatile(LPARX" %[result]," _Q_VALUE "\n"
"xor. %[result], %[result], %[expectedValue]\n"
"bne $+16\n"
@@ -354,7 +354,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
{
- register void *result;
+ void *result;
asm volatile("eieio\n"
LPARX" %[result]," _Q_VALUE "\n"
"xor. %[result], %[result], %[expectedValue]\n"
@@ -373,7 +373,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
{
- register T *originalValue;
+ T *originalValue;
asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
STPCX" %[newValue]," _Q_VALUE "\n"
"bne- $-8\n"
@@ -388,7 +388,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
{
- register T *originalValue;
+ T *originalValue;
asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
STPCX" %[newValue]," _Q_VALUE "\n"
"bne- $-8\n"
@@ -404,7 +404,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
{
- register T *originalValue;
+ T *originalValue;
asm volatile("eieio\n"
LPARX" %[originalValue]," _Q_VALUE "\n"
STPCX" %[newValue]," _Q_VALUE "\n"
@@ -420,8 +420,8 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
{
- register T *originalValue;
- register T *newValue;
+ T *originalValue;
+ T *newValue;
asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
STPCX" %[newValue]," _Q_VALUE "\n"
@@ -438,8 +438,8 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueTo
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
{
- register T *originalValue;
- register T *newValue;
+ T *originalValue;
+ T *newValue;
asm volatile(LPARX" %[originalValue]," _Q_VALUE "\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
STPCX" %[newValue]," _Q_VALUE "\n"
@@ -457,8 +457,8 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueTo
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
{
- register T *originalValue;
- register T *newValue;
+ T *originalValue;
+ T *newValue;
asm volatile("eieio\n"
LPARX" %[originalValue]," _Q_VALUE "\n"
"add %[newValue], %[originalValue], %[valueToAdd]\n"
diff --git a/src/corelib/arch/qatomic_sh4a.h b/src/corelib/arch/qatomic_sh4a.h
index 08f75e4..6e59279 100644
--- a/src/corelib/arch/qatomic_sh4a.h
+++ b/src/corelib/arch/qatomic_sh4a.h
@@ -147,7 +147,7 @@ inline bool QBasicAtomicInt::deref()
inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
{
- register int result;
+ int result;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"xor %[expectedValue], r0\n"
@@ -169,7 +169,7 @@ inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
{
- register int result;
+ int result;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"xor %[expectedValue], r0\n"
@@ -192,7 +192,7 @@ inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
{
- register int result;
+ int result;
asm volatile("synco\n"
"0:\n"
"movli.l @%[_q_value], r0\n"
@@ -220,7 +220,7 @@ inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
{
- register int originalValue;
+ int originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -237,7 +237,7 @@ inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
{
- register int originalValue;
+ int originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -255,7 +255,7 @@ inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
{
- register int originalValue;
+ int originalValue;
asm volatile("synco\n"
"0:\n"
"movli.l @%[_q_value], r0\n"
@@ -278,7 +278,7 @@ inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
{
- register int originalValue;
+ int originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -295,7 +295,7 @@ inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
{
- register int originalValue;
+ int originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -313,7 +313,7 @@ inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
{
- register int originalValue;
+ int originalValue;
asm volatile("synco\n"
"0:\n"
"movli.l @%[_q_value], r0\n"
@@ -337,7 +337,7 @@ inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
{
- register T *result;
+ T *result;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"xor %[expectedValue], r0\n"
@@ -360,7 +360,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
{
- register T *result;
+ T *result;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"xor %[expectedValue], r0\n"
@@ -384,7 +384,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
{
- register T *result;
+ T *result;
asm volatile("synco\n"
"0:\n"
"movli.l @%[_q_value], r0\n"
@@ -414,7 +414,7 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValu
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
{
- register T *originalValue;
+ T *originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -432,7 +432,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
{
- register T *originalValue;
+ T *originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -451,7 +451,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
{
- register T *originalValue;
+ T *originalValue;
asm volatile("synco\n"
"0:\n"
"movli.l @%[_q_value], r0\n"
@@ -476,7 +476,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
{
- register T *originalValue;
+ T *originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -494,7 +494,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueTo
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
{
- register T *originalValue;
+ T *originalValue;
asm volatile("0:\n"
"movli.l @%[_q_value], r0\n"
"mov r0, %[originalValue]\n"
@@ -513,7 +513,7 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueTo
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
{
- register T *originalValue;
+ T *originalValue;
asm volatile("synco\n"
"0:\n"
"movli.l @%[_q_value], r0\n"
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index b685c1f..d02e4cf 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -151,7 +151,7 @@
/* Intel C++ also masquerades as GCC */
# define Q_CC_INTEL
# define Q_ASSUME_IMPL(expr) __assume(expr)
-# define Q_UNREACHABLE_IMPL() __assume(0)
+# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
# elif defined(__clang__)
/* Clang also masquerades as GCC */
# define Q_CC_CLANG
@@ -161,6 +161,13 @@
# /* Compatibility with older Clang versions */
# define __has_extension __has_feature
# endif
+# if defined(__APPLE__)
+ /* Apple/clang specific features */
+# define Q_DECL_CF_RETURNS_RETAINED __attribute__((cf_returns_retained))
+# ifdef __OBJC__
+# define Q_DECL_NS_RETURNS_AUTORELEASED __attribute__((ns_returns_autoreleased))
+# endif
+# endif
# else
/* Plain GCC */
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
@@ -190,7 +197,6 @@
# define Q_REQUIRED_RESULT __attribute__ ((__warn_unused_result__))
# if !defined(QT_MOC_CPP)
# define Q_PACKED __attribute__ ((__packed__))
-# define Q_NO_PACKED_REFERENCE
# ifndef __ARM_EABI__
# define QT_NO_ARM_EABI
# endif
@@ -441,6 +447,7 @@
* N2346 Q_COMPILER_DEFAULT_MEMBERS
* N2346 Q_COMPILER_DELETE_MEMBERS
* N1986 Q_COMPILER_DELEGATING_CONSTRUCTORS
+ * N2437 Q_COMPILER_EXPLICIT_CONVERSIONS
* N3206 N3272 Q_COMPILER_EXPLICIT_OVERRIDES (v0.9 and above only)
* N1987 Q_COMPILER_EXTERN_TEMPLATES
* N2540 Q_COMPILER_INHERITING_CONSTRUCTORS
@@ -491,11 +498,21 @@
# define Q_COMPILER_VARIADIC_TEMPLATES
# endif
# if __INTEL_COMPILER >= 1300
+# define Q_COMPILER_ATOMICS
// constexpr support is only partial
//# define Q_COMPILER_CONSTEXPR
# define Q_COMPILER_INITIALIZER_LISTS
# define Q_COMPILER_NOEXCEPT
# endif
+# if __INTEL_COMPILER >= 1400
+# define Q_COMPILER_CONSTEXPR
+# define Q_COMPILER_DELEGATING_CONSTRUCTORS
+# define Q_COMPILER_EXPLICIT_OVERRIDES
+# define Q_COMPILER_NONSTATIC_MEMBER_INIT
+# define Q_COMPILER_RAW_STRINGS
+# define Q_COMPILER_REF_QUALIFIERS
+# define Q_COMPILER_UNRESTRICTED_UNIONS
+# endif
# endif
#endif
@@ -545,6 +562,9 @@
# if __has_feature(cxx_delegating_constructors)
# define Q_COMPILER_DELEGATING_CONSTRUCTORS
# endif
+# if __has_feature(cxx_explicit_conversions)
+# define Q_COMPILER_EXPLICIT_CONVERSIONS
+# endif
# if __has_feature(cxx_override_control)
# define Q_COMPILER_EXPLICIT_OVERRIDES
# endif
@@ -584,7 +604,7 @@
# if __has_feature(cxx_alias_templates)
# define Q_COMPILER_TEMPLATE_ALIAS
# endif
-# if 0 /* not implemented in clang yet */
+# if __has_feature(cxx_thread_local)
# define Q_COMPILER_THREAD_LOCAL
# endif
# if __has_feature(cxx_user_literals)
@@ -630,6 +650,7 @@
# endif
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
/* C++11 features supported in GCC 4.5: */
+# define Q_COMPILER_EXPLICIT_CONVERSIONS
# define Q_COMPILER_LAMBDA
# define Q_COMPILER_RAW_STRINGS
# endif
@@ -674,16 +695,21 @@
# if _MSC_VER >= 1400
/* C++11 features supported in VC8 = VC2005: */
# define Q_COMPILER_VARIADIC_MACROS
+
+# ifndef __cplusplus_cli
/* 2005 supports the override and final contextual keywords, in
the same positions as the C++11 variants, but 'final' is
called 'sealed' instead:
http://msdn.microsoft.com/en-us/library/0w2w91tf%28v=vs.80%29.aspx
+ The behavior is slightly different in C++/CLI, which requires the
+ "virtual" keyword to be present too, so don't define for that.
So don't define Q_COMPILER_EXPLICIT_OVERRIDES (since it's not
the same as the C++11 version), but define the Q_DECL_* flags
accordingly: */
# define Q_DECL_OVERRIDE override
# define Q_DECL_FINAL sealed
# endif
+# endif
# if _MSC_VER >= 1600
/* C++11 features supported in VC10 = VC2010: */
# define Q_COMPILER_AUTO_FUNCTION
@@ -792,10 +818,6 @@
#ifndef Q_NORETURN
# define Q_NORETURN
#endif
-#ifndef Q_PACKED
-# define Q_PACKED
-# undef Q_NO_PACKED_REFERENCE
-#endif
#ifndef Q_LIKELY
# define Q_LIKELY(x) (x)
#endif
@@ -839,6 +861,12 @@
# define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
# endif
#endif
+#ifndef Q_DECL_CF_RETURNS_RETAINED
+# define Q_DECL_CF_RETURNS_RETAINED
+#endif
+#ifndef Q_DECL_NS_RETURNS_AUTORELEASED
+# define Q_DECL_NS_RETURNS_AUTORELEASED
+#endif
/*
Workaround for static const members on MSVC++.
@@ -881,4 +909,26 @@
Q_UNUSED(valueOfExpression); /* the value may not be used if Q_ASSERT_X and Q_ASSUME_IMPL are noop */\
} while (0)
+
+/*
+ Sanitize compiler feature availability
+*/
+#if !defined(Q_PROCESSOR_X86)
+# undef QT_COMPILER_SUPPORTS_SSE2
+# undef QT_COMPILER_SUPPORTS_SSE3
+# undef QT_COMPILER_SUPPORTS_SSSE3
+# undef QT_COMPILER_SUPPORTS_SSE4_1
+# undef QT_COMPILER_SUPPORTS_SSE4_2
+# undef QT_COMPILER_SUPPORTS_AVX
+# undef QT_COMPILER_SUPPORTS_AVX2
+#endif
+#if !defined(Q_PROCESSOR_ARM)
+# undef QT_COMPILER_SUPPORTS_IWMMXT
+# undef QT_COMPILER_SUPPORTS_NEON
+#endif
+#if !defined(Q_PROCESSOR_MIPS)
+# undef QT_COMPILER_SUPPORTS_MIPS_DSP
+# undef QT_COMPILER_SUPPORTS_MIPS_DSPR2
+#endif
+
#endif // QCOMPILERDETECTION_H
diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h
index f2e5dc7..17dd600 100644
--- a/src/corelib/global/qfeatures.h
+++ b/src/corelib/global/qfeatures.h
@@ -115,6 +115,9 @@
// Image Text
//#define QT_NO_IMAGE_TEXT
+// QKeySequenceEdit
+//#define QT_NO_KEYSEQUENCEEDIT
+
// QLCDNumber
//#define QT_NO_LCDNUMBER
@@ -276,11 +279,6 @@
#define QT_NO_DRAGANDDROP
#endif
-// QFileSystemModel
-#if !defined(QT_NO_FILESYSTEMMODEL) && (defined(QT_NO_FILESYSTEMWATCHER))
-#define QT_NO_FILESYSTEMMODEL
-#endif
-
// File Transfer Protocol
#if !defined(QT_NO_FTP) && (defined(QT_NO_TEXTDATE))
#define QT_NO_FTP
@@ -306,11 +304,21 @@
#define QT_NO_IMAGEFORMATPLUGIN
#endif
+// QKeySequenceEdit
+#if !defined(QT_NO_KEYSEQUENCEEDIT) && (defined(QT_NO_SHORTCUT))
+#define QT_NO_KEYSEQUENCEEDIT
+#endif
+
// QLocalServer
#if !defined(QT_NO_LOCALSERVER) && (defined(QT_NO_TEMPORARYFILE))
#define QT_NO_LOCALSERVER
#endif
+// QPdf
+#if !defined(QT_NO_PDF) && (defined(QT_NO_TEMPORARYFILE))
+#define QT_NO_PDF
+#endif
+
// QMenu
#if !defined(QT_NO_MENU) && (defined(QT_NO_ACTION))
#define QT_NO_MENU
@@ -386,11 +394,6 @@
#define QT_NO_CONTEXTMENU
#endif
-// Qt D-Bus module
-#if !defined(QT_NO_DBUS) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_DOM))
-#define QT_NO_DBUS
-#endif
-
// QPrinter
#if !defined(QT_NO_PRINTER) && (defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE))
#define QT_NO_PRINTER
@@ -446,6 +449,11 @@
#define QT_NO_BEARERMANAGEMENT
#endif
+// Qt D-Bus module
+#if !defined(QT_NO_DBUS) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_XMLSTREAMREADER))
+#define QT_NO_DBUS
+#endif
+
// QGraphicsView
#if !defined(QT_NO_GRAPHICSVIEW) && (defined(QT_NO_SCROLLAREA))
#define QT_NO_GRAPHICSVIEW
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 79e32fe..1d19a6c 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -45,17 +45,17 @@
#include <stddef.h>
-#define QT_VERSION_STR "5.1.0"
+#define QT_VERSION_STR "5.2.0"
/*
QT_VERSION is (major << 16) + (minor << 8) + patch.
*/
-#define QT_VERSION 0x050100
+#define QT_VERSION 0x050200
/*
can be used like #if (QT_VERSION >= QT_VERSION_CHECK(4, 4, 0))
*/
#define QT_VERSION_CHECK(major, minor, patch) ((major<<16)|(minor<<8)|(patch))
-#if !defined(QT_BUILD_MOC) && !defined(QT_BUILD_QMAKE) && !defined(QT_BUILD_CONFIGURE)
+#if !defined(QT_BUILD_QMAKE) && !defined(QT_BUILD_CONFIGURE)
#include <QtCore/qconfig.h>
#endif
@@ -68,12 +68,15 @@
#define QT_STRINGIFY(x) QT_STRINGIFY2(x)
#include <QtCore/qsystemdetection.h>
-#include <QtCore/qcompilerdetection.h>
#include <QtCore/qprocessordetection.h>
+#include <QtCore/qcompilerdetection.h>
#if defined (__ELF__)
# define Q_OF_ELF
#endif
+#if defined (__MACH__) && defined (__APPLE__)
+# define Q_OF_MACH_O
+#endif
#ifdef __cplusplus
@@ -191,8 +194,10 @@ typedef quint64 qulonglong;
#ifndef QT_POINTER_SIZE
# if defined(Q_OS_WIN64)
# define QT_POINTER_SIZE 8
-# elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
+# elif defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
# define QT_POINTER_SIZE 4
+# elif defined(Q_OS_ANDROID)
+# define QT_POINTER_SIZE 4 // ### Add auto-detection to Windows configure
# endif
#endif
@@ -203,11 +208,7 @@ typedef quint64 qulonglong;
QT_BEGIN_INCLUDE_NAMESPACE
typedef unsigned char uchar;
typedef unsigned short ushort;
-#if defined(Q_QDOC) || !defined(Q_OS_ANDROID)
typedef unsigned int uint;
-#else
-# include <sys/types.h>
-#endif
typedef unsigned long ulong;
QT_END_INCLUDE_NAMESPACE
@@ -539,6 +540,10 @@ class QDataStream;
# define QT_NO_SYSTEMSEMAPHORE // not needed at all in a flat address space
#endif
+#if defined(Q_OS_WINRT)
+# define QT_NO_PROCESS
+#endif
+
inline void qt_noop(void) {}
/* These wrap try/catch so we can switch off exceptions later.
@@ -651,8 +656,13 @@ template <> class QStaticAssertFailure<true> {};
#define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
#define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
+#ifdef __COUNTER__
+#define Q_STATIC_ASSERT(Condition) \
+ enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
+#else
#define Q_STATIC_ASSERT(Condition) \
enum {Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) = sizeof(QStaticAssertFailure<!!(Condition)>)}
+#endif /* __COUNTER__ */
#define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition)
#endif
@@ -678,11 +688,13 @@ typedef void (*QFunctionPointer)();
# define Q_UNIMPLEMENTED() qWarning("%s:%d: %s: Unimplemented code.", __FILE__, __LINE__, Q_FUNC_INFO)
#endif
+Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(double p1, double p2)
{
return (qAbs(p1 - p2) * 1000000000000. <= qMin(qAbs(p1), qAbs(p2)));
}
+Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
{
return (qAbs(p1 - p2) * 100000.f <= qMin(qAbs(p1), qAbs(p2)));
@@ -691,6 +703,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyCompare(float p1, float p2)
/*!
\internal
*/
+Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
{
return qAbs(d) <= 0.000000000001;
@@ -699,6 +712,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(double d)
/*!
\internal
*/
+Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f) Q_REQUIRED_RESULT;
Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
{
return qAbs(f) <= 0.00001f;
@@ -709,6 +723,7 @@ Q_DECL_CONSTEXPR static inline bool qFuzzyIsNull(float f)
check whether the actual value is 0 or close to 0, but whether
it is binary 0, disregarding sign.
*/
+static inline bool qIsNull(double d) Q_REQUIRED_RESULT;
static inline bool qIsNull(double d)
{
union U {
@@ -725,6 +740,7 @@ static inline bool qIsNull(double d)
check whether the actual value is 0 or close to 0, but whether
it is binary 0, disregarding sign.
*/
+static inline bool qIsNull(float f) Q_REQUIRED_RESULT;
static inline bool qIsNull(float f)
{
union U {
@@ -982,6 +998,20 @@ template <bool B, typename T = void> struct QEnableIf;
template <typename T> struct QEnableIf<true, T> { typedef T Type; };
}
+#ifndef Q_FORWARD_DECLARE_OBJC_CLASS
+# ifdef __OBJC__
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) @class classname
+# else
+# define Q_FORWARD_DECLARE_OBJC_CLASS(classname) typedef struct objc_object classname
+# endif
+#endif
+#ifndef Q_FORWARD_DECLARE_CF_TYPE
+# define Q_FORWARD_DECLARE_CF_TYPE(type) typedef const struct __ ## type * type ## Ref
+#endif
+#ifndef Q_FORWARD_DECLARE_MUTABLE_CF_TYPE
+# define Q_FORWARD_DECLARE_MUTABLE_CF_TYPE(type) typedef struct __ ## type * type ## Ref
+#endif
+
QT_END_NAMESPACE
// Q_GLOBAL_STATIC
#include <QtCore/qglobalstatic.h>
diff --git a/src/corelib/global/qglobalstatic.h b/src/corelib/global/qglobalstatic.h
index a6268e0..ad39452 100644
--- a/src/corelib/global/qglobalstatic.h
+++ b/src/corelib/global/qglobalstatic.h
@@ -57,11 +57,16 @@ enum GuardValues {
};
}
-#if defined(QT_NO_THREAD) || defined(Q_CC_GNU)
+#if defined(QT_NO_THREAD) || (defined(Q_CC_GNU) && !defined(Q_OS_MAC))
// some compilers support thread-safe statics
// The IA-64 C++ ABI requires this, so we know that all GCC versions since 3.4
// support it. C++11 also requires this behavior.
-// Clang and Intel CC masquerade as GCC when compiling on Linux and Mac OS X.
+// Clang and Intel CC masquerade as GCC when compiling on Linux.
+//
+// Apple's libc++abi however uses a global lock for initializing local statics,
+// which will block other threads also trying to initialize a local static
+// until the constructor returns ...
+// We better avoid these kind of problems by using our own locked implementation.
#define Q_GLOBAL_STATIC_INTERNAL(ARGS) \
Q_DECL_HIDDEN inline Type *innerFunction() \
@@ -121,8 +126,16 @@ struct QGlobalStatic
bool exists() const { return guard.load() == QtGlobalStatic::Initialized; }
operator Type *() { if (isDestroyed()) return 0; return innerFunction(); }
Type *operator()() { if (isDestroyed()) return 0; return innerFunction(); }
- Type *operator->() { return innerFunction(); }
- Type &operator*() { return *innerFunction(); }
+ Type *operator->()
+ {
+ Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
+ return innerFunction();
+ }
+ Type &operator*()
+ {
+ Q_ASSERT_X(!isDestroyed(), "Q_GLOBAL_STATIC", "The global static was used after being destroyed");
+ return *innerFunction();
+ }
};
#define Q_GLOBAL_STATIC_WITH_ARGS(TYPE, NAME, ARGS) \
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index b275e01..17864b5 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -92,7 +92,7 @@ public:
};
static QString location(LibraryLocation); // ### Qt 6: consider renaming it to path()
#ifdef QT_BOOTSTRAPPED
- enum PathGroup { FinalPaths, EffectivePaths };
+ enum PathGroup { FinalPaths, EffectivePaths, EffectiveSourcePaths };
static QString rawLocation(LibraryLocation, PathGroup);
#endif
diff --git a/src/corelib/global/qlogging.h b/src/corelib/global/qlogging.h
index 2b798f9..68a24d0 100644
--- a/src/corelib/global/qlogging.h
+++ b/src/corelib/global/qlogging.h
@@ -59,7 +59,7 @@ QT_BEGIN_NAMESPACE
class QDebug;
class QNoDebug;
-enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtSystemMsg = QtCriticalMsg };
+enum QtMsgType { QtDebugMsg, QtWarningMsg, QtCriticalMsg, QtFatalMsg, QtTraceMsg, QtSystemMsg = QtCriticalMsg };
class QMessageLogContext
{
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 25c47d5..8a46f3a 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -89,12 +89,14 @@ Qt {
Q_ENUMS(ScreenOrientation)
Q_FLAGS(ScreenOrientations)
Q_ENUMS(ConnectionType)
+ Q_ENUMS(ApplicationState)
#ifndef QT_NO_GESTURES
Q_ENUMS(GestureState)
Q_ENUMS(GestureType)
#endif
Q_ENUMS(CursorMoveStyle)
Q_ENUMS(TimerType)
+ Q_ENUMS(ScrollPhase)
#endif // defined(Q_MOC_RUN)
#if defined(Q_MOC_RUN)
@@ -221,7 +223,7 @@ public:
// Text formatting flags for QPainter::drawText and QLabel.
// The following two enums can be combined to one integer which
- // is passed as 'flags' to drawText and qt_format_text.
+ // is passed as 'flags' to QPainter::drawText, QFontMetrics::boundingRect and qt_format_text.
enum AlignmentFlag {
AlignLeft = 0x0001,
@@ -236,7 +238,12 @@ public:
AlignTop = 0x0020,
AlignBottom = 0x0040,
AlignVCenter = 0x0080,
- AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter,
+ AlignBaseline = 0x0100,
+ // Note that 0x100 will clash with Qt::TextSingleLine = 0x100 due to what the comment above
+ // this enum declaration states. However, since Qt::AlignBaseline is only used by layouts,
+ // it doesn't make sense to pass Qt::AlignBaseline to QPainter::drawText(), so there
+ // shouldn't really be any ambiguity between the two overlapping enum values.
+ AlignVertical_Mask = AlignTop | AlignBottom | AlignVCenter | AlignBaseline,
AlignCenter = AlignVCenter | AlignHCenter
};
@@ -289,6 +296,7 @@ public:
Desktop = 0x00000010 | Window,
SubWindow = 0x00000012,
ForeignWindow = 0x00000020 | Window,
+ CoverWindow = 0x00000040 | Window,
WindowType_Mask = 0x000000ff,
MSWindowsFixedSizeDialogHint = 0x00000100,
@@ -899,7 +907,7 @@ public:
Key_BrightnessAdjust = 0x010000c2,
Key_Finance = 0x010000c3,
Key_Community = 0x010000c4,
- Key_AudioRewind = 0x010000c5,
+ Key_AudioRewind = 0x010000c5, // Media rewind
Key_BackForward = 0x010000c6,
Key_ApplicationLeft = 0x010000c7,
Key_ApplicationRight = 0x010000c8,
@@ -911,7 +919,7 @@ public:
Key_Close = 0x010000ce,
Key_Copy = 0x010000cf,
Key_Cut = 0x010000d0,
- Key_Display = 0x010000d1,
+ Key_Display = 0x010000d1, // Output switch key
Key_DOS = 0x010000d2,
Key_Documents = 0x010000d3,
Key_Excel = 0x010000d4,
@@ -960,9 +968,9 @@ public:
Key_Bluetooth = 0x010000ff,
Key_WLAN = 0x01000100,
Key_UWB = 0x01000101,
- Key_AudioForward = 0x01000102,
- Key_AudioRepeat = 0x01000103,
- Key_AudioRandomPlay = 0x01000104,
+ Key_AudioForward = 0x01000102, // Media fast-forward
+ Key_AudioRepeat = 0x01000103, // Toggle repeat mode
+ Key_AudioRandomPlay = 0x01000104, // Toggle shuffle mode
Key_Subtitle = 0x01000105,
Key_AudioCycleTrack = 0x01000106,
Key_Time = 0x01000107,
@@ -982,6 +990,14 @@ public:
Key_MicMute = 0x01000113,
+ Key_Red = 0x01000114,
+ Key_Green = 0x01000115,
+ Key_Yellow = 0x01000116,
+ Key_Blue = 0x01000117,
+
+ Key_ChannelUp = 0x01000118,
+ Key_ChannelDown = 0x01000119,
+
Key_MediaLast = 0x0100ffff,
// Keypad navigation keys
@@ -1173,13 +1189,15 @@ public:
SystemLocaleShortDate,
SystemLocaleLongDate,
DefaultLocaleShortDate,
- DefaultLocaleLongDate
+ DefaultLocaleLongDate,
+ RFC2822Date // RFC 2822 (+ 850 and 1036 during parsing)
};
enum TimeSpec {
LocalTime,
UTC,
- OffsetFromUTC
+ OffsetFromUTC,
+ TimeZone
};
enum DayOfWeek {
@@ -1539,6 +1557,18 @@ public:
IgnoredGesturesPropagateToParent = 0x04
};
Q_DECLARE_FLAGS(GestureFlags, GestureFlag)
+
+ enum NativeGestureType
+ {
+ BeginNativeGesture,
+ EndNativeGesture,
+ PanNativeGesture,
+ ZoomNativeGesture,
+ SmartZoomNativeGesture,
+ RotateNativeGesture,
+ SwipeNativeGesture
+ };
+
#endif // QT_NO_GESTURES
enum NavigationMode
@@ -1560,6 +1590,12 @@ public:
CoarseTimer,
VeryCoarseTimer
};
+
+ enum ScrollPhase {
+ ScrollBegin = 1,
+ ScrollUpdate,
+ ScrollEnd
+ };
}
#ifdef Q_MOC_RUN
;
diff --git a/src/corelib/global/qprocessordetection.h b/src/corelib/global/qprocessordetection.h
index 21f9c8f..623e30a 100644
--- a/src/corelib/global/qprocessordetection.h
+++ b/src/corelib/global/qprocessordetection.h
@@ -90,14 +90,24 @@
// Q_BYTE_ORDER not defined, use endianness auto-detection
/*
- ARM family, known revisions: V5, V6, and V7
+ ARM family, known revisions: V5, V6, V7, V8
ARM is bi-endian, detect using __ARMEL__ or __ARMEB__, falling back to
auto-detection implemented below.
*/
-#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM)
+#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(__arm64__)
# define Q_PROCESSOR_ARM
-# if defined(__ARM_ARCH_7__) \
+# if defined(__arm64__)
+# define Q_PROCESSOR_ARM_64
+# else
+# define Q_PROCESSOR_ARM_32
+# endif
+# if defined(__ARM64_ARCH_8__)
+# define Q_PROCESSOR_ARM_V8
+# define Q_PROCESSOR_ARM_V7
+# define Q_PROCESSOR_ARM_V6
+# define Q_PROCESSOR_ARM_V5
+# elif defined(__ARM_ARCH_7__) \
|| defined(__ARM_ARCH_7A__) \
|| defined(__ARM_ARCH_7R__) \
|| defined(__ARM_ARCH_7M__) \
@@ -157,11 +167,33 @@
X86 is little-endian.
*/
#elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
-# define Q_PROCESSOR_X86
# define Q_PROCESSOR_X86_32
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
+
+/*
+ * We define Q_PROCESSOR_X86 == 6 for anything above a equivalent or better
+ * than a Pentium Pro (the processor whose architecture was called P6) or an
+ * Athlon.
+ *
+ * All processors since the Pentium III and the Athlon 4 have SSE support, so
+ * we use that to detect. That leaves the original Athlon, Pentium Pro and
+ * Pentium II.
+ */
+
+# if defined(_M_IX86)
+# define Q_PROCESSOR_X86 (_M_IX86/100)
+# elif defined(__i686__) || defined(__athlon__) || defined(__SSE__)
+# define Q_PROCESSOR_X86 6
+# elif defined(__i586__) || defined(__k6__)
+# define Q_PROCESSOR_X86 5
+# elif defined(__i486__)
+# define Q_PROCESSOR_X86 4
+# else
+# define Q_PROCESSOR_X86 3
+# endif
+
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
-# define Q_PROCESSOR_X86
+# define Q_PROCESSOR_X86 6
# define Q_PROCESSOR_X86_64
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
@@ -285,7 +317,7 @@
# elif defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN)
# define Q_BYTE_ORDER Q_BIG_ENDIAN
# elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN) \
- || defined(_WIN32_WCE) // Windows CE is always little-endian according to MSDN.
+ || defined(_WIN32_WCE) || defined(WINAPI_FAMILY) // Windows CE is always little-endian according to MSDN.
# define Q_BYTE_ORDER Q_LITTLE_ENDIAN
# else
# error "Unable to determine byte order!"
diff --git a/src/corelib/global/qsysinfo.h b/src/corelib/global/qsysinfo.h
index a6accdf..bd76f90 100644
--- a/src/corelib/global/qsysinfo.h
+++ b/src/corelib/global/qsysinfo.h
@@ -96,6 +96,7 @@ public:
WV_VISTA = 0x0080,
WV_WINDOWS7 = 0x0090,
WV_WINDOWS8 = 0x00a0,
+ WV_WINDOWS8_1 = 0x00b0,
WV_NT_based = 0x00f0,
/* version numbers */
@@ -106,6 +107,7 @@ public:
WV_6_0 = WV_VISTA,
WV_6_1 = WV_WINDOWS7,
WV_6_2 = WV_WINDOWS8,
+ WV_6_3 = WV_WINDOWS8_1,
WV_CE = 0x0100,
WV_CENET = 0x0200,
diff --git a/src/corelib/global/qsystemdetection.h b/src/corelib/global/qsystemdetection.h
index cb55fa8..7b1c326 100644
--- a/src/corelib/global/qsystemdetection.h
+++ b/src/corelib/global/qsystemdetection.h
@@ -49,21 +49,22 @@
/*
The operating system, must be one of: (Q_OS_x)
- DARWIN - Darwin OS (synonym for Q_OS_MAC)
- MAC - OS X or iOS (synonym for Q_OS_DARWIN)
- MACX - OS X
+ DARWIN - Any Darwin system
+ MAC - OS X and iOS
+ OSX - OS X
IOS - iOS
MSDOS - MS-DOS and Windows
OS2 - OS/2
OS2EMX - XFree86 on OS/2 (not PM)
WIN32 - Win32 (Windows 2000/XP/Vista/7 and Windows Server 2003/2008)
WINCE - WinCE (Windows CE 5.0)
+ WINRT - WinRT (Windows 8 Runtime)
CYGWIN - Cygwin
SOLARIS - Sun Solaris
HPUX - HP-UX
ULTRIX - DEC Ultrix
- LINUX - Linux
- FREEBSD - FreeBSD
+ LINUX - Linux [has variants]
+ FREEBSD - FreeBSD [has variants]
NETBSD - NetBSD
OPENBSD - OpenBSD
BSDI - BSD/OS
@@ -76,12 +77,20 @@
DGUX - DG/UX
RELIANT - Reliant UNIX
DYNIX - DYNIX/ptx
- QNX - QNX
+ QNX - QNX [has variants]
QNX6 - QNX RTP 6.1
LYNX - LynxOS
BSD4 - Any BSD 4.4 system
UNIX - Any UNIX BSD/SYSV system
ANDROID - Android platform
+
+ The following operating systems have variants:
+ LINUX - both Q_OS_LINUX and Q_OS_ANDROID are defined when building for Android
+ - only Q_OS_LINUX is defined if building for other Linux systems
+ QNX - both Q_OS_QNX and Q_OS_BLACKBERRY are defined when building for Blackberry 10
+ - only Q_OS_QNX is defined if building for other QNX targets
+ FREEBSD - Q_OS_FREEBSD is defined only when building for FreeBSD with a BSD userland
+ - Q_OS_FREEBSD_KERNEL is always defined on FreeBSD, even if the userland is from GNU
*/
#if defined(__APPLE__) && (defined(__GNUC__) || defined(__xlC__) || defined(__xlc__))
@@ -97,12 +106,21 @@
# define Q_OS_LINUX
#elif defined(__CYGWIN__)
# define Q_OS_CYGWIN
-#elif !defined(SAG_COM) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
+#elif !defined(SAG_COM) && (!defined(WINAPI_FAMILY) || WINAPI_FAMILY==WINAPI_FAMILY_DESKTOP_APP) && (defined(WIN64) || defined(_WIN64) || defined(__WIN64__))
# define Q_OS_WIN32
# define Q_OS_WIN64
#elif !defined(SAG_COM) && (defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__NT__))
# if defined(WINCE) || defined(_WIN32_WCE)
# define Q_OS_WINCE
+# elif defined(WINAPI_FAMILY)
+# if WINAPI_FAMILY==WINAPI_FAMILY_PHONE_APP
+# define Q_OS_WINPHONE
+# define Q_OS_WINRT
+# elif WINAPI_FAMILY==WINAPI_FAMILY_APP
+# define Q_OS_WINRT
+# else
+# define Q_OS_WIN32
+# endif
# else
# define Q_OS_WIN32
# endif
@@ -118,8 +136,11 @@
# define Q_OS_NACL
#elif defined(__linux__) || defined(__linux)
# define Q_OS_LINUX
-#elif defined(__FreeBSD__) || defined(__DragonFly__)
+#elif defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
+# ifndef __FreeBSD_kernel__
# define Q_OS_FREEBSD
+# endif
+# define Q_OS_FREEBSD_KERNEL
# define Q_OS_BSD4
#elif defined(__NetBSD__)
# define Q_OS_NETBSD
@@ -161,7 +182,7 @@
# error "Qt has not been ported to this OS - see http://www.qt-project.org/"
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN32) || defined(Q_OS_WIN64) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT)
# define Q_OS_WIN
#endif
@@ -175,8 +196,9 @@
# include <TargetConditionals.h>
# if defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE
# define Q_OS_IOS
-# else
-# define Q_OS_MACX
+# elif defined(TARGET_OS_MAC) && TARGET_OS_MAC
+# define Q_OS_OSX
+# define Q_OS_MACX // compatibility synonym
# endif
#endif
@@ -238,10 +260,6 @@
# if !defined(__IPHONE_7_0)
# define __IPHONE_7_0 70000
# endif
-#
-# if (__MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_8)
-# warning "This version of OS X is unsupported"
-# endif
#endif
#ifdef __LSB_VERSION__
diff --git a/src/corelib/global/qtypeinfo.h b/src/corelib/global/qtypeinfo.h
index 8e34c97..58736ac 100644
--- a/src/corelib/global/qtypeinfo.h
+++ b/src/corelib/global/qtypeinfo.h
@@ -110,7 +110,7 @@ public:
To create a proper QTypeInfo specialization for A struct, we have to check
all sub-components; B, C and D, then take the lowest common denominator and call
- Q_DECLATE_TYPEINFO with the resulting flags. An easier and less fragile approach is to
+ Q_DECLARE_TYPEINFO with the resulting flags. An easier and less fragile approach is to
use QTypeInfoMerger, which does that automatically. So struct A would have
the following QTypeInfo definition:
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index 969cdf4..f107e80 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -86,8 +86,9 @@ public:
Qt_4_8 = Qt_4_7,
Qt_4_9 = Qt_4_8,
Qt_5_0 = 13,
- Qt_5_1 = 14
-#if QT_VERSION >= 0x050200
+ Qt_5_1 = 14,
+ Qt_5_2 = 15
+#if QT_VERSION >= 0x050300
#error Add the datastream version for this Qt version
#endif
};
diff --git a/src/corelib/io/qfileinfo.h b/src/corelib/io/qfileinfo.h
index 211c18d..0f18261 100644
--- a/src/corelib/io/qfileinfo.h
+++ b/src/corelib/io/qfileinfo.h
@@ -84,6 +84,7 @@ public:
void setFile(const QFile &file);
void setFile(const QDir &dir, const QString &file);
bool exists() const;
+ static bool exists(const QString &file);
void refresh();
QString filePath() const;
diff --git a/src/corelib/io/qprocess.h b/src/corelib/io/qprocess.h
index 9da3e63..c0b3ab9 100644
--- a/src/corelib/io/qprocess.h
+++ b/src/corelib/io/qprocess.h
@@ -124,7 +124,13 @@ public:
enum ProcessChannelMode {
SeparateChannels,
MergedChannels,
- ForwardedChannels
+ ForwardedChannels,
+ ForwardedOutputChannel,
+ ForwardedErrorChannel
+ };
+ enum InputChannelMode {
+ ManagedInputChannel,
+ ForwardedInputChannel
};
enum ExitStatus {
NormalExit,
@@ -149,6 +155,8 @@ public:
void setReadChannelMode(ProcessChannelMode mode);
ProcessChannelMode processChannelMode() const;
void setProcessChannelMode(ProcessChannelMode mode);
+ InputChannelMode inputChannelMode() const;
+ void setInputChannelMode(InputChannelMode mode);
ProcessChannel readChannel() const;
void setReadChannel(ProcessChannel channel);
@@ -209,6 +217,8 @@ public:
static QStringList systemEnvironment();
+ static QString nullDevice();
+
public Q_SLOTS:
void terminate();
void kill();
diff --git a/src/corelib/io/qsavefile.h b/src/corelib/io/qsavefile.h
index 6d81f58..ad18417 100644
--- a/src/corelib/io/qsavefile.h
+++ b/src/corelib/io/qsavefile.h
@@ -42,6 +42,10 @@
#ifndef QSAVEFILE_H
#define QSAVEFILE_H
+#include <QtCore/qglobal.h>
+
+#ifndef QT_NO_TEMPORARYFILE
+
#include <QtCore/qfiledevice.h>
#include <QtCore/qstring.h>
@@ -51,7 +55,6 @@
QT_BEGIN_NAMESPACE
-
class QAbstractFileEngine;
class QSaveFilePrivate;
@@ -90,4 +93,6 @@ private:
QT_END_NAMESPACE
+#endif // QT_NO_TEMPORARYFILE
+
#endif // QSAVEFILE_H
diff --git a/src/corelib/io/qstandardpaths.h b/src/corelib/io/qstandardpaths.h
index d8b6d24..df9089a 100644
--- a/src/corelib/io/qstandardpaths.h
+++ b/src/corelib/io/qstandardpaths.h
@@ -89,7 +89,10 @@ public:
static QString findExecutable(const QString &executableName, const QStringList &paths = QStringList());
- static void enableTestMode(bool testMode);
+#if QT_DEPRECATED_SINCE(5, 2)
+ static QT_DEPRECATED void enableTestMode(bool testMode);
+#endif
+ static void setTestModeEnabled(bool testMode);
static bool isTestModeEnabled();
private:
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index de4ce75..e7edb43 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -50,6 +50,11 @@
#include <QtCore/qpair.h>
#include <QtCore/qglobal.h>
+#ifdef Q_OS_MAC
+Q_FORWARD_DECLARE_OBJC_CLASS(NSURL);
+Q_FORWARD_DECLARE_CF_TYPE(CFURL);
+#endif
+
QT_BEGIN_NAMESPACE
@@ -114,6 +119,10 @@ public:
template<typename E1, typename E2>
class QTypeInfo<QUrlTwoFlags<E1, E2> > : public QTypeInfoMerger<QUrlTwoFlags<E1, E2>, E1, E2> {};
+class QUrl;
+// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
+Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) Q_DECL_NOTHROW;
+
class Q_CORE_EXPORT QUrl
{
public:
@@ -136,7 +145,9 @@ public:
RemoveFragment = 0x80,
// 0x100 was a private code in Qt 4, keep unused for a while
PreferLocalFile = 0x200,
- StripTrailingSlash = 0x400
+ StripTrailingSlash = 0x400,
+ RemoveFilename = 0x800,
+ NormalizePathSegments = 0x1000
};
enum ComponentFormattingOption {
@@ -181,6 +192,7 @@ public:
QString url(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
QString toDisplayString(FormattingOptions options = FormattingOptions(PrettyDecoded)) const;
+ QUrl adjusted(FormattingOptions options) const;
QByteArray toEncoded(FormattingOptions options = FullyEncoded) const;
static QUrl fromEncoded(const QByteArray &url, ParsingMode mode = TolerantMode);
@@ -202,21 +214,22 @@ public:
void setUserInfo(const QString &userInfo, ParsingMode mode = TolerantMode);
QString userInfo(ComponentFormattingOptions options = PrettyDecoded) const;
- void setUserName(const QString &userName, ParsingMode mode = TolerantMode);
- QString userName(ComponentFormattingOptions options = PrettyDecoded) const;
+ void setUserName(const QString &userName, ParsingMode mode = DecodedMode);
+ QString userName(ComponentFormattingOptions options = FullyDecoded) const;
- void setPassword(const QString &password, ParsingMode mode = TolerantMode);
- QString password(ComponentFormattingOptions = PrettyDecoded) const;
+ void setPassword(const QString &password, ParsingMode mode = DecodedMode);
+ QString password(ComponentFormattingOptions = FullyDecoded) const;
- void setHost(const QString &host, ParsingMode mode = TolerantMode);
- QString host(ComponentFormattingOptions = PrettyDecoded) const;
- QString topLevelDomain(ComponentFormattingOptions options = PrettyDecoded) const;
+ void setHost(const QString &host, ParsingMode mode = DecodedMode);
+ QString host(ComponentFormattingOptions = FullyDecoded) const;
+ QString topLevelDomain(ComponentFormattingOptions options = FullyDecoded) const;
void setPort(int port);
int port(int defaultPort = -1) const;
- void setPath(const QString &path, ParsingMode mode = TolerantMode);
- QString path(ComponentFormattingOptions options = PrettyDecoded) const;
+ void setPath(const QString &path, ParsingMode mode = DecodedMode);
+ QString path(ComponentFormattingOptions options = FullyDecoded) const;
+ QString fileName(ComponentFormattingOptions options = FullyDecoded) const;
bool hasQuery() const;
void setQuery(const QString &query, ParsingMode mode = TolerantMode);
@@ -243,10 +256,19 @@ public:
bool operator ==(const QUrl &url) const;
bool operator !=(const QUrl &url) const;
+ bool matches(const QUrl &url, FormattingOptions options) const;
+
static QString fromPercentEncoding(const QByteArray &);
static QByteArray toPercentEncoding(const QString &,
const QByteArray &exclude = QByteArray(),
const QByteArray &include = QByteArray());
+#if defined(Q_OS_MAC) || defined(Q_QDOC)
+ static QUrl fromCFURL(CFURLRef url);
+ CFURLRef toCFURL() const Q_DECL_CF_RETURNS_RETAINED;
+ static QUrl fromNSURL(const NSURL *url);
+ NSURL *toNSURL() const Q_DECL_NS_RETURNS_AUTORELEASED;
+#endif
+
#if QT_DEPRECATED_SINCE(5,0)
QT_DEPRECATED static QString fromPunycode(const QByteArray &punycode)
{ return fromAce(punycode); }
@@ -324,7 +346,7 @@ public:
static QList<QUrl> fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode);
static void setIdnWhitelist(const QStringList &);
- friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) Q_DECL_NOTHROW;
+ friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW;
private:
QUrlPrivate *d;
diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h
index 215ccce..95b9d27 100644
--- a/src/corelib/itemmodels/qabstractitemmodel.h
+++ b/src/corelib/itemmodels/qabstractitemmodel.h
@@ -98,6 +98,9 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &);
class QPersistentModelIndexData;
+// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
+uint qHash(const QPersistentModelIndex &index, uint seed = 0);
+
class Q_CORE_EXPORT QPersistentModelIndex
{
public:
@@ -110,6 +113,11 @@ public:
inline bool operator!=(const QPersistentModelIndex &other) const
{ return !operator==(other); }
QPersistentModelIndex &operator=(const QPersistentModelIndex &other);
+#ifdef Q_COMPILER_RVALUE_REFS
+ inline QPersistentModelIndex(QPersistentModelIndex &&other) : d(other.d) { other.d = 0; }
+ inline QPersistentModelIndex &operator=(QPersistentModelIndex &&other)
+ { qSwap(d, other.d); return *this; }
+#endif
inline void swap(QPersistentModelIndex &other) { qSwap(d, other.d); }
bool operator==(const QModelIndex &other) const;
bool operator!=(const QModelIndex &other) const;
@@ -128,7 +136,7 @@ public:
bool isValid() const;
private:
QPersistentModelIndexData *d;
- friend uint qHash(const QPersistentModelIndex &, uint seed = 0);
+ friend uint qHash(const QPersistentModelIndex &, uint seed);
#ifndef QT_NO_DEBUG_STREAM
friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &);
#endif
@@ -424,6 +432,15 @@ public:
int row, int column, const QModelIndex &parent);
Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ inline QObject *parent() const { return QAbstractItemModel::parent(); }
+#endif
+#else
+ using QObject::parent;
+#endif
+
protected:
QAbstractTableModel(QAbstractItemModelPrivate &dd, QObject *parent);
@@ -446,6 +463,15 @@ public:
int row, int column, const QModelIndex &parent);
Qt::ItemFlags flags(const QModelIndex &index) const Q_DECL_OVERRIDE;
+
+#ifdef Q_NO_USING_KEYWORD
+#ifndef Q_QDOC
+ inline QObject *parent() const { return QAbstractItemModel::parent(); }
+#endif
+#else
+ using QObject::parent;
+#endif
+
protected:
QAbstractListModel(QAbstractItemModelPrivate &dd, QObject *parent);
diff --git a/src/corelib/json/qjsonarray.h b/src/corelib/json/qjsonarray.h
index 1474cca..562e6ac 100644
--- a/src/corelib/json/qjsonarray.h
+++ b/src/corelib/json/qjsonarray.h
@@ -211,7 +211,7 @@ private:
QJsonPrivate::Array *a;
};
-#ifndef QT_NO_DEBUG_STREAM
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonArray &);
#endif
diff --git a/src/corelib/json/qjsondocument.h b/src/corelib/json/qjsondocument.h
index 0354262..ea42d76 100644
--- a/src/corelib/json/qjsondocument.h
+++ b/src/corelib/json/qjsondocument.h
@@ -117,7 +117,7 @@ public:
#ifdef Q_QDOC
QByteArray toJson(JsonFormat format = Indented) const;
-#else
+#elif !defined(QT_JSON_READONLY)
QByteArray toJson() const; //### Merge in Qt6
QByteArray toJson(JsonFormat format) const;
#endif
@@ -148,7 +148,7 @@ private:
QJsonPrivate::Data *d;
};
-#ifndef QT_NO_DEBUG_STREAM
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonDocument &);
#endif
diff --git a/src/corelib/json/qjsonobject.h b/src/corelib/json/qjsonobject.h
index 8226b61..ad3184b 100644
--- a/src/corelib/json/qjsonobject.h
+++ b/src/corelib/json/qjsonobject.h
@@ -206,7 +206,7 @@ private:
QJsonPrivate::Object *o;
};
-#ifndef QT_NO_DEBUG_STREAM
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonObject &);
#endif
diff --git a/src/corelib/json/qjsonvalue.h b/src/corelib/json/qjsonvalue.h
index b8bdf55..c0ecdd2 100644
--- a/src/corelib/json/qjsonvalue.h
+++ b/src/corelib/json/qjsonvalue.h
@@ -79,6 +79,7 @@ public:
QJsonValue(bool b);
QJsonValue(double n);
QJsonValue(int n);
+ QJsonValue(qint64 n);
QJsonValue(const QString &s);
QJsonValue(QLatin1String s);
QJsonValue(const QJsonArray &a);
@@ -102,6 +103,7 @@ public:
inline bool isUndefined() const { return type() == Undefined; }
bool toBool(bool defaultValue = false) const;
+ int toInt(int defaultValue = 0) const;
double toDouble(double defaultValue = 0) const;
QString toString(const QString &defaultValue = QString()) const;
QJsonArray toArray() const;
@@ -157,6 +159,7 @@ public:
inline bool isUndefined() const { return type() == QJsonValue::Undefined; }
inline bool toBool() const { return toValue().toBool(); }
+ inline int toInt() const { return toValue().toInt(); }
inline double toDouble() const { return toValue().toDouble(); }
inline QString toString() const { return toValue().toString(); }
QJsonArray toArray() const;
@@ -176,7 +179,7 @@ private:
uint index : 31;
};
-#ifndef QT_NO_DEBUG_STREAM
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY)
Q_CORE_EXPORT QDebug operator<<(QDebug, const QJsonValue &);
#endif
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index 2ca0a7d..e974c4d 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -249,7 +249,7 @@ public:
TouchEnd = 196,
#ifndef QT_NO_GESTURES
- NativeGesture = 197, // Internal for platform gesture support
+ NativeGesture = 197, // QtGui native gesture
#endif
RequestSoftwareInputPanel = 199,
CloseSoftwareInputPanel = 200,
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
index ab7bbe3..c71bd6a 100644
--- a/src/corelib/kernel/qfunctions_wince.h
+++ b/src/corelib/kernel/qfunctions_wince.h
@@ -108,6 +108,7 @@ struct tm {
#endif // _TM_DEFINED
FILETIME qt_wince_time_tToFt( time_t tt );
+time_t qt_wince_ftToTime_t( const FILETIME ft );
// File I/O ---------------------------------------------------------
#define _O_RDONLY 0x0001
@@ -433,6 +434,7 @@ generate_inline_return_func4(getenv_s, errno_t, size_t *, char *, size_t, const
generate_inline_return_func2(_putenv_s, errno_t, const char *, const char *)
generate_inline_return_func0(_getpid, int)
generate_inline_return_func1(time_tToFt, FILETIME, time_t)
+generate_inline_return_func1(ftToTime_t, time_t, FILETIME)
generate_inline_return_func0(_getdrive, int)
generate_inline_return_func2(_waccess, int, const wchar_t *, int)
generate_inline_return_func3(_wopen, int, const wchar_t *, int, int)
diff --git a/src/corelib/kernel/qmetaobject.h b/src/corelib/kernel/qmetaobject.h
index 23fc89f..8186131 100644
--- a/src/corelib/kernel/qmetaobject.h
+++ b/src/corelib/kernel/qmetaobject.h
@@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE
template <typename T> class QList;
+#define Q_METAMETHOD_INVOKE_MAX_ARGS 10
+
class Q_CORE_EXPORT QMetaMethod
{
public:
@@ -146,8 +148,8 @@ public:
static inline QMetaMethod fromSignal(Func signal)
{
typedef QtPrivate::FunctionPointer<Func> SignalType;
- reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(
- *reinterpret_cast<typename SignalType::Object *>(0));
+ Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
+ "No Q_OBJECT in the class with the signal");
return fromSignalImpl(&SignalType::Object::staticMetaObject,
reinterpret_cast<void **>(&signal));
}
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index aed998f..4ccfc7b 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -47,17 +47,27 @@
#include <QtCore/qbytearray.h>
#include <QtCore/qvarlengtharray.h>
#include <QtCore/qisenum.h>
+#include <QtCore/qtypetraits.h>
#ifndef QT_NO_QOBJECT
#include <QtCore/qobjectdefs.h>
#endif
#include <new>
+#include <vector>
+#include <list>
+#include <map>
+
#ifdef Bool
#error qmetatype.h must be included before any header file that defines Bool
#endif
QT_BEGIN_NAMESPACE
+template <typename T>
+struct QMetaTypeId2;
+
+template <typename T>
+inline Q_DECL_CONSTEXPR int qMetaTypeId();
// F is a tuple: (QMetaType::TypeName, QMetaType::TypeNameID, RealType)
#define QT_FOR_EACH_STATIC_PRIMITIVE_TYPE(F)\
@@ -183,10 +193,190 @@ QT_BEGIN_NAMESPACE
#define QT_DEFINE_METATYPE_ID(TypeName, Id, Name) \
TypeName = Id,
+#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F) \
+ F(QList) \
+ F(QVector) \
+ F(QQueue) \
+ F(QStack) \
+ F(QSet) \
+ F(QLinkedList)
+
+#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F) \
+ F(QHash, class) \
+ F(QMap, class) \
+ F(QPair, struct)
+
+#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(F) \
+ F(QSharedPointer) \
+ F(QWeakPointer) \
+ F(QPointer)
+
class QDataStream;
class QMetaTypeInterface;
struct QMetaObject;
+namespace QtPrivate
+{
+/*!
+ This template is used for implicit conversion from type From to type To.
+ \internal
+*/
+template<typename From, typename To>
+To convertImplicit(const From& from)
+{
+ return from;
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+struct AbstractDebugStreamFunction
+{
+ typedef void (*Stream)(const AbstractDebugStreamFunction *, QDebug&, const void *);
+ typedef void (*Destroy)(AbstractDebugStreamFunction *);
+ explicit AbstractDebugStreamFunction(Stream s = 0, Destroy d = 0)
+ : stream(s), destroy(d) {}
+ Q_DISABLE_COPY(AbstractDebugStreamFunction)
+ Stream stream;
+ Destroy destroy;
+};
+
+template<typename T>
+struct BuiltInDebugStreamFunction : public AbstractDebugStreamFunction
+{
+ BuiltInDebugStreamFunction()
+ : AbstractDebugStreamFunction(stream, destroy) {}
+ static void stream(const AbstractDebugStreamFunction *, QDebug& dbg, const void *r)
+ {
+ const T *rhs = static_cast<const T *>(r);
+ operator<<(dbg, *rhs);
+ }
+
+ static void destroy(AbstractDebugStreamFunction *_this)
+ {
+ delete static_cast<BuiltInDebugStreamFunction *>(_this);
+ }
+};
+#endif
+
+struct AbstractComparatorFunction
+{
+ typedef bool (*LessThan)(const AbstractComparatorFunction *, const void *, const void *);
+ typedef bool (*Equals)(const AbstractComparatorFunction *, const void *, const void *);
+ typedef void (*Destroy)(AbstractComparatorFunction *);
+ explicit AbstractComparatorFunction(LessThan lt = 0, Equals e = 0, Destroy d = 0)
+ : lessThan(lt), equals(e), destroy(d) {}
+ Q_DISABLE_COPY(AbstractComparatorFunction)
+ LessThan lessThan;
+ Equals equals;
+ Destroy destroy;
+};
+
+template<typename T>
+struct BuiltInComparatorFunction : public AbstractComparatorFunction
+{
+ BuiltInComparatorFunction()
+ : AbstractComparatorFunction(lessThan, equals, destroy) {}
+ static bool lessThan(const AbstractComparatorFunction *, const void *l, const void *r)
+ {
+ const T *lhs = static_cast<const T *>(l);
+ const T *rhs = static_cast<const T *>(r);
+ return *lhs < *rhs;
+ }
+
+ static bool equals(const AbstractComparatorFunction *, const void *l, const void *r)
+ {
+ const T *lhs = static_cast<const T *>(l);
+ const T *rhs = static_cast<const T *>(r);
+ return *lhs == *rhs;
+ }
+
+ static void destroy(AbstractComparatorFunction *_this)
+ {
+ delete static_cast<BuiltInComparatorFunction *>(_this);
+ }
+};
+
+struct AbstractConverterFunction
+{
+ typedef bool (*Converter)(const AbstractConverterFunction *, const void *, void*);
+ explicit AbstractConverterFunction(Converter c = 0)
+ : convert(c) {}
+ Q_DISABLE_COPY(AbstractConverterFunction)
+ Converter convert;
+};
+
+template<typename From, typename To>
+struct ConverterMemberFunction : public AbstractConverterFunction
+{
+ explicit ConverterMemberFunction(To(From::*function)() const)
+ : AbstractConverterFunction(convert),
+ m_function(function) {}
+ ~ConverterMemberFunction();
+ static bool convert(const AbstractConverterFunction *_this, const void *in, void *out)
+ {
+ const From *f = static_cast<const From *>(in);
+ To *t = static_cast<To *>(out);
+ const ConverterMemberFunction *_typedThis =
+ static_cast<const ConverterMemberFunction *>(_this);
+ *t = (f->*_typedThis->m_function)();
+ return true;
+ }
+
+ To(From::* const m_function)() const;
+};
+
+template<typename From, typename To>
+struct ConverterMemberFunctionOk : public AbstractConverterFunction
+{
+ explicit ConverterMemberFunctionOk(To(From::*function)(bool *) const)
+ : AbstractConverterFunction(convert),
+ m_function(function) {}
+ ~ConverterMemberFunctionOk();
+ static bool convert(const AbstractConverterFunction *_this, const void *in, void *out)
+ {
+ const From *f = static_cast<const From *>(in);
+ To *t = static_cast<To *>(out);
+ bool ok = false;
+ const ConverterMemberFunctionOk *_typedThis =
+ static_cast<const ConverterMemberFunctionOk *>(_this);
+ *t = (f->*_typedThis->m_function)(&ok);
+ if (!ok)
+ *t = To();
+ return ok;
+ }
+
+ To(From::* const m_function)(bool*) const;
+};
+
+template<typename From, typename To, typename UnaryFunction>
+struct ConverterFunctor : public AbstractConverterFunction
+{
+ explicit ConverterFunctor(UnaryFunction function)
+ : AbstractConverterFunction(convert),
+ m_function(function) {}
+ ~ConverterFunctor();
+ static bool convert(const AbstractConverterFunction *_this, const void *in, void *out)
+ {
+ const From *f = static_cast<const From *>(in);
+ To *t = static_cast<To *>(out);
+ const ConverterFunctor *_typedThis =
+ static_cast<const ConverterFunctor *>(_this);
+ *t = _typedThis->m_function(*f);
+ return true;
+ }
+
+ UnaryFunction m_function;
+};
+
+ template<typename T, bool>
+ struct ValueTypeIsMetaType;
+ template<typename T, bool>
+ struct AssociativeValueTypeIsMetaType;
+ template<typename T, bool>
+ struct IsMetaTypePair;
+ template<typename, typename>
+ struct MetaTypeSmartPointerHelper;
+}
+
class Q_CORE_EXPORT QMetaType {
enum ExtensionFlag { NoExtensionFlags,
CreateEx = 0x1, DestroyEx = 0x2,
@@ -320,6 +510,109 @@ public:
inline void destroy(void *data) const;
inline void *construct(void *where, const void *copy = 0) const;
inline void destruct(void *data) const;
+
+public:
+ template<typename T>
+ static bool registerComparators()
+ {
+ Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn),
+ "QMetaType::registerComparators: The type must be a custom type.");
+
+ const int typeId = qMetaTypeId<T>();
+ static const QtPrivate::BuiltInComparatorFunction<T> f;
+ return registerComparatorFunction( &f, typeId);
+ }
+ template<typename T>
+ static bool hasRegisteredComparators()
+ {
+ return hasRegisteredComparators(qMetaTypeId<T>());
+ }
+ static bool hasRegisteredComparators(int typeId);
+
+
+#ifndef QT_NO_DEBUG_STREAM
+ template<typename T>
+ static bool registerDebugStreamOperator()
+ {
+ Q_STATIC_ASSERT_X((!QMetaTypeId2<T>::IsBuiltIn),
+ "QMetaType::registerDebugStreamOperator: The type must be a custom type.");
+
+ const int typeId = qMetaTypeId<T>();
+ static const QtPrivate::BuiltInDebugStreamFunction<T> f;
+ return registerDebugStreamOperatorFunction(&f, typeId);
+ }
+ template<typename T>
+ static bool hasRegisteredDebugStreamOperator()
+ {
+ return hasRegisteredDebugStreamOperator(qMetaTypeId<T>());
+ }
+ static bool hasRegisteredDebugStreamOperator(int typeId);
+#endif
+
+ // implicit conversion supported like double -> float
+ template<typename From, typename To>
+ static bool registerConverter()
+ {
+ return registerConverter<From, To>(QtPrivate::convertImplicit<From, To>);
+ }
+
+#ifdef Q_QDOC
+ static bool registerConverter(MemberFunction function);
+ static bool registerConverter(MemberFunctionOk function);
+ static bool registerConverter(UnaryFunction function);
+#else
+ // member function as in "QString QFont::toString() const"
+ template<typename From, typename To>
+ static bool registerConverter(To(From::*function)() const)
+ {
+ Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
+ "QMetaType::registerConverter: At least one of the types must be a custom type.");
+
+ const int fromTypeId = qMetaTypeId<From>();
+ const int toTypeId = qMetaTypeId<To>();
+ static const QtPrivate::ConverterMemberFunction<From, To> f(function);
+ return registerConverterFunction(&f, fromTypeId, toTypeId);
+ }
+
+ // member function as in "double QString::toDouble(bool *ok = 0) const"
+ template<typename From, typename To>
+ static bool registerConverter(To(From::*function)(bool*) const)
+ {
+ Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
+ "QMetaType::registerConverter: At least one of the types must be a custom type.");
+
+ const int fromTypeId = qMetaTypeId<From>();
+ const int toTypeId = qMetaTypeId<To>();
+ static const QtPrivate::ConverterMemberFunctionOk<From, To> f(function);
+ return registerConverterFunction(&f, fromTypeId, toTypeId);
+ }
+
+ // functor or function pointer
+ template<typename From, typename To, typename UnaryFunction>
+ static bool registerConverter(UnaryFunction function)
+ {
+ Q_STATIC_ASSERT_X((!QMetaTypeId2<To>::IsBuiltIn || !QMetaTypeId2<From>::IsBuiltIn),
+ "QMetaType::registerConverter: At least one of the types must be a custom type.");
+
+ const int fromTypeId = qMetaTypeId<From>();
+ const int toTypeId = qMetaTypeId<To>();
+ static const QtPrivate::ConverterFunctor<From, To, UnaryFunction> f(function);
+ return registerConverterFunction(&f, fromTypeId, toTypeId);
+ }
+#endif
+
+ static bool convert(const void *from, int fromTypeId, void *to, int toTypeId);
+ static bool compare(const void *lhs, const void *rhs, int typeId, int* result);
+ static bool debugStream(QDebug& dbg, const void *rhs, int typeId);
+
+ template<typename From, typename To>
+ static bool hasRegisteredConverterFunction()
+ {
+ return hasRegisteredConverterFunction(qMetaTypeId<From>(), qMetaTypeId<To>());
+ }
+
+ static bool hasRegisteredConverterFunction(int fromTypeId, int toTypeId);
+
private:
static QMetaType typeInfo(const int type);
inline QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info,
@@ -348,6 +641,32 @@ private:
void *constructExtended(void *where, const void *copy = 0) const;
void destructExtended(void *data) const;
+ static bool registerComparatorFunction(const QtPrivate::AbstractComparatorFunction *f, int type);
+#ifndef QT_NO_DEBUG_STREAM
+ static bool registerDebugStreamOperatorFunction(const QtPrivate::AbstractDebugStreamFunction *f, int type);
+#endif
+
+#ifndef Q_NO_TEMPLATE_FRIENDS
+#ifndef Q_QDOC
+ template<typename T>
+ friend bool qRegisterSequentialConverter();
+ template<typename, bool> friend struct QtPrivate::ValueTypeIsMetaType;
+ template<typename, typename> friend struct QtPrivate::ConverterMemberFunction;
+ template<typename, typename> friend struct QtPrivate::ConverterMemberFunctionOk;
+ template<typename, typename, typename> friend struct QtPrivate::ConverterFunctor;
+ template<typename T>
+ friend bool qRegisterAssociativeConverter();
+ template<typename, bool> friend struct QtPrivate::AssociativeValueTypeIsMetaType;
+ template<typename, bool> friend struct QtPrivate::IsMetaTypePair;
+ template<typename, typename> friend struct QtPrivate::MetaTypeSmartPointerHelper;
+#endif
+#else
+public:
+#endif
+ static bool registerConverterFunction(const QtPrivate::AbstractConverterFunction *f, int from, int to);
+ static void unregisterConverterFunction(int from, int to);
+private:
+
Creator m_creator;
Deleter m_deleter;
SaveOperator m_saveOp;
@@ -366,6 +685,26 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QMetaType::TypeFlags)
+namespace QtPrivate {
+
+template<typename From, typename To>
+ConverterMemberFunction<From, To>::~ConverterMemberFunction()
+{
+ QMetaType::unregisterConverterFunction(qMetaTypeId<From>(), qMetaTypeId<To>());
+}
+template<typename From, typename To>
+ConverterMemberFunctionOk<From, To>::~ConverterMemberFunctionOk()
+{
+ QMetaType::unregisterConverterFunction(qMetaTypeId<From>(), qMetaTypeId<To>());
+}
+template<typename From, typename To, typename UnaryFunction>
+ConverterFunctor<From, To, UnaryFunction>::~ConverterFunctor()
+{
+ QMetaType::unregisterConverterFunction(qMetaTypeId<From>(), qMetaTypeId<To>());
+}
+
+}
+
namespace QtMetaTypePrivate {
template <typename T, bool Accepted = true>
struct QMetaTypeFunctionHelper {
@@ -421,13 +760,513 @@ template <>
struct QMetaTypeFunctionHelper<void, /* Accepted */ true>
: public QMetaTypeFunctionHelper<void, /* Accepted */ false>
{};
+
+struct VariantData
+{
+ VariantData(const int metaTypeId_,
+ const void *data_,
+ const uint flags_)
+ : metaTypeId(metaTypeId_)
+ , data(data_)
+ , flags(flags_)
+ {
+ }
+ const int metaTypeId;
+ const void *data;
+ const uint flags;
+};
+
+template<typename const_iterator>
+struct IteratorOwner
+{
+ static void assign(void **ptr, const_iterator iterator)
+ {
+ *ptr = new const_iterator(iterator);
+ }
+
+ static void advance(void **iterator, int step)
+ {
+ const_iterator &it = *static_cast<const_iterator*>(*iterator);
+ std::advance(it, step);
+ }
+
+ static void destroy(void **ptr)
+ {
+ delete static_cast<const_iterator*>(*ptr);
+ }
+
+ static const void *getData(void * const *iterator)
+ {
+ return &**static_cast<const_iterator*>(*iterator);
+ }
+
+ static const void *getData(const_iterator it)
+ {
+ return &*it;
+ }
+};
+template<typename const_iterator>
+struct IteratorOwner<const const_iterator*>
+{
+ static void assign(void **ptr, const const_iterator *iterator )
+ {
+ *ptr = const_cast<const_iterator*>(iterator);
+ }
+
+ static void advance(void **iterator, int step)
+ {
+ const_iterator *it = static_cast<const_iterator*>(*iterator);
+ std::advance(it, step);
+ *iterator = it;
+ }
+
+ static void destroy(void **)
+ {
+ }
+
+ static const void *getData(void * const *iterator)
+ {
+ return *iterator;
+ }
+
+ static const void *getData(const const_iterator *it)
+ {
+ return it;
+ }
+};
+
+enum IteratorCapability
+{
+ ForwardCapability = 1,
+ BiDirectionalCapability = 2,
+ RandomAccessCapability = 4
+};
+
+template<typename T, typename Category = typename std::iterator_traits<typename T::const_iterator>::iterator_category>
+struct CapabilitiesImpl;
+
+template<typename T>
+struct CapabilitiesImpl<T, std::forward_iterator_tag>
+{ enum { IteratorCapabilities = ForwardCapability }; };
+template<typename T>
+struct CapabilitiesImpl<T, std::bidirectional_iterator_tag>
+{ enum { IteratorCapabilities = BiDirectionalCapability | ForwardCapability }; };
+template<typename T>
+struct CapabilitiesImpl<T, std::random_access_iterator_tag>
+{ enum { IteratorCapabilities = RandomAccessCapability | BiDirectionalCapability | ForwardCapability }; };
+
+template<typename T>
+struct ContainerAPI : CapabilitiesImpl<T>
+{
+ static int size(const T *t) { return std::distance(t->begin(), t->end()); }
+};
+
+template<typename T>
+struct ContainerAPI<QList<T> > : CapabilitiesImpl<QList<T> >
+{ static int size(const QList<T> *t) { return t->size(); } };
+
+template<typename T>
+struct ContainerAPI<QVector<T> > : CapabilitiesImpl<QVector<T> >
+{ static int size(const QVector<T> *t) { return t->size(); } };
+
+template<typename T>
+struct ContainerAPI<std::vector<T> > : CapabilitiesImpl<std::vector<T> >
+{ static int size(const std::vector<T> *t) { return t->size(); } };
+
+template<typename T>
+struct ContainerAPI<std::list<T> > : CapabilitiesImpl<std::list<T> >
+{ static int size(const std::list<T> *t) { return t->size(); } };
+
+class QSequentialIterableImpl
+{
+public:
+ const void * _iterable;
+ void *_iterator;
+ int _metaType_id;
+ uint _metaType_flags;
+ uint _iteratorCapabilities;
+ typedef int(*sizeFunc)(const void *p);
+ typedef const void * (*atFunc)(const void *p, int);
+ typedef void (*moveIteratorFunc)(const void *p, void **);
+ typedef void (*advanceFunc)(void **p, int);
+ typedef VariantData (*getFunc)( void * const *p, int metaTypeId, uint flags);
+ typedef void (*destroyIterFunc)(void **p);
+ typedef bool (*equalIterFunc)(void * const *p, void * const *other);
+ typedef void (*copyIterFunc)(void **, void * const *);
+
+ sizeFunc _size;
+ atFunc _at;
+ moveIteratorFunc _moveToBegin;
+ moveIteratorFunc _moveToEnd;
+ advanceFunc _advance;
+ getFunc _get;
+ destroyIterFunc _destroyIter;
+ equalIterFunc _equalIter;
+ copyIterFunc _copyIter;
+
+ template<class T>
+ static int sizeImpl(const void *p)
+ { return ContainerAPI<T>::size(static_cast<const T*>(p)); }
+
+ template<class T>
+ static const void* atImpl(const void *p, int idx)
+ {
+ typename T::const_iterator i = static_cast<const T*>(p)->begin();
+ std::advance(i, idx);
+ return IteratorOwner<typename T::const_iterator>::getData(i);
+ }
+
+ template<class T>
+ static void advanceImpl(void **p, int step)
+ { IteratorOwner<typename T::const_iterator>::advance(p, step); }
+
+ template<class T>
+ static void moveToBeginImpl(const void *container, void **iterator)
+ { IteratorOwner<typename T::const_iterator>::assign(iterator, static_cast<const T*>(container)->begin()); }
+
+ template<class T>
+ static void moveToEndImpl(const void *container, void **iterator)
+ { IteratorOwner<typename T::const_iterator>::assign(iterator, static_cast<const T*>(container)->end()); }
+
+ template<class T>
+ static void destroyIterImpl(void **iterator)
+ { IteratorOwner<typename T::const_iterator>::destroy(iterator); }
+
+ template<class T>
+ static bool equalIterImpl(void * const *iterator, void * const *other)
+ { return *static_cast<typename T::const_iterator*>(*iterator) == *static_cast<typename T::const_iterator*>(*other); }
+
+ template<class T>
+ static VariantData getImpl(void * const *iterator, int metaTypeId, uint flags)
+ { return VariantData(metaTypeId, IteratorOwner<typename T::const_iterator>::getData(iterator), flags); }
+
+ template<class T>
+ static void copyIterImpl(void **dest, void * const * src)
+ { IteratorOwner<typename T::const_iterator>::assign(dest, *static_cast<typename T::const_iterator*>(*src)); }
+
+public:
+ template<class T> QSequentialIterableImpl(const T*p)
+ : _iterable(p)
+ , _iterator(0)
+ , _metaType_id(qMetaTypeId<typename T::value_type>())
+ , _metaType_flags(QTypeInfo<typename T::value_type>::isPointer)
+ , _iteratorCapabilities(ContainerAPI<T>::IteratorCapabilities)
+ , _size(sizeImpl<T>)
+ , _at(atImpl<T>)
+ , _moveToBegin(moveToBeginImpl<T>)
+ , _moveToEnd(moveToEndImpl<T>)
+ , _advance(advanceImpl<T>)
+ , _get(getImpl<T>)
+ , _destroyIter(destroyIterImpl<T>)
+ , _equalIter(equalIterImpl<T>)
+ , _copyIter(copyIterImpl<T>)
+ {
+ }
+
+ QSequentialIterableImpl()
+ : _iterable(0)
+ , _iterator(0)
+ , _metaType_id(QMetaType::UnknownType)
+ , _metaType_flags(0)
+ , _iteratorCapabilities(0)
+ , _size(0)
+ , _at(0)
+ , _moveToBegin(0)
+ , _moveToEnd(0)
+ , _advance(0)
+ , _get(0)
+ , _destroyIter(0)
+ , _equalIter(0)
+ , _copyIter(0)
+ {
+ }
+
+ inline void moveToBegin() { _moveToBegin(_iterable, &_iterator); }
+ inline void moveToEnd() { _moveToEnd(_iterable, &_iterator); }
+ inline bool equal(const QSequentialIterableImpl&other) const { return _equalIter(&_iterator, &other._iterator); }
+ inline QSequentialIterableImpl &advance(int i) {
+ Q_ASSERT(i > 0 || _iteratorCapabilities & BiDirectionalCapability);
+ _advance(&_iterator, i);
+ return *this;
+ }
+
+ inline VariantData getCurrent() const { return _get(&_iterator, _metaType_id, _metaType_flags); }
+
+ VariantData at(int idx) const
+ { return VariantData(_metaType_id, _at(_iterable, idx), _metaType_flags); }
+
+ int size() const { Q_ASSERT(_iterable); return _size(_iterable); }
+
+ inline void destroyIter() { _destroyIter(&_iterator); }
+
+ void copy(const QSequentialIterableImpl &other)
+ {
+ *this = other;
+ _copyIter(&_iterator, &other._iterator);
+ }
+};
+
+template<typename From>
+struct QSequentialIterableConvertFunctor
+{
+ QSequentialIterableImpl operator()(const From &f) const
+ {
+ return QSequentialIterableImpl(&f);
+ }
+};
+}
+
+namespace QtMetaTypePrivate {
+template<typename T, bool = QtPrivate::is_same<typename T::const_iterator::value_type, typename T::mapped_type>::value>
+struct AssociativeContainerAccessor
+{
+ static const typename T::key_type& getKey(const typename T::const_iterator &it)
+ {
+ return it.key();
+ }
+
+ static const typename T::mapped_type& getValue(const typename T::const_iterator &it)
+ {
+ return it.value();
+ }
+};
+
+template<typename T, bool = QtPrivate::is_same<typename T::const_iterator::value_type, std::pair<const typename T::key_type, typename T::mapped_type> >::value>
+struct StlStyleAssociativeContainerAccessor;
+
+template<typename T>
+struct StlStyleAssociativeContainerAccessor<T, true>
+{
+ static const typename T::key_type& getKey(const typename T::const_iterator &it)
+ {
+ return it->first;
+ }
+
+ static const typename T::mapped_type& getValue(const typename T::const_iterator &it)
+ {
+ return it->second;
+ }
+};
+
+template<typename T>
+struct AssociativeContainerAccessor<T, false> : public StlStyleAssociativeContainerAccessor<T>
+{
+};
+
+class QAssociativeIterableImpl
+{
+public:
+ const void *_iterable;
+ void *_iterator;
+ int _metaType_id_key;
+ uint _metaType_flags_key;
+ int _metaType_id_value;
+ uint _metaType_flags_value;
+ typedef int(*sizeFunc)(const void *p);
+ typedef void (*findFunc)(const void *container, const void *p, void **iterator);
+ typedef void (*beginFunc)(const void *p, void **);
+ typedef void (*advanceFunc)(void **p, int);
+ typedef VariantData (*getFunc)(void * const *p, int metaTypeId, uint flags);
+ typedef void (*destroyIterFunc)(void **p);
+ typedef bool (*equalIterFunc)(void * const *p, void * const *other);
+ typedef void (*copyIterFunc)(void **, void * const *);
+
+ sizeFunc _size;
+ findFunc _find;
+ beginFunc _begin;
+ beginFunc _end;
+ advanceFunc _advance;
+ getFunc _getKey;
+ getFunc _getValue;
+ destroyIterFunc _destroyIter;
+ equalIterFunc _equalIter;
+ copyIterFunc _copyIter;
+
+ template<class T>
+ static int sizeImpl(const void *p)
+ { return std::distance(static_cast<const T*>(p)->begin(),
+ static_cast<const T*>(p)->end()); }
+
+ template<class T>
+ static void findImpl(const void *container, const void *p, void **iterator)
+ { IteratorOwner<typename T::const_iterator>::assign(iterator,
+ static_cast<const T*>(container)->find(*static_cast<const typename T::key_type*>(p))); }
+
+ template<class T>
+ static void advanceImpl(void **p, int step)
+ { std::advance(*static_cast<typename T::const_iterator*>(*p), step); }
+
+ template<class T>
+ static void beginImpl(const void *container, void **iterator)
+ { IteratorOwner<typename T::const_iterator>::assign(iterator, static_cast<const T*>(container)->begin()); }
+
+ template<class T>
+ static void endImpl(const void *container, void **iterator)
+ { IteratorOwner<typename T::const_iterator>::assign(iterator, static_cast<const T*>(container)->end()); }
+
+ template<class T>
+ static VariantData getKeyImpl(void * const *iterator, int metaTypeId, uint flags)
+ { return VariantData(metaTypeId, &AssociativeContainerAccessor<T>::getKey(*static_cast<typename T::const_iterator*>(*iterator)), flags); }
+
+ template<class T>
+ static VariantData getValueImpl(void * const *iterator, int metaTypeId, uint flags)
+ { return VariantData(metaTypeId, &AssociativeContainerAccessor<T>::getValue(*static_cast<typename T::const_iterator*>(*iterator)), flags); }
+
+ template<class T>
+ static void destroyIterImpl(void **iterator)
+ { IteratorOwner<typename T::const_iterator>::destroy(iterator); }
+
+ template<class T>
+ static bool equalIterImpl(void * const *iterator, void * const *other)
+ { return *static_cast<typename T::const_iterator*>(*iterator) == *static_cast<typename T::const_iterator*>(*other); }
+
+ template<class T>
+ static void copyIterImpl(void **dest, void * const * src)
+ { IteratorOwner<typename T::const_iterator>::assign(dest, *static_cast<typename T::const_iterator*>(*src)); }
+
+public:
+ template<class T> QAssociativeIterableImpl(const T*p)
+ : _iterable(p)
+ , _metaType_id_key(qMetaTypeId<typename T::key_type>())
+ , _metaType_flags_key(QTypeInfo<typename T::key_type>::isPointer)
+ , _metaType_id_value(qMetaTypeId<typename T::mapped_type>())
+ , _metaType_flags_value(QTypeInfo<typename T::mapped_type>::isPointer)
+ , _size(sizeImpl<T>)
+ , _find(findImpl<T>)
+ , _begin(beginImpl<T>)
+ , _end(endImpl<T>)
+ , _advance(advanceImpl<T>)
+ , _getKey(getKeyImpl<T>)
+ , _getValue(getValueImpl<T>)
+ , _destroyIter(destroyIterImpl<T>)
+ , _equalIter(equalIterImpl<T>)
+ , _copyIter(copyIterImpl<T>)
+ {
+ }
+
+ QAssociativeIterableImpl()
+ : _iterable(0)
+ , _metaType_id_key(QMetaType::UnknownType)
+ , _metaType_flags_key(0)
+ , _metaType_id_value(QMetaType::UnknownType)
+ , _metaType_flags_value(0)
+ , _size(0)
+ , _find(0)
+ , _begin(0)
+ , _end(0)
+ , _advance(0)
+ , _getKey(0)
+ , _getValue(0)
+ , _destroyIter(0)
+ , _equalIter(0)
+ , _copyIter(0)
+ {
+ }
+
+ inline void begin() { _begin(_iterable, &_iterator); }
+ inline void end() { _end(_iterable, &_iterator); }
+ inline bool equal(const QAssociativeIterableImpl&other) const { return _equalIter(&_iterator, &other._iterator); }
+ inline QAssociativeIterableImpl &advance(int i) { _advance(&_iterator, i); return *this; }
+
+ inline void destroyIter() { _destroyIter(&_iterator); }
+
+ inline VariantData getCurrentKey() const { return _getKey(&_iterator, _metaType_id_key, _metaType_flags_value); }
+ inline VariantData getCurrentValue() const { return _getValue(&_iterator, _metaType_id_value, _metaType_flags_value); }
+
+ inline void find(const VariantData &key)
+ { _find(_iterable, key.data, &_iterator); }
+
+ int size() const { Q_ASSERT(_iterable); return _size(_iterable); }
+
+ void copy(const QAssociativeIterableImpl &other)
+ {
+ *this = other;
+ _copyIter(&_iterator, &other._iterator);
+ }
+};
+
+template<typename From>
+struct QAssociativeIterableConvertFunctor
+{
+ QAssociativeIterableImpl operator()(const From& f) const
+ {
+ return QAssociativeIterableImpl(&f);
+ }
+};
+
+class QPairVariantInterfaceImpl
+{
+ const void *_pair;
+ int _metaType_id_first;
+ uint _metaType_flags_first;
+ int _metaType_id_second;
+ uint _metaType_flags_second;
+
+ typedef VariantData (*getFunc)(const void * const *p, int metaTypeId, uint flags);
+
+ getFunc _getFirst;
+ getFunc _getSecond;
+
+ template<class T>
+ static VariantData getFirstImpl(const void * const *pair, int metaTypeId, uint flags)
+ { return VariantData(metaTypeId, &static_cast<const T*>(*pair)->first, flags); }
+ template<class T>
+ static VariantData getSecondImpl(const void * const *pair, int metaTypeId, uint flags)
+ { return VariantData(metaTypeId, &static_cast<const T*>(*pair)->second, flags); }
+
+public:
+ template<class T> QPairVariantInterfaceImpl(const T*p)
+ : _pair(p)
+ , _metaType_id_first(qMetaTypeId<typename T::first_type>())
+ , _metaType_flags_first(QTypeInfo<typename T::first_type>::isPointer)
+ , _metaType_id_second(qMetaTypeId<typename T::second_type>())
+ , _metaType_flags_second(QTypeInfo<typename T::second_type>::isPointer)
+ , _getFirst(getFirstImpl<T>)
+ , _getSecond(getSecondImpl<T>)
+ {
+ }
+
+ QPairVariantInterfaceImpl()
+ : _pair(0)
+ , _getFirst(0)
+ , _getSecond(0)
+ {
+ }
+
+ inline VariantData first() const { return _getFirst(&_pair, _metaType_id_first, _metaType_flags_first); }
+ inline VariantData second() const { return _getSecond(&_pair, _metaType_id_second, _metaType_flags_second); }
+};
+
+template<typename From>
+struct QPairVariantInterfaceConvertFunctor;
+
+template<typename T, typename U>
+struct QPairVariantInterfaceConvertFunctor<QPair<T, U> >
+{
+ QPairVariantInterfaceImpl operator()(const QPair<T, U>& f) const
+ {
+ return QPairVariantInterfaceImpl(&f);
+ }
+};
+
+template<typename T, typename U>
+struct QPairVariantInterfaceConvertFunctor<std::pair<T, U> >
+{
+ QPairVariantInterfaceImpl operator()(const std::pair<T, U>& f) const
+ {
+ return QPairVariantInterfaceImpl(&f);
+ }
+};
+
}
class QObject;
class QWidget;
-template <class T> class QSharedPointer;
-template <class T> class QWeakPointer;
-template <class T> class QPointer;
+
+#define QT_FORWARD_DECLARE_SHARED_POINTER_TYPES_ITER(Name) \
+ template <class T> class Name; \
+
+QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(QT_FORWARD_DECLARE_SHARED_POINTER_TYPES_ITER)
namespace QtPrivate
{
@@ -509,6 +1348,116 @@ namespace QtPrivate
enum { Value = true };
};
+ template<typename T>
+ struct IsSequentialContainer
+ {
+ enum { Value = false };
+ };
+
+ template<typename T>
+ struct IsAssociativeContainer
+ {
+ enum { Value = false };
+ };
+
+ template<typename T, bool = QtPrivate::IsSequentialContainer<T>::Value>
+ struct SequentialContainerConverterHelper
+ {
+ static bool registerConverter(int)
+ {
+ return false;
+ }
+ };
+
+ template<typename T, bool = QMetaTypeId2<typename T::value_type>::Defined>
+ struct ValueTypeIsMetaType
+ {
+ static bool registerConverter(int)
+ {
+ return false;
+ }
+ };
+
+ template<typename T>
+ struct SequentialContainerConverterHelper<T, true> : ValueTypeIsMetaType<T>
+ {
+ };
+
+ template<typename T, bool = QtPrivate::IsAssociativeContainer<T>::Value>
+ struct AssociativeContainerConverterHelper
+ {
+ static bool registerConverter(int)
+ {
+ return false;
+ }
+ };
+
+ template<typename T, bool = QMetaTypeId2<typename T::mapped_type>::Defined>
+ struct AssociativeValueTypeIsMetaType
+ {
+ static bool registerConverter(int)
+ {
+ return false;
+ }
+ };
+
+ template<typename T, bool = QMetaTypeId2<typename T::key_type>::Defined>
+ struct KeyAndValueTypeIsMetaType
+ {
+ static bool registerConverter(int)
+ {
+ return false;
+ }
+ };
+
+ template<typename T>
+ struct KeyAndValueTypeIsMetaType<T, true> : AssociativeValueTypeIsMetaType<T>
+ {
+ };
+
+ template<typename T>
+ struct AssociativeContainerConverterHelper<T, true> : KeyAndValueTypeIsMetaType<T>
+ {
+ };
+
+ template<typename T, bool = QMetaTypeId2<typename T::first_type>::Defined
+ && QMetaTypeId2<typename T::second_type>::Defined>
+ struct IsMetaTypePair
+ {
+ static bool registerConverter(int)
+ {
+ return false;
+ }
+ };
+
+ template<typename T>
+ struct IsMetaTypePair<T, true>
+ {
+ inline static bool registerConverter(int id);
+ };
+
+ template<typename T>
+ struct IsPair
+ {
+ static bool registerConverter(int)
+ {
+ return false;
+ }
+ };
+ template<typename T, typename U>
+ struct IsPair<QPair<T, U> > : IsMetaTypePair<QPair<T, U> > {};
+ template<typename T, typename U>
+ struct IsPair<std::pair<T, U> > : IsMetaTypePair<std::pair<T, U> > {};
+
+ template<typename T>
+ struct MetaTypePairHelper : IsPair<T> {};
+
+ template<typename T, typename = void>
+ struct MetaTypeSmartPointerHelper
+ {
+ static bool registerConverter(int) { return false; }
+ };
+
Q_CORE_EXPORT bool isBuiltinType(const QByteArray &type);
} // namespace QtPrivate
@@ -546,11 +1495,16 @@ namespace QtPrivate {
{ return -1; }
};
+#ifndef Q_COMPILER_VARIADIC_TEMPLATES
// Function pointers don't derive from QObject
template <class Result> struct IsPointerToTypeDerivedFromQObject<Result(*)()> { enum { Value = false }; };
template <class Result, class Arg0> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0)> { enum { Value = false }; };
template <class Result, class Arg0, class Arg1> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1)> { enum { Value = false }; };
template <class Result, class Arg0, class Arg1, class Arg2> struct IsPointerToTypeDerivedFromQObject<Result(*)(Arg0, Arg1, Arg2)> { enum { Value = false }; };
+#else
+ template <typename Result, typename... Args>
+ struct IsPointerToTypeDerivedFromQObject<Result(*)(Args...)> { enum { Value = false }; };
+#endif
template<typename T>
struct QMetaTypeTypeFlags
@@ -571,6 +1525,24 @@ namespace QtPrivate {
{
enum DefinedType { Defined = defined };
};
+
+ template<typename SmartPointer>
+ struct QSmartPointerConvertFunctor
+ {
+ QObject* operator()(const SmartPointer &p) const
+ {
+ return p.operator->();
+ }
+ };
+
+ template<typename T>
+ struct QSmartPointerConvertFunctor<QWeakPointer<T> >
+ {
+ QObject* operator()(const QWeakPointer<T> &p) const
+ {
+ return p.data();
+ }
+ };
}
template <typename T>
@@ -593,14 +1565,23 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz
if (defined)
flags |= QMetaType::WasDeclaredAsMetaType;
- return QMetaType::registerNormalizedType(normalizedTypeName,
+ const int id = QMetaType::registerNormalizedType(normalizedTypeName,
QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Delete,
QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Create,
QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Destruct,
QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Construct,
- sizeof(T),
+ int(sizeof(T)),
flags,
QtPrivate::MetaObjectForType<T>::value());
+
+ if (id > 0) {
+ QtPrivate::SequentialContainerConverterHelper<T>::registerConverter(id);
+ QtPrivate::AssociativeContainerConverterHelper<T>::registerConverter(id);
+ QtPrivate::MetaTypePairHelper<T>::registerConverter(id);
+ QtPrivate::MetaTypeSmartPointerHelper<T>::registerConverter(id);
+ }
+
+ return id;
}
template <typename T>
@@ -686,7 +1667,7 @@ struct QMetaTypeIdQObject<T*, /* isPointerToTypeDerivedFromQObject */ true>
template <typename T>
inline int qRegisterMetaTypeStreamOperators()
{
- register int id = qMetaTypeId<T>();
+ int id = qMetaTypeId<T>();
QMetaType::registerStreamOperators(id, QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Save,
QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Load);
return id;
@@ -746,6 +1727,7 @@ typedef QMap<QString, QVariant> QVariantMap;
typedef QHash<QString, QVariant> QVariantHash;
#define Q_DECLARE_METATYPE_TEMPLATE_1ARG(SINGLE_ARG_TEMPLATE) \
+QT_BEGIN_NAMESPACE \
template <typename T> \
struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
{ \
@@ -761,8 +1743,8 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
Q_ASSERT(tName); \
const int tNameLen = qstrlen(tName); \
QByteArray typeName; \
- typeName.reserve(sizeof(#SINGLE_ARG_TEMPLATE) + 1 + tNameLen + 1 + 1); \
- typeName.append(#SINGLE_ARG_TEMPLATE, sizeof(#SINGLE_ARG_TEMPLATE) - 1) \
+ typeName.reserve(int(sizeof(#SINGLE_ARG_TEMPLATE)) + 1 + tNameLen + 1 + 1); \
+ typeName.append(#SINGLE_ARG_TEMPLATE, int(sizeof(#SINGLE_ARG_TEMPLATE)) - 1) \
.append('<').append(tName, tNameLen); \
if (typeName.endsWith('>')) \
typeName.append(' '); \
@@ -773,9 +1755,18 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \
metatype_id.storeRelease(newId); \
return newId; \
} \
-};
+}; \
+namespace QtPrivate { \
+template<typename T> \
+struct IsSequentialContainer<SINGLE_ARG_TEMPLATE<T> > \
+{ \
+ enum { Value = true }; \
+}; \
+} \
+QT_END_NAMESPACE
#define Q_DECLARE_METATYPE_TEMPLATE_2ARG(DOUBLE_ARG_TEMPLATE) \
+QT_BEGIN_NAMESPACE \
template<typename T, typename U> \
struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
{ \
@@ -794,8 +1785,8 @@ struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
const int tNameLen = qstrlen(tName); \
const int uNameLen = qstrlen(uName); \
QByteArray typeName; \
- typeName.reserve(sizeof(#DOUBLE_ARG_TEMPLATE) + 1 + tNameLen + 1 + uNameLen + 1 + 1); \
- typeName.append(#DOUBLE_ARG_TEMPLATE, sizeof(#DOUBLE_ARG_TEMPLATE) - 1) \
+ typeName.reserve(int(sizeof(#DOUBLE_ARG_TEMPLATE)) + 1 + tNameLen + 1 + uNameLen + 1 + 1); \
+ typeName.append(#DOUBLE_ARG_TEMPLATE, int(sizeof(#DOUBLE_ARG_TEMPLATE)) - 1) \
.append('<').append(tName, tNameLen).append(',').append(uName, uNameLen); \
if (typeName.endsWith('>')) \
typeName.append(' '); \
@@ -806,19 +1797,30 @@ struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \
metatype_id.storeRelease(newId); \
return newId; \
} \
+}; \
+QT_END_NAMESPACE
+
+namespace QtPrivate {
+
+template<typename T, bool /* isSharedPointerToQObjectDerived */ = false>
+struct SharedPointerMetaTypeIdHelper
+{
+ enum {
+ Defined = 0
+ };
+ static int qt_metatype_id()
+ {
+ return -1;
+ }
};
+}
+
#define Q_DECLARE_SMART_POINTER_METATYPE(SMART_POINTER) \
-template <typename T, bool = QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value> \
-struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar \
-{ \
- enum { \
- Defined = 0 \
- }; \
-};\
- \
+QT_BEGIN_NAMESPACE \
+namespace QtPrivate { \
template<typename T> \
-struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T, true> \
+struct SharedPointerMetaTypeIdHelper<SMART_POINTER<T>, true> \
{ \
enum { \
Defined = 1 \
@@ -830,8 +1832,8 @@ struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T, true> \
return id; \
const char * const cName = T::staticMetaObject.className(); \
QByteArray typeName; \
- typeName.reserve(sizeof(#SMART_POINTER) + 1 + strlen(cName) + 1); \
- typeName.append(#SMART_POINTER, sizeof(#SMART_POINTER) - 1) \
+ typeName.reserve(int(sizeof(#SMART_POINTER) + 1 + strlen(cName) + 1)); \
+ typeName.append(#SMART_POINTER, int(sizeof(#SMART_POINTER)) - 1) \
.append('<').append(cName).append('>'); \
const int newId = qRegisterNormalizedMetaType< SMART_POINTER<T> >( \
typeName, \
@@ -840,51 +1842,85 @@ struct QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T, true> \
return newId; \
} \
}; \
-\
template<typename T> \
-struct QMetaTypeId< SMART_POINTER<T> > : public QMetaTypeId_ ## SMART_POINTER ## _QObjectStar<T> \
+struct MetaTypeSmartPointerHelper<SMART_POINTER<T> , \
+ typename QEnableIf<IsPointerToTypeDerivedFromQObject<T*>::Value >::Type> \
{ \
-};
+ static bool registerConverter(int id) \
+ { \
+ const int toId = QMetaType::QObjectStar; \
+ if (!QMetaType::hasRegisteredConverterFunction(id, toId)) { \
+ QtPrivate::QSmartPointerConvertFunctor<SMART_POINTER<T> > o; \
+ static const QtPrivate::ConverterFunctor<SMART_POINTER<T>, \
+ QObject*, \
+ QSmartPointerConvertFunctor<SMART_POINTER<T> > > f(o); \
+ return QMetaType::registerConverterFunction(&f, id, toId); \
+ } \
+ return true; \
+ } \
+}; \
+} \
+template <typename T> \
+struct QMetaTypeId< SMART_POINTER<T> > \
+ : QtPrivate::SharedPointerMetaTypeIdHelper< SMART_POINTER<T>, \
+ QtPrivate::IsPointerToTypeDerivedFromQObject<T*>::Value> \
+{ \
+};\
+QT_END_NAMESPACE
-#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(F) \
- F(QList) \
- F(QVector) \
- F(QQueue) \
- F(QStack) \
- F(QSet) \
- F(QLinkedList)
+#define Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE_ITER(TEMPLATENAME) \
+ QT_BEGIN_NAMESPACE \
+ template <class T> class TEMPLATENAME; \
+ QT_END_NAMESPACE \
+ Q_DECLARE_METATYPE_TEMPLATE_1ARG(TEMPLATENAME)
-#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(F) \
- F(QHash, class) \
- F(QMap, class) \
- F(QPair, struct)
+QT_END_NAMESPACE
-#define QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(F) \
- F(QSharedPointer) \
- F(QWeakPointer) \
- F(QPointer)
+QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE_ITER)
-#define Q_DECLARE_METATYPE_TEMPLATE_1ARG_ITER(TEMPLATENAME) \
- template <class T> class TEMPLATENAME; \
- Q_DECLARE_METATYPE_TEMPLATE_1ARG(TEMPLATENAME)
+#undef Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE_ITER
-QT_FOR_EACH_AUTOMATIC_TEMPLATE_1ARG(Q_DECLARE_METATYPE_TEMPLATE_1ARG_ITER)
+#define Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE Q_DECLARE_METATYPE_TEMPLATE_1ARG
-#undef Q_DECLARE_METATYPE_TEMPLATE_1ARG_ITER
+Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(std::vector)
+Q_DECLARE_SEQUENTIAL_CONTAINER_METATYPE(std::list)
-#define Q_DECLARE_METATYPE_TEMPLATE_2ARG_ITER(TEMPLATENAME, CPPTYPE) \
+#define Q_FORWARD_DECLARE_METATYPE_TEMPLATE_2ARG_ITER(TEMPLATENAME, CPPTYPE) \
+ QT_BEGIN_NAMESPACE \
template <class T1, class T2> CPPTYPE TEMPLATENAME; \
- Q_DECLARE_METATYPE_TEMPLATE_2ARG(TEMPLATENAME)
+ QT_END_NAMESPACE \
-QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(Q_DECLARE_METATYPE_TEMPLATE_2ARG_ITER)
+QT_FOR_EACH_AUTOMATIC_TEMPLATE_2ARG(Q_FORWARD_DECLARE_METATYPE_TEMPLATE_2ARG_ITER)
#undef Q_DECLARE_METATYPE_TEMPLATE_2ARG_ITER
+#define Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(TEMPLATENAME) \
+ QT_BEGIN_NAMESPACE \
+ namespace QtPrivate { \
+ template<typename T, typename U> \
+ struct IsAssociativeContainer<TEMPLATENAME<T, U> > \
+ { \
+ enum { Value = true }; \
+ }; \
+ } \
+ QT_END_NAMESPACE \
+ Q_DECLARE_METATYPE_TEMPLATE_2ARG(TEMPLATENAME)
+
+Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(QHash)
+Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(QMap)
+Q_DECLARE_ASSOCIATIVE_CONTAINER_METATYPE(std::map)
+
+Q_DECLARE_METATYPE_TEMPLATE_2ARG(QPair)
+Q_DECLARE_METATYPE_TEMPLATE_2ARG(std::pair)
+
#define Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER(TEMPLATENAME) \
Q_DECLARE_SMART_POINTER_METATYPE(TEMPLATENAME)
+
QT_FOR_EACH_AUTOMATIC_TEMPLATE_SMART_POINTER(Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER)
+QT_BEGIN_NAMESPACE
+
#undef Q_DECLARE_METATYPE_TEMPLATE_SMART_POINTER_ITER
inline QMetaType::QMetaType(const ExtensionFlag extensionFlags, const QMetaTypeInterface *info,
@@ -987,5 +2023,62 @@ QT_END_NAMESPACE
QT_FOR_EACH_STATIC_TYPE(Q_DECLARE_BUILTIN_METATYPE)
+Q_DECLARE_METATYPE(QtMetaTypePrivate::QSequentialIterableImpl)
+Q_DECLARE_METATYPE(QtMetaTypePrivate::QAssociativeIterableImpl)
+Q_DECLARE_METATYPE(QtMetaTypePrivate::QPairVariantInterfaceImpl)
+
+QT_BEGIN_NAMESPACE
+
+template <typename T>
+inline bool QtPrivate::IsMetaTypePair<T, true>::registerConverter(int id)
+{
+ const int toId = qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>();
+ if (!QMetaType::hasRegisteredConverterFunction(id, toId)) {
+ QtMetaTypePrivate::QPairVariantInterfaceConvertFunctor<T> o;
+ static const QtPrivate::ConverterFunctor<T,
+ QtMetaTypePrivate::QPairVariantInterfaceImpl,
+ QtMetaTypePrivate::QPairVariantInterfaceConvertFunctor<T> > f(o);
+ return QMetaType::registerConverterFunction(&f, id, toId);
+ }
+ return true;
+}
+
+namespace QtPrivate {
+ template<typename T>
+ struct ValueTypeIsMetaType<T, true>
+ {
+ static bool registerConverter(int id)
+ {
+ const int toId = qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>();
+ if (!QMetaType::hasRegisteredConverterFunction(id, toId)) {
+ QtMetaTypePrivate::QSequentialIterableConvertFunctor<T> o;
+ static const QtPrivate::ConverterFunctor<T,
+ QtMetaTypePrivate::QSequentialIterableImpl,
+ QtMetaTypePrivate::QSequentialIterableConvertFunctor<T> > f(o);
+ return QMetaType::registerConverterFunction(&f, id, toId);
+ }
+ return true;
+ }
+ };
+
+ template<typename T>
+ struct AssociativeValueTypeIsMetaType<T, true>
+ {
+ static bool registerConverter(int id)
+ {
+ const int toId = qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>();
+ if (!QMetaType::hasRegisteredConverterFunction(id, toId)) {
+ QtMetaTypePrivate::QAssociativeIterableConvertFunctor<T> o;
+ static const QtPrivate::ConverterFunctor<T,
+ QtMetaTypePrivate::QAssociativeIterableImpl,
+ QtMetaTypePrivate::QAssociativeIterableConvertFunctor<T> > f(o);
+ return QMetaType::registerConverterFunction(&f, id, toId);
+ }
+ return true;
+ }
+ };
+}
+
+QT_END_NAMESPACE
#endif // QMETATYPE_H
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index aaa09fa..e2000af 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -208,6 +208,7 @@ public:
#ifdef Q_QDOC
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type);
static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor);
+ static QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type);
#else
//Connect a signal to a pointer to qobject member function
template <typename Func1, typename Func2>
@@ -217,7 +218,9 @@ public:
{
typedef QtPrivate::FunctionPointer<Func1> SignalType;
typedef QtPrivate::FunctionPointer<Func2> SlotType;
- reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<typename SignalType::Object *>(0));
+
+ Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
+ "No Q_OBJECT in the class with the signal");
//compilation error if the arguments does not match.
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
@@ -243,9 +246,22 @@ public:
static inline typename QtPrivate::QEnableIf<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0, QMetaObject::Connection>::Type
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
{
+ return connect(sender, signal, sender, slot, Qt::DirectConnection);
+ }
+
+ //connect to a function pointer (not a member)
+ template <typename Func1, typename Func2>
+ static inline typename QtPrivate::QEnableIf<int(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0 &&
+ !QtPrivate::FunctionPointer<Func2>::IsPointerToMemberFunction, QMetaObject::Connection>::Type
+ connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
+ Qt::ConnectionType type = Qt::AutoConnection)
+ {
typedef QtPrivate::FunctionPointer<Func1> SignalType;
typedef QtPrivate::FunctionPointer<Func2> SlotType;
+ Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
+ "No Q_OBJECT in the class with the signal");
+
//compilation error if the arguments does not match.
Q_STATIC_ASSERT_X(int(SignalType::ArgumentCount) >= int(SlotType::ArgumentCount),
"The slot requires more arguments than the signal provides.");
@@ -254,11 +270,15 @@ public:
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<typename SlotType::ReturnType, typename SignalType::ReturnType>::value),
"Return type of the slot is not compatible with the return type of the signal.");
- return connectImpl(sender, reinterpret_cast<void **>(&signal), sender, 0,
+ const int *types = 0;
+ if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
+ types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
+
+ return connectImpl(sender, reinterpret_cast<void **>(&signal), context, 0,
new QtPrivate::QStaticSlotObject<Func2,
typename QtPrivate::List_Left<typename SignalType::Arguments, SlotType::ArgumentCount>::Value,
typename SignalType::ReturnType>(slot),
- Qt::DirectConnection, 0, &SignalType::Object::staticMetaObject);
+ type, types, &SignalType::Object::staticMetaObject);
}
//connect to a functor
@@ -266,6 +286,15 @@ public:
static inline typename QtPrivate::QEnableIf<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::Type
connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot)
{
+ return connect(sender, signal, sender, slot, Qt::DirectConnection);
+ }
+
+ //connect to a functor, with a "context" object defining in which event loop is going to be executed
+ template <typename Func1, typename Func2>
+ static inline typename QtPrivate::QEnableIf<QtPrivate::FunctionPointer<Func2>::ArgumentCount == -1, QMetaObject::Connection>::Type
+ connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot,
+ Qt::ConnectionType type = Qt::AutoConnection)
+ {
#if defined (Q_COMPILER_DECLTYPE) && defined (Q_COMPILER_VARIADIC_TEMPLATES)
typedef QtPrivate::FunctionPointer<Func1> SignalType;
const int FunctorArgumentCount = QtPrivate::ComputeFunctorArgumentCount<Func2 , typename SignalType::Arguments>::Value;
@@ -287,9 +316,10 @@ public:
C++11 variadic templates
*/
#ifndef Q_COMPILER_DECLTYPE //Workaround the lack of decltype using another function as indirection
- return connect_functor(sender, signal, slot, &Func2::operator()); }
+ return connect_functor(sender, signal, context, slot, &Func2::operator(), type); }
template <typename Func1, typename Func2, typename Func2Operator>
- static inline QMetaObject::Connection connect_functor(const QObject *sender, Func1 signal, Func2 slot, Func2Operator) {
+ static inline QMetaObject::Connection connect_functor(const QObject *sender, Func1 signal, const QObject *context,
+ Func2 slot, Func2Operator, Qt::ConnectionType type) {
typedef QtPrivate::FunctionPointer<Func2Operator> SlotType ;
#else
typedef QtPrivate::FunctionPointer<decltype(&Func2::operator())> SlotType ;
@@ -307,11 +337,18 @@ public:
Q_STATIC_ASSERT_X((QtPrivate::AreArgumentsCompatible<SlotReturnType, typename SignalType::ReturnType>::value),
"Return type of the slot is not compatible with the return type of the signal.");
- return connectImpl(sender, reinterpret_cast<void **>(&signal), sender, 0,
+ Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
+ "No Q_OBJECT in the class with the signal");
+
+ const int *types = 0;
+ if (type == Qt::QueuedConnection || type == Qt::BlockingQueuedConnection)
+ types = QtPrivate::ConnectionTypes<typename SignalType::Arguments>::types();
+
+ return connectImpl(sender, reinterpret_cast<void **>(&signal), context, 0,
new QtPrivate::QFunctorSlotObject<Func2, SlotArgumentCount,
typename QtPrivate::List_Left<typename SignalType::Arguments, SlotArgumentCount>::Value,
typename SignalType::ReturnType>(slot),
- Qt::DirectConnection, 0, &SignalType::Object::staticMetaObject);
+ type, types, &SignalType::Object::staticMetaObject);
}
#endif //Q_QDOC
@@ -335,7 +372,9 @@ public:
{
typedef QtPrivate::FunctionPointer<Func1> SignalType;
typedef QtPrivate::FunctionPointer<Func2> SlotType;
- reinterpret_cast<typename SignalType::Object *>(0)->qt_check_for_QOBJECT_macro(*reinterpret_cast<typename SignalType::Object *>(0));
+
+ Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<typename SignalType::Object>::Value,
+ "No Q_OBJECT in the class with the signal");
//compilation error if the arguments does not match.
Q_STATIC_ASSERT_X((QtPrivate::CheckCompatibleArguments<typename SignalType::Arguments, typename SlotType::Arguments>::value),
@@ -477,18 +516,18 @@ inline QT_DEPRECATED QList<T> qFindChildren(const QObject *o, const QRegExp &re)
template <class T>
inline T qobject_cast(QObject *object)
{
-#if !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(object));
-#endif
+ typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
+ "qobject_cast requires the type to have a Q_OBJECT macro");
return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
}
template <class T>
inline T qobject_cast(const QObject *object)
{
-#if !defined(QT_NO_QOBJECT_CHECK)
- reinterpret_cast<T>(object)->qt_check_for_QOBJECT_macro(*reinterpret_cast<T>(const_cast<QObject *>(object)));
-#endif
+ typedef typename QtPrivate::remove_cv<typename QtPrivate::remove_pointer<T>::type>::type ObjType;
+ Q_STATIC_ASSERT_X(QtPrivate::HasQ_OBJECT_Macro<ObjType>::Value,
+ "qobject_cast requires the type to have a Q_OBJECT macro");
return static_cast<T>(reinterpret_cast<T>(object)->staticMetaObject.cast(object));
}
diff --git a/src/corelib/kernel/qobject_impl.h b/src/corelib/kernel/qobject_impl.h
index 0b5631f..1bbd548 100644
--- a/src/corelib/kernel/qobject_impl.h
+++ b/src/corelib/kernel/qobject_impl.h
@@ -204,7 +204,6 @@ namespace QtPrivate {
public:
explicit QFunctorSlotObject(const Func &f) : QSlotObjectBase(&impl), function(f) {}
};
-
}
diff --git a/src/corelib/kernel/qobjectdefs.h b/src/corelib/kernel/qobjectdefs.h
index afbe1a5..7354c3f 100644
--- a/src/corelib/kernel/qobjectdefs.h
+++ b/src/corelib/kernel/qobjectdefs.h
@@ -125,7 +125,7 @@ class QString;
/* qmake ignore Q_OBJECT */
#define Q_OBJECT_CHECK \
- template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const \
+ template <typename ThisObject> inline void qt_check_for_QOBJECT_macro(const ThisObject &_q_argument) const \
{ int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; }
template <typename T>
@@ -456,6 +456,7 @@ class Q_CORE_EXPORT QMetaObject::Connection {
void *d_ptr; //QObjectPrivate::Connection*
explicit Connection(void *data) : d_ptr(data) { }
friend class QObject;
+ friend class QObjectPrivate;
friend struct QMetaObject;
public:
~Connection();
@@ -479,6 +480,16 @@ public:
inline const QMetaObject *QMetaObject::superClass() const
{ return d.superdata; }
+namespace QtPrivate {
+ /* Trait that tells is a the Object has a Q_OBJECT macro */
+ template <typename Object> struct HasQ_OBJECT_Macro {
+ template <typename T>
+ static char test(int (T::*)(QMetaObject::Call, int, void **));
+ static int test(int (Object::*)(QMetaObject::Call, int, void **));
+ enum { Value = sizeof(test(&Object::qt_metacall)) == sizeof(int) };
+ };
+}
+
QT_END_NAMESPACE
#endif // QOBJECTDEFS_H
diff --git a/src/corelib/kernel/qobjectdefs_impl.h b/src/corelib/kernel/qobjectdefs_impl.h
index 4f44d92..fb6601f 100644
--- a/src/corelib/kernel/qobjectdefs_impl.h
+++ b/src/corelib/kernel/qobjectdefs_impl.h
@@ -129,7 +129,7 @@ namespace QtPrivate {
its call function is the same as the FunctionPointer::call function.
*/
#ifndef Q_COMPILER_VARIADIC_TEMPLATES
- template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1}; };
+ template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1, IsPointerToMemberFunction = false}; };
//Pointers to member functions
template<class Obj, typename Ret> struct FunctionPointer<Ret (Obj::*) ()>
{
@@ -137,7 +137,7 @@ namespace QtPrivate {
typedef void Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) ();
- enum {ArgumentCount = 0};
+ enum {ArgumentCount = 0, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) { (o->*f)(), ApplyReturnValue<R>(arg[0]); }
};
@@ -147,7 +147,7 @@ namespace QtPrivate {
typedef List<Arg1, void> Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1);
- enum {ArgumentCount = 1};
+ enum {ArgumentCount = 1, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)((*reinterpret_cast<typename RemoveRef<typename Args::Car>::Type *>(arg[1]))), ApplyReturnValue<R>(arg[0]);
@@ -159,7 +159,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, void> > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2);
- enum {ArgumentCount = 2};
+ enum {ArgumentCount = 2, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -172,7 +172,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3);
- enum {ArgumentCount = 3};
+ enum {ArgumentCount = 3, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -186,7 +186,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4);
- enum {ArgumentCount = 4};
+ enum {ArgumentCount = 4, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -201,7 +201,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
- enum {ArgumentCount = 5};
+ enum {ArgumentCount = 5, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -218,7 +218,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
- enum {ArgumentCount = 6};
+ enum {ArgumentCount = 6, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -237,7 +237,7 @@ namespace QtPrivate {
typedef void Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) () const;
- enum {ArgumentCount = 0};
+ enum {ArgumentCount = 0, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) { (o->*f)(), ApplyReturnValue<R>(arg[0]); }
};
@@ -247,7 +247,7 @@ namespace QtPrivate {
typedef List<Arg1, void> Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1) const;
- enum {ArgumentCount = 1};
+ enum {ArgumentCount = 1, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)((*reinterpret_cast<typename RemoveRef<typename Args::Car>::Type *>(arg[1]))), ApplyReturnValue<R>(arg[0]);
@@ -259,7 +259,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, void> > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2) const;
- enum {ArgumentCount = 2};
+ enum {ArgumentCount = 2, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -272,7 +272,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3) const;
- enum {ArgumentCount = 3};
+ enum {ArgumentCount = 3, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -286,7 +286,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4) const;
- enum {ArgumentCount = 4};
+ enum {ArgumentCount = 4, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -301,7 +301,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, void> > > > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5) const;
- enum {ArgumentCount = 5};
+ enum {ArgumentCount = 5, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -318,7 +318,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6) const;
- enum {ArgumentCount = 6};
+ enum {ArgumentCount = 6, IsPointerToMemberFunction = true};
template <typename Args, typename R>
static void call(Function f, Obj *o, void **arg) {
(o->*f)( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -336,7 +336,7 @@ namespace QtPrivate {
typedef void Arguments;
typedef Ret (*Function) ();
typedef Ret ReturnType;
- enum {ArgumentCount = 0};
+ enum {ArgumentCount = 0, IsPointerToMemberFunction = false};
template <typename Args, typename R>
static void call(Function f, void *, void **arg) { f(), ApplyReturnValue<R>(arg[0]); }
};
@@ -345,7 +345,7 @@ namespace QtPrivate {
typedef List<Arg1, void> Arguments;
typedef Ret ReturnType;
typedef Ret (*Function) (Arg1);
- enum {ArgumentCount = 1};
+ enum {ArgumentCount = 1, IsPointerToMemberFunction = false};
template <typename Args, typename R>
static void call(Function f, void *, void **arg)
{ f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1])), ApplyReturnValue<R>(arg[0]); }
@@ -355,7 +355,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, void> > Arguments;
typedef Ret ReturnType;
typedef Ret (*Function) (Arg1, Arg2);
- enum {ArgumentCount = 2};
+ enum {ArgumentCount = 2, IsPointerToMemberFunction = false};
template <typename Args, typename R>
static void call(Function f, void *, void **arg) {
f(*reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -366,7 +366,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, void> > > Arguments;
typedef Ret ReturnType;
typedef Ret (*Function) (Arg1, Arg2, Arg3);
- enum {ArgumentCount = 3};
+ enum {ArgumentCount = 3, IsPointerToMemberFunction = false};
template <typename Args, typename R>
static void call(Function f, void *, void **arg) {
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -379,7 +379,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, void> > > > Arguments;
typedef Ret ReturnType;
typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4);
- enum {ArgumentCount = 4};
+ enum {ArgumentCount = 4, IsPointerToMemberFunction = false};
template <typename Args, typename R>
static void call(Function f, void *, void **arg) {
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -394,7 +394,7 @@ namespace QtPrivate {
List<Arg4, List<Arg5, void > > > > > Arguments;
typedef Ret ReturnType;
typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5);
- enum {ArgumentCount = 5};
+ enum {ArgumentCount = 5, IsPointerToMemberFunction = false};
template <typename Args, typename R>
static void call(Function f, void *, void **arg) {
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -409,7 +409,7 @@ namespace QtPrivate {
typedef List<Arg1, List<Arg2, List<Arg3, List<Arg4, List<Arg5, List<Arg6, void> > > > > > Arguments;
typedef Ret ReturnType;
typedef Ret (*Function) (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6);
- enum {ArgumentCount = 6};
+ enum {ArgumentCount = 6, IsPointerToMemberFunction = false};
template <typename Args, typename R>
static void call(Function f, void *, void **arg) {
f( *reinterpret_cast<typename RemoveRef<typename List_Select<Args, 0>::Value>::Type *>(arg[1]),
@@ -493,25 +493,25 @@ namespace QtPrivate {
template <int N> struct Indexes
{ typedef typename IndexesAppend<typename Indexes<N - 1>::Value, N - 1>::Value Value; };
template <> struct Indexes<0> { typedef IndexesList<> Value; };
- template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1}; };
+ template<typename Func> struct FunctionPointer { enum {ArgumentCount = -1, IsPointerToMemberFunction = false}; };
template <typename, typename, typename, typename> struct FunctorCall;
- template <int... I, typename... SignalArgs, typename R, typename Function>
- struct FunctorCall<IndexesList<I...>, List<SignalArgs...>, R, Function> {
+ template <int... II, typename... SignalArgs, typename R, typename Function>
+ struct FunctorCall<IndexesList<II...>, List<SignalArgs...>, R, Function> {
static void call(Function f, void **arg) {
- f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
+ f((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]);
}
};
- template <int... I, typename... SignalArgs, typename R, typename... SlotArgs, typename SlotRet, class Obj>
- struct FunctorCall<IndexesList<I...>, List<SignalArgs...>, R, SlotRet (Obj::*)(SlotArgs...)> {
+ template <int... II, typename... SignalArgs, typename R, typename... SlotArgs, typename SlotRet, class Obj>
+ struct FunctorCall<IndexesList<II...>, List<SignalArgs...>, R, SlotRet (Obj::*)(SlotArgs...)> {
static void call(SlotRet (Obj::*f)(SlotArgs...), Obj *o, void **arg) {
- (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
+ (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]);
}
};
- template <int... I, typename... SignalArgs, typename R, typename... SlotArgs, typename SlotRet, class Obj>
- struct FunctorCall<IndexesList<I...>, List<SignalArgs...>, R, SlotRet (Obj::*)(SlotArgs...) const> {
+ template <int... II, typename... SignalArgs, typename R, typename... SlotArgs, typename SlotRet, class Obj>
+ struct FunctorCall<IndexesList<II...>, List<SignalArgs...>, R, SlotRet (Obj::*)(SlotArgs...) const> {
static void call(SlotRet (Obj::*f)(SlotArgs...) const, Obj *o, void **arg) {
- (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[I+1]))...), ApplyReturnValue<R>(arg[0]);
+ (o->*f)((*reinterpret_cast<typename RemoveRef<SignalArgs>::Type *>(arg[II+1]))...), ApplyReturnValue<R>(arg[0]);
}
};
@@ -521,7 +521,7 @@ namespace QtPrivate {
typedef List<Args...> Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Args...);
- enum {ArgumentCount = sizeof...(Args)};
+ enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = true};
template <typename SignalArgs, typename R>
static void call(Function f, Obj *o, void **arg) {
FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, o, arg);
@@ -533,7 +533,7 @@ namespace QtPrivate {
typedef List<Args...> Arguments;
typedef Ret ReturnType;
typedef Ret (Obj::*Function) (Args...) const;
- enum {ArgumentCount = sizeof...(Args)};
+ enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = true};
template <typename SignalArgs, typename R>
static void call(Function f, Obj *o, void **arg) {
FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, o, arg);
@@ -545,7 +545,7 @@ namespace QtPrivate {
typedef List<Args...> Arguments;
typedef Ret ReturnType;
typedef Ret (*Function) (Args...);
- enum {ArgumentCount = sizeof...(Args)};
+ enum {ArgumentCount = sizeof...(Args), IsPointerToMemberFunction = false};
template <typename SignalArgs, typename R>
static void call(Function f, void *, void **arg) {
FunctorCall<typename Indexes<ArgumentCount>::Value, SignalArgs, R, Function>::call(f, arg);
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index 6f212f5..5ff33cc 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -49,6 +49,7 @@
#include <QtCore/qmap.h>
#include <QtCore/qhash.h>
#include <QtCore/qstring.h>
+#include <QtCore/qstringlist.h>
#include <QtCore/qobject.h>
QT_BEGIN_NAMESPACE
@@ -432,6 +433,14 @@ class Q_CORE_EXPORT QVariant
{ return cmp(v); }
inline bool operator!=(const QVariant &v) const
{ return !cmp(v); }
+ inline bool operator<(const QVariant &v) const
+ { return compare(v) < 0; }
+ inline bool operator<=(const QVariant &v) const
+ { return compare(v) <= 0; }
+ inline bool operator>(const QVariant &v) const
+ { return compare(v) > 0; }
+ inline bool operator>=(const QVariant &v) const
+ { return compare(v) >= 0; }
protected:
friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &);
@@ -449,6 +458,7 @@ public:
Private d;
void create(int type, const void *copy);
bool cmp(const QVariant &other) const;
+ int compare(const QVariant &other) const;
bool convert(const int t, void *ptr) const;
private:
@@ -562,6 +572,107 @@ inline bool operator!=(const QVariant &v1, const QVariantComparisonHelper &v2)
}
#endif
+class Q_CORE_EXPORT QSequentialIterable
+{
+ QtMetaTypePrivate::QSequentialIterableImpl m_impl;
+public:
+ struct Q_CORE_EXPORT const_iterator
+ {
+ private:
+ QtMetaTypePrivate::QSequentialIterableImpl m_impl;
+ QAtomicInt *ref;
+ friend class QSequentialIterable;
+ explicit const_iterator(const QSequentialIterable &iter, QAtomicInt *ref_);
+
+ explicit const_iterator(const QtMetaTypePrivate::QSequentialIterableImpl &impl, QAtomicInt *ref_);
+
+ void begin();
+ void end();
+ public:
+ ~const_iterator();
+
+ const_iterator(const const_iterator &other);
+
+ const_iterator& operator=(const const_iterator &other);
+
+ const QVariant operator*() const;
+ bool operator==(const const_iterator &o) const;
+ bool operator!=(const const_iterator &o) const;
+ const_iterator &operator++();
+ const_iterator operator++(int);
+ const_iterator &operator--();
+ const_iterator operator--(int);
+ const_iterator &operator+=(int j);
+ const_iterator &operator-=(int j);
+ const_iterator operator+(int j) const;
+ const_iterator operator-(int j) const;
+ };
+
+ friend struct const_iterator;
+
+ explicit QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl impl);
+
+ const_iterator begin() const;
+ const_iterator end() const;
+
+ QVariant at(int idx) const;
+ int size() const;
+
+ bool canReverseIterate() const;
+};
+
+class Q_CORE_EXPORT QAssociativeIterable
+{
+ QtMetaTypePrivate::QAssociativeIterableImpl m_impl;
+public:
+ struct Q_CORE_EXPORT const_iterator
+ {
+ private:
+ QtMetaTypePrivate::QAssociativeIterableImpl m_impl;
+ QAtomicInt *ref;
+ friend class QAssociativeIterable;
+ explicit const_iterator(const QAssociativeIterable &iter, QAtomicInt *ref_);
+
+ explicit const_iterator(const QtMetaTypePrivate::QAssociativeIterableImpl &impl, QAtomicInt *ref_);
+
+ void begin();
+ void end();
+ public:
+ ~const_iterator();
+ const_iterator(const const_iterator &other);
+
+ const_iterator& operator=(const const_iterator &other);
+
+ const QVariant key() const;
+
+ const QVariant value() const;
+
+ const QVariant operator*() const;
+ bool operator==(const const_iterator &o) const;
+ bool operator!=(const const_iterator &o) const;
+ const_iterator &operator++();
+ const_iterator operator++(int);
+ const_iterator &operator--();
+ const_iterator operator--(int);
+ const_iterator &operator+=(int j);
+ const_iterator &operator-=(int j);
+ const_iterator operator+(int j) const;
+ const_iterator operator-(int j) const;
+ };
+
+ friend struct const_iterator;
+
+ explicit QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl impl);
+
+ const_iterator begin() const;
+ const_iterator end() const;
+
+ QVariant value(const QVariant &key) const;
+
+ int size() const;
+};
+
+#ifndef QT_MOC
namespace QtPrivate {
template<typename T>
struct QVariantValueHelper : TreatAsQObjectBeforeMetaType<QVariantValueHelper<T>, T, const QVariant &, T>
@@ -571,26 +682,132 @@ namespace QtPrivate {
const int vid = qMetaTypeId<T>();
if (vid == v.userType())
return *reinterpret_cast<const T *>(v.constData());
- if (vid < int(QMetaType::User)) {
T t;
if (v.convert(vid, &t))
return t;
- }
return T();
}
#ifndef QT_NO_QOBJECT
static T object(const QVariant &v)
{
- return qobject_cast<T>(QMetaType::typeFlags(v.userType()) & QMetaType::PointerToQObject ? v.d.data.o : 0);
+ return qobject_cast<T>(QMetaType::typeFlags(v.userType()) & QMetaType::PointerToQObject
+ ? v.d.data.o
+ : QVariantValueHelper::metaType(v));
}
#endif
};
+
+ template<typename T>
+ struct QVariantValueHelperInterface : QVariantValueHelper<T>
+ {
+ };
+
+ template<>
+ struct QVariantValueHelperInterface<QSequentialIterable>
+ {
+ static QSequentialIterable invoke(const QVariant &v)
+ {
+ if (v.userType() == qMetaTypeId<QVariantList>()) {
+ return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QVariantList*>(v.constData())));
+ }
+ if (v.userType() == qMetaTypeId<QStringList>()) {
+ return QSequentialIterable(QtMetaTypePrivate::QSequentialIterableImpl(reinterpret_cast<const QStringList*>(v.constData())));
+ }
+ return QSequentialIterable(v.value<QtMetaTypePrivate::QSequentialIterableImpl>());
+ }
+ };
+ template<>
+ struct QVariantValueHelperInterface<QAssociativeIterable>
+ {
+ static QAssociativeIterable invoke(const QVariant &v)
+ {
+ if (v.userType() == qMetaTypeId<QVariantMap>()) {
+ return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast<const QVariantMap*>(v.constData())));
+ }
+ if (v.userType() == qMetaTypeId<QVariantHash>()) {
+ return QAssociativeIterable(QtMetaTypePrivate::QAssociativeIterableImpl(reinterpret_cast<const QVariantHash*>(v.constData())));
+ }
+ return QAssociativeIterable(v.value<QtMetaTypePrivate::QAssociativeIterableImpl>());
+ }
+ };
+ template<>
+ struct QVariantValueHelperInterface<QVariantList>
+ {
+ static QVariantList invoke(const QVariant &v)
+ {
+ if (v.userType() == qMetaTypeId<QStringList>() || QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QSequentialIterableImpl>())) {
+ QSequentialIterable iter = QVariantValueHelperInterface<QSequentialIterable>::invoke(v);
+ QVariantList l;
+ l.reserve(iter.size());
+ for (QSequentialIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it)
+ l << *it;
+ return l;
+ }
+ return QVariantValueHelper<QVariantList>::invoke(v);
+ }
+ };
+ template<>
+ struct QVariantValueHelperInterface<QVariantHash>
+ {
+ static QVariantHash invoke(const QVariant &v)
+ {
+ if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v);
+ QVariantHash l;
+ l.reserve(iter.size());
+ for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it)
+ l.insert(it.key().toString(), it.value());
+ return l;
+ }
+ return QVariantValueHelper<QVariantHash>::invoke(v);
+ }
+ };
+ template<>
+ struct QVariantValueHelperInterface<QVariantMap>
+ {
+ static QVariantMap invoke(const QVariant &v)
+ {
+ if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QAssociativeIterableImpl>())) {
+ QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v);
+ QVariantMap l;
+ for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it)
+ l.insert(it.key().toString(), it.value());
+ return l;
+ }
+ return QVariantValueHelper<QVariantMap>::invoke(v);
+ }
+ };
+ template<>
+ struct QVariantValueHelperInterface<QPair<QVariant, QVariant> >
+ {
+ static QPair<QVariant, QVariant> invoke(const QVariant &v)
+ {
+ if (v.userType() == qMetaTypeId<QPair<QVariant, QVariant> >())
+ return QVariantValueHelper<QPair<QVariant, QVariant> >::invoke(v);
+
+ if (QMetaType::hasRegisteredConverterFunction(v.userType(), qMetaTypeId<QtMetaTypePrivate::QPairVariantInterfaceImpl>())) {
+ QtMetaTypePrivate::QPairVariantInterfaceImpl pi = v.value<QtMetaTypePrivate::QPairVariantInterfaceImpl>();
+
+ const QtMetaTypePrivate::VariantData d1 = pi.first();
+ QVariant v1(d1.metaTypeId, d1.data, d1.flags);
+ if (d1.metaTypeId == qMetaTypeId<QVariant>())
+ v1 = *reinterpret_cast<const QVariant*>(d1.data);
+
+ const QtMetaTypePrivate::VariantData d2 = pi.second();
+ QVariant v2(d2.metaTypeId, d2.data, d2.flags);
+ if (d2.metaTypeId == qMetaTypeId<QVariant>())
+ v2 = *reinterpret_cast<const QVariant*>(d2.data);
+
+ return QPair<QVariant, QVariant>(v1, v2);
+ }
+ return QVariantValueHelper<QPair<QVariant, QVariant> >::invoke(v);
+ }
+ };
}
-#ifndef QT_MOC
template<typename T> inline T qvariant_cast(const QVariant &v)
{
- return QtPrivate::QVariantValueHelper<T>::invoke(v);
+ return QtPrivate::QVariantValueHelperInterface<T>::invoke(v);
}
template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
diff --git a/src/corelib/plugin/qplugin.h b/src/corelib/plugin/qplugin.h
index b91a0e9..1ec9325 100644
--- a/src/corelib/plugin/qplugin.h
+++ b/src/corelib/plugin/qplugin.h
@@ -44,6 +44,7 @@
#include <QtCore/qobject.h>
#include <QtCore/qpointer.h>
+#include <QtCore/qjsonobject.h>
QT_BEGIN_NAMESPACE
@@ -59,11 +60,22 @@ QT_BEGIN_NAMESPACE
typedef QObject *(*QtPluginInstanceFunction)();
typedef const char *(*QtPluginMetaDataFunction)();
-struct QStaticPlugin
+struct Q_CORE_EXPORT QStaticPlugin
{
+ // Note: This struct is initialized using an initializer list.
+ // As such, it cannot have any new constructors or variables.
+#ifndef Q_QDOC
QtPluginInstanceFunction instance;
- QtPluginMetaDataFunction metaData;
+ QtPluginMetaDataFunction rawMetaData;
+#else
+ // Since qdoc gets confused by the use of function
+ // pointers, we add these dummes for it to parse instead:
+ QObject *instance();
+ const char *rawMetaData();
+#endif
+ QJsonObject metaData() const;
};
+Q_DECLARE_TYPEINFO(QStaticPlugin, Q_PRIMITIVE_TYPE);
void Q_CORE_EXPORT qRegisterStaticPluginFunction(QStaticPlugin staticPlugin);
diff --git a/src/corelib/plugin/qpluginloader.h b/src/corelib/plugin/qpluginloader.h
index 8f8833e..88c8ba4 100644
--- a/src/corelib/plugin/qpluginloader.h
+++ b/src/corelib/plugin/qpluginloader.h
@@ -43,6 +43,7 @@
#define QPLUGINLOADER_H
#include <QtCore/qlibrary.h>
+#include <QtCore/qplugin.h>
#ifndef QT_NO_LIBRARY
@@ -65,6 +66,7 @@ public:
QJsonObject metaData() const;
static QObjectList staticInstances();
+ static QVector<QStaticPlugin> staticPlugins();
bool load();
bool unload();
diff --git a/src/corelib/thread/qbasicatomic.h b/src/corelib/thread/qbasicatomic.h
index cf0a6a5..ddcc25f 100644
--- a/src/corelib/thread/qbasicatomic.h
+++ b/src/corelib/thread/qbasicatomic.h
@@ -60,11 +60,11 @@
// Processor dependent implementation
#elif defined(Q_PROCESSOR_ALPHA)
# include "QtCore/qatomic_alpha.h"
-#elif defined(Q_PROCESSOR_ARM_V7)
+#elif defined(Q_PROCESSOR_ARM_V7) && defined(Q_PROCESSOR_ARM_32)
# include "QtCore/qatomic_armv7.h"
-#elif defined(Q_PROCESSOR_ARM_V6)
+#elif defined(Q_PROCESSOR_ARM_V6) && defined(Q_PROCESSOR_ARM_32)
# include "QtCore/qatomic_armv6.h"
-#elif defined(Q_PROCESSOR_ARM_V5)
+#elif defined(Q_PROCESSOR_ARM_V5) && defined(Q_PROCESSOR_ARM_32)
# include "QtCore/qatomic_armv5.h"
#elif defined(Q_PROCESSOR_BFIN)
# include "QtCore/qatomic_bfin.h"
diff --git a/src/corelib/thread/qgenericatomic.h b/src/corelib/thread/qgenericatomic.h
index a0a851e..3a213f6 100644
--- a/src/corelib/thread/qgenericatomic.h
+++ b/src/corelib/thread/qgenericatomic.h
@@ -172,7 +172,7 @@ template <typename BaseClass> struct QGenericAtomicOps
{
// implement fetchAndStore on top of testAndSet
Q_FOREVER {
- register T tmp = load(_q_value);
+ T tmp = load(_q_value);
if (BaseClass::testAndSetRelaxed(_q_value, tmp, newValue))
return tmp;
}
@@ -207,7 +207,7 @@ template <typename BaseClass> struct QGenericAtomicOps
{
// implement fetchAndAdd on top of testAndSet
Q_FOREVER {
- register T tmp = BaseClass::load(_q_value);
+ T tmp = BaseClass::load(_q_value);
if (BaseClass::testAndSetRelaxed(_q_value, tmp, T(tmp + valueToAdd)))
return tmp;
}
diff --git a/src/corelib/thread/qthread.h b/src/corelib/thread/qthread.h
index 19c0f82..f06981c 100644
--- a/src/corelib/thread/qthread.h
+++ b/src/corelib/thread/qthread.h
@@ -86,6 +86,9 @@ public:
bool isFinished() const;
bool isRunning() const;
+ void requestInterruption();
+ bool isInterruptionRequested() const;
+
void setStackSize(uint stackSize);
uint stackSize() const;
diff --git a/src/corelib/thread/qthreadpool.h b/src/corelib/thread/qthreadpool.h
index ffc16de..22a42c2 100644
--- a/src/corelib/thread/qthreadpool.h
+++ b/src/corelib/thread/qthreadpool.h
@@ -83,6 +83,8 @@ public:
void releaseThread();
bool waitForDone(int msecs = -1);
+
+ void clear();
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index e3b7688..c6eede0 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -53,27 +53,30 @@ QT_BEGIN_NAMESPACE
*/
namespace QAlgorithmsPrivate {
+#if QT_DEPRECATED_SINCE(5, 2)
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan);
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan);
template <typename RandomAccessIterator, typename T>
-inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy);
+QT_DEPRECATED inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy);
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan);
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan);
template <typename RandomAccessIterator, typename T>
-inline void qStableSortHelper(RandomAccessIterator, RandomAccessIterator, const T &);
+QT_DEPRECATED inline void qStableSortHelper(RandomAccessIterator, RandomAccessIterator, const T &);
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan);
+#endif // QT_DEPRECATED_SINCE(5, 2)
}
+#if QT_DEPRECATED_SINCE(5, 2)
template <typename InputIterator, typename OutputIterator>
-inline OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
+QT_DEPRECATED inline OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterator dest)
{
while (begin != end)
*dest++ = *begin++;
@@ -81,7 +84,7 @@ inline OutputIterator qCopy(InputIterator begin, InputIterator end, OutputIterat
}
template <typename BiIterator1, typename BiIterator2>
-inline BiIterator2 qCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2 dest)
+QT_DEPRECATED inline BiIterator2 qCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2 dest)
{
while (begin != end)
*--dest = *--end;
@@ -89,7 +92,7 @@ inline BiIterator2 qCopyBackward(BiIterator1 begin, BiIterator1 end, BiIterator2
}
template <typename InputIterator1, typename InputIterator2>
-inline bool qEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
+QT_DEPRECATED inline bool qEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2)
{
for (; first1 != last1; ++first1, ++first2)
if (!(*first1 == *first2))
@@ -98,20 +101,20 @@ inline bool qEqual(InputIterator1 first1, InputIterator1 last1, InputIterator2 f
}
template <typename ForwardIterator, typename T>
-inline void qFill(ForwardIterator first, ForwardIterator last, const T &val)
+QT_DEPRECATED inline void qFill(ForwardIterator first, ForwardIterator last, const T &val)
{
for (; first != last; ++first)
*first = val;
}
template <typename Container, typename T>
-inline void qFill(Container &container, const T &val)
+QT_DEPRECATED inline void qFill(Container &container, const T &val)
{
qFill(container.begin(), container.end(), val);
}
template <typename InputIterator, typename T>
-inline InputIterator qFind(InputIterator first, InputIterator last, const T &val)
+QT_DEPRECATED inline InputIterator qFind(InputIterator first, InputIterator last, const T &val)
{
while (first != last && !(*first == val))
++first;
@@ -119,13 +122,13 @@ inline InputIterator qFind(InputIterator first, InputIterator last, const T &val
}
template <typename Container, typename T>
-inline typename Container::const_iterator qFind(const Container &container, const T &val)
+QT_DEPRECATED inline typename Container::const_iterator qFind(const Container &container, const T &val)
{
return qFind(container.constBegin(), container.constEnd(), val);
}
template <typename InputIterator, typename T, typename Size>
-inline void qCount(InputIterator first, InputIterator last, const T &value, Size &n)
+QT_DEPRECATED inline void qCount(InputIterator first, InputIterator last, const T &value, Size &n)
{
for (; first != last; ++first)
if (*first == value)
@@ -133,7 +136,7 @@ inline void qCount(InputIterator first, InputIterator last, const T &value, Size
}
template <typename Container, typename T, typename Size>
-inline void qCount(const Container &container, const T &value, Size &n)
+QT_DEPRECATED inline void qCount(const Container &container, const T &value, Size &n)
{
qCount(container.constBegin(), container.constEnd(), value, n);
}
@@ -150,7 +153,7 @@ LessThan qGreater()
}
#else
template <typename T>
-class qLess
+class QT_DEPRECATED qLess
{
public:
inline bool operator()(const T &t1, const T &t2) const
@@ -160,7 +163,7 @@ public:
};
template <typename T>
-class qGreater
+class QT_DEPRECATED qGreater
{
public:
inline bool operator()(const T &t1, const T &t2) const
@@ -171,21 +174,21 @@ public:
#endif
template <typename RandomAccessIterator>
-inline void qSort(RandomAccessIterator start, RandomAccessIterator end)
+QT_DEPRECATED inline void qSort(RandomAccessIterator start, RandomAccessIterator end)
{
if (start != end)
QAlgorithmsPrivate::qSortHelper(start, end, *start);
}
template <typename RandomAccessIterator, typename LessThan>
-inline void qSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
+QT_DEPRECATED inline void qSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
{
if (start != end)
QAlgorithmsPrivate::qSortHelper(start, end, *start, lessThan);
}
template<typename Container>
-inline void qSort(Container &c)
+QT_DEPRECATED inline void qSort(Container &c)
{
#ifdef Q_CC_BOR
// Work around Borland 5.5 optimizer bug
@@ -196,21 +199,21 @@ inline void qSort(Container &c)
}
template <typename RandomAccessIterator>
-inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
+QT_DEPRECATED inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end)
{
if (start != end)
QAlgorithmsPrivate::qStableSortHelper(start, end, *start);
}
template <typename RandomAccessIterator, typename LessThan>
-inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
+QT_DEPRECATED inline void qStableSort(RandomAccessIterator start, RandomAccessIterator end, LessThan lessThan)
{
if (start != end)
QAlgorithmsPrivate::qStableSortHelper(start, end, *start, lessThan);
}
template<typename Container>
-inline void qStableSort(Container &c)
+QT_DEPRECATED inline void qStableSort(Container &c)
{
#ifdef Q_CC_BOR
// Work around Borland 5.5 optimizer bug
@@ -221,7 +224,7 @@ inline void qStableSort(Container &c)
}
template <typename RandomAccessIterator, typename T>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
{
// Implementation is duplicated from QAlgorithmsPrivate to keep existing code
// compiling. We have to allow using *begin and value with different types,
@@ -244,19 +247,19 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin
}
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
return QAlgorithmsPrivate::qLowerBoundHelper(begin, end, value, lessThan);
}
template <typename Container, typename T>
-Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qLowerBound(const Container &container, const T &value)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qLowerBound(const Container &container, const T &value)
{
return QAlgorithmsPrivate::qLowerBoundHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
}
template <typename RandomAccessIterator, typename T>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
{
// Implementation is duplicated from QAlgorithmsPrivate.
RandomAccessIterator middle;
@@ -277,19 +280,19 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin
}
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
return QAlgorithmsPrivate::qUpperBoundHelper(begin, end, value, lessThan);
}
template <typename Container, typename T>
-Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qUpperBound(const Container &container, const T &value)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qUpperBound(const Container &container, const T &value)
{
return QAlgorithmsPrivate::qUpperBoundHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
}
template <typename RandomAccessIterator, typename T>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
{
// Implementation is duplicated from QAlgorithmsPrivate.
RandomAccessIterator it = qLowerBound(begin, end, value);
@@ -301,16 +304,17 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin
}
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
return QAlgorithmsPrivate::qBinaryFindHelper(begin, end, value, lessThan);
}
template <typename Container, typename T>
-Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qBinaryFind(const Container &container, const T &value)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE typename Container::const_iterator qBinaryFind(const Container &container, const T &value)
{
return QAlgorithmsPrivate::qBinaryFindHelper(container.constBegin(), container.constEnd(), value, qLess<T>());
}
+#endif // QT_DEPRECATED_SINCE(5, 2)
template <typename ForwardIterator>
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
@@ -333,8 +337,10 @@ inline void qDeleteAll(const Container &c)
*/
namespace QAlgorithmsPrivate {
+#if QT_DEPRECATED_SINCE(5, 2)
+
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qSortHelper(RandomAccessIterator start, RandomAccessIterator end, const T &t, LessThan lessThan)
{
top:
int span = int(end - start);
@@ -387,13 +393,13 @@ top:
}
template <typename RandomAccessIterator, typename T>
-inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy)
+QT_DEPRECATED inline void qSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy)
{
qSortHelper(begin, end, dummy, qLess<T>());
}
template <typename RandomAccessIterator>
-Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessIterator end)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessIterator end)
{
--end;
while (begin < end)
@@ -401,7 +407,7 @@ Q_OUTOFLINE_TEMPLATE void qReverse(RandomAccessIterator begin, RandomAccessItera
}
template <typename RandomAccessIterator>
-Q_OUTOFLINE_TEMPLATE void qRotate(RandomAccessIterator begin, RandomAccessIterator middle, RandomAccessIterator end)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qRotate(RandomAccessIterator begin, RandomAccessIterator middle, RandomAccessIterator end)
{
qReverse(begin, middle);
qReverse(middle, end);
@@ -409,7 +415,7 @@ Q_OUTOFLINE_TEMPLATE void qRotate(RandomAccessIterator begin, RandomAccessIterat
}
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE void qMerge(RandomAccessIterator begin, RandomAccessIterator pivot, RandomAccessIterator end, T &t, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qMerge(RandomAccessIterator begin, RandomAccessIterator pivot, RandomAccessIterator end, T &t, LessThan lessThan)
{
const int len1 = pivot - begin;
const int len2 = end - pivot;
@@ -444,7 +450,7 @@ Q_OUTOFLINE_TEMPLATE void qMerge(RandomAccessIterator begin, RandomAccessIterato
}
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &t, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &t, LessThan lessThan)
{
const int span = end - begin;
if (span < 2)
@@ -457,13 +463,13 @@ Q_OUTOFLINE_TEMPLATE void qStableSortHelper(RandomAccessIterator begin, RandomAc
}
template <typename RandomAccessIterator, typename T>
-inline void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy)
+QT_DEPRECATED inline void qStableSortHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &dummy)
{
qStableSortHelper(begin, end, dummy, qLess<T>());
}
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
RandomAccessIterator middle;
int n = int(end - begin);
@@ -484,7 +490,7 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBoundHelper(RandomAccessIterator
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
RandomAccessIterator middle;
int n = end - begin;
@@ -504,7 +510,7 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator
}
template <typename RandomAccessIterator, typename T, typename LessThan>
-Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
+QT_DEPRECATED Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
RandomAccessIterator it = qLowerBoundHelper(begin, end, value, lessThan);
@@ -514,8 +520,77 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator
return it;
}
+#endif // QT_DEPRECATED_SINCE(5, 2)
+
} //namespace QAlgorithmsPrivate
+
+// Use __builtin_popcount on gcc. Clang claims to be gcc
+// but has a bug where __builtin_popcount is not marked as
+// constexpr.
+#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
+#define QALGORITHMS_USE_BUILTIN_POPCOUNT
+#endif
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint32 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcount(v);
+#else
+ // See http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 24) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint8 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcount(v);
+#else
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint16 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcount(v);
+#else
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(quint64 v)
+{
+#ifdef QALGORITHMS_USE_BUILTIN_POPCOUNT
+ return __builtin_popcountll(v);
+#else
+ return
+ (((v ) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 12) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 24) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 36) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 48) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f +
+ (((v >> 60) & 0xfff) * Q_UINT64_C(0x1001001001001) & Q_UINT64_C(0x84210842108421)) % 0x1f;
+#endif
+}
+
+Q_DECL_CONSTEXPR inline uint qPopulationCount(long unsigned int v)
+{
+ return qPopulationCount(static_cast<quint64>(v));
+}
+
+#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG)
+#undef QALGORITHMS_USE_BUILTIN_POPCOUNT
+#endif
+
+
QT_END_NAMESPACE
#endif // QALGORITHMS_H
diff --git a/src/corelib/tools/qarraydataops.h b/src/corelib/tools/qarraydataops.h
index 3cd8c51..c8a0825 100644
--- a/src/corelib/tools/qarraydataops.h
+++ b/src/corelib/tools/qarraydataops.h
@@ -62,7 +62,7 @@ struct QPodArrayOps
Q_ASSERT(newSize <= this->alloc);
::memset(this->end(), 0, (newSize - this->size) * sizeof(T));
- this->size = newSize;
+ this->size = int(newSize);
}
void copyAppend(const T *b, const T *e)
@@ -84,7 +84,7 @@ struct QPodArrayOps
const T *const end = iter + n;
for (; iter != end; ++iter)
::memcpy(iter, &t, sizeof(T));
- this->size += n;
+ this->size += int(n);
}
void truncate(size_t newSize)
@@ -92,7 +92,7 @@ struct QPodArrayOps
Q_ASSERT(!this->ref.isShared());
Q_ASSERT(newSize < size_t(this->size));
- this->size = newSize;
+ this->size = int(newSize);
}
void destroyAll() // Call from destructors, ONLY!
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index 1103712..eaf9b2f 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -61,6 +61,7 @@ public:
QBitArray(const QBitArray &other) : d(other.d) {}
inline QBitArray &operator=(const QBitArray &other) { d = other.d; return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
+ inline QBitArray(QBitArray &&other) : d(std::move(other.d)) {}
inline QBitArray &operator=(QBitArray &&other)
{ qSwap(d, other.d); return *this; }
#endif
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index f3cc301..ae8166d 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -173,6 +173,15 @@ private:
typedef QTypedArrayData<char> Data;
public:
+ enum Base64Option {
+ Base64Encoding = 0,
+ Base64UrlEncoding = 1,
+
+ KeepTrailingEquals = 0,
+ OmitTrailingEquals = 2
+ };
+ Q_DECLARE_FLAGS(Base64Options, Base64Option)
+
inline QByteArray();
QByteArray(const char *, int size = -1);
QByteArray(int size, char c);
@@ -317,7 +326,8 @@ public:
qulonglong toULongLong(bool *ok = 0, int base = 10) const;
float toFloat(bool *ok = 0) const;
double toDouble(bool *ok = 0) const;
- QByteArray toBase64() const;
+ QByteArray toBase64(Base64Options options) const;
+ QByteArray toBase64() const; // ### Qt6 merge with previous
QByteArray toHex() const;
QByteArray toPercentEncoding(const QByteArray &exclude = QByteArray(),
const QByteArray &include = QByteArray(),
@@ -339,7 +349,8 @@ public:
static QByteArray number(qulonglong, int base = 10);
static QByteArray number(double, char f = 'g', int prec = 6);
static QByteArray fromRawData(const char *, int size);
- static QByteArray fromBase64(const QByteArray &base64);
+ static QByteArray fromBase64(const QByteArray &base64, Base64Options options);
+ static QByteArray fromBase64(const QByteArray &base64); // ### Qt6 merge with previous
static QByteArray fromHex(const QByteArray &hexEncoded);
static QByteArray fromPercentEncoding(const QByteArray &pctEncoded, char percent = '%');
@@ -373,7 +384,7 @@ public:
bool isNull() const;
inline QByteArray(QByteArrayDataPtr dd)
- : d(reinterpret_cast<Data *>(dd.ptr))
+ : d(static_cast<Data *>(dd.ptr))
{
}
@@ -392,6 +403,8 @@ public:
inline DataPtr &data_ptr() { return d; }
};
+Q_DECLARE_OPERATORS_FOR_FLAGS(QByteArray::Base64Options)
+
inline QByteArray::QByteArray(): d(Data::sharedNull()) { }
inline QByteArray::~QByteArray() { if (!d->ref.deref()) Data::deallocate(d); }
inline int QByteArray::size() const
diff --git a/src/corelib/tools/qcryptographichash.h b/src/corelib/tools/qcryptographichash.h
index d4e75c4..c4f7c3a 100644
--- a/src/corelib/tools/qcryptographichash.h
+++ b/src/corelib/tools/qcryptographichash.h
@@ -55,9 +55,12 @@ class Q_CORE_EXPORT QCryptographicHash
{
public:
enum Algorithm {
+#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
Md4,
Md5,
- Sha1,
+#endif
+ Sha1 = 2,
+#ifndef QT_CRYPTOGRAPHICHASH_ONLY_SHA1
Sha224,
Sha256,
Sha384,
@@ -66,6 +69,7 @@ public:
Sha3_256,
Sha3_384,
Sha3_512
+#endif
};
explicit QCryptographicHash(Algorithm method);
diff --git a/src/corelib/tools/qdatetime.h b/src/corelib/tools/qdatetime.h
index 5c16680..b9f6995 100644
--- a/src/corelib/tools/qdatetime.h
+++ b/src/corelib/tools/qdatetime.h
@@ -50,6 +50,7 @@
QT_BEGIN_NAMESPACE
+class QTimeZone;
class Q_CORE_EXPORT QDate
{
@@ -168,6 +169,9 @@ public:
bool operator>(const QTime &other) const { return mds > other.mds; }
bool operator>=(const QTime &other) const { return mds >= other.mds; }
+ static inline QTime fromMSecsSinceStartOfDay(int msecs) { QTime t; t.mds = msecs; return t; }
+ inline int msecsSinceStartOfDay() const { return mds == NullTime ? 0 : mds; }
+
static QTime currentTime();
#ifndef QT_NO_DATESTRING
static QTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
@@ -203,6 +207,11 @@ public:
QDateTime();
explicit QDateTime(const QDate &);
QDateTime(const QDate &, const QTime &, Qt::TimeSpec spec = Qt::LocalTime);
+ // ### Qt 6: Merge with above with default offsetSeconds = 0
+ QDateTime(const QDate &date, const QTime &time, Qt::TimeSpec spec, int offsetSeconds);
+#ifndef QT_BOOTSTRAPPED
+ QDateTime(const QDate &date, const QTime &time, const QTimeZone &timeZone);
+#endif // QT_BOOTSTRAPPED
QDateTime(const QDateTime &other);
~QDateTime();
@@ -216,13 +225,28 @@ public:
QDate date() const;
QTime time() const;
Qt::TimeSpec timeSpec() const;
+ int offsetFromUtc() const;
+#ifndef QT_BOOTSTRAPPED
+ QTimeZone timeZone() const;
+#endif // QT_BOOTSTRAPPED
+ QString timeZoneAbbreviation() const;
+ bool isDaylightTime() const;
+
qint64 toMSecsSinceEpoch() const;
+ // ### Qt 6: use quint64 instead of uint
uint toTime_t() const;
+
void setDate(const QDate &date);
void setTime(const QTime &time);
void setTimeSpec(Qt::TimeSpec spec);
+ void setOffsetFromUtc(int offsetSeconds);
+#ifndef QT_BOOTSTRAPPED
+ void setTimeZone(const QTimeZone &toZone);
+#endif // QT_BOOTSTRAPPED
void setMSecsSinceEpoch(qint64 msecs);
+ // ### Qt 6: use quint64 instead of uint
void setTime_t(uint secsSince1Jan1970UTC);
+
#ifndef QT_NO_DATESTRING
QString toString(Qt::DateFormat f = Qt::TextDate) const;
QString toString(const QString &format) const;
@@ -232,9 +256,15 @@ public:
QDateTime addYears(int years) const;
QDateTime addSecs(qint64 secs) const;
QDateTime addMSecs(qint64 msecs) const;
+
QDateTime toTimeSpec(Qt::TimeSpec spec) const;
inline QDateTime toLocalTime() const { return toTimeSpec(Qt::LocalTime); }
inline QDateTime toUTC() const { return toTimeSpec(Qt::UTC); }
+ QDateTime toOffsetFromUtc(int offsetSeconds) const;
+#ifndef QT_BOOTSTRAPPED
+ QDateTime toTimeZone(const QTimeZone &toZone) const;
+#endif // QT_BOOTSTRAPPED
+
qint64 daysTo(const QDateTime &) const;
qint64 secsTo(const QDateTime &) const;
qint64 msecsTo(const QDateTime &) const;
@@ -246,8 +276,10 @@ public:
inline bool operator>(const QDateTime &other) const { return other < *this; }
inline bool operator>=(const QDateTime &other) const { return !(*this < other); }
- void setUtcOffset(int seconds);
- int utcOffset() const;
+#if QT_DEPRECATED_SINCE(5, 2)
+ QT_DEPRECATED void setUtcOffset(int seconds);
+ QT_DEPRECATED int utcOffset() const;
+#endif // QT_DEPRECATED_SINCE
static QDateTime currentDateTime();
static QDateTime currentDateTimeUtc();
@@ -255,8 +287,20 @@ public:
static QDateTime fromString(const QString &s, Qt::DateFormat f = Qt::TextDate);
static QDateTime fromString(const QString &s, const QString &format);
#endif
+ // ### Qt 6: use quint64 instead of uint
static QDateTime fromTime_t(uint secsSince1Jan1970UTC);
+ // ### Qt 6: Merge with above with default spec = Qt::LocalTime
+ static QDateTime fromTime_t(uint secsSince1Jan1970UTC, Qt::TimeSpec spec,
+ int offsetFromUtc = 0);
+#ifndef QT_BOOTSTRAPPED
+ static QDateTime fromTime_t(uint secsSince1Jan1970UTC, const QTimeZone &timeZone);
+#endif
static QDateTime fromMSecsSinceEpoch(qint64 msecs);
+ // ### Qt 6: Merge with above with default spec = Qt::LocalTime
+ static QDateTime fromMSecsSinceEpoch(qint64 msecs, Qt::TimeSpec spec, int offsetFromUtc = 0);
+#ifndef QT_BOOTSTRAPPED
+ static QDateTime fromMSecsSinceEpoch(qint64 msecs, const QTimeZone &timeZone);
+#endif
static qint64 currentMSecsSinceEpoch() Q_DECL_NOTHROW;
private:
@@ -272,6 +316,10 @@ private:
friend Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QDateTime &);
friend Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QDateTime &);
#endif
+
+#if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_NO_DATESTRING)
+ friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QDateTime &);
+#endif
};
Q_DECLARE_SHARED(QDateTime)
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index e99a67d..9dd0e61 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -509,6 +509,20 @@ private:
static void deleteNode2(QHashData::Node *node);
static void duplicateNode(QHashData::Node *originalNode, void *newNode);
+
+ bool isValidIterator(const iterator &it) const
+ {
+#if defined(QT_DEBUG) && !defined(Q_HASH_NO_ITERATOR_DEBUG)
+ QHashData::Node *node = it.i;
+ while (node->next)
+ node = node->next;
+ return (static_cast<void *>(node) == d);
+#else
+ Q_UNUSED(it);
+ return true;
+#endif
+ }
+ friend class QSet<Key>;
};
@@ -831,9 +845,27 @@ Q_OUTOFLINE_TEMPLATE T QHash<Key, T>::take(const Key &akey)
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE typename QHash<Key, T>::iterator QHash<Key, T>::erase(iterator it)
{
+ Q_ASSERT_X(isValidIterator(it), "QHash::erase", "The specified iterator argument 'it' is invalid");
+
if (it == iterator(e))
return it;
+ if (d->ref.isShared()) {
+ int bucketNum = (it.i->h % d->numBuckets);
+ iterator bucketIterator(*(d->buckets + bucketNum));
+ int stepsFromBucketStartToIte = 0;
+ while (bucketIterator != it) {
+ ++stepsFromBucketStartToIte;
+ ++bucketIterator;
+ }
+ detach();
+ it = iterator(*(d->buckets + bucketNum));
+ while (stepsFromBucketStartToIte > 0) {
+ --stepsFromBucketStartToIte;
+ ++it;
+ }
+ }
+
iterator ret = it;
++ret;
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index b9ca1b9..79a62cb 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -48,6 +48,12 @@
#include <iterator>
#include <list>
+#include <algorithm>
+
+#if defined(Q_COMPILER_INITIALIZER_LISTS)
+# include <initializer_list>
+#endif
+
QT_BEGIN_NAMESPACE
@@ -78,6 +84,13 @@ class QLinkedList
public:
inline QLinkedList() : d(const_cast<QLinkedListData *>(&QLinkedListData::shared_null)) { }
inline QLinkedList(const QLinkedList<T> &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); }
+#if defined(Q_COMPILER_INITIALIZER_LISTS)
+ inline QLinkedList(std::initializer_list<T> list)
+ : d(const_cast<QLinkedListData *>(&QLinkedListData::shared_null))
+ {
+ std::copy(list.begin(), list.end(), std::back_inserter(*this));
+ }
+#endif
~QLinkedList();
QLinkedList<T> &operator=(const QLinkedList<T> &);
#ifdef Q_COMPILER_RVALUE_REFS
@@ -91,7 +104,7 @@ public:
inline int size() const { return d->size; }
inline void detach()
- { if (d->ref.isShared()) detach_helper(); }
+ { if (d->ref.isShared()) detach_helper2(this->e); }
inline bool isDetached() const { return !d->ref.isShared(); }
inline void setSharable(bool sharable) { if (!sharable) detach(); if (d != &QLinkedListData::shared_null) d->sharable = sharable; }
inline bool isSharedWith(const QLinkedList<T> &other) const { return d == other.d; }
@@ -219,9 +232,9 @@ public:
typedef qptrdiff difference_type;
static inline QLinkedList<T> fromStdList(const std::list<T> &list)
- { QLinkedList<T> tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
+ { QLinkedList<T> tmp; std::copy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
inline std::list<T> toStdList() const
- { std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
+ { std::list<T> tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
// comfort
QLinkedList<T> &operator+=(const QLinkedList<T> &l);
@@ -232,6 +245,7 @@ public:
private:
void detach_helper();
+ iterator detach_helper2(iterator);
void freeData(QLinkedListData*);
};
@@ -245,6 +259,14 @@ inline QLinkedList<T>::~QLinkedList()
template <typename T>
void QLinkedList<T>::detach_helper()
{
+ detach_helper2(this->e);
+}
+
+template <typename T>
+typename QLinkedList<T>::iterator QLinkedList<T>::detach_helper2(iterator orgite)
+{
+ // detach and convert orgite to an iterator in the detached instance
+ bool isEndIterator = (orgite.i == this->e);
union { QLinkedListData *d; Node *e; } x;
x.d = new QLinkedListData;
x.d->ref.initializeOwned();
@@ -252,6 +274,22 @@ void QLinkedList<T>::detach_helper()
x.d->sharable = true;
Node *original = e->n;
Node *copy = x.e;
+ Node *org = orgite.i;
+
+ while (original != org) {
+ QT_TRY {
+ copy->n = new Node(original->t);
+ copy->n->p = copy;
+ original = original->n;
+ copy = copy->n;
+ } QT_CATCH(...) {
+ copy->n = x.e;
+ Q_ASSERT(!x.d->ref.deref()); // Don't trigger assert in free
+ freeData(x.d);
+ QT_RETHROW;
+ }
+ }
+ iterator r(copy);
while (original != e) {
QT_TRY {
copy->n = new Node(original->t);
@@ -270,6 +308,9 @@ void QLinkedList<T>::detach_helper()
if (!d->ref.deref())
freeData(d);
d = x.d;
+ if (!isEndIterator)
+ ++r; // since we stored the element right before the original node.
+ return r;
}
template <typename T>
@@ -376,7 +417,7 @@ template <typename T>
bool QLinkedList<T>::removeOne(const T &_t)
{
detach();
- iterator it = qFind(begin(), end(), _t);
+ iterator it = std::find(begin(), end(), _t);
if (it != end()) {
erase(it);
return true;
@@ -425,6 +466,9 @@ int QLinkedList<T>::count(const T &t) const
template <typename T>
typename QLinkedList<T>::iterator QLinkedList<T>::insert(iterator before, const T &t)
{
+ if (d->ref.isShared())
+ before = detach_helper2(before);
+
Node *i = before.i;
Node *m = new Node(t);
m->n = i;
@@ -448,7 +492,9 @@ typename QLinkedList<T>::iterator QLinkedList<T>::erase(typename QLinkedList<T>:
template <typename T>
typename QLinkedList<T>::iterator QLinkedList<T>::erase(iterator pos)
{
- detach();
+ if (d->ref.isShared())
+ pos = detach_helper2(pos);
+
Node *i = pos.i;
if (i != e) {
Node *n = i;
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 0592c24..333ce72 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -48,6 +48,7 @@
#include <iterator>
#include <list>
+#include <algorithm>
#ifdef Q_COMPILER_INITIALIZER_LISTS
#include <initializer_list>
#endif
@@ -123,7 +124,7 @@ public:
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QList(std::initializer_list<T> args)
: d(const_cast<QListData::Data *>(&QListData::shared_null))
- { qCopy(args.begin(), args.end(), std::back_inserter(*this)); }
+ { std::copy(args.begin(), args.end(), std::back_inserter(*this)); }
#endif
bool operator==(const QList<T> &l) const;
inline bool operator!=(const QList<T> &l) const { return !(*this == l); }
@@ -332,9 +333,9 @@ public:
static QList<T> fromSet(const QSet<T> &set);
static inline QList<T> fromStdList(const std::list<T> &list)
- { QList<T> tmp; qCopy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
+ { QList<T> tmp; std::copy(list.begin(), list.end(), std::back_inserter(tmp)); return tmp; }
inline std::list<T> toStdList() const
- { std::list<T> tmp; qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
+ { std::list<T> tmp; std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
private:
Node *detach_helper_grow(int i, int n);
@@ -346,6 +347,11 @@ private:
void node_destruct(Node *n);
void node_copy(Node *from, Node *to, Node *src);
void node_destruct(Node *from, Node *to);
+
+ bool isValidIterator(const iterator &i) const
+ {
+ return (constBegin().i <= i.i) && (i.i <= constEnd().i);
+ }
};
#if defined(Q_CC_BOR)
@@ -433,8 +439,14 @@ Q_INLINE_TEMPLATE QList<T> &QList<T>::operator=(const QList<T> &l)
template <typename T>
inline typename QList<T>::iterator QList<T>::insert(iterator before, const T &t)
{
+ Q_ASSERT_X(isValidIterator(before), "QList::insert", "The specified iterator argument 'before' is invalid");
+
int iBefore = int(before.i - reinterpret_cast<Node *>(p.begin()));
- Node *n = reinterpret_cast<Node *>(p.insert(iBefore));
+ Node *n = 0;
+ if (d->ref.isShared())
+ n = detach_helper_grow(iBefore, 1);
+ else
+ n = reinterpret_cast<Node *>(p.insert(iBefore));
QT_TRY {
node_construct(n, t);
} QT_CATCH(...) {
@@ -445,8 +457,16 @@ inline typename QList<T>::iterator QList<T>::insert(iterator before, const T &t)
}
template <typename T>
inline typename QList<T>::iterator QList<T>::erase(iterator it)
-{ node_destruct(it.i);
- return reinterpret_cast<Node *>(p.erase(reinterpret_cast<void**>(it.i))); }
+{
+ Q_ASSERT_X(isValidIterator(it), "QList::erase", "The specified iterator argument 'it' is invalid");
+ if (d->ref.isShared()) {
+ int offset = int(it.i - reinterpret_cast<Node *>(p.begin()));
+ it = begin(); // implies detach()
+ it += offset;
+ }
+ node_destruct(it.i);
+ return reinterpret_cast<Node *>(p.erase(reinterpret_cast<void**>(it.i)));
+}
template <typename T>
inline const T &QList<T>::at(int i) const
{ Q_ASSERT_X(i >= 0 && i < p.size(), "QList<T>::at", "index out of range");
@@ -619,7 +639,7 @@ inline void QList<T>::move(int from, int to)
template<typename T>
Q_OUTOFLINE_TEMPLATE QList<T> QList<T>::mid(int pos, int alength) const
{
- if (alength < 0 || pos + alength > size())
+ if (alength < 0 || pos > size() - alength)
alength = size() - pos;
if (pos == 0 && alength == size())
return *this;
@@ -715,18 +735,14 @@ Q_OUTOFLINE_TEMPLATE QList<T>::QList(const QList<T> &l)
if (!d->ref.ref()) {
p.detach(d->alloc);
- struct Cleanup
- {
- Cleanup(QListData::Data *d) : d_(d) {}
- ~Cleanup() { if (d_) QListData::dispose(d_); }
-
- QListData::Data *d_;
- } tryCatch(d);
-
+ QT_TRY {
node_copy(reinterpret_cast<Node *>(p.begin()),
reinterpret_cast<Node *>(p.end()),
reinterpret_cast<Node *>(l.p.begin()));
- tryCatch.d_ = 0;
+ } QT_CATCH(...) {
+ QListData::dispose(d);
+ QT_RETHROW;
+ }
}
}
@@ -811,6 +827,19 @@ template <typename T>
Q_OUTOFLINE_TEMPLATE typename QList<T>::iterator QList<T>::erase(typename QList<T>::iterator afirst,
typename QList<T>::iterator alast)
{
+ Q_ASSERT_X(isValidIterator(afirst), "QList::erase", "The specified iterator argument 'afirst' is invalid");
+ Q_ASSERT_X(isValidIterator(alast), "QList::erase", "The specified iterator argument 'alast' is invalid");
+
+ if (d->ref.isShared()) {
+ // ### A block is erased and a detach is needed. We should shrink and only copy relevant items.
+ int offsetfirst = int(afirst.i - reinterpret_cast<Node *>(p.begin()));
+ int offsetlast = int(alast.i - reinterpret_cast<Node *>(p.begin()));
+ afirst = begin(); // implies detach()
+ alast = afirst;
+ afirst += offsetfirst;
+ alast += offsetlast;
+ }
+
for (Node *n = afirst.i; n < alast.i; ++n)
node_destruct(n);
int idx = afirst - begin();
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index 78fa336..0fc3f87 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -775,13 +775,14 @@ public:
SouthSudan = 254,
Bonaire = 255,
SintMaarten = 256,
+ Kosovo = 257,
DemocraticRepublicOfCongo = CongoKinshasa,
PeoplesRepublicOfCongo = CongoBrazzaville,
DemocraticRepublicOfKorea = NorthKorea,
RepublicOfKorea = SouthKorea,
RussianFederation = Russia,
SyrianArabRepublic = Syria,
- LastCountry = SintMaarten
+ LastCountry = Kosovo
};
// GENERATED PART ENDS HERE
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 449fcbc..db0cd6a 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -140,32 +140,32 @@ template <class Key, class T>
inline QMapNode<Key, T> *QMapNode<Key, T>::lowerBound(const Key &akey)
{
QMapNode<Key, T> *n = this;
- QMapNode<Key, T> *last = 0;
+ QMapNode<Key, T> *lastNode = 0;
while (n) {
if (!qMapLessThanKey(n->key, akey)) {
- last = n;
+ lastNode = n;
n = n->leftNode();
} else {
n = n->rightNode();
}
}
- return last;
+ return lastNode;
}
template <class Key, class T>
inline QMapNode<Key, T> *QMapNode<Key, T>::upperBound(const Key &akey)
{
QMapNode<Key, T> *n = this;
- QMapNode<Key, T> *last = 0;
+ QMapNode<Key, T> *lastNode = 0;
while (n) {
if (qMapLessThanKey(akey, n->key)) {
- last = n;
+ lastNode = n;
n = n->leftNode();
} else {
n = n->rightNode();
}
}
- return last;
+ return lastNode;
}
@@ -206,7 +206,7 @@ struct QMapData : public QMapDataBase
void deleteNode(Node *z);
Node *findNode(const Key &akey) const;
- void nodeRange(const Key &akey, Node **first, Node **last);
+ void nodeRange(const Key &akey, Node **firstNode, Node **lastNode);
Node *createNode(const Key &k, const T &v, Node *parent = 0, bool left = false)
{
@@ -288,15 +288,17 @@ void QMapData<Key, T>::deleteNode(QMapNode<Key, T> *z)
template <class Key, class T>
QMapNode<Key, T> *QMapData<Key, T>::findNode(const Key &akey) const
{
- Node *lb = root()->lowerBound(akey);
+ if (Node *r = root()) {
+ Node *lb = r->lowerBound(akey);
if (lb && !qMapLessThanKey(akey, lb->key))
return lb;
+ }
return 0;
}
template <class Key, class T>
-void QMapData<Key, T>::nodeRange(const Key &akey, QMapNode<Key, T> **first, QMapNode<Key, T> **last)
+void QMapData<Key, T>::nodeRange(const Key &akey, QMapNode<Key, T> **firstNode, QMapNode<Key, T> **lastNode)
{
Node *n = root();
Node *l = end();
@@ -307,16 +309,16 @@ void QMapData<Key, T>::nodeRange(const Key &akey, QMapNode<Key, T> **first, QMap
} else if (qMapLessThanKey(n->key, akey)) {
n = n->rightNode();
} else {
- *first = n->leftNode()->lowerBound(akey);
- if (!*first)
- *first = n;
- *last = n->rightNode()->upperBound(akey);
- if (!*last)
- *last = l;
+ *firstNode = n->leftNode() ? n->leftNode()->lowerBound(akey) : 0;
+ if (!*firstNode)
+ *firstNode = n;
+ *lastNode = n->rightNode() ? n->rightNode()->upperBound(akey) : 0;
+ if (!*lastNode)
+ *lastNode = l;
return;
}
}
- *first = *last = l;
+ *firstNode = *lastNode = l;
}
@@ -395,6 +397,14 @@ public:
QList<T> values(const Key &key) const;
int count(const Key &key) const;
+ inline const Key &firstKey() const { Q_ASSERT(!isEmpty()); return constBegin().key(); }
+ inline const Key &lastKey() const { Q_ASSERT(!isEmpty()); return (constEnd() - 1).key(); }
+
+ inline T &first() { Q_ASSERT(!isEmpty()); return *begin(); }
+ inline const T &first() const { Q_ASSERT(!isEmpty()); return *constBegin(); }
+ inline T &last() { Q_ASSERT(!isEmpty()); return *(end() - 1); }
+ inline const T &last() const { Q_ASSERT(!isEmpty()); return *(constEnd() - 1); }
+
class const_iterator;
class iterator
@@ -557,6 +567,18 @@ public:
private:
void detach_helper();
+ bool isValidIterator(const const_iterator &ci) const
+ {
+#if defined(QT_DEBUG) && !defined(Q_MAP_NO_ITERATOR_DEBUG)
+ const QMapNodeBase *n = ci.i;
+ while (n->parent())
+ n = n->parent();
+ return n->left == d->root();
+#else
+ Q_UNUSED(ci);
+ return true;
+#endif
+ }
};
template <class Key, class T>
@@ -621,12 +643,12 @@ Q_INLINE_TEMPLATE int QMap<Key, T>::count(const Key &akey) const
Node *lastNode;
d->nodeRange(akey, &firstNode, &lastNode);
- const_iterator first(firstNode);
- const const_iterator last(lastNode);
+ const_iterator ci_first(firstNode);
+ const const_iterator ci_last(lastNode);
int cnt = 0;
- while (first != last) {
+ while (ci_first != ci_last) {
++cnt;
- ++first;
+ ++ci_first;
}
return cnt;
}
@@ -643,12 +665,12 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insert(const Key
detach();
Node *n = d->root();
Node *y = d->end();
- Node *last = 0;
+ Node *lastNode = 0;
bool left = true;
while (n) {
y = n;
if (!qMapLessThanKey(n->key, akey)) {
- last = n;
+ lastNode = n;
left = true;
n = n->leftNode();
} else {
@@ -656,9 +678,9 @@ Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::insert(const Key
n = n->rightNode();
}
}
- if (last && !qMapLessThanKey(akey, last->key)) {
- last->value = avalue;
- return iterator(last);
+ if (lastNode && !qMapLessThanKey(akey, lastNode->key)) {
+ lastNode->value = avalue;
+ return iterator(lastNode);
}
Node *z = d->createNode(akey, avalue, y, left);
return iterator(z);
@@ -670,6 +692,8 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insert(const_iterator pos, const K
if (d->ref.isShared())
return this->insert(akey, avalue);
+ Q_ASSERT_X(isValidIterator(pos), "QMap::insert", "The specified const_iterator argument 'it' is invalid");
+
if (pos == constEnd()) {
// Hint is that the Node is larger than (or equal to) the largest value.
Node *n = static_cast<Node *>(pos.i->left);
@@ -753,6 +777,8 @@ typename QMap<Key, T>::iterator QMap<Key, T>::insertMulti(const_iterator pos, co
if (d->ref.isShared())
return this->insertMulti(akey, avalue);
+ Q_ASSERT_X(isValidIterator(pos), "QMap::insertMulti", "The specified const_iterator argument 'pos' is invalid");
+
if (pos == constEnd()) {
// Hint is that the Node is larger than (or equal to) the largest value.
Node *n = static_cast<Node *>(pos.i->left);
@@ -836,9 +862,9 @@ template <class Key, class T>
QPair<typename QMap<Key, T>::iterator, typename QMap<Key, T>::iterator> QMap<Key, T>::equal_range(const Key &akey)
{
detach();
- Node *first, *last;
- d->nodeRange(akey, &first, &last);
- return QPair<iterator, iterator>(iterator(first), iterator(last));
+ Node *firstNode, *lastNode;
+ d->nodeRange(akey, &firstNode, &lastNode);
+ return QPair<iterator, iterator>(iterator(firstNode), iterator(lastNode));
}
#ifdef Q_MAP_DEBUG
@@ -895,6 +921,29 @@ Q_OUTOFLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::erase(iterato
if (it == iterator(d->end()))
return it;
+ Q_ASSERT_X(isValidIterator(const_iterator(it)), "QMap::erase", "The specified iterator argument 'it' is invalid");
+
+ if (d->ref.isShared()) {
+ const_iterator oldBegin = constBegin();
+ const_iterator old = const_iterator(it);
+ int backStepsWithSameKey = 0;
+
+ while (old != oldBegin) {
+ --old;
+ if (qMapLessThanKey(old.key(), it.key()))
+ break;
+ ++backStepsWithSameKey;
+ }
+
+ it = find(old.key()); // ensures detach
+ Q_ASSERT_X(it != iterator(d->end()), "QMap::erase", "Unable to locate same key in erase after detach.");
+
+ while (backStepsWithSameKey > 0) {
+ ++it;
+ --backStepsWithSameKey;
+ }
+ }
+
Node *n = it.i;
++it;
d->deleteNode(n);
@@ -1005,7 +1054,7 @@ Q_OUTOFLINE_TEMPLATE QList<T> QMap<Key, T>::values(const Key &akey) const
template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator QMap<Key, T>::lowerBound(const Key &akey) const
{
- Node *lb = d->root()->lowerBound(akey);
+ Node *lb = d->root() ? d->root()->lowerBound(akey) : 0;
if (!lb)
lb = d->end();
return const_iterator(lb);
@@ -1015,7 +1064,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::lowerBound(const Key &akey)
{
detach();
- Node *lb = d->root()->lowerBound(akey);
+ Node *lb = d->root() ? d->root()->lowerBound(akey) : 0;
if (!lb)
lb = d->end();
return iterator(lb);
@@ -1025,7 +1074,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::const_iterator
QMap<Key, T>::upperBound(const Key &akey) const
{
- Node *ub = d->root()->upperBound(akey);
+ Node *ub = d->root() ? d->root()->upperBound(akey) : 0;
if (!ub)
ub = d->end();
return const_iterator(ub);
@@ -1035,7 +1084,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMap<Key, T>::iterator QMap<Key, T>::upperBound(const Key &akey)
{
detach();
- Node *ub = d->root()->upperBound(akey);
+ Node *ub = d->root() ? d->root()->upperBound(akey) : 0;
if (!ub)
ub = d->end();
return iterator(ub);
diff --git a/src/corelib/tools/qmargins.h b/src/corelib/tools/qmargins.h
index 0d68be9..ad5e94c 100644
--- a/src/corelib/tools/qmargins.h
+++ b/src/corelib/tools/qmargins.h
@@ -242,6 +242,24 @@ inline QMargins &QMargins::operator-=(const QMargins &margins)
return *this = *this - margins;
}
+inline QMargins &QMargins::operator+=(int margin)
+{
+ m_left += margin;
+ m_top += margin;
+ m_right += margin;
+ m_bottom += margin;
+ return *this;
+}
+
+inline QMargins &QMargins::operator-=(int margin)
+{
+ m_left -= margin;
+ m_top -= margin;
+ m_right -= margin;
+ m_bottom -= margin;
+ return *this;
+}
+
inline QMargins &QMargins::operator*=(int factor)
{
return *this = *this * factor;
diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h
index 96b1b65..9b8691a 100644
--- a/src/corelib/tools/qpair.h
+++ b/src/corelib/tools/qpair.h
@@ -57,6 +57,19 @@ struct QPair
QPair(const T1 &t1, const T2 &t2) : first(t1), second(t2) {}
// compiler-generated copy/move ctor/assignment operators are fine!
+ template <typename TT1, typename TT2>
+ QPair(const QPair<TT1, TT2> &p) : first(p.first), second(p.second) {}
+ template <typename TT1, typename TT2>
+ QPair &operator=(const QPair<TT1, TT2> &p)
+ { first = p.first; second = p.second; return *this; }
+#ifdef Q_COMPILER_RVALUE_REFS
+ template <typename TT1, typename TT2>
+ QPair(QPair<TT1, TT2> &&p) : first(std::move(p.first)), second(std::move(p.second)) {}
+ template <typename TT1, typename TT2>
+ QPair &operator=(QPair<TT1, TT2> &&p)
+ { first = std::move(p.first); second = std::move(p.second); return *this; }
+#endif
+
T1 first;
T2 second;
};
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 2155c56..dd6e5bd 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -83,6 +83,17 @@ struct QScopedPointerPodDeleter
static inline void cleanup(void *pointer) { if (pointer) free(pointer); }
};
+#ifndef QT_NO_QOBJECT
+template <typename T>
+struct QScopedPointerObjectDeleteLater
+{
+ static inline void cleanup(T *pointer) { if (pointer) pointer->deleteLater(); }
+};
+
+class QObject;
+typedef QScopedPointerObjectDeleteLater<QObject> QScopedPointerDeleteLater;
+#endif
+
template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
class QScopedPointer
{
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index d5c3637..ad2f91b 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -70,6 +70,7 @@ public:
inline QSet<T> &operator=(const QSet<T> &other)
{ q_hash = other.q_hash; return *this; }
#ifdef Q_COMPILER_RVALUE_REFS
+ inline QSet(QSet &&other) : q_hash(qMove(other.q_hash)) {}
inline QSet<T> &operator=(QSet<T> &&other)
{ qSwap(q_hash, other.q_hash); return *this; }
#endif
@@ -180,7 +181,10 @@ public:
inline const_iterator cend() const { return q_hash.end(); }
inline const_iterator constEnd() const { return q_hash.constEnd(); }
iterator erase(iterator i)
- { return q_hash.erase(reinterpret_cast<typename Hash::iterator &>(i)); }
+ {
+ Q_ASSERT_X(isValidIterator(i), "QSet::erase", "The specified const_iterator argument 'i' is invalid");
+ return q_hash.erase(reinterpret_cast<typename Hash::iterator &>(i));
+ }
// more Qt
typedef iterator Iterator;
@@ -233,6 +237,10 @@ public:
private:
Hash q_hash;
+ bool isValidIterator(const iterator &i) const
+ {
+ return q_hash.isValidIterator(reinterpret_cast<const typename Hash::iterator&>(i));
+ }
};
template <class T>
@@ -253,8 +261,16 @@ Q_INLINE_TEMPLATE QSet<T> &QSet<T>::unite(const QSet<T> &other)
template <class T>
Q_INLINE_TEMPLATE QSet<T> &QSet<T>::intersect(const QSet<T> &other)
{
- QSet<T> copy1(*this);
- QSet<T> copy2(other);
+ QSet<T> copy1;
+ QSet<T> copy2;
+ if (size() <= other.size()) {
+ copy1 = *this;
+ copy2 = other;
+ } else {
+ copy1 = other;
+ copy2 = *this;
+ *this = copy1;
+ }
typename QSet<T>::const_iterator i = copy1.constEnd();
while (i != copy1.constBegin()) {
--i;
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 5e30cf3..1423449 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -506,7 +506,7 @@ public:
if (o) {
// increase the strongref, but never up from zero
// or less (-1 is used by QWeakPointer on untracked QObject)
- register int tmp = o->strongref.load();
+ int tmp = o->strongref.load();
while (tmp > 0) {
// try to increment from "tmp" to "tmp + 1"
if (o->strongref.testAndSetRelaxed(tmp, tmp + 1))
@@ -801,7 +801,7 @@ namespace QtSharedPointer {
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerCast(const QSharedPointer<T> &src)
{
- register X *ptr = static_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
+ X *ptr = static_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
return QtSharedPointer::copyAndSetPointer(ptr, src);
}
template <class X, class T>
@@ -813,7 +813,7 @@ Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerCast(const QWeakPointer<T> &sr
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src)
{
- register X *ptr = dynamic_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
+ X *ptr = dynamic_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
if (!ptr)
return QSharedPointer<X>();
return QtSharedPointer::copyAndSetPointer(ptr, src);
@@ -827,7 +827,7 @@ Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QWeakPointer
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerConstCast(const QSharedPointer<T> &src)
{
- register X *ptr = const_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
+ X *ptr = const_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid
return QtSharedPointer::copyAndSetPointer(ptr, src);
}
template <class X, class T>
@@ -847,7 +847,7 @@ QWeakPointer<X> qWeakPointerCast(const QSharedPointer<T> &src)
template <class X, class T>
Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerObjectCast(const QSharedPointer<T> &src)
{
- register X *ptr = qobject_cast<X *>(src.data());
+ X *ptr = qobject_cast<X *>(src.data());
return QtSharedPointer::copyAndSetPointer(ptr, src);
}
template <class X, class T>
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index d8aaa92..2eaed65 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -64,8 +64,12 @@ namespace std
#error qstring.h must be included before any header file that defines truncate
#endif
-QT_BEGIN_NAMESPACE
+#ifdef Q_OS_MAC
+Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
+Q_FORWARD_DECLARE_CF_TYPE(CFString);
+#endif
+QT_BEGIN_NAMESPACE
class QCharRef;
class QRegExp;
@@ -657,8 +661,12 @@ public:
const_iterator constEnd() const;
// STL compatibility
+ typedef int size_type;
+ typedef qptrdiff difference_type;
typedef const QChar & const_reference;
typedef QChar & reference;
+ typedef QChar *pointer;
+ typedef const QChar *const_pointer;
typedef QChar value_type;
inline void push_back(QChar c) { append(c); }
inline void push_back(const QString &s) { append(s); }
@@ -670,6 +678,12 @@ public:
static inline QString fromStdWString(const std::wstring &s);
inline std::wstring toStdWString() const;
+#if defined(Q_OS_MAC) || defined(Q_QDOC)
+ static QString fromCFString(CFStringRef string);
+ CFStringRef toCFString() const Q_DECL_CF_RETURNS_RETAINED;
+ static QString fromNSString(const NSString *string);
+ NSString *toNSString() const Q_DECL_NS_RETURNS_AUTORELEASED;
+#endif
// compatibility
struct Null { };
static const Null null;
@@ -920,8 +934,8 @@ inline QString::~QString() { if (!d->ref.deref()) Data::deallocate(d); }
inline void QString::reserve(int asize)
{
- if (d->ref.isShared() || uint(asize) + 1u > d->alloc)
- reallocData(uint(asize) + 1u);
+ if (d->ref.isShared() || uint(asize) >= d->alloc)
+ reallocData(qMax(asize, d->size) + 1u);
if (!d->capacityReserved) {
// cannot set unconditionally, since d could be the shared_null/shared_empty (which is const)
@@ -1222,6 +1236,10 @@ public:
int count(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
int count(const QStringRef &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
+ QStringRef left(int n) const Q_REQUIRED_RESULT;
+ QStringRef right(int n) const Q_REQUIRED_RESULT;
+ QStringRef mid(int pos, int n = -1) const Q_REQUIRED_RESULT;
+
bool startsWith(const QString &s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QLatin1String s, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
bool startsWith(QChar c, Qt::CaseSensitivity cs = Qt::CaseSensitive) const;
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 3a20280..309d2a2 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -49,6 +49,7 @@
#include <new>
#include <string.h>
#include <stdlib.h>
+#include <algorithm>
QT_BEGIN_NAMESPACE
@@ -192,11 +193,18 @@ private:
qint64 q_for_alignment_1;
double q_for_alignment_2;
};
+
+ bool isValidIterator(const const_iterator &i) const
+ {
+ return (i <= constEnd()) && (constBegin() <= i);
+ }
};
template <class T, int Prealloc>
Q_INLINE_TEMPLATE QVarLengthArray<T, Prealloc>::QVarLengthArray(int asize)
: s(asize) {
+ Q_STATIC_ASSERT_X(Prealloc > 0, "QVarLengthArray Prealloc must be greater than 0.");
+ Q_ASSERT_X(s >= 0, "QVarLengthArray::QVarLengthArray()", "Size must be greater than or equal to 0.");
if (s > Prealloc) {
ptr = reinterpret_cast<T *>(malloc(s * sizeof(T)));
Q_CHECK_PTR(ptr);
@@ -310,7 +318,7 @@ Q_OUTOFLINE_TEMPLATE void QVarLengthArray<T, Prealloc>::realloc(int asize, int a
template <class T, int Prealloc>
Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T, Prealloc>::value(int i) const
{
- if (i < 0 || i >= size()) {
+ if (uint(i) >= uint(size())) {
return T();
}
return at(i);
@@ -318,7 +326,7 @@ Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T, Prealloc>::value(int i) const
template <class T, int Prealloc>
Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T, Prealloc>::value(int i, const T &defaultValue) const
{
- return (i < 0 || i >= size()) ? defaultValue : at(i);
+ return (uint(i) >= uint(size())) ? defaultValue : at(i);
}
template <class T, int Prealloc>
@@ -353,6 +361,8 @@ inline void QVarLengthArray<T, Prealloc>::replace(int i, const T &t)
template <class T, int Prealloc>
Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(const_iterator before, size_type n, const T &t)
{
+ Q_ASSERT_X(isValidIterator(before), "QVarLengthArray::insert", "The specified const_iterator argument 'before' is invalid");
+
int offset = int(before - ptr);
if (n != 0) {
resize(s + n);
@@ -380,11 +390,14 @@ Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthA
template <class T, int Prealloc>
Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(const_iterator abegin, const_iterator aend)
{
+ Q_ASSERT_X(isValidIterator(abegin), "QVarLengthArray::insert", "The specified const_iterator argument 'abegin' is invalid");
+ Q_ASSERT_X(isValidIterator(aend), "QVarLengthArray::insert", "The specified const_iterator argument 'aend' is invalid");
+
int f = int(abegin - ptr);
int l = int(aend - ptr);
int n = l - f;
if (QTypeInfo<T>::isComplex) {
- qCopy(ptr + l, ptr + s, ptr + f);
+ std::copy(ptr + l, ptr + s, ptr + f);
T *i = ptr + s;
T *b = ptr + s - n;
while (i != b) {
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index 816e1f1..f56511e 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -56,6 +56,8 @@
#include <initializer_list>
#endif
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
class QRegion;
@@ -150,6 +152,11 @@ public:
bool contains(const T &t) const;
int count(const T &t) const;
+ // QList compatibility
+ void removeAt(int i) { remove(i); }
+ int length() const { return size(); }
+ T takeAt(int i) { T t = at(i); remove(i); return t; }
+
// STL-style
typedef typename Data::iterator iterator;
typedef typename Data::const_iterator const_iterator;
@@ -185,7 +192,7 @@ public:
inline const T &last() const { Q_ASSERT(!isEmpty()); return *(end()-1); }
inline bool startsWith(const T &t) const { return !isEmpty() && first() == t; }
inline bool endsWith(const T &t) const { return !isEmpty() && last() == t; }
- QVector<T> mid(int pos, int length = -1) const;
+ QVector<T> mid(int pos, int len = -1) const;
T value(int i) const;
T value(int i, const T &defaultValue) const;
@@ -227,18 +234,22 @@ public:
static QVector<T> fromList(const QList<T> &list);
static inline QVector<T> fromStdVector(const std::vector<T> &vector)
- { QVector<T> tmp; tmp.reserve(int(vector.size())); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
+ { QVector<T> tmp; tmp.reserve(int(vector.size())); std::copy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
inline std::vector<T> toStdVector() const
- { std::vector<T> tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
+ { std::vector<T> tmp; tmp.reserve(size()); std::copy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
private:
friend class QRegion; // Optimization for QRegion::rects()
void reallocData(const int size, const int alloc, QArrayData::AllocationOptions options = QArrayData::Default);
+ void reallocData(const int sz) { reallocData(sz, d->alloc); }
void freeData(Data *d);
void defaultConstruct(T *from, T *to);
void copyConstruct(const T *srcFrom, const T *srcTo, T *dstFrom);
void destruct(T *from, T *to);
-
+ bool isValidIterator(const iterator &i) const
+ {
+ return (i <= d->end()) && (d->begin() <= i);
+ }
class AlignmentDummy { Data header; T array[1]; };
};
@@ -398,7 +409,8 @@ QVector<T> &QVector<T>::operator=(const QVector<T> &v)
template <typename T>
QVector<T>::QVector(int asize)
{
- if (Q_LIKELY(asize)) {
+ Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0.");
+ if (Q_LIKELY(asize > 0)) {
d = Data::allocate(asize);
d->size = asize;
defaultConstruct(d->begin(), d->end());
@@ -410,7 +422,8 @@ QVector<T>::QVector(int asize)
template <typename T>
QVector<T>::QVector(int asize, const T &t)
{
- if (asize) {
+ Q_ASSERT_X(asize >= 0, "QVector::QVector", "Size must be greater than or equal to 0.");
+ if (asize > 0) {
d = Data::allocate(asize);
d->size = asize;
T* i = d->end();
@@ -530,7 +543,7 @@ void QVector<T>::reallocData(const int asize, const int aalloc, QArrayData::Allo
template<typename T>
Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i) const
{
- if (i < 0 || i >= d->size) {
+ if (uint(i) >= uint(d->size)) {
return T();
}
return d->begin()[i];
@@ -538,7 +551,7 @@ Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i) const
template<typename T>
Q_OUTOFLINE_TEMPLATE T QVector<T>::value(int i, const T &defaultValue) const
{
- return ((i < 0 || i >= d->size) ? defaultValue : d->begin()[i]);
+ return uint(i) >= uint(d->size) ? defaultValue : d->begin()[i];
}
template <typename T>
@@ -558,24 +571,25 @@ void QVector<T>::append(const T &t)
}
template <typename T>
-inline void QVector<T>::removeLast()
+void QVector<T>::removeLast()
{
Q_ASSERT(!isEmpty());
+ Q_ASSERT(d->alloc);
- if (d->alloc) {
- if (d->ref.isShared()) {
- reallocData(d->size - 1, int(d->alloc));
- return;
- }
- if (QTypeInfo<T>::isComplex)
- (d->data() + d->size - 1)->~T();
+ if (!d->ref.isShared()) {
--d->size;
+ if (QTypeInfo<T>::isComplex)
+ (d->data() + d->size)->~T();
+ } else {
+ reallocData(d->size - 1);
}
}
template <typename T>
typename QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, const T &t)
{
+ Q_ASSERT_X(isValidIterator(before), "QVector::insert", "The specified iterator argument 'before' is invalid");
+
int offset = std::distance(d->begin(), before);
if (n != 0) {
const T copy(t);
@@ -609,6 +623,9 @@ typename QVector<T>::iterator QVector<T>::insert(iterator before, size_type n, c
template <typename T>
typename QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend)
{
+ Q_ASSERT_X(isValidIterator(abegin), "QVector::erase", "The specified iterator argument 'abegin' is invalid");
+ Q_ASSERT_X(isValidIterator(aend), "QVector::erase", "The specified iterator argument 'aend' is invalid");
+
const int itemsToErase = aend - abegin;
if (!itemsToErase)
@@ -632,7 +649,7 @@ typename QVector<T>::iterator QVector<T>::erase(iterator abegin, iterator aend)
iterator moveEnd = d->end();
while (moveBegin != moveEnd) {
if (QTypeInfo<T>::isComplex)
- abegin->~T();
+ static_cast<T *>(abegin)->~T();
new (abegin++) T(*moveBegin++);
}
if (abegin < d->end()) {
@@ -760,17 +777,17 @@ int QVector<T>::count(const T &t) const
}
template <typename T>
-Q_OUTOFLINE_TEMPLATE QVector<T> QVector<T>::mid(int pos, int length) const
+Q_OUTOFLINE_TEMPLATE QVector<T> QVector<T>::mid(int pos, int len) const
{
- if (length < 0)
- length = size() - pos;
- if (pos == 0 && length == size())
+ if (len < 0)
+ len = size() - pos;
+ if (pos == 0 && len == size())
return *this;
- if (pos + length > size())
- length = size() - pos;
+ if (pos + len > size())
+ len = size() - pos;
QVector<T> copy;
- copy.reserve(length);
- for (int i = pos; i < pos + length; ++i)
+ copy.reserve(len);
+ for (int i = pos; i < pos + len; ++i)
copy += at(i);
return copy;
}
More information about the Development
mailing list