Commit 4e06ffee authored by hjk's avatar hjk
Browse files

debugger: python and c++ dumpers for QDate and QTime

parent 8672cbec
......@@ -1227,6 +1227,64 @@ static void qDumpQChar(QDumper &d)
d.disarm();
}
static void qDumpQDate(QDumper &d)
{
#ifdef QT_NO_DATESTRING
qDumpUnknown(d);
#else
const QDate &date = *reinterpret_cast<const QDate *>(d.data);
if (date.isNull()) {
d.putItem("value", "(null)");
} else {
d.putItem("value", date.toString());
d.putItem("valueencoded", "2");
}
d.putItem("type", NS"QDate");
d.putItem("numchild", "1");
if (d.dumpChildren) {
d.beginChildren();
d.putHash("isNull", date.isNull());
d.putHash("toString", date.toString());
# if QT_VERSION >= 0x040500
d.putHash("toString_(ISO)", date.toString(Qt::ISODate));
d.putHash("toString_(SystemLocale)", date.toString(Qt::SystemLocaleDate));
d.putHash("toString_(Locale)", date.toString(Qt::LocaleDate));
# endif
d.endChildren();
}
d.disarm();
#endif // ifdef QT_NO_DATESTRING
}
static void qDumpQTime(QDumper &d)
{
#ifdef QT_NO_DATESTRING
qDumpUnknown(d);
#else
const QTime &date = *reinterpret_cast<const QTime *>(d.data);
if (date.isNull()) {
d.putItem("value", "(null)");
} else {
d.putItem("value", date.toString());
d.putItem("valueencoded", "2");
}
d.putItem("type", NS"QTime");
d.putItem("numchild", "1");
if (d.dumpChildren) {
d.beginChildren();
d.putHash("isNull", date.isNull());
d.putHash("toString", date.toString());
# if QT_VERSION >= 0x040500
d.putHash("toString_(ISO)", date.toString(Qt::ISODate));
d.putHash("toString_(SystemLocale)", date.toString(Qt::SystemLocaleDate));
d.putHash("toString_(Locale)", date.toString(Qt::LocaleDate));
# endif
d.endChildren();
}
d.disarm();
#endif // ifdef QT_NO_DATESTRING
}
static void qDumpQDateTime(QDumper &d)
{
#ifdef QT_NO_DATESTRING
......@@ -1240,10 +1298,9 @@ static void qDumpQDateTime(QDumper &d)
d.putItem("valueencoded", "2");
}
d.putItem("type", NS"QDateTime");
d.putItem("numchild", "3");
d.putItem("numchild", "1");
if (d.dumpChildren) {
d.beginChildren();
d.putHash("isNull", date.isNull());
d.putHash("toTime_t", (long)date.toTime_t());
d.putHash("toString", date.toString());
# if QT_VERSION >= 0x040500
......@@ -3492,7 +3549,9 @@ static void handleProtocolVersion2and3(QDumper &d)
qDumpQChar(d);
break;
case 'D':
if (isEqual(type, "QDateTime"))
if (isEqual(type, "QDate"))
qDumpQDate(d);
else if (isEqual(type, "QDateTime"))
qDumpQDateTime(d);
else if (isEqual(type, "QDir"))
qDumpQDir(d);
......@@ -3638,6 +3697,8 @@ static void handleProtocolVersion2and3(QDumper &d)
if (isEqual(type, "QTextCodec"))
qDumpQTextCodec(d);
# endif
if (isEqual(type, "QTime"))
qDumpQTime(d);
break;
case 'V':
# ifndef QT_BOOTSTRAPPED
......
......@@ -158,13 +158,16 @@ def qdump__QModelIndex(d, item):
#gdb.execute("call free($mi)")
def qdump__QDateTime(d, item):
def qdump__QDate(d, item):
if int(item.value["jd"]) == 0:
d.putValue("(null)")
d.putNumChild(0)
return
d.putStringValue(call(item.value, "toString('%sQt::TextDate')" % d.ns))
d.putNumChild(3)
d.putNumChild(1)
if d.isExpanded(item):
# FIXME: This improperly uses complex return values.
with Children(d, 8):
d.putCallItem("isNull", item, "isNull()")
d.putCallItem("toTime_t", item, "toTime_t()")
d.putCallItem("toString",
item, "toString('%sQt::TextDate')" % d.ns)
......@@ -180,6 +183,55 @@ def qdump__QDateTime(d, item):
item, "toTimeSpec('%sQt::LocalTime')" % d.ns)
def qdump__QTime(d, item):
if int(item.value["mds"]) == -1:
d.putValue("(null)")
d.putNumChild(0)
return
d.putStringValue(call(item.value, "toString('%sQt::TextDate')" % d.ns))
d.putNumChild(1)
if d.isExpanded(item):
# FIXME: This improperly uses complex return values.
with Children(d, 8):
d.putCallItem("toString",
item, "toString('%sQt::TextDate')" % d.ns)
d.putCallItem("(ISO)",
item, "toString('%sQt::ISODate')" % d.ns)
d.putCallItem("(SystemLocale)",
item, "toString('%sQt::SystemLocaleDate')" % d.ns)
d.putCallItem("(Locale)",
item, "toString('%sQt::LocaleDate')" % d.ns)
d.putCallItem("toUTC",
item, "toTimeSpec('%sQt::UTC')" % d.ns)
#d.putCallItem("toLocalTime",
# item, "toTimeSpec('%sQt::LocalTime')" % d.ns)
def qdump__QDateTime(d, item):
if int(item.value["d"]["d"].dereference()["time"]["mds"]) == -1:
d.putValue("(null)")
d.putNumChild(0)
return
d.putStringValue(call(item.value, "toString('%sQt::TextDate')" % d.ns))
d.putNumChild(1)
if d.isExpanded(item):
# FIXME: This improperly uses complex return values.
with Children(d, 8):
d.putCallItem("toTime_t", item, "toTime_t()")
d.putCallItem("toString",
item, "toString('%sQt::TextDate')" % d.ns)
d.putCallItem("(ISO)",
item, "toString('%sQt::ISODate')" % d.ns)
d.putCallItem("(SystemLocale)",
item, "toString('%sQt::SystemLocaleDate')" % d.ns)
d.putCallItem("(Locale)",
item, "toString('%sQt::LocaleDate')" % d.ns)
d.putCallItem("toUTC",
item, "toTimeSpec('%sQt::UTC')" % d.ns)
#d.putCallItem("toLocalTime",
# item, "toTimeSpec('%sQt::LocalTime')" % d.ns)
def qdump__QDir(d, item):
d.putStringValue(call(item.value, "path()"))
d.putNumChild(2)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment