aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4numberobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2014-11-12 09:21:41 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2014-11-15 11:25:09 +0100
commit7cc5fb2b53616ed2ca2b525262457fb44e2b5355 (patch)
treefdbaab790c7f41aa3ad30b617edbe47b45ee4101 /src/qml/jsruntime/qv4numberobject.cpp
parentb04b5b57e92af2e036ffb65e2dd7cbba4b6c3c6a (diff)
Cleanup: remove Value::toString/Object overloads taking a context
Change-Id: I4cb63c3cc4eb9bb81f10f9826f80e581b4e1990c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4numberobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 99028e7c7d..404ad8f61e 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -117,8 +117,9 @@ inline double thisNumber(ExecutionContext *ctx)
ReturnedValue NumberPrototype::method_toString(CallContext *ctx)
{
+ Scope scope(ctx);
double num = thisNumber(ctx);
- if (ctx->d()->engine->hasException)
+ if (scope.engine->hasException)
return Encode::undefined();
if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) {
@@ -128,9 +129,9 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx)
.arg(radix));
if (std::isnan(num)) {
- return ctx->d()->engine->newString(QStringLiteral("NaN"))->asReturnedValue();
+ return scope.engine->newString(QStringLiteral("NaN"))->asReturnedValue();
} else if (qIsInf(num)) {
- return ctx->d()->engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue();
+ return scope.engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue();
}
if (radix != 10) {
@@ -160,19 +161,19 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx)
}
if (negative)
str.prepend(QLatin1Char('-'));
- return ctx->d()->engine->newString(str)->asReturnedValue();
+ return scope.engine->newString(str)->asReturnedValue();
}
}
- return Primitive::fromDouble(num).toString(ctx)->asReturnedValue();
+ return Primitive::fromDouble(num).toString(scope.engine)->asReturnedValue();
}
ReturnedValue NumberPrototype::method_toLocaleString(CallContext *ctx)
{
Scope scope(ctx);
ScopedValue v(scope, thisNumberValue(ctx));
- ScopedString str(scope, v->toString(ctx));
- if (ctx->d()->engine->hasException)
+ ScopedString str(scope, v->toString(scope.engine));
+ if (scope.engine->hasException)
return Encode::undefined();
return str.asReturnedValue();
}
@@ -184,8 +185,9 @@ ReturnedValue NumberPrototype::method_valueOf(CallContext *ctx)
ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx)
{
+ Scope scope(ctx);
double v = thisNumber(ctx);
- if (ctx->d()->engine->hasException)
+ if (scope.engine->hasException)
return Encode::undefined();
double fdigits = 0;
@@ -208,14 +210,14 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx)
str = QString::number(v, 'f', int (fdigits));
else
return RuntimeHelpers::stringFromNumber(ctx->engine(), v)->asReturnedValue();
- return ctx->d()->engine->newString(str)->asReturnedValue();
+ return scope.engine->newString(str)->asReturnedValue();
}
ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx)
{
Scope scope(ctx);
double d = thisNumber(ctx);
- if (ctx->d()->engine->hasException)
+ if (scope.engine->hasException)
return Encode::undefined();
int fdigits = -1;
@@ -223,7 +225,7 @@ ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx)
if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) {
fdigits = ctx->d()->callData->args[0].toInt32();
if (fdigits < 0 || fdigits > 20) {
- ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
+ ScopedString error(scope, scope.engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")));
return ctx->engine()->throwRangeError(error);
}
}
@@ -233,14 +235,14 @@ ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx)
double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToExponential(d, fdigits, &builder);
QString result = QString::fromLatin1(builder.Finalize());
- return ctx->d()->engine->newString(result)->asReturnedValue();
+ return scope.engine->newString(result)->asReturnedValue();
}
ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
{
Scope scope(ctx);
ScopedValue v(scope, thisNumberValue(ctx));
- if (ctx->d()->engine->hasException)
+ if (scope.engine->hasException)
return Encode::undefined();
if (!ctx->d()->callData->argc || ctx->d()->callData->args[0].isUndefined())
@@ -248,7 +250,7 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
double precision = ctx->d()->callData->args[0].toInt32();
if (precision < 1 || precision > 21) {
- ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
+ ScopedString error(scope, scope.engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")));
return ctx->engine()->throwRangeError(error);
}
@@ -257,5 +259,5 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx)
double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToPrecision(v->asDouble(), precision, &builder);
QString result = QString::fromLatin1(builder.Finalize());
- return ctx->d()->engine->newString(result)->asReturnedValue();
+ return scope.engine->newString(result)->asReturnedValue();
}