From 8afc6773067bb878020c29b3bebfe8662e3fbfdd Mon Sep 17 00:00:00 2001
From: Olivier Goffart <olivier.goffart@nokia.com>
Date: Mon, 16 Aug 2010 15:04:17 +0200
Subject: QMetaType:  add "signed char" as builtin.

According to the c++ specificaiton, 3.9.1 [basic.fundamentals]
Plain char, signed char, and unsigned char are three distinct types

In QMetaType, I decide that 'signed char' alias with 'char'
This allow qint8 to work nice (and which is already registered as
an alias to char (QMetaType::Char)

Reviewed-by: Joao
Task-number: QTBUG-12920
---
 src/corelib/kernel/qmetatype.cpp       | 1 +
 src/corelib/kernel/qmetatype.h         | 1 +
 tests/auto/qmetatype/tst_qmetatype.cpp | 5 +++++
 3 files changed, 7 insertions(+)

diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp
index fef02cf..bb77d2c 100644
--- a/src/corelib/kernel/qmetatype.cpp
+++ b/src/corelib/kernel/qmetatype.cpp
@@ -311,6 +311,7 @@ static const struct { const char * typeName; int typeNameLength; int type; } typ
     QT_ADD_STATIC_METATYPE("long long", QMetaType::LongLong),
     QT_ADD_STATIC_METATYPE("unsigned long long", QMetaType::ULongLong),
     QT_ADD_STATIC_METATYPE("qint8", QMetaType::Char),
+    QT_ADD_STATIC_METATYPE("signed char", QMetaType::Char),
     QT_ADD_STATIC_METATYPE("quint8", QMetaType::UChar),
     QT_ADD_STATIC_METATYPE("qint16", QMetaType::Short),
     QT_ADD_STATIC_METATYPE("quint16", QMetaType::UShort),
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 2108b92..52efcd0 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -355,6 +355,7 @@ Q_DECLARE_BUILTIN_METATYPE(QChar, QChar)
 Q_DECLARE_BUILTIN_METATYPE(long, Long)
 Q_DECLARE_BUILTIN_METATYPE(short, Short)
 Q_DECLARE_BUILTIN_METATYPE(char, Char)
+Q_DECLARE_BUILTIN_METATYPE(signed char, Char)
 Q_DECLARE_BUILTIN_METATYPE(ulong, ULong)
 Q_DECLARE_BUILTIN_METATYPE(ushort, UShort)
 Q_DECLARE_BUILTIN_METATYPE(uchar, UChar)
diff --git a/tests/auto/qmetatype/tst_qmetatype.cpp b/tests/auto/qmetatype/tst_qmetatype.cpp
index 8558e06..eaa19d0 100644
--- a/tests/auto/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/qmetatype/tst_qmetatype.cpp
@@ -160,6 +160,11 @@ void tst_QMetaType::qMetaTypeId()
     QCOMPARE(::qMetaTypeId<QString>(), int(QMetaType::QString));
     QCOMPARE(::qMetaTypeId<int>(), int(QMetaType::Int));
     QCOMPARE(::qMetaTypeId<TestSpace::Foo>(), QMetaType::type("TestSpace::Foo"));
+
+    QCOMPARE(::qMetaTypeId<char>(), QMetaType::type("char"));
+    QCOMPARE(::qMetaTypeId<uchar>(), QMetaType::type("unsigned char"));
+    QCOMPARE(::qMetaTypeId<signed char>(), QMetaType::type("signed char"));
+    QCOMPARE(::qMetaTypeId<qint8>(), QMetaType::type("qint8"));
 }
 
 void tst_QMetaType::properties()
-- 
cgit v0.12