summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
Diffstat (limited to 'src/script')
-rw-r--r--src/script/qscriptcontext.cpp2
-rw-r--r--src/script/qscriptcontext_p.cpp6
-rw-r--r--src/script/qscriptecmaerror.cpp6
-rw-r--r--src/script/qscriptecmafunction.cpp2
-rw-r--r--src/script/qscriptecmaglobal.cpp2
-rw-r--r--src/script/qscriptecmaobject.cpp2
-rw-r--r--src/script/qscriptengine.cpp2
-rw-r--r--src/script/qscriptengine_p.cpp5
-rw-r--r--src/script/qscriptenginefwd_p.h1
-rw-r--r--src/script/qscriptextqobject.cpp56
-rw-r--r--src/script/qscriptparser.cpp4
-rw-r--r--src/script/qscriptprettypretty.cpp108
-rw-r--r--src/script/qscriptsyntaxchecker.cpp4
-rw-r--r--src/script/qscriptsyntaxchecker_p.h2
-rw-r--r--src/script/qscriptvalue.cpp1
-rw-r--r--src/script/qscriptvalueimpl.cpp12
-rw-r--r--src/script/qscriptxmlgenerator.cpp10
17 files changed, 133 insertions, 92 deletions
diff --git a/src/script/qscriptcontext.cpp b/src/script/qscriptcontext.cpp
index 0b72342..4db32d0 100644
--- a/src/script/qscriptcontext.cpp
+++ b/src/script/qscriptcontext.cpp
@@ -467,7 +467,7 @@ QString QScriptContext::toString() const
QScriptValue arg = argument(i);
result.append(safeValueToString(arg));
}
- result.append(QLatin1String(")"));
+ result.append(QLatin1Char(')'));
QString fileName = info.fileName();
int lineNumber = info.lineNumber();
diff --git a/src/script/qscriptcontext_p.cpp b/src/script/qscriptcontext_p.cpp
index 199c9d4..f19ba9c 100644
--- a/src/script/qscriptcontext_p.cpp
+++ b/src/script/qscriptcontext_p.cpp
@@ -841,7 +841,7 @@ Ltop:
flags = iPtr->operand[1].m_int_value;
#ifndef QT_NO_REGEXP
if (flags != 0) {
- literal += QLatin1String("/");
+ literal += QLatin1Char('/');
literal += QString::number(flags);
}
#endif
@@ -2396,10 +2396,10 @@ QStringList QScriptContextPrivate::backtrace() const
s += QLatin1String("<global>");
}
}
- s += QLatin1String("(");
+ s += QLatin1Char('(');
for (int i = 0; i < ctx->argc; ++i) {
if (i > 0)
- s += QLatin1String(",");
+ s += QLatin1Char(',');
QScriptValueImpl arg = ctx->args[i];
if (arg.isObject())
s += QLatin1String("[object Object]"); // don't do a function call
diff --git a/src/script/qscriptecmaerror.cpp b/src/script/qscriptecmaerror.cpp
index fc39bf9..0dde68c 100644
--- a/src/script/qscriptecmaerror.cpp
+++ b/src/script/qscriptecmaerror.cpp
@@ -318,18 +318,18 @@ QStringList Error::backtrace(const QScriptValueImpl &error)
} else {
s += functionName;
}
- s += QLatin1String("(");
+ s += QLatin1Char('(');
QScriptValueImpl arguments = frame.property(QLatin1String("arguments"));
if (arguments.isObject()) {
int argCount = arguments.property(QLatin1String("length")).toInt32();
for (int j = 0; j < argCount; ++j) {
if (j > 0)
- s += QLatin1String(",");
+ s += QLatin1Char(',');
s += arguments.property(j).toString();
}
}
s += QLatin1String(")@") + o.property(QLatin1String("fileName")).toString()
- + QLatin1String(":") + o.property(QLatin1String("lineNumber")).toString();
+ + QLatin1Char(':') + o.property(QLatin1String("lineNumber")).toString();
result.append(s);
}
return result;
diff --git a/src/script/qscriptecmafunction.cpp b/src/script/qscriptecmafunction.cpp
index ec45ae4..a1e5b58 100644
--- a/src/script/qscriptecmafunction.cpp
+++ b/src/script/qscriptecmafunction.cpp
@@ -197,7 +197,7 @@ QString Function::buildFunction(QScriptContextPrivate *context)
// the formals
for (int i = 0; i < argc - 1; ++i) {
if (i != 0)
- code += QLatin1String(",");
+ code += QLatin1Char(',');
code += context->argument(i).toString();
}
diff --git a/src/script/qscriptecmaglobal.cpp b/src/script/qscriptecmaglobal.cpp
index da7ab9e..b5cf675 100644
--- a/src/script/qscriptecmaglobal.cpp
+++ b/src/script/qscriptecmaglobal.cpp
@@ -296,7 +296,7 @@ public:
QString result;
for (int i = 0; i < context->argumentCount(); ++i) {
if (i != 0)
- result.append(QLatin1String(" "));
+ result.append(QLatin1Char(' '));
QString s = context->argument(i).toString();
if (context->state() == QScriptContext::ExceptionState)
diff --git a/src/script/qscriptecmaobject.cpp b/src/script/qscriptecmaobject.cpp
index 694f479..c4a1b08 100644
--- a/src/script/qscriptecmaobject.cpp
+++ b/src/script/qscriptecmaobject.cpp
@@ -113,7 +113,7 @@ QScriptValueImpl Object::method_toString(QScriptContextPrivate *context, QScript
QString s = QLatin1String("[object ");
QScriptValueImpl self = context->thisObject();
s += self.classInfo()->name();
- s += QLatin1String("]");
+ s += QLatin1Char(']');
return (QScriptValueImpl(eng, s));
}
diff --git a/src/script/qscriptengine.cpp b/src/script/qscriptengine.cpp
index 2a36104..8441842 100644
--- a/src/script/qscriptengine.cpp
+++ b/src/script/qscriptengine.cpp
@@ -583,7 +583,7 @@ QScriptValue QScriptEngine::newQObject(const QScriptValue &scriptObject,
QScriptValuePrivate *p = QScriptValuePrivate::get(scriptObject);
if (!p || !p->value.isObject())
return newQObject(qtObject, ownership, options);
- if (p->value.isVariant()) {
+ if (p->value.isQObject()) {
QScript::ExtQObject::Instance *data;
data = d->qobjectConstructor->get(p->value);
Q_ASSERT(data != 0);
diff --git a/src/script/qscriptengine_p.cpp b/src/script/qscriptengine_p.cpp
index 27b8101..ad26550 100644
--- a/src/script/qscriptengine_p.cpp
+++ b/src/script/qscriptengine_p.cpp
@@ -1662,6 +1662,11 @@ bool QScriptEnginePrivate::convert(const QScriptValueImpl &value,
return false;
}
+QScriptEngine::DemarshalFunction QScriptEnginePrivate::demarshalFunction(int type) const
+{
+ return m_customTypes.value(type).demarshal;
+}
+
QScriptValuePrivate *QScriptEnginePrivate::registerValue(const QScriptValueImpl &value)
{
if (value.isString()) {
diff --git a/src/script/qscriptenginefwd_p.h b/src/script/qscriptenginefwd_p.h
index 2ea66c5..855317c 100644
--- a/src/script/qscriptenginefwd_p.h
+++ b/src/script/qscriptenginefwd_p.h
@@ -350,6 +350,7 @@ public:
QScriptValueImpl create(int type, const void *ptr);
static bool convert(const QScriptValueImpl &value, int type, void *ptr,
QScriptEnginePrivate *eng);
+ QScriptEngine::DemarshalFunction demarshalFunction(int type) const;
QScriptValueImpl arrayFromStringList(const QStringList &lst);
static QStringList stringListFromArray(const QScriptValueImpl &arr);
diff --git a/src/script/qscriptextqobject.cpp b/src/script/qscriptextqobject.cpp
index d18c3da..47c04d4 100644
--- a/src/script/qscriptextqobject.cpp
+++ b/src/script/qscriptextqobject.cpp
@@ -425,7 +425,7 @@ static void callQtMethod(QScriptContextPrivate *context, QMetaMethod::MethodType
matchDistance += 10;
}
}
- } else if (actual.isNumber()) {
+ } else if (actual.isNumber() || actual.isString()) {
// see if it's an enum value
QMetaEnum m;
if (argType.isMetaEnum()) {
@@ -436,11 +436,21 @@ static void callQtMethod(QScriptContextPrivate *context, QMetaMethod::MethodType
m = meta->enumerator(mi);
}
if (m.isValid()) {
- int ival = actual.toInt32();
- if (m.valueToKey(ival) != 0) {
- qVariantSetValue(v, ival);
- converted = true;
- matchDistance += 10;
+ if (actual.isNumber()) {
+ int ival = actual.toInt32();
+ if (m.valueToKey(ival) != 0) {
+ qVariantSetValue(v, ival);
+ converted = true;
+ matchDistance += 10;
+ }
+ } else {
+ QString sval = actual.toString();
+ int ival = m.keyToValue(sval.toLatin1());
+ if (ival != -1) {
+ qVariantSetValue(v, ival);
+ converted = true;
+ matchDistance += 10;
+ }
}
}
}
@@ -1657,12 +1667,27 @@ void QScript::QObjectConnectionManager::execute(int slotIndex, void **argv)
activation_data->m_members[i].object(nameId, i,
QScriptValue::Undeletable
| QScriptValue::SkipInEnumeration);
+ QScriptValueImpl actual;
if (i < argc) {
- int argType = QMetaType::type(parameterTypes.at(i));
- activation_data->m_values[i] = eng->create(argType, argv[i + 1]);
+ void *arg = argv[i + 1];
+ QByteArray typeName = parameterTypes.at(i);
+ int argType = QMetaType::type(typeName);
+ if (!argType) {
+ if (typeName == "QVariant") {
+ actual = eng->valueFromVariant(*reinterpret_cast<QVariant*>(arg));
+ } else {
+ qWarning("QScriptEngine: Unable to handle unregistered datatype '%s' "
+ "when invoking handler of signal %s::%s",
+ typeName.constData(), meta->className(), method.signature());
+ actual = eng->undefinedValue();
+ }
+ } else {
+ actual = eng->create(argType, arg);
+ }
} else {
- activation_data->m_values[i] = eng->undefinedValue();
+ actual = eng->undefinedValue();
}
+ activation_data->m_values[i] = actual;
}
QScriptValueImpl senderObject;
@@ -1809,7 +1834,16 @@ void QScript::QtPropertyFunction::execute(QScriptContextPrivate *context)
}
} else {
// set
- QVariant v = variantFromValue(eng_p, prop.userType(), context->argument(0));
+ QScriptValueImpl arg = context->argument(0);
+ QVariant v;
+ if (prop.isEnumType() && arg.isString()
+ && !eng_p->demarshalFunction(prop.userType())) {
+ // give QMetaProperty::write() a chance to convert from
+ // string to enum value
+ v = arg.toString();
+ } else {
+ v = variantFromValue(eng_p, prop.userType(), arg);
+ }
QScriptable *scriptable = scriptableFromQObject(qobject);
QScriptEngine *oldEngine = 0;
@@ -1864,8 +1898,6 @@ void QScript::QtFunction::execute(QScriptContextPrivate *context)
return;
}
- QScriptValueImpl result = eng_p->undefinedValue();
-
const QMetaObject *meta = qobj->metaObject();
QObject *thisQObject = context->thisObject().toQObject();
diff --git a/src/script/qscriptparser.cpp b/src/script/qscriptparser.cpp
index 0b04df1..7408ec5 100644
--- a/src/script/qscriptparser.cpp
+++ b/src/script/qscriptparser.cpp
@@ -1148,9 +1148,9 @@ case 266: {
error_message += QLatin1String (", ");
first = false;
- error_message += QLatin1String("`");
+ error_message += QLatin1Char('`');
error_message += QLatin1String (spell [expected_tokens [s]]);
- error_message += QLatin1String("'");
+ error_message += QLatin1Char('\'');
}
}
diff --git a/src/script/qscriptprettypretty.cpp b/src/script/qscriptprettypretty.cpp
index 6ee1e55..b221b0a 100644
--- a/src/script/qscriptprettypretty.cpp
+++ b/src/script/qscriptprettypretty.cpp
@@ -73,13 +73,13 @@ PrettyPretty::~PrettyPretty()
void PrettyPretty::acceptAsBlock(AST::Node *node)
{
- out << "{";
+ out << '{';
pushIndentLevel();
newlineAndIndent();
accept(node);
popIndentLevel();
newlineAndIndent();
- out << "}";
+ out << '}';
}
int PrettyPretty::operatorPrecedenceLevel(int op)
@@ -230,8 +230,8 @@ void PrettyPretty::endVisit(AST::FalseLiteral *node)
bool PrettyPretty::visit(AST::StringLiteral *node)
{
QString lit = QScriptEnginePrivate::toString(node->value);
- lit.replace(QLatin1String("\\"), QLatin1String("\\\\"));
- out << "\"" << lit << "\"";
+ lit.replace(QLatin1Char('\\'), QLatin1String("\\\\"));
+ out << '\"' << lit << '\"';
return false;
}
@@ -253,7 +253,7 @@ void PrettyPretty::endVisit(AST::NumericLiteral *node)
bool PrettyPretty::visit(AST::RegExpLiteral *node)
{
- out << "/" << QScriptEnginePrivate::toString(node->pattern) << "/";
+ out << '/' << QScriptEnginePrivate::toString(node->pattern) << '/';
if (node->flags)
out << QScript::Ecma::RegExp::flagsToString(node->flags);
@@ -267,10 +267,10 @@ void PrettyPretty::endVisit(AST::RegExpLiteral *node)
bool PrettyPretty::visit(AST::ArrayLiteral *node)
{
- out << "[";
+ out << '[';
accept(node->elements);
accept(node->elision);
- out << "]";
+ out << ']';
return false;
}
@@ -281,7 +281,7 @@ void PrettyPretty::endVisit(AST::ArrayLiteral *node)
bool PrettyPretty::visit(AST::ObjectLiteral *node)
{
- out << "{";
+ out << '{';
if (node->properties) {
pushIndentLevel();
AST::PropertyNameAndValueList *prop;
@@ -289,12 +289,12 @@ bool PrettyPretty::visit(AST::ObjectLiteral *node)
newlineAndIndent();
accept(prop);
if (prop->next)
- out << ",";
+ out << ',';
}
popIndentLevel();
newlineAndIndent();
}
- out << "}";
+ out << '}';
return false;
}
@@ -384,9 +384,9 @@ void PrettyPretty::endVisit(AST::NumericLiteralPropertyName *node)
bool PrettyPretty::visit(AST::ArrayMemberExpression *node)
{
accept(node->base);
- out << "[";
+ out << '[';
accept(node->expression);
- out << "]";
+ out << ']';
return false;
}
@@ -398,7 +398,7 @@ void PrettyPretty::endVisit(AST::ArrayMemberExpression *node)
bool PrettyPretty::visit(AST::FieldMemberExpression *node)
{
accept(node->base);
- out << "." << QScriptEnginePrivate::toString(node->name);
+ out << '.' << QScriptEnginePrivate::toString(node->name);
return false;
}
@@ -411,9 +411,9 @@ bool PrettyPretty::visit(AST::NewMemberExpression *node)
{
out << "new ";
accept(node->base);
- out << "(";
+ out << '(';
accept(node->arguments);
- out << ")";
+ out << ')';
return false;
}
@@ -437,9 +437,9 @@ void PrettyPretty::endVisit(AST::NewExpression *node)
bool PrettyPretty::visit(AST::CallExpression *node)
{
accept(node->base);
- out << "(";
+ out << '(';
accept(node->arguments);
- out << ")";
+ out << ')';
return false;
}
@@ -549,13 +549,13 @@ void PrettyPretty::endVisit(AST::PreDecrementExpression *node)
bool PrettyPretty::visit(AST::UnaryPlusExpression *node)
{
- out << "+";
+ out << '+';
bool needParens = (node->expression->binaryExpressionCast() != 0);
if (needParens)
- out << "(";
+ out << '(';
accept(node->expression);
if (needParens)
- out << ")";
+ out << ')';
return false;
}
@@ -566,13 +566,13 @@ void PrettyPretty::endVisit(AST::UnaryPlusExpression *node)
bool PrettyPretty::visit(AST::UnaryMinusExpression *node)
{
- out << "-";
+ out << '-';
bool needParens = (node->expression->binaryExpressionCast() != 0);
if (needParens)
- out << "(";
+ out << '(';
accept(node->expression);
if (needParens)
- out << ")";
+ out << ')';
return false;
}
@@ -583,13 +583,13 @@ void PrettyPretty::endVisit(AST::UnaryMinusExpression *node)
bool PrettyPretty::visit(AST::TildeExpression *node)
{
- out << "~";
+ out << '~';
bool needParens = (node->expression->binaryExpressionCast() != 0);
if (needParens)
- out << "(";
+ out << '(';
accept(node->expression);
if (needParens)
- out << ")";
+ out << ')';
return false;
}
@@ -600,13 +600,13 @@ void PrettyPretty::endVisit(AST::TildeExpression *node)
bool PrettyPretty::visit(AST::NotExpression *node)
{
- out << "!";
+ out << '!';
bool needParens = (node->expression->binaryExpressionCast() != 0);
if (needParens)
- out << "(";
+ out << '(';
accept(node->expression);
if (needParens)
- out << ")";
+ out << ')';
return false;
}
@@ -620,10 +620,10 @@ bool PrettyPretty::visit(AST::BinaryExpression *node)
bool needParens = node->left->binaryExpressionCast()
&& (compareOperatorPrecedence(node->left->binaryExpressionCast()->op, node->op) < 0);
if (needParens)
- out << "(";
+ out << '(';
accept(node->left);
if (needParens)
- out << ")";
+ out << ')';
QString s;
switch (node->op) {
case QSOperator::Add:
@@ -699,14 +699,14 @@ bool PrettyPretty::visit(AST::BinaryExpression *node)
default:
Q_ASSERT (0);
}
- out << " " << s << " ";
+ out << ' ' << s << ' ';
needParens = node->right->binaryExpressionCast()
&& (compareOperatorPrecedence(node->right->binaryExpressionCast()->op, node->op) <= 0);
if (needParens)
- out << "(";
+ out << '(';
accept(node->right);
if (needParens)
- out << ")";
+ out << ')';
return false;
}
@@ -798,7 +798,7 @@ bool PrettyPretty::visit(AST::VariableStatement *node)
void PrettyPretty::endVisit(AST::VariableStatement *node)
{
Q_UNUSED(node);
- out << ";";
+ out << ';';
}
bool PrettyPretty::visit(AST::VariableDeclaration *node)
@@ -819,7 +819,7 @@ void PrettyPretty::endVisit(AST::VariableDeclaration *node)
bool PrettyPretty::visit(AST::EmptyStatement *node)
{
Q_UNUSED(node);
- out << ";";
+ out << ';';
return true;
}
@@ -831,7 +831,7 @@ void PrettyPretty::endVisit(AST::EmptyStatement *node)
bool PrettyPretty::visit(AST::ExpressionStatement *node)
{
accept(node->expression);
- out << ";";
+ out << ';';
return false;
}
@@ -959,9 +959,9 @@ bool PrettyPretty::visit(AST::ContinueStatement *node)
{
out << "continue";
if (node->label) {
- out << " " << QScriptEnginePrivate::toString(node->label);
+ out << ' ' << QScriptEnginePrivate::toString(node->label);
}
- out << ";";
+ out << ';';
return false;
}
@@ -974,9 +974,9 @@ bool PrettyPretty::visit(AST::BreakStatement *node)
{
out << "break";
if (node->label) {
- out << " " << QScriptEnginePrivate::toString(node->label);
+ out << ' ' << QScriptEnginePrivate::toString(node->label);
}
- out << ";";
+ out << ';';
return false;
}
@@ -989,10 +989,10 @@ bool PrettyPretty::visit(AST::ReturnStatement *node)
{
out << "return";
if (node->expression) {
- out << " ";
+ out << ' ';
accept(node->expression);
}
- out << ";";
+ out << ';';
return false;
}
@@ -1067,7 +1067,7 @@ bool PrettyPretty::visit(AST::CaseClause *node)
{
out << "case ";
accept(node->expression);
- out << ":";
+ out << ':';
if (node->statements) {
newlineAndIndent();
accept(node->statements);
@@ -1109,7 +1109,7 @@ bool PrettyPretty::visit(AST::ThrowStatement *node)
Q_UNUSED(node);
out << "throw ";
accept(node->expression);
- out << ";";
+ out << ';';
return false;
}
@@ -1166,10 +1166,10 @@ bool PrettyPretty::visit(AST::FunctionDeclaration *node)
out << "function";
if (node->name)
- out << " " << QScriptEnginePrivate::toString(node->name);
+ out << ' ' << QScriptEnginePrivate::toString(node->name);
// the arguments
- out << "(";
+ out << '(';
for (AST::FormalParameterList *it = node->formals; it; it = it->next) {
if (it->name)
out << QScriptEnginePrivate::toString(it->name);
@@ -1177,7 +1177,7 @@ bool PrettyPretty::visit(AST::FunctionDeclaration *node)
if (it->next)
out << ", ";
}
- out << ")";
+ out << ')';
// the function body
out << " {";
@@ -1190,7 +1190,7 @@ bool PrettyPretty::visit(AST::FunctionDeclaration *node)
newlineAndIndent();
}
- out << "}";
+ out << '}';
return false;
}
@@ -1205,10 +1205,10 @@ bool PrettyPretty::visit(AST::FunctionExpression *node)
out << "function";
if (node->name)
- out << " " << QScriptEnginePrivate::toString(node->name);
+ out << ' ' << QScriptEnginePrivate::toString(node->name);
// the arguments
- out << "(";
+ out << '(';
for (AST::FormalParameterList *it = node->formals; it; it = it->next) {
if (it->name)
out << QScriptEnginePrivate::toString(it->name);
@@ -1216,7 +1216,7 @@ bool PrettyPretty::visit(AST::FunctionExpression *node)
if (it->next)
out << ", ";
}
- out << ")";
+ out << ')';
// the function body
out << " {";
@@ -1229,7 +1229,7 @@ bool PrettyPretty::visit(AST::FunctionExpression *node)
newlineAndIndent();
}
- out << "}";
+ out << '}';
return false;
}
@@ -1320,7 +1320,7 @@ bool PrettyPretty::visit(AST::DebuggerStatement *node)
void PrettyPretty::endVisit(AST::DebuggerStatement *node)
{
Q_UNUSED(node);
- out << ";";
+ out << ';';
}
bool PrettyPretty::preVisit(AST::Node *node)
diff --git a/src/script/qscriptsyntaxchecker.cpp b/src/script/qscriptsyntaxchecker.cpp
index 9653bc1..74ca00f 100644
--- a/src/script/qscriptsyntaxchecker.cpp
+++ b/src/script/qscriptsyntaxchecker.cpp
@@ -186,9 +186,9 @@ SyntaxChecker::Result SyntaxChecker::checkSyntax(const QString &code)
error_message += QLatin1String (", ");
first = false;
- error_message += QLatin1String("`");
+ error_message += QLatin1Char('`');
error_message += QLatin1String (spell [expected_tokens [s]]);
- error_message += QLatin1String("'");
+ error_message += QLatin1Char('\'');
}
}
diff --git a/src/script/qscriptsyntaxchecker_p.h b/src/script/qscriptsyntaxchecker_p.h
index 0c02d24..18f0611 100644
--- a/src/script/qscriptsyntaxchecker_p.h
+++ b/src/script/qscriptsyntaxchecker_p.h
@@ -71,7 +71,7 @@ public:
enum State {
Error,
Intermediate,
- Valid,
+ Valid
};
struct Result {
diff --git a/src/script/qscriptvalue.cpp b/src/script/qscriptvalue.cpp
index 4282248..0f0b6f7 100644
--- a/src/script/qscriptvalue.cpp
+++ b/src/script/qscriptvalue.cpp
@@ -904,6 +904,7 @@ qsreal QScriptValue::toInteger() const
\row \o QObject Object \o A QVariant containing a pointer to the QObject.
\row \o Date Object \o A QVariant containing the date value (toDateTime()).
\row \o RegExp Object \o A QVariant containing the regular expression value (toRegExp()).
+ \row \o Array Object \o The array is converted to a QVariantList.
\row \o Object \o If the value is primitive, then the result is converted to a QVariant according to the above rules; otherwise, an invalid QVariant is returned.
\endtable
diff --git a/src/script/qscriptvalueimpl.cpp b/src/script/qscriptvalueimpl.cpp
index 15d1b8a..7c7b711 100644
--- a/src/script/qscriptvalueimpl.cpp
+++ b/src/script/qscriptvalueimpl.cpp
@@ -339,6 +339,8 @@ QVariant QScriptValueImpl::toVariant() const
if (isQObject())
return qVariantFromValue(toQObject());
#endif
+ if (isArray())
+ return QScriptEnginePrivate::variantListFromArray(*this);
QScriptValueImpl v = engine()->toPrimitive(*this);
if (!v.isObject())
@@ -395,7 +397,7 @@ QDebug &operator<<(QDebug &d, const QScriptValueImpl &object)
QScriptObject *od = object.objectValue();
for (int i=0; i<od->memberCount(); ++i) {
if (i != 0)
- d << ",";
+ d << ',';
QScript::Member m;
od->member(i, &m);
@@ -404,7 +406,7 @@ QDebug &operator<<(QDebug &d, const QScriptValueImpl &object)
d << object.engine()->toString(m.nameId());
QScriptValueImpl o;
od->get(m, &o);
- d.nospace() << QLatin1String(":")
+ d.nospace() << QLatin1Char(':')
<< (o.classInfo()
? o.classInfo()->name()
: QLatin1String("?"));
@@ -415,14 +417,14 @@ QDebug &operator<<(QDebug &d, const QScriptValueImpl &object)
QScriptValueImpl scope = object.scope();
while (scope.isValid()) {
Q_ASSERT(scope.isObject());
- d.nospace() << " " << scope.objectValue();
+ d.nospace() << ' ' << scope.objectValue();
scope = scope.scope();
}
- d.nospace() << "}";
+ d.nospace() << '}';
break;
}
- d << ")";
+ d << ')';
return d;
}
diff --git a/src/script/qscriptxmlgenerator.cpp b/src/script/qscriptxmlgenerator.cpp
index 131882b..163b60c 100644
--- a/src/script/qscriptxmlgenerator.cpp
+++ b/src/script/qscriptxmlgenerator.cpp
@@ -121,10 +121,10 @@ QTextStream &XmlGenerator::startTag(const QString &name, AST::Node *locationNode
{
pushIndentLevel();
newlineAndIndent();
- out << QLatin1String("<") << name;
+ out << QLatin1Char('<') << name;
if (locationNode)
- out << QLatin1String(" line=\"") << locationNode->startLine << QLatin1String("\"");
- out << QLatin1String(">");
+ out << QLatin1String(" line=\"") << locationNode->startLine << QLatin1Char('\"');
+ out << QLatin1Char('>');
return out;
}
@@ -132,7 +132,7 @@ QTextStream &XmlGenerator::endTag(const QString &name)
{
newlineAndIndent();
popIndentLevel();
- out << QLatin1String("</") << escape(name) << QLatin1String(">");
+ out << QLatin1String("</") << escape(name) << QLatin1Char('>');
return out;
}
@@ -233,7 +233,7 @@ void XmlGenerator::endVisit(AST::NumericLiteral *)
bool XmlGenerator::visit(AST::RegExpLiteral *node)
{
startTag(QLatin1String("regexp"));
- out << QLatin1String("/") << escape(QScriptEnginePrivate::toString(node->pattern)) << QLatin1String("/");
+ out << QLatin1Char('/') << escape(QScriptEnginePrivate::toString(node->pattern)) << QLatin1Char('/');
if (node->flags)
out << QScript::Ecma::RegExp::flagsToString(node->flags);
out << QLatin1String("</regexp>");