diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-09-09 13:38:10 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-11 13:02:23 +0200 |
commit | 262d7261033df7650938c38401112a4767d926ff (patch) | |
tree | 8a9ecd61f546d40afa796e5ec3e786301fba1258 /src/qml/jsruntime/qv4arrayobject.cpp | |
parent | 6324e987e23b4fefc622f1fc6493baa1a3e47ee9 (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/qv4arrayobject.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4arrayobject.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 3ab74d8080..e3b08f5941 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -546,12 +546,14 @@ Value ArrayPrototype::method_unshift(SimpleCallContext *ctx) Value ArrayPrototype::method_indexOf(SimpleCallContext *ctx) { + ValueScope scope(ctx); + Object *instance = ctx->thisObject.toObject(ctx); uint len = getLength(ctx, instance); if (!len) return Value::fromInt32(-1); - Value searchValue; + ScopedValue searchValue(scope); uint fromIndex = 0; if (ctx->argumentCount >= 1) @@ -569,9 +571,10 @@ Value ArrayPrototype::method_indexOf(SimpleCallContext *ctx) } if (instance->isStringObject()) { + ScopedValue v(scope); for (uint k = fromIndex; k < len; ++k) { bool exists; - Value v = instance->getIndexed(k, &exists); + v = instance->getIndexed(k, &exists); if (exists && __qmljs_strict_equal(v, searchValue)) return Value::fromDouble(k); } @@ -583,12 +586,14 @@ Value ArrayPrototype::method_indexOf(SimpleCallContext *ctx) Value ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) { + ValueScope scope(ctx); + Object *instance = ctx->thisObject.toObject(ctx); uint len = getLength(ctx, instance); if (!len) return Value::fromInt32(-1); - Value searchValue; + ScopedValue searchValue(scope); uint fromIndex = len; if (ctx->argumentCount >= 1) @@ -608,10 +613,11 @@ Value ArrayPrototype::method_lastIndexOf(SimpleCallContext *ctx) fromIndex = (uint) f + 1; } + ScopedValue v(scope); for (uint k = fromIndex; k > 0;) { --k; bool exists; - Value v = instance->getIndexed(k, &exists); + v = instance->getIndexed(k, &exists); if (exists && __qmljs_strict_equal(v, searchValue)) return Value::fromDouble(k); } |