summaryrefslogtreecommitdiffstats
path: root/src/script
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2009-05-28 08:27:50 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2009-05-28 08:31:07 (GMT)
commitf390f9b51cf8686e9ed44f13a33c7349b9e96a09 (patch)
tree162c768769713a7215bca64daf8f2bdc75c9fbee /src/script
parent0bb0699d403b7541472a72a4057ecf0ca366a7cd (diff)
downloadQt-f390f9b51cf8686e9ed44f13a33c7349b9e96a09.zip
Qt-f390f9b51cf8686e9ed44f13a33c7349b9e96a09.tar.gz
Qt-f390f9b51cf8686e9ed44f13a33c7349b9e96a09.tar.bz2
improved string operations all over the place
used character operations whenever possible better usage of QLatin1String
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/qscriptparser.cpp4
-rw-r--r--src/script/qscriptprettypretty.cpp108
-rw-r--r--src/script/qscriptsyntaxchecker.cpp4
-rw-r--r--src/script/qscriptvalueimpl.cpp10
-rw-r--r--src/script/qscriptxmlgenerator.cpp10
11 files changed, 78 insertions, 78 deletions
diff --git a/src/script/qscriptcontext.cpp b/src/script/qscriptcontext.cpp
index 020601b..ff519c7 100644
--- a/src/script/qscriptcontext.cpp
+++ b/src/script/qscriptcontext.cpp
@@ -469,7 +469,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/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/qscriptvalueimpl.cpp b/src/script/qscriptvalueimpl.cpp
index 15d1b8a..a890839 100644
--- a/src/script/qscriptvalueimpl.cpp
+++ b/src/script/qscriptvalueimpl.cpp
@@ -395,7 +395,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 +404,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 +415,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>");