diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-11-21 16:41:32 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-04 09:45:50 +0100 |
commit | 9306c05dd152511b8b938d7899a7bdf1aeb8d1c2 (patch) | |
tree | 514b6cda632244d7f9e7fdb1af143da05b7b1ce0 /src/qml/jsapi | |
parent | 0f32303e5cc9c539aa8698cab2b8cc2e946d885a (diff) |
Encapsulate the current context and fix it's usage
Encapsulate accesses to the current context, and rework
the way we push and pop this context from the context
stack.
Largely a cleanup, but simplifies the code in the long term
Change-Id: I409e378490d0ab027be6a4c01a4031b2ea35c51d
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/jsapi')
-rw-r--r-- | src/qml/jsapi/qjsengine.cpp | 2 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalue.cpp | 24 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalueiterator.cpp | 6 |
3 files changed, 16 insertions, 16 deletions
diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index cb050c2518..a19c358231 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -261,7 +261,7 @@ void QJSEngine::collectGarbage() QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, int lineNumber) { QV4::Scope scope(d->m_v4Engine); - QV4::ExecutionContext *ctx = d->m_v4Engine->current; + QV4::ExecutionContext *ctx = d->m_v4Engine->currentContext(); QV4::ScopedValue result(scope); QV4::Script script(ctx, program, fileName, lineNumber); diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index f0e92ebd4d..d7a1cef3ba 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -383,7 +383,7 @@ double QJSValue::toNumber() const if (d->value.isEmpty()) return __qmljs_string_to_number(d->string); - QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0; + QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; double dbl = d->value.toNumber(); if (ctx && ctx->engine->hasException) { ctx->catchException(); @@ -409,7 +409,7 @@ bool QJSValue::toBool() const if (d->value.isEmpty()) return d->string.length() > 0; - QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0; + QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; bool b = d->value.toBoolean(); if (ctx && ctx->engine->hasException) { ctx->catchException(); @@ -435,7 +435,7 @@ qint32 QJSValue::toInt() const if (d->value.isEmpty()) return QV4::Primitive::toInt32(__qmljs_string_to_number(d->string)); - QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0; + QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; qint32 i = d->value.toInt32(); if (ctx && ctx->engine->hasException) { ctx->catchException(); @@ -461,7 +461,7 @@ quint32 QJSValue::toUInt() const if (d->value.isEmpty()) return QV4::Primitive::toUInt32(__qmljs_string_to_number(d->string)); - QV4::ExecutionContext *ctx = d->engine ? d->engine->current : 0; + QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; quint32 u = d->value.toUInt32(); if (ctx && ctx->engine->hasException) { ctx->catchException(); @@ -536,7 +536,7 @@ QJSValue QJSValue::call(const QJSValueList &args) } ScopedValue result(scope); - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); result = f->call(callData); if (scope.hasException()) result = ctx->catchException(); @@ -590,7 +590,7 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList } ScopedValue result(scope); - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); result = f->call(callData); if (scope.hasException()) result = ctx->catchException(); @@ -636,7 +636,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args) } ScopedValue result(scope); - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); result = f->construct(callData); if (scope.hasException()) result = ctx->catchException(); @@ -859,7 +859,7 @@ QJSValue QJSValue::property(const QString& name) const return property(idx); s->makeIdentifier(); - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); QV4::ScopedValue result(scope); result = o->get(s); if (scope.hasException()) @@ -891,7 +891,7 @@ QJSValue QJSValue::property(quint32 arrayIndex) const if (!o) return QJSValue(); - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); QV4::ScopedValue result(scope); result = arrayIndex == UINT_MAX ? o->get(engine->id_uintMax) : o->getIndexed(arrayIndex); if (scope.hasException()) @@ -933,7 +933,7 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value) return; } - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); s->makeIdentifier(); QV4::ScopedValue v(scope, value.d->getValue(engine)); o->put(s, v); @@ -964,7 +964,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value) if (!o) return; - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); QV4::ScopedValue v(scope, value.d->getValue(engine)); if (arrayIndex != UINT_MAX) o->putIndexed(arrayIndex, v); @@ -997,7 +997,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value) bool QJSValue::deleteProperty(const QString &name) { ExecutionEngine *engine = d->engine; - ExecutionContext *ctx = engine->current; + ExecutionContext *ctx = engine->currentContext(); Scope scope(engine); ScopedObject o(scope, d->value.asObject()); if (!o) diff --git a/src/qml/jsapi/qjsvalueiterator.cpp b/src/qml/jsapi/qjsvalueiterator.cpp index 245b75b384..ed011ef691 100644 --- a/src/qml/jsapi/qjsvalueiterator.cpp +++ b/src/qml/jsapi/qjsvalueiterator.cpp @@ -59,7 +59,7 @@ QJSValueIteratorPrivate::QJSValueIteratorPrivate(const QJSValue &v) QV4::Scope scope(e); QV4::ScopedObject o(scope, jsp->value); - iterator = e->newForEachIteratorObject(e->current, o)->asReturnedValue(); + iterator = e->newForEachIteratorObject(e->currentContext(), o)->asReturnedValue(); currentName = (QV4::String *)0; nextName = (QV4::String *)0; @@ -198,7 +198,7 @@ QJSValue QJSValueIterator::value() const QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value()); QV4::ScopedObject o(scope, it->it.object); - QV4::ExecutionContext *ctx = engine->current; + QV4::ExecutionContext *ctx = engine->currentContext(); QV4::ScopedValue v(scope); if (!!d_ptr->currentName) { QV4::ScopedString n(scope, d_ptr->currentName); @@ -237,7 +237,7 @@ QJSValueIterator& QJSValueIterator::operator=(QJSValue& object) QJSValuePrivate *jsp = QJSValuePrivate::get(object); QV4::Scope scope(v4); QV4::ScopedObject o(scope, jsp->value); - d_ptr->iterator = v4->newForEachIteratorObject(v4->current, o)->asReturnedValue(); + d_ptr->iterator = v4->newForEachIteratorObject(v4->currentContext(), o)->asReturnedValue(); QV4::Scoped<QV4::ForEachIteratorObject> it(scope, d_ptr->iterator.value()); it->it.flags = QV4::ObjectIterator::NoFlags; it->it.next(d_ptr->nextName, &d_ptr->nextIndex, &d_ptr->nextAttributes); |