aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4arrayobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-14 11:25:02 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-18 13:14:13 +0200
commitf79df5da0769836bc866b470cdac43d6363dc7db (patch)
tree28deb1584b6c43dca92b39328bcf43099a92fcd6 /src/qml/jsruntime/qv4arrayobject.cpp
parente4e90923c93adfafb23c81be7359e8df2a500b4f (diff)
Convert more methods to return a Returned<>
Change-Id: If294c9c4f574824c308b63a11da1337226180105 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4arrayobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4arrayobject.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp
index 5508372265..1f09b97d5c 100644
--- a/src/qml/jsruntime/qv4arrayobject.cpp
+++ b/src/qml/jsruntime/qv4arrayobject.cpp
@@ -57,7 +57,8 @@ ArrayCtor::ArrayCtor(ExecutionContext *scope)
ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData)
{
ExecutionEngine *v4 = m->engine();
- ArrayObject *a = v4->newArrayObject();
+ Scope scope(v4);
+ Scoped<ArrayObject> a(scope, v4->newArrayObject());
uint len;
if (callData->argc == 1 && callData->args[0].isNumber()) {
bool ok;
@@ -77,7 +78,7 @@ ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData)
}
a->setArrayLengthUnchecked(len);
- return Value::fromObject(a).asReturnedValue();
+ return a.asReturnedValue();
}
ReturnedValue ArrayCtor::call(Managed *that, CallData *callData)
@@ -156,7 +157,8 @@ ReturnedValue ArrayPrototype::method_toLocaleString(SimpleCallContext *ctx)
ReturnedValue ArrayPrototype::method_concat(SimpleCallContext *ctx)
{
- ArrayObject *result = ctx->engine->newArrayObject();
+ Scope scope(ctx);
+ Scoped<ArrayObject> result(scope, ctx->engine->newArrayObject());
if (ArrayObject *instance = ctx->thisObject.asArrayObject()) {
result->copyArrayData(instance);
@@ -178,10 +180,10 @@ ReturnedValue ArrayPrototype::method_concat(SimpleCallContext *ctx)
result->arrayConcat(elt);
else
- result->arraySet(getLength(ctx, result), arg);
+ result->arraySet(getLength(ctx, result.getPointer()), arg);
}
- return Value::fromObject(result).asReturnedValue();
+ return result.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_join(SimpleCallContext *ctx)
@@ -404,7 +406,7 @@ ReturnedValue ArrayPrototype::method_slice(SimpleCallContext *ctx)
Scope scope(ctx);
Object *o = ctx->thisObject.toObject(ctx);
- ArrayObject *result = ctx->engine->newArrayObject();
+ Scoped<ArrayObject> result(scope, ctx->engine->newArrayObject());
uint len = ArrayPrototype::getLength(ctx, o);
double s = ctx->argument(0).toInteger();
uint start;
@@ -435,7 +437,7 @@ ReturnedValue ArrayPrototype::method_slice(SimpleCallContext *ctx)
}
++n;
}
- return Value::fromObject(result).asReturnedValue();
+ return result.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_sort(SimpleCallContext *ctx)
@@ -455,7 +457,7 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx)
Object *instance = ctx->thisObject.toObject(ctx);
uint len = getLength(ctx, instance);
- ArrayObject *newArray = ctx->engine->newArrayObject();
+ Scoped<ArrayObject> newArray(scope, ctx->engine->newArrayObject());
double rs = ctx->argument(0).toInteger();
uint start;
@@ -508,7 +510,7 @@ ReturnedValue ArrayPrototype::method_splice(SimpleCallContext *ctx)
ctx->strictMode = true;
instance->put(ctx->engine->id_length, Value::fromDouble(len - deleteCount + itemCount));
- return Value::fromObject(newArray).asReturnedValue();
+ return newArray.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_unshift(SimpleCallContext *ctx)
@@ -750,7 +752,7 @@ ReturnedValue ArrayPrototype::method_map(SimpleCallContext *ctx)
Value thisArg = ctx->argument(1);
- ArrayObject *a = ctx->engine->newArrayObject();
+ Scoped<ArrayObject> a(scope, ctx->engine->newArrayObject());
a->arrayReserve(len);
a->setArrayLengthUnchecked(len);
@@ -771,7 +773,7 @@ ReturnedValue ArrayPrototype::method_map(SimpleCallContext *ctx)
mapped = callback->call(callData);
a->arraySet(k, mapped);
}
- return Value::fromObject(a).asReturnedValue();
+ return a.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_filter(SimpleCallContext *ctx)
@@ -787,7 +789,7 @@ ReturnedValue ArrayPrototype::method_filter(SimpleCallContext *ctx)
Value thisArg = ctx->argument(1);
- ArrayObject *a = ctx->engine->newArrayObject();
+ Scoped<ArrayObject> a(scope, ctx->engine->newArrayObject());
a->arrayReserve(len);
ScopedValue selected(scope);
@@ -812,7 +814,7 @@ ReturnedValue ArrayPrototype::method_filter(SimpleCallContext *ctx)
++to;
}
}
- return Value::fromObject(a).asReturnedValue();
+ return a.asReturnedValue();
}
ReturnedValue ArrayPrototype::method_reduce(SimpleCallContext *ctx)