From 522c91f41f857bf2b52881d0bea2e07468516a42 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sat, 22 Jun 2013 00:09:24 +0200 Subject: Remove context parameter from Manged::put. Change-Id: Ib99e726ffbb20463d45a8444b4fbdfe32cd6dbef Reviewed-by: Simon Hausmann --- src/imports/localstorage/plugin.cpp | 12 ++++++------ src/qml/qml/qqmlcontextwrapper.cpp | 20 ++++++++++---------- src/qml/qml/qqmlcontextwrapper_p.h | 2 +- src/qml/qml/qqmllistwrapper.cpp | 3 +-- src/qml/qml/qqmllistwrapper_p.h | 2 +- src/qml/qml/qqmltypewrapper.cpp | 16 ++++++++-------- src/qml/qml/qqmltypewrapper_p.h | 2 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 8 ++++---- src/qml/qml/qqmlvaluetypewrapper_p.h | 2 +- src/qml/qml/v4/qv4arrayobject.cpp | 18 +++++++++--------- src/qml/qml/v4/qv4context.cpp | 6 +++--- src/qml/qml/v4/qv4jsonobject.cpp | 2 +- src/qml/qml/v4/qv4managed_p.h | 6 +++--- src/qml/qml/v4/qv4object.cpp | 24 ++++++++++++------------ src/qml/qml/v4/qv4object_p.h | 6 +++--- src/qml/qml/v4/qv4qobjectwrapper.cpp | 9 +++++---- src/qml/qml/v4/qv4qobjectwrapper_p.h | 2 +- src/qml/qml/v4/qv4regexp.cpp | 2 +- src/qml/qml/v4/qv4regexp_p.h | 2 +- src/qml/qml/v4/qv4runtime.cpp | 8 ++++---- src/qml/qml/v4/qv4string.cpp | 6 +++--- src/qml/qml/v4/qv4string_p.h | 2 +- src/qml/qml/v4/qv4stringobject.cpp | 4 ++-- src/qml/qml/v8/qjsvalue.cpp | 4 ++-- src/qml/qml/v8/qv4domerrors_p.h | 2 +- src/qml/qml/v8/qv8engine.cpp | 2 +- src/quick/items/context2d/qquickcontext2d.cpp | 2 +- tools/v4/main.cpp | 8 +++----- 28 files changed, 90 insertions(+), 92 deletions(-) diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 131de2b7bb..9357b5a43c 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -65,7 +65,7 @@ using namespace QV4; #define V4THROW_SQL(error, desc) { \ Value v = Value::fromString(ctx, desc); \ Object *ex = ctx->engine->newErrorObject(v); \ - ex->put(ctx, ctx->engine->newIdentifier(QStringLiteral("code")), Value::fromInt32(error)); \ + ex->put(ctx->engine->newIdentifier(QStringLiteral("code")), Value::fromInt32(error)); \ ctx->throwError(Value::fromObject(ex)); \ } @@ -201,9 +201,9 @@ static Value qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, ExecutionEngin for (int ii = 0; ii < record.count(); ++ii) { QVariant v = record.value(ii); if (v.isNull()) { - row->put(v4->current, v4->newIdentifier(record.fieldName(ii)), Value::nullValue()); + row->put(v4->newIdentifier(record.fieldName(ii)), Value::nullValue()); } else { - row->put(v4->current, v4->newIdentifier(record.fieldName(ii)), v8->fromVariant(v)); + row->put(v4->newIdentifier(record.fieldName(ii)), v8->fromVariant(v)); } } if (hasProperty) @@ -294,9 +294,9 @@ static Value qmlsqldatabase_executeSql(SimpleCallContext *ctx) Object *resultObject = ctx->engine->newObject(); result = Value::fromObject(resultObject); // XXX optimize - resultObject->put(ctx, ctx->engine->newIdentifier("rowsAffected"), Value::fromInt32(query.numRowsAffected())); - resultObject->put(ctx, ctx->engine->newIdentifier("insertId"), engine->toString(query.lastInsertId().toString())); - resultObject->put(ctx, ctx->engine->newIdentifier("rows"), Value::fromObject(rows)); + resultObject->put(ctx->engine->newIdentifier("rowsAffected"), Value::fromInt32(query.numRowsAffected())); + resultObject->put(ctx->engine->newIdentifier("insertId"), engine->toString(query.lastInsertId().toString())); + resultObject->put(ctx->engine->newIdentifier("rows"), Value::fromObject(rows)); } else { err = true; } diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 2413ebe00f..bae2e03825 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -262,27 +262,28 @@ Value QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty) return Value::undefinedValue(); } -void QmlContextWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void QmlContextWrapper::put(Managed *m, String *name, const Value &value) { QmlContextWrapper *wrapper = m->as(); + ExecutionEngine *v4 = m->engine(); if (!wrapper) - ctx->throwTypeError(); + v4->current->throwTypeError(); if (wrapper->isNullWrapper) { if (wrapper && wrapper->readOnly) { QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + QLatin1Char('"'); - ctx->throwError(Value::fromString(ctx->engine->newString(error))); + v4->current->throwError(Value::fromString(v4->current->engine->newString(error))); } - Object::put(m, ctx, name, value); + Object::put(m, name, value); return; } PropertyAttributes attrs; Property *pd = wrapper->__getOwnProperty__(name, &attrs); if (pd) { - wrapper->putValue(ctx, pd, attrs, value); + wrapper->putValue(v4->current, pd, attrs, value); return; } @@ -296,7 +297,6 @@ void QmlContextWrapper::put(Managed *m, ExecutionContext *ctx, String *name, con // See QV8ContextWrapper::Getter for resolution order - QV8Engine *engine = wrapper->v8; QObject *scopeObject = wrapper->getScopeObject(); QHashedV4String propertystring(Value::fromString(name)); @@ -308,13 +308,13 @@ void QmlContextWrapper::put(Managed *m, ExecutionContext *ctx, String *name, con // Search scope object if (scopeObject && - QV4::QObjectWrapper::setQmlProperty(ctx, context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, value)) + QV4::QObjectWrapper::setQmlProperty(v4->current, context, scopeObject, name, QV4::QObjectWrapper::CheckRevision, value)) return; scopeObject = 0; // Search context object if (context->contextObject && - QV4::QObjectWrapper::setQmlProperty(ctx, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, value)) + QV4::QObjectWrapper::setQmlProperty(v4->current, context, context->contextObject, name, QV4::QObjectWrapper::CheckRevision, value)) return; context = context->parent; @@ -325,10 +325,10 @@ void QmlContextWrapper::put(Managed *m, ExecutionContext *ctx, String *name, con if (wrapper->readOnly) { QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + QLatin1Char('"'); - ctx->throwError(error); + v4->current->throwError(error); } - Object::put(m, ctx, name, value); + Object::put(m, name, value); } void QmlContextWrapper::destroy(Managed *that) diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h index dab10c05c5..646135b61f 100644 --- a/src/qml/qml/qqmlcontextwrapper_p.h +++ b/src/qml/qml/qqmlcontextwrapper_p.h @@ -83,7 +83,7 @@ struct Q_QML_EXPORT QmlContextWrapper : Object void setReadOnly(bool b) { readOnly = b; } static Value get(Managed *m, String *name, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static void destroy(Managed *that); diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index aba6b6c192..e396f700af 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -130,11 +130,10 @@ Value QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProperty) return Value::undefinedValue(); } -void QmlListWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void QmlListWrapper::put(Managed *m, String *name, const Value &value) { // doesn't do anything. Should we throw? Q_UNUSED(m); - Q_UNUSED(ctx); Q_UNUSED(name); Q_UNUSED(value); } diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h index 3d0a831ae9..83624d1423 100644 --- a/src/qml/qml/qqmllistwrapper_p.h +++ b/src/qml/qml/qqmllistwrapper_p.h @@ -82,7 +82,7 @@ public: static Value get(Managed *m, String *name, bool *hasProperty); static Value getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes); static void destroy(Managed *that); diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index aa03b0e1d9..241d1f42a3 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -226,13 +226,14 @@ Value QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty) } -void QmlTypeWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void QmlTypeWrapper::put(Managed *m, String *name, const Value &value) { QmlTypeWrapper *w = m->as(); + QV4::ExecutionEngine *v4 = m->engine(); if (!w) - ctx->throwTypeError(); + v4->current->throwTypeError(); - QV8Engine *v8engine = w->v8; + QV8Engine *v8engine = v4->v8Engine; QQmlContextData *context = v8engine->callingContext(); QHashedV4String propertystring(Value::fromString(name)); @@ -242,7 +243,7 @@ void QmlTypeWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const QObject *object = w->object; QObject *ao = qmlAttachedPropertiesObjectById(type->attachedPropertiesId(), object); if (ao) - QV4::QObjectWrapper::setQmlProperty(ctx, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value); + QV4::QObjectWrapper::setQmlProperty(v4->current, context, ao, name, QV4::QObjectWrapper::IgnoreRevision, value); } else if (type && type->isSingleton()) { QQmlEngine *e = v8engine->engine(); QQmlType::SingletonInstanceInfo *siinfo = type->singletonInstanceInfo(); @@ -250,15 +251,14 @@ void QmlTypeWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const QObject *qobjectSingleton = siinfo->qobjectApi(e); if (qobjectSingleton) { - QV4::QObjectWrapper::setQmlProperty(ctx, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, value); + QV4::QObjectWrapper::setQmlProperty(v4->current, context, qobjectSingleton, name, QV4::QObjectWrapper::IgnoreRevision, value); } else if (!siinfo->scriptApi(e).isUndefined()) { QV4::Object *apiprivate = QJSValuePrivate::get(siinfo->scriptApi(e))->value.asObject(); if (!apiprivate) { QString error = QLatin1String("Cannot assign to read-only property \"") + name->toQString() + QLatin1Char('\"'); - ctx->throwError(error); + v4->current->throwError(error); } else { - QV4::ExecutionEngine *engine = QV8Engine::getV4(v8engine); - apiprivate->put(engine->current, name, value); + apiprivate->put(name, value); } } } diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h index 511406d996..9ad364e94d 100644 --- a/src/qml/qml/qqmltypewrapper_p.h +++ b/src/qml/qml/qqmltypewrapper_p.h @@ -83,7 +83,7 @@ public: static Value get(Managed *m, String *name, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static void destroy(Managed *that); private: diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 268cdb30f9..388025dbc4 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -308,11 +308,12 @@ Value QmlValueTypeWrapper::get(Managed *m, String *name, bool *hasProperty) #undef VALUE_TYPE_ACCESSOR } -void QmlValueTypeWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void QmlValueTypeWrapper::put(Managed *m, String *name, const Value &value) { QmlValueTypeWrapper *r = m->as(); + ExecutionEngine *v4 = m->engine(); if (!r) - ctx->throwTypeError(); + v4->current->throwTypeError(); QByteArray propName = name->toQString().toUtf8(); if (r->objectType == QmlValueTypeWrapper::Reference) { @@ -335,7 +336,7 @@ void QmlValueTypeWrapper::put(Managed *m, ExecutionContext *ctx, String *name, c if (!f->bindingKeyFlag) { // assigning a JS function to a non-var-property is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to value-type property"); - ctx->throwError(r->v8->toString(error)); + v4->current->throwError(r->v8->toString(error)); } QQmlContextData *context = r->v8->callingContext(); @@ -349,7 +350,6 @@ void QmlValueTypeWrapper::put(Managed *m, ExecutionContext *ctx, String *name, c cacheData.valueTypeCoreIndex = index; cacheData.valueTypePropType = p.userType(); - QV4::ExecutionEngine *v4 = ctx->engine; QV4::ExecutionEngine::StackFrame frame = v4->currentStackFrame(); newBinding = new QQmlBinding(value, reference->object, context, diff --git a/src/qml/qml/qqmlvaluetypewrapper_p.h b/src/qml/qml/qqmlvaluetypewrapper_p.h index d36fc80328..18dca0a4c9 100644 --- a/src/qml/qml/qqmlvaluetypewrapper_p.h +++ b/src/qml/qml/qqmlvaluetypewrapper_p.h @@ -84,7 +84,7 @@ public: static Value get(Managed *m, String *name, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static void destroy(Managed *that); static bool isEqualTo(Managed *m, Managed *other); diff --git a/src/qml/qml/v4/qv4arrayobject.cpp b/src/qml/qml/v4/qv4arrayobject.cpp index 4a36f66d72..26ee41d7f3 100644 --- a/src/qml/qml/v4/qv4arrayobject.cpp +++ b/src/qml/qml/v4/qv4arrayobject.cpp @@ -228,7 +228,7 @@ Value ArrayPrototype::method_pop(SimpleCallContext *ctx) if (!len) { if (!instance->isArrayObject()) - instance->put(ctx, ctx->engine->id_length, Value::fromInt32(0)); + instance->put(ctx->engine->id_length, Value::fromInt32(0)); return Value::undefinedValue(); } @@ -238,7 +238,7 @@ Value ArrayPrototype::method_pop(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len - 1); else - instance->put(ctx, ctx->engine->id_length, Value::fromDouble(len - 1)); + instance->put(ctx->engine->id_length, Value::fromDouble(len - 1)); return result; } @@ -252,11 +252,11 @@ Value ArrayPrototype::method_push(SimpleCallContext *ctx) double l = len; for (double i = 0; i < ctx->argumentCount; ++i) { Value idx = Value::fromDouble(l + i); - instance->put(ctx, idx.toString(ctx), ctx->argument(i)); + instance->put(idx.toString(ctx), ctx->argument(i)); } double newLen = l + ctx->argumentCount; if (!instance->isArrayObject()) - instance->put(ctx, ctx->engine->id_length, Value::fromDouble(newLen)); + instance->put(ctx->engine->id_length, Value::fromDouble(newLen)); else ctx->throwRangeError(Value::fromString(ctx, QStringLiteral("Array.prototype.push: Overflow"))); return Value::fromDouble(newLen); @@ -293,7 +293,7 @@ Value ArrayPrototype::method_push(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len); else - instance->put(ctx, ctx->engine->id_length, Value::fromDouble(len)); + instance->put(ctx->engine->id_length, Value::fromDouble(len)); if (len < INT_MAX) return Value::fromInt32(len); @@ -331,7 +331,7 @@ Value ArrayPrototype::method_shift(SimpleCallContext *ctx) if (!len) { if (!instance->isArrayObject()) - instance->put(ctx, ctx->engine->id_length, Value::fromInt32(0)); + instance->put(ctx->engine->id_length, Value::fromInt32(0)); return Value::undefinedValue(); } @@ -378,7 +378,7 @@ Value ArrayPrototype::method_shift(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len - 1); else - instance->put(ctx, ctx->engine->id_length, Value::fromDouble(len - 1)); + instance->put(ctx->engine->id_length, Value::fromDouble(len - 1)); return result; } @@ -485,7 +485,7 @@ Value ArrayPrototype::method_splice(SimpleCallContext *ctx) instance->putIndexed(start + i, ctx->argument(i + 2)); ctx->strictMode = true; - instance->put(ctx, ctx->engine->id_length, Value::fromDouble(len - deleteCount + itemCount)); + instance->put(ctx->engine->id_length, Value::fromDouble(len - deleteCount + itemCount)); return Value::fromObject(newArray); } @@ -539,7 +539,7 @@ Value ArrayPrototype::method_unshift(SimpleCallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(newLen); else - instance->put(ctx, ctx->engine->id_length, Value::fromDouble(newLen)); + instance->put(ctx->engine->id_length, Value::fromDouble(newLen)); if (newLen < INT_MAX) return Value::fromInt32(newLen); diff --git a/src/qml/qml/v4/qv4context.cpp b/src/qml/qml/v4/qv4context.cpp index 88dc30ba1a..7ab493c351 100644 --- a/src/qml/qml/v4/qv4context.cpp +++ b/src/qml/qml/v4/qv4context.cpp @@ -312,7 +312,7 @@ void ExecutionContext::setProperty(String *name, const Value& value) if (ctx->type == Type_WithContext) { Object *w = static_cast(ctx)->withObject; if (w->__hasProperty__(name)) { - w->put(ctx, name, value); + w->put(name, value); return; } } else if (ctx->type == Type_CatchContext && static_cast(ctx)->exceptionVarName->isEqualTo(name)) { @@ -338,14 +338,14 @@ void ExecutionContext::setProperty(String *name, const Value& value) } if (activation && (ctx->type == Type_QmlContext || activation->__hasProperty__(name))) { - activation->put(this, name, value); + activation->put(name, value); return; } } } if (strictMode || name->isEqualTo(engine->id_this)) throwReferenceError(Value::fromString(name)); - engine->globalObject->put(this, name, value); + engine->globalObject->put(name, value); } Value ExecutionContext::getProperty(String *name) diff --git a/src/qml/qml/v4/qv4jsonobject.cpp b/src/qml/qml/v4/qv4jsonobject.cpp index 57b241f1ff..b4ecbb9534 100644 --- a/src/qml/qml/v4/qv4jsonobject.cpp +++ b/src/qml/qml/v4/qv4jsonobject.cpp @@ -965,7 +965,7 @@ QV4::Value JsonObject::fromJsonObject(ExecutionEngine *engine, const QJsonObject { Object *o = engine->newObject(); for (QJsonObject::const_iterator it = object.begin(); it != object.end(); ++it) - o->put(engine->current, engine->newString(it.key()), fromJsonValue(engine, it.value())); + o->put(engine->newString(it.key()), fromJsonValue(engine, it.value())); return Value::fromObject(o); } diff --git a/src/qml/qml/v4/qv4managed_p.h b/src/qml/qml/v4/qv4managed_p.h index 6061f92da1..2f884781f9 100644 --- a/src/qml/qml/v4/qv4managed_p.h +++ b/src/qml/qml/v4/qv4managed_p.h @@ -107,7 +107,7 @@ struct ManagedVTable bool (*hasInstance)(Managed *, const Value &value); Value (*get)(Managed *, String *name, bool *hasProperty); Value (*getIndexed)(Managed *, uint index, bool *hasProperty); - void (*put)(Managed *, ExecutionContext *ctx, String *name, const Value &value); + void (*put)(Managed *, String *name, const Value &value); void (*putIndexed)(Managed *, uint index, const Value &value); PropertyAttributes (*query)(const Managed *, String *name); PropertyAttributes (*queryIndexed)(const Managed *, uint index); @@ -264,8 +264,8 @@ public: Value call(ExecutionContext *context, const Value &thisObject, Value *args, int argc); Value get(String *name, bool *hasProperty = 0); Value getIndexed(uint index, bool *hasProperty = 0); - void put(ExecutionContext *ctx, String *name, const Value &value) - { vtbl->put(this, ctx, name, value); } + void put(String *name, const Value &value) + { vtbl->put(this, name, value); } void putIndexed(uint index, const Value &value) { vtbl->putIndexed(this, index, value); } PropertyAttributes query(String *name) const diff --git a/src/qml/qml/v4/qv4object.cpp b/src/qml/qml/v4/qv4object.cpp index 85171b838b..f542f34b53 100644 --- a/src/qml/qml/v4/qv4object.cpp +++ b/src/qml/qml/v4/qv4object.cpp @@ -128,7 +128,7 @@ void Object::destroy(Managed *that) void Object::put(ExecutionContext *ctx, const QString &name, const Value &value) { - put(ctx, ctx->engine->newString(name), value); + put(ctx->engine->newString(name), value); } Value Object::getValue(const Value &thisObject, ExecutionContext *ctx, const Property *p, PropertyAttributes attrs) @@ -171,7 +171,7 @@ void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, String *name, const V Value v = get(name); Value result; op(ctx, &result, v, rhs); - put(ctx, name, result); + put(name, result); } void Object::inplaceBinOp(ExecutionContext *ctx, BinOp op, const Value &index, const Value &rhs) @@ -404,9 +404,9 @@ Value Object::getIndexed(Managed *m, uint index, bool *hasProperty) return static_cast(m)->internalGetIndexed(index, hasProperty); } -void Object::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void Object::put(Managed *m, String *name, const Value &value) { - static_cast(m)->internalPut(ctx, name, value); + static_cast(m)->internalPut(name, value); } void Object::putIndexed(Managed *m, uint index, const Value &value) @@ -516,7 +516,7 @@ void Object::setLookup(Managed *m, Lookup *l, const Value &value) } } - o->put(o->engine()->current, l->name, value); + o->put(l->name, value); } Property *Object::advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attrs) @@ -645,13 +645,13 @@ Value Object::internalGetIndexed(uint index, bool *hasProperty) // Section 8.12.5 -void Object::internalPut(ExecutionContext *ctx, String *name, const Value &value) +void Object::internalPut(String *name, const Value &value) { uint idx = name->asArrayIndex(); if (idx != UINT_MAX) return putIndexed(idx, value); - name->makeIdentifier(ctx); + name->makeIdentifier(engine()->current); uint member = internalClass->find(name); Property *pd = 0; @@ -669,11 +669,11 @@ void Object::internalPut(ExecutionContext *ctx, String *name, const Value &value goto reject; } else if (!attrs.isWritable()) goto reject; - else if (isArrayObject() && name->isEqualTo(ctx->engine->id_length)) { + else if (isArrayObject() && name->isEqualTo(engine()->id_length)) { bool ok; uint l = value.asArrayLength(&ok); if (!ok) - ctx->throwRangeError(value); + engine()->current->throwRangeError(value); ok = setArrayLength(l); if (!ok) goto reject; @@ -706,7 +706,7 @@ void Object::internalPut(ExecutionContext *ctx, String *name, const Value &value Value args[1]; args[0] = value; - pd->setter()->call(ctx, Value::fromObject(this), args, 1); + pd->setter()->call(engine()->current, Value::fromObject(this), args, 1); return; } @@ -717,11 +717,11 @@ void Object::internalPut(ExecutionContext *ctx, String *name, const Value &value } reject: - if (ctx->strictMode) { + if (engine()->current->strictMode) { QString message = QStringLiteral("Cannot assign to read-only property \""); message += name->toQString(); message += QLatin1Char('\"'); - ctx->throwTypeError(message); + engine()->current->throwTypeError(message); } } diff --git a/src/qml/qml/v4/qv4object_p.h b/src/qml/qml/v4/qv4object_p.h index 287513decc..dcdeca1611 100644 --- a/src/qml/qml/v4/qv4object_p.h +++ b/src/qml/qml/v4/qv4object_p.h @@ -332,7 +332,7 @@ public: inline Value getIndexed(uint idx, bool *hasProperty = 0) { return vtbl->getIndexed(this, idx, hasProperty); } inline void put(String *name, const Value &v) - { vtbl->put(this, engine()->current, name, v); } + { vtbl->put(this, name, v); } inline void putIndexed(uint idx, const Value &v) { vtbl->putIndexed(this, idx, v); } using Managed::get; @@ -352,7 +352,7 @@ protected: static void markObjects(Managed *that); static Value get(Managed *m, String *name, bool *hasProperty); static Value getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static void putIndexed(Managed *m, uint index, const Value &value); static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); @@ -366,7 +366,7 @@ protected: private: Value internalGet(String *name, bool *hasProperty); Value internalGetIndexed(uint index, bool *hasProperty); - void internalPut(ExecutionContext *ctx, String *name, const Value &value); + void internalPut(String *name, const Value &value); void internalPutIndexed(uint index, const Value &value); bool internalDeleteProperty(String *name); bool internalDeleteIndexedProperty(uint index); diff --git a/src/qml/qml/v4/qv4qobjectwrapper.cpp b/src/qml/qml/v4/qv4qobjectwrapper.cpp index a911c6f066..2cb6a36afd 100644 --- a/src/qml/qml/v4/qv4qobjectwrapper.cpp +++ b/src/qml/qml/v4/qv4qobjectwrapper.cpp @@ -612,18 +612,19 @@ QV4::Value QObjectWrapper::get(Managed *m, String *name, bool *hasProperty) return that->getQmlProperty(v4->current, qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true); } -void QObjectWrapper::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void QObjectWrapper::put(Managed *m, String *name, const Value &value) { QObjectWrapper *that = static_cast(m); + ExecutionEngine *v4 = m->engine(); if (QQmlData::wasDeleted(that->m_object)) return; - QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(ctx->engine); - if (!setQmlProperty(ctx, qmlContext, that->m_object, name, QV4::QObjectWrapper::IgnoreRevision, value)) { + QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(v4); + if (!setQmlProperty(v4->current, qmlContext, that->m_object, name, QV4::QObjectWrapper::IgnoreRevision, value)) { QString error = QLatin1String("Cannot assign to non-existent property \"") + name->toQString() + QLatin1Char('\"'); - ctx->throwError(error); + v4->current->throwError(error); } } diff --git a/src/qml/qml/v4/qv4qobjectwrapper_p.h b/src/qml/qml/v4/qv4qobjectwrapper_p.h index 70d21a3205..708c2a784c 100644 --- a/src/qml/qml/v4/qv4qobjectwrapper_p.h +++ b/src/qml/qml/v4/qv4qobjectwrapper_p.h @@ -106,7 +106,7 @@ private: String *m_toString; static Value get(Managed *m, String *name, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static PropertyAttributes query(const Managed *, String *name); static Property *advanceIterator(Managed *m, ObjectIterator *it, String **name, uint *index, PropertyAttributes *attributes); static void markObjects(Managed *that); diff --git a/src/qml/qml/v4/qv4regexp.cpp b/src/qml/qml/v4/qv4regexp.cpp index 621ed89e24..b35916925a 100644 --- a/src/qml/qml/v4/qv4regexp.cpp +++ b/src/qml/qml/v4/qv4regexp.cpp @@ -146,7 +146,7 @@ Value RegExp::getIndexed(Managed *m, uint index, bool *hasProperty) return Value::undefinedValue(); } -void RegExp::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void RegExp::put(Managed *m, String *name, const Value &value) { } diff --git a/src/qml/qml/v4/qv4regexp_p.h b/src/qml/qml/v4/qv4regexp_p.h index ff6d30c53e..cac450871f 100644 --- a/src/qml/qml/v4/qv4regexp_p.h +++ b/src/qml/qml/v4/qv4regexp_p.h @@ -113,7 +113,7 @@ protected: static void markObjects(Managed *that); static Value get(Managed *m, String *name, bool *hasProperty); static Value getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static void putIndexed(Managed *m, uint index, const Value &value); static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); diff --git a/src/qml/qml/v4/qv4runtime.cpp b/src/qml/qml/v4/qv4runtime.cpp index af4a6e7936..2cff28b3c0 100644 --- a/src/qml/qml/v4/qv4runtime.cpp +++ b/src/qml/qml/v4/qv4runtime.cpp @@ -544,7 +544,7 @@ String *__qmljs_convert_to_string(ExecutionContext *ctx, const Value &value) void __qmljs_set_property(ExecutionContext *ctx, const Value &object, String *name, const Value &value) { Object *o = object.toObject(ctx); - o->put(ctx, name, value); + o->put(name, value); } void __qmljs_get_element(ExecutionContext *ctx, Value *result, const Value &object, const Value &index) @@ -636,7 +636,7 @@ void __qmljs_set_element(ExecutionContext *ctx, const Value &object, const Value } String *name = index.toString(ctx); - o->put(ctx, name, value); + o->put(name, value); } void __qmljs_foreach_iterator_object(ExecutionContext *ctx, Value *result, const Value &in) @@ -1070,7 +1070,7 @@ void __qmljs_builtin_post_increment_member(ExecutionContext *context, Value *res v = Value::fromDouble(d + 1); } - o->put(context, name, v); + o->put(name, v); } void __qmljs_builtin_post_increment_element(ExecutionContext *context, Value *result, const Value &base, const Value *index) @@ -1150,7 +1150,7 @@ void __qmljs_builtin_post_decrement_member(ExecutionContext *context, Value *res v = Value::fromDouble(d - 1); } - o->put(context, name, v); + o->put(name, v); } void __qmljs_builtin_post_decrement_element(ExecutionContext *context, Value *result, const Value &base, const Value &index) diff --git a/src/qml/qml/v4/qv4string.cpp b/src/qml/qml/v4/qv4string.cpp index ed01efa958..c9e6657578 100644 --- a/src/qml/qml/v4/qv4string.cpp +++ b/src/qml/qml/v4/qv4string.cpp @@ -144,11 +144,11 @@ Value String::getIndexed(Managed *m, uint index, bool *hasProperty) return engine->stringPrototype->getValue(Value::fromString(that), engine->current, pd, attrs); } -void String::put(Managed *m, ExecutionContext *ctx, String *name, const Value &value) +void String::put(Managed *m, String *name, const Value &value) { String *that = static_cast(m); - Object *o = ctx->engine->newStringObject(Value::fromString(that)); - o->put(ctx, name, value); + Object *o = that->engine()->newStringObject(Value::fromString(that)); + o->put(name, value); } void String::putIndexed(Managed *m, uint index, const Value &value) diff --git a/src/qml/qml/v4/qv4string_p.h b/src/qml/qml/v4/qv4string_p.h index bafeb2175e..2a855a29a6 100644 --- a/src/qml/qml/v4/qv4string_p.h +++ b/src/qml/qml/v4/qv4string_p.h @@ -122,7 +122,7 @@ protected: static void destroy(Managed *); static Value get(Managed *m, String *name, bool *hasProperty); static Value getIndexed(Managed *m, uint index, bool *hasProperty); - static void put(Managed *m, ExecutionContext *ctx, String *name, const Value &value); + static void put(Managed *m, String *name, const Value &value); static void putIndexed(Managed *m, uint index, const Value &value); static PropertyAttributes query(const Managed *m, String *name); static PropertyAttributes queryIndexed(const Managed *m, uint index); diff --git a/src/qml/qml/v4/qv4stringobject.cpp b/src/qml/qml/v4/qv4stringobject.cpp index 4b30a3e5d6..350a2c44fe 100644 --- a/src/qml/qml/v4/qv4stringobject.cpp +++ b/src/qml/qml/v4/qv4stringobject.cpp @@ -358,7 +358,7 @@ Value StringPrototype::method_match(SimpleCallContext *context) return exec->call(context, Value::fromObject(rx), &arg, 1); String *lastIndex = context->engine->newString(QStringLiteral("lastIndex")); - rx->put(context, lastIndex, Value::fromInt32(0)); + rx->put(lastIndex, Value::fromInt32(0)); ArrayObject *a = context->engine->newArrayObject(); double previousLastIndex = 0; @@ -371,7 +371,7 @@ Value StringPrototype::method_match(SimpleCallContext *context) double thisIndex = rx->get(lastIndex, 0).toInteger(); if (previousLastIndex == thisIndex) { previousLastIndex = thisIndex + 1; - rx->put(context, lastIndex, Value::fromDouble(previousLastIndex)); + rx->put(lastIndex, Value::fromDouble(previousLastIndex)); } else { previousLastIndex = thisIndex; } diff --git a/src/qml/qml/v8/qjsvalue.cpp b/src/qml/qml/v8/qjsvalue.cpp index df54418cc4..e45a22140b 100644 --- a/src/qml/qml/v8/qjsvalue.cpp +++ b/src/qml/qml/v8/qjsvalue.cpp @@ -873,7 +873,7 @@ void QJSValue::setProperty(const QString& name, const QJSValue& value) QV4::ExecutionContext *ctx = engine->current; s->makeIdentifier(ctx); try { - o->put(ctx, s, value.d->getValue(engine)); + o->put(s, value.d->getValue(engine)); } catch (QV4::Exception &e) { e.accept(ctx); } @@ -903,7 +903,7 @@ void QJSValue::setProperty(quint32 arrayIndex, const QJSValue& value) if (arrayIndex != UINT_MAX) o->putIndexed(arrayIndex, value.d->getValue(engine)); else - o->put(ctx, engine->id_uintMax, value.d->getValue(engine)); + o->put(engine->id_uintMax, value.d->getValue(engine)); } catch (QV4::Exception &e) { e.accept(ctx); } diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h index 85fa271437..ed38886e15 100644 --- a/src/qml/qml/v8/qv4domerrors_p.h +++ b/src/qml/qml/v8/qv4domerrors_p.h @@ -79,7 +79,7 @@ QT_BEGIN_NAMESPACE #define V4THROW_DOM(error, string) { \ QV4::Value v = QV4::Value::fromString(ctx, QStringLiteral(string)); \ QV4::Object *ex = ctx->engine->newErrorObject(v); \ - ex->put(ctx, ctx->engine->newIdentifier(QStringLiteral("code")), QV4::Value::fromInt32(error)); \ + ex->put(ctx->engine->newIdentifier(QStringLiteral("code")), QV4::Value::fromInt32(error)); \ ctx->throwError(QV4::Value::fromObject(ex)); \ } diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 51edb6c360..0336a16eea 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -209,7 +209,7 @@ static QV4::Value objectFromVariantMap(QV8Engine *engine, const QVariantMap &map QV4::ExecutionEngine *e = QV8Engine::getV4(engine); QV4::Object *o = e->newObject(); for (QVariantMap::ConstIterator iter = map.begin(); iter != map.end(); ++iter) - o->put(e->current, e->newString(iter.key()), engine->fromVariant(iter.value())); + o->put(e->newString(iter.key()), engine->fromVariant(iter.value())); return QV4::Value::fromObject(o); } diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index d7d956d4c1..5011fd45f2 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -2419,7 +2419,7 @@ QV4::Value QQuickJSContext2DPrototype::method_measureText(QV4::SimpleCallContext QFontMetrics fm(r->context->state.font); uint width = fm.width(ctx->arguments[0].toQString()); QV4::Object *tm = ctx->engine->newObject(); - tm->put(ctx->engine->current, ctx->engine->newIdentifier(QStringLiteral("width")), QV4::Value::fromDouble(width)); + tm->put(ctx->engine->newIdentifier(QStringLiteral("width")), QV4::Value::fromDouble(width)); return QV4::Value::fromObject(tm); } return QV4::Value::undefinedValue(); diff --git a/tools/v4/main.cpp b/tools/v4/main.cpp index e30fd8d21c..bc95178397 100644 --- a/tools/v4/main.cpp +++ b/tools/v4/main.cpp @@ -137,7 +137,7 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::Exception &exce std::cerr << qPrintable(msg->buildFullMessage(ctx)->toQString()) << std::endl; } } else { - std::cerr << "Uncaught exception: " << qPrintable(e->get(ctx, ctx->engine->newString(QStringLiteral("message")), 0).toString(ctx)->toQString()) << std::endl; + std::cerr << "Uncaught exception: " << qPrintable(e->get(ctx->engine->newString(QStringLiteral("message")), 0).toString(ctx)->toQString()) << std::endl; } } @@ -379,12 +379,10 @@ int main(int argc, char *argv[]) QV4::Object *globalObject = vm.globalObject; QV4::Object *print = new (ctx->engine->memoryManager) builtins::Print(ctx); print->prototype = ctx->engine->objectPrototype; - globalObject->put(ctx, vm.newIdentifier(QStringLiteral("print")), - QV4::Value::fromObject(print)); + globalObject->put(vm.newIdentifier(QStringLiteral("print")), QV4::Value::fromObject(print)); QV4::Object *gc = new (ctx->engine->memoryManager) builtins::GC(ctx); gc->prototype = ctx->engine->objectPrototype; - globalObject->put(ctx, vm.newIdentifier(QStringLiteral("gc")), - QV4::Value::fromObject(gc)); + globalObject->put(vm.newIdentifier(QStringLiteral("gc")), QV4::Value::fromObject(gc)); foreach (const QString &fn, args) { QFile file(fn); -- cgit v1.2.3