Commit 2f68d722 authored by hjk's avatar hjk
Browse files

debugger: improve QScriptValue dumper

parent 7fe7909c
......@@ -1915,9 +1915,9 @@ def qdump__QVariant(d, item):
d.putValue(" ", None, -99)
d.putType("%sQVariant (%s)" % (d.ns, type))
d.putNumChild(1)
tdata = data.cast(lookupType(type).pointer()).dereference()
if d.isExpanded(item):
with Children(d):
tdata = data.cast(lookupType(type).pointer()).dereference()
#warn("TDATA: %s" % tdata)
d.putSubItem(Item(tdata, item.iname, "data", "data"))
return tdata.type
......@@ -2366,6 +2366,7 @@ def jstagAsString(tag):
return "Unknown"
def qdump__QTJSC__JSValue(d, item):
d.putValue(" ")
d.putNumChild(1)
......@@ -2379,17 +2380,85 @@ def qdump__QTJSC__JSValue(d, item):
d.putValue(jstagAsString(long(tag)))
d.putType(" ")
d.putNumChild(0)
d.putIntItem("payload", long(payload))
d.putFields(Item(item.value["u"], item.iname))
if tag == -2:
cellType = lookupType("QTJSC::JSCell").pointer()
d.putSubItem(Item(payload.cast(cellType), item.iname, "cell", "cell"))
#with SubItem(d):
# d.putName("cell")
# d.putValue(payload.cast(cellType))
# d.putType("QTJSC::JSCell*")
# d.putNumChild(1)
d.putIntItem("payload", long(payload))
d.putFields(Item(data, item.iname))
try:
# FIXME: This might not always be a variant.
delegateType = lookupType(d.ns + "QScript::QVariantDelegate").pointer()
delegate = scriptObject["d"]["delegate"].cast(delegateType)
#d.putSubItem(Item(delegate, item.iname, "delegate", "delegate"))
variant = delegate["m_value"]
d.putSubItem(Item(variant, item.iname, "variant", "variant"))
except:
pass
def qdump__QScriptValue(d, item):
# structure:
# engine QScriptEnginePrivate
# jscValue QTJSC::JSValue
# next QScriptValuePrivate *
# numberValue 5.5987310416280426e-270 myns::qsreal
# prev QScriptValuePrivate *
# ref QBasicAtomicInt
# stringValue QString
# type QScriptValuePrivate::Type: { JavaScriptCore, Number, String }
#d.putValue(" ")
dd = item.value["d_ptr"]["d"]
if isNull(dd):
d.putValue("(invalid)")
d.putNumChild(0)
return
if long(dd["type"]) == 1: # Number
d.putValue(dd["numberValue"])
d.putType("%sQScriptValue (Number)" % d.ns)
d.putNumChild(0)
return
if long(dd["type"]) == 2: # String
d.putStringValue(dd["stringValue"])
d.putType("%sQScriptValue (String)" % d.ns)
return
d.putType("%sQScriptValue (JSCoreValue)" % d.ns)
x = dd["jscValue"]["u"]
tag = x["asBits"]["tag"]
payload = x["asBits"]["payload"]
try:
# This might already fail for "native" payloads.
scriptObjectType = lookupType(d.ns + "QScriptObject").pointer()
scriptObject = payload.cast(scriptObjectType)
# FIXME: This might not always be a variant.
delegateType = lookupType(d.ns + "QScript::QVariantDelegate").pointer()
delegate = scriptObject["d"]["delegate"].cast(delegateType)
#d.putSubItem(Item(delegate, item.iname, "delegate", "delegate"))
variant = delegate["m_value"]
#d.putSubItem(Item(variant, item.iname, "variant", "variant"))
t = qdump__QVariant(d, Item(variant, "variant"))
# Override the "QVariant (foo)" output
d.putType("%sQScriptValue (%s)" % (d.ns, t), d.currentTypePriority + 1)
if t != "JSCoreValue":
return
except:
pass
# This is a "native" JSCore type for e.g. QDateTime.
d.putValue("<native>")
d.putNumChild(1)
if d.isExpanded(item):
with Children(d):
d.putSubItem(Item(dd["jscValue"], item.iname, "jscValue", "jscValue"))
#######################################################################
......
......@@ -2060,6 +2060,27 @@ struct Ty
};
void testStuff()
{
using namespace std;
typedef map<string, list<string> > map_t;
map_t m;
m["one"].push_back("a");
m["one"].push_back("b");
m["one"].push_back("c");
m["two"].push_back("1");
m["two"].push_back("2");
m["two"].push_back("3");
map_t::const_iterator i = m.begin();
vector<int> vec;
vec.push_back(1);
vec.push_back(2);
pair<vector<int>, vector<int> > a(pair<vector<int>,vector<int> >(vec, vec));
i++;
}
void testStuff4()
{
Ty x;
x.doit();
......@@ -2205,9 +2226,21 @@ void testQScriptValue(int argc, char *argv[])
QCoreApplication app(argc, argv);
QScriptEngine engine;
QDateTime date = QDateTime::currentDateTime();
QVariant var;
QScriptValue s = engine.newDate(date);
s = engine.newVariant(var);
QScriptValue s;
s = QScriptValue(33);
int x = s.toInt32();
s = QScriptValue(QString("34"));
QString x1 = s.toString();
s = engine.newVariant(QVariant(43));
QVariant v = s.toVariant();
s = engine.newVariant(QVariant(43.0));
s = engine.newVariant(QVariant(QString("sss")));
s = engine.newDate(date);
x = s.toInt32();
date = s.toDateTime();
s.setProperty("a", QScriptValue());
QScriptValue d = s.data();
}
......
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