diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-11-01 12:38:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-04 02:16:04 +0100 |
commit | a79e400150e9d550cc4ddc0c0497778d8b78fe5d (patch) | |
tree | 5a66670d4c31aaf0d356042b6fe607728e237b5b /src/qml/jsruntime | |
parent | b5991ce2a61219bda5a7fa6e33f323158d1eb78b (diff) |
Fix various compiler warnings in order to remove warn_off in the near future
Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime')
30 files changed, 175 insertions, 130 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index fb4fcb7b1a..13075f05ed 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -66,7 +66,7 @@ ArgumentsObject::ArgumentsObject(CallContext *context) memberData[CallerPropertyIndex] = pd; arrayReserve(context->callData->argc); - for (unsigned int i = 0; i < context->callData->argc; ++i) + for (int i = 0; i < context->callData->argc; ++i) arrayData[i].value = context->callData->args[i]; arrayDataLen = context->callData->argc; } else { @@ -154,7 +154,7 @@ ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData) if (!o) return v4->current->throwTypeError(); - Q_ASSERT(g->index < o->context->callData->argc); + Q_ASSERT(g->index < static_cast<unsigned>(o->context->callData->argc)); return o->context->argument(g->index); } @@ -169,7 +169,7 @@ ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData) if (!o) return v4->current->throwTypeError(); - Q_ASSERT(s->index < o->context->callData->argc); + Q_ASSERT(s->index < static_cast<unsigned>(o->context->callData->argc)); o->context->callData->args[s->index] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined(); return Encode::undefined(); } diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 22ad10560e..85423a4118 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -143,7 +143,7 @@ ReturnedValue ArrayPrototype::method_toString(SimpleCallContext *ctx) ScopedObject o(scope, ctx->callData->thisObject, ScopedObject::Convert); if (ctx->engine->hasException) return Encode::undefined(); - ScopedString s(scope, ctx->engine->newString("join")); + ScopedString s(scope, ctx->engine->newString(QStringLiteral("join"))); ScopedFunctionObject f(scope, o->get(s)); if (!!f) { ScopedCallData d(scope, 0); @@ -174,7 +174,7 @@ ReturnedValue ArrayPrototype::method_concat(SimpleCallContext *ctx) } ScopedArrayObject elt(scope); - for (uint i = 0; i < ctx->callData->argc; ++i) { + for (int i = 0; i < ctx->callData->argc; ++i) { elt = ctx->callData->args[i]; if (elt) result->arrayConcat(elt.getPointer()); @@ -299,7 +299,7 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) } if (!instance->protoHasArray() && instance->arrayDataLen <= len) { - for (uint i = 0; i < ctx->callData->argc; ++i) { + for (int i = 0; i < ctx->callData->argc; ++i) { if (!instance->sparseArray) { if (len >= instance->arrayAlloc) instance->arrayReserve(len + 1); @@ -308,13 +308,13 @@ ReturnedValue ArrayPrototype::method_push(SimpleCallContext *ctx) instance->arrayAttributes[len] = Attr_Data; instance->arrayDataLen = len + 1; } else { - uint i = instance->allocArrayValue(ctx->callData->args[i]); - instance->sparseArray->push_back(i, len); + uint j = instance->allocArrayValue(ctx->callData->args[i]); + instance->sparseArray->push_back(j, len); } ++len; } } else { - for (uint i = 0; i < ctx->callData->argc; ++i) + for (int i = 0; i < ctx->callData->argc; ++i) instance->putIndexed(len + i, ctx->callData->args[i]); len += ctx->callData->argc; } @@ -591,7 +591,7 @@ ReturnedValue ArrayPrototype::method_unshift(SimpleCallContext *ctx) else instance->deleteIndexedProperty(k + ctx->callData->argc - 1); } - for (uint i = 0; i < ctx->callData->argc; ++i) + for (int i = 0; i < ctx->callData->argc; ++i) instance->putIndexed(i, ctx->callData->args[i]); } diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index ece31822b5..a8628d6fa8 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -85,7 +85,7 @@ CallContext *ExecutionContext::newCallContext(void *stackSpace, SafeValue *local if (function->varCount) std::fill(c->locals, c->locals + function->varCount, Primitive::undefinedValue()); - if (callData->argc < function->formalParameterCount) { + if (callData->argc < static_cast<int>(function->formalParameterCount)) { #ifndef QT_NO_DEBUG Q_ASSERT(function->formalParameterCount <= QV4::Global::ReservedArgumentCount); #endif @@ -128,7 +128,7 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData c->callData = reinterpret_cast<CallData *>(c->locals + function->varCount); ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(SafeValue)); - if (callData->argc < function->formalParameterCount) + if (callData->argc < static_cast<int>(function->formalParameterCount)) std::fill(c->callData->args + c->callData->argc, c->callData->args + function->formalParameterCount, Primitive::undefinedValue()); c->callData->argc = qMax((uint)callData->argc, function->formalParameterCount); @@ -309,13 +309,13 @@ bool ExecutionContext::deleteProperty(const StringRef name) } if (strictMode) - throwSyntaxError(QString("Can't delete property %1").arg(name->toQString())); + throwSyntaxError(QStringLiteral("Can't delete property %1").arg(name->toQString())); return true; } bool CallContext::needsOwnArguments() const { - return function->needsActivation || callData->argc < function->formalParameterCount; + return function->needsActivation || callData->argc < static_cast<int>(function->formalParameterCount); } void ExecutionContext::mark() @@ -328,7 +328,7 @@ void ExecutionContext::mark() outer->mark(); callData->thisObject.mark(); - for (unsigned arg = 0; arg < callData->argc; ++arg) + for (int arg = 0; arg < callData->argc; ++arg) callData->args[arg].mark(); if (type >= Type_CallContext) { diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 688730af9b..462210adae 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1282,25 +1282,25 @@ ReturnedValue DatePrototype::method_toISOString(SimpleCallContext *ctx) if (year < 0 || year > 9999) { if (qAbs(year) >= 1000000) return ctx->engine->newString(QStringLiteral("Invalid Date"))->asReturnedValue(); - result += year < 0 ? '-' : '+'; + result += year < 0 ? QLatin1Char('-') : QLatin1Char('+'); year = qAbs(year); addZeroPrefixedInt(result, year, 6); } else { addZeroPrefixedInt(result, year, 4); } - result += '-'; + result += QLatin1Char('-'); addZeroPrefixedInt(result, (int)MonthFromTime(t) + 1, 2); - result += '-'; + result += QLatin1Char('-'); addZeroPrefixedInt(result, (int)DateFromTime(t), 2); - result += 'T'; + result += QLatin1Char('T'); addZeroPrefixedInt(result, HourFromTime(t), 2); - result += ':'; + result += QLatin1Char(':'); addZeroPrefixedInt(result, MinFromTime(t), 2); - result += ':'; + result += QLatin1Char(':'); addZeroPrefixedInt(result, SecFromTime(t), 2); - result += '.'; + result += QLatin1Char('.'); addZeroPrefixedInt(result, msFromTime(t), 3); - result += 'Z'; + result += QLatin1Char('Z'); return ctx->engine->newString(result)->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index a29aba8504..a9fc050483 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -356,6 +356,8 @@ void Debugger::maybeBreakAtInstruction(const uchar *code, bool breakPointHit) void Debugger::aboutToThrow(const QV4::ValueRef value) { + Q_UNUSED(value); + qDebug() << "*** We are about to throw..."; } @@ -470,7 +472,7 @@ void Debugger::BreakPoints::applyToFunction(Function *function, bool removeBreak while (breakPoint != breakPointsForFile->end()) { bool breakPointFound = false; const quint32 *lineNumberMappings = function->compiledFunction->lineNumberMapping(); - for (int i = 0; i < function->compiledFunction->nLineNumberMappingEntries; ++i) { + for (quint32 i = 0; i < function->compiledFunction->nLineNumberMappingEntries; ++i) { const int codeOffset = lineNumberMappings[i * 2]; const int lineNumber = lineNumberMappings[i * 2 + 1]; if (lineNumber == *breakPoint) { diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 3b5b1f3ff9..6cb269d842 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -857,7 +857,7 @@ QQmlError ExecutionEngine::catchExceptionAsQmlError(ExecutionContext *context) } QV4::Scoped<QV4::ErrorObject> errorObj(scope, exception); if (!!errorObj && errorObj->asSyntaxError()) { - QV4::ScopedString m(scope, errorObj->engine()->newString("message")); + QV4::ScopedString m(scope, errorObj->engine()->newString(QStringLiteral("message"))); QV4::ScopedValue v(scope, errorObj->get(m)); error.setDescription(v->toQStringNoThrow()); } else diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index 12ac4218bd..f149bc556e 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -82,7 +82,7 @@ ErrorObject::ErrorObject(InternalClass *ic) Scope scope(engine()); ScopedValue protectThis(scope, this); - ScopedString s(scope, ic->engine->newString("Error")); + ScopedString s(scope, ic->engine->newString(QStringLiteral("Error"))); defineDefaultProperty(QStringLiteral("name"), s); } diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp index d660457aa6..99d5de4fe5 100644 --- a/src/qml/jsruntime/qv4function.cpp +++ b/src/qml/jsruntime/qv4function.cpp @@ -58,19 +58,21 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, , codeData(0) , codeSize(_codeSize) { + Q_UNUSED(engine); + name = compilationUnit->runtimeStrings[compiledFunction->nameIndex].asString(); formals.resize(compiledFunction->nFormals); formals.fill(0); const quint32 *formalsIndices = compiledFunction->formalsTable(); - for (int i = 0; i < compiledFunction->nFormals; ++i) + for (quint32 i = 0; i < compiledFunction->nFormals; ++i) formals[i] = compilationUnit->runtimeStrings[formalsIndices[i]].asString(); locals.resize(compiledFunction->nLocals); locals.fill(0); const quint32 *localsIndices = compiledFunction->localsTable(); - for (int i = 0; i < compiledFunction->nLocals; ++i) + for (quint32 i = 0; i < compiledFunction->nLocals; ++i) locals[i] = compilationUnit->runtimeStrings[localsIndices[i]].asString(); } @@ -92,7 +94,7 @@ namespace QV4 { struct LineNumberMappingHelper { const quint32 *table; - int lowerBound(int begin, int end, qptrdiff offset) { + int lowerBound(int begin, int end, quint32 offset) { int middle; int n = int(end - begin); int half; @@ -122,7 +124,7 @@ int Function::lineNumberForProgramCounter(qptrdiff offset) const int pos = helper.lowerBound(0, count, offset); if (pos != 0 && count > 0) --pos; - if (pos == count) + if (static_cast<uint>(pos) == count) return -1; return helper.table[pos * 2 + 1]; } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 523ef9c1e7..d8029548f4 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -244,7 +244,7 @@ ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData) QString arguments; QString body; if (callData->argc > 0) { - for (uint i = 0; i < callData->argc - 1; ++i) { + for (int i = 0; i < callData->argc - 1; ++i) { if (i) arguments += QLatin1String(", "); arguments += callData->args[i].toString(ctx)->toQString(); @@ -264,13 +264,13 @@ ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData) const bool parsed = parser.parseExpression(); if (!parsed) - return f->engine()->current->throwSyntaxError(0); + return f->engine()->current->throwSyntaxError(QLatin1String("Parse error")); using namespace QQmlJS::AST; FunctionExpression *fe = QQmlJS::AST::cast<FunctionExpression *>(parser.rootNode()); ExecutionEngine *v4 = f->engine(); if (!fe) - return v4->current->throwSyntaxError(0); + return f->engine()->current->throwSyntaxError(QLatin1String("Parse error")); QQmlJS::V4IR::Module module(v4->debugger != 0); @@ -350,7 +350,7 @@ ReturnedValue FunctionPrototype::method_apply(SimpleCallContext *ctx) callData->args[i] = arr->getIndexed(i); } else { int alen = qMin(len, arr->arrayDataLen); - for (quint32 i = 0; i < alen; ++i) + for (int i = 0; i < alen; ++i) callData->args[i] = arr->arrayData[i].value; for (quint32 i = alen; i < len; ++i) callData->args[i] = Primitive::undefinedValue(); @@ -387,7 +387,7 @@ ReturnedValue FunctionPrototype::method_bind(SimpleCallContext *ctx) ScopedValue boundThis(scope, ctx->argument(0)); QVector<SafeValue> boundArgs; - for (uint i = 1; i < ctx->callData->argc; ++i) + for (int i = 1; i < ctx->callData->argc; ++i) boundArgs += ctx->callData->args[i]; return ctx->engine->newBoundFunction(ctx->engine->rootContext, target, boundThis, boundArgs)->asReturnedValue(); @@ -462,7 +462,6 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData) ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) { ScriptFunction *f = static_cast<ScriptFunction *>(that); - void *stackSpace; ExecutionContext *context = f->engine()->current; Scope scope(context); if (scope.hasException()) @@ -642,7 +641,7 @@ DEFINE_MANAGED_VTABLE(IndexedBuiltinFunction); DEFINE_MANAGED_VTABLE(BoundFunction); BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObjectRef target, const ValueRef boundThis, const QVector<SafeValue> &boundArgs) - : FunctionObject(scope, 0) + : FunctionObject(scope, QStringLiteral("__bound function__")) , target(target) , boundArgs(boundArgs) { diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index fca49308cc..3ded454f2e 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -101,16 +101,16 @@ static QString escape(const QString &input) output.append(QChar(uc)); } else { output.append('%'); - output.append(QChar(toHex(uc >> 4))); - output.append(QChar(toHex(uc))); + output.append(QLatin1Char(toHex(uc >> 4))); + output.append(QLatin1Char(toHex(uc))); } } else { output.append('%'); output.append('u'); - output.append(QChar(toHex(uc >> 12))); - output.append(QChar(toHex(uc >> 8))); - output.append(QChar(toHex(uc >> 4))); - output.append(QChar(toHex(uc))); + output.append(QLatin1Char(toHex(uc >> 12))); + output.append(QLatin1Char(toHex(uc >> 8))); + output.append(QLatin1Char(toHex(uc >> 4))); + output.append(QLatin1Char(toHex(uc))); } } return output; @@ -396,7 +396,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) const QString code = callData->args[0].stringValue()->toQString(); bool inheritContext = !ctx->strictMode; - Script script(ctx, code, QString("eval code")); + Script script(ctx, code, QStringLiteral("eval code")); script.strictMode = (directCall && parentContext->strictMode); script.inheritContext = inheritContext; script.parse(); @@ -558,7 +558,7 @@ ReturnedValue GlobalFunctions::method_parseFloat(SimpleCallContext *ctx) if (trimmed.startsWith(QLatin1String("Infinity")) || trimmed.startsWith(QLatin1String("+Infinity"))) return Encode(Q_INFINITY); - if (trimmed.startsWith("-Infinity")) + if (trimmed.startsWith(QStringLiteral("-Infinity"))) return Encode(-Q_INFINITY); QByteArray ba = trimmed.toLatin1(); bool ok; diff --git a/src/qml/jsruntime/qv4identifier.cpp b/src/qml/jsruntime/qv4identifier.cpp index 08f48c36a4..87fbd6f8e4 100644 --- a/src/qml/jsruntime/qv4identifier.cpp +++ b/src/qml/jsruntime/qv4identifier.cpp @@ -57,8 +57,8 @@ static inline int primeForNumBits(int numBits) IdentifierHashData::IdentifierHashData(int numBits) - : numBits(numBits) - , size(0) + : size(0) + , numBits(numBits) { refCount.store(1); alloc = primeForNumBits(numBits); @@ -83,7 +83,7 @@ IdentifierHashEntry *IdentifierHashBase::addEntry(const Identifier *identifier) int newAlloc = primeForNumBits(d->numBits); IdentifierHashEntry *newEntries = (IdentifierHashEntry *)malloc(newAlloc * sizeof(IdentifierHashEntry)); memset(newEntries, 0, newAlloc*sizeof(IdentifierHashEntry)); - for (uint i = 0; i < d->alloc; ++i) { + for (int i = 0; i < d->alloc; ++i) { const IdentifierHashEntry &e = d->entries[i]; if (!e.identifier) continue; diff --git a/src/qml/jsruntime/qv4identifiertable.cpp b/src/qml/jsruntime/qv4identifiertable.cpp index 04c31828cc..e300a4811e 100644 --- a/src/qml/jsruntime/qv4identifiertable.cpp +++ b/src/qml/jsruntime/qv4identifiertable.cpp @@ -91,7 +91,7 @@ void IdentifierTable::addEntry(String *str) int newAlloc = primeForNumBits(numBits); String **newEntries = (String **)malloc(newAlloc*sizeof(String *)); memset(newEntries, 0, newAlloc*sizeof(String *)); - for (uint i = 0; i < alloc; ++i) { + for (int i = 0; i < alloc; ++i) { String *e = entries[i]; if (!e) continue; diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 40f7b865d0..f156065125 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -89,11 +89,11 @@ QV4::ReturnedValue QV4Include::resultValue(QV4::ExecutionEngine *v4, Status stat QV4::ScopedObject o(scope, v4->newObject()); QV4::ScopedString s(scope); QV4::ScopedValue v(scope); - o->put((s = v4->newString("OK")), (v = QV4::Primitive::fromInt32(Ok))); - o->put((s = v4->newString("LOADING")), (v = QV4::Primitive::fromInt32(Loading))); - o->put((s = v4->newString("NETWORK_ERROR")), (v = QV4::Primitive::fromInt32(NetworkError))); - o->put((s = v4->newString("EXCEPTION")), (v = QV4::Primitive::fromInt32(Exception))); - o->put((s = v4->newString("status")), (v = QV4::Primitive::fromInt32(status))); + o->put((s = v4->newString(QStringLiteral("OK"))), (v = QV4::Primitive::fromInt32(Ok))); + o->put((s = v4->newString(QStringLiteral("LOADING"))), (v = QV4::Primitive::fromInt32(Loading))); + o->put((s = v4->newString(QStringLiteral("NETWORK_ERROR"))), (v = QV4::Primitive::fromInt32(NetworkError))); + o->put((s = v4->newString(QStringLiteral("EXCEPTION"))), (v = QV4::Primitive::fromInt32(Exception))); + o->put((s = v4->newString(QStringLiteral("status"))), (v = QV4::Primitive::fromInt32(status))); return o.asReturnedValue(); } @@ -154,19 +154,19 @@ void QV4Include::finished() QV4::Script script(v4, qmlglobal, code, m_url.toString()); QV4::ExecutionContext *ctx = v4->current; - QV4::ScopedString status(scope, v4->newString("status")); + QV4::ScopedString status(scope, v4->newString(QStringLiteral("status"))); script.parse(); if (!scope.engine->hasException) script.run(); if (scope.engine->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Exception))); - resultObj->put(QV4::ScopedString(scope, v4->newString("exception")), ex); + resultObj->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("exception"))), ex); } else { resultObj->put(status, QV4::ScopedValue(scope, QV4::Primitive::fromInt32(Ok))); } } else { - resultObj->put(QV4::ScopedString(scope, v4->newString("status")), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError))); + resultObj->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("status"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(NetworkError))); } QV4::ScopedValue cb(scope, m_callbackFunction.value()); @@ -227,7 +227,7 @@ QV4::ReturnedValue QV4Include::method_include(QV4::SimpleCallContext *ctx) if (v4->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); result = resultValue(v4, Exception); - result->asObject()->put(QV4::ScopedString(scope, v4->newString("exception")), ex); + result->asObject()->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("exception"))), ex); } else { result = resultValue(v4, Ok); } diff --git a/src/qml/jsruntime/qv4internalclass.cpp b/src/qml/jsruntime/qv4internalclass.cpp index 02783b79a0..c3dd3e0505 100644 --- a/src/qml/jsruntime/qv4internalclass.cpp +++ b/src/qml/jsruntime/qv4internalclass.cpp @@ -69,8 +69,8 @@ static inline int primeForNumBits(int numBits) } PropertyHashData::PropertyHashData(int numBits) - : numBits(numBits) - , size(0) + : size(0) + , numBits(numBits) { refCount.store(1); alloc = primeForNumBits(numBits); @@ -85,9 +85,9 @@ void PropertyHash::addEntry(const PropertyHash::Entry &entry, int classSize) if (classSize < d->size || grow) { PropertyHashData *dd = new PropertyHashData(grow ? d->numBits + 1 : d->numBits); - for (uint i = 0; i < d->alloc; ++i) { + for (int i = 0; i < d->alloc; ++i) { const Entry &e = d->entries[i]; - if (!e.identifier || e.index >= classSize) + if (!e.identifier || e.index >= static_cast<unsigned>(classSize)) continue; uint idx = e.identifier->hashValue % dd->alloc; while (dd->entries[idx].identifier) { @@ -155,7 +155,7 @@ InternalClass *InternalClass::changeMember(String *string, PropertyAttributes da return this; - Transition t = { string->identifier, (int)data.flags() }; + Transition t = { { string->identifier }, (int)data.flags() }; QHash<Transition, InternalClass *>::const_iterator tit = transitions.constFind(t); if (tit != transitions.constEnd()) return tit.value(); @@ -211,7 +211,7 @@ InternalClass *InternalClass::addMember(String *string, PropertyAttributes data, if (propertyTable.lookup(string->identifier) < size) return changeMember(string, data, index); - Transition t = { string->identifier, (int)data.flags() }; + Transition t = { { string->identifier }, (int)data.flags() }; QHash<Transition, InternalClass *>::const_iterator tit = transitions.constFind(t); if (index) @@ -239,9 +239,9 @@ InternalClass *InternalClass::addMember(String *string, PropertyAttributes data, void InternalClass::removeMember(Object *object, Identifier *id) { int propIdx = propertyTable.lookup(id); - assert(propIdx < size); + assert(propIdx < static_cast<int>(size)); - Transition t = { id, -1 }; + Transition t = { { id } , -1 }; QHash<Transition, InternalClass *>::const_iterator tit = transitions.constFind(t); if (tit != transitions.constEnd()) { diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 5a8acf803c..8d693f7705 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -614,8 +614,8 @@ bool JsonParser::parseString(QString *string) } qDebug() << "scanEscape" << hex << ch; if (QChar::requiresSurrogates(ch)) { - *string += QChar::highSurrogate(ch); - *string += QChar::lowSurrogate(ch); + *string += QChar(QChar::highSurrogate(ch)); + *string += QChar(QChar::lowSurrogate(ch)); } else { *string += QChar(ch); } @@ -661,42 +661,42 @@ struct Stringify static QString quote(const QString &str) { - QString product = "\""; + QString product = QStringLiteral("\""); for (int i = 0; i < str.length(); ++i) { QChar c = str.at(i); switch (c.unicode()) { case '"': - product += "\\\""; + product += QStringLiteral("\\\""); break; case '\\': - product += "\\\\"; + product += QStringLiteral("\\\\"); break; case '\b': - product += "\\b"; + product += QStringLiteral("\\b"); break; case '\f': - product += "\\f"; + product += QStringLiteral("\\f"); break; case '\n': - product += "\\n"; + product += QStringLiteral("\\n"); break; case '\r': - product += "\\r"; + product += QStringLiteral("\\r"); break; case '\t': - product += "\\t"; + product += QStringLiteral("\\t"); break; default: if (c.unicode() <= 0x1f) { - product += "\\u00"; - product += c.unicode() > 0xf ? '1' : '0'; - product += "0123456789abcdef"[c.unicode() & 0xf]; + product += QStringLiteral("\\u00"); + product += c.unicode() > 0xf ? QLatin1Char('1') : QLatin1Char('0'); + product += QLatin1Char("0123456789abcdef"[c.unicode() & 0xf]); } else { product += c; } } } - product += '"'; + product += QLatin1Char('"'); return product; } @@ -768,9 +768,9 @@ QString Stringify::makeMember(const QString &key, ValueRef v) { QString strP = Str(key, v); if (!strP.isEmpty()) { - QString member = quote(key) + ':'; + QString member = quote(key) + QLatin1Char(':'); if (!gap.isEmpty()) - member += ' '; + member += QLatin1Char(' '); member += strP; return member; } @@ -823,10 +823,10 @@ QString Stringify::JO(ObjectRef o) if (partial.isEmpty()) { result = QStringLiteral("{}"); } else if (gap.isEmpty()) { - result = "{" + partial.join(",") + "}"; + result = QStringLiteral("{") + partial.join(QLatin1Char(',')) + QStringLiteral("}"); } else { - QString separator = ",\n" + indent; - result = "{\n" + indent + partial.join(separator) + "\n" + stepback + "}"; + QString separator = QStringLiteral(",\n") + indent; + result = QStringLiteral("{\n") + indent + partial.join(separator) + QStringLiteral("\n") + stepback + QStringLiteral("}"); } indent = stepback; @@ -868,10 +868,10 @@ QString Stringify::JA(ArrayObjectRef a) if (partial.isEmpty()) { result = QStringLiteral("[]"); } else if (gap.isEmpty()) { - result = "[" + partial.join(",") + "]"; + result = QStringLiteral("[") + partial.join(QLatin1Char(',')) + QStringLiteral("]"); } else { - QString separator = ",\n" + indent; - result = "[\n" + indent + partial.join(separator) + "\n" + stepback + "]"; + QString separator = QStringLiteral(",\n") + indent; + result = QStringLiteral("[\n") + indent + partial.join(separator) + QStringLiteral("\n") + stepback + QStringLiteral("]"); } indent = stepback; @@ -905,7 +905,7 @@ ReturnedValue JsonObject::method_parse(SimpleCallContext *ctx) ScopedValue result(scope, parser.parse(&error)); if (error.error != QJsonParseError::NoError) { DEBUG << "parse error" << error.errorString(); - return ctx->throwSyntaxError("JSON.parse: Parse error"); + return ctx->throwSyntaxError(QStringLiteral("JSON.parse: Parse error")); } return result.asReturnedValue(); diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 4123e95d87..f67b24c040 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -343,7 +343,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx) } Scope scope(ctx); Scoped<String> n(scope, l->name); - ctx->throwReferenceError(n); + return ctx->throwReferenceError(n); } ReturnedValue Lookup::globalGetter0(Lookup *l, ExecutionContext *ctx) diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index 4d40b72bab..6455a08037 100644 --- a/src/qml/jsruntime/qv4managed.cpp +++ b/src/qml/jsruntime/qv4managed.cpp @@ -168,6 +168,12 @@ QString Managed::className() const case Type_ForeachIteratorObject: s = "__ForeachIterator"; break; + case Type_RegExp: + s = "RegExp"; + break; + case Type_QmlSequence: + s = "QmlSequence"; + break; } return QString::fromLatin1(s); } diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index c5cd77fc14..d5a1a88dc5 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -210,7 +210,7 @@ ReturnedValue MathObject::method_log(SimpleCallContext *context) ReturnedValue MathObject::method_max(SimpleCallContext *context) { double mx = -qInf(); - for (unsigned i = 0; i < context->callData->argc; ++i) { + for (int i = 0; i < context->callData->argc; ++i) { double x = context->callData->args[i].toNumber(); if (x > mx || std::isnan(x)) mx = x; @@ -221,7 +221,7 @@ ReturnedValue MathObject::method_max(SimpleCallContext *context) ReturnedValue MathObject::method_min(SimpleCallContext *context) { double mx = qInf(); - for (unsigned i = 0; i < context->callData->argc; ++i) { + for (int i = 0; i < context->callData->argc; ++i) { double x = context->callData->args[i].toNumber(); if ((x == 0 && mx == x && copySign(1.0, x) == -1.0) || (x < mx) || std::isnan(x)) { diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 3277ea96ab..25443a59c2 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -244,10 +244,10 @@ void Object::markObjects(Managed *that) Object *o = static_cast<Object *>(that); if (!o->hasAccessorProperty) { - for (int i = 0; i < o->internalClass->size; ++i) + for (uint i = 0; i < o->internalClass->size; ++i) o->memberData[i].value.mark(); } else { - for (int i = 0; i < o->internalClass->size; ++i) { + for (uint i = 0; i < o->internalClass->size; ++i) { const Property &pd = o->memberData[i]; if (o->internalClass->propertyData[i].isAccessor()) { if (pd.getter()) @@ -1128,6 +1128,8 @@ void Object::copyArrayData(Object *other) ReturnedValue Object::arrayIndexOf(const ValueRef v, uint fromIndex, uint endIndex, ExecutionContext *ctx, Object *o) { + Q_UNUSED(ctx); + Scope scope(engine()); ScopedValue value(scope); @@ -1150,7 +1152,7 @@ ReturnedValue Object::arrayIndexOf(const ValueRef v, uint fromIndex, uint endInd return Encode(n->key()); } } else { - if ((int) endIndex > arrayDataLen) + if (endIndex > arrayDataLen) endIndex = arrayDataLen; Property *pd = arrayData; Property *end = pd + endIndex; @@ -1191,14 +1193,14 @@ void Object::arrayConcat(const ArrayObject *other) } } } else { - int oldSize = arrayLength(); + uint oldSize = arrayLength(); arrayReserve(oldSize + other->arrayDataLen); if (oldSize > arrayDataLen) { - for (int i = arrayDataLen; i < oldSize; ++i) + for (uint i = arrayDataLen; i < oldSize; ++i) arrayData[i].value = Primitive::emptyValue(); } if (other->arrayAttributes) { - for (int i = 0; i < other->arrayDataLen; ++i) { + for (uint i = 0; i < other->arrayDataLen; ++i) { bool exists; arrayData[oldSize + i].value = const_cast<ArrayObject *>(other)->getIndexed(i, &exists); arrayDataLen = oldSize + i + 1; @@ -1223,7 +1225,7 @@ void Object::arraySort(ExecutionContext *context, ObjectRef thisObject, const Va return; if (sparseArray) { - context->throwUnimplemented("Object::sort unimplemented for sparse arrays"); + context->throwUnimplemented(QStringLiteral("Object::sort unimplemented for sparse arrays")); return; } @@ -1267,7 +1269,7 @@ void Object::arraySort(ExecutionContext *context, ObjectRef thisObject, const Va // and aborts otherwise. We do not want JavaScript to easily crash // the entire application and therefore choose qSort, which doesn't // have this property. - qSort(begin, begin + len, lessThan); + std::sort(begin, begin + len, lessThan); } @@ -1276,7 +1278,7 @@ void Object::initSparse() if (!sparseArray) { flags &= ~SimpleArray; sparseArray = new SparseArray; - for (int i = 0; i < arrayDataLen; ++i) { + for (uint i = 0; i < arrayDataLen; ++i) { if (!((arrayAttributes && arrayAttributes[i].isGeneric()) || arrayData[i].value.isEmpty())) { SparseArrayNode *n = sparseArray->insert(i); n->value = i + arrayOffset; @@ -1296,7 +1298,7 @@ void Object::initSparse() } arrayData[o - 1].value = Primitive::fromInt32(arrayDataLen + off); } - for (int i = arrayDataLen + off; i < arrayAlloc; ++i) { + for (uint i = arrayDataLen + off; i < arrayAlloc; ++i) { arrayData[i].value = Primitive::fromInt32(i + 1); } } @@ -1443,6 +1445,8 @@ ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list) void ArrayObject::init(ExecutionEngine *engine) { + Q_UNUSED(engine); + type = Type_ArrayObject; memberData[LengthPropertyIndex].value = Primitive::fromInt32(0); } diff --git a/src/qml/jsruntime/qv4objectiterator.cpp b/src/qml/jsruntime/qv4objectiterator.cpp index 46698b0ad3..cec0873527 100644 --- a/src/qml/jsruntime/qv4objectiterator.cpp +++ b/src/qml/jsruntime/qv4objectiterator.cpp @@ -83,7 +83,7 @@ Property *ObjectIterator::next(StringRef name, uint *index, PropertyAttributes * if (!current) break; - while (p = current->advanceIterator(this, name, index, attrs)) { + while ((p = current->advanceIterator(this, name, index, attrs))) { // check the property is not already defined earlier in the proto chain if (current != object) { Property *pp; diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 091eddcf99..5284f927d4 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -257,6 +257,8 @@ void QObjectWrapper::initializeBindings(ExecutionEngine *engine) QQmlPropertyData *QObjectWrapper::findProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, QQmlPropertyData *local) const { + Q_UNUSED(revisionMode); + QQmlData *ddata = QQmlData::get(m_object, false); if (!ddata) return 0; @@ -277,7 +279,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD return QV4::Encode::undefined(); } - QV4:Scope scope(ctx); + QV4::Scope scope(ctx); QV4::ScopedString name(scope, n); if (name->equals(m_destroy) || name->equals(scope.engine->id_toString)) { @@ -704,7 +706,7 @@ Property *QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, String const QMetaObject *mo = that->m_object->metaObject(); const int propertyCount = mo->propertyCount(); - if (it->arrayIndex < propertyCount) { + if (it->arrayIndex < static_cast<uint>(propertyCount)) { name = that->engine()->newString(QString::fromUtf8(mo->property(it->arrayIndex).name())); ++it->arrayIndex; if (attributes) @@ -713,7 +715,7 @@ Property *QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, String return &it->tmpDynamicProperty; } const int methodCount = mo->methodCount(); - if (it->arrayIndex < propertyCount + methodCount) { + if (it->arrayIndex < static_cast<uint>(propertyCount + methodCount)) { name = that->engine()->newString(QString::fromUtf8(mo->method(it->arrayIndex - propertyCount).name())); ++it->arrayIndex; if (attributes) @@ -1226,7 +1228,7 @@ static int MatchScore(const QV4::ValueRef actual, int conversionType) } else if (QV4::Object *obj = actual->asObject()) { QV8Engine *engine = obj->engine()->v8Engine; - if (QV4::VariantObject *v = obj->as<QV4::VariantObject>()) { + if (obj->as<QV4::VariantObject>()) { if (conversionType == qMetaTypeId<QVariant>()) return 0; if (engine->toVariant(actual, -1).userType() == conversionType) diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index 103605ee7a..8c184754ca 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -134,6 +134,7 @@ void RegExp::destroy(Managed *that) void RegExp::markObjects(Managed *that) { + Q_UNUSED(that); } ReturnedValue RegExp::get(Managed *, const StringRef, bool *) @@ -143,24 +144,40 @@ ReturnedValue RegExp::get(Managed *, const StringRef, bool *) ReturnedValue RegExp::getIndexed(Managed *m, uint index, bool *hasProperty) { + Q_UNUSED(m); + Q_UNUSED(index); + Q_UNUSED(hasProperty); + return Encode::undefined(); } void RegExp::put(Managed *m, const StringRef name, const ValueRef value) { + Q_UNUSED(m); + Q_UNUSED(name); + Q_UNUSED(value); } void RegExp::putIndexed(Managed *m, uint index, const ValueRef value) { + Q_UNUSED(m); + Q_UNUSED(index); + Q_UNUSED(value); } PropertyAttributes RegExp::query(const Managed *m, StringRef name) { + Q_UNUSED(m); + Q_UNUSED(name); + return Attr_Invalid; } PropertyAttributes RegExp::queryIndexed(const Managed *m, uint index) { + Q_UNUSED(m); + Q_UNUSED(index); + return Attr_Invalid; } @@ -171,10 +188,19 @@ bool RegExp::deleteProperty(Managed *, const StringRef) bool RegExp::deleteIndexedProperty(Managed *m, uint index) { + Q_UNUSED(m); + Q_UNUSED(index); + return false; } Property *RegExp::advanceIterator(Managed *m, ObjectIterator *it, StringRef name, uint *index, PropertyAttributes *attributes) { + Q_UNUSED(m); + Q_UNUSED(it); + Q_UNUSED(name); + Q_UNUSED(index); + Q_UNUSED(attributes); + return 0; } diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 4f0f07377f..02467c3045 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -185,6 +185,7 @@ void RegExpObject::markObjects(Managed *that) Property *RegExpObject::lastIndexProperty(ExecutionContext *ctx) { + Q_UNUSED(ctx); Q_ASSERT(0 == internalClass->find(ctx->engine->newIdentifier(QStringLiteral("lastIndex")))); return &memberData[0]; } @@ -200,14 +201,14 @@ QRegExp RegExpObject::toQRegExp() const QString RegExpObject::toString() const { - QString result = QChar('/') + source(); - result += QChar('/'); + QString result = QLatin1Char('/') + source(); + result += QLatin1Char('/'); if (global) - result += QChar('g'); + result += QLatin1Char('g'); if (value->ignoreCase()) - result += QChar('i'); + result += QLatin1Char('i'); if (value->multiLine()) - result += QChar('m'); + result += QLatin1Char('m'); return result; } @@ -270,21 +271,21 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) if (scope.hasException()) return Encode::undefined(); for (int i = 0; i < str.length(); ++i) { - if (str.at(i) == QChar('g') && !global) { + if (str.at(i) == QLatin1Char('g') && !global) { global = true; - } else if (str.at(i) == QChar('i') && !ignoreCase) { + } else if (str.at(i) == QLatin1Char('i') && !ignoreCase) { ignoreCase = true; - } else if (str.at(i) == QChar('m') && !multiLine) { + } else if (str.at(i) == QLatin1Char('m') && !multiLine) { multiLine = true; } else { - return ctx->throwSyntaxError(0); + return ctx->throwSyntaxError(QStringLiteral("Invalid flags supplied to RegExp constructor")); } } } Scoped<RegExp> regexp(scope, RegExp::create(ctx->engine, pattern, ignoreCase, multiLine)); if (!regexp->isValid()) - return ctx->throwSyntaxError(0); + return ctx->throwSyntaxError(QStringLiteral("Invalid regular expression")); return Encode(ctx->engine->newRegExpObject(regexp, global)); } diff --git a/src/qml/jsruntime/qv4regexpobject_p.h b/src/qml/jsruntime/qv4regexpobject_p.h index 0ef95a36e2..eb932a49ee 100644 --- a/src/qml/jsruntime/qv4regexpobject_p.h +++ b/src/qml/jsruntime/qv4regexpobject_p.h @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE namespace QV4 { -struct RegExp; +class RegExp; struct RegExpObject: Object { Q_MANAGED diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 923c51f1f9..4e40779c16 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -823,7 +823,7 @@ ReturnedValue __qmljs_call_property(ExecutionContext *context, const StringRef n Scoped<FunctionObject> o(scope, baseObject->get(name)); if (!o) { - QString error = QString("Property '%1' of object %2 is not a function").arg(name->toQString(), callData->thisObject.toQStringNoThrow()); + QString error = QStringLiteral("Property '%1' of object %2 is not a function").arg(name->toQString(), callData->thisObject.toQStringNoThrow()); return context->throwTypeError(error); } @@ -1065,7 +1065,7 @@ ReturnedValue __qmljs_builtin_define_object_literal(QV4::ExecutionContext *ctx, QV4::InternalClass *klass = ctx->compilationUnit->runtimeClasses[classId]; Scoped<Object> o(scope, ctx->engine->newObject(klass)); - for (int i = 0; i < klass->size; ++i) { + for (uint i = 0; i < klass->size; ++i) { if (klass->propertyData[i].isData()) o->memberData[i].value = *args++; else { diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index f1903cf323..49fee99135 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -223,7 +223,7 @@ void Script::parse() if (!vmFunction) { // ### FIX file/line number - Scoped<Object> error(valueScope, v4->newSyntaxErrorObject("Syntax error")); + Scoped<Object> error(valueScope, v4->newSyntaxErrorObject(QStringLiteral("Syntax error"))); v4->current->throwError(error); } } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 5a42c7fe35..8d2a399b70 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -178,6 +178,7 @@ public: flags &= ~SimpleArray; QV4::Scope scope(engine); QV4::ScopedObject protectThis(scope, this); + Q_UNUSED(protectThis); init(); } @@ -192,6 +193,7 @@ public: flags &= ~SimpleArray; QV4::Scope scope(engine); QV4::ScopedObject protectThis(scope, this); + Q_UNUSED(protectThis); loadReference(); init(); } @@ -297,7 +299,7 @@ public: loadReference(); } - if (it->arrayIndex < m_container.count()) { + if (it->arrayIndex < static_cast<uint>(m_container.count())) { if (attrs) *attrs = QV4::Attr_Data; *index = it->arrayIndex; @@ -569,6 +571,7 @@ QV4::ReturnedValue SequencePrototype::method_sort(QV4::SimpleCallContext *ctx) FOREACH_QML_SEQUENCE_TYPE(CALL_SORT) #undef CALL_SORT + {} return o.asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index 88e7630055..06a2603280 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -371,7 +371,7 @@ ReturnedValue Serialize::deserialize(const char *&data, QV8Engine *engine) QQmlListModelWorkerAgent::VariantRef ref(agent); QVariant var = qVariantFromValue(ref); QV4::ScopedValue v(scope, engine->fromVariant((var))); - QV4::ScopedString s(scope, v4->newString("__qml:hidden:ref")); + QV4::ScopedString s(scope, v4->newString(QStringLiteral("__qml:hidden:ref"))); rv->asObject()->defineReadonlyProperty(s, v); agent->release(); diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp index 01d76c48bd..016bc3878e 100644 --- a/src/qml/jsruntime/qv4string.cpp +++ b/src/qml/jsruntime/qv4string.cpp @@ -167,7 +167,7 @@ ReturnedValue String::getIndexed(Managed *m, uint index, bool *hasProperty) Scope scope(engine); ScopedString that(scope, static_cast<String *>(m)); - if (index < (uint)that->_text->size) { + if (index < static_cast<uint>(that->_text->size)) { if (hasProperty) *hasProperty = true; return Encode(engine->newString(that->toQString().mid(index, 1))); @@ -216,7 +216,7 @@ PropertyAttributes String::query(const Managed *m, StringRef name) PropertyAttributes String::queryIndexed(const Managed *m, uint index) { const String *that = static_cast<const String *>(m); - return (index < (uint)that->_text->size) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid; + return (index < static_cast<uint>(that->_text->size)) ? Attr_NotConfigurable|Attr_NotWritable : Attr_Invalid; } bool String::deleteProperty(Managed *, const StringRef) diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index f36c7d84a4..0fc5dee5be 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -86,7 +86,7 @@ StringObject::StringObject(InternalClass *ic) Scope scope(engine()); ScopedObject protectThis(scope, this); - value = ic->engine->newString("")->asReturnedValue(); + value = ic->engine->newString(QStringLiteral(""))->asReturnedValue(); tmpProperty.value = Primitive::undefinedValue(); @@ -129,7 +129,7 @@ bool StringObject::deleteIndexedProperty(Managed *m, uint index) return false; } - if (index < o->value.stringValue()->toQString().length()) { + if (index < static_cast<uint>(o->value.stringValue()->toQString().length())) { if (v4->current->strictMode) v4->current->throwTypeError(); return false; @@ -444,7 +444,7 @@ static void appendReplacementString(QString *result, const QString &input, const uint substStart = JSC::Yarr::offsetNoMatch; uint substEnd = JSC::Yarr::offsetNoMatch; if (ch == '$') { - *result += ch; + *result += QLatin1Char(ch); continue; } else if (ch == '&') { substStart = matchOffsets[0]; @@ -457,7 +457,7 @@ static void appendReplacementString(QString *result, const QString &input, const substEnd = input.length(); } else if (ch >= '1' && ch <= '9') { uint capture = ch - '0'; - if (capture > 0 && capture < captureCount) { + if (capture > 0 && capture < static_cast<uint>(captureCount)) { substStart = matchOffsets[capture * 2]; substEnd = matchOffsets[capture * 2 + 1]; } @@ -557,7 +557,7 @@ ReturnedValue StringPrototype::method_replace(SimpleCallContext *ctx) callData->args[k] = entry; } uint matchStart = matchOffsets[i * numCaptures * 2]; - Q_ASSERT(matchStart >= lastEnd); + Q_ASSERT(matchStart >= static_cast<uint>(lastEnd)); uint matchEnd = matchOffsets[i * numCaptures * 2 + 1]; callData->args[numCaptures] = Primitive::fromUInt32(matchStart); callData->args[numCaptures + 1] = ctx->engine->newString(string); |