aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4stringobject.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@digia.com>2013-09-09 13:38:10 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-11 13:02:23 +0200
commit262d7261033df7650938c38401112a4767d926ff (patch)
tree8a9ecd61f546d40afa796e5ec3e786301fba1258 /src/qml/jsruntime/qv4stringobject.cpp
parent6324e987e23b4fefc622f1fc6493baa1a3e47ee9 (diff)
Continue conversion to using scoped values
This converts all methods in qv4runtime_p.h to not use raw values in arguments anymore. The conversion of return values will be done in a separate commit. Change-Id: Ie6e8f3bed459d09cb831f7f87920b7eada161502 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsruntime/qv4stringobject.cpp')
-rw-r--r--src/qml/jsruntime/qv4stringobject.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp
index 6fdb3e6dda..0a9cb32e6f 100644
--- a/src/qml/jsruntime/qv4stringobject.cpp
+++ b/src/qml/jsruntime/qv4stringobject.cpp
@@ -280,12 +280,15 @@ Value StringPrototype::method_charCodeAt(SimpleCallContext *context)
Value StringPrototype::method_concat(SimpleCallContext *context)
{
+ ValueScope scope(context);
+
QString value = getThisString(context, context->thisObject);
+ ScopedValue v(scope);
for (int i = 0; i < context->argumentCount; ++i) {
- Value v = __qmljs_to_string(context->arguments[i], context);
- assert(v.isString());
- value += v.stringValue()->toQString();
+ v = __qmljs_to_string(ValueRef(&context->arguments[i]), context);
+ assert(v->isString());
+ value += v->stringValue()->toQString();
}
return Value::fromString(context, value);
@@ -312,15 +315,17 @@ Value StringPrototype::method_indexOf(SimpleCallContext *context)
Value StringPrototype::method_lastIndexOf(SimpleCallContext *context)
{
+ ValueScope scope(context);
+
const QString value = getThisString(context, context->thisObject);
QString searchString;
if (context->argumentCount) {
- Value v = __qmljs_to_string(context->arguments[0], context);
+ Value v = __qmljs_to_string(ValueRef(&context->arguments[0]), context);
searchString = v.stringValue()->toQString();
}
- Value posArg = context->argumentCount > 1 ? context->arguments[1] : Value::undefinedValue();
+ ScopedValue posArg(scope, context->argumentCount > 1 ? context->arguments[1] : Value::undefinedValue());
double position = __qmljs_to_number(posArg);
if (std::isnan(position))
position = +qInf();
@@ -784,7 +789,7 @@ Value StringPrototype::method_trim(SimpleCallContext *ctx)
if (ctx->thisObject.isNull() || ctx->thisObject.isUndefined())
ctx->throwTypeError();
- QString s = __qmljs_to_string(ctx->thisObject, ctx).stringValue()->toQString();
+ QString s = __qmljs_to_string(ValueRef(&ctx->thisObject), ctx).stringValue()->toQString();
const QChar *chars = s.constData();
int start, end;
for (start = 0; start < s.length(); ++start) {