aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4stringobject.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/qv4stringobject.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/qv4stringobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 2223432ec9..811c5b26b9 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -379,7 +379,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context)
String *lastIndex = context->engine->newString(QStringLiteral("lastIndex"));
rx->put(lastIndex, Value::fromInt32(0));
- ArrayObject *a = context->engine->newArrayObject();
+ Scoped<ArrayObject> a(scope, context->engine->newArrayObject());
double previousLastIndex = 0;
uint n = 0;
@@ -406,7 +406,7 @@ ReturnedValue StringPrototype::method_match(SimpleCallContext *context)
if (!n)
return Encode::null();
- return Value::fromObject(a).asReturnedValue();
+ return a.asReturnedValue();
}
@@ -618,6 +618,7 @@ ReturnedValue StringPrototype::method_slice(SimpleCallContext *ctx)
ReturnedValue StringPrototype::method_split(SimpleCallContext *ctx)
{
+ Scope scope(ctx);
QString text;
if (StringObject *thisObject = ctx->thisObject.asStringObject())
text = thisObject->value.stringValue()->toQString();
@@ -627,13 +628,12 @@ ReturnedValue StringPrototype::method_split(SimpleCallContext *ctx)
Value separatorValue = ctx->argumentCount > 0 ? ctx->argument(0) : Value::undefinedValue();
Value limitValue = ctx->argumentCount > 1 ? ctx->argument(1) : Value::undefinedValue();
- ArrayObject* array = ctx->engine->newArrayObject();
- Value result = Value::fromObject(array);
+ Scoped<ArrayObject> array(scope, ctx->engine->newArrayObject());
if (separatorValue.isUndefined()) {
if (limitValue.isUndefined()) {
array->push_back(Value::fromString(ctx, text));
- return result.asReturnedValue();
+ return array.asReturnedValue();
}
return Value::fromString(ctx, text.left(limitValue.toInteger())).asReturnedValue();
}
@@ -641,7 +641,7 @@ ReturnedValue StringPrototype::method_split(SimpleCallContext *ctx)
uint limit = limitValue.isUndefined() ? UINT_MAX : limitValue.toUInt32();
if (limit == 0)
- return result.asReturnedValue();
+ return array.asReturnedValue();
if (RegExpObject* re = separatorValue.as<RegExpObject>()) {
if (re->value->pattern().isEmpty()) {
@@ -679,7 +679,7 @@ ReturnedValue StringPrototype::method_split(SimpleCallContext *ctx)
if (separator.isEmpty()) {
for (uint i = 0; i < qMin(limit, uint(text.length())); ++i)
array->push_back(Value::fromString(ctx, text.mid(i, 1)));
- return result.asReturnedValue();
+ return array.asReturnedValue();
}
int start = 0;
@@ -693,7 +693,7 @@ ReturnedValue StringPrototype::method_split(SimpleCallContext *ctx)
if (array->arrayLength() < limit && start != -1)
array->push_back(Value::fromString(ctx, text.mid(start)));
}
- return result.asReturnedValue();
+ return array.asReturnedValue();
}
ReturnedValue StringPrototype::method_substr(SimpleCallContext *context)