aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4numberobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-30 20:57:57 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-10-02 16:07:33 +0200
commitac8afca822031f3039dce31525a6ab48c741e73b (patch)
tree1f65aa3ac5ddd8234bd83125573691294f200707 /src/qml/jsruntime/qv4numberobject.cpp
parent1e454c8aa6ad0782eee1c8c94ac2780954a08351 (diff)
Remove some more uses of QV4::Value
All remaining uses should be GC safe now. Change-Id: I05c962de6ab896f108f70caa1bf937a24e67bfe1 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4numberobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4numberobject.cpp29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp
index 06a04b4eb7..3ff4b795f5 100644
--- a/src/qml/jsruntime/qv4numberobject.cpp
+++ b/src/qml/jsruntime/qv4numberobject.cpp
@@ -100,19 +100,29 @@ void NumberPrototype::init(ExecutionEngine *engine, ObjectRef ctor)
defineDefaultProperty(QStringLiteral("toPrecision"), method_toPrecision);
}
-inline Value thisNumberValue(ExecutionContext *ctx)
+inline ReturnedValue thisNumberValue(ExecutionContext *ctx)
{
if (ctx->callData->thisObject.isNumber())
- return ctx->callData->thisObject;
+ return ctx->callData->thisObject.asReturnedValue();
NumberObject *n = ctx->callData->thisObject.asNumberObject();
if (!n)
ctx->throwTypeError();
- return n->value;
+ return n->value.asReturnedValue();
+}
+
+inline double thisNumber(ExecutionContext *ctx)
+{
+ if (ctx->callData->thisObject.isNumber())
+ return ctx->callData->thisObject.asDouble();
+ NumberObject *n = ctx->callData->thisObject.asNumberObject();
+ if (!n)
+ ctx->throwTypeError();
+ return n->value.asDouble();
}
ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx)
{
- double num = thisNumberValue(ctx).asDouble();
+ double num = thisNumber(ctx);
if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) {
int radix = ctx->callData->args[0].toInt32();
@@ -165,20 +175,20 @@ ReturnedValue NumberPrototype::method_toString(SimpleCallContext *ctx)
ReturnedValue NumberPrototype::method_toLocaleString(SimpleCallContext *ctx)
{
Scope scope(ctx);
- Value v = thisNumberValue(ctx);
+ ScopedValue v(scope, thisNumberValue(ctx));
- ScopedString str(scope, v.toString(ctx));
+ ScopedString str(scope, v->toString(ctx));
return str.asReturnedValue();
}
ReturnedValue NumberPrototype::method_valueOf(SimpleCallContext *ctx)
{
- return thisNumberValue(ctx).asReturnedValue();
+ return thisNumberValue(ctx);
}
ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx)
{
- double v = thisNumberValue(ctx).asDouble();
+ double v = thisNumber(ctx);
double fdigits = 0;
@@ -206,7 +216,7 @@ ReturnedValue NumberPrototype::method_toFixed(SimpleCallContext *ctx)
ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx)
{
Scope scope(ctx);
- double d = thisNumberValue(ctx).asDouble();
+ double d = thisNumber(ctx);
int fdigits = -1;
@@ -229,7 +239,6 @@ ReturnedValue NumberPrototype::method_toExponential(SimpleCallContext *ctx)
ReturnedValue NumberPrototype::method_toPrecision(SimpleCallContext *ctx)
{
Scope scope(ctx);
-
ScopedValue v(scope, thisNumberValue(ctx));
if (!ctx->callData->argc || ctx->callData->args[0].isUndefined())