From 47fbcb47771a36ab9fd0a4d5ede7b7504ab1410d Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Sun, 11 Jan 2015 16:30:29 +0100 Subject: Get rid of all uses of Managed::engine() Change-Id: I596f14554d81f5e9af9996294d96047f2e810bef Reviewed-by: Simon Hausmann --- src/imports/localstorage/plugin.cpp | 4 ++-- src/qml/jsruntime/qv4argumentsobject.cpp | 4 ++-- src/qml/jsruntime/qv4arraybuffer.cpp | 2 +- src/qml/jsruntime/qv4arrayobject.cpp | 2 +- src/qml/jsruntime/qv4booleanobject.cpp | 4 ++-- src/qml/jsruntime/qv4context_p.h | 2 ++ src/qml/jsruntime/qv4dataview.cpp | 2 +- src/qml/jsruntime/qv4dateobject.cpp | 6 +++--- src/qml/jsruntime/qv4errorobject.cpp | 28 +++++++++++++-------------- src/qml/jsruntime/qv4functionobject.cpp | 8 ++++---- src/qml/jsruntime/qv4functionobject_p.h | 2 +- src/qml/jsruntime/qv4managed.cpp | 5 ----- src/qml/jsruntime/qv4managed_p.h | 2 -- src/qml/jsruntime/qv4numberobject.cpp | 4 ++-- src/qml/jsruntime/qv4object.cpp | 16 +++++++-------- src/qml/jsruntime/qv4objectproto.cpp | 10 ++++++---- src/qml/jsruntime/qv4qobjectwrapper.cpp | 4 ++-- src/qml/jsruntime/qv4regexpobject.cpp | 2 +- src/qml/jsruntime/qv4script.cpp | 2 +- src/qml/jsruntime/qv4stringobject.cpp | 11 ++++------- src/qml/jsruntime/qv4typedarray.cpp | 9 +++++---- src/qml/jsruntime/qv4value.cpp | 9 ++++++--- src/qml/qml/qqmlcontextwrapper.cpp | 14 +++++++------- src/qml/qml/qqmllistwrapper.cpp | 4 ++-- src/qml/qml/qqmltypewrapper.cpp | 6 +++--- src/qml/qml/qqmlvaluetypewrapper.cpp | 4 ++-- src/qml/qml/qqmlxmlhttprequest.cpp | 14 +++++++------- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 2 +- src/qml/types/qqmldelegatemodel.cpp | 8 ++++---- src/quick/items/context2d/qquickcontext2d.cpp | 4 ++-- 30 files changed, 96 insertions(+), 98 deletions(-) (limited to 'src') diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 2de47b232a..5b99783431 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -240,13 +240,13 @@ static ReturnedValue qmlsqldatabase_rows_index(QQmlSqlDatabaseWrapper *r, Execut ReturnedValue QQmlSqlDatabaseWrapper::getIndexed(Managed *m, uint index, bool *hasProperty) { - QV4::Scope scope(m->engine()); + QV4::Scope scope(static_cast(m)->engine()); Q_ASSERT(m->as()); QV4::Scoped r(scope, static_cast(m)); if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Rows) return Object::getIndexed(m, index, hasProperty); - return qmlsqldatabase_rows_index(r, m->engine(), index, hasProperty); + return qmlsqldatabase_rows_index(r, scope.engine, index, hasProperty); } static ReturnedValue qmlsqldatabase_rows_item(CallContext *ctx) diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 48e8bb67d4..5e002446ed 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -201,7 +201,7 @@ DEFINE_OBJECT_VTABLE(ArgumentsGetterFunction); ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData) { - ExecutionEngine *v4 = getter->engine(); + ExecutionEngine *v4 = static_cast(getter)->engine(); Scope scope(v4); Scoped g(scope, static_cast(getter)); Scoped o(scope, callData->thisObject.as()); @@ -216,7 +216,7 @@ DEFINE_OBJECT_VTABLE(ArgumentsSetterFunction); ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData) { - ExecutionEngine *v4 = setter->engine(); + ExecutionEngine *v4 = static_cast(setter)->engine(); Scope scope(v4); Scoped s(scope, static_cast(setter)); Scoped o(scope, callData->thisObject.as()); diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 60ab527a42..5d2c95bed4 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -46,7 +46,7 @@ Heap::ArrayBufferCtor::ArrayBufferCtor(QV4::ExecutionContext *scope) ReturnedValue ArrayBufferCtor::construct(Managed *m, CallData *callData) { - ExecutionEngine *v4 = m->engine(); + ExecutionEngine *v4 = static_cast(m)->engine(); Scope scope(v4); ScopedValue l(scope, callData->argument(0)); diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 078b7fee70..6c677e856f 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -49,7 +49,7 @@ Heap::ArrayCtor::ArrayCtor(QV4::ExecutionContext *scope) ReturnedValue ArrayCtor::construct(Managed *m, CallData *callData) { - ExecutionEngine *v4 = m->engine(); + ExecutionEngine *v4 = static_cast(m)->engine(); Scope scope(v4); ScopedArrayObject a(scope, v4->newArrayObject()); uint len; diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp index 0b3ae4e705..c606e37310 100644 --- a/src/qml/jsruntime/qv4booleanobject.cpp +++ b/src/qml/jsruntime/qv4booleanobject.cpp @@ -45,10 +45,10 @@ Heap::BooleanCtor::BooleanCtor(QV4::ExecutionContext *scope) ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); bool n = callData->argc ? callData->args[0].toBoolean() : false; ScopedValue b(scope, QV4::Primitive::fromBoolean(n)); - return Encode(m->engine()->newBooleanObject(b)); + return Encode(scope.engine->newBooleanObject(b)); } ReturnedValue BooleanCtor::call(Managed *, CallData *callData) diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 48319c7444..0b70677cb3 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -140,6 +140,8 @@ struct Q_QML_EXPORT ExecutionContext : public Managed V4_MANAGED(ExecutionContext, Managed) Q_MANAGED_TYPE(ExecutionContext) + ExecutionEngine *engine() const { return d()->engine; } + Heap::CallContext *newCallContext(FunctionObject *f, CallData *callData); Heap::WithContext *newWithContext(Object *with); Heap::CatchContext *newCatchContext(String *exceptionVarName, const ValueRef exceptionValue); diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp index f50ce768ae..55a41a7c6c 100644 --- a/src/qml/jsruntime/qv4dataview.cpp +++ b/src/qml/jsruntime/qv4dataview.cpp @@ -48,7 +48,7 @@ Heap::DataViewCtor::DataViewCtor(QV4::ExecutionContext *scope) ReturnedValue DataViewCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); Scoped buffer(scope, callData->argument(0)); if (!buffer) return scope.engine->throwTypeError(); diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index bfc97b12af..fde0818f0e 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -650,13 +650,13 @@ Heap::DateCtor::DateCtor(QV4::ExecutionContext *scope) ReturnedValue DateCtor::construct(Managed *m, CallData *callData) { + Scope scope(static_cast(m)->engine()); double t = 0; if (callData->argc == 0) t = currentTime(); else if (callData->argc == 1) { - Scope scope(m->engine()); ScopedValue arg(scope, callData->args[0]); if (DateObject *d = arg->asDateObject()) arg = d->date(); @@ -683,13 +683,13 @@ ReturnedValue DateCtor::construct(Managed *m, CallData *callData) t = TimeClip(UTC(t)); } - return Encode(m->engine()->newDateObject(Primitive::fromDouble(t))); + return Encode(scope.engine->newDateObject(Primitive::fromDouble(t))); } ReturnedValue DateCtor::call(Managed *m, CallData *) { double t = currentTime(); - return m->engine()->newString(ToString(t))->asReturnedValue(); + return static_cast(m)->engine()->newString(ToString(t))->asReturnedValue(); } void DatePrototype::init(ExecutionEngine *engine, Object *ctor) diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index bf966e5028..30c7fe188a 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -257,9 +257,9 @@ Heap::ErrorCtor::ErrorCtor(QV4::ExecutionContext *scope, const QString &name) ReturnedValue ErrorCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, callData->argument(0)); - return Encode(m->engine()->newErrorObject(v)); + return Encode(scope.engine->newErrorObject(v)); } ReturnedValue ErrorCtor::call(Managed *that, CallData *callData) @@ -274,9 +274,9 @@ Heap::EvalErrorCtor::EvalErrorCtor(QV4::ExecutionContext *scope) ReturnedValue EvalErrorCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, callData->argument(0)); - return (m->engine()->memoryManager->alloc(m->engine(), v))->asReturnedValue(); + return (scope.engine->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } Heap::RangeErrorCtor::RangeErrorCtor(QV4::ExecutionContext *scope) @@ -286,9 +286,9 @@ Heap::RangeErrorCtor::RangeErrorCtor(QV4::ExecutionContext *scope) ReturnedValue RangeErrorCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, callData->argument(0)); - return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); + return (scope.engine->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } Heap::ReferenceErrorCtor::ReferenceErrorCtor(QV4::ExecutionContext *scope) @@ -298,9 +298,9 @@ Heap::ReferenceErrorCtor::ReferenceErrorCtor(QV4::ExecutionContext *scope) ReturnedValue ReferenceErrorCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, callData->argument(0)); - return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); + return (scope.engine->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } Heap::SyntaxErrorCtor::SyntaxErrorCtor(QV4::ExecutionContext *scope) @@ -310,9 +310,9 @@ Heap::SyntaxErrorCtor::SyntaxErrorCtor(QV4::ExecutionContext *scope) ReturnedValue SyntaxErrorCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, callData->argument(0)); - return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); + return (scope.engine->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } Heap::TypeErrorCtor::TypeErrorCtor(QV4::ExecutionContext *scope) @@ -322,9 +322,9 @@ Heap::TypeErrorCtor::TypeErrorCtor(QV4::ExecutionContext *scope) ReturnedValue TypeErrorCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, callData->argument(0)); - return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); + return (scope.engine->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } Heap::URIErrorCtor::URIErrorCtor(QV4::ExecutionContext *scope) @@ -334,9 +334,9 @@ Heap::URIErrorCtor::URIErrorCtor(QV4::ExecutionContext *scope) ReturnedValue URIErrorCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, callData->argument(0)); - return (m->engine()->memoryManager->alloc(scope.engine, v))->asReturnedValue(); + return (scope.engine->memoryManager->alloc(scope.engine, v))->asReturnedValue(); } void ErrorPrototype::init(ExecutionEngine *engine, Object *ctor, Object *obj) diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 5c5674d380..4f55929193 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -221,7 +221,7 @@ Heap::FunctionCtor::FunctionCtor(QV4::ExecutionContext *scope) // 15.3.2 ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData) { - Scope scope(that->engine()); + Scope scope(static_cast(that)->engine()); Scoped f(scope, static_cast(that)); ScopedContext ctx(scope, scope.engine->currentContext()); QString arguments; @@ -393,7 +393,7 @@ Heap::ScriptFunction::ScriptFunction(QV4::ExecutionContext *scope, Function *fun ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData) { - ExecutionEngine *v4 = that->engine(); + ExecutionEngine *v4 = static_cast(that)->engine(); if (v4->hasException) return Encode::undefined(); CHECK_STACK_LIMITS(v4); @@ -425,7 +425,7 @@ ReturnedValue ScriptFunction::construct(Managed *that, CallData *callData) ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) { - ExecutionEngine *v4 = that->engine(); + ExecutionEngine *v4 = static_cast(that)->engine(); if (v4->hasException) return Encode::undefined(); CHECK_STACK_LIMITS(v4); @@ -475,7 +475,7 @@ Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, F ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) { - ExecutionEngine *v4 = that->engine(); + ExecutionEngine *v4 = static_cast(that)->engine(); if (v4->hasException) return Encode::undefined(); CHECK_STACK_LIMITS(v4); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index c00597d469..b971ca6568 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -186,7 +186,7 @@ struct IndexedBuiltinFunction: FunctionObject static ReturnedValue construct(Managed *m, CallData *) { - return m->engine()->throwTypeError(); + return static_cast(m)->engine()->throwTypeError(); } static ReturnedValue call(Managed *that, CallData *callData); diff --git a/src/qml/jsruntime/qv4managed.cpp b/src/qml/jsruntime/qv4managed.cpp index b783d70163..e2bbda82b6 100644 --- a/src/qml/jsruntime/qv4managed.cpp +++ b/src/qml/jsruntime/qv4managed.cpp @@ -56,11 +56,6 @@ const ManagedVTable Managed::static_vtbl = }; -ExecutionEngine *Managed::engine() const -{ - return internalClass()->engine; -} - QString Managed::className() const { const char *s = 0; diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 99d6cdafbb..a23785837e 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -229,8 +229,6 @@ public: }; Q_MANAGED_TYPE(Invalid) - ExecutionEngine *engine() const; - template T *as() { Q_ASSERT(internalClass()); diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 67bf92d552..dcde8f13f3 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -52,10 +52,10 @@ Heap::NumberCtor::NumberCtor(QV4::ExecutionContext *scope) ReturnedValue NumberCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); double dbl = callData->argc ? callData->args[0].toNumber() : 0.; ScopedValue d(scope, QV4::Primitive::fromDouble(dbl)); - return Encode(m->engine()->newNumberObject(d)); + return Encode(scope.engine->newNumberObject(d)); } ReturnedValue NumberCtor::call(Managed *, CallData *callData) diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 020607a2d0..64cfc24724 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -367,12 +367,12 @@ bool Object::hasOwnProperty(uint index) const ReturnedValue Object::construct(Managed *m, CallData *) { - return m->engine()->throwTypeError(); + return static_cast(m)->engine()->throwTypeError(); } ReturnedValue Object::call(Managed *m, CallData *) { - return m->engine()->throwTypeError(); + return static_cast(m)->engine()->throwTypeError(); } ReturnedValue Object::get(Managed *m, String *name, bool *hasProperty) @@ -466,7 +466,7 @@ ReturnedValue Object::getLookup(Managed *m, Lookup *l) void Object::setLookup(Managed *m, Lookup *l, const ValueRef value) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedObject o(scope, static_cast(m)); ScopedString name(scope, scope.engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); @@ -574,7 +574,7 @@ void Object::advanceIterator(Managed *m, ObjectIterator *it, Heap::String **name PropertyAttributes a = o->internalClass()->propertyData[it->memberIndex]; ++it->memberIndex; if (!(it->flags & ObjectIterator::EnumerableOnly) || a.isEnumerable()) { - *name = m->engine()->newString(n->string); + *name = o->engine()->newString(n->string); *attrs = a; pd->copy(p, a); return; @@ -1096,7 +1096,7 @@ void Object::copyArrayData(Object *other) uint Object::getLength(const Managed *m) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedValue v(scope, static_cast(const_cast(m))->get(scope.engine->id_length)); return v->toUInt32(); } @@ -1157,9 +1157,9 @@ Heap::ArrayObject::ArrayObject(ExecutionEngine *engine, const QStringList &list) ReturnedValue ArrayObject::getLookup(Managed *m, Lookup *l) { - Scope scope(m->engine()); - ScopedString name(scope, m->engine()->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); - if (name->equals(m->engine()->id_length)) { + Scope scope(static_cast(m)->engine()); + ScopedString name(scope, scope.engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]); + if (name->equals(scope.engine->id_length)) { // special case, as the property is on the object itself l->getter = Lookup::arrayLengthGetter; ArrayObject *a = static_cast(m); diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 8762935268..b1bc6ab5c0 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -56,9 +56,9 @@ Heap::ObjectCtor::ObjectCtor(QV4::ExecutionContext *scope) ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData) { - ExecutionEngine *v4 = that->engine(); - Scope scope(v4); ObjectCtor *ctor = static_cast(that); + ExecutionEngine *v4 = ctor->engine(); + Scope scope(v4); if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) { ScopedObject obj(scope, v4->newObject()); ScopedObject proto(scope, ctor->get(v4->id_prototype)); @@ -71,9 +71,11 @@ ReturnedValue ObjectCtor::construct(Managed *that, CallData *callData) ReturnedValue ObjectCtor::call(Managed *m, CallData *callData) { + ObjectCtor *ctor = static_cast(m); + ExecutionEngine *v4 = ctor->engine(); if (!callData->argc || callData->args[0].isUndefined() || callData->args[0].isNull()) - return m->engine()->newObject()->asReturnedValue(); - return RuntimeHelpers::toObject(m->engine(), ValueRef(&callData->args[0])); + return v4->newObject()->asReturnedValue(); + return RuntimeHelpers::toObject(v4, ValueRef(&callData->args[0])); } void ObjectPrototype::init(ExecutionEngine *v4, Object *ctor) diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 1d6a89a647..e4c141c15d 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -677,14 +677,14 @@ ReturnedValue QObjectWrapper::create(ExecutionEngine *engine, QObject *object) QV4::ReturnedValue QObjectWrapper::get(Managed *m, String *name, bool *hasProperty) { QObjectWrapper *that = static_cast(m); - QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(m->engine()); + QQmlContextData *qmlContext = QV4::QmlContextWrapper::callingContext(that->engine()); return that->getQmlProperty(qmlContext, name, IgnoreRevision, hasProperty, /*includeImports*/ true); } void QObjectWrapper::put(Managed *m, String *name, const ValueRef value) { QObjectWrapper *that = static_cast(m); - ExecutionEngine *v4 = m->engine(); + ExecutionEngine *v4 = that->engine(); if (v4->hasException || QQmlData::wasDeleted(that->d()->object)) return; diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index cd1d1563fa..b9d22794bb 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -239,7 +239,7 @@ void Heap::RegExpCtor::clearLastMatch() ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); ScopedContext ctx(scope, scope.engine->currentContext()); ScopedValue r(scope, callData->argument(0)); diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index f7afd004b9..9f49678a3e 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -124,7 +124,7 @@ Heap::QmlBindingWrapper::QmlBindingWrapper(QV4::ExecutionContext *scope, QV4::Ob ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *) { - ExecutionEngine *engine = that->engine(); + ExecutionEngine *engine = static_cast(that)->engine(); CHECK_STACK_LIMITS(engine); Scope scope(engine); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 5ce4b5b33c..aab1505832 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -105,13 +105,10 @@ Property *Heap::StringObject::getIndex(uint index) const bool StringObject::deleteIndexedProperty(Managed *m, uint index) { - ExecutionEngine *v4 = m->engine(); + ExecutionEngine *v4 = static_cast(m)->engine(); Scope scope(v4); Scoped o(scope, m->asStringObject()); - if (!o) { - v4->throwTypeError(); - return false; - } + Q_ASSERT(!!o); if (index < static_cast(o->d()->value.stringValue()->toQString().length())) { if (v4->currentContext()->strictMode) @@ -166,7 +163,7 @@ Heap::StringCtor::StringCtor(QV4::ExecutionContext *scope) ReturnedValue StringCtor::construct(Managed *m, CallData *callData) { - ExecutionEngine *v4 = m->engine(); + ExecutionEngine *v4 = static_cast(m)->engine(); Scope scope(v4); ScopedValue value(scope); if (callData->argc) @@ -178,7 +175,7 @@ ReturnedValue StringCtor::construct(Managed *m, CallData *callData) ReturnedValue StringCtor::call(Managed *m, CallData *callData) { - ExecutionEngine *v4 = m->engine(); + ExecutionEngine *v4 = static_cast(m)->engine(); Scope scope(v4); ScopedValue value(scope); if (callData->argc) diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index 11b675646d..2277d37876 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -201,7 +201,7 @@ Heap::TypedArrayCtor::TypedArrayCtor(QV4::ExecutionContext *scope, TypedArray::T ReturnedValue TypedArrayCtor::construct(Managed *m, CallData *callData) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); Scoped that(scope, static_cast(m)); if (!callData->argc || !callData->args[0].isObject()) { @@ -346,7 +346,7 @@ void TypedArray::markObjects(Heap::Base *that, ExecutionEngine *e) ReturnedValue TypedArray::getIndexed(Managed *m, uint index, bool *hasProperty) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); Scoped a(scope, static_cast(m)); uint bytesPerElement = a->d()->type->bytesPerElement; @@ -363,10 +363,11 @@ ReturnedValue TypedArray::getIndexed(Managed *m, uint index, bool *hasProperty) void TypedArray::putIndexed(Managed *m, uint index, const ValueRef value) { - if (m->engine()->hasException) + ExecutionEngine *v4 = static_cast(m)->engine(); + if (v4->hasException) return; - Scope scope(m->engine()); + Scope scope(v4); Scoped a(scope, static_cast(m)); uint bytesPerElement = a->d()->type->bytesPerElement; diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp index d1289bba7f..784628071b 100644 --- a/src/qml/jsruntime/qv4value.cpp +++ b/src/qml/jsruntime/qv4value.cpp @@ -88,7 +88,8 @@ double Value::toNumberImpl() const if (isString()) return RuntimeHelpers::stringToNumber(stringValue()->toQString()); { - Scope scope(managed()->engine()); + Q_ASSERT(isObject()); + Scope scope(objectValue()->engine()); ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), NUMBER_HINT)); if (scope.engine->hasException) return 0; @@ -123,7 +124,8 @@ QString Value::toQStringNoThrow() const if (isString()) return stringValue()->toQString(); { - Scope scope(managed()->engine()); + Q_ASSERT(isObject()); + Scope scope(objectValue()->engine()); ScopedValue ex(scope); bool caughtException = false; ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT)); @@ -175,7 +177,8 @@ QString Value::toQString() const if (isString()) return stringValue()->toQString(); { - Scope scope(managed()->engine()); + Q_ASSERT(isObject()); + Scope scope(objectValue()->engine()); ScopedValue prim(scope, RuntimeHelpers::toPrimitive(ValueRef::fromRawValue(this), STRING_HINT)); return prim->toQString(); } diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index dda5187b4f..0c16ae18db 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -126,9 +126,9 @@ void QmlContextWrapper::takeContextOwnership(const ValueRef qmlglobal) ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); - QV4::Scope scope(v4); QmlContextWrapper *resource = static_cast(m); + QV4::ExecutionEngine *v4 = resource->engine(); + QV4::Scope scope(v4); // In V8 the JS global object would come _before_ the QML global object, // so simulate that here. @@ -268,11 +268,12 @@ ReturnedValue QmlContextWrapper::get(Managed *m, String *name, bool *hasProperty void QmlContextWrapper::put(Managed *m, String *name, const ValueRef value) { Q_ASSERT(m->as()); - ExecutionEngine *v4 = m->engine(); + QmlContextWrapper *resource = static_cast(m); + ExecutionEngine *v4 = resource->engine(); QV4::Scope scope(v4); if (scope.hasException()) return; - QV4::Scoped wrapper(scope, static_cast(m)); + QV4::Scoped wrapper(scope, resource); PropertyAttributes attrs; Property *pd = wrapper->__getOwnProperty__(name, &attrs); @@ -428,7 +429,7 @@ Heap::QQmlIdObjectsArray::QQmlIdObjectsArray(ExecutionEngine *engine, QV4::QmlCo ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasProperty) { - Scope scope(m->engine()); + Scope scope(static_cast(m)->engine()); Scoped This(scope, static_cast(m)); Scoped contextWrapper(scope, This->d()->contextWrapper); QQmlContextData *context = contextWrapper->getContext(); @@ -446,8 +447,7 @@ ReturnedValue QQmlIdObjectsArray::getIndexed(Managed *m, uint index, bool *hasPr if (hasProperty) *hasProperty = true; - ExecutionEngine *v4 = m->engine(); - QQmlEnginePrivate *ep = v4->qmlEngine() ? QQmlEnginePrivate::get(v4->qmlEngine()) : 0; + QQmlEnginePrivate *ep = scope.engine->qmlEngine() ? QQmlEnginePrivate::get(scope.engine->qmlEngine()) : 0; if (ep) ep->captureProperty(&context->idValues[index].bindings); diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp index 022a60faf4..af955ff15c 100644 --- a/src/qml/qml/qqmllistwrapper.cpp +++ b/src/qml/qml/qqmllistwrapper.cpp @@ -95,8 +95,8 @@ QVariant QmlListWrapper::toVariant() const ReturnedValue QmlListWrapper::get(Managed *m, String *name, bool *hasProperty) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); QmlListWrapper *w = static_cast(m); + QV4::ExecutionEngine *v4 = w->engine(); if (name->equals(v4->id_length) && !w->d()->object.isNull()) { quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0; @@ -115,8 +115,8 @@ ReturnedValue QmlListWrapper::getIndexed(Managed *m, uint index, bool *hasProper Q_UNUSED(hasProperty); Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); QmlListWrapper *w = static_cast(m); + QV4::ExecutionEngine *v4 = w->engine(); quint32 count = w->d()->property.count ? w->d()->property.count(&w->d()->property) : 0; if (index < count && w->d()->property.at) { diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp index a72950e7d8..77d472e0c7 100644 --- a/src/qml/qml/qqmltypewrapper.cpp +++ b/src/qml/qml/qqmltypewrapper.cpp @@ -125,10 +125,10 @@ ReturnedValue QmlTypeWrapper::get(Managed *m, String *name, bool *hasProperty) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); + QV4::ExecutionEngine *v4 = static_cast(m)->engine(); QV4::Scope scope(v4); - Scoped w(scope, static_cast(m)); + Scoped w(scope, static_cast(m)); if (hasProperty) *hasProperty = true; @@ -232,7 +232,7 @@ void QmlTypeWrapper::put(Managed *m, String *name, const ValueRef value) { Q_ASSERT(m->as()); QmlTypeWrapper *w = static_cast(m); - QV4::ExecutionEngine *v4 = m->engine(); + QV4::ExecutionEngine *v4 = w->engine(); if (v4->hasException) return; diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index d36549fcf5..1e138be341 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -287,7 +287,7 @@ ReturnedValue QQmlValueTypeWrapper::get(Managed *m, String *name, bool *hasPrope { Q_ASSERT(m->as()); QQmlValueTypeWrapper *r = static_cast(m); - QV4::ExecutionEngine *v4 = m->engine(); + QV4::ExecutionEngine *v4 = r->engine(); // Note: readReferenceValue() can change the reference->type. if (QQmlValueTypeReference *reference = r->as()) { @@ -340,7 +340,7 @@ ReturnedValue QQmlValueTypeWrapper::get(Managed *m, String *name, bool *hasPrope void QQmlValueTypeWrapper::put(Managed *m, String *name, const ValueRef value) { Q_ASSERT(m->as()); - ExecutionEngine *v4 = m->engine(); + ExecutionEngine *v4 = static_cast(m)->engine(); Scope scope(v4); if (scope.hasException()) return; diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 6d730970b3..7c4413a500 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -872,8 +872,8 @@ bool Node::isNull() const ReturnedValue NamedNodeMap::getIndexed(Managed *m, uint index, bool *hasProperty) { - QV4::ExecutionEngine *v4 = m->engine(); NamedNodeMap *r = m->as(); + QV4::ExecutionEngine *v4 = r->engine(); if (!r) { if (hasProperty) *hasProperty = false; @@ -894,7 +894,7 @@ ReturnedValue NamedNodeMap::get(Managed *m, String *name, bool *hasProperty) { Q_ASSERT(m->as()); NamedNodeMap *r = static_cast(m); - QV4::ExecutionEngine *v4 = m->engine(); + QV4::ExecutionEngine *v4 = r->engine(); name->makeIdentifier(v4); if (name->equals(v4->id_length)) @@ -922,8 +922,8 @@ ReturnedValue NamedNodeMap::create(ExecutionEngine *v4, NodeImpl *data, const QL ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); NodeList *r = static_cast(m); + QV4::ExecutionEngine *v4 = r->engine(); if ((int)index < r->d()->d->children.count()) { if (hasProperty) @@ -938,8 +938,8 @@ ReturnedValue NodeList::getIndexed(Managed *m, uint index, bool *hasProperty) ReturnedValue NodeList::get(Managed *m, String *name, bool *hasProperty) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); NodeList *r = static_cast(m); + QV4::ExecutionEngine *v4 = r->engine(); name->makeIdentifier(v4); @@ -1614,13 +1614,13 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject } static ReturnedValue construct(Managed *that, QV4::CallData *) { - Scope scope(that->engine()); + Scope scope(static_cast(that)->engine()); Scoped ctor(scope, that->as()); if (!ctor) - return that->engine()->throwTypeError(); + return scope.engine->throwTypeError(); QQmlXMLHttpRequest *r = new QQmlXMLHttpRequest(scope.engine, scope.engine->v8Engine->networkAccessManager()); - Scoped w(scope, that->engine()->memoryManager->alloc(that->engine(), r)); + Scoped w(scope, scope.engine->memoryManager->alloc(scope.engine, r)); ScopedObject proto(scope, ctor->d()->proto); w->setPrototype(proto); return w.asReturnedValue(); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 360c560d0b..0878063f2e 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1158,7 +1158,7 @@ void QQmlBindingFunction::initBindingLocation() ReturnedValue QQmlBindingFunction::call(Managed *that, CallData *callData) { - Scope scope(that->engine()); + Scope scope(static_cast(that)->engine()); ScopedFunctionObject function(scope, static_cast(that)->d()->originalFunction); return function->call(callData); } diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 8d9a06ff75..61c3e17c63 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -88,12 +88,12 @@ struct DelegateModelGroupFunction : QV4::FunctionObject static QV4::ReturnedValue construct(QV4::Managed *m, QV4::CallData *) { - return m->engine()->throwTypeError(); + return static_cast(m)->engine()->throwTypeError(); } static QV4::ReturnedValue call(QV4::Managed *that, QV4::CallData *callData) { - QV4::ExecutionEngine *v4 = that->engine(); + QV4::ExecutionEngine *v4 = static_cast(that)->engine(); QV4::Scope scope(v4); QV4::Scoped f(scope, that, QV4::Scoped::Cast); QV4::Scoped o(scope, callData->thisObject); @@ -3282,7 +3282,7 @@ public: static QV4::ReturnedValue getIndexed(QV4::Managed *m, uint index, bool *hasProperty) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); + QV4::ExecutionEngine *v4 = static_cast(m)->engine(); QV4::Scope scope(v4); QV4::Scoped array(scope, static_cast(m)); @@ -3309,7 +3309,7 @@ public: Q_ASSERT(m->as()); QQmlDelegateModelGroupChangeArray *array = static_cast(m); - if (name->equals(m->engine()->id_length)) { + if (name->equals(array->engine()->id_length)) { if (hasProperty) *hasProperty = true; return QV4::Encode(array->count()); diff --git a/src/quick/items/context2d/qquickcontext2d.cpp b/src/quick/items/context2d/qquickcontext2d.cpp index 59e4b021e8..87b42f6f19 100644 --- a/src/quick/items/context2d/qquickcontext2d.cpp +++ b/src/quick/items/context2d/qquickcontext2d.cpp @@ -3094,7 +3094,7 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::proto_get_length(QV4::CallContext QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint index, bool *hasProperty) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); + QV4::ExecutionEngine *v4 = static_cast(m)->engine(); QV4::Scope scope(v4); QV4::Scoped r(scope, static_cast(m)); @@ -3125,7 +3125,7 @@ QV4::ReturnedValue QQuickJSContext2DPixelData::getIndexed(QV4::Managed *m, uint void QQuickJSContext2DPixelData::putIndexed(QV4::Managed *m, uint index, const QV4::ValueRef value) { Q_ASSERT(m->as()); - QV4::ExecutionEngine *v4 = m->engine(); + QV4::ExecutionEngine *v4 = static_cast(m)->engine(); QV4::Scope scope(v4); if (scope.hasException()) return; -- cgit v1.2.3