diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-25 15:24:50 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-28 13:33:39 +0200 |
commit | 150731fc68bcf823bec40729285813d902990cb7 (patch) | |
tree | 7af619f4bc8fac030bc162ce6ead2e2a7be86783 /src/qml/jsruntime/qv4numberobject.cpp | |
parent | c79cc3f30d395c94d4f14b978903d7db4ad871dc (diff) |
Remove more direct QV4::Value usage
Remove Value::fromString(String *), and make
Encode safe against encoding raw Managed * pointers.
Change-Id: Ibca4668e1cbeaf85c78169d14386281659d33ef6
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4numberobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4numberobject.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index c641d2c9e0..396dc33fd5 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -157,16 +157,16 @@ ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx) } } - String *str = Primitive::fromDouble(num).toString(ctx); - return Value::fromString(str).asReturnedValue(); + return Primitive::fromDouble(num).toString(ctx)->asReturnedValue(); } ReturnedValue NumberPrototype::method_toLocaleString(SimpleCallContext *ctx) { + Scope scope(ctx); Value v = thisNumberValue(ctx); - String *str = v.toString(ctx); - return Value::fromString(str).asReturnedValue(); + ScopedString str(scope, v.toString(ctx)); + return str.asReturnedValue(); } ReturnedValue NumberPrototype::method_valueOf(SimpleCallContext *ctx) @@ -203,6 +203,7 @@ ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx) ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx) { + Scope scope(ctx); double d = thisNumberValue(ctx).asDouble(); int fdigits = -1; @@ -210,8 +211,8 @@ ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx) if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) { int fdigits = ctx->callData->args[0].toInt32(); if (fdigits < 0 || fdigits > 20) { - String *error = ctx->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range")); - ctx->throwRangeError(Value::fromString(error)); + ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range"))); + ctx->throwRangeError(error.asValue()); } } @@ -234,8 +235,8 @@ ReturnedValue NumberPrototype::method_toPrecision(SimpleCallContext *ctx) double precision = ctx->callData->args[0].toInt32(); if (precision < 1 || precision > 21) { - String *error = ctx->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range")); - ctx->throwRangeError(Value::fromString(error)); + ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range"))); + ctx->throwRangeError(error.asValue()); } char str[100]; |