From 9744e8bd423d528165f5e78704c6e017852b8e9a Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 6 May 2014 09:23:59 +0200 Subject: Convert ExecutionContext to new storage scheme Change-Id: I9fcc13da5360f37cef3149b114ed9263b9b74281 Reviewed-by: Simon Hausmann --- src/qml/jit/qv4assembler.cpp | 10 +- src/qml/jit/qv4assembler_p.h | 4 +- src/qml/jit/qv4isel_masm.cpp | 8 +- src/qml/jsapi/qjsengine.cpp | 2 +- src/qml/jsapi/qjsvalue.cpp | 8 +- src/qml/jsruntime/qv4argumentsobject.cpp | 54 ++-- src/qml/jsruntime/qv4argumentsobject_p.h | 2 +- src/qml/jsruntime/qv4arrayobject.cpp | 152 +++++----- src/qml/jsruntime/qv4booleanobject.cpp | 14 +- src/qml/jsruntime/qv4context.cpp | 184 ++++++------ src/qml/jsruntime/qv4context_p.h | 96 ++++--- src/qml/jsruntime/qv4dateobject.cpp | 152 +++++----- src/qml/jsruntime/qv4debugging.cpp | 22 +- src/qml/jsruntime/qv4engine.cpp | 40 +-- src/qml/jsruntime/qv4errorobject.cpp | 12 +- src/qml/jsruntime/qv4functionobject.cpp | 108 +++---- src/qml/jsruntime/qv4globalobject.cpp | 94 +++--- src/qml/jsruntime/qv4include.cpp | 33 ++- src/qml/jsruntime/qv4jsonobject.cpp | 20 +- src/qml/jsruntime/qv4lookup.cpp | 14 +- src/qml/jsruntime/qv4mathobject.cpp | 48 ++-- src/qml/jsruntime/qv4numberobject.cpp | 56 ++-- src/qml/jsruntime/qv4object.cpp | 26 +- src/qml/jsruntime/qv4objectiterator_p.h | 2 +- src/qml/jsruntime/qv4objectproto.cpp | 88 +++--- src/qml/jsruntime/qv4qobjectwrapper.cpp | 82 +++--- src/qml/jsruntime/qv4regexpobject.cpp | 46 +-- src/qml/jsruntime/qv4runtime.cpp | 108 +++---- src/qml/jsruntime/qv4script.cpp | 42 +-- src/qml/jsruntime/qv4sequenceobject.cpp | 24 +- src/qml/jsruntime/qv4sequenceobject_p.h | 2 +- src/qml/jsruntime/qv4stringobject.cpp | 144 +++++----- src/qml/jsruntime/qv4variantobject.cpp | 14 +- src/qml/jsruntime/qv4vme_moth.cpp | 48 ++-- src/qml/qml/qqmlcomponent.cpp | 16 +- src/qml/qml/qqmlcontextwrapper.cpp | 2 +- src/qml/qml/qqmljavascriptexpression.cpp | 2 +- src/qml/qml/qqmllocale.cpp | 252 ++++++++-------- src/qml/qml/qqmllocale_p.h | 2 +- src/qml/qml/qqmlvaluetypewrapper.cpp | 2 +- src/qml/qml/qqmlxmlhttprequest.cpp | 152 +++++----- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 476 +++++++++++++++---------------- src/qml/qml/v8/qv4domerrors_p.h | 6 +- src/qml/qml/v8/qv8engine.cpp | 4 +- src/qml/types/qqmldelegatemodel.cpp | 18 +- src/qml/types/qquickworkerscript.cpp | 6 +- src/qml/util/qqmladaptormodel.cpp | 28 +- 47 files changed, 1371 insertions(+), 1354 deletions(-) (limited to 'src/qml') diff --git a/src/qml/jit/qv4assembler.cpp b/src/qml/jit/qv4assembler.cpp index 7ce682490d..4539714f40 100644 --- a/src/qml/jit/qv4assembler.cpp +++ b/src/qml/jit/qv4assembler.cpp @@ -194,18 +194,18 @@ Assembler::Pointer Assembler::loadArgLocalAddress(RegisterID baseReg, IR::ArgLoc int scope = al->scope; RegisterID context = ContextRegister; if (scope) { - loadPtr(Address(ContextRegister, qOffsetOf(ExecutionContext, outer)), baseReg); + loadPtr(Address(ContextRegister, qOffsetOf(ExecutionContext::Data, outer)), baseReg); --scope; context = baseReg; while (scope) { - loadPtr(Address(context, qOffsetOf(ExecutionContext, outer)), context); + loadPtr(Address(context, qOffsetOf(ExecutionContext::Data, outer)), context); --scope; } } switch (al->kind) { case IR::ArgLocal::Formal: case IR::ArgLocal::ScopedFormal: { - loadPtr(Address(context, qOffsetOf(ExecutionContext, callData)), baseReg); + loadPtr(Address(context, qOffsetOf(ExecutionContext::Data, callData)), baseReg); offset = sizeof(CallData) + (al->index - 1) * sizeof(Value); } break; case IR::ArgLocal::Local: @@ -221,7 +221,7 @@ Assembler::Pointer Assembler::loadArgLocalAddress(RegisterID baseReg, IR::ArgLoc Assembler::Pointer Assembler::loadStringAddress(RegisterID reg, const QString &string) { - loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, compilationUnit)), Assembler::ScratchRegister); + loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, compilationUnit)), Assembler::ScratchRegister); loadPtr(Address(Assembler::ScratchRegister, qOffsetOf(QV4::CompiledData::CompilationUnit, runtimeStrings)), reg); const int id = _isel->registerString(string); return Pointer(reg, id * sizeof(QV4::StringValue)); @@ -229,7 +229,7 @@ Assembler::Pointer Assembler::loadStringAddress(RegisterID reg, const QString &s void Assembler::loadStringRef(RegisterID reg, const QString &string) { - loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, compilationUnit)), reg); + loadPtr(Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, compilationUnit)), reg); loadPtr(Address(reg, qOffsetOf(QV4::CompiledData::CompilationUnit, runtimeStrings)), reg); const int id = _isel->registerString(string); addPtr(TrustedImmPtr(id * sizeof(QV4::StringValue)), reg); diff --git a/src/qml/jit/qv4assembler_p.h b/src/qml/jit/qv4assembler_p.h index faef4fd168..5e1f162f39 100644 --- a/src/qml/jit/qv4assembler_p.h +++ b/src/qml/jit/qv4assembler_p.h @@ -775,7 +775,7 @@ public: void leaveStandardStackFrame(); void checkException() { - loadPtr(Address(ContextRegister, qOffsetOf(QV4::ExecutionContext, engine)), ScratchRegister); + loadPtr(Address(ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, engine)), ScratchRegister); load32(Address(ScratchRegister, qOffsetOf(QV4::ExecutionEngine, hasException)), ScratchRegister); Jump exceptionThrown = branch32(NotEqual, ScratchRegister, TrustedImm32(0)); if (catchBlock) @@ -1201,7 +1201,7 @@ void Assembler::copyValue(Result result, IR::Expr* source) template inline void prepareRelativeCall(const T &, Assembler *){} template <> inline void prepareRelativeCall(const RelativeCall &relativeCall, Assembler *as) { - as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, lookups)), + as->loadPtr(Assembler::Address(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, lookups)), relativeCall.addr.base); } diff --git a/src/qml/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp index 30df7bfe3b..6091a5336b 100644 --- a/src/qml/jit/qv4isel_masm.cpp +++ b/src/qml/jit/qv4isel_masm.cpp @@ -248,7 +248,7 @@ void InstructionSelection::run(int functionIndex) #endif const int locals = _as->stackLayout().calculateJSStackFrameSize(); - _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister); + _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext::Data, engine)), Assembler::ScratchRegister); _as->loadPtr(Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop)), Assembler::LocalsRegister); _as->addPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister); _as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop))); @@ -264,7 +264,7 @@ void InstructionSelection::run(int functionIndex) foreach (IR::Stmt *s, _block->statements()) { if (s->location.isValid()) { if (int(s->location.startLine) != lastLine) { - Assembler::Address lineAddr(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext, lineNumber)); + Assembler::Address lineAddr(Assembler::ContextRegister, qOffsetOf(QV4::ExecutionContext::Data, lineNumber)); _as->store32(Assembler::TrustedImm32(s->location.startLine), lineAddr); lastLine = s->location.startLine; } @@ -544,7 +544,7 @@ void InstructionSelection::callValue(IR::Expr *value, IR::ExprList *args, IR::Ex void InstructionSelection::loadThisObject(IR::Expr *temp) { - _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, callData)), Assembler::ScratchRegister); + _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext::Data, callData)), Assembler::ScratchRegister); #if defined(VALUE_FITS_IN_REGISTER) _as->load64(Pointer(Assembler::ScratchRegister, qOffsetOf(CallData, thisObject)), Assembler::ReturnValueRegister); @@ -1461,7 +1461,7 @@ void InstructionSelection::visitRet(IR::Ret *s) const int locals = _as->stackLayout().calculateJSStackFrameSize(); _as->subPtr(Assembler::TrustedImm32(sizeof(QV4::Value)*locals), Assembler::LocalsRegister); - _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext, engine)), Assembler::ScratchRegister); + _as->loadPtr(Address(Assembler::ContextRegister, qOffsetOf(ExecutionContext::Data, engine)), Assembler::ScratchRegister); _as->storePtr(Assembler::LocalsRegister, Address(Assembler::ScratchRegister, qOffsetOf(ExecutionEngine, jsStackTop))); _as->leaveStandardStackFrame(); diff --git a/src/qml/jsapi/qjsengine.cpp b/src/qml/jsapi/qjsengine.cpp index 3c3a32370c..929361bf72 100644 --- a/src/qml/jsapi/qjsengine.cpp +++ b/src/qml/jsapi/qjsengine.cpp @@ -309,7 +309,7 @@ QJSValue QJSEngine::evaluate(const QString& program, const QString& fileName, in QV4::ScopedValue result(scope); QV4::Script script(ctx, program, fileName, lineNumber); - script.strictMode = ctx->strictMode; + script.strictMode = ctx->d()->strictMode; script.inheritContext = true; script.parse(); if (!scope.engine->hasException) diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index 502fa1e64f..04e2d2802c 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -385,7 +385,7 @@ double QJSValue::toNumber() const QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; double dbl = d->value.toNumber(); - if (ctx && ctx->engine->hasException) { + if (ctx && ctx->d()->engine->hasException) { ctx->catchException(); return 0; } @@ -411,7 +411,7 @@ bool QJSValue::toBool() const QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; bool b = d->value.toBoolean(); - if (ctx && ctx->engine->hasException) { + if (ctx && ctx->d()->engine->hasException) { ctx->catchException(); return false; } @@ -437,7 +437,7 @@ qint32 QJSValue::toInt() const QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; qint32 i = d->value.toInt32(); - if (ctx && ctx->engine->hasException) { + if (ctx && ctx->d()->engine->hasException) { ctx->catchException(); return 0; } @@ -463,7 +463,7 @@ quint32 QJSValue::toUInt() const QV4::ExecutionContext *ctx = d->engine ? d->engine->currentContext() : 0; quint32 u = d->value.toUInt32(); - if (ctx && ctx->engine->hasException) { + if (ctx && ctx->d()->engine->hasException) { ctx->catchException(); return 0; } diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index 092d151409..11e15d8d1b 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -47,34 +47,34 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(ArgumentsObject); ArgumentsObject::ArgumentsObject(CallContext *context) - : Object(context->strictMode ? context->engine->strictArgumentsObjectClass : context->engine->argumentsObjectClass) + : Object(context->d()->strictMode ? context->d()->engine->strictArgumentsObjectClass : context->d()->engine->argumentsObjectClass) { d()->context = context; d()->fullyCreated = false; - ExecutionEngine *v4 = context->engine; + ExecutionEngine *v4 = context->d()->engine; Scope scope(v4); ScopedObject protectThis(scope, this); setArrayType(ArrayData::Complex); - if (context->strictMode) { - Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->engine->id_callee)); - Q_ASSERT(CallerPropertyIndex == internalClass()->find(context->engine->id_caller)); + if (context->d()->strictMode) { + Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->d()->engine->id_callee)); + Q_ASSERT(CallerPropertyIndex == internalClass()->find(context->d()->engine->id_caller)); propertyAt(CalleePropertyIndex)->value = v4->thrower; propertyAt(CalleePropertyIndex)->set = v4->thrower; propertyAt(CallerPropertyIndex)->value = v4->thrower; propertyAt(CallerPropertyIndex)->set = v4->thrower; - arrayReserve(context->callData->argc); - arrayPut(0, context->callData->args, context->callData->argc); + arrayReserve(context->d()->callData->argc); + arrayPut(0, context->d()->callData->args, context->d()->callData->argc); d()->fullyCreated = true; } else { setHasAccessorProperty(); - Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->engine->id_callee)); + Q_ASSERT(CalleePropertyIndex == internalClass()->find(context->d()->engine->id_callee)); memberData()[CalleePropertyIndex] = context->function->asReturnedValue(); } - Q_ASSERT(LengthPropertyIndex == internalClass()->find(context->engine->id_length)); + Q_ASSERT(LengthPropertyIndex == internalClass()->find(context->d()->engine->id_length)); memberData()[LengthPropertyIndex] = Primitive::fromInt32(context->realArgumentCount); Q_ASSERT(internalClass()->vtable == staticVTable()); @@ -86,15 +86,15 @@ void ArgumentsObject::fullyCreate() return; uint numAccessors = qMin((int)context()->function->formalParameterCount(), context()->realArgumentCount); - uint argCount = qMin(context()->realArgumentCount, context()->callData->argc); + uint argCount = qMin(context()->realArgumentCount, context()->d()->callData->argc); ArrayData::realloc(this, ArrayData::Sparse, 0, argCount, true); - context()->engine->requireArgumentsAccessors(numAccessors); + context()->d()->engine->requireArgumentsAccessors(numAccessors); mappedArguments().ensureIndex(engine(), numAccessors); for (uint i = 0; i < (uint)numAccessors; ++i) { - mappedArguments()[i] = context()->callData->args[i]; - arraySet(i, context()->engine->argumentsAccessors[i], Attr_Accessor); + mappedArguments()[i] = context()->d()->callData->args[i]; + arraySet(i, context()->d()->engine->argumentsAccessors[i], Attr_Accessor); } - arrayPut(numAccessors, context()->callData->args + numAccessors, argCount - numAccessors); + arrayPut(numAccessors, context()->d()->callData->args + numAccessors, argCount - numAccessors); for (uint i = numAccessors; i < argCount; ++i) setArrayAttributes(i, Attr_Data); @@ -112,7 +112,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const bool isMapped = false; uint numAccessors = qMin((int)context()->function->formalParameterCount(), context()->realArgumentCount); if (pd && index < (uint)numAccessors) - isMapped = arrayData()->attributes(index).isAccessor() && pd->getter() == context()->engine->argumentsAccessors[index].getter(); + isMapped = arrayData()->attributes(index).isAccessor() && pd->getter() == context()->d()->engine->argumentsAccessors[index].getter(); if (isMapped) { mapAttrs = arrayData()->attributes(index); @@ -122,10 +122,10 @@ bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const pd->value = mappedArguments()[index]; } - bool strict = ctx->strictMode; - ctx->strictMode = false; + bool strict = ctx->d()->strictMode; + ctx->d()->strictMode = false; bool result = Object::defineOwnProperty2(ctx, index, desc, attrs); - ctx->strictMode = strict; + ctx->d()->strictMode = strict; if (isMapped && attrs.isData()) { ScopedCallData callData(scope, 1); @@ -140,7 +140,7 @@ bool ArgumentsObject::defineOwnProperty(ExecutionContext *ctx, uint index, const } } - if (ctx->strictMode && !result) + if (ctx->d()->strictMode && !result) return ctx->throwTypeError(); return result; } @@ -151,10 +151,10 @@ ReturnedValue ArgumentsObject::getIndexed(Managed *m, uint index, bool *hasPrope if (args->fullyCreated()) return Object::getIndexed(m, index, hasProperty); - if (index < static_cast(args->context()->callData->argc)) { + if (index < static_cast(args->context()->d()->callData->argc)) { if (hasProperty) *hasProperty = true; - return args->context()->callData->args[index].asReturnedValue(); + return args->context()->d()->callData->args[index].asReturnedValue(); } if (hasProperty) *hasProperty = false; @@ -164,7 +164,7 @@ ReturnedValue ArgumentsObject::getIndexed(Managed *m, uint index, bool *hasPrope void ArgumentsObject::putIndexed(Managed *m, uint index, const ValueRef value) { ArgumentsObject *args = static_cast(m); - if (!args->fullyCreated() && index >= static_cast(args->context()->callData->argc)) + if (!args->fullyCreated() && index >= static_cast(args->context()->d()->callData->argc)) args->fullyCreate(); if (args->fullyCreated()) { @@ -172,7 +172,7 @@ void ArgumentsObject::putIndexed(Managed *m, uint index, const ValueRef value) return; } - args->context()->callData->args[index] = value; + args->context()->d()->callData->args[index] = value; } bool ArgumentsObject::deleteIndexedProperty(Managed *m, uint index) @@ -190,7 +190,7 @@ PropertyAttributes ArgumentsObject::queryIndexed(const Managed *m, uint index) return Object::queryIndexed(m, index); uint numAccessors = qMin((int)args->context()->function->formalParameterCount(), args->context()->realArgumentCount); - uint argCount = qMin(args->context()->realArgumentCount, args->context()->callData->argc); + uint argCount = qMin(args->context()->realArgumentCount, args->context()->d()->callData->argc); if (index >= argCount) return PropertyAttributes(); if (index >= numAccessors) @@ -209,7 +209,7 @@ ReturnedValue ArgumentsGetterFunction::call(Managed *getter, CallData *callData) if (!o) return v4->currentContext()->throwTypeError(); - Q_ASSERT(g->index() < static_cast(o->context()->callData->argc)); + Q_ASSERT(g->index() < static_cast(o->context()->d()->callData->argc)); return o->context()->argument(g->index()); } @@ -224,8 +224,8 @@ ReturnedValue ArgumentsSetterFunction::call(Managed *setter, CallData *callData) if (!o) return v4->currentContext()->throwTypeError(); - Q_ASSERT(s->index() < static_cast(o->context()->callData->argc)); - o->context()->callData->args[s->index()] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined(); + Q_ASSERT(s->index() < static_cast(o->context()->d()->callData->argc)); + o->context()->d()->callData->args[s->index()] = callData->argc ? callData->args[0].asReturnedValue() : Encode::undefined(); return Encode::undefined(); } diff --git a/src/qml/jsruntime/qv4argumentsobject_p.h b/src/qml/jsruntime/qv4argumentsobject_p.h index 50eb776359..b32e935cb4 100644 --- a/src/qml/jsruntime/qv4argumentsobject_p.h +++ b/src/qml/jsruntime/qv4argumentsobject_p.h @@ -115,7 +115,7 @@ struct ArgumentsObject: Object { static bool isNonStrictArgumentsObject(Managed *m) { return m->internalClass()->vtable->type == Type_ArgumentsObject && - !static_cast(m)->context()->strictMode; + !static_cast(m)->context()->d()->strictMode; } enum { diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 74712f9b3f..88700e17d0 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -122,21 +122,21 @@ void ArrayPrototype::init(ExecutionEngine *engine, ObjectRef ctor) ReturnedValue ArrayPrototype::method_isArray(CallContext *ctx) { - bool isArray = ctx->callData->argc && ctx->callData->args[0].asArrayObject(); + bool isArray = ctx->d()->callData->argc && ctx->d()->callData->args[0].asArrayObject(); return Encode(isArray); } ReturnedValue ArrayPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->callData->thisObject, ScopedObject::Convert); - if (ctx->engine->hasException) + ScopedObject o(scope, ctx->d()->callData->thisObject, ScopedObject::Convert); + if (ctx->d()->engine->hasException) return Encode::undefined(); - ScopedString s(scope, ctx->engine->newString(QStringLiteral("join"))); + ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("join"))); ScopedFunctionObject f(scope, o->get(s)); if (!!f) { ScopedCallData d(scope, 0); - d->thisObject = ctx->callData->thisObject; + d->thisObject = ctx->d()->callData->thisObject; return f->call(d); } return ObjectPrototype::method_toString(ctx); @@ -150,9 +150,9 @@ ReturnedValue ArrayPrototype::method_toLocaleString(CallContext *ctx) ReturnedValue ArrayPrototype::method_concat(CallContext *ctx) { Scope scope(ctx); - ScopedObject result(scope, ctx->engine->newArrayObject()); + ScopedObject result(scope, ctx->d()->engine->newArrayObject()); - ScopedObject thisObject(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject thisObject(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!thisObject) return Encode::undefined(); ScopedArrayObject instance(scope, thisObject); @@ -165,9 +165,9 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx) ScopedArrayObject elt(scope); ScopedObject eltAsObj(scope); ScopedValue entry(scope); - for (int i = 0; i < ctx->callData->argc; ++i) { - eltAsObj = ctx->callData->args[i]; - elt = ctx->callData->args[i]; + for (int i = 0; i < ctx->d()->callData->argc; ++i) { + eltAsObj = ctx->d()->callData->args[i]; + elt = ctx->d()->callData->args[i]; if (elt) { uint n = elt->getLength(); uint newLen = ArrayData::append(result.getPointer(), elt.getPointer(), n); @@ -179,7 +179,7 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx) result->putIndexed(startIndex + i, entry); } } else { - result->arraySet(result->getLength(), ValueRef(ctx->callData->args[i])); + result->arraySet(result->getLength(), ValueRef(ctx->d()->callData->args[i])); } } @@ -197,12 +197,12 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx) else r4 = arg->toQString(); - ScopedObject self(scope, ctx->callData->thisObject); - ScopedValue length(scope, self->get(ctx->engine->id_length)); + ScopedObject self(scope, ctx->d()->callData->thisObject); + ScopedValue length(scope, self->get(ctx->d()->engine->id_length)); const quint32 r2 = length->isUndefined() ? 0 : length->toUInt32(); if (!r2) - return ctx->engine->newString(QString())->asReturnedValue(); + return ctx->d()->engine->newString(QString())->asReturnedValue(); QString R; @@ -223,7 +223,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx) // // crazy! // - ScopedString name(scope, ctx->engine->newString(QStringLiteral("0"))); + ScopedString name(scope, ctx->d()->engine->newString(QStringLiteral("0"))); ScopedValue r6(scope, self->get(name)); if (!r6->isNullOrUndefined()) R = r6->toString(ctx)->toQString(); @@ -242,20 +242,20 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx) } } - return ctx->engine->newString(R)->asReturnedValue(); + return ctx->d()->engine->newString(R)->asReturnedValue(); } ReturnedValue ArrayPrototype::method_pop(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); if (!len) { if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0))); + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0))); return Encode::undefined(); } @@ -269,14 +269,14 @@ ReturnedValue ArrayPrototype::method_pop(CallContext *ctx) if (instance->isArrayObject()) instance->setArrayLength(len - 1); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1))); + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1))); return result.asReturnedValue(); } ReturnedValue ArrayPrototype::method_push(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -284,38 +284,38 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx) uint len = instance->getLength(); - if (len + ctx->callData->argc < len) { + if (len + ctx->d()->callData->argc < len) { // ughh... double l = len; ScopedString s(scope); - for (int i = 0; i < ctx->callData->argc; ++i) { + for (int i = 0; i < ctx->d()->callData->argc; ++i) { s = Primitive::fromDouble(l + i).toString(ctx); - instance->put(s, ctx->callData->args[i]); + instance->put(s, ctx->d()->callData->args[i]); } - double newLen = l + ctx->callData->argc; + double newLen = l + ctx->d()->callData->argc; if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen))); + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen))); else { - ScopedString str(scope, ctx->engine->newString(QStringLiteral("Array.prototype.push: Overflow"))); + ScopedString str(scope, ctx->d()->engine->newString(QStringLiteral("Array.prototype.push: Overflow"))); return ctx->throwRangeError(str); } return Encode(newLen); } - if (!ctx->callData->argc) { + if (!ctx->d()->callData->argc) { ; } else if (!instance->protoHasArray() && instance->arrayData()->length() <= len && instance->arrayType() == ArrayData::Simple) { - instance->arrayData()->vtable()->putArray(instance.getPointer(), len, ctx->callData->args, ctx->callData->argc); + instance->arrayData()->vtable()->putArray(instance.getPointer(), len, ctx->d()->callData->args, ctx->d()->callData->argc); len = instance->arrayData()->length(); } else { - for (int i = 0; i < ctx->callData->argc; ++i) - instance->putIndexed(len + i, ctx->callData->args[i]); - len += ctx->callData->argc; + for (int i = 0; i < ctx->d()->callData->argc; ++i) + instance->putIndexed(len + i, ctx->d()->callData->args[i]); + len += ctx->d()->callData->argc; } if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len))); + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len))); return Encode(len); } @@ -323,7 +323,7 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx) ReturnedValue ArrayPrototype::method_reverse(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); uint length = instance->getLength(); @@ -355,7 +355,7 @@ ReturnedValue ArrayPrototype::method_reverse(CallContext *ctx) ReturnedValue ArrayPrototype::method_shift(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -365,7 +365,7 @@ ReturnedValue ArrayPrototype::method_shift(CallContext *ctx) if (!len) { if (!instance->isArrayObject()) - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0))); + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromInt32(0))); return Encode::undefined(); } @@ -399,18 +399,18 @@ ReturnedValue ArrayPrototype::method_shift(CallContext *ctx) if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len - 1); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1))); + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - 1))); return result.asReturnedValue(); } ReturnedValue ArrayPrototype::method_slice(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!o) return Encode::undefined(); - Scoped result(scope, ctx->engine->newArrayObject()); + Scoped result(scope, ctx->d()->engine->newArrayObject()); uint len = o->getLength(); double s = ScopedValue(scope, ctx->argument(0))->toInteger(); uint start; @@ -421,8 +421,8 @@ ReturnedValue ArrayPrototype::method_slice(CallContext *ctx) else start = (uint) s; uint end = len; - if (ctx->callData->argc > 1 && !ctx->callData->args[1].isUndefined()) { - double e = ctx->callData->args[1].toInteger(); + if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) { + double e = ctx->d()->callData->args[1].toInteger(); if (e < 0) end = (uint)qMax(len + e, 0.); else if (e > len) @@ -448,7 +448,7 @@ ReturnedValue ArrayPrototype::method_slice(CallContext *ctx) ReturnedValue ArrayPrototype::method_sort(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -456,18 +456,18 @@ ReturnedValue ArrayPrototype::method_sort(CallContext *ctx) ScopedValue comparefn(scope, ctx->argument(0)); ArrayData::sort(ctx, instance, comparefn, len); - return ctx->callData->thisObject.asReturnedValue(); + return ctx->d()->callData->thisObject.asReturnedValue(); } ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); - Scoped newArray(scope, ctx->engine->newArrayObject()); + Scoped newArray(scope, ctx->d()->engine->newArrayObject()); double rs = ScopedValue(scope, ctx->argument(0))->toInteger(); uint start; @@ -490,7 +490,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) } newArray->setArrayLengthUnchecked(deleteCount); - uint itemCount = ctx->callData->argc < 2 ? 0 : ctx->callData->argc - 2; + uint itemCount = ctx->d()->callData->argc < 2 ? 0 : ctx->d()->callData->argc - 2; if (itemCount < deleteCount) { for (uint k = start; k < len - deleteCount; ++k) { @@ -528,13 +528,13 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) } for (uint i = 0; i < itemCount; ++i) { - instance->putIndexed(start + i, ctx->callData->args[i + 2]); + instance->putIndexed(start + i, ctx->d()->callData->args[i + 2]); if (scope.hasException()) return Encode::undefined(); } - ctx->strictMode = true; - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount))); + ctx->d()->strictMode = true; + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(len - deleteCount + itemCount))); return newArray.asReturnedValue(); } @@ -542,7 +542,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -551,26 +551,26 @@ ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx) uint len = instance->getLength(); if (!instance->protoHasArray() && !instance->arrayData()->hasAttributes() && instance->arrayData()->length() <= len) { - instance->arrayData()->vtable()->push_front(instance.getPointer(), ctx->callData->args, ctx->callData->argc); + instance->arrayData()->vtable()->push_front(instance.getPointer(), ctx->d()->callData->args, ctx->d()->callData->argc); } else { ScopedValue v(scope); for (uint k = len; k > 0; --k) { bool exists; v = instance->getIndexed(k - 1, &exists); if (exists) - instance->putIndexed(k + ctx->callData->argc - 1, v); + instance->putIndexed(k + ctx->d()->callData->argc - 1, v); else - instance->deleteIndexedProperty(k + ctx->callData->argc - 1); + instance->deleteIndexedProperty(k + ctx->d()->callData->argc - 1); } - for (int i = 0; i < ctx->callData->argc; ++i) - instance->putIndexed(i, ctx->callData->args[i]); + for (int i = 0; i < ctx->d()->callData->argc; ++i) + instance->putIndexed(i, ctx->d()->callData->args[i]); } - uint newLen = len + ctx->callData->argc; + uint newLen = len + ctx->d()->callData->argc; if (instance->isArrayObject()) instance->setArrayLengthUnchecked(newLen); else - instance->put(ctx->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen))); + instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen))); return Encode(newLen); } @@ -579,18 +579,18 @@ ReturnedValue ArrayPrototype::method_indexOf(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); if (!len) return Encode(-1); - ScopedValue searchValue(scope, ctx->callData->argument(0)); + ScopedValue searchValue(scope, ctx->d()->callData->argument(0)); uint fromIndex = 0; - if (ctx->callData->argc >= 2) { - double f = ctx->callData->args[1].toInteger(); + if (ctx->d()->callData->argc >= 2) { + double f = ctx->d()->callData->args[1].toInteger(); if (scope.hasException()) return Encode::undefined(); if (f >= len) @@ -650,7 +650,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); @@ -660,13 +660,13 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx) ScopedValue searchValue(scope); uint fromIndex = len; - if (ctx->callData->argc >= 1) + if (ctx->d()->callData->argc >= 1) searchValue = ctx->argument(0); else searchValue = Primitive::undefinedValue(); - if (ctx->callData->argc >= 2) { - double f = ctx->callData->args[1].toInteger(); + if (ctx->d()->callData->argc >= 2) { + double f = ctx->d()->callData->args[1].toInteger(); if (scope.hasException()) return Encode::undefined(); if (f > 0) @@ -695,7 +695,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx) ReturnedValue ArrayPrototype::method_every(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -729,7 +729,7 @@ ReturnedValue ArrayPrototype::method_every(CallContext *ctx) ReturnedValue ArrayPrototype::method_some(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -763,7 +763,7 @@ ReturnedValue ArrayPrototype::method_some(CallContext *ctx) ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -794,7 +794,7 @@ ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx) ReturnedValue ArrayPrototype::method_map(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -804,7 +804,7 @@ ReturnedValue ArrayPrototype::method_map(CallContext *ctx) if (!callback) return ctx->throwTypeError(); - Scoped a(scope, ctx->engine->newArrayObject()); + Scoped a(scope, ctx->d()->engine->newArrayObject()); a->arrayReserve(len); a->setArrayLengthUnchecked(len); @@ -831,7 +831,7 @@ ReturnedValue ArrayPrototype::method_map(CallContext *ctx) ReturnedValue ArrayPrototype::method_filter(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -841,7 +841,7 @@ ReturnedValue ArrayPrototype::method_filter(CallContext *ctx) if (!callback) return ctx->throwTypeError(); - Scoped a(scope, ctx->engine->newArrayObject()); + Scoped a(scope, ctx->d()->engine->newArrayObject()); a->arrayReserve(len); ScopedValue selected(scope); @@ -872,7 +872,7 @@ ReturnedValue ArrayPrototype::method_filter(CallContext *ctx) ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -886,7 +886,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx) ScopedValue acc(scope); ScopedValue v(scope); - if (ctx->callData->argc > 1) { + if (ctx->d()->callData->argc > 1) { acc = ctx->argument(1); } else { bool kPresent = false; @@ -922,7 +922,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx) ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx) { Scope scope(ctx); - Scoped instance(scope, ctx->callData->thisObject.toObject(ctx)); + Scoped instance(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!instance) return Encode::undefined(); @@ -933,7 +933,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx) return ctx->throwTypeError(); if (len == 0) { - if (ctx->callData->argc == 1) + if (ctx->d()->callData->argc == 1) return ctx->throwTypeError(); return ctx->argument(1); } @@ -941,7 +941,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx) uint k = len; ScopedValue acc(scope); ScopedValue v(scope); - if (ctx->callData->argc > 1) { + if (ctx->d()->callData->argc > 1) { acc = ctx->argument(1); } else { bool kPresent = false; diff --git a/src/qml/jsruntime/qv4booleanobject.cpp b/src/qml/jsruntime/qv4booleanobject.cpp index b2851abd7d..f1b4bbc901 100644 --- a/src/qml/jsruntime/qv4booleanobject.cpp +++ b/src/qml/jsruntime/qv4booleanobject.cpp @@ -80,26 +80,26 @@ void BooleanPrototype::init(ExecutionEngine *engine, ObjectRef ctor) ReturnedValue BooleanPrototype::method_toString(CallContext *ctx) { bool result; - if (ctx->callData->thisObject.isBoolean()) { - result = ctx->callData->thisObject.booleanValue(); + if (ctx->d()->callData->thisObject.isBoolean()) { + result = ctx->d()->callData->thisObject.booleanValue(); } else { Scope scope(ctx); - Scoped thisObject(scope, ctx->callData->thisObject); + Scoped thisObject(scope, ctx->d()->callData->thisObject); if (!thisObject) return ctx->throwTypeError(); result = thisObject->value().booleanValue(); } - return Encode(ctx->engine->newString(QLatin1String(result ? "true" : "false"))); + return Encode(ctx->d()->engine->newString(QLatin1String(result ? "true" : "false"))); } ReturnedValue BooleanPrototype::method_valueOf(CallContext *ctx) { - if (ctx->callData->thisObject.isBoolean()) - return ctx->callData->thisObject.asReturnedValue(); + if (ctx->d()->callData->thisObject.isBoolean()) + return ctx->d()->callData->thisObject.asReturnedValue(); Scope scope(ctx); - Scoped thisObject(scope, ctx->callData->thisObject); + Scoped thisObject(scope, ctx->d()->callData->thisObject); if (!thisObject) return ctx->throwTypeError(); diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 655df13e27..528ca97208 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -57,19 +57,19 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData { Q_ASSERT(function->function()); - CallContext *c = static_cast(engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc))); - new (c) CallContext(engine, Type_CallContext); + CallContext *c = static_cast(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(function, callData->argc))); + new (c) CallContext(d()->engine, Type_CallContext); c->function = function; c->realArgumentCount = callData->argc; - c->strictMode = function->strictMode(); - c->outer = function->scope(); + c->d()->strictMode = function->strictMode(); + c->d()->outer = function->scope(); c->activation = 0; - c->compilationUnit = function->function()->compilationUnit; - c->lookups = c->compilationUnit->runtimeLookups; + c->d()->compilationUnit = function->function()->compilationUnit; + c->d()->lookups = c->d()->compilationUnit->runtimeLookups; c->locals = (Value *)((quintptr(c + 1) + 7) & ~7); const CompiledData::Function *compiledFunction = function->function()->compiledFunction; @@ -77,31 +77,31 @@ CallContext *ExecutionContext::newCallContext(FunctionObject *function, CallData if (nLocals) std::fill(c->locals, c->locals + nLocals, Primitive::undefinedValue()); - c->callData = reinterpret_cast(c->locals + nLocals); - ::memcpy(c->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value)); + c->d()->callData = reinterpret_cast(c->locals + nLocals); + ::memcpy(c->d()->callData, callData, sizeof(CallData) + (callData->argc - 1) * sizeof(Value)); if (callData->argc < static_cast(compiledFunction->nFormals)) - std::fill(c->callData->args + c->callData->argc, c->callData->args + compiledFunction->nFormals, Primitive::undefinedValue()); - c->callData->argc = qMax((uint)callData->argc, compiledFunction->nFormals); + std::fill(c->d()->callData->args + c->d()->callData->argc, c->d()->callData->args + compiledFunction->nFormals, Primitive::undefinedValue()); + c->d()->callData->argc = qMax((uint)callData->argc, compiledFunction->nFormals); return c; } WithContext *ExecutionContext::newWithContext(ObjectRef with) { - WithContext *w = new (engine->memoryManager) WithContext(engine, with); + WithContext *w = new (d()->engine->memoryManager) WithContext(d()->engine, with); return w; } CatchContext *ExecutionContext::newCatchContext(const StringRef exceptionVarName, const ValueRef exceptionValue) { - CatchContext *c = new (engine->memoryManager) CatchContext(engine, exceptionVarName, exceptionValue); + CatchContext *c = new (d()->engine->memoryManager) CatchContext(d()->engine, exceptionVarName, exceptionValue); return c; } CallContext *ExecutionContext::newQmlContext(FunctionObject *f, ObjectRef qml) { - CallContext *c = static_cast(engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0))); - new (c) CallContext(engine, qml, f); + CallContext *c = static_cast(d()->engine->memoryManager->allocManaged(requiredMemoryForExecutionContect(f, 0))); + new (c) CallContext(d()->engine, qml, f); return c; } @@ -112,17 +112,17 @@ void ExecutionContext::createMutableBinding(const StringRef name, bool deletable Scope scope(this); // find the right context to create the binding on - ScopedObject activation(scope, engine->globalObject); + ScopedObject activation(scope, d()->engine->globalObject); ExecutionContext *ctx = this; while (ctx) { - if (ctx->type >= Type_CallContext) { + if (ctx->d()->type >= Type_CallContext) { CallContext *c = static_cast(ctx); if (!c->activation) - c->activation = engine->newObject()->getPointer(); + c->activation = d()->engine->newObject()->getPointer(); activation = c->activation; break; } - ctx = ctx->outer; + ctx = ctx->d()->outer; } if (activation->hasProperty(name)) @@ -143,10 +143,10 @@ GlobalContext::GlobalContext(ExecutionEngine *eng) WithContext::WithContext(ExecutionEngine *engine, ObjectRef with) : ExecutionContext(engine, Type_WithContext) { - callData = parent->callData; - outer = parent; - lookups = parent->lookups; - compilationUnit = parent->compilationUnit; + d()->callData = d()->parent->d()->callData; + d()->outer = d()->parent; + d()->lookups = d()->parent->d()->lookups; + d()->compilationUnit = d()->parent->d()->compilationUnit; withObject = with.getPointer(); } @@ -154,11 +154,11 @@ WithContext::WithContext(ExecutionEngine *engine, ObjectRef with) CatchContext::CatchContext(ExecutionEngine *engine, const StringRef exceptionVarName, const ValueRef exceptionValue) : ExecutionContext(engine, Type_CatchContext) { - strictMode = parent->strictMode; - callData = parent->callData; - outer = parent; - lookups = parent->lookups; - compilationUnit = parent->compilationUnit; + d()->strictMode = d()->parent->d()->strictMode; + d()->callData = d()->parent->d()->callData; + d()->outer = d()->parent; + d()->lookups = d()->parent->d()->lookups; + d()->compilationUnit = d()->parent->d()->compilationUnit; this->exceptionVarName = exceptionVarName; this->exceptionValue = exceptionValue; @@ -168,19 +168,19 @@ CallContext::CallContext(ExecutionEngine *engine, ObjectRef qml, FunctionObject : ExecutionContext(engine, Type_QmlContext) { this->function = function; - callData = reinterpret_cast(this + 1); - callData->tag = QV4::Value::_Integer_Type; - callData->argc = 0; - callData->thisObject = Primitive::undefinedValue(); + d()->callData = reinterpret_cast(this + 1); + d()->callData->tag = QV4::Value::_Integer_Type; + d()->callData->argc = 0; + d()->callData->thisObject = Primitive::undefinedValue(); - strictMode = true; - outer = function->scope(); + d()->strictMode = true; + d()->outer = function->scope(); activation = qml.getPointer(); if (function->function()) { - compilationUnit = function->function()->compilationUnit; - lookups = compilationUnit->runtimeLookups; + d()->compilationUnit = function->function()->compilationUnit; + d()->lookups = d()->compilationUnit->runtimeLookups; } locals = (Value *)(this + 1); @@ -214,17 +214,17 @@ bool ExecutionContext::deleteProperty(const StringRef name) { Scope scope(this); bool hasWith = false; - for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { - if (ctx->type == Type_WithContext) { + for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { + if (ctx->d()->type == Type_WithContext) { hasWith = true; WithContext *w = static_cast(ctx); if (w->withObject->hasProperty(name)) return w->withObject->deleteProperty(name); - } else if (ctx->type == Type_CatchContext) { + } else if (ctx->d()->type == Type_CatchContext) { CatchContext *c = static_cast(ctx); if (c->exceptionVarName->isEqualTo(name)) return false; - } else if (ctx->type >= Type_CallContext) { + } else if (ctx->d()->type >= Type_CallContext) { CallContext *c = static_cast(ctx); FunctionObject *f = c->function; if (f->needsActivation() || hasWith) { @@ -235,50 +235,50 @@ bool ExecutionContext::deleteProperty(const StringRef name) } if (c->activation && c->activation->hasProperty(name)) return c->activation->deleteProperty(name); - } else if (ctx->type == Type_GlobalContext) { + } else if (ctx->d()->type == Type_GlobalContext) { GlobalContext *g = static_cast(ctx); if (g->global->hasProperty(name)) return g->global->deleteProperty(name); } } - if (strictMode) + if (d()->strictMode) throwSyntaxError(QStringLiteral("Can't delete property %1").arg(name->toQString())); return true; } bool CallContext::needsOwnArguments() const { - return function->needsActivation() || callData->argc < static_cast(function->formalParameterCount()); + return function->needsActivation() || d()->callData->argc < static_cast(function->formalParameterCount()); } void ExecutionContext::markObjects(Managed *m, ExecutionEngine *engine) { ExecutionContext *ctx = static_cast(m); - if (ctx->outer) - ctx->outer->mark(engine); + if (ctx->d()->outer) + ctx->d()->outer->mark(engine); // ### shouldn't need these 3 lines - ctx->callData->thisObject.mark(engine); - for (int arg = 0; arg < ctx->callData->argc; ++arg) - ctx->callData->args[arg].mark(engine); + ctx->d()->callData->thisObject.mark(engine); + for (int arg = 0; arg < ctx->d()->callData->argc; ++arg) + ctx->d()->callData->args[arg].mark(engine); - if (ctx->type >= Type_CallContext) { + if (ctx->d()->type >= Type_CallContext) { QV4::CallContext *c = static_cast(ctx); for (unsigned local = 0, lastLocal = c->function->varCount(); local < lastLocal; ++local) c->locals[local].mark(engine); if (c->activation) c->activation->mark(engine); c->function->mark(engine); - } else if (ctx->type == Type_WithContext) { + } else if (ctx->d()->type == Type_WithContext) { WithContext *w = static_cast(ctx); w->withObject->mark(engine); - } else if (ctx->type == Type_CatchContext) { + } else if (ctx->d()->type == Type_CatchContext) { CatchContext *c = static_cast(ctx); c->exceptionVarName->mark(engine); c->exceptionValue.mark(engine); - } else if (ctx->type == Type_GlobalContext) { + } else if (ctx->d()->type == Type_GlobalContext) { GlobalContext *g = static_cast(ctx); g->global->mark(engine); } @@ -287,25 +287,25 @@ void ExecutionContext::markObjects(Managed *m, ExecutionEngine *engine) void ExecutionContext::setProperty(const StringRef name, const ValueRef value) { Scope scope(this); - for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { - if (ctx->type == Type_WithContext) { + for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { + if (ctx->d()->type == Type_WithContext) { ScopedObject w(scope, static_cast(ctx)->withObject); if (w->hasProperty(name)) { w->put(name, value); return; } - } else if (ctx->type == Type_CatchContext && static_cast(ctx)->exceptionVarName->isEqualTo(name)) { + } else if (ctx->d()->type == Type_CatchContext && static_cast(ctx)->exceptionVarName->isEqualTo(name)) { static_cast(ctx)->exceptionValue = *value; return; } else { ScopedObject activation(scope, (Object *)0); - if (ctx->type >= Type_CallContext) { + if (ctx->d()->type >= Type_CallContext) { CallContext *c = static_cast(ctx); if (c->function->function()) { uint index = c->function->function()->internalClass->find(name); if (index < UINT_MAX) { if (index < c->function->formalParameterCount()) { - c->callData->args[c->function->formalParameterCount() - index - 1] = *value; + c->d()->callData->args[c->function->formalParameterCount() - index - 1] = *value; } else { index -= c->function->formalParameterCount(); c->locals[index] = *value; @@ -314,12 +314,12 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value) } } activation = c->activation; - } else if (ctx->type == Type_GlobalContext) { + } else if (ctx->d()->type == Type_GlobalContext) { activation = static_cast(ctx)->global; } if (activation) { - if (ctx->type == Type_QmlContext) { + if (ctx->d()->type == Type_QmlContext) { activation->put(name, value); return; } else { @@ -332,12 +332,12 @@ void ExecutionContext::setProperty(const StringRef name, const ValueRef value) } } } - if (strictMode || name->equals(engine->id_this)) { + if (d()->strictMode || name->equals(d()->engine->id_this)) { ScopedValue n(scope, name.asReturnedValue()); throwReferenceError(n); return; } - engine->globalObject->put(name, value); + d()->engine->globalObject->put(name, value); } ReturnedValue ExecutionContext::getProperty(const StringRef name) @@ -346,13 +346,13 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) ScopedValue v(scope); name->makeIdentifier(); - if (name->equals(engine->id_this)) - return callData->thisObject.asReturnedValue(); + if (name->equals(d()->engine->id_this)) + return d()->callData->thisObject.asReturnedValue(); bool hasWith = false; bool hasCatchScope = false; - for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { - if (ctx->type == Type_WithContext) { + for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { + if (ctx->d()->type == Type_WithContext) { ScopedObject w(scope, static_cast(ctx)->withObject); hasWith = true; bool hasProperty = false; @@ -363,21 +363,21 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) continue; } - else if (ctx->type == Type_CatchContext) { + else if (ctx->d()->type == Type_CatchContext) { hasCatchScope = true; CatchContext *c = static_cast(ctx); if (c->exceptionVarName->isEqualTo(name)) return c->exceptionValue.asReturnedValue(); } - else if (ctx->type >= Type_CallContext) { + else if (ctx->d()->type >= Type_CallContext) { QV4::CallContext *c = static_cast(ctx); ScopedFunctionObject f(scope, c->function); if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { uint index = f->function()->internalClass->find(name); if (index < UINT_MAX) { if (index < c->function->formalParameterCount()) - return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); + return c->d()->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); return c->locals[index - c->function->formalParameterCount()].asReturnedValue(); } } @@ -392,7 +392,7 @@ ReturnedValue ExecutionContext::getProperty(const StringRef name) return f.asReturnedValue(); } - else if (ctx->type == Type_GlobalContext) { + else if (ctx->d()->type == Type_GlobalContext) { GlobalContext *g = static_cast(ctx); bool hasProperty = false; v = g->global->get(name, &hasProperty); @@ -411,13 +411,13 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR base = (Object *)0; name->makeIdentifier(); - if (name->equals(engine->id_this)) - return callData->thisObject.asReturnedValue(); + if (name->equals(d()->engine->id_this)) + return d()->callData->thisObject.asReturnedValue(); bool hasWith = false; bool hasCatchScope = false; - for (ExecutionContext *ctx = this; ctx; ctx = ctx->outer) { - if (ctx->type == Type_WithContext) { + for (ExecutionContext *ctx = this; ctx; ctx = ctx->d()->outer) { + if (ctx->d()->type == Type_WithContext) { Object *w = static_cast(ctx)->withObject; hasWith = true; bool hasProperty = false; @@ -429,21 +429,21 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR continue; } - else if (ctx->type == Type_CatchContext) { + else if (ctx->d()->type == Type_CatchContext) { hasCatchScope = true; CatchContext *c = static_cast(ctx); if (c->exceptionVarName->isEqualTo(name)) return c->exceptionValue.asReturnedValue(); } - else if (ctx->type >= Type_CallContext) { + else if (ctx->d()->type >= Type_CallContext) { QV4::CallContext *c = static_cast(ctx); FunctionObject *f = c->function; if (f->function() && (f->needsActivation() || hasWith || hasCatchScope)) { uint index = f->function()->internalClass->find(name); if (index < UINT_MAX) { if (index < c->function->formalParameterCount()) - return c->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); + return c->d()->callData->args[c->function->formalParameterCount() - index - 1].asReturnedValue(); return c->locals[index - c->function->formalParameterCount()].asReturnedValue(); } } @@ -451,7 +451,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR bool hasProperty = false; v = c->activation->get(name, &hasProperty); if (hasProperty) { - if (ctx->type == Type_QmlContext) + if (ctx->d()->type == Type_QmlContext) base = c->activation; return v.asReturnedValue(); } @@ -461,7 +461,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR return c->function->asReturnedValue(); } - else if (ctx->type == Type_GlobalContext) { + else if (ctx->d()->type == Type_GlobalContext) { GlobalContext *g = static_cast(ctx); bool hasProperty = false; v = g->global->get(name, &hasProperty); @@ -476,56 +476,56 @@ ReturnedValue ExecutionContext::getPropertyAndBase(const StringRef name, ObjectR ReturnedValue ExecutionContext::throwError(const ValueRef value) { - return engine->throwException(value); + return d()->engine->throwException(value); } ReturnedValue ExecutionContext::throwError(const QString &message) { Scope scope(this); - ScopedValue v(scope, engine->newString(message)); - v = engine->newErrorObject(v); + ScopedValue v(scope, d()->engine->newString(message)); + v = d()->engine->newErrorObject(v); return throwError(v); } ReturnedValue ExecutionContext::throwSyntaxError(const QString &message, const QString &fileName, int line, int column) { Scope scope(this); - Scoped error(scope, engine->newSyntaxErrorObject(message, fileName, line, column)); + Scoped error(scope, d()->engine->newSyntaxErrorObject(message, fileName, line, column)); return throwError(error); } ReturnedValue ExecutionContext::throwSyntaxError(const QString &message) { Scope scope(this); - Scoped error(scope, engine->newSyntaxErrorObject(message)); + Scoped error(scope, d()->engine->newSyntaxErrorObject(message)); return throwError(error); } ReturnedValue ExecutionContext::throwTypeError() { Scope scope(this); - Scoped error(scope, engine->newTypeErrorObject(QStringLiteral("Type error"))); + Scoped error(scope, d()->engine->newTypeErrorObject(QStringLiteral("Type error"))); return throwError(error); } ReturnedValue ExecutionContext::throwTypeError(const QString &message) { Scope scope(this); - Scoped error(scope, engine->newTypeErrorObject(message)); + Scoped error(scope, d()->engine->newTypeErrorObject(message)); return throwError(error); } ReturnedValue ExecutionContext::throwUnimplemented(const QString &message) { Scope scope(this); - ScopedValue v(scope, engine->newString(QStringLiteral("Unimplemented ") + message)); - v = engine->newErrorObject(v); + ScopedValue v(scope, d()->engine->newString(QStringLiteral("Unimplemented ") + message)); + v = d()->engine->newErrorObject(v); return throwError(v); } ReturnedValue ExecutionContext::catchException(StackTrace *trace) { - return engine->catchException(this, trace); + return d()->engine->catchException(this, trace); } ReturnedValue ExecutionContext::throwReferenceError(const ValueRef value) @@ -533,7 +533,7 @@ ReturnedValue ExecutionContext::throwReferenceError(const ValueRef value) Scope scope(this); Scoped s(scope, value->toString(this)); QString msg = s->toQString() + QStringLiteral(" is not defined"); - Scoped error(scope, engine->newReferenceErrorObject(msg)); + Scoped error(scope, d()->engine->newReferenceErrorObject(msg)); return throwError(error); } @@ -541,7 +541,7 @@ ReturnedValue ExecutionContext::throwReferenceError(const QString &message, cons { Scope scope(this); QString msg = message; - Scoped error(scope, engine->newReferenceErrorObject(msg, fileName, line, column)); + Scoped error(scope, d()->engine->newReferenceErrorObject(msg, fileName, line, column)); return throwError(error); } @@ -550,20 +550,20 @@ ReturnedValue ExecutionContext::throwRangeError(const ValueRef value) Scope scope(this); ScopedString s(scope, value->toString(this)); QString msg = s->toQString() + QStringLiteral(" out of range"); - ScopedObject error(scope, engine->newRangeErrorObject(msg)); + ScopedObject error(scope, d()->engine->newRangeErrorObject(msg)); return throwError(error); } ReturnedValue ExecutionContext::throwRangeError(const QString &message) { Scope scope(this); - ScopedObject error(scope, engine->newRangeErrorObject(message)); + ScopedObject error(scope, d()->engine->newRangeErrorObject(message)); return throwError(error); } ReturnedValue ExecutionContext::throwURIError(const ValueRef msg) { Scope scope(this); - ScopedObject error(scope, engine->newURIErrorObject(msg)); + ScopedObject error(scope, d()->engine->newURIErrorObject(msg)); return throwError(error); } diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index a07cbf2da5..e4e9c09ad8 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -69,8 +69,6 @@ struct WithContext; struct Q_QML_EXPORT ExecutionContext : public Managed { - V4_MANAGED - Q_MANAGED_TYPE(ExecutionContext) enum { IsExecutionContext = true }; @@ -83,41 +81,61 @@ struct Q_QML_EXPORT ExecutionContext : public Managed Type_CallContext = 0x5, Type_QmlContext = 0x6 }; - - ExecutionContext(ExecutionEngine *engine, ContextType t) - : Managed(engine->executionContextClass) + struct EvalCode { - this->type = t; - strictMode = false; - this->engine = engine; - this->parent = engine->currentContext(); - outer = 0; - lookups = 0; - compilationUnit = 0; - currentEvalCode = 0; - lineNumber = -1; - engine->current = this; - } + Function *function; + EvalCode *next; + }; - ContextType type; - bool strictMode; + struct Data : Managed::Data { + ContextType type; + bool strictMode; - CallData *callData; + CallData *callData; - ExecutionEngine *engine; - ExecutionContext *parent; - ExecutionContext *outer; - Lookup *lookups; - CompiledData::CompilationUnit *compilationUnit; + ExecutionEngine *engine; + ExecutionContext *parent; + ExecutionContext *outer; + Lookup *lookups; + CompiledData::CompilationUnit *compilationUnit; + EvalCode *currentEvalCode; + + int lineNumber; - struct EvalCode - { - Function *function; - EvalCode *next; }; - EvalCode *currentEvalCode; + struct { + ContextType type; + bool strictMode; + + CallData *callData; - int lineNumber; + ExecutionEngine *engine; + ExecutionContext *parent; + ExecutionContext *outer; + Lookup *lookups; + CompiledData::CompilationUnit *compilationUnit; + EvalCode *currentEvalCode; + + int lineNumber; + } __data; + + V4_MANAGED_NEW + Q_MANAGED_TYPE(ExecutionContext) + + ExecutionContext(ExecutionEngine *engine, ContextType t) + : Managed(engine->executionContextClass) + { + d()->type = t; + d()->strictMode = false; + d()->engine = engine; + d()->parent = engine->currentContext(); + d()->outer = 0; + d()->lookups = 0; + d()->compilationUnit = 0; + d()->currentEvalCode = 0; + d()->lineNumber = -1; + engine->current = this; + } CallContext *newCallContext(FunctionObject *f, CallData *callData); WithContext *newWithContext(ObjectRef with); @@ -180,7 +198,7 @@ struct CallContext : public ExecutionContext }; inline ReturnedValue CallContext::argument(int i) { - return i < callData->argc ? callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); + return i < d()->callData->argc ? d()->callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); } struct GlobalContext : public ExecutionContext @@ -206,26 +224,26 @@ struct WithContext : public ExecutionContext inline CallContext *ExecutionContext::asCallContext() { - return type >= Type_SimpleCallContext ? static_cast(this) : 0; + return d()->type >= Type_SimpleCallContext ? static_cast(this) : 0; } inline const CallContext *ExecutionContext::asCallContext() const { - return type >= Type_SimpleCallContext ? static_cast(this) : 0; + return d()->type >= Type_SimpleCallContext ? static_cast(this) : 0; } inline void ExecutionEngine::pushContext(CallContext *context) { - context->parent = current; + context->d()->parent = current; current = context; - current->currentEvalCode = 0; + current->d()->currentEvalCode = 0; } inline ExecutionContext *ExecutionEngine::popContext() { - Q_ASSERT(current->parent); - current = current->parent; + Q_ASSERT(current->d()->parent); + current = current->d()->parent; return current; } @@ -235,7 +253,7 @@ struct ExecutionContextSaver ExecutionContext *savedContext; ExecutionContextSaver(ExecutionContext *context) - : engine(context->engine) + : engine(context->d()->engine) , savedContext(context) { } @@ -246,7 +264,7 @@ struct ExecutionContextSaver }; inline Scope::Scope(ExecutionContext *ctx) - : engine(ctx->engine) + : engine(ctx->d()->engine) #ifndef QT_NO_DEBUG , size(0) #endif diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 61261d6b8a..6c485200c9 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -770,7 +770,7 @@ void DatePrototype::init(ExecutionEngine *engine, ObjectRef ctor) double DatePrototype::getThisDate(ExecutionContext *ctx) { - if (DateObject *thisObject = ctx->callData->thisObject.asDateObject()) + if (DateObject *thisObject = ctx->d()->callData->thisObject.asDateObject()) return thisObject->date().asDouble(); else { ctx->throwTypeError(); @@ -780,22 +780,22 @@ double DatePrototype::getThisDate(ExecutionContext *ctx) ReturnedValue DatePrototype::method_parse(CallContext *ctx) { - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) return Encode(qSNaN()); - return Encode(ParseString(ctx->callData->args[0].toString(ctx)->toQString())); + return Encode(ParseString(ctx->d()->callData->args[0].toString(ctx)->toQString())); } ReturnedValue DatePrototype::method_UTC(CallContext *ctx) { - const int numArgs = ctx->callData->argc; + const int numArgs = ctx->d()->callData->argc; if (numArgs >= 2) { - double year = ctx->callData->args[0].toNumber(); - double month = ctx->callData->args[1].toNumber(); - double day = numArgs >= 3 ? ctx->callData->args[2].toNumber() : 1; - double hours = numArgs >= 4 ? ctx->callData->args[3].toNumber() : 0; - double mins = numArgs >= 5 ? ctx->callData->args[4].toNumber() : 0; - double secs = numArgs >= 6 ? ctx->callData->args[5].toNumber() : 0; - double ms = numArgs >= 7 ? ctx->callData->args[6].toNumber() : 0; + double year = ctx->d()->callData->args[0].toNumber(); + double month = ctx->d()->callData->args[1].toNumber(); + double day = numArgs >= 3 ? ctx->d()->callData->args[2].toNumber() : 1; + double hours = numArgs >= 4 ? ctx->d()->callData->args[3].toNumber() : 0; + double mins = numArgs >= 5 ? ctx->d()->callData->args[4].toNumber() : 0; + double secs = numArgs >= 6 ? ctx->d()->callData->args[5].toNumber() : 0; + double ms = numArgs >= 7 ? ctx->d()->callData->args[6].toNumber() : 0; if (year >= 0 && year <= 99) year += 1900; double t = MakeDate(MakeDay(year, month, day), @@ -815,37 +815,37 @@ ReturnedValue DatePrototype::method_now(CallContext *ctx) ReturnedValue DatePrototype::method_toString(CallContext *ctx) { double t = getThisDate(ctx); - return ctx->engine->newString(ToString(t))->asReturnedValue(); + return ctx->d()->engine->newString(ToString(t))->asReturnedValue(); } ReturnedValue DatePrototype::method_toDateString(CallContext *ctx) { double t = getThisDate(ctx); - return ctx->engine->newString(ToDateString(t))->asReturnedValue(); + return ctx->d()->engine->newString(ToDateString(t))->asReturnedValue(); } ReturnedValue DatePrototype::method_toTimeString(CallContext *ctx) { double t = getThisDate(ctx); - return ctx->engine->newString(ToTimeString(t))->asReturnedValue(); + return ctx->d()->engine->newString(ToTimeString(t))->asReturnedValue(); } ReturnedValue DatePrototype::method_toLocaleString(CallContext *ctx) { double t = getThisDate(ctx); - return ctx->engine->newString(ToLocaleString(t))->asReturnedValue(); + return ctx->d()->engine->newString(ToLocaleString(t))->asReturnedValue(); } ReturnedValue DatePrototype::method_toLocaleDateString(CallContext *ctx) { double t = getThisDate(ctx); - return ctx->engine->newString(ToLocaleDateString(t))->asReturnedValue(); + return ctx->d()->engine->newString(ToLocaleDateString(t))->asReturnedValue(); } ReturnedValue DatePrototype::method_toLocaleTimeString(CallContext *ctx) { double t = getThisDate(ctx); - return ctx->engine->newString(ToLocaleTimeString(t))->asReturnedValue(); + return ctx->d()->engine->newString(ToLocaleTimeString(t))->asReturnedValue(); } ReturnedValue DatePrototype::method_valueOf(CallContext *ctx) @@ -1007,11 +1007,11 @@ ReturnedValue DatePrototype::method_getTimezoneOffset(CallContext *ctx) ReturnedValue DatePrototype::method_setTime(CallContext *ctx) { Scope scope(ctx); - Scoped self(scope, ctx->callData->thisObject); + Scoped self(scope, ctx->d()->callData->thisObject); if (!self) return ctx->throwTypeError(); - double t = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double t = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); self->date().setDouble(TimeClip(t)); return self->date().asReturnedValue(); } @@ -1019,37 +1019,37 @@ ReturnedValue DatePrototype::method_setTime(CallContext *ctx) ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx) { Scope scope(ctx); - Scoped self(scope, ctx->callData->thisObject); + Scoped self(scope, ctx->d()->callData->thisObject); if (!self) return ctx->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double ms = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); self->date().setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))))); return self->date().asReturnedValue(); } ReturnedValue DatePrototype::method_setUTCMilliseconds(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - double ms = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); self->date().setDouble(TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms))))); return self->date().asReturnedValue(); } ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double sec = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double ms = (ctx->callData->argc < 2) ? msFromTime(t) : ctx->callData->args[1].toNumber(); + double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double ms = (ctx->d()->callData->argc < 2) ? msFromTime(t) : ctx->d()->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1057,13 +1057,13 @@ ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - double sec = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double ms = (ctx->callData->argc < 2) ? msFromTime(t) : ctx->callData->args[1].toNumber(); + double sec = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double ms = (ctx->d()->callData->argc < 2) ? msFromTime(t) : ctx->d()->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1071,14 +1071,14 @@ ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx) ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double min = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double sec = (ctx->callData->argc < 2) ? SecFromTime(t) : ctx->callData->args[1].toNumber(); - double ms = (ctx->callData->argc < 3) ? msFromTime(t) : ctx->callData->args[2].toNumber(); + double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double sec = (ctx->d()->callData->argc < 2) ? SecFromTime(t) : ctx->d()->callData->args[1].toNumber(); + double ms = (ctx->d()->callData->argc < 3) ? msFromTime(t) : ctx->d()->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1086,14 +1086,14 @@ ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - double min = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double sec = (ctx->callData->argc < 2) ? SecFromTime(t) : ctx->callData->args[1].toNumber(); - double ms = (ctx->callData->argc < 3) ? msFromTime(t) : ctx->callData->args[2].toNumber(); + double min = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double sec = (ctx->d()->callData->argc < 2) ? SecFromTime(t) : ctx->d()->callData->args[1].toNumber(); + double ms = (ctx->d()->callData->argc < 3) ? msFromTime(t) : ctx->d()->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1101,15 +1101,15 @@ ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx) ReturnedValue DatePrototype::method_setHours(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double hour = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double min = (ctx->callData->argc < 2) ? MinFromTime(t) : ctx->callData->args[1].toNumber(); - double sec = (ctx->callData->argc < 3) ? SecFromTime(t) : ctx->callData->args[2].toNumber(); - double ms = (ctx->callData->argc < 4) ? msFromTime(t) : ctx->callData->args[3].toNumber(); + double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double min = (ctx->d()->callData->argc < 2) ? MinFromTime(t) : ctx->d()->callData->args[1].toNumber(); + double sec = (ctx->d()->callData->argc < 3) ? SecFromTime(t) : ctx->d()->callData->args[2].toNumber(); + double ms = (ctx->d()->callData->argc < 4) ? msFromTime(t) : ctx->d()->callData->args[3].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1117,15 +1117,15 @@ ReturnedValue DatePrototype::method_setHours(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - double hour = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double min = (ctx->callData->argc < 2) ? MinFromTime(t) : ctx->callData->args[1].toNumber(); - double sec = (ctx->callData->argc < 3) ? SecFromTime(t) : ctx->callData->args[2].toNumber(); - double ms = (ctx->callData->argc < 4) ? msFromTime(t) : ctx->callData->args[3].toNumber(); + double hour = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double min = (ctx->d()->callData->argc < 2) ? MinFromTime(t) : ctx->d()->callData->args[1].toNumber(); + double sec = (ctx->d()->callData->argc < 3) ? SecFromTime(t) : ctx->d()->callData->args[2].toNumber(); + double ms = (ctx->d()->callData->argc < 4) ? msFromTime(t) : ctx->d()->callData->args[3].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1133,12 +1133,12 @@ ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx) ReturnedValue DatePrototype::method_setDate(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double date = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1146,12 +1146,12 @@ ReturnedValue DatePrototype::method_setDate(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - double date = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1159,13 +1159,13 @@ ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx) ReturnedValue DatePrototype::method_setMonth(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double month = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double date = (ctx->callData->argc < 2) ? DateFromTime(t) : ctx->callData->args[1].toNumber(); + double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double date = (ctx->d()->callData->argc < 2) ? DateFromTime(t) : ctx->d()->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1173,13 +1173,13 @@ ReturnedValue DatePrototype::method_setMonth(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - double month = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double date = (ctx->callData->argc < 2) ? DateFromTime(t) : ctx->callData->args[1].toNumber(); + double month = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double date = (ctx->d()->callData->argc < 2) ? DateFromTime(t) : ctx->d()->callData->args[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1187,7 +1187,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx) ReturnedValue DatePrototype::method_setYear(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); @@ -1196,7 +1196,7 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx) t = 0; else t = LocalTime(t); - double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); + double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); double r; if (std::isnan(year)) { r = qSNaN(); @@ -1213,14 +1213,14 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double month = (ctx->callData->argc < 2) ? MonthFromTime(t) : ctx->callData->args[1].toNumber(); - double date = (ctx->callData->argc < 3) ? DateFromTime(t) : ctx->callData->args[2].toNumber(); + double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double month = (ctx->d()->callData->argc < 2) ? MonthFromTime(t) : ctx->d()->callData->args[1].toNumber(); + double date = (ctx->d()->callData->argc < 3) ? DateFromTime(t) : ctx->d()->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1228,16 +1228,16 @@ ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx) ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = LocalTime(self->date().asDouble()); if (std::isnan(t)) t = 0; - double year = ctx->callData->argc ? ctx->callData->args[0].toNumber() : qSNaN(); - double month = (ctx->callData->argc < 2) ? MonthFromTime(t) : ctx->callData->args[1].toNumber(); - double date = (ctx->callData->argc < 3) ? DateFromTime(t) : ctx->callData->args[2].toNumber(); + double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double month = (ctx->d()->callData->argc < 2) ? MonthFromTime(t) : ctx->d()->callData->args[1].toNumber(); + double date = (ctx->d()->callData->argc < 3) ? DateFromTime(t) : ctx->d()->callData->args[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1245,12 +1245,12 @@ ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx) ReturnedValue DatePrototype::method_toUTCString(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); - return ctx->engine->newString(ToUTCString(t))->asReturnedValue(); + return ctx->d()->engine->newString(ToUTCString(t))->asReturnedValue(); } static void addZeroPrefixedInt(QString &str, int num, int nDigits) @@ -1268,19 +1268,19 @@ static void addZeroPrefixedInt(QString &str, int num, int nDigits) ReturnedValue DatePrototype::method_toISOString(CallContext *ctx) { - DateObject *self = ctx->callData->thisObject.asDateObject(); + DateObject *self = ctx->d()->callData->thisObject.asDateObject(); if (!self) return ctx->throwTypeError(); double t = self->date().asDouble(); if (!std::isfinite(t)) - return ctx->throwRangeError(ctx->callData->thisObject); + return ctx->throwRangeError(ctx->d()->callData->thisObject); QString result; int year = (int)YearFromTime(t); if (year < 0 || year > 9999) { if (qAbs(year) >= 1000000) - return ctx->engine->newString(QStringLiteral("Invalid Date"))->asReturnedValue(); + return ctx->d()->engine->newString(QStringLiteral("Invalid Date"))->asReturnedValue(); result += year < 0 ? QLatin1Char('-') : QLatin1Char('+'); year = qAbs(year); addZeroPrefixedInt(result, year, 6); @@ -1301,19 +1301,19 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx) addZeroPrefixedInt(result, msFromTime(t), 3); result += QLatin1Char('Z'); - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) { Scope scope(ctx); - ScopedValue O(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->callData->thisObject))); + ScopedValue O(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->d()->callData->thisObject))); ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT)); if (tv->isNumber() && !std::isfinite(tv->toNumber())) return Encode::null(); - ScopedString s(scope, ctx->engine->newString(QStringLiteral("toISOString"))); + ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toISOString"))); ScopedValue v(scope, O->objectValue()->get(s)); FunctionObject *toIso = v->asFunctionObject(); @@ -1321,7 +1321,7 @@ ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) return ctx->throwTypeError(); ScopedCallData callData(scope, 0); - callData->thisObject = ctx->callData->thisObject; + callData->thisObject = ctx->d()->callData->thisObject; return toIso->call(callData); } diff --git a/src/qml/jsruntime/qv4debugging.cpp b/src/qml/jsruntime/qv4debugging.cpp index 9917426284..59b7c5fb9c 100644 --- a/src/qml/jsruntime/qv4debugging.cpp +++ b/src/qml/jsruntime/qv4debugging.cpp @@ -210,7 +210,7 @@ Debugger::ExecutionState Debugger::currentExecutionState() const { ExecutionState state; state.fileName = getFunction()->sourceFile(); - state.lineNumber = engine()->currentContext()->lineNumber; + state.lineNumber = engine()->currentContext()->d()->lineNumber; return state; } @@ -229,7 +229,7 @@ static inline CallContext *findContext(ExecutionContext *ctxt, int frame) return cCtxt; --frame; } - ctxt = ctxt->parent; + ctxt = ctxt->d()->parent; } return 0; @@ -238,7 +238,7 @@ static inline CallContext *findContext(ExecutionContext *ctxt, int frame) static inline CallContext *findScope(ExecutionContext *ctxt, int scope) { for (; scope > 0 && ctxt; --scope) - ctxt = ctxt->outer; + ctxt = ctxt->d()->outer; return ctxt ? ctxt->asCallContext() : 0; } @@ -369,7 +369,7 @@ bool Debugger::collectThisInContext(Debugger::Collector *collector, int frame) if (CallContext *cCtxt = ctxt->asCallContext()) if (cCtxt->activation) break; - ctxt = ctxt->outer; + ctxt = ctxt->d()->outer; } if (!ctxt) @@ -434,12 +434,12 @@ QVector Debugger::getScopeTypes(int frame) const return types; CallContext *sctxt = findContext(m_engine->currentContext(), frame); - if (!sctxt || sctxt->type < ExecutionContext::Type_SimpleCallContext) + if (!sctxt || sctxt->d()->type < ExecutionContext::Type_SimpleCallContext) return types; CallContext *ctxt = static_cast(sctxt); - for (ExecutionContext *it = ctxt; it; it = it->outer) - types.append(it->type); + for (ExecutionContext *it = ctxt; it; it = it->d()->outer) + types.append(it->d()->type); return types; } @@ -450,7 +450,7 @@ void Debugger::maybeBreakAtInstruction() return; QMutexLocker locker(&m_lock); - int lineNumber = engine()->currentContext()->lineNumber; + int lineNumber = engine()->currentContext()->d()->lineNumber; if (m_gatherSources) { m_gatherSources->run(); @@ -495,7 +495,7 @@ void Debugger::leavingFunction(const ReturnedValue &retVal) QMutexLocker locker(&m_lock); if (m_stepping != NotStepping && m_currentContext == m_engine->currentContext()) { - m_currentContext = m_engine->currentContext()->parent; + m_currentContext = m_engine->currentContext()->d()->parent; m_stepping = StepOver; m_returnedValue = retVal; } @@ -519,8 +519,8 @@ Function *Debugger::getFunction() const if (CallContext *callCtx = context->asCallContext()) return callCtx->function->function(); else { - Q_ASSERT(context->type == QV4::ExecutionContext::Type_GlobalContext); - return context->engine->globalCode; + Q_ASSERT(context->d()->type == QV4::ExecutionContext::Type_GlobalContext); + return context->d()->engine->globalCode; } } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index f089737e42..e0325bb7ac 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -371,7 +371,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) // globalObject = newObject()->getPointer(); rootContext->global = globalObject; - rootContext->callData->thisObject = globalObject; + rootContext->d()->callData->thisObject = globalObject; Q_ASSERT(globalObject->internalClass()->vtable); globalObject->defineDefaultProperty(QStringLiteral("Object"), objectCtor); @@ -460,11 +460,11 @@ void ExecutionEngine::initRootContext() { rootContext = static_cast(memoryManager->allocManaged(sizeof(GlobalContext) + sizeof(CallData))); new (rootContext) GlobalContext(this); - rootContext->callData = reinterpret_cast(rootContext + 1); - rootContext->callData->tag = QV4::Value::_Integer_Type; - rootContext->callData->argc = 0; - rootContext->callData->thisObject = globalObject; - rootContext->callData->args[0] = Encode::undefined(); + rootContext->d()->callData = reinterpret_cast(rootContext + 1); + rootContext->d()->callData->tag = QV4::Value::_Integer_Type; + rootContext->d()->callData->argc = 0; + rootContext->d()->callData->thisObject = globalObject; + rootContext->d()->callData->args[0] = Encode::undefined(); } InternalClass *ExecutionEngine::newClass(const InternalClass &other) @@ -475,7 +475,7 @@ InternalClass *ExecutionEngine::newClass(const InternalClass &other) ExecutionContext *ExecutionEngine::pushGlobalContext() { GlobalContext *g = new (memoryManager) GlobalContext(this); - g->callData = rootContext->callData; + g->d()->callData = rootContext->d()->callData; Q_ASSERT(currentContext() == g); return g; @@ -670,17 +670,17 @@ Returned *ExecutionEngine::qmlContextObject() const { ExecutionContext *ctx = currentContext(); - if (ctx->type == QV4::ExecutionContext::Type_SimpleCallContext && !ctx->outer) - ctx = ctx->parent; + if (ctx->d()->type == QV4::ExecutionContext::Type_SimpleCallContext && !ctx->d()->outer) + ctx = ctx->d()->parent; - if (!ctx->outer) + if (!ctx->d()->outer) return 0; - while (ctx->outer && ctx->outer->type != ExecutionContext::Type_GlobalContext) - ctx = ctx->outer; + while (ctx->d()->outer && ctx->d()->outer->d()->type != ExecutionContext::Type_GlobalContext) + ctx = ctx->d()->outer; Q_ASSERT(ctx); - if (ctx->type != ExecutionContext::Type_QmlContext) + if (ctx->d()->type != ExecutionContext::Type_QmlContext) return 0; return static_cast(ctx)->activation->asReturned(); @@ -706,19 +706,19 @@ QVector ExecutionEngine::stackTrace(int frameLimit) const if (callCtx->function->function()) // line numbers can be negative for places where you can't set a real breakpoint - frame.line = qAbs(callCtx->lineNumber); + frame.line = qAbs(callCtx->d()->lineNumber); stack.append(frame); --frameLimit; } - c = c->parent; + c = c->d()->parent; } if (frameLimit && globalCode) { StackFrame frame; frame.source = globalCode->sourceFile(); frame.function = globalCode->name()->toQString(); - frame.line = rootContext->lineNumber; + frame.line = rootContext->d()->lineNumber; frame.column = -1; @@ -752,8 +752,8 @@ static inline char *v4StackTrace(const ExecutionContext *context) QString result; QTextStream str(&result); str << "stack=["; - if (context && context->engine) { - const QVector stackTrace = context->engine->stackTrace(20); + if (context && context->d()->engine) { + const QVector stackTrace = context->d()->engine->stackTrace(20); for (int i = 0; i < stackTrace.size(); ++i) { if (i) str << ','; @@ -788,7 +788,7 @@ QUrl ExecutionEngine::resolvedUrl(const QString &file) base.setUrl(callCtx->function->function()->sourceFile()); break; } - c = c->parent; + c = c->d()->parent; } if (base.isEmpty() && globalCode) @@ -842,7 +842,7 @@ void ExecutionEngine::markObjects() ExecutionContext *c = currentContext(); while (c) { c->mark(this); - c = c->parent; + c = c->d()->parent; } id_empty->mark(this); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index 9c1e4f607f..f8fbbf09cb 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -156,7 +156,7 @@ ErrorObject::ErrorObject(InternalClass *ic, const QString &message, const QStrin ReturnedValue ErrorObject::method_get_stack(CallContext *ctx) { Scope scope(ctx); - Scoped This(scope, ctx->callData->thisObject); + Scoped This(scope, ctx->d()->callData->thisObject); if (!This) return ctx->throwTypeError(); if (!This->d()->stack) { @@ -173,7 +173,7 @@ ReturnedValue ErrorObject::method_get_stack(CallContext *ctx) trace += QString::number(frame.line); } } - This->d()->stack = ctx->engine->newString(trace)->getPointer(); + This->d()->stack = ctx->d()->engine->newString(trace)->getPointer(); } return This->d()->stack->asReturnedValue(); } @@ -371,18 +371,18 @@ ReturnedValue ErrorPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - Object *o = ctx->callData->thisObject.asObject(); + Object *o = ctx->d()->callData->thisObject.asObject(); if (!o) return ctx->throwTypeError(); - ScopedValue name(scope, o->get(ctx->engine->id_name)); + ScopedValue name(scope, o->get(ctx->d()->engine->id_name)); QString qname; if (name->isUndefined()) qname = QString::fromLatin1("Error"); else qname = name->toQString(); - ScopedString s(scope, ctx->engine->newString(QString::fromLatin1("message"))); + ScopedString s(scope, ctx->d()->engine->newString(QString::fromLatin1("message"))); ScopedValue message(scope, o->get(s)); QString qmessage; if (!message->isUndefined()) @@ -397,5 +397,5 @@ ReturnedValue ErrorPrototype::method_toString(CallContext *ctx) str = qname + QLatin1String(": ") + qmessage; } - return ctx->engine->newString(str)->asReturnedValue(); + return ctx->d()->engine->newString(str)->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 198138aab9..236e4be219 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -75,7 +75,7 @@ using namespace QV4; DEFINE_OBJECT_VTABLE(FunctionObject); FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bool createProto) - : Object(scope->engine->functionClass) + : Object(scope->d()->engine->functionClass) { d()->scope = scope; d()->function = 0; @@ -83,7 +83,7 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const StringRef name, bo } FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto) - : Object(scope->engine->functionClass) + : Object(scope->d()->engine->functionClass) { d()->scope = scope; d()->function = 0; @@ -95,7 +95,7 @@ FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, boo } FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name) - : Object(scope->engine->functionClass) + : Object(scope->d()->engine->functionClass) { d()->scope = scope; d()->function = 0; @@ -132,7 +132,7 @@ void FunctionObject::init(const StringRef n, bool createProto) d()->strictMode = false; if (createProto) { - Scoped proto(s, scope()->engine->newObject(scope()->engine->protoClass)); + Scoped proto(s, scope()->d()->engine->newObject(scope()->d()->engine->protoClass)); proto->memberData()[Index_ProtoConstructor] = this->asReturnedValue(); memberData()[Index_Prototype] = proto.asReturnedValue(); } else { @@ -140,12 +140,12 @@ void FunctionObject::init(const StringRef n, bool createProto) } ScopedValue v(s, n.asReturnedValue()); - defineReadonlyProperty(scope()->engine->id_name, v); + defineReadonlyProperty(scope()->d()->engine->id_name, v); } ReturnedValue FunctionObject::name() { - return get(scope()->engine->id_name); + return get(scope()->d()->engine->id_name); } @@ -182,8 +182,8 @@ FunctionObject *FunctionObject::createScriptFunction(ExecutionContext *scope, Fu function->compiledFunction->flags & CompiledData::Function::HasCatchOrWith || function->compiledFunction->nFormals > QV4::Global::ReservedArgumentCount || function->isNamedExpression()) - return new (scope->engine->memoryManager) ScriptFunction(scope, function); - return new (scope->engine->memoryManager) SimpleScriptFunction(scope, function, createProto); + return new (scope->d()->engine->memoryManager) ScriptFunction(scope, function); + return new (scope->d()->engine->memoryManager) SimpleScriptFunction(scope, function, createProto); } DEFINE_OBJECT_VTABLE(FunctionCtor); @@ -210,7 +210,7 @@ ReturnedValue FunctionCtor::construct(Managed *that, CallData *callData) } body = callData->args[callData->argc - 1].toString(ctx)->toQString(); } - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); QString function = QLatin1String("function(") + arguments + QLatin1String("){") + body + QLatin1String("}"); @@ -273,17 +273,17 @@ void FunctionPrototype::init(ExecutionEngine *engine, ObjectRef ctor) ReturnedValue FunctionPrototype::method_toString(CallContext *ctx) { - FunctionObject *fun = ctx->callData->thisObject.asFunctionObject(); + FunctionObject *fun = ctx->d()->callData->thisObject.asFunctionObject(); if (!fun) return ctx->throwTypeError(); - return ctx->engine->newString(QStringLiteral("function() { [code] }"))->asReturnedValue(); + return ctx->d()->engine->newString(QStringLiteral("function() { [code] }"))->asReturnedValue(); } ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) { Scope scope(ctx); - FunctionObject *o = ctx->callData->thisObject.asFunctionObject(); + FunctionObject *o = ctx->d()->callData->thisObject.asFunctionObject(); if (!o) return ctx->throwTypeError(); @@ -323,14 +323,14 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx) { Scope scope(ctx); - FunctionObject *o = ctx->callData->thisObject.asFunctionObject(); + FunctionObject *o = ctx->d()->callData->thisObject.asFunctionObject(); if (!o) return ctx->throwTypeError(); - ScopedCallData callData(scope, ctx->callData->argc ? ctx->callData->argc - 1 : 0); - if (ctx->callData->argc) { - for (int i = 1; i < ctx->callData->argc; ++i) - callData->args[i - 1] = ctx->callData->args[i]; + ScopedCallData callData(scope, ctx->d()->callData->argc ? ctx->d()->callData->argc - 1 : 0); + if (ctx->d()->callData->argc) { + for (int i = 1; i < ctx->d()->callData->argc; ++i) + callData->args[i - 1] = ctx->d()->callData->args[i]; } callData->thisObject = ctx->argument(0); return o->call(callData); @@ -339,21 +339,21 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx) ReturnedValue FunctionPrototype::method_bind(CallContext *ctx) { Scope scope(ctx); - Scoped target(scope, ctx->callData->thisObject); + Scoped target(scope, ctx->d()->callData->thisObject); if (!target) return ctx->throwTypeError(); ScopedValue boundThis(scope, ctx->argument(0)); Members boundArgs; boundArgs.reset(); - if (ctx->callData->argc > 1) { - boundArgs.ensureIndex(scope.engine, ctx->callData->argc - 1); - boundArgs.d()->d()->size = ctx->callData->argc - 1; - memcpy(boundArgs.data(), ctx->callData->args + 1, (ctx->callData->argc - 1)*sizeof(Value)); + if (ctx->d()->callData->argc > 1) { + boundArgs.ensureIndex(scope.engine, ctx->d()->callData->argc - 1); + boundArgs.d()->d()->size = ctx->d()->callData->argc - 1; + memcpy(boundArgs.data(), ctx->d()->callData->args + 1, (ctx->d()->callData->argc - 1)*sizeof(Value)); } ScopedValue protectBoundArgs(scope, boundArgs.d()); - return ctx->engine->newBoundFunction(ctx->engine->rootContext, target, boundThis, boundArgs)->asReturnedValue(); + return ctx->d()->engine->newBoundFunction(ctx->d()->engine->rootContext, target, boundThis, boundArgs)->asReturnedValue(); } DEFINE_OBJECT_VTABLE(ScriptFunction); @@ -369,13 +369,13 @@ ScriptFunction::ScriptFunction(ExecutionContext *scope, Function *function) d()->needsActivation = function->needsActivation(); d()->strictMode = function->isStrict(); - defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount())); + defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(formalParameterCount())); - if (scope->strictMode) { + if (scope->d()->strictMode) { ExecutionEngine *v4 = scope->engine; Property pd(v4->thrower, v4->thrower); - insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); - insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); } } @@ -424,7 +424,7 @@ ReturnedValue ScriptFunction::call(Managed *that, CallData *callData) ScopedValue result(scope, Q_V4_PROFILE(v4, ctx, f->function())); if (f->function()->compiledFunction->hasQmlDependencies()) - QmlContextWrapper::registerQmlDependencies(ctx->engine, f->function()->compiledFunction); + QmlContextWrapper::registerQmlDependencies(ctx->d()->engine, f->function()->compiledFunction); return result.asReturnedValue(); } @@ -448,17 +448,17 @@ SimpleScriptFunction::SimpleScriptFunction(ExecutionContext *scope, Function *fu if (!scope) return; - ExecutionEngine *v4 = scope->engine; + ExecutionEngine *v4 = scope->d()->engine; d()->needsActivation = function->needsActivation(); d()->strictMode = function->isStrict(); - defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(formalParameterCount())); + defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(formalParameterCount())); - if (scope->strictMode) { + if (scope->d()->strictMode) { Property pd(v4->thrower, v4->thrower); - insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); - insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); } } @@ -479,12 +479,12 @@ ReturnedValue SimpleScriptFunction::construct(Managed *that, CallData *callData) ExecutionContextSaver ctxSaver(context); CallContext ctx(v4); - ctx.strictMode = f->strictMode(); - ctx.callData = callData; + ctx.d()->strictMode = f->strictMode(); + ctx.d()->callData = callData; ctx.function = f.getPointer(); - ctx.compilationUnit = f->function()->compilationUnit; - ctx.lookups = ctx.compilationUnit->runtimeLookups; - ctx.outer = f->scope(); + ctx.d()->compilationUnit = f->function()->compilationUnit; + ctx.d()->lookups = ctx.d()->compilationUnit->runtimeLookups; + ctx.d()->outer = f->scope(); ctx.locals = v4->stackPush(f->varCount()); while (callData->argc < (int)f->formalParameterCount()) { callData->args[callData->argc] = Encode::undefined(); @@ -516,12 +516,12 @@ ReturnedValue SimpleScriptFunction::call(Managed *that, CallData *callData) ExecutionContextSaver ctxSaver(context); CallContext ctx(v4); - ctx.strictMode = f->strictMode(); - ctx.callData = callData; + ctx.d()->strictMode = f->strictMode(); + ctx.d()->callData = callData; ctx.function = f; - ctx.compilationUnit = f->function()->compilationUnit; - ctx.lookups = ctx.compilationUnit->runtimeLookups; - ctx.outer = f->scope(); + ctx.d()->compilationUnit = f->function()->compilationUnit; + ctx.d()->lookups = ctx.d()->compilationUnit->runtimeLookups; + ctx.d()->outer = f->scope(); ctx.locals = v4->stackPush(f->varCount()); while (callData->argc < (int)f->formalParameterCount()) { callData->args[callData->argc] = Encode::undefined(); @@ -579,8 +579,8 @@ ReturnedValue BuiltinFunction::call(Managed *that, CallData *callData) ExecutionContextSaver ctxSaver(context); CallContext ctx(v4); - ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? - ctx.callData = callData; + ctx.d()->strictMode = f->scope()->d()->strictMode; // ### needed? scope or parent context? + ctx.d()->callData = callData; Q_ASSERT(v4->currentContext() == &ctx); return f->d()->code(&ctx); @@ -598,8 +598,8 @@ ReturnedValue IndexedBuiltinFunction::call(Managed *that, CallData *callData) ExecutionContextSaver ctxSaver(context); CallContext ctx(v4); - ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context? - ctx.callData = callData; + ctx.d()->strictMode = f->scope()->d()->strictMode; // ### needed? scope or parent context? + ctx.d()->callData = callData; Q_ASSERT(v4->currentContext() == &ctx); return f->d()->code(&ctx, f->d()->index); @@ -622,18 +622,18 @@ BoundFunction::BoundFunction(ExecutionContext *scope, FunctionObjectRef target, Scope s(scope); ScopedValue protectThis(s, this); - ScopedValue l(s, target->get(scope->engine->id_length)); + ScopedValue l(s, target->get(scope->d()->engine->id_length)); int len = l->toUInt32(); len -= boundArgs.size(); if (len < 0) len = 0; - defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(len)); + defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(len)); - ExecutionEngine *v4 = scope->engine; + ExecutionEngine *v4 = scope->d()->engine; Property pd(v4->thrower, v4->thrower); - insertMember(scope->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); - insertMember(scope->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); + insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable); } void BoundFunction::destroy(Managed *that) @@ -644,7 +644,7 @@ void BoundFunction::destroy(Managed *that) ReturnedValue BoundFunction::call(Managed *that, CallData *dd) { BoundFunction *f = static_cast(that); - Scope scope(f->scope()->engine); + Scope scope(f->scope()->d()->engine); if (scope.hasException()) return Encode::undefined(); @@ -658,7 +658,7 @@ ReturnedValue BoundFunction::call(Managed *that, CallData *dd) ReturnedValue BoundFunction::construct(Managed *that, CallData *dd) { BoundFunction *f = static_cast(that); - Scope scope(f->scope()->engine); + Scope scope(f->scope()->d()->engine); if (scope.hasException()) return Encode::undefined(); diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index e78b913302..1be9561193 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -347,10 +347,10 @@ static QString decode(const QString &input, DecodeMode decodeMode, bool *ok) DEFINE_OBJECT_VTABLE(EvalFunction); EvalFunction::EvalFunction(ExecutionContext *scope) - : FunctionObject(scope, scope->engine->id_eval) + : FunctionObject(scope, scope->d()->engine->id_eval) { setVTable(staticVTable()); - defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); + defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); } ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) @@ -363,16 +363,16 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) ContextStateSaver(ExecutionContext *context) : savedContext(context) - , strictMode(context->strictMode) - , evalCode(context->currentEvalCode) - , compilationUnit(context->compilationUnit) + , strictMode(context->d()->strictMode) + , evalCode(context->d()->currentEvalCode) + , compilationUnit(context->d()->compilationUnit) {} ~ContextStateSaver() { - savedContext->strictMode = strictMode; - savedContext->currentEvalCode = evalCode; - savedContext->compilationUnit = compilationUnit; + savedContext->d()->strictMode = strictMode; + savedContext->d()->currentEvalCode = evalCode; + savedContext->d()->compilationUnit = compilationUnit; } }; @@ -396,10 +396,10 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) return callData->args[0].asReturnedValue(); const QString code = callData->args[0].stringValue()->toQString(); - bool inheritContext = !ctx->strictMode; + bool inheritContext = !ctx->d()->strictMode; Script script(ctx, code, QStringLiteral("eval code")); - script.strictMode = (directCall && parentContext->strictMode); + script.strictMode = (directCall && parentContext->d()->strictMode); script.inheritContext = inheritContext; script.parse(); if (scope.engine->hasException) @@ -409,14 +409,14 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) if (!function) return Encode::undefined(); - d()->strictMode = function->isStrict() || (ctx->strictMode); + d()->strictMode = function->isStrict() || (ctx->d()->strictMode); d()->needsActivation = function->needsActivation(); if (strictMode()) { ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function)); ScopedCallData callData(scope, 0); - callData->thisObject = ctx->callData->thisObject; + callData->thisObject = ctx->d()->callData->thisObject; return e->call(callData); } @@ -424,12 +424,12 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) ExecutionContext::EvalCode evalCode; evalCode.function = function; - evalCode.next = ctx->currentEvalCode; - ctx->currentEvalCode = &evalCode; + evalCode.next = ctx->d()->currentEvalCode; + ctx->d()->currentEvalCode = &evalCode; // set the correct strict mode flag on the context - ctx->strictMode = strictMode(); - ctx->compilationUnit = function->compilationUnit; + ctx->d()->strictMode = strictMode(); + ctx->d()->compilationUnit = function->compilationUnit; return function->code(ctx, function->codeData); } @@ -470,7 +470,7 @@ ReturnedValue GlobalFunctions::method_parseInt(CallContext *ctx) String *inputString = string->toString(ctx); // 1 QString trimmed = inputString->toQString().trimmed(); // 2 - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); const QChar *pos = trimmed.constData(); @@ -574,117 +574,117 @@ ReturnedValue GlobalFunctions::method_parseFloat(CallContext *ctx) /// isNaN [15.1.2.4] ReturnedValue GlobalFunctions::method_isNaN(CallContext *ctx) { - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) // undefined gets converted to NaN return Encode(true); - if (ctx->callData->args[0].integerCompatible()) + if (ctx->d()->callData->args[0].integerCompatible()) return Encode(false); - double d = ctx->callData->args[0].toNumber(); + double d = ctx->d()->callData->args[0].toNumber(); return Encode((bool)std::isnan(d)); } /// isFinite [15.1.2.5] ReturnedValue GlobalFunctions::method_isFinite(CallContext *ctx) { - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) // undefined gets converted to NaN return Encode(false); - if (ctx->callData->args[0].integerCompatible()) + if (ctx->d()->callData->args[0].integerCompatible()) return Encode(true); - double d = ctx->callData->args[0].toNumber(); + double d = ctx->d()->callData->args[0].toNumber(); return Encode((bool)std::isfinite(d)); } /// decodeURI [15.1.3.1] ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = decode(uriString, DecodeNonReserved, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } /// decodeURIComponent [15.1.3.2] ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = decode(uriString, DecodeAll, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } /// encodeURI [15.1.3.3] ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = encode(uriString, uriUnescapedReserved, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } /// encodeURIComponent [15.1.3.4] ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context) { - if (context->callData->argc == 0) + if (context->d()->callData->argc == 0) return Encode::undefined(); - QString uriString = context->callData->args[0].toString(context)->toQString(); + QString uriString = context->d()->callData->args[0].toString(context)->toQString(); bool ok; QString out = encode(uriString, uriUnescaped, &ok); if (!ok) { Scope scope(context); - ScopedString s(scope, context->engine->newString(QStringLiteral("malformed URI sequence"))); + ScopedString s(scope, context->d()->engine->newString(QStringLiteral("malformed URI sequence"))); return context->throwURIError(s); } - return context->engine->newString(out)->asReturnedValue(); + return context->d()->engine->newString(out)->asReturnedValue(); } ReturnedValue GlobalFunctions::method_escape(CallContext *context) { - if (!context->callData->argc) - return context->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); + if (!context->d()->callData->argc) + return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); - QString str = context->callData->args[0].toString(context)->toQString(); - return context->engine->newString(escape(str))->asReturnedValue(); + QString str = context->d()->callData->args[0].toString(context)->toQString(); + return context->d()->engine->newString(escape(str))->asReturnedValue(); } ReturnedValue GlobalFunctions::method_unescape(CallContext *context) { - if (!context->callData->argc) - return context->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); + if (!context->d()->callData->argc) + return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); - QString str = context->callData->args[0].toString(context)->toQString(); - return context->engine->newString(unescape(str))->asReturnedValue(); + QString str = context->d()->callData->args[0].toString(context)->toQString(); + return context->d()->engine->newString(unescape(str))->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index d5bae0e35e..6b382b53fa 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -181,27 +181,26 @@ void QV4Include::finished() */ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) { - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) return QV4::Encode::undefined(); - QV4::ExecutionEngine *v4 = ctx->engine; - QV4::Scope scope(v4); - QV8Engine *engine = v4->v8Engine; - QQmlContextData *context = QV4::QmlContextWrapper::callingContext(v4); + QV4::Scope scope(ctx->engine()); + QV8Engine *engine = scope.engine->v8Engine; + QQmlContextData *context = QV4::QmlContextWrapper::callingContext(scope.engine); if (!context || !context->isJSContext) V4THROW_ERROR("Qt.include(): Can only be called from JavaScript files"); - QUrl url(ctx->engine->resolvedUrl(ctx->callData->args[0].toQStringNoThrow())); + QUrl url(scope.engine->resolvedUrl(ctx->d()->callData->args[0].toQStringNoThrow())); QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue()); - if (ctx->callData->argc >= 2 && ctx->callData->args[1].asFunctionObject()) - callbackFunction = ctx->callData->args[1]; + if (ctx->d()->callData->argc >= 2 && ctx->d()->callData->args[1].asFunctionObject()) + callbackFunction = ctx->d()->callData->args[1]; QString localFile = QQmlFile::urlToLocalFileOrQrc(url); QV4::ScopedValue result(scope); - QV4::ScopedObject qmlcontextobject(scope, v4->qmlContextObject()); + QV4::ScopedObject qmlcontextobject(scope, scope.engine->qmlContextObject()); if (localFile.isEmpty()) { QV4Include *i = new QV4Include(url, engine, context, @@ -218,21 +217,21 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) QString code = QString::fromUtf8(data); QmlIR::Document::removeScriptPragmas(code); - QV4::Script script(v4, qmlcontextobject, code, url.toString()); + QV4::Script script(scope.engine, qmlcontextobject, code, url.toString()); - QV4::ExecutionContext *ctx = v4->currentContext(); + QV4::ExecutionContext *ctx = scope.engine->currentContext(); script.parse(); - if (!v4->hasException) + if (!scope.engine->hasException) script.run(); - if (v4->hasException) { + if (scope.engine->hasException) { QV4::ScopedValue ex(scope, ctx->catchException()); - result = resultValue(v4, Exception); - result->asObject()->put(QV4::ScopedString(scope, v4->newString(QStringLiteral("exception"))), ex); + result = resultValue(scope.engine, Exception); + result->asObject()->put(QV4::ScopedString(scope, scope.engine->newString(QStringLiteral("exception"))), ex); } else { - result = resultValue(v4, Ok); + result = resultValue(scope.engine, Ok); } } else { - result = resultValue(v4, NetworkError); + result = resultValue(scope.engine, NetworkError); } callback(callbackFunction, result); diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index c904dd95c9..8552936663 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -237,7 +237,7 @@ ReturnedValue JsonParser::parseObject() BEGIN << "parseObject pos=" << json; Scope scope(context); - ScopedObject o(scope, context->engine->newObject()); + ScopedObject o(scope, context->d()->engine->newObject()); QChar token = nextToken(); while (token == Quote) { @@ -285,7 +285,7 @@ bool JsonParser::parseMember(ObjectRef o) if (!parseValue(val)) return false; - ScopedString s(scope, context->engine->newIdentifier(key)); + ScopedString s(scope, context->d()->engine->newIdentifier(key)); uint idx = s->asArrayIndex(); if (idx < UINT_MAX) { o->putIndexed(idx, val); @@ -304,7 +304,7 @@ ReturnedValue JsonParser::parseArray() { Scope scope(context); BEGIN << "parseArray"; - Scoped array(scope, context->engine->newArrayObject()); + Scoped array(scope, context->d()->engine->newArrayObject()); if (++nestingLevel > nestingLimit) { lastError = QJsonParseError::DeepNesting; @@ -407,7 +407,7 @@ bool JsonParser::parseValue(ValueRef val) return false; DEBUG << "value: string"; END; - val = context->engine->newString(value); + val = context->d()->engine->newString(value); return true; } case BeginArray: { @@ -710,21 +710,21 @@ QString Stringify::Str(const QString &key, ValueRef v) ScopedValue value(scope, *v); ScopedObject o(scope, value); if (o) { - ScopedString s(scope, ctx->engine->newString(QStringLiteral("toJSON"))); + ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toJSON"))); Scoped toJSON(scope, o->get(s)); if (!!toJSON) { ScopedCallData callData(scope, 1); callData->thisObject = value; - callData->args[0] = ctx->engine->newString(key); + callData->args[0] = ctx->d()->engine->newString(key); value = toJSON->call(callData); } } if (replacerFunction) { - ScopedObject holder(scope, ctx->engine->newObject()); + ScopedObject holder(scope, ctx->d()->engine->newObject()); holder->put(ctx, QString(), value); ScopedCallData callData(scope, 2); - callData->args[0] = ctx->engine->newString(key); + callData->args[0] = ctx->d()->engine->newString(key); callData->args[1] = value; callData->thisObject = holder; value = replacerFunction->call(callData); @@ -954,7 +954,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) QString result = stringify.Str(QString(), arg0); if (result.isEmpty() || scope.engine->hasException) return Encode::undefined(); - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } @@ -962,7 +962,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) ReturnedValue JsonObject::fromJsonValue(ExecutionEngine *engine, const QJsonValue &value) { if (value.isString()) - return engine->currentContext()->engine->newString(value.toString())->asReturnedValue(); + return engine->currentContext()->d()->engine->newString(value.toString())->asReturnedValue(); else if (value.isDouble()) return Encode(value.toDouble()); else if (value.isBool()) diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 4d56a7de98..ed555b7763 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -581,7 +581,7 @@ ReturnedValue Lookup::arrayLengthGetter(Lookup *l, const ValueRef object) ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx) { - Object *o = ctx->engine->globalObject; + Object *o = ctx->d()->engine->globalObject; PropertyAttributes attrs; ReturnedValue v = l->lookup(o, &attrs); if (v != Primitive::emptyValue().asReturnedValue()) { @@ -610,7 +610,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionContext *ctx) ReturnedValue Lookup::globalGetter0(Lookup *l, ExecutionContext *ctx) { - Object *o = ctx->engine->globalObject; + Object *o = ctx->d()->engine->globalObject; if (l->classList[0] == o->internalClass()) return o->memberData()[l->index].asReturnedValue(); @@ -620,7 +620,7 @@ ReturnedValue Lookup::globalGetter0(Lookup *l, ExecutionContext *ctx) ReturnedValue Lookup::globalGetter1(Lookup *l, ExecutionContext *ctx) { - Object *o = ctx->engine->globalObject; + Object *o = ctx->d()->engine->globalObject; if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass()) return o->prototype()->memberData()[l->index].asReturnedValue(); @@ -631,7 +631,7 @@ ReturnedValue Lookup::globalGetter1(Lookup *l, ExecutionContext *ctx) ReturnedValue Lookup::globalGetter2(Lookup *l, ExecutionContext *ctx) { - Object *o = ctx->engine->globalObject; + Object *o = ctx->d()->engine->globalObject; if (l->classList[0] == o->internalClass()) { o = o->prototype(); if (l->classList[1] == o->internalClass()) { @@ -647,7 +647,7 @@ ReturnedValue Lookup::globalGetter2(Lookup *l, ExecutionContext *ctx) ReturnedValue Lookup::globalGetterAccessor0(Lookup *l, ExecutionContext *ctx) { - Object *o = ctx->engine->globalObject; + Object *o = ctx->d()->engine->globalObject; if (l->classList[0] == o->internalClass()) { Scope scope(o->engine()); FunctionObject *getter = o->propertyAt(l->index)->getter(); @@ -664,7 +664,7 @@ ReturnedValue Lookup::globalGetterAccessor0(Lookup *l, ExecutionContext *ctx) ReturnedValue Lookup::globalGetterAccessor1(Lookup *l, ExecutionContext *ctx) { - Object *o = ctx->engine->globalObject; + Object *o = ctx->d()->engine->globalObject; if (l->classList[0] == o->internalClass() && l->classList[1] == o->prototype()->internalClass()) { Scope scope(o->engine()); @@ -682,7 +682,7 @@ ReturnedValue Lookup::globalGetterAccessor1(Lookup *l, ExecutionContext *ctx) ReturnedValue Lookup::globalGetterAccessor2(Lookup *l, ExecutionContext *ctx) { - Object *o = ctx->engine->globalObject; + Object *o = ctx->d()->engine->globalObject; if (l->classList[0] == o->internalClass()) { o = o->prototype(); if (l->classList[1] == o->internalClass()) { diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index 16d76e6914..6216fddaad 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -104,15 +104,15 @@ static double copySign(double x, double y) ReturnedValue MathObject::method_abs(CallContext *context) { - if (!context->callData->argc) + if (!context->d()->callData->argc) return Encode(qSNaN()); - if (context->callData->args[0].isInteger()) { - int i = context->callData->args[0].integerValue(); + if (context->d()->callData->args[0].isInteger()) { + int i = context->d()->callData->args[0].integerValue(); return Encode(i < 0 ? - i : i); } - double v = context->callData->args[0].toNumber(); + double v = context->d()->callData->args[0].toNumber(); if (v == 0) // 0 | -0 return Encode(0); @@ -121,7 +121,7 @@ ReturnedValue MathObject::method_abs(CallContext *context) ReturnedValue MathObject::method_acos(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : 2; + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2; if (v > 1) return Encode(qSNaN()); @@ -130,7 +130,7 @@ ReturnedValue MathObject::method_acos(CallContext *context) ReturnedValue MathObject::method_asin(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : 2; + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2; if (v > 1) return Encode(qSNaN()); else @@ -139,7 +139,7 @@ ReturnedValue MathObject::method_asin(CallContext *context) ReturnedValue MathObject::method_atan(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); if (v == 0.0) return Encode(v); else @@ -148,8 +148,8 @@ ReturnedValue MathObject::method_atan(CallContext *context) ReturnedValue MathObject::method_atan2(CallContext *context) { - double v1 = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); - double v2 = context->callData->argc > 1 ? context->callData->args[1].toNumber() : qSNaN(); + double v1 = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v2 = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN(); if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0)) return Encode(copySign(0, -1.0)); @@ -166,7 +166,7 @@ ReturnedValue MathObject::method_atan2(CallContext *context) ReturnedValue MathObject::method_ceil(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); if (v < 0.0 && v > -1.0) return Encode(copySign(0, -1.0)); else @@ -175,13 +175,13 @@ ReturnedValue MathObject::method_ceil(CallContext *context) ReturnedValue MathObject::method_cos(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); return Encode(::cos(v)); } ReturnedValue MathObject::method_exp(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); if (qIsInf(v)) { if (copySign(1.0, v) == -1.0) return Encode(0); @@ -194,13 +194,13 @@ ReturnedValue MathObject::method_exp(CallContext *context) ReturnedValue MathObject::method_floor(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); return Encode(::floor(v)); } ReturnedValue MathObject::method_log(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); if (v < 0) return Encode(qSNaN()); else @@ -210,8 +210,8 @@ ReturnedValue MathObject::method_log(CallContext *context) ReturnedValue MathObject::method_max(CallContext *context) { double mx = -qInf(); - for (int i = 0; i < context->callData->argc; ++i) { - double x = context->callData->args[i].toNumber(); + for (int i = 0; i < context->d()->callData->argc; ++i) { + double x = context->d()->callData->args[i].toNumber(); if (x > mx || std::isnan(x)) mx = x; } @@ -221,8 +221,8 @@ ReturnedValue MathObject::method_max(CallContext *context) ReturnedValue MathObject::method_min(CallContext *context) { double mx = qInf(); - for (int i = 0; i < context->callData->argc; ++i) { - double x = context->callData->args[i].toNumber(); + for (int i = 0; i < context->d()->callData->argc; ++i) { + double x = context->d()->callData->args[i].toNumber(); if ((x == 0 && mx == x && copySign(1.0, x) == -1.0) || (x < mx) || std::isnan(x)) { mx = x; @@ -233,8 +233,8 @@ ReturnedValue MathObject::method_min(CallContext *context) ReturnedValue MathObject::method_pow(CallContext *context) { - double x = context->callData->argc > 0 ? context->callData->args[0].toNumber() : qSNaN(); - double y = context->callData->argc > 1 ? context->callData->args[1].toNumber() : qSNaN(); + double x = context->d()->callData->argc > 0 ? context->d()->callData->args[0].toNumber() : qSNaN(); + double y = context->d()->callData->argc > 1 ? context->d()->callData->args[1].toNumber() : qSNaN(); if (std::isnan(y)) return Encode(qSNaN()); @@ -294,26 +294,26 @@ ReturnedValue MathObject::method_random(CallContext *context) ReturnedValue MathObject::method_round(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); v = copySign(::floor(v + 0.5), v); return Encode(v); } ReturnedValue MathObject::method_sin(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); return Encode(::sin(v)); } ReturnedValue MathObject::method_sqrt(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); return Encode(::sqrt(v)); } ReturnedValue MathObject::method_tan(CallContext *context) { - double v = context->callData->argc ? context->callData->args[0].toNumber() : qSNaN(); + double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); if (v == 0.0) return Encode(v); else diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index 1a41150bd2..426f2c7861 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -103,9 +103,9 @@ void NumberPrototype::init(ExecutionEngine *engine, ObjectRef ctor) inline ReturnedValue thisNumberValue(ExecutionContext *ctx) { - if (ctx->callData->thisObject.isNumber()) - return ctx->callData->thisObject.asReturnedValue(); - NumberObject *n = ctx->callData->thisObject.asNumberObject(); + if (ctx->d()->callData->thisObject.isNumber()) + return ctx->d()->callData->thisObject.asReturnedValue(); + NumberObject *n = ctx->d()->callData->thisObject.asNumberObject(); if (!n) return ctx->throwTypeError(); return n->value().asReturnedValue(); @@ -113,9 +113,9 @@ inline ReturnedValue thisNumberValue(ExecutionContext *ctx) inline double thisNumber(ExecutionContext *ctx) { - if (ctx->callData->thisObject.isNumber()) - return ctx->callData->thisObject.asDouble(); - NumberObject *n = ctx->callData->thisObject.asNumberObject(); + if (ctx->d()->callData->thisObject.isNumber()) + return ctx->d()->callData->thisObject.asDouble(); + NumberObject *n = ctx->d()->callData->thisObject.asNumberObject(); if (!n) return ctx->throwTypeError(); return n->value().asDouble(); @@ -124,19 +124,19 @@ inline double thisNumber(ExecutionContext *ctx) ReturnedValue NumberPrototype::method_toString(CallContext *ctx) { double num = thisNumber(ctx); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); - if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) { - int radix = ctx->callData->args[0].toInt32(); + if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) { + int radix = ctx->d()->callData->args[0].toInt32(); if (radix < 2 || radix > 36) return ctx->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix") .arg(radix)); if (std::isnan(num)) { - return ctx->engine->newString(QStringLiteral("NaN"))->asReturnedValue(); + return ctx->d()->engine->newString(QStringLiteral("NaN"))->asReturnedValue(); } else if (qIsInf(num)) { - return ctx->engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue(); + return ctx->d()->engine->newString(QLatin1String(num < 0 ? "-Infinity" : "Infinity"))->asReturnedValue(); } if (radix != 10) { @@ -166,7 +166,7 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx) } if (negative) str.prepend(QLatin1Char('-')); - return ctx->engine->newString(str)->asReturnedValue(); + return ctx->d()->engine->newString(str)->asReturnedValue(); } } @@ -178,7 +178,7 @@ ReturnedValue NumberPrototype::method_toLocaleString(CallContext *ctx) Scope scope(ctx); ScopedValue v(scope, thisNumberValue(ctx)); ScopedString str(scope, v->toString(ctx)); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); return str.asReturnedValue(); } @@ -191,19 +191,19 @@ ReturnedValue NumberPrototype::method_valueOf(CallContext *ctx) ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) { double v = thisNumber(ctx); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); double fdigits = 0; - if (ctx->callData->argc > 0) - fdigits = ctx->callData->args[0].toInteger(); + if (ctx->d()->callData->argc > 0) + fdigits = ctx->d()->callData->args[0].toInteger(); if (std::isnan(fdigits)) fdigits = 0; if (fdigits < 0 || fdigits > 20) - return ctx->throwRangeError(ctx->callData->thisObject); + return ctx->throwRangeError(ctx->d()->callData->thisObject); QString str; if (std::isnan(v)) @@ -214,22 +214,22 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) str = QString::number(v, 'f', int (fdigits)); else return RuntimeHelpers::stringFromNumber(ctx, v)->asReturnedValue(); - return ctx->engine->newString(str)->asReturnedValue(); + return ctx->d()->engine->newString(str)->asReturnedValue(); } ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx) { Scope scope(ctx); double d = thisNumber(ctx); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); int fdigits = -1; - if (ctx->callData->argc && !ctx->callData->args[0].isUndefined()) { - fdigits = ctx->callData->args[0].toInt32(); + if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) { + fdigits = ctx->d()->callData->args[0].toInt32(); if (fdigits < 0 || fdigits > 20) { - ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range"))); + ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range"))); return ctx->throwRangeError(error); } } @@ -239,22 +239,22 @@ ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx) double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToExponential(d, fdigits, &builder); QString result = QString::fromLatin1(builder.Finalize()); - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx) { Scope scope(ctx); ScopedValue v(scope, thisNumberValue(ctx)); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); - if (!ctx->callData->argc || ctx->callData->args[0].isUndefined()) + if (!ctx->d()->callData->argc || ctx->d()->callData->args[0].isUndefined()) return RuntimeHelpers::toString(ctx, v); - double precision = ctx->callData->args[0].toInt32(); + double precision = ctx->d()->callData->args[0].toInt32(); if (precision < 1 || precision > 21) { - ScopedString error(scope, ctx->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range"))); + ScopedString error(scope, ctx->d()->engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range"))); return ctx->throwRangeError(error); } @@ -263,5 +263,5 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx) double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToPrecision(v->asDouble(), precision, &builder); QString result = QString::fromLatin1(builder.Finalize()); - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index 3fcc52e995..d24ae97d41 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -103,7 +103,7 @@ bool Object::setPrototype(Object *proto) void Object::put(ExecutionContext *ctx, const QString &name, const ValueRef value) { Scope scope(ctx); - ScopedString n(scope, ctx->engine->newString(name)); + ScopedString n(scope, ctx->d()->engine->newString(name)); put(n, value); } @@ -145,7 +145,7 @@ void Object::putValue(Property *pd, PropertyAttributes attrs, const ValueRef val return; reject: - if (engine()->currentContext()->strictMode) + if (engine()->currentContext()->d()->strictMode) engine()->currentContext()->throwTypeError(); } @@ -737,7 +737,7 @@ void Object::internalPut(const StringRef name, const ValueRef value) return; reject: - if (engine()->currentContext()->strictMode) { + if (engine()->currentContext()->d()->strictMode) { QString message = QStringLiteral("Cannot assign to read-only property \""); message += name->toQString(); message += QLatin1Char('\"'); @@ -809,7 +809,7 @@ void Object::internalPutIndexed(uint index, const ValueRef value) return; reject: - if (engine()->currentContext()->strictMode) + if (engine()->currentContext()->d()->strictMode) engine()->currentContext()->throwTypeError(); } @@ -831,7 +831,7 @@ bool Object::internalDeleteProperty(const StringRef name) InternalClass::removeMember(this, name->identifier()); return true; } - if (engine()->currentContext()->strictMode) + if (engine()->currentContext()->d()->strictMode) engine()->currentContext()->throwTypeError(); return false; } @@ -847,7 +847,7 @@ bool Object::internalDeleteIndexedProperty(uint index) if (!arrayData() || arrayData()->vtable()->del(this, index)) return true; - if (engine()->currentContext()->strictMode) + if (engine()->currentContext()->d()->strictMode) engine()->currentContext()->throwTypeError(); return false; } @@ -866,8 +866,8 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, const StringRef name, PropertyAttributes *cattrs; uint memberIndex; - if (isArrayObject() && name->equals(ctx->engine->id_length)) { - assert(ArrayObject::LengthPropertyIndex == internalClass()->find(ctx->engine->id_length)); + if (isArrayObject() && name->equals(ctx->d()->engine->id_length)) { + assert(ArrayObject::LengthPropertyIndex == internalClass()->find(ctx->d()->engine->id_length)); Property *lp = propertyAt(ArrayObject::LengthPropertyIndex); cattrs = internalClass()->propertyData.constData() + ArrayObject::LengthPropertyIndex; if (attrs.isEmpty() || p.isSubset(attrs, *lp, *cattrs)) @@ -913,7 +913,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, const StringRef name, return __defineOwnProperty__(ctx, memberIndex, name, p, attrs); reject: - if (ctx->strictMode) + if (ctx->d()->strictMode) ctx->throwTypeError(); return false; } @@ -929,7 +929,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Prop return defineOwnProperty2(ctx, index, p, attrs); reject: - if (ctx->strictMode) + if (ctx->d()->strictMode) ctx->throwTypeError(); return false; } @@ -965,7 +965,7 @@ bool Object::defineOwnProperty2(ExecutionContext *ctx, uint index, const Propert return __defineOwnProperty__(ctx, index, StringRef::null(), p, attrs); reject: - if (ctx->strictMode) + if (ctx->d()->strictMode) ctx->throwTypeError(); return false; } @@ -1057,7 +1057,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri setHasAccessorProperty(); return true; reject: - if (ctx->strictMode) + if (ctx->d()->strictMode) ctx->throwTypeError(); return false; } @@ -1066,7 +1066,7 @@ bool Object::__defineOwnProperty__(ExecutionContext *ctx, uint index, const Stri bool Object::__defineOwnProperty__(ExecutionContext *ctx, const QString &name, const Property &p, PropertyAttributes attrs) { Scope scope(ctx); - ScopedString s(scope, ctx->engine->newString(name)); + ScopedString s(scope, ctx->d()->engine->newString(name)); return __defineOwnProperty__(ctx, s, p, attrs); } diff --git a/src/qml/jsruntime/qv4objectiterator_p.h b/src/qml/jsruntime/qv4objectiterator_p.h index 7fb46344dc..9a212df5a5 100644 --- a/src/qml/jsruntime/qv4objectiterator_p.h +++ b/src/qml/jsruntime/qv4objectiterator_p.h @@ -99,7 +99,7 @@ struct ForEachIteratorObject: Object { Q_MANAGED_TYPE(ForeachIteratorObject) ForEachIteratorObject(ExecutionContext *ctx, const ObjectRef o) - : Object(ctx->engine) + : Object(ctx->d()->engine) , __data(o, ObjectIterator::EnumerableOnly|ObjectIterator::WithProtoChain) { setVTable(staticVTable()); } diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 9971289730..48fea0d0bf 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -176,7 +176,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(CallContext *context) if (!O) return context->throwTypeError(); - ScopedArrayObject array(scope, getOwnPropertyNames(context->engine, context->callData->args[0])); + ScopedArrayObject array(scope, getOwnPropertyNames(context->d()->engine, context->d()->callData->args[0])); return array.asReturnedValue(); } @@ -187,11 +187,11 @@ ReturnedValue ObjectPrototype::method_create(CallContext *ctx) if (!O->isObject() && !O->isNull()) return ctx->throwTypeError(); - Scoped newObject(scope, ctx->engine->newObject()); + Scoped newObject(scope, ctx->d()->engine->newObject()); newObject->setPrototype(O->asObject()); - if (ctx->callData->argc > 1 && !ctx->callData->args[1].isUndefined()) { - ctx->callData->args[0] = newObject.asReturnedValue(); + if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) { + ctx->d()->callData->args[0] = newObject.asReturnedValue(); return method_defineProperties(ctx); } @@ -395,7 +395,7 @@ ReturnedValue ObjectPrototype::method_keys(CallContext *ctx) if (!o) return ctx->throwTypeError(); - Scoped a(scope, ctx->engine->newArrayObject()); + Scoped a(scope, ctx->d()->engine->newArrayObject()); ObjectIterator it(scope, o, ObjectIterator::EnumerableOnly); ScopedValue name(scope); @@ -412,24 +412,24 @@ ReturnedValue ObjectPrototype::method_keys(CallContext *ctx) ReturnedValue ObjectPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - if (ctx->callData->thisObject.isUndefined()) { - return ctx->engine->newString(QStringLiteral("[object Undefined]"))->asReturnedValue(); - } else if (ctx->callData->thisObject.isNull()) { - return ctx->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue(); + if (ctx->d()->callData->thisObject.isUndefined()) { + return ctx->d()->engine->newString(QStringLiteral("[object Undefined]"))->asReturnedValue(); + } else if (ctx->d()->callData->thisObject.isNull()) { + return ctx->d()->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue(); } else { - ScopedObject obj(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->callData->thisObject))); + ScopedObject obj(scope, RuntimeHelpers::toObject(ctx, ValueRef(&ctx->d()->callData->thisObject))); QString className = obj->className(); - return ctx->engine->newString(QString::fromLatin1("[object %1]").arg(className))->asReturnedValue(); + return ctx->d()->engine->newString(QString::fromLatin1("[object %1]").arg(className))->asReturnedValue(); } } ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->callData->thisObject.toObject(ctx)); + ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(ctx)); if (!o) return Encode::undefined(); - Scoped f(scope, o->get(ctx->engine->id_toString)); + Scoped f(scope, o->get(ctx->d()->engine->id_toString)); if (!f) return ctx->throwTypeError(); ScopedCallData callData(scope, 0); @@ -440,8 +440,8 @@ ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx) ReturnedValue ObjectPrototype::method_valueOf(CallContext *ctx) { Scope scope(ctx); - ScopedValue v(scope, ctx->callData->thisObject.toObject(ctx)); - if (ctx->engine->hasException) + ScopedValue v(scope, ctx->d()->callData->thisObject.toObject(ctx)); + if (ctx->d()->engine->hasException) return Encode::undefined(); return v.asReturnedValue(); } @@ -452,7 +452,7 @@ ReturnedValue ObjectPrototype::method_hasOwnProperty(CallContext *ctx) Scoped P(scope, ctx->argument(0), Scoped::Convert); if (scope.engine->hasException) return Encode::undefined(); - Scoped O(scope, ctx->callData->thisObject, Scoped::Convert); + Scoped O(scope, ctx->d()->callData->thisObject, Scoped::Convert); if (scope.engine->hasException) return Encode::undefined(); bool r = O->hasOwnProperty(P); @@ -468,7 +468,7 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(CallContext *ctx) if (!V) return Encode(false); - Scoped O(scope, ctx->callData->thisObject, Scoped::Convert); + Scoped O(scope, ctx->d()->callData->thisObject, Scoped::Convert); if (scope.engine->hasException) return Encode::undefined(); Scoped proto(scope, V->prototype()); @@ -487,7 +487,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - Scoped o(scope, ctx->callData->thisObject, Scoped::Convert); + Scoped o(scope, ctx->d()->callData->thisObject, Scoped::Convert); if (scope.engine->hasException) return Encode::undefined(); PropertyAttributes attrs; @@ -497,7 +497,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx) ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) { - if (ctx->callData->argc < 2) + if (ctx->d()->callData->argc < 2) return ctx->throwTypeError(); Scope scope(ctx); @@ -509,11 +509,11 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - Scoped o(scope, ctx->callData->thisObject); + Scoped o(scope, ctx->d()->callData->thisObject); if (!o) { - if (!ctx->callData->thisObject.isUndefined()) + if (!ctx->d()->callData->thisObject.isUndefined()) return Encode::undefined(); - o = ctx->engine->globalObject; + o = ctx->d()->engine->globalObject; } Property pd; @@ -525,7 +525,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) { - if (ctx->callData->argc < 2) + if (ctx->d()->callData->argc < 2) return ctx->throwTypeError(); Scope scope(ctx); @@ -537,11 +537,11 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - Scoped o(scope, ctx->callData->thisObject); + Scoped o(scope, ctx->d()->callData->thisObject); if (!o) { - if (!ctx->callData->thisObject.isUndefined()) + if (!ctx->d()->callData->thisObject.isUndefined()) return Encode::undefined(); - o = ctx->engine->globalObject; + o = ctx->d()->engine->globalObject; } Property pd; @@ -554,7 +554,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->callData->thisObject.asObject()); + ScopedObject o(scope, ctx->d()->callData->thisObject.asObject()); if (!o) return ctx->throwTypeError(); @@ -564,16 +564,16 @@ ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx) ReturnedValue ObjectPrototype::method_set_proto(CallContext *ctx) { Scope scope(ctx); - Scoped o(scope, ctx->callData->thisObject); - if (!o || !ctx->callData->argc) + Scoped o(scope, ctx->d()->callData->thisObject); + if (!o || !ctx->d()->callData->argc) return ctx->throwTypeError(); - if (ctx->callData->args[0].isNull()) { + if (ctx->d()->callData->args[0].isNull()) { o->setPrototype(0); return Encode::undefined(); } - Scoped p(scope, ctx->callData->args[0]); + Scoped p(scope, ctx->d()->callData->args[0]); bool ok = false; if (!!p) { if (o->prototype() == p.getPointer()) { @@ -601,14 +601,14 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef desc->set = Primitive::emptyValue(); ScopedValue tmp(scope); - if (o->hasProperty(ctx->engine->id_enumerable)) - attrs->setEnumerable((tmp = o->get(ctx->engine->id_enumerable))->toBoolean()); + if (o->hasProperty(ctx->d()->engine->id_enumerable)) + attrs->setEnumerable((tmp = o->get(ctx->d()->engine->id_enumerable))->toBoolean()); - if (o->hasProperty(ctx->engine->id_configurable)) - attrs->setConfigurable((tmp = o->get(ctx->engine->id_configurable))->toBoolean()); + if (o->hasProperty(ctx->d()->engine->id_configurable)) + attrs->setConfigurable((tmp = o->get(ctx->d()->engine->id_configurable))->toBoolean()); - if (o->hasProperty(ctx->engine->id_get)) { - ScopedValue get(scope, o->get(ctx->engine->id_get)); + if (o->hasProperty(ctx->d()->engine->id_get)) { + ScopedValue get(scope, o->get(ctx->d()->engine->id_get)); FunctionObject *f = get->asFunctionObject(); if (f || get->isUndefined()) { desc->value = get; @@ -619,8 +619,8 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef attrs->setType(PropertyAttributes::Accessor); } - if (o->hasProperty(ctx->engine->id_set)) { - ScopedValue set(scope, o->get(ctx->engine->id_set)); + if (o->hasProperty(ctx->d()->engine->id_set)) { + ScopedValue set(scope, o->get(ctx->d()->engine->id_set)); FunctionObject *f = set->asFunctionObject(); if (f || set->isUndefined()) { desc->set = set; @@ -631,22 +631,22 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionContext *ctx, const ValueRef attrs->setType(PropertyAttributes::Accessor); } - if (o->hasProperty(ctx->engine->id_writable)) { + if (o->hasProperty(ctx->d()->engine->id_writable)) { if (attrs->isAccessor()) { ctx->throwTypeError(); return; } - attrs->setWritable((tmp = o->get(ctx->engine->id_writable))->toBoolean()); + attrs->setWritable((tmp = o->get(ctx->d()->engine->id_writable))->toBoolean()); // writable forces it to be a data descriptor desc->value = Primitive::undefinedValue(); } - if (o->hasProperty(ctx->engine->id_value)) { + if (o->hasProperty(ctx->d()->engine->id_value)) { if (attrs->isAccessor()) { ctx->throwTypeError(); return; } - desc->value = o->get(ctx->engine->id_value); + desc->value = o->get(ctx->d()->engine->id_value); attrs->setType(PropertyAttributes::Data); } @@ -660,7 +660,7 @@ ReturnedValue ObjectPrototype::fromPropertyDescriptor(ExecutionContext *ctx, con if (!desc) return Encode::undefined(); - ExecutionEngine *engine = ctx->engine; + ExecutionEngine *engine = ctx->d()->engine; Scope scope(engine); // Let obj be the result of creating a new object as if by the expression new Object() where Object // is the standard built-in constructor with that name. diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index b81b273f1d..a731eee624 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -284,14 +284,14 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD if (name->equals(scope.engine->id_destroy) || name->equals(scope.engine->id_toString)) { int index = name->equals(scope.engine->id_destroy) ? QV4::QObjectMethod::DestroyMethod : QV4::QObjectMethod::ToStringMethod; - QV4::ScopedValue method(scope, QV4::QObjectMethod::create(ctx->engine->rootContext, d()->object, index)); + QV4::ScopedValue method(scope, QV4::QObjectMethod::create(ctx->d()->engine->rootContext, d()->object, index)); if (hasProperty) *hasProperty = true; return method.asReturnedValue(); } QQmlPropertyData local; - QQmlPropertyData *result = findProperty(ctx->engine, qmlContext, name.getPointer(), revisionMode, &local); + QQmlPropertyData *result = findProperty(ctx->d()->engine, qmlContext, name.getPointer(), revisionMode, &local); if (!result) { if (includeImports && name->startsWithUpper()) { @@ -306,9 +306,9 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD if (r.scriptIndex != -1) { return QV4::Encode::undefined(); } else if (r.type) { - return QmlTypeWrapper::create(ctx->engine->v8Engine, d()->object, r.type, QmlTypeWrapper::ExcludeEnums); + return QmlTypeWrapper::create(ctx->d()->engine->v8Engine, d()->object, r.type, QmlTypeWrapper::ExcludeEnums); } else if (r.importNamespace) { - return QmlTypeWrapper::create(ctx->engine->v8Engine, d()->object, qmlContext->imports, r.importNamespace, QmlTypeWrapper::ExcludeEnums); + return QmlTypeWrapper::create(ctx->d()->engine->v8Engine, d()->object, qmlContext->imports, r.importNamespace, QmlTypeWrapper::ExcludeEnums); } Q_ASSERT(!"Unreachable"); } @@ -345,23 +345,23 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx Q_ASSERT(vmemo); return vmemo->vmeMethod(property->coreIndex); } else if (property->isV4Function()) { - QV4::Scoped qmlcontextobject(scope, ctx->engine->qmlContextObject()); - return QV4::QObjectMethod::create(ctx->engine->rootContext, object, property->coreIndex, qmlcontextobject); + QV4::Scoped qmlcontextobject(scope, ctx->d()->engine->qmlContextObject()); + return QV4::QObjectMethod::create(ctx->d()->engine->rootContext, object, property->coreIndex, qmlcontextobject); } else if (property->isSignalHandler()) { - QV4::Scoped handler(scope, new (ctx->engine->memoryManager) QV4::QmlSignalHandler(ctx->engine, object, property->coreIndex)); + QV4::Scoped handler(scope, new (ctx->d()->engine->memoryManager) QV4::QmlSignalHandler(ctx->d()->engine, object, property->coreIndex)); - QV4::ScopedString connect(scope, ctx->engine->newIdentifier(QStringLiteral("connect"))); - QV4::ScopedString disconnect(scope, ctx->engine->newIdentifier(QStringLiteral("disconnect"))); - handler->put(connect, QV4::ScopedValue(scope, ctx->engine->functionClass->prototype->get(connect))); - handler->put(disconnect, QV4::ScopedValue(scope, ctx->engine->functionClass->prototype->get(disconnect))); + QV4::ScopedString connect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("connect"))); + QV4::ScopedString disconnect(scope, ctx->d()->engine->newIdentifier(QStringLiteral("disconnect"))); + handler->put(connect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(connect))); + handler->put(disconnect, QV4::ScopedValue(scope, ctx->d()->engine->functionClass->prototype->get(disconnect))); return handler.asReturnedValue(); } else { - return QV4::QObjectMethod::create(ctx->engine->rootContext, object, property->coreIndex); + return QV4::QObjectMethod::create(ctx->d()->engine->rootContext, object, property->coreIndex); } } - QQmlEnginePrivate *ep = ctx->engine->v8Engine->engine() ? QQmlEnginePrivate::get(ctx->engine->v8Engine->engine()) : 0; + QQmlEnginePrivate *ep = ctx->d()->engine->v8Engine->engine() ? QQmlEnginePrivate::get(ctx->d()->engine->v8Engine->engine()) : 0; if (property->hasAccessors()) { QQmlNotifier *n = 0; @@ -370,7 +370,7 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx if (ep && ep->propertyCapture && property->accessors->notifier) nptr = &n; - QV4::ScopedValue rv(scope, LoadProperty(ctx->engine->v8Engine, object, *property, nptr)); + QV4::ScopedValue rv(scope, LoadProperty(ctx->d()->engine->v8Engine, object, *property, nptr)); if (captureRequired) { if (property->accessors->notifier) { @@ -392,9 +392,9 @@ ReturnedValue QObjectWrapper::getProperty(QObject *object, ExecutionContext *ctx Q_ASSERT(vmemo); return vmemo->vmeProperty(property->coreIndex); } else if (property->isDirect()) { - return LoadProperty(ctx->engine->v8Engine, object, *property, 0); + return LoadProperty(ctx->d()->engine->v8Engine, object, *property, 0); } else { - return LoadProperty(ctx->engine->v8Engine, object, *property, 0); + return LoadProperty(ctx->d()->engine->v8Engine, object, *property, 0); } } @@ -413,7 +413,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(ExecutionContext *ctx, QQmlContextD return QV4::Encode::null(); } - QV4::Scoped wrapper(scope, wrap(ctx->engine, object)); + QV4::Scoped wrapper(scope, wrap(ctx->d()->engine, object)); if (!wrapper) { if (hasProperty) *hasProperty = false; @@ -431,7 +431,7 @@ bool QObjectWrapper::setQmlProperty(ExecutionContext *ctx, QQmlContextData *qmlC QQmlPropertyData local; QQmlPropertyData *result = 0; { - result = QQmlPropertyCache::property(ctx->engine->v8Engine->engine(), object, name, qmlContext, local); + result = QQmlPropertyCache::property(ctx->d()->engine->v8Engine->engine(), object, name, qmlContext, local); } if (!result) @@ -473,7 +473,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro } } else { // binding assignment. - QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->engine); + QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->d()->engine); QV4::Scoped bindingFunction(scope, f); bindingFunction->initBindingLocation(); @@ -513,7 +513,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro } else if (value->isUndefined() && property->propType == QMetaType::QJsonValue) { PROPERTY_STORE(QJsonValue, QJsonValue(QJsonValue::Undefined)); } else if (!newBinding && property->propType == qMetaTypeId()) { - PROPERTY_STORE(QJSValue, new QJSValuePrivate(ctx->engine, value)); + PROPERTY_STORE(QJSValue, new QJSValuePrivate(ctx->d()->engine, value)); } else if (value->isUndefined()) { QString error = QLatin1String("Cannot assign [undefined] to "); if (!QMetaType::typeName(property->propType)) @@ -541,11 +541,11 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro } else { QVariant v; if (property->isQList()) - v = ctx->engine->v8Engine->toVariant(value, qMetaTypeId >()); + v = ctx->d()->engine->v8Engine->toVariant(value, qMetaTypeId >()); else - v = ctx->engine->v8Engine->toVariant(value, property->propType); + v = ctx->d()->engine->v8Engine->toVariant(value, property->propType); - QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->engine); + QQmlContextData *callingQmlContext = QV4::QmlContextWrapper::callingContext(ctx->d()->engine); if (!QQmlPropertyPrivate::write(object, *property, v, callingQmlContext)) { const char *valueType = 0; if (v.userType() == QVariant::Invalid) valueType = "null"; @@ -866,10 +866,10 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase ReturnedValue QObjectWrapper::method_connect(CallContext *ctx) { - if (ctx->callData->argc == 0) + if (ctx->d()->callData->argc == 0) V4THROW_ERROR("Function.prototype.connect: no arguments given"); - QPair signalInfo = extractQtSignal(ctx->callData->thisObject); + QPair signalInfo = extractQtSignal(ctx->d()->callData->thisObject); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; // in method range, not signal range! @@ -886,11 +886,11 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx) QV4::ScopedFunctionObject f(scope); QV4::ScopedValue thisObject (scope, QV4::Encode::undefined()); - if (ctx->callData->argc == 1) { - f = ctx->callData->args[0]; - } else if (ctx->callData->argc >= 2) { - thisObject = ctx->callData->args[0]; - f = ctx->callData->args[1]; + if (ctx->d()->callData->argc == 1) { + f = ctx->d()->callData->args[0]; + } else if (ctx->d()->callData->argc >= 2) { + thisObject = ctx->d()->callData->args[0]; + f = ctx->d()->callData->args[1]; } if (!f) @@ -917,12 +917,12 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx) ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx) { - if (ctx->callData->argc == 0) + if (ctx->d()->callData->argc == 0) V4THROW_ERROR("Function.prototype.disconnect: no arguments given"); QV4::Scope scope(ctx); - QPair signalInfo = extractQtSignal(ctx->callData->thisObject); + QPair signalInfo = extractQtSignal(ctx->d()->callData->thisObject); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; @@ -938,11 +938,11 @@ ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx) QV4::ScopedFunctionObject functionValue(scope); QV4::ScopedValue functionThisValue(scope, QV4::Encode::undefined()); - if (ctx->callData->argc == 1) { - functionValue = ctx->callData->args[0]; - } else if (ctx->callData->argc >= 2) { - functionThisValue = ctx->callData->args[0]; - functionValue = ctx->callData->args[1]; + if (ctx->d()->callData->argc == 1) { + functionValue = ctx->d()->callData->args[0]; + } else if (ctx->d()->callData->argc >= 2) { + functionThisValue = ctx->d()->callData->args[0]; + functionValue = ctx->d()->callData->args[1]; } if (!functionValue) @@ -954,7 +954,7 @@ ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx) QPair functionData = extractQtMethod(functionValue); void *a[] = { - ctx->engine, + ctx->d()->engine, functionValue.ptr, functionThisValue.ptr, functionData.first, @@ -1750,7 +1750,7 @@ QV4::ReturnedValue CallArgument::toValue(QV8Engine *engine) ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal) { - return (new (scope->engine->memoryManager) QObjectMethod(scope, object, index, qmlGlobal))->asReturnedValue(); + return (new (scope->d()->engine->memoryManager) QObjectMethod(scope, object, index, qmlGlobal))->asReturnedValue(); } QObjectMethod::QObjectMethod(ExecutionContext *scope, QObject *object, int index, const ValueRef qmlGlobal) @@ -1784,7 +1784,7 @@ QV4::ReturnedValue QObjectMethod::method_toString(QV4::ExecutionContext *ctx) result = QLatin1String("null"); } - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, const ValueRef args, int argc) @@ -1828,7 +1828,7 @@ ReturnedValue QObjectMethod::callInternal(CallData *callData) if (!ddata) return Encode::undefined(); - QV8Engine *v8Engine = context->engine->v8Engine; + QV8Engine *v8Engine = context->d()->engine->v8Engine; QV4::ExecutionEngine *v4 = QV8Engine::getV4(v8Engine); QV4::Scope scope(v4); diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index b46c6914d5..7e3400d4a6 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -181,7 +181,7 @@ void RegExpObject::markObjects(Managed *that, ExecutionEngine *e) Property *RegExpObject::lastIndexProperty(ExecutionContext *ctx) { Q_UNUSED(ctx); - Q_ASSERT(0 == internalClass()->find(ctx->engine->newIdentifier(QStringLiteral("lastIndex")))); + Q_ASSERT(0 == internalClass()->find(ctx->d()->engine->newIdentifier(QStringLiteral("lastIndex")))); return propertyAt(0); } @@ -257,7 +257,7 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) return ctx->throwTypeError(); Scoped newRe(scope, re->value()); - return Encode(ctx->engine->newRegExpObject(newRe, re->global())); + return Encode(ctx->d()->engine->newRegExpObject(newRe, re->global())); } QString pattern; @@ -287,11 +287,11 @@ ReturnedValue RegExpCtor::construct(Managed *m, CallData *callData) } } - Scoped regexp(scope, RegExp::create(ctx->engine, pattern, ignoreCase, multiLine)); + Scoped regexp(scope, RegExp::create(ctx->d()->engine, pattern, ignoreCase, multiLine)); if (!regexp->isValid()) return ctx->throwSyntaxError(QStringLiteral("Invalid regular expression")); - return Encode(ctx->engine->newRegExpObject(regexp, global)); + return Encode(ctx->d()->engine->newRegExpObject(regexp, global)); } ReturnedValue RegExpCtor::call(Managed *that, CallData *callData) @@ -351,7 +351,7 @@ void RegExpPrototype::init(ExecutionEngine *engine, ObjectRef ctor) ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); @@ -370,7 +370,7 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) uint* matchOffsets = (uint*)alloca(r->value()->captureCount() * 2 * sizeof(uint)); const int result = r->value()->match(s, offset, matchOffsets); - Scoped regExpCtor(scope, ctx->engine->regExpCtor); + Scoped regExpCtor(scope, ctx->d()->engine->regExpCtor); regExpCtor->clearLastMatch(); if (result == -1) { @@ -379,14 +379,14 @@ ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) } // fill in result data - Scoped array(scope, ctx->engine->newArrayObject(ctx->engine->regExpExecArrayClass)); + Scoped array(scope, ctx->d()->engine->newArrayObject(ctx->d()->engine->regExpExecArrayClass)); int len = r->value()->captureCount(); array->arrayReserve(len); ScopedValue v(scope); for (int i = 0; i < len; ++i) { int start = matchOffsets[i * 2]; int end = matchOffsets[i * 2 + 1]; - v = (start != -1 && end != -1) ? ctx->engine->newString(s.mid(start, end - start))->asReturnedValue() : Encode::undefined(); + v = (start != -1 && end != -1) ? ctx->d()->engine->newString(s.mid(start, end - start))->asReturnedValue() : Encode::undefined(); array->arrayPut(i, v); } array->setArrayLengthUnchecked(len); @@ -415,24 +415,24 @@ ReturnedValue RegExpPrototype::method_test(CallContext *ctx) ReturnedValue RegExpPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - return ctx->engine->newString(r->toString())->asReturnedValue(); + return ctx->d()->engine->newString(r->toString())->asReturnedValue(); } ReturnedValue RegExpPrototype::method_compile(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - ScopedCallData callData(scope, ctx->callData->argc); - memcpy(callData->args, ctx->callData->args, ctx->callData->argc*sizeof(Value)); + ScopedCallData callData(scope, ctx->d()->callData->argc); + memcpy(callData->args, ctx->d()->callData->args, ctx->d()->callData->argc*sizeof(Value)); - Scoped re(scope, ctx->engine->regExpCtor.asFunctionObject()->construct(callData)); + Scoped re(scope, ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData)); r->d()->value = re->value(); r->d()->global = re->global(); @@ -443,42 +443,42 @@ template ReturnedValue RegExpPrototype::method_get_lastMatch_n(CallContext *ctx) { Scope scope(ctx); - ScopedArrayObject lastMatch(scope, static_cast(ctx->engine->regExpCtor.objectValue())->lastMatch()); + ScopedArrayObject lastMatch(scope, static_cast(ctx->d()->engine->regExpCtor.objectValue())->lastMatch()); ScopedValue result(scope, lastMatch ? lastMatch->getIndexed(index) : Encode::undefined()); if (result->isUndefined()) - return ctx->engine->newString(QString())->asReturnedValue(); + return ctx->d()->engine->newString(QString())->asReturnedValue(); return result.asReturnedValue(); } ReturnedValue RegExpPrototype::method_get_lastParen(CallContext *ctx) { Scope scope(ctx); - ScopedArrayObject lastMatch(scope, static_cast(ctx->engine->regExpCtor.objectValue())->lastMatch()); + ScopedArrayObject lastMatch(scope, static_cast(ctx->d()->engine->regExpCtor.objectValue())->lastMatch()); ScopedValue result(scope, lastMatch ? lastMatch->getIndexed(lastMatch->getLength() - 1) : Encode::undefined()); if (result->isUndefined()) - return ctx->engine->newString(QString())->asReturnedValue(); + return ctx->d()->engine->newString(QString())->asReturnedValue(); return result.asReturnedValue(); } ReturnedValue RegExpPrototype::method_get_input(CallContext *ctx) { - return static_cast(ctx->engine->regExpCtor.objectValue())->lastInput().asReturnedValue(); + return static_cast(ctx->d()->engine->regExpCtor.objectValue())->lastInput().asReturnedValue(); } ReturnedValue RegExpPrototype::method_get_leftContext(CallContext *ctx) { Scope scope(ctx); - Scoped regExpCtor(scope, ctx->engine->regExpCtor); + Scoped regExpCtor(scope, ctx->d()->engine->regExpCtor); QString lastInput = regExpCtor->lastInput()->toQString(); - return ctx->engine->newString(lastInput.left(regExpCtor->lastMatchStart()))->asReturnedValue(); + return ctx->d()->engine->newString(lastInput.left(regExpCtor->lastMatchStart()))->asReturnedValue(); } ReturnedValue RegExpPrototype::method_get_rightContext(CallContext *ctx) { Scope scope(ctx); - Scoped regExpCtor(scope, ctx->engine->regExpCtor); + Scoped regExpCtor(scope, ctx->d()->engine->regExpCtor); QString lastInput = regExpCtor->lastInput()->toQString(); - return ctx->engine->newString(lastInput.mid(regExpCtor->lastMatchEnd()))->asReturnedValue(); + return ctx->d()->engine->newString(lastInput.mid(regExpCtor->lastMatchEnd()))->asReturnedValue(); } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 86eb0c7fe7..3fa8db9098 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -265,7 +265,7 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix) ReturnedValue Runtime::closure(ExecutionContext *ctx, int functionId) { - QV4::Function *clos = ctx->compilationUnit->runtimeFunctions[functionId]; + QV4::Function *clos = ctx->d()->compilationUnit->runtimeFunctions[functionId]; Q_ASSERT(clos); FunctionObject *f = FunctionObject::createScriptFunction(ctx, clos); return f->asReturnedValue(); @@ -370,7 +370,7 @@ Returned *RuntimeHelpers::stringFromNumber(ExecutionContext *ctx, double { QString qstr; RuntimeHelpers::numberToString(&qstr, number, 10); - return ctx->engine->newString(qstr); + return ctx->engine()->newString(qstr); } ReturnedValue RuntimeHelpers::objectDefaultValue(Object *object, int typeHint) @@ -428,13 +428,13 @@ Returned *RuntimeHelpers::convertToObject(ExecutionContext *ctx, const V ctx->throwTypeError(); return 0; case Value::Boolean_Type: - return ctx->engine->newBooleanObject(value); + return ctx->engine()->newBooleanObject(value); case Value::Managed_Type: Q_ASSERT(value->isString()); - return ctx->engine->newStringObject(value); + return ctx->engine()->newStringObject(value); case Value::Integer_Type: default: // double - return ctx->engine->newNumberObject(value); + return ctx->engine()->newNumberObject(value); } } @@ -444,14 +444,14 @@ Returned *RuntimeHelpers::convertToString(ExecutionContext *ctx, const V case Value::Empty_Type: Q_ASSERT(!"empty Value encountered"); case Value::Undefined_Type: - return ctx->engine->id_undefined.ret(); + return ctx->engine()->id_undefined.ret(); case Value::Null_Type: - return ctx->engine->id_null.ret(); + return ctx->engine()->id_null.ret(); case Value::Boolean_Type: if (value->booleanValue()) - return ctx->engine->id_true.ret(); + return ctx->engine()->id_true.ret(); else - return ctx->engine->id_false.ret(); + return ctx->engine()->id_false.ret(); case Value::Managed_Type: if (value->isString()) return value->stringValue()->asReturned(); @@ -475,14 +475,14 @@ static Returned *convert_to_string_add(ExecutionContext *ctx, const Valu case Value::Empty_Type: Q_ASSERT(!"empty Value encountered"); case Value::Undefined_Type: - return ctx->engine->id_undefined.ret(); + return ctx->engine()->id_undefined.ret(); case Value::Null_Type: - return ctx->engine->id_null.ret(); + return ctx->engine()->id_null.ret(); case Value::Boolean_Type: if (value->booleanValue()) - return ctx->engine->id_true.ret(); + return ctx->engine()->id_true.ret(); else - return ctx->engine->id_false.ret(); + return ctx->engine()->id_false.ret(); case Value::Managed_Type: if (value->isString()) return value->stringValue()->asReturned(); @@ -515,7 +515,7 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionContext *ctx, const ValueR return pright->asReturnedValue(); if (!pright->stringValue()->length()) return pleft->asReturnedValue(); - return (new (ctx->engine->memoryManager) String(ctx->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); + return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); } double x = RuntimeHelpers::toNumber(pleft); double y = RuntimeHelpers::toNumber(pright); @@ -531,7 +531,7 @@ QV4::ReturnedValue Runtime::addString(QV4::ExecutionContext *ctx, const QV4::Val return right->asReturnedValue(); if (!right->stringValue()->length()) return left->asReturnedValue(); - return (new (ctx->engine->memoryManager) String(ctx->engine, left->stringValue(), right->stringValue()))->asReturnedValue(); + return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, left->stringValue(), right->stringValue()))->asReturnedValue(); } Scope scope(ctx); @@ -548,7 +548,7 @@ QV4::ReturnedValue Runtime::addString(QV4::ExecutionContext *ctx, const QV4::Val return pright->asReturnedValue(); if (!pright->stringValue()->length()) return pleft->asReturnedValue(); - return (new (ctx->engine->memoryManager) String(ctx->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); + return (new (ctx->engine()->memoryManager) String(ctx->d()->engine, pleft->stringValue(), pright->stringValue()))->asReturnedValue(); } void Runtime::setProperty(ExecutionContext *ctx, const ValueRef object, const StringRef name, const ValueRef value) @@ -633,7 +633,7 @@ ReturnedValue Runtime::foreachIterator(ExecutionContext *ctx, const ValueRef in) Scoped o(scope, (Object *)0); if (!in->isNullOrUndefined()) o = in->toObject(ctx); - Scoped it(scope, ctx->engine->newForEachIteratorObject(ctx, o)); + Scoped it(scope, ctx->engine()->newForEachIteratorObject(ctx, o)); return it.asReturnedValue(); } @@ -871,12 +871,12 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionContext *context, uint index, C Scope scope(context); Q_ASSERT(callData->thisObject.isUndefined()); - Lookup *l = context->lookups + index; + Lookup *l = context->d()->lookups + index; Scoped o(scope, l->globalGetter(l, context)); if (!o) return context->throwTypeError(); - if (o.getPointer() == context->engine->evalFunction && l->name->equals(context->engine->id_eval)) + if (o.getPointer() == scope.engine->evalFunction && l->name->equals(scope.engine->id_eval)) return static_cast(o.getPointer())->evalCall(callData, true); return o->call(callData); @@ -890,7 +890,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, const S ScopedObject base(scope); ScopedValue func(scope, context->getPropertyAndBase(name, base)); - if (context->engine->hasException) + if (scope.engine->hasException) return Encode::undefined(); if (base) @@ -905,7 +905,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionContext *context, const S return context->throwTypeError(msg); } - if (o == context->engine->evalFunction && name->equals(context->engine->id_eval)) { + if (o == scope.engine->evalFunction && name->equals(scope.engine->id_eval)) { return static_cast(o)->evalCall(callData, true); } @@ -940,7 +940,7 @@ ReturnedValue Runtime::callProperty(ExecutionContext *context, const StringRef n ReturnedValue Runtime::callPropertyLookup(ExecutionContext *context, uint index, CallDataRef callData) { - Lookup *l = context->lookups + index; + Lookup *l = context->d()->lookups + index; Value v; v = l->getter(l, callData->thisObject); if (!v.isObject()) @@ -980,7 +980,7 @@ ReturnedValue Runtime::constructGlobalLookup(ExecutionContext *context, uint ind Scope scope(context); Q_ASSERT(callData->thisObject.isUndefined()); - Lookup *l = context->lookups + index; + Lookup *l = context->d()->lookups + index; Scoped f(scope, l->globalGetter(l, context)); if (!f) return context->throwTypeError(); @@ -993,7 +993,7 @@ ReturnedValue Runtime::constructActivationProperty(ExecutionContext *context, co { Scope scope(context); ScopedValue func(scope, context->getProperty(name)); - if (context->engine->hasException) + if (scope.engine->hasException) return Encode::undefined(); Object *f = func->asObject(); @@ -1028,7 +1028,7 @@ ReturnedValue Runtime::constructProperty(ExecutionContext *context, const String ReturnedValue Runtime::constructPropertyLookup(ExecutionContext *context, uint index, CallDataRef callData) { - Lookup *l = context->lookups + index; + Lookup *l = context->d()->lookups + index; Value v; v = l->getter(l, callData->thisObject); if (!v.isObject()) @@ -1050,24 +1050,24 @@ ReturnedValue Runtime::typeofValue(ExecutionContext *ctx, const ValueRef value) ScopedString res(scope); switch (value->type()) { case Value::Undefined_Type: - res = ctx->engine->id_undefined; + res = ctx->engine()->id_undefined; break; case Value::Null_Type: - res = ctx->engine->id_object; + res = ctx->engine()->id_object; break; case Value::Boolean_Type: - res = ctx->engine->id_boolean; + res = ctx->engine()->id_boolean; break; case Value::Managed_Type: if (value->isString()) - res = ctx->engine->id_string; + res = ctx->engine()->id_string; else if (value->objectValue()->asFunctionObject()) - res = ctx->engine->id_function; + res = ctx->engine()->id_function; else - res = ctx->engine->id_object; // ### implementation-defined + res = ctx->engine()->id_object; // ### implementation-defined break; default: - res = ctx->engine->id_number; + res = ctx->engine()->id_number; break; } return res.asReturnedValue(); @@ -1078,7 +1078,7 @@ QV4::ReturnedValue Runtime::typeofName(ExecutionContext *context, const StringRe Scope scope(context); ScopedValue prop(scope, context->getProperty(name)); // typeof doesn't throw. clear any possible exception - context->engine->hasException = false; + scope.engine->hasException = false; return Runtime::typeofValue(context, prop); } @@ -1112,21 +1112,21 @@ ExecutionContext *Runtime::pushWithScope(const ValueRef o, ExecutionContext *ctx ReturnedValue Runtime::unwindException(ExecutionContext *ctx) { - if (!ctx->engine->hasException) + if (!ctx->engine()->hasException) return Primitive::emptyValue().asReturnedValue(); - return ctx->engine->catchException(ctx, 0); + return ctx->engine()->catchException(ctx, 0); } ExecutionContext *Runtime::pushCatchScope(ExecutionContext *ctx, const StringRef exceptionVarName) { Scope scope(ctx); - ScopedValue v(scope, ctx->engine->catchException(ctx, 0)); + ScopedValue v(scope, ctx->engine()->catchException(ctx, 0)); return ctx->newCatchContext(exceptionVarName, v); } ExecutionContext *Runtime::popScope(ExecutionContext *ctx) { - return ctx->engine->popContext(); + return ctx->engine()->popContext(); } void Runtime::declareVar(ExecutionContext *ctx, bool deletable, const StringRef name) @@ -1137,7 +1137,7 @@ void Runtime::declareVar(ExecutionContext *ctx, bool deletable, const StringRef ReturnedValue Runtime::arrayLiteral(ExecutionContext *ctx, Value *values, uint length) { Scope scope(ctx); - Scoped a(scope, ctx->engine->newArrayObject()); + Scoped a(scope, ctx->engine()->newArrayObject()); if (length) { a->arrayReserve(length); @@ -1150,8 +1150,8 @@ ReturnedValue Runtime::arrayLiteral(ExecutionContext *ctx, Value *values, uint l ReturnedValue Runtime::objectLiteral(QV4::ExecutionContext *ctx, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags) { Scope scope(ctx); - QV4::InternalClass *klass = ctx->compilationUnit->runtimeClasses[classId]; - Scoped o(scope, ctx->engine->newObject(klass)); + QV4::InternalClass *klass = ctx->d()->compilationUnit->runtimeClasses[classId]; + Scoped o(scope, ctx->engine()->newObject(klass)); { bool needSparseArray = arrayGetterSetterCountAndFlags >> 30; @@ -1191,9 +1191,9 @@ ReturnedValue Runtime::objectLiteral(QV4::ExecutionContext *ctx, const QV4::Valu QV4::ReturnedValue Runtime::setupArgumentsObject(ExecutionContext *ctx) { - assert(ctx->type >= ExecutionContext::Type_CallContext); + Q_ASSERT(ctx->d()->type >= ExecutionContext::Type_CallContext); CallContext *c = static_cast(ctx); - return (new (c->engine->memoryManager) ArgumentsObject(c))->asReturnedValue(); + return (new (c->engine()->memoryManager) ArgumentsObject(c))->asReturnedValue(); } #endif // V4_BOOTSTRAP @@ -1279,27 +1279,27 @@ unsigned Runtime::doubleToUInt(const double &d) ReturnedValue Runtime::regexpLiteral(ExecutionContext *ctx, int id) { - return ctx->compilationUnit->runtimeRegularExpressions[id].asReturnedValue(); + return ctx->d()->compilationUnit->runtimeRegularExpressions[id].asReturnedValue(); } ReturnedValue Runtime::getQmlIdArray(NoThrowContext *ctx) { - return ctx->engine->qmlContextObject()->getPointer()->as()->idObjectsArray(); + return ctx->engine()->qmlContextObject()->getPointer()->as()->idObjectsArray(); } ReturnedValue Runtime::getQmlContextObject(NoThrowContext *ctx) { - QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine); + QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine()); if (!context) return Encode::undefined(); - return QObjectWrapper::wrap(ctx->engine, context->contextObject); + return QObjectWrapper::wrap(ctx->d()->engine, context->contextObject); } ReturnedValue Runtime::getQmlScopeObject(NoThrowContext *ctx) { Scope scope(ctx); - QV4::Scoped c(scope, ctx->engine->qmlContextObject()->getPointer()->as()); - return QObjectWrapper::wrap(ctx->engine, c->getScopeObject()); + QV4::Scoped c(scope, ctx->engine()->qmlContextObject()->getPointer()->as()); + return QObjectWrapper::wrap(ctx->d()->engine, c->getScopeObject()); } ReturnedValue Runtime::getQmlQObjectProperty(ExecutionContext *ctx, const ValueRef object, int propertyIndex, bool captureRequired) @@ -1316,11 +1316,11 @@ ReturnedValue Runtime::getQmlQObjectProperty(ExecutionContext *ctx, const ValueR QV4::ReturnedValue Runtime::getQmlAttachedProperty(ExecutionContext *ctx, int attachedPropertiesId, int propertyIndex) { Scope scope(ctx); - QV4::Scoped c(scope, ctx->engine->qmlContextObject()->getPointer()->as()); + QV4::Scoped c(scope, ctx->engine()->qmlContextObject()->getPointer()->as()); QObject *scopeObject = c->getScopeObject(); QObject *attachedObject = qmlAttachedPropertiesObjectById(attachedPropertiesId, scopeObject); - QQmlEngine *qmlEngine = ctx->engine->v8Engine->engine(); + QQmlEngine *qmlEngine = ctx->engine()->v8Engine->engine(); QQmlData::ensurePropertyCache(qmlEngine, attachedObject); return QV4::QObjectWrapper::getProperty(attachedObject, ctx, propertyIndex, /*captureRequired*/true); } @@ -1338,7 +1338,7 @@ void Runtime::setQmlQObjectProperty(ExecutionContext *ctx, const ValueRef object ReturnedValue Runtime::getQmlImportedScripts(NoThrowContext *ctx) { - QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine); + QQmlContextData *context = QmlContextWrapper::callingContext(ctx->engine()); if (!context) return Encode::undefined(); return context->importedScripts.value(); @@ -1346,16 +1346,16 @@ ReturnedValue Runtime::getQmlImportedScripts(NoThrowContext *ctx) QV4::ReturnedValue Runtime::getQmlSingleton(QV4::NoThrowContext *ctx, const QV4::StringRef name) { - return ctx->engine->qmlContextObject()->getPointer()->as()->qmlSingletonWrapper(ctx->engine->v8Engine, name); + return ctx->engine()->qmlContextObject()->getPointer()->as()->qmlSingletonWrapper(ctx->engine()->v8Engine, name); } void Runtime::convertThisToObject(ExecutionContext *ctx) { - Value *t = &ctx->callData->thisObject; + Value *t = &ctx->d()->callData->thisObject; if (t->isObject()) return; if (t->isNullOrUndefined()) { - *t = ctx->engine->globalObject->asReturnedValue(); + *t = ctx->engine()->globalObject->asReturnedValue(); } else { *t = t->toObject(ctx)->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index f67cd6c52a..fa856be6a2 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -62,7 +62,7 @@ using namespace QV4; QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, ObjectRef qml) - : FunctionObject(scope, scope->engine->id_eval, /*createProto = */ false) + : FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false) { d()->qml = qml; @@ -77,14 +77,14 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, Function *f, Objec Scope s(scope); ScopedValue protectThis(s, this); - defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); + defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); - d()->qmlContext = scope->engine->currentContext()->newQmlContext(this, qml); - scope->engine->popContext(); + d()->qmlContext = scope->d()->engine->currentContext()->newQmlContext(this, qml); + scope->d()->engine->popContext(); } QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml) - : FunctionObject(scope, scope->engine->id_eval, /*createProto = */ false) + : FunctionObject(scope, scope->d()->engine->id_eval, /*createProto = */ false) { d()->qml = qml; @@ -96,10 +96,10 @@ QmlBindingWrapper::QmlBindingWrapper(ExecutionContext *scope, ObjectRef qml) Scope s(scope); ScopedValue protectThis(s, this); - defineReadonlyProperty(scope->engine->id_length, Primitive::fromInt32(1)); + defineReadonlyProperty(scope->d()->engine->id_length, Primitive::fromInt32(1)); - d()->qmlContext = scope->engine->currentContext()->newQmlContext(this, qml); - scope->engine->popContext(); + d()->qmlContext = scope->d()->engine->currentContext()->newQmlContext(this, qml); + scope->d()->engine->popContext(); } ReturnedValue QmlBindingWrapper::call(Managed *that, CallData *) @@ -133,7 +133,7 @@ void QmlBindingWrapper::markObjects(Managed *m, ExecutionEngine *e) static ReturnedValue signalParameterGetter(QV4::CallContext *ctx, uint parameterIndex) { - QV4::CallContext *signalEmittingContext = ctx->parent->asCallContext(); + QV4::CallContext *signalEmittingContext = ctx->d()->parent->asCallContext(); Q_ASSERT(signalEmittingContext); return signalEmittingContext->argument(parameterIndex); } @@ -226,7 +226,7 @@ void Script::parse() parsed = true; - ExecutionEngine *v4 = scope->engine; + ExecutionEngine *v4 = scope->d()->engine; Scope valueScope(v4); MemoryManager::GCBlocker gcBlocker(v4->memoryManager); @@ -300,16 +300,16 @@ ReturnedValue Script::run() ContextStateSaver(ExecutionContext *context) : savedContext(context) - , strictMode(context->strictMode) - , lookups(context->lookups) - , compilationUnit(context->compilationUnit) + , strictMode(context->d()->strictMode) + , lookups(context->d()->lookups) + , compilationUnit(context->d()->compilationUnit) {} ~ContextStateSaver() { - savedContext->strictMode = strictMode; - savedContext->lookups = lookups; - savedContext->compilationUnit = compilationUnit; + savedContext->d()->strictMode = strictMode; + savedContext->d()->lookups = lookups; + savedContext->d()->compilationUnit = compilationUnit; } }; @@ -318,7 +318,7 @@ ReturnedValue Script::run() if (!vmFunction) return Encode::undefined(); - QV4::ExecutionEngine *engine = scope->engine; + QV4::ExecutionEngine *engine = scope->d()->engine; QV4::Scope valueScope(engine); if (qml.isUndefined()) { @@ -326,9 +326,9 @@ ReturnedValue Script::run() ExecutionContextSaver ctxSaver(scope); ContextStateSaver stateSaver(scope); - scope->strictMode = vmFunction->isStrict(); - scope->lookups = vmFunction->compilationUnit->runtimeLookups; - scope->compilationUnit = vmFunction->compilationUnit; + scope->d()->strictMode = vmFunction->isStrict(); + scope->d()->lookups = vmFunction->compilationUnit->runtimeLookups; + scope->d()->compilationUnit = vmFunction->compilationUnit; return vmFunction->code(scope, vmFunction->codeData); } else { @@ -406,7 +406,7 @@ ReturnedValue Script::qmlBinding() { if (!parsed) parse(); - ExecutionEngine *v4 = scope->engine; + ExecutionEngine *v4 = scope->d()->engine; Scope valueScope(v4); ScopedObject qmlObj(valueScope, qml.value()); ScopedObject v(valueScope, new (v4->memoryManager) QmlBindingWrapper(scope, vmFunction, qmlObj)); diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 17ec640244..6dbe787ab5 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -58,13 +58,13 @@ using namespace QV4; // helper function to generate valid warnings if errors occur during sequence operations. static void generateWarning(QV4::ExecutionContext *ctx, const QString& description) { - QQmlEngine *engine = ctx->engine->v8Engine->engine(); + QQmlEngine *engine = ctx->d()->engine->v8Engine->engine(); if (!engine) return; QQmlError retn; retn.setDescription(description); - QV4::StackFrame frame = ctx->engine->currentStackFrame(); + QV4::StackFrame frame = ctx->d()->engine->currentStackFrame(); retn.setLine(frame.line); retn.setUrl(QUrl(frame.source)); @@ -380,9 +380,9 @@ public: QV4::Scope scope(m_ctx); ScopedObject compare(scope, m_compareFn); ScopedCallData callData(scope, 2); - callData->args[0] = convertElementToValue(this->m_ctx->engine, lhs); - callData->args[1] = convertElementToValue(this->m_ctx->engine, rhs); - callData->thisObject = this->m_ctx->engine->globalObject; + callData->args[0] = convertElementToValue(this->m_ctx->d()->engine, lhs); + callData->args[1] = convertElementToValue(this->m_ctx->d()->engine, rhs); + callData->thisObject = this->m_ctx->d()->engine->globalObject; QV4::ScopedValue result(scope, compare->call(callData)); return result->toNumber() < 0; } @@ -401,8 +401,8 @@ public: } QV4::Scope scope(ctx); - if (ctx->callData->argc == 1 && ctx->callData->args[0].asFunctionObject()) { - CompareFunctor cf(ctx, ctx->callData->args[0]); + if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].asFunctionObject()) { + CompareFunctor cf(ctx, ctx->d()->callData->args[0]); std::sort(d()->container.begin(), d()->container.end(), cf); } else { DefaultCompareFunctor cf; @@ -416,7 +416,7 @@ public: static QV4::ReturnedValue method_get_length(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped > This(scope, ctx->callData->thisObject.as >()); + QV4::Scoped > This(scope, ctx->d()->callData->thisObject.as >()); if (!This) return ctx->throwTypeError(); @@ -431,11 +431,11 @@ public: static QV4::ReturnedValue method_set_length(QV4::CallContext* ctx) { QV4::Scope scope(ctx); - QV4::Scoped > This(scope, ctx->callData->thisObject.as >()); + QV4::Scoped > This(scope, ctx->d()->callData->thisObject.as >()); if (!This) return ctx->throwTypeError(); - quint32 newLength = ctx->callData->args[0].toUInt32(); + quint32 newLength = ctx->d()->callData->args[0].toUInt32(); /* Qt containers have int (rather than uint) allowable indexes. */ if (newLength > INT_MAX) { generateWarning(ctx, QLatin1String("Index out of range during length set")); @@ -564,11 +564,11 @@ void SequencePrototype::init() QV4::ReturnedValue SequencePrototype::method_sort(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::ScopedObject o(scope, ctx->callData->thisObject); + QV4::ScopedObject o(scope, ctx->d()->callData->thisObject); if (!o || !o->isListType()) return ctx->throwTypeError(); - if (ctx->callData->argc >= 2) + if (ctx->d()->callData->argc >= 2) return o.asReturnedValue(); #define CALL_SORT(SequenceElementType, SequenceElementTypeName, SequenceType, DefaultValue) \ diff --git a/src/qml/jsruntime/qv4sequenceobject_p.h b/src/qml/jsruntime/qv4sequenceobject_p.h index 4a5e82b688..d82f80d35e 100644 --- a/src/qml/jsruntime/qv4sequenceobject_p.h +++ b/src/qml/jsruntime/qv4sequenceobject_p.h @@ -71,7 +71,7 @@ struct SequencePrototype : public QV4::Object static ReturnedValue method_valueOf(QV4::CallContext *ctx) { - return ctx->callData->thisObject.toString(ctx)->asReturnedValue(); + return ctx->d()->callData->thisObject.toString(ctx)->asReturnedValue(); } static ReturnedValue method_sort(QV4::CallContext *ctx); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index b0cfb3e53c..5cc1b13c4f 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -128,7 +128,7 @@ bool StringObject::deleteIndexedProperty(Managed *m, uint index) } if (index < static_cast(o->d()->value.stringValue()->toQString().length())) { - if (v4->currentContext()->strictMode) + if (v4->currentContext()->d()->strictMode) v4->currentContext()->throwTypeError(); return false; } @@ -238,7 +238,7 @@ void StringPrototype::init(ExecutionEngine *engine, ObjectRef ctor) static QString getThisString(ExecutionContext *ctx) { Scope scope(ctx); - ScopedValue t(scope, ctx->callData->thisObject); + ScopedValue t(scope, ctx->d()->callData->thisObject); if (t->isString()) return t->stringValue()->toQString(); if (StringObject *thisString = t->asStringObject()) @@ -252,10 +252,10 @@ static QString getThisString(ExecutionContext *ctx) ReturnedValue StringPrototype::method_toString(CallContext *context) { - if (context->callData->thisObject.isString()) - return context->callData->thisObject.asReturnedValue(); + if (context->d()->callData->thisObject.isString()) + return context->d()->callData->thisObject.asReturnedValue(); - StringObject *o = context->callData->thisObject.asStringObject(); + StringObject *o = context->d()->callData->thisObject.asStringObject(); if (!o) return context->throwTypeError(); return o->d()->value.asReturnedValue(); @@ -264,29 +264,29 @@ ReturnedValue StringPrototype::method_toString(CallContext *context) ReturnedValue StringPrototype::method_charAt(CallContext *context) { const QString str = getThisString(context); - if (context->engine->hasException) + if (context->d()->engine->hasException) return Encode::undefined(); int pos = 0; - if (context->callData->argc > 0) - pos = (int) context->callData->args[0].toInteger(); + if (context->d()->callData->argc > 0) + pos = (int) context->d()->callData->args[0].toInteger(); QString result; if (pos >= 0 && pos < str.length()) result += str.at(pos); - return context->engine->newString(result)->asReturnedValue(); + return context->d()->engine->newString(result)->asReturnedValue(); } ReturnedValue StringPrototype::method_charCodeAt(CallContext *context) { const QString str = getThisString(context); - if (context->engine->hasException) + if (context->d()->engine->hasException) return Encode::undefined(); int pos = 0; - if (context->callData->argc > 0) - pos = (int) context->callData->args[0].toInteger(); + if (context->d()->callData->argc > 0) + pos = (int) context->d()->callData->args[0].toInteger(); if (pos >= 0 && pos < str.length()) @@ -304,30 +304,30 @@ ReturnedValue StringPrototype::method_concat(CallContext *context) return Encode::undefined(); ScopedValue v(scope); - for (int i = 0; i < context->callData->argc; ++i) { - v = RuntimeHelpers::toString(context, ValueRef(&context->callData->args[i])); + for (int i = 0; i < context->d()->callData->argc; ++i) { + v = RuntimeHelpers::toString(context, ValueRef(&context->d()->callData->args[i])); if (scope.hasException()) return Encode::undefined(); Q_ASSERT(v->isString()); value += v->stringValue()->toQString(); } - return context->engine->newString(value)->asReturnedValue(); + return context->d()->engine->newString(value)->asReturnedValue(); } ReturnedValue StringPrototype::method_indexOf(CallContext *context) { QString value = getThisString(context); - if (context->engine->hasException) + if (context->d()->engine->hasException) return Encode::undefined(); QString searchString; - if (context->callData->argc) - searchString = context->callData->args[0].toString(context)->toQString(); + if (context->d()->callData->argc) + searchString = context->d()->callData->args[0].toString(context)->toQString(); int pos = 0; - if (context->callData->argc > 1) - pos = (int) context->callData->args[1].toInteger(); + if (context->d()->callData->argc > 1) + pos = (int) context->d()->callData->args[1].toInteger(); int index = -1; if (! value.isEmpty()) @@ -345,8 +345,8 @@ ReturnedValue StringPrototype::method_lastIndexOf(CallContext *context) return Encode::undefined(); QString searchString; - if (context->callData->argc) - searchString = context->callData->args[0].toQString(); + if (context->d()->callData->argc) + searchString = context->d()->callData->args[0].toQString(); ScopedValue posArg(scope, context->argument(1)); double position = RuntimeHelpers::toNumber(posArg); @@ -371,25 +371,25 @@ ReturnedValue StringPrototype::method_localeCompare(CallContext *context) if (scope.engine->hasException) return Encode::undefined(); - ScopedValue v(scope, context->callData->argument(0)); + ScopedValue v(scope, context->d()->callData->argument(0)); const QString that = v->toQString(); return Encode(QString::localeAwareCompare(value, that)); } ReturnedValue StringPrototype::method_match(CallContext *context) { - if (context->callData->thisObject.isUndefined() || context->callData->thisObject.isNull()) + if (context->d()->callData->thisObject.isUndefined() || context->d()->callData->thisObject.isNull()) return context->throwTypeError(); Scope scope(context); - ScopedString s(scope, context->callData->thisObject.toString(context)); + ScopedString s(scope, context->d()->callData->thisObject.toString(context)); - ScopedValue regexp(scope, context->callData->argument(0)); + ScopedValue regexp(scope, context->d()->callData->argument(0)); Scoped rx(scope, regexp); if (!rx) { ScopedCallData callData(scope, 1); callData->args[0] = regexp; - rx = context->engine->regExpCtor.asFunctionObject()->construct(callData); + rx = context->d()->engine->regExpCtor.asFunctionObject()->construct(callData); } if (!rx) @@ -399,8 +399,8 @@ ReturnedValue StringPrototype::method_match(CallContext *context) bool global = rx->global(); // ### use the standard builtin function, not the one that might be redefined in the proto - ScopedString execString(scope, context->engine->newString(QStringLiteral("exec"))); - Scoped exec(scope, context->engine->regExpClass->prototype->get(execString)); + ScopedString execString(scope, context->d()->engine->newString(QStringLiteral("exec"))); + Scoped exec(scope, context->d()->engine->regExpClass->prototype->get(execString)); ScopedCallData callData(scope, 1); callData->thisObject = rx; @@ -408,9 +408,9 @@ ReturnedValue StringPrototype::method_match(CallContext *context) if (!global) return exec->call(callData); - ScopedString lastIndex(scope, context->engine->newString(QStringLiteral("lastIndex"))); + ScopedString lastIndex(scope, context->d()->engine->newString(QStringLiteral("lastIndex"))); rx->put(lastIndex, ScopedValue(scope, Primitive::fromInt32(0))); - Scoped a(scope, context->engine->newArrayObject()); + Scoped a(scope, context->d()->engine->newArrayObject()); double previousLastIndex = 0; uint n = 0; @@ -491,10 +491,10 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx) { Scope scope(ctx); QString string; - if (StringObject *thisString = ctx->callData->thisObject.asStringObject()) + if (StringObject *thisString = ctx->d()->callData->thisObject.asStringObject()) string = thisString->d()->value.stringValue()->toQString(); else - string = ctx->callData->thisObject.toString(ctx)->toQString(); + string = ctx->d()->callData->thisObject.toString(ctx)->toQString(); int numCaptures = 0; int numStringMatches = 0; @@ -563,14 +563,14 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx) uint end = matchOffsets[idx + 1]; entry = Primitive::undefinedValue(); if (start != JSC::Yarr::offsetNoMatch && end != JSC::Yarr::offsetNoMatch) - entry = ctx->engine->newString(string.mid(start, end - start)); + entry = ctx->d()->engine->newString(string.mid(start, end - start)); callData->args[k] = entry; } uint matchStart = matchOffsets[i * numCaptures * 2]; Q_ASSERT(matchStart >= static_cast(lastEnd)); uint matchEnd = matchOffsets[i * numCaptures * 2 + 1]; callData->args[numCaptures] = Primitive::fromUInt32(matchStart); - callData->args[numCaptures + 1] = ctx->engine->newString(string); + callData->args[numCaptures + 1] = ctx->d()->engine->newString(string); replacement = searchCallback->call(callData); result += string.midRef(lastEnd, matchStart - lastEnd); @@ -600,7 +600,7 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx) if (matchOffsets != _matchOffsets) free(matchOffsets); - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } ReturnedValue StringPrototype::method_search(CallContext *ctx) @@ -614,7 +614,7 @@ ReturnedValue StringPrototype::method_search(CallContext *ctx) if (!regExp) { ScopedCallData callData(scope, 1); callData->args[0] = regExpValue; - regExpValue = ctx->engine->regExpCtor.asFunctionObject()->construct(callData); + regExpValue = ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData); if (scope.engine->hasException) return Encode::undefined(); regExp = regExpValue->as(); @@ -630,14 +630,14 @@ ReturnedValue StringPrototype::method_search(CallContext *ctx) ReturnedValue StringPrototype::method_slice(CallContext *ctx) { const QString text = getThisString(ctx); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); const double length = text.length(); - double start = ctx->callData->argc ? ctx->callData->args[0].toInteger() : 0; - double end = (ctx->callData->argc < 2 || ctx->callData->args[1].isUndefined()) - ? length : ctx->callData->args[1].toInteger(); + double start = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toInteger() : 0; + double end = (ctx->d()->callData->argc < 2 || ctx->d()->callData->args[1].isUndefined()) + ? length : ctx->d()->callData->args[1].toInteger(); if (start < 0) start = qMax(length + start, 0.); @@ -653,7 +653,7 @@ ReturnedValue StringPrototype::method_slice(CallContext *ctx) const int intEnd = int(end); int count = qMax(0, intEnd - intStart); - return ctx->engine->newString(text.mid(intStart, count))->asReturnedValue(); + return ctx->d()->engine->newString(text.mid(intStart, count))->asReturnedValue(); } ReturnedValue StringPrototype::method_split(CallContext *ctx) @@ -666,15 +666,15 @@ ReturnedValue StringPrototype::method_split(CallContext *ctx) ScopedValue separatorValue(scope, ctx->argument(0)); ScopedValue limitValue(scope, ctx->argument(1)); - ScopedArrayObject array(scope, ctx->engine->newArrayObject()); + ScopedArrayObject array(scope, ctx->d()->engine->newArrayObject()); if (separatorValue->isUndefined()) { if (limitValue->isUndefined()) { - ScopedString s(scope, ctx->engine->newString(text)); + ScopedString s(scope, ctx->d()->engine->newString(text)); array->push_back(s); return array.asReturnedValue(); } - return ctx->engine->newString(text.left(limitValue->toInteger()))->asReturnedValue(); + return ctx->d()->engine->newString(text.left(limitValue->toInteger()))->asReturnedValue(); } uint limit = limitValue->isUndefined() ? UINT_MAX : limitValue->toUInt32(); @@ -686,7 +686,7 @@ ReturnedValue StringPrototype::method_split(CallContext *ctx) if (re) { if (re->value()->pattern().isEmpty()) { re = (RegExpObject *)0; - separatorValue = ctx->engine->newString(QString()); + separatorValue = ctx->d()->engine->newString(QString()); } } @@ -699,7 +699,7 @@ ReturnedValue StringPrototype::method_split(CallContext *ctx) if (result == JSC::Yarr::offsetNoMatch) break; - array->push_back((s = ctx->engine->newString(text.mid(offset, matchOffsets[0] - offset)))); + array->push_back((s = ctx->d()->engine->newString(text.mid(offset, matchOffsets[0] - offset)))); offset = qMax(offset + 1, matchOffsets[1]); if (array->getLength() >= limit) @@ -708,31 +708,31 @@ ReturnedValue StringPrototype::method_split(CallContext *ctx) for (int i = 1; i < re->value()->captureCount(); ++i) { uint start = matchOffsets[i * 2]; uint end = matchOffsets[i * 2 + 1]; - array->push_back((s = ctx->engine->newString(text.mid(start, end - start)))); + array->push_back((s = ctx->d()->engine->newString(text.mid(start, end - start)))); if (array->getLength() >= limit) break; } } if (array->getLength() < limit) - array->push_back((s = ctx->engine->newString(text.mid(offset)))); + array->push_back((s = ctx->d()->engine->newString(text.mid(offset)))); } else { QString separator = separatorValue->toString(ctx)->toQString(); if (separator.isEmpty()) { for (uint i = 0; i < qMin(limit, uint(text.length())); ++i) - array->push_back((s = ctx->engine->newString(text.mid(i, 1)))); + array->push_back((s = ctx->d()->engine->newString(text.mid(i, 1)))); return array.asReturnedValue(); } int start = 0; int end; while ((end = text.indexOf(separator, start)) != -1) { - array->push_back((s = ctx->engine->newString(text.mid(start, end - start)))); + array->push_back((s = ctx->d()->engine->newString(text.mid(start, end - start)))); start = end + separator.size(); if (array->getLength() >= limit) break; } if (array->getLength() < limit && start != -1) - array->push_back((s = ctx->engine->newString(text.mid(start)))); + array->push_back((s = ctx->d()->engine->newString(text.mid(start)))); } return array.asReturnedValue(); } @@ -740,16 +740,16 @@ ReturnedValue StringPrototype::method_split(CallContext *ctx) ReturnedValue StringPrototype::method_substr(CallContext *context) { const QString value = getThisString(context); - if (context->engine->hasException) + if (context->d()->engine->hasException) return Encode::undefined(); double start = 0; - if (context->callData->argc > 0) - start = context->callData->args[0].toInteger(); + if (context->d()->callData->argc > 0) + start = context->d()->callData->args[0].toInteger(); double length = +qInf(); - if (context->callData->argc > 1) - length = context->callData->args[1].toInteger(); + if (context->d()->callData->argc > 1) + length = context->d()->callData->args[1].toInteger(); double count = value.length(); if (start < 0) @@ -759,21 +759,21 @@ ReturnedValue StringPrototype::method_substr(CallContext *context) qint32 x = Primitive::toInt32(start); qint32 y = Primitive::toInt32(length); - return context->engine->newString(value.mid(x, y))->asReturnedValue(); + return context->d()->engine->newString(value.mid(x, y))->asReturnedValue(); } ReturnedValue StringPrototype::method_substring(CallContext *context) { QString value = getThisString(context); - if (context->engine->hasException) + if (context->d()->engine->hasException) return Encode::undefined(); int length = value.length(); double start = 0; double end = length; - if (context->callData->argc > 0) - start = context->callData->args[0].toInteger(); + if (context->d()->callData->argc > 0) + start = context->d()->callData->args[0].toInteger(); Scope scope(context); ScopedValue endValue(scope, context->argument(1)); @@ -800,15 +800,15 @@ ReturnedValue StringPrototype::method_substring(CallContext *context) qint32 x = (int)start; qint32 y = (int)(end - start); - return context->engine->newString(value.mid(x, y))->asReturnedValue(); + return context->d()->engine->newString(value.mid(x, y))->asReturnedValue(); } ReturnedValue StringPrototype::method_toLowerCase(CallContext *ctx) { QString value = getThisString(ctx); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); - return ctx->engine->newString(value.toLower())->asReturnedValue(); + return ctx->d()->engine->newString(value.toLower())->asReturnedValue(); } ReturnedValue StringPrototype::method_toLocaleLowerCase(CallContext *ctx) @@ -819,9 +819,9 @@ ReturnedValue StringPrototype::method_toLocaleLowerCase(CallContext *ctx) ReturnedValue StringPrototype::method_toUpperCase(CallContext *ctx) { QString value = getThisString(ctx); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); - return ctx->engine->newString(value.toUpper())->asReturnedValue(); + return ctx->d()->engine->newString(value.toUpper())->asReturnedValue(); } ReturnedValue StringPrototype::method_toLocaleUpperCase(CallContext *ctx) @@ -831,19 +831,19 @@ ReturnedValue StringPrototype::method_toLocaleUpperCase(CallContext *ctx) ReturnedValue StringPrototype::method_fromCharCode(CallContext *context) { - QString str(context->callData->argc, Qt::Uninitialized); + QString str(context->d()->callData->argc, Qt::Uninitialized); QChar *ch = str.data(); - for (int i = 0; i < context->callData->argc; ++i) { - *ch = QChar(context->callData->args[i].toUInt16()); + for (int i = 0; i < context->d()->callData->argc; ++i) { + *ch = QChar(context->d()->callData->args[i].toUInt16()); ++ch; } - return context->engine->newString(str)->asReturnedValue(); + return context->d()->engine->newString(str)->asReturnedValue(); } ReturnedValue StringPrototype::method_trim(CallContext *ctx) { QString s = getThisString(ctx); - if (ctx->engine->hasException) + if (ctx->d()->engine->hasException) return Encode::undefined(); const QChar *chars = s.constData(); @@ -857,5 +857,5 @@ ReturnedValue StringPrototype::method_trim(CallContext *ctx) break; } - return ctx->engine->newString(QString(chars + start, end - start + 1))->asReturnedValue(); + return ctx->d()->engine->newString(QString(chars + start, end - start + 1))->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp index 269a2b4b48..195c356cb9 100644 --- a/src/qml/jsruntime/qv4variantobject.cpp +++ b/src/qml/jsruntime/qv4variantobject.cpp @@ -151,7 +151,7 @@ void VariantPrototype::init() QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx) { Scope scope(ctx); - Scoped o(scope, ctx->callData->thisObject.as()); + Scoped o(scope, ctx->d()->callData->thisObject.as()); if (o && o->isScarce()) o->d()->node.remove(); return Encode::undefined(); @@ -160,7 +160,7 @@ QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx) QV4::ReturnedValue VariantPrototype::method_destroy(CallContext *ctx) { Scope scope(ctx); - Scoped o(scope, ctx->callData->thisObject.as()); + Scoped o(scope, ctx->d()->callData->thisObject.as()); if (o) { if (o->isScarce()) o->d()->node.remove(); @@ -172,26 +172,26 @@ QV4::ReturnedValue VariantPrototype::method_destroy(CallContext *ctx) QV4::ReturnedValue VariantPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - Scoped o(scope, ctx->callData->thisObject.as()); + Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return Encode::undefined(); QString result = o->d()->data.toString(); if (result.isEmpty() && !o->d()->data.canConvert(QVariant::String)) result = QString::fromLatin1("QVariant(%0)").arg(QString::fromLatin1(o->d()->data.typeName())); - return Encode(ctx->engine->newString(result)); + return Encode(ctx->d()->engine->newString(result)); } QV4::ReturnedValue VariantPrototype::method_valueOf(CallContext *ctx) { Scope scope(ctx); - Scoped o(scope, ctx->callData->thisObject.as()); + Scoped o(scope, ctx->d()->callData->thisObject.as()); if (o) { QVariant v = o->d()->data; switch (v.type()) { case QVariant::Invalid: return Encode::undefined(); case QVariant::String: - return Encode(ctx->engine->newString(v.toString())); + return Encode(ctx->d()->engine->newString(v.toString())); case QVariant::Int: return Encode(v.toInt()); case QVariant::Double: @@ -203,7 +203,7 @@ QV4::ReturnedValue VariantPrototype::method_valueOf(CallContext *ctx) break; } } - return ctx->callData->thisObject.asReturnedValue(); + return ctx->d()->callData->thisObject.asReturnedValue(); } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 8e52ed5a96..99aba9c2bd 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -185,14 +185,14 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code const uchar *exceptionHandler = 0; - context->lineNumber = -1; - QV4::ExecutionEngine *engine = context->engine; + context->d()->lineNumber = -1; + QV4::ExecutionEngine *engine = context->d()->engine; #ifdef DO_TRACE_INSTR qDebug("Starting VME with context=%p and code=%p", context, code); #endif // DO_TRACE_INSTR - QV4::StringValue * const runtimeStrings = context->compilationUnit->runtimeStrings; + QV4::StringValue * const runtimeStrings = context->d()->compilationUnit->runtimeStrings; // setup lookup scopes int scopeDepth = 0; @@ -200,28 +200,28 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code QV4::ExecutionContext *scope = context; while (scope) { ++scopeDepth; - scope = scope->outer; + scope = scope->d()->outer; } } QV4::Value **scopes = static_cast(alloca(sizeof(QV4::Value *)*(2 + 2*scopeDepth))); { - scopes[0] = const_cast(context->compilationUnit->data->constants()); + scopes[0] = const_cast(context->d()->compilationUnit->data->constants()); // stack gets setup in push instruction scopes[1] = 0; QV4::ExecutionContext *scope = context; int i = 0; while (scope) { - if (scope->type >= QV4::ExecutionContext::Type_SimpleCallContext) { + if (scope->d()->type >= QV4::ExecutionContext::Type_SimpleCallContext) { QV4::CallContext *cc = static_cast(scope); - scopes[2*i + 2] = cc->callData->args; + scopes[2*i + 2] = cc->d()->callData->args; scopes[2*i + 3] = cc->locals; } else { scopes[2*i + 2] = 0; scopes[2*i + 3] = 0; } ++i; - scope = scope->outer; + scope = scope->d()->outer; } } @@ -253,7 +253,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_BEGIN_INSTR(LoadRegExp) // TRACE(value, "%s", instr.value.toString(context)->toQString().toUtf8().constData()); - VALUE(instr.result) = context->compilationUnit->runtimeRegularExpressions[instr.regExpId]; + VALUE(instr.result) = context->d()->compilationUnit->runtimeRegularExpressions[instr.regExpId]; MOTH_END_INSTR(LoadRegExp) MOTH_BEGIN_INSTR(LoadClosure) @@ -267,7 +267,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_BEGIN_INSTR(GetGlobalLookup) TRACE(inline, "property name = %s", runtimeStrings[instr.name]->toQString().toUtf8().constData()); - QV4::Lookup *l = context->lookups + instr.index; + QV4::Lookup *l = context->d()->lookups + instr.index; STOREVALUE(instr.result, l->globalGetter(l, context)); MOTH_END_INSTR(GetGlobalLookup) @@ -282,7 +282,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_END_INSTR(LoadElement) MOTH_BEGIN_INSTR(LoadElementLookup) - QV4::Lookup *l = context->lookups + instr.lookup; + QV4::Lookup *l = context->d()->lookups + instr.lookup; STOREVALUE(instr.result, l->indexedGetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index))); MOTH_END_INSTR(LoadElementLookup) @@ -292,7 +292,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_END_INSTR(StoreElement) MOTH_BEGIN_INSTR(StoreElementLookup) - QV4::Lookup *l = context->lookups + instr.lookup; + QV4::Lookup *l = context->d()->lookups + instr.lookup; l->indexedSetter(l, VALUEPTR(instr.base), VALUEPTR(instr.index), VALUEPTR(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(StoreElementLookup) @@ -302,7 +302,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_END_INSTR(LoadProperty) MOTH_BEGIN_INSTR(GetLookup) - QV4::Lookup *l = context->lookups + instr.index; + QV4::Lookup *l = context->d()->lookups + instr.index; STOREVALUE(instr.result, l->getter(l, VALUEPTR(instr.base))); MOTH_END_INSTR(GetLookup) @@ -312,7 +312,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_END_INSTR(StoreProperty) MOTH_BEGIN_INSTR(SetLookup) - QV4::Lookup *l = context->lookups + instr.index; + QV4::Lookup *l = context->d()->lookups + instr.index; l->setter(l, VALUEPTR(instr.base), VALUEPTR(instr.source)); CHECK_EXCEPTION; MOTH_END_INSTR(SetLookup) @@ -333,7 +333,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_BEGIN_INSTR(Push) TRACE(inline, "stack size: %u", instr.value); stackSize = instr.value; - stack = context->engine->stackPush(stackSize); + stack = context->engine()->stackPush(stackSize); #ifndef QT_NO_DEBUG memset(stack, 0, stackSize * sizeof(QV4::Value)); #endif @@ -342,7 +342,7 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_BEGIN_INSTR(CallValue) #if 0 //def DO_TRACE_INSTR - if (Debugging::Debugger *debugger = context->engine->debugger) { + if (Debugging::Debugger *debugger = context->engine()->debugger) { if (QV4::FunctionObject *o = (VALUE(instr.dest)).asFunctionObject()) { if (Debugging::FunctionDebugInfo *info = debugger->debugInfo(o)) { QString n = debugger->name(o); @@ -655,24 +655,24 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code MOTH_END_INSTR(BinopContext) MOTH_BEGIN_INSTR(Ret) - context->engine->stackPop(stackSize); + context->engine()->stackPop(stackSize); // TRACE(Ret, "returning value %s", result.toString(context)->toQString().toUtf8().constData()); return VALUE(instr.result).asReturnedValue(); MOTH_END_INSTR(Ret) MOTH_BEGIN_INSTR(Debug) - context->lineNumber = instr.lineNumber; - QV4::Debugging::Debugger *debugger = context->engine->debugger; + context->d()->lineNumber = instr.lineNumber; + QV4::Debugging::Debugger *debugger = context->engine()->debugger; if (debugger && debugger->pauseAtNextOpportunity()) debugger->maybeBreakAtInstruction(); MOTH_END_INSTR(Debug) MOTH_BEGIN_INSTR(Line) - context->lineNumber = instr.lineNumber; + context->d()->lineNumber = instr.lineNumber; MOTH_END_INSTR(Debug) MOTH_BEGIN_INSTR(LoadThis) - VALUE(instr.result) = context->callData->thisObject; + VALUE(instr.result) = context->d()->callData->thisObject; MOTH_END_INSTR(LoadThis) MOTH_BEGIN_INSTR(LoadQmlIdArray) @@ -706,9 +706,9 @@ QV4::ReturnedValue VME::run(QV4::ExecutionContext *context, const uchar *code Q_ASSERT(false); catchException: - Q_ASSERT(context->engine->hasException); + Q_ASSERT(context->engine()->hasException); if (!exceptionHandler) { - context->engine->stackPop(stackSize); + context->engine()->stackPop(stackSize); return QV4::Encode::undefined(); } code = exceptionHandler; @@ -732,7 +732,7 @@ void **VME::instructionJumpTable() QV4::ReturnedValue VME::exec(QV4::ExecutionContext *ctxt, const uchar *code) { VME vme; - QV4::Debugging::Debugger *debugger = ctxt->engine->debugger; + QV4::Debugging::Debugger *debugger = ctxt->engine()->debugger; if (debugger) debugger->enteringFunction(); QV4::ReturnedValue retVal = vme.run(ctxt, code); diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index b739b756e2..0968b3a0d7 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1424,17 +1424,17 @@ QQmlComponentExtension::QQmlComponentExtension(QV8Engine *engine) QV4::ReturnedValue QmlIncubatorObject::method_get_object(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(); - return QV4::QObjectWrapper::wrap(ctx->engine, o->d()->incubator->object()); + return QV4::QObjectWrapper::wrap(ctx->d()->engine, o->d()->incubator->object()); } QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(); @@ -1446,7 +1446,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_forceCompletion(QV4::CallContext * QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(); @@ -1456,7 +1456,7 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_status(QV4::CallContext *ctx) QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(); @@ -1466,12 +1466,12 @@ QV4::ReturnedValue QmlIncubatorObject::method_get_statusChanged(QV4::CallContext QV4::ReturnedValue QmlIncubatorObject::method_set_statusChanged(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); - if (!o || ctx->callData->argc < 1) + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); + if (!o || ctx->d()->callData->argc < 1) return ctx->throwTypeError(); - o->d()->statusChanged = ctx->callData->args[0]; + o->d()->statusChanged = ctx->d()->callData->args[0]; return QV4::Encode::undefined(); } diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp index 7d4d31b69d..46f94832dd 100644 --- a/src/qml/qml/qqmlcontextwrapper.cpp +++ b/src/qml/qml/qqmlcontextwrapper.cpp @@ -303,7 +303,7 @@ void QmlContextWrapper::put(Managed *m, const StringRef name, const ValueRef val if (wrapper && wrapper->d()->readOnly) { QString error = QLatin1String("Invalid write to global property \"") + name->toQString() + QLatin1Char('"'); - Scoped e(scope, v4->currentContext()->engine->newString(error)); + Scoped e(scope, v4->currentContext()->d()->engine->newString(error)); v4->currentContext()->throwError(e); return; } diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 560a4c8afd..8fea5e66d3 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -158,7 +158,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context, QV4::ExecutionContext *ctx = v4->currentContext(); callData->thisObject = v4->globalObject; if (scopeObject()) { - QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->engine, scopeObject())); + QV4::ScopedValue value(scope, QV4::QObjectWrapper::wrap(ctx->d()->engine, scopeObject())); if (value->isObject()) callData->thisObject = value; } diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 395a510b03..c66b5920d9 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -82,36 +82,36 @@ void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ctx) { - if (ctx->callData->argc > 2) + if (ctx->d()->callData->argc > 2) return QV4::DatePrototype::method_toLocaleString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *date = ctx->callData->thisObject.asDateObject(); + QV4::DateObject *date = ctx->d()->callData->thisObject.asDateObject(); if (!date) return QV4::DatePrototype::method_toLocaleString(ctx); QDateTime dt = date->toQDateTime(); - if (ctx->callData->argc == 0) { + if (ctx->d()->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; - return ctx->engine->newString(locale.toString(dt))->asReturnedValue(); + return ctx->d()->engine->newString(locale.toString(dt))->asReturnedValue(); } - if (!isLocaleObject(ctx->callData->args[0])) + if (!isLocaleObject(ctx->d()->callData->args[0])) return QV4::DatePrototype::method_toLocaleString(ctx); // Use the default Date toLocaleString() - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDt; - if (ctx->callData->argc == 2) { - if (ctx->callData->args[1].isString()) { - QString format = ctx->callData->args[1].stringValue()->toQString(); + if (ctx->d()->callData->argc == 2) { + if (ctx->d()->callData->args[1].isString()) { + QString format = ctx->d()->callData->args[1].stringValue()->toQString(); formattedDt = r->d()->locale.toString(dt, format); - } else if (ctx->callData->args[1].isNumber()) { - quint32 intFormat = ctx->callData->args[1].toNumber(); + } else if (ctx->d()->callData->args[1].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDt = r->d()->locale.toString(dt, format); } else { @@ -121,42 +121,42 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ct formattedDt = r->d()->locale.toString(dt, enumFormat); } - return ctx->engine->newString(formattedDt)->asReturnedValue(); + return ctx->d()->engine->newString(formattedDt)->asReturnedValue(); } QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext *ctx) { - if (ctx->callData->argc > 2) + if (ctx->d()->callData->argc > 2) return QV4::DatePrototype::method_toLocaleTimeString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *date = ctx->callData->thisObject.asDateObject(); + QV4::DateObject *date = ctx->d()->callData->thisObject.asDateObject(); if (!date) return QV4::DatePrototype::method_toLocaleTimeString(ctx); QDateTime dt = date->toQDateTime(); QTime time = dt.time(); - if (ctx->callData->argc == 0) { + if (ctx->d()->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; - return ctx->engine->newString(locale.toString(time))->asReturnedValue(); + return ctx->d()->engine->newString(locale.toString(time))->asReturnedValue(); } - if (!isLocaleObject(ctx->callData->args[0])) + if (!isLocaleObject(ctx->d()->callData->args[0])) return QV4::DatePrototype::method_toLocaleTimeString(ctx); // Use the default Date toLocaleTimeString() - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedTime; - if (ctx->callData->argc == 2) { - if (ctx->callData->args[1].isString()) { - QString format = ctx->callData->args[1].stringValue()->toQString(); + if (ctx->d()->callData->argc == 2) { + if (ctx->d()->callData->args[1].isString()) { + QString format = ctx->d()->callData->args[1].stringValue()->toQString(); formattedTime = r->d()->locale.toString(time, format); - } else if (ctx->callData->args[1].isNumber()) { - quint32 intFormat = ctx->callData->args[1].toNumber(); + } else if (ctx->d()->callData->args[1].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedTime = r->d()->locale.toString(time, format); } else { @@ -166,42 +166,42 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext formattedTime = r->d()->locale.toString(time, enumFormat); } - return ctx->engine->newString(formattedTime)->asReturnedValue(); + return ctx->d()->engine->newString(formattedTime)->asReturnedValue(); } QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext *ctx) { - if (ctx->callData->argc > 2) + if (ctx->d()->callData->argc > 2) return QV4::DatePrototype::method_toLocaleDateString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *dateObj = ctx->callData->thisObject.asDateObject(); + QV4::DateObject *dateObj = ctx->d()->callData->thisObject.asDateObject(); if (!dateObj) return QV4::DatePrototype::method_toLocaleDateString(ctx); QDateTime dt = dateObj->toQDateTime(); QDate date = dt.date(); - if (ctx->callData->argc == 0) { + if (ctx->d()->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; - return ctx->engine->newString(locale.toString(date))->asReturnedValue(); + return ctx->d()->engine->newString(locale.toString(date))->asReturnedValue(); } - if (!isLocaleObject(ctx->callData->args[0])) + if (!isLocaleObject(ctx->d()->callData->args[0])) return QV4::DatePrototype::method_toLocaleDateString(ctx); // Use the default Date toLocaleDateString() - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDate; - if (ctx->callData->argc == 2) { - if (ctx->callData->args[1].isString()) { - QString format = ctx->callData->args[1].stringValue()->toQString(); + if (ctx->d()->callData->argc == 2) { + if (ctx->d()->callData->args[1].isString()) { + QString format = ctx->d()->callData->args[1].stringValue()->toQString(); formattedDate = r->d()->locale.toString(date, format); - } else if (ctx->callData->args[1].isNumber()) { - quint32 intFormat = ctx->callData->args[1].toNumber(); + } else if (ctx->d()->callData->args[1].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDate = r->d()->locale.toString(date, format); } else { @@ -211,35 +211,35 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext formattedDate = r->d()->locale.toString(date, enumFormat); } - return ctx->engine->newString(formattedDate)->asReturnedValue(); + return ctx->d()->engine->newString(formattedDate)->asReturnedValue(); } QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *ctx) { - QV4::ExecutionEngine * const engine = ctx->engine; - if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) { + QV4::ExecutionEngine * const engine = ctx->d()->engine; + if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) { QLocale locale; - QString dateString = ctx->callData->args[0].stringValue()->toQString(); + QString dateString = ctx->d()->callData->args[0].stringValue()->toQString(); QDateTime dt = locale.toDateTime(dateString); return QV4::Encode(engine->newDateObject(dt)); } QV4::Scope scope(ctx); - if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0])) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0])) V4THROW_ERROR("Locale: Date.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDateTime dt; - QString dateString = ctx->callData->args[1].toQStringNoThrow(); - if (ctx->callData->argc == 3) { - if (ctx->callData->args[2].isString()) { - QString format = ctx->callData->args[2].stringValue()->toQString(); + QString dateString = ctx->d()->callData->args[1].toQStringNoThrow(); + if (ctx->d()->callData->argc == 3) { + if (ctx->d()->callData->args[2].isString()) { + QString format = ctx->d()->callData->args[2].stringValue()->toQString(); dt = r->d()->locale.toDateTime(dateString, format); - } else if (ctx->callData->args[2].isNumber()) { - quint32 intFormat = ctx->callData->args[2].toNumber(); + } else if (ctx->d()->callData->args[2].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->d()->locale.toDateTime(dateString, format); } else { @@ -254,33 +254,33 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext * QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallContext *ctx) { - QV4::ExecutionEngine * const engine = ctx->engine; + QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) { + if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) { QLocale locale; - QString timeString = ctx->callData->args[0].stringValue()->toQString(); + QString timeString = ctx->d()->callData->args[0].stringValue()->toQString(); QTime time = locale.toTime(timeString); QDateTime dt = QDateTime::currentDateTime(); dt.setTime(time); return QV4::Encode(engine->newDateObject(dt)); } - if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0])) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0])) V4THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QTime tm; - QString dateString = ctx->callData->args[1].toQStringNoThrow(); - if (ctx->callData->argc == 3) { - if (ctx->callData->args[2].isString()) { - QString format = ctx->callData->args[2].stringValue()->toQString(); + QString dateString = ctx->d()->callData->args[1].toQStringNoThrow(); + if (ctx->d()->callData->argc == 3) { + if (ctx->d()->callData->args[2].isString()) { + QString format = ctx->d()->callData->args[2].stringValue()->toQString(); tm = r->d()->locale.toTime(dateString, format); - } else if (ctx->callData->args[2].isNumber()) { - quint32 intFormat = ctx->callData->args[2].toNumber(); + } else if (ctx->d()->callData->args[2].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); tm = r->d()->locale.toTime(dateString, format); } else { @@ -301,31 +301,31 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallContext *ctx) { - QV4::ExecutionEngine * const engine = ctx->engine; + QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->callData->argc == 1 && ctx->callData->args[0].isString()) { + if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) { QLocale locale; - QString dateString = ctx->callData->args[0].stringValue()->toQString(); + QString dateString = ctx->d()->callData->args[0].stringValue()->toQString(); QDate date = locale.toDate(dateString); return QV4::Encode(engine->newDateObject(QDateTime(date))); } - if (ctx->callData->argc < 1 || ctx->callData->argc > 3 || !isLocaleObject(ctx->callData->args[0])) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0])) V4THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDate dt; - QString dateString = ctx->callData->args[1].toQStringNoThrow(); - if (ctx->callData->argc == 3) { - if (ctx->callData->args[2].isString()) { - QString format = ctx->callData->args[2].stringValue()->toQString(); + QString dateString = ctx->d()->callData->args[1].toQStringNoThrow(); + if (ctx->d()->callData->argc == 3) { + if (ctx->d()->callData->args[2].isString()) { + QString format = ctx->d()->callData->args[2].stringValue()->toQString(); dt = r->d()->locale.toDate(dateString, format); - } else if (ctx->callData->args[2].isNumber()) { - quint32 intFormat = ctx->callData->args[2].toNumber(); + } else if (ctx->d()->callData->args[2].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->d()->locale.toDate(dateString, format); } else { @@ -340,7 +340,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::CallContext *ctx) { - if (ctx->callData->argc != 0) + if (ctx->d()->callData->argc != 0) V4THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments"); QV4::DatePrototype::timezoneUpdated(); @@ -360,75 +360,75 @@ void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::CallContext *ctx) { - if (ctx->callData->argc > 3) + if (ctx->d()->callData->argc > 3) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - double number = ctx->callData->thisObject.toNumber(); + double number = ctx->d()->callData->thisObject.toNumber(); - if (ctx->callData->argc == 0) { + if (ctx->d()->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; - return ctx->engine->newString(locale.toString(number))->asReturnedValue(); + return ctx->d()->engine->newString(locale.toString(number))->asReturnedValue(); } - if (!isLocaleObject(ctx->callData->args[0])) + if (!isLocaleObject(ctx->d()->callData->args[0])) return QV4::NumberPrototype::method_toLocaleString(ctx); // Use the default Number toLocaleString() QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); quint16 format = 'f'; - if (ctx->callData->argc > 1) { - if (!ctx->callData->args[1].isString()) + if (ctx->d()->callData->argc > 1) { + if (!ctx->d()->callData->args[1].isString()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - QV4::String *fs = ctx->callData->args[1].toString(ctx); + QV4::String *fs = ctx->d()->callData->args[1].toString(ctx); if (fs->length()) format = fs->toQString().at(0).unicode(); } int prec = 2; - if (ctx->callData->argc > 2) { - if (!ctx->callData->args[2].isNumber()) + if (ctx->d()->callData->argc > 2) { + if (!ctx->d()->callData->args[2].isNumber()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - prec = ctx->callData->args[2].toInt32(); + prec = ctx->d()->callData->args[2].toInt32(); } - return ctx->engine->newString(r->d()->locale.toString(number, (char)format, prec))->asReturnedValue(); + return ctx->d()->engine->newString(r->d()->locale.toString(number, (char)format, prec))->asReturnedValue(); } QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::CallContext *ctx) { - if (ctx->callData->argc > 2) + if (ctx->d()->callData->argc > 2) V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); - double number = ctx->callData->thisObject.toNumber(); + double number = ctx->d()->callData->thisObject.toNumber(); - if (ctx->callData->argc == 0) { + if (ctx->d()->callData->argc == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; - return ctx->engine->newString(locale.toString(number))->asReturnedValue(); + return ctx->d()->engine->newString(locale.toString(number))->asReturnedValue(); } - if (!isLocaleObject(ctx->callData->args[0])) + if (!isLocaleObject(ctx->d()->callData->args[0])) V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); QString symbol; - if (ctx->callData->argc > 1) { - if (!ctx->callData->args[1].isString()) + if (ctx->d()->callData->argc > 1) { + if (!ctx->d()->callData->args[1].isString()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - symbol = ctx->callData->args[1].toQStringNoThrow(); + symbol = ctx->d()->callData->args[1].toQStringNoThrow(); } - return ctx->engine->newString(r->d()->locale.toCurrencyString(number, symbol))->asReturnedValue(); + return ctx->d()->engine->newString(r->d()->locale.toCurrencyString(number, symbol))->asReturnedValue(); } QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::CallContext *ctx) { - if (ctx->callData->argc < 1 || ctx->callData->argc > 2) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); int numberIdx = 0; @@ -436,17 +436,17 @@ QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::CallContext QV4::Scope scope(ctx); - if (ctx->callData->argc == 2) { - if (!isLocaleObject(ctx->callData->args[0])) + if (ctx->d()->callData->argc == 2) { + if (!isLocaleObject(ctx->d()->callData->args[0])) V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(ctx->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); locale = r->d()->locale; numberIdx = 1; } - QV4::String *ns = ctx->callData->args[numberIdx].toString(ctx); + QV4::String *ns = ctx->d()->callData->args[numberIdx].toString(ctx); if (!ns->length()) return QV4::Encode(Q_QNAN); @@ -499,7 +499,7 @@ QV4::ReturnedValue QQmlLocaleData::method_get_weekDays(QV4::CallContext *ctx) QList days = locale->weekdays(); - QV4::Scoped result(scope, ctx->engine->newArrayObject()); + QV4::Scoped result(scope, ctx->d()->engine->newArrayObject()); result->arrayReserve(days.size()); for (int i = 0; i < days.size(); ++i) { int day = days.at(i); @@ -520,11 +520,11 @@ QV4::ReturnedValue QQmlLocaleData::method_get_uiLanguages(QV4::CallContext *ctx) return QV4::Encode::undefined(); QStringList langs = locale->uiLanguages(); - QV4::Scoped result(scope, ctx->engine->newArrayObject()); + QV4::Scoped result(scope, ctx->d()->engine->newArrayObject()); result->arrayReserve(langs.size()); QV4::ScopedValue v(scope); for (int i = 0; i < langs.size(); ++i) - result->arrayPut(i, (v = ctx->engine->newString(langs.at(i)))); + result->arrayPut(i, (v = ctx->d()->engine->newString(langs.at(i)))); result->setArrayLengthUnchecked(langs.size()); @@ -537,16 +537,16 @@ QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::CallContext *ctx) if (!locale) return QV4::Encode::undefined(); - if (ctx->callData->argc > 1) + if (ctx->d()->callData->argc > 1) V4THROW_ERROR("Locale: currencySymbol(): Invalid arguments"); QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol; - if (ctx->callData->argc == 1) { - quint32 intFormat = ctx->callData->args[0].toNumber(); + if (ctx->d()->callData->argc == 1) { + quint32 intFormat = ctx->d()->callData->args[0].toNumber(); format = QLocale::CurrencySymbolFormat(intFormat); } - return ctx->engine->newString(locale->currencySymbol(format))->asReturnedValue(); + return ctx->d()->engine->newString(locale->currencySymbol(format))->asReturnedValue(); } #define LOCALE_FORMAT(FUNC) \ @@ -554,14 +554,14 @@ QV4::ReturnedValue QQmlLocaleData::method_ ##FUNC (QV4::CallContext *ctx) { \ QLocale *locale = getThisLocale(ctx); \ if (!locale) \ return QV4::Encode::undefined(); \ - if (ctx->callData->argc > 1) \ + if (ctx->d()->callData->argc > 1) \ V4THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \ QLocale::FormatType format = QLocale::LongFormat;\ - if (ctx->callData->argc == 1) { \ - quint32 intFormat = ctx->callData->args[0].toUInt32(); \ + if (ctx->d()->callData->argc == 1) { \ + quint32 intFormat = ctx->d()->callData->args[0].toUInt32(); \ format = QLocale::FormatType(intFormat); \ } \ - return ctx->engine->newString(locale-> FUNC (format))->asReturnedValue(); \ + return ctx->engine()->newString(locale-> FUNC (format))->asReturnedValue(); \ } LOCALE_FORMAT(dateTimeFormat) @@ -574,16 +574,16 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) { QLocale *locale = getThisLocale(ctx); \ if (!locale) \ return QV4::Encode::undefined(); \ - if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \ + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) \ V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = ctx->callData->args[0].toInt32() + 1; \ + int idx = ctx->d()->callData->args[0].toInt32() + 1; \ if (idx < 1 || idx > 12) \ V4THROW_ERROR("Locale: Invalid month"); \ QString name; \ - if (ctx->callData->argc == 2) { \ - if (ctx->callData->args[1].isNumber()) { \ - quint32 intFormat = ctx->callData->args[1].toUInt32(); \ + if (ctx->d()->callData->argc == 2) { \ + if (ctx->d()->callData->args[1].isNumber()) { \ + quint32 intFormat = ctx->d()->callData->args[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale-> VARIABLE(idx, format); \ } else { \ @@ -592,7 +592,7 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) { } else { \ name = locale-> VARIABLE(idx, enumFormat); \ } \ - return ctx->engine->newString(name)->asReturnedValue(); \ + return ctx->engine()->newString(name)->asReturnedValue(); \ } // 0 -> 7 as Qt::Sunday is 7, but Sunday is 0 in JS Date @@ -601,17 +601,17 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) { QLocale *locale = getThisLocale(ctx); \ if (!locale) \ return QV4::Encode::undefined(); \ - if (ctx->callData->argc < 1 || ctx->callData->argc > 2) \ + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) \ V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = ctx->callData->args[0].toInt32(); \ + int idx = ctx->d()->callData->args[0].toInt32(); \ if (idx < 0 || idx > 7) \ V4THROW_ERROR("Locale: Invalid day"); \ if (idx == 0) idx = 7; \ QString name; \ - if (ctx->callData->argc == 2) { \ - if (ctx->callData->args[1].isNumber()) { \ - quint32 intFormat = ctx->callData->args[1].toUInt32(); \ + if (ctx->d()->callData->argc == 2) { \ + if (ctx->d()->callData->args[1].isNumber()) { \ + quint32 intFormat = ctx->d()->callData->args[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale-> VARIABLE(idx, format); \ } else { \ @@ -620,7 +620,7 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) { } else { \ name = locale-> VARIABLE(idx, enumFormat); \ } \ - return ctx->engine->newString(name)->asReturnedValue(); \ + return ctx->engine()->newString(name)->asReturnedValue(); \ } LOCALE_FORMATTED_MONTHNAME(monthName) @@ -633,7 +633,7 @@ LOCALE_FORMATTED_DAYNAME(standaloneDayName) QLocale *locale = getThisLocale(ctx); \ if (!locale) \ return QV4::Encode::undefined(); \ - return ctx->engine->newString(locale-> VARIABLE())->asReturnedValue();\ + return ctx->engine()->newString(locale-> VARIABLE())->asReturnedValue();\ } LOCALE_STRING_PROPERTY(name) @@ -828,14 +828,14 @@ void QQmlLocale::registerStringLocaleCompare(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlLocale::method_localeCompare(QV4::CallContext *ctx) { - if (ctx->callData->argc != 1 || (!ctx->callData->args[0].isString() && !ctx->callData->args[0].asStringObject())) + if (ctx->d()->callData->argc != 1 || (!ctx->d()->callData->args[0].isString() && !ctx->d()->callData->args[0].asStringObject())) return QV4::StringPrototype::method_localeCompare(ctx); - if (!ctx->callData->thisObject.isString() && !ctx->callData->thisObject.asStringObject()) + if (!ctx->d()->callData->thisObject.isString() && !ctx->d()->callData->thisObject.asStringObject()) return QV4::StringPrototype::method_localeCompare(ctx); - QString thisString = ctx->callData->thisObject.toQStringNoThrow(); - QString thatString = ctx->callData->args[0].toQStringNoThrow(); + QString thisString = ctx->d()->callData->thisObject.toQStringNoThrow(); + QString thatString = ctx->d()->callData->args[0].toQStringNoThrow(); return QV4::Encode(QString::localeAwareCompare(thisString, thatString)); } diff --git a/src/qml/qml/qqmllocale_p.h b/src/qml/qml/qqmllocale_p.h index 9d6a9d939c..02877d79c8 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -148,7 +148,7 @@ public: static QLocale *getThisLocale(QV4::CallContext *ctx) { - QQmlLocaleData *thisObject = ctx->callData->thisObject.asObject()->as(); + QQmlLocaleData *thisObject = ctx->d()->callData->thisObject.asObject()->as(); if (!thisObject) { ctx->throwTypeError(); return 0; diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index 8561264e3c..b54b355214 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -248,7 +248,7 @@ bool QmlValueTypeWrapper::isEqual(const QVariant& value) ReturnedValue QmlValueTypeWrapper::method_toString(CallContext *ctx) { - Object *o = ctx->callData->thisObject.asObject(); + Object *o = ctx->d()->callData->thisObject.asObject(); if (!o) return ctx->throwTypeError(); QmlValueTypeWrapper *w = o->as(); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 2818a178d2..019869fec1 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -72,7 +72,7 @@ using namespace QV4; #ifndef QT_NO_XMLSTREAMREADER #define V4THROW_REFERENCE(string) { \ - Scoped error(scope, ctx->engine->newReferenceErrorObject(QStringLiteral(string))); \ + Scoped error(scope, ctx->engine()->newReferenceErrorObject(QStringLiteral(string))); \ return ctx->throwError(error); \ } @@ -437,7 +437,7 @@ void NodeImpl::release() ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); @@ -456,13 +456,13 @@ ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx) name = r->d()->d->name; break; } - return Encode(ctx->engine->newString(name)); + return Encode(ctx->d()->engine->newString(name)); } ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); @@ -475,13 +475,13 @@ ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx) r->d()->d->type == NodeImpl::Notation) return Encode::null(); - return Encode(ctx->engine->newString(r->d()->d->data)); + return Encode(ctx->d()->engine->newString(r->d()->d->data)); } ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); @@ -491,11 +491,11 @@ ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx) ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->parent) return Node::create(engine, r->d()->d->parent); @@ -506,11 +506,11 @@ ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx) ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return NodeList::create(engine, r->d()->d); } @@ -518,11 +518,11 @@ ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx) ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->children.isEmpty()) return Encode::null(); @@ -533,11 +533,11 @@ ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx) ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->children.isEmpty()) return Encode::null(); @@ -548,11 +548,11 @@ ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx) ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (!r->d()->d->parent) return Encode::null(); @@ -572,11 +572,11 @@ ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx) ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (!r->d()->d->parent) return Encode::null(); @@ -596,11 +596,11 @@ ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx) ReturnedValue NodePrototype::method_get_attributes(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return ctx->throwTypeError(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->d()->d->type != NodeImpl::Element) return Encode::null(); @@ -690,10 +690,10 @@ ReturnedValue Attr::prototype(ExecutionEngine *engine) ReturnedValue Attr::method_name(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(r->d()->d->name); } @@ -701,10 +701,10 @@ ReturnedValue Attr::method_name(CallContext *ctx) ReturnedValue Attr::method_value(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(r->d()->d->data); } @@ -712,10 +712,10 @@ ReturnedValue Attr::method_value(CallContext *ctx) ReturnedValue Attr::method_ownerElement(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return Node::create(engine, r->d()->d->parent); } @@ -723,10 +723,10 @@ ReturnedValue Attr::method_ownerElement(CallContext *ctx) ReturnedValue CharacterData::method_length(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; Q_UNUSED(engine) return Encode(r->d()->d->data.length()); } @@ -750,7 +750,7 @@ ReturnedValue CharacterData::prototype(ExecutionEngine *v4) ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); return Encode(r->d()->d->data.trimmed().isEmpty()); @@ -759,10 +759,10 @@ ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx) ReturnedValue Text::method_wholeText(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(r->d()->d->data); } @@ -1024,10 +1024,10 @@ ReturnedValue NodeList::create(QV8Engine *engine, NodeImpl *data) ReturnedValue Document::method_documentElement(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return Node::create(engine, static_cast(r->d()->d)->root); } @@ -1035,10 +1035,10 @@ ReturnedValue Document::method_documentElement(CallContext *ctx) ReturnedValue Document::method_xmlStandalone(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; Q_UNUSED(engine) return Encode(static_cast(r->d()->d)->isStandalone); } @@ -1046,10 +1046,10 @@ ReturnedValue Document::method_xmlStandalone(CallContext *ctx) ReturnedValue Document::method_xmlVersion(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(static_cast(r->d()->d)->version); } @@ -1057,10 +1057,10 @@ ReturnedValue Document::method_xmlVersion(CallContext *ctx) ReturnedValue Document::method_xmlEncoding(CallContext *ctx) { Scope scope(ctx); - Scoped r(scope, ctx->callData->thisObject.as()); + Scoped r(scope, ctx->d()->callData->thisObject.as()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; return engine->toString(static_cast(r->d()->d)->encoding); } @@ -1760,18 +1760,18 @@ void QQmlXMLHttpRequestCtor::setupProto() ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->callData->argc < 2 || ctx->callData->argc > 5) + if (ctx->d()->callData->argc < 2 || ctx->d()->callData->argc > 5) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; // Argument 0 - Method - QString method = ctx->callData->args[0].toQStringNoThrow().toUpper(); + QString method = ctx->d()->callData->args[0].toQStringNoThrow().toUpper(); if (method != QLatin1String("GET") && method != QLatin1String("PUT") && method != QLatin1String("HEAD") && @@ -1780,21 +1780,21 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type"); // Argument 1 - URL - QUrl url = QUrl(ctx->callData->args[1].toQStringNoThrow()); + QUrl url = QUrl(ctx->d()->callData->args[1].toQStringNoThrow()); if (url.isRelative()) url = engine->callingContext()->resolvedUrl(url); // Argument 2 - async (optional) - if (ctx->callData->argc > 2 && !ctx->callData->args[2].booleanValue()) + if (ctx->d()->callData->argc > 2 && !ctx->d()->callData->args[2].booleanValue()) V4THROW_DOM(DOMEXCEPTION_NOT_SUPPORTED_ERR, "Synchronous XMLHttpRequest calls are not supported"); // Argument 3/4 - user/pass (optional) QString username, password; - if (ctx->callData->argc > 3) - username = ctx->callData->args[3].toQStringNoThrow(); - if (ctx->callData->argc > 4) - password = ctx->callData->args[4].toQStringNoThrow(); + if (ctx->d()->callData->argc > 3) + username = ctx->d()->callData->args[3].toQStringNoThrow(); + if (ctx->d()->callData->argc > 4) + password = ctx->d()->callData->args[4].toQStringNoThrow(); // Clear the fragment (if any) url.setFragment(QString()); @@ -1803,26 +1803,26 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) if (!username.isNull()) url.setUserName(username); if (!password.isNull()) url.setPassword(password); - ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine)); + ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, engine)); return r->open(meObject, method, url); } ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 2) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag()) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - QString name = ctx->callData->args[0].toQStringNoThrow(); - QString value = ctx->callData->args[1].toQStringNoThrow(); + QString name = ctx->d()->callData->args[0].toQStringNoThrow(); + QString value = ctx->d()->callData->args[1].toQStringNoThrow(); // ### Check that name and value are well formed @@ -1857,48 +1857,48 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_send(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->readyState() != QQmlXMLHttpRequest::Opened || r->sendFlag()) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); QByteArray data; - if (ctx->callData->argc > 0) - data = ctx->callData->args[0].toQStringNoThrow().toUtf8(); + if (ctx->d()->callData->argc > 0) + data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8(); - ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, engine)); + ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, engine)); return r->send(meObject, data); } ReturnedValue QQmlXMLHttpRequestCtor::method_abort(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - ScopedValue meObject(scope, constructMeObject(ctx->callData->thisObject, ctx->engine->v8Engine)); + ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, ctx->d()->engine->v8Engine)); return r->abort(meObject); } ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1906,20 +1906,20 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx) r->readyState() != QQmlXMLHttpRequest::HeadersReceived) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - return engine->toString(r->header(ctx->callData->args[0].toQStringNoThrow())); + return engine->toString(r->header(ctx->d()->callData->args[0].toQStringNoThrow())); } ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; - if (ctx->callData->argc != 0) + if (ctx->d()->callData->argc != 0) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1934,7 +1934,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext * ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1945,7 +1945,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1963,12 +1963,12 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->readyState() == QQmlXMLHttpRequest::Unsent || r->readyState() == QQmlXMLHttpRequest::Opened) @@ -1983,12 +1983,12 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - QV8Engine *engine = ctx->engine->v8Engine; + QV8Engine *engine = ctx->d()->engine->v8Engine; if (r->readyState() != QQmlXMLHttpRequest::Loading && r->readyState() != QQmlXMLHttpRequest::Done) @@ -2000,7 +2000,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx) { Scope scope(ctx); - Scoped w(scope, ctx->callData->thisObject.as()); + Scoped w(scope, ctx->d()->callData->thisObject.as()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -2010,7 +2010,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx) r->readyState() != QQmlXMLHttpRequest::Done)) { return Encode::null(); } else { - return Document::load(ctx->engine->v8Engine, r->rawResponseBody()); + return Document::load(ctx->d()->engine->v8Engine, r->rawResponseBody()); } } diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index c8440b8384..996f41b674 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -159,10 +159,10 @@ Returns true if \c object is a valid reference to a Qt or QML object, otherwise */ ReturnedValue QtObject::method_isQtObject(QV4::CallContext *ctx) { - if (ctx->callData->argc == 0) + if (ctx->d()->callData->argc == 0) return QV4::Encode(false); - return QV4::Encode(ctx->callData->args[0].as() != 0); + return QV4::Encode(ctx->d()->callData->args[0].as() != 0); } /*! @@ -173,14 +173,14 @@ All components should be in the range 0-1 inclusive. */ ReturnedValue QtObject::method_rgba(QV4::CallContext *ctx) { - int argCount = ctx->callData->argc; + int argCount = ctx->d()->callData->argc; if (argCount < 3 || argCount > 4) V4THROW_ERROR("Qt.rgba(): Invalid arguments"); - double r = ctx->callData->args[0].toNumber(); - double g = ctx->callData->args[1].toNumber(); - double b = ctx->callData->args[2].toNumber(); - double a = (argCount == 4) ? ctx->callData->args[3].toNumber() : 1; + double r = ctx->d()->callData->args[0].toNumber(); + double g = ctx->d()->callData->args[1].toNumber(); + double b = ctx->d()->callData->args[2].toNumber(); + double a = (argCount == 4) ? ctx->d()->callData->args[3].toNumber() : 1; if (r < 0.0) r=0.0; if (r > 1.0) r=1.0; @@ -191,7 +191,7 @@ ReturnedValue QtObject::method_rgba(QV4::CallContext *ctx) if (a < 0.0) a=0.0; if (a > 1.0) a=1.0; - return ctx->engine->v8Engine->fromVariant(QQml_colorProvider()->fromRgbF(r, g, b, a)); + return ctx->d()->engine->v8Engine->fromVariant(QQml_colorProvider()->fromRgbF(r, g, b, a)); } /*! @@ -202,14 +202,14 @@ All components should be in the range 0-1 inclusive. */ ReturnedValue QtObject::method_hsla(QV4::CallContext *ctx) { - int argCount = ctx->callData->argc; + int argCount = ctx->d()->callData->argc; if (argCount < 3 || argCount > 4) V4THROW_ERROR("Qt.hsla(): Invalid arguments"); - double h = ctx->callData->args[0].toNumber(); - double s = ctx->callData->args[1].toNumber(); - double l = ctx->callData->args[2].toNumber(); - double a = (argCount == 4) ? ctx->callData->args[3].toNumber() : 1; + double h = ctx->d()->callData->args[0].toNumber(); + double s = ctx->d()->callData->args[1].toNumber(); + double l = ctx->d()->callData->args[2].toNumber(); + double a = (argCount == 4) ? ctx->d()->callData->args[3].toNumber() : 1; if (h < 0.0) h=0.0; if (h > 1.0) h=1.0; @@ -220,7 +220,7 @@ ReturnedValue QtObject::method_hsla(QV4::CallContext *ctx) if (a < 0.0) a=0.0; if (a > 1.0) a=1.0; - return ctx->engine->v8Engine->fromVariant(QQml_colorProvider()->fromHslF(h, s, l, a)); + return ctx->d()->engine->v8Engine->fromVariant(QQml_colorProvider()->fromHslF(h, s, l, a)); } /*! @@ -233,14 +233,14 @@ basic type. */ ReturnedValue QtObject::method_colorEqual(QV4::CallContext *ctx) { - if (ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 2) V4THROW_ERROR("Qt.colorEqual(): Invalid arguments"); bool ok = false; - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QVariant lhs = v8engine->toVariant(ctx->callData->args[0], -1); + QVariant lhs = v8engine->toVariant(ctx->d()->callData->args[0], -1); if (lhs.userType() == QVariant::String) { lhs = QQmlStringConverters::colorFromString(lhs.toString(), &ok); if (!ok) { @@ -250,7 +250,7 @@ ReturnedValue QtObject::method_colorEqual(QV4::CallContext *ctx) V4THROW_ERROR("Qt.colorEqual(): Invalid arguments"); } - QVariant rhs = v8engine->toVariant(ctx->callData->args[1], -1); + QVariant rhs = v8engine->toVariant(ctx->d()->callData->args[1], -1); if (rhs.userType() == QVariant::String) { rhs = QQmlStringConverters::colorFromString(rhs.toString(), &ok); if (!ok) { @@ -273,15 +273,15 @@ The returned object has \c x, \c y, \c width and \c height attributes with the g */ ReturnedValue QtObject::method_rect(QV4::CallContext *ctx) { - if (ctx->callData->argc != 4) + if (ctx->d()->callData->argc != 4) V4THROW_ERROR("Qt.rect(): Invalid arguments"); - double x = ctx->callData->args[0].toNumber(); - double y = ctx->callData->args[1].toNumber(); - double w = ctx->callData->args[2].toNumber(); - double h = ctx->callData->args[3].toNumber(); + double x = ctx->d()->callData->args[0].toNumber(); + double y = ctx->d()->callData->args[1].toNumber(); + double w = ctx->d()->callData->args[2].toNumber(); + double h = ctx->d()->callData->args[3].toNumber(); - return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h))); + return ctx->d()->engine->v8Engine->fromVariant(QVariant::fromValue(QRectF(x, y, w, h))); } /*! @@ -290,13 +290,13 @@ Returns a Point with the specified \c x and \c y coordinates. */ ReturnedValue QtObject::method_point(QV4::CallContext *ctx) { - if (ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 2) V4THROW_ERROR("Qt.point(): Invalid arguments"); - double x = ctx->callData->args[0].toNumber(); - double y = ctx->callData->args[1].toNumber(); + double x = ctx->d()->callData->args[0].toNumber(); + double y = ctx->d()->callData->args[1].toNumber(); - return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QPointF(x, y))); + return ctx->d()->engine->v8Engine->fromVariant(QVariant::fromValue(QPointF(x, y))); } /*! @@ -305,13 +305,13 @@ Returns a Size with the specified \c width and \c height. */ ReturnedValue QtObject::method_size(QV4::CallContext *ctx) { - if (ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 2) V4THROW_ERROR("Qt.size(): Invalid arguments"); - double w = ctx->callData->args[0].toNumber(); - double h = ctx->callData->args[1].toNumber(); + double w = ctx->d()->callData->args[0].toNumber(); + double h = ctx->d()->callData->args[1].toNumber(); - return ctx->engine->v8Engine->fromVariant(QVariant::fromValue(QSizeF(w, h))); + return ctx->d()->engine->v8Engine->fromVariant(QVariant::fromValue(QSizeF(w, h))); } /*! @@ -324,12 +324,12 @@ Invalid keys will be ignored. */ ReturnedValue QtObject::method_font(QV4::CallContext *ctx) { - if (ctx->callData->argc != 1 || !ctx->callData->args[0].isObject()) + if (ctx->d()->callData->argc != 1 || !ctx->d()->callData->args[0].isObject()) V4THROW_ERROR("Qt.font(): Invalid arguments"); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->callData->args[0]), v8engine, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->d()->callData->args[0]), v8engine, &ok); if (!ok) V4THROW_ERROR("Qt.font(): Invalid argument: no valid font subproperties specified"); return v8engine->fromVariant(v); @@ -343,15 +343,15 @@ Returns a Vector2D with the specified \c x and \c y. */ ReturnedValue QtObject::method_vector2d(QV4::CallContext *ctx) { - if (ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 2) V4THROW_ERROR("Qt.vector2d(): Invalid arguments"); float xy[3]; // qvector2d uses float internally - xy[0] = ctx->callData->args[0].toNumber(); - xy[1] = ctx->callData->args[1].toNumber(); + xy[0] = ctx->d()->callData->args[0].toNumber(); + xy[1] = ctx->d()->callData->args[1].toNumber(); const void *params[] = { xy }; - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector2D, 1, params)); } @@ -361,16 +361,16 @@ Returns a Vector3D with the specified \c x, \c y and \c z. */ ReturnedValue QtObject::method_vector3d(QV4::CallContext *ctx) { - if (ctx->callData->argc != 3) + if (ctx->d()->callData->argc != 3) V4THROW_ERROR("Qt.vector3d(): Invalid arguments"); float xyz[3]; // qvector3d uses float internally - xyz[0] = ctx->callData->args[0].toNumber(); - xyz[1] = ctx->callData->args[1].toNumber(); - xyz[2] = ctx->callData->args[2].toNumber(); + xyz[0] = ctx->d()->callData->args[0].toNumber(); + xyz[1] = ctx->d()->callData->args[1].toNumber(); + xyz[2] = ctx->d()->callData->args[2].toNumber(); const void *params[] = { xyz }; - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector3D, 1, params)); } @@ -380,17 +380,17 @@ Returns a Vector4D with the specified \c x, \c y, \c z and \c w. */ ReturnedValue QtObject::method_vector4d(QV4::CallContext *ctx) { - if (ctx->callData->argc != 4) + if (ctx->d()->callData->argc != 4) V4THROW_ERROR("Qt.vector4d(): Invalid arguments"); float xyzw[4]; // qvector4d uses float internally - xyzw[0] = ctx->callData->args[0].toNumber(); - xyzw[1] = ctx->callData->args[1].toNumber(); - xyzw[2] = ctx->callData->args[2].toNumber(); - xyzw[3] = ctx->callData->args[3].toNumber(); + xyzw[0] = ctx->d()->callData->args[0].toNumber(); + xyzw[1] = ctx->d()->callData->args[1].toNumber(); + xyzw[2] = ctx->d()->callData->args[2].toNumber(); + xyzw[3] = ctx->d()->callData->args[3].toNumber(); const void *params[] = { xyzw }; - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector4D, 1, params)); } @@ -400,17 +400,17 @@ Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z. */ ReturnedValue QtObject::method_quaternion(QV4::CallContext *ctx) { - if (ctx->callData->argc != 4) + if (ctx->d()->callData->argc != 4) V4THROW_ERROR("Qt.quaternion(): Invalid arguments"); qreal sxyz[4]; // qquaternion uses qreal internally - sxyz[0] = ctx->callData->args[0].toNumber(); - sxyz[1] = ctx->callData->args[1].toNumber(); - sxyz[2] = ctx->callData->args[2].toNumber(); - sxyz[3] = ctx->callData->args[3].toNumber(); + sxyz[0] = ctx->d()->callData->args[0].toNumber(); + sxyz[1] = ctx->d()->callData->args[1].toNumber(); + sxyz[2] = ctx->d()->callData->args[2].toNumber(); + sxyz[3] = ctx->d()->callData->args[3].toNumber(); const void *params[] = { sxyz }; - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QQuaternion, 1, params)); } @@ -423,36 +423,36 @@ matrix values. */ ReturnedValue QtObject::method_matrix4x4(QV4::CallContext *ctx) { - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; - if (ctx->callData->argc == 1 && ctx->callData->args[0].isObject()) { + if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isObject()) { bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->callData->args[0]), v8engine, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->d()->callData->args[0]), v8engine, &ok); if (!ok) V4THROW_ERROR("Qt.matrix4x4(): Invalid argument: not a valid matrix4x4 values array"); return v8engine->fromVariant(v); } - if (ctx->callData->argc != 16) + if (ctx->d()->callData->argc != 16) V4THROW_ERROR("Qt.matrix4x4(): Invalid arguments"); qreal vals[16]; // qmatrix4x4 uses qreal internally - vals[0] = ctx->callData->args[0].toNumber(); - vals[1] = ctx->callData->args[1].toNumber(); - vals[2] = ctx->callData->args[2].toNumber(); - vals[3] = ctx->callData->args[3].toNumber(); - vals[4] = ctx->callData->args[4].toNumber(); - vals[5] = ctx->callData->args[5].toNumber(); - vals[6] = ctx->callData->args[6].toNumber(); - vals[7] = ctx->callData->args[7].toNumber(); - vals[8] = ctx->callData->args[8].toNumber(); - vals[9] = ctx->callData->args[9].toNumber(); - vals[10] = ctx->callData->args[10].toNumber(); - vals[11] = ctx->callData->args[11].toNumber(); - vals[12] = ctx->callData->args[12].toNumber(); - vals[13] = ctx->callData->args[13].toNumber(); - vals[14] = ctx->callData->args[14].toNumber(); - vals[15] = ctx->callData->args[15].toNumber(); + vals[0] = ctx->d()->callData->args[0].toNumber(); + vals[1] = ctx->d()->callData->args[1].toNumber(); + vals[2] = ctx->d()->callData->args[2].toNumber(); + vals[3] = ctx->d()->callData->args[3].toNumber(); + vals[4] = ctx->d()->callData->args[4].toNumber(); + vals[5] = ctx->d()->callData->args[5].toNumber(); + vals[6] = ctx->d()->callData->args[6].toNumber(); + vals[7] = ctx->d()->callData->args[7].toNumber(); + vals[8] = ctx->d()->callData->args[8].toNumber(); + vals[9] = ctx->d()->callData->args[9].toNumber(); + vals[10] = ctx->d()->callData->args[10].toNumber(); + vals[11] = ctx->d()->callData->args[11].toNumber(); + vals[12] = ctx->d()->callData->args[12].toNumber(); + vals[13] = ctx->d()->callData->args[13].toNumber(); + vals[14] = ctx->d()->callData->args[14].toNumber(); + vals[15] = ctx->d()->callData->args[15].toNumber(); const void *params[] = { vals }; return v8engine->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 1, params)); @@ -474,11 +474,11 @@ If \c factor is not supplied, returns a color 50% lighter than \c baseColor (fac */ ReturnedValue QtObject::method_lighter(QV4::CallContext *ctx) { - if (ctx->callData->argc != 1 && ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 1 && ctx->d()->callData->argc != 2) V4THROW_ERROR("Qt.lighter(): Invalid arguments"); - QV8Engine *v8engine = ctx->engine->v8Engine; - QVariant v = v8engine->toVariant(ctx->callData->args[0], -1); + QV8Engine *v8engine = ctx->d()->engine->v8Engine; + QVariant v = v8engine->toVariant(ctx->d()->callData->args[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -490,8 +490,8 @@ ReturnedValue QtObject::method_lighter(QV4::CallContext *ctx) } qreal factor = 1.5; - if (ctx->callData->argc == 2) - factor = ctx->callData->args[1].toNumber(); + if (ctx->d()->callData->argc == 2) + factor = ctx->d()->callData->args[1].toNumber(); return v8engine->fromVariant(QQml_colorProvider()->lighter(v, factor)); } @@ -513,11 +513,11 @@ If \c factor is not supplied, returns a color 50% darker than \c baseColor (fact */ ReturnedValue QtObject::method_darker(QV4::CallContext *ctx) { - if (ctx->callData->argc != 1 && ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 1 && ctx->d()->callData->argc != 2) V4THROW_ERROR("Qt.darker(): Invalid arguments"); - QV8Engine *v8engine = ctx->engine->v8Engine; - QVariant v = v8engine->toVariant(ctx->callData->args[0], -1); + QV8Engine *v8engine = ctx->d()->engine->v8Engine; + QVariant v = v8engine->toVariant(ctx->d()->callData->args[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -529,8 +529,8 @@ ReturnedValue QtObject::method_darker(QV4::CallContext *ctx) } qreal factor = 2.0; - if (ctx->callData->argc == 2) - factor = ctx->callData->args[1].toNumber(); + if (ctx->d()->callData->argc == 2) + factor = ctx->d()->callData->args[1].toNumber(); return v8engine->fromVariant(QQml_colorProvider()->darker(v, factor)); } @@ -561,13 +561,13 @@ ReturnedValue QtObject::method_darker(QV4::CallContext *ctx) */ ReturnedValue QtObject::method_tint(QV4::CallContext *ctx) { - if (ctx->callData->argc != 2) + if (ctx->d()->callData->argc != 2) V4THROW_ERROR("Qt.tint(): Invalid arguments"); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; // base color - QVariant v1 = v8engine->toVariant(ctx->callData->args[0], -1); + QVariant v1 = v8engine->toVariant(ctx->d()->callData->args[0], -1); if (v1.userType() == QVariant::String) { bool ok = false; v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok); @@ -579,7 +579,7 @@ ReturnedValue QtObject::method_tint(QV4::CallContext *ctx) } // tint color - QVariant v2 = v8engine->toVariant(ctx->callData->args[1], -1); + QVariant v2 = v8engine->toVariant(ctx->d()->callData->args[1], -1); if (v2.userType() == QVariant::String) { bool ok = false; v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok); @@ -611,22 +611,22 @@ If \a format is not specified, \a date is formatted using */ ReturnedValue QtObject::method_formatDate(QV4::CallContext *ctx) { - if (ctx->callData->argc < 1 || ctx->callData->argc > 2) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) V4THROW_ERROR("Qt.formatDate(): Invalid arguments"); QV4::Scope scope(ctx); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDate date = v8engine->toVariant(ctx->callData->args[0], -1).toDateTime().date(); + QDate date = v8engine->toVariant(ctx->d()->callData->args[0], -1).toDateTime().date(); QString formattedDate; - if (ctx->callData->argc == 2) { - QV4::ScopedString s(scope, ctx->callData->args[1]); + if (ctx->d()->callData->argc == 2) { + QV4::ScopedString s(scope, ctx->d()->callData->args[1]); if (s) { QString format = s->toQString(); formattedDate = date.toString(format); - } else if (ctx->callData->args[1].isNumber()) { - quint32 intFormat = ctx->callData->args[1].asDouble(); + } else if (ctx->d()->callData->args[1].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDate = date.toString(format); } else { @@ -636,7 +636,7 @@ ReturnedValue QtObject::method_formatDate(QV4::CallContext *ctx) formattedDate = date.toString(enumFormat); } - return ctx->engine->newString(formattedDate)->asReturnedValue(); + return ctx->d()->engine->newString(formattedDate)->asReturnedValue(); } /*! @@ -656,28 +656,28 @@ If \a format is not specified, \a time is formatted using */ ReturnedValue QtObject::method_formatTime(QV4::CallContext *ctx) { - if (ctx->callData->argc < 1 || ctx->callData->argc > 2) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) V4THROW_ERROR("Qt.formatTime(): Invalid arguments"); QV4::Scope scope(ctx); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QVariant argVariant = v8engine->toVariant(ctx->callData->args[0], -1); + QVariant argVariant = v8engine->toVariant(ctx->d()->callData->args[0], -1); QTime time; - if (ctx->callData->args[0].asDateObject() || (argVariant.type() == QVariant::String)) + if (ctx->d()->callData->args[0].asDateObject() || (argVariant.type() == QVariant::String)) time = argVariant.toDateTime().time(); else // if (argVariant.type() == QVariant::Time), or invalid. time = argVariant.toTime(); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; QString formattedTime; - if (ctx->callData->argc == 2) { - QV4::ScopedString s(scope, ctx->callData->args[1]); + if (ctx->d()->callData->argc == 2) { + QV4::ScopedString s(scope, ctx->d()->callData->args[1]); if (s) { QString format = s->toQString(); formattedTime = time.toString(format); - } else if (ctx->callData->args[1].isNumber()) { - quint32 intFormat = ctx->callData->args[1].asDouble(); + } else if (ctx->d()->callData->args[1].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedTime = time.toString(format); } else { @@ -687,7 +687,7 @@ ReturnedValue QtObject::method_formatTime(QV4::CallContext *ctx) formattedTime = time.toString(enumFormat); } - return ctx->engine->newString(formattedTime)->asReturnedValue(); + return ctx->d()->engine->newString(formattedTime)->asReturnedValue(); } /*! @@ -782,22 +782,22 @@ with the \a format values below to produce the following results: */ ReturnedValue QtObject::method_formatDateTime(QV4::CallContext *ctx) { - if (ctx->callData->argc < 1 || ctx->callData->argc > 2) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) V4THROW_ERROR("Qt.formatDateTime(): Invalid arguments"); QV4::Scope scope(ctx); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDateTime dt = v8engine->toVariant(ctx->callData->args[0], -1).toDateTime(); + QDateTime dt = v8engine->toVariant(ctx->d()->callData->args[0], -1).toDateTime(); QString formattedDt; - if (ctx->callData->argc == 2) { - QV4::ScopedString s(scope, ctx->callData->args[1]); + if (ctx->d()->callData->argc == 2) { + QV4::ScopedString s(scope, ctx->d()->callData->args[1]); if (s) { QString format = s->toQString(); formattedDt = dt.toString(format); - } else if (ctx->callData->args[1].isNumber()) { - quint32 intFormat = ctx->callData->args[1].asDouble(); + } else if (ctx->d()->callData->args[1].isNumber()) { + quint32 intFormat = ctx->d()->callData->args[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDt = dt.toString(format); } else { @@ -807,7 +807,7 @@ ReturnedValue QtObject::method_formatDateTime(QV4::CallContext *ctx) formattedDt = dt.toString(enumFormat); } - return ctx->engine->newString(formattedDt)->asReturnedValue(); + return ctx->d()->engine->newString(formattedDt)->asReturnedValue(); } /*! @@ -816,10 +816,10 @@ Attempts to open the specified \c target url in an external application, based o */ ReturnedValue QtObject::method_openUrlExternally(QV4::CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) return QV4::Encode(false); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; QUrl url(Value::fromReturnedValue(method_resolvedUrl(ctx)).toQStringNoThrow()); return v8engine->fromVariant(QQml_guiProvider()->openUrlExternally(url)); @@ -831,21 +831,21 @@ ReturnedValue QtObject::method_openUrlExternally(QV4::CallContext *ctx) */ ReturnedValue QtObject::method_resolvedUrl(QV4::CallContext *ctx) { - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QUrl url = v8engine->toVariant(ctx->callData->args[0], -1).toUrl(); + QUrl url = v8engine->toVariant(ctx->d()->callData->args[0], -1).toUrl(); QQmlEngine *e = v8engine->engine(); QQmlEnginePrivate *p = 0; if (e) p = QQmlEnginePrivate::get(e); if (p) { QQmlContextData *ctxt = v8engine->callingContext(); if (ctxt) - return ctx->engine->newString(ctxt->resolvedUrl(url).toString())->asReturnedValue(); + return ctx->d()->engine->newString(ctxt->resolvedUrl(url).toString())->asReturnedValue(); else - return ctx->engine->newString(url.toString())->asReturnedValue(); + return ctx->d()->engine->newString(url.toString())->asReturnedValue(); } - return ctx->engine->newString(e->baseUrl().resolved(url).toString())->asReturnedValue(); + return ctx->d()->engine->newString(e->baseUrl().resolved(url).toString())->asReturnedValue(); } /*! @@ -854,10 +854,10 @@ Returns a list of the font families available to the application. */ ReturnedValue QtObject::method_fontFamilies(CallContext *ctx) { - if (ctx->callData->argc != 0) + if (ctx->d()->callData->argc != 0) V4THROW_ERROR("Qt.fontFamilies(): Invalid arguments"); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; return v8engine->fromVariant(QVariant(QQml_guiProvider()->fontFamilies())); } @@ -867,12 +867,12 @@ Returns a hex string of the md5 hash of \c data. */ ReturnedValue QtObject::method_md5(CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_ERROR("Qt.md5(): Invalid arguments"); - QByteArray data = ctx->callData->args[0].toQStringNoThrow().toUtf8(); + QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8(); QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5); - return ctx->engine->newString(QLatin1String(result.toHex()))->asReturnedValue(); + return ctx->d()->engine->newString(QLatin1String(result.toHex()))->asReturnedValue(); } /*! @@ -881,12 +881,12 @@ Binary to ASCII - this function returns a base64 encoding of \c data. */ ReturnedValue QtObject::method_btoa(CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_ERROR("Qt.btoa(): Invalid arguments"); - QByteArray data = ctx->callData->args[0].toQStringNoThrow().toUtf8(); + QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8(); - return ctx->engine->newString(QLatin1String(data.toBase64()))->asReturnedValue(); + return ctx->d()->engine->newString(QLatin1String(data.toBase64()))->asReturnedValue(); } /*! @@ -895,12 +895,12 @@ ASCII to binary - this function returns a base64 decoding of \c data. */ ReturnedValue QtObject::method_atob(CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_ERROR("Qt.atob(): Invalid arguments"); - QByteArray data = ctx->callData->args[0].toQStringNoThrow().toLatin1(); + QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toLatin1(); - return ctx->engine->newString(QString::fromUtf8(QByteArray::fromBase64(data)))->asReturnedValue(); + return ctx->d()->engine->newString(QString::fromUtf8(QByteArray::fromBase64(data)))->asReturnedValue(); } /*! @@ -912,7 +912,7 @@ QQmlEngine::quit() signal to the QCoreApplication::quit() slot. */ ReturnedValue QtObject::method_quit(CallContext *ctx) { - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; QQmlEnginePrivate::get(v8engine->engine())->sendQuit(); return QV4::Encode::undefined(); @@ -945,7 +945,7 @@ See \l {Dynamic QML Object Creation from JavaScript} for more information on usi ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) { Scope scope(ctx); - if (ctx->callData->argc < 2 || ctx->callData->argc > 3) + if (ctx->d()->callData->argc < 2 || ctx->d()->callData->argc > 3) V4THROW_ERROR("Qt.createQmlObject(): Invalid arguments"); struct Error { @@ -975,7 +975,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) } }; - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; QQmlEngine *engine = v8engine->engine(); QQmlContextData *context = v8engine->callingContext(); @@ -987,13 +987,13 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) effectiveContext = context->asQQmlContext(); Q_ASSERT(effectiveContext); - QString qml = ctx->callData->args[0].toQStringNoThrow(); + QString qml = ctx->d()->callData->args[0].toQStringNoThrow(); if (qml.isEmpty()) return QV4::Encode::null(); QUrl url; - if (ctx->callData->argc > 2) - url = QUrl(ctx->callData->args[2].toQStringNoThrow()); + if (ctx->d()->callData->argc > 2) + url = QUrl(ctx->d()->callData->args[2].toQStringNoThrow()); else url = QUrl(QLatin1String("inline")); @@ -1001,7 +1001,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) url = context->resolvedUrl(url); QObject *parentArg = 0; - QV4::Scoped qobjectWrapper(scope, ctx->callData->args[1]); + QV4::Scoped qobjectWrapper(scope, ctx->d()->callData->args[1]); if (!!qobjectWrapper) parentArg = qobjectWrapper->object(); if (!parentArg) @@ -1011,7 +1011,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) component.setData(qml.toUtf8(), url); if (component.isError()) { - ScopedValue v(scope, Error::create(ctx->engine, component.errors())); + ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors())); return ctx->throwError(v); } @@ -1035,13 +1035,13 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) component.completeCreate(); if (component.isError()) { - ScopedValue v(scope, Error::create(ctx->engine, component.errors())); + ScopedValue v(scope, Error::create(ctx->d()->engine, component.errors())); return ctx->throwError(v); } Q_ASSERT(obj); - return QV4::QObjectWrapper::wrap(ctx->engine, obj); + return QV4::QObjectWrapper::wrap(ctx->d()->engine, obj); } /*! @@ -1077,12 +1077,12 @@ use \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()}. */ ReturnedValue QtObject::method_createComponent(CallContext *ctx) { - if (ctx->callData->argc < 1 || ctx->callData->argc > 3) + if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3) return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); Scope scope(ctx); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; QQmlEngine *engine = v8engine->engine(); QQmlContextData *context = v8engine->callingContext(); @@ -1091,7 +1091,7 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) if (context->isPragmaLibraryContext) effectiveContext = 0; - QString arg = ctx->callData->args[0].toQStringNoThrow(); + QString arg = ctx->d()->callData->args[0].toQStringNoThrow(); if (arg.isEmpty()) return QV4::Encode::null(); @@ -1099,23 +1099,23 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) QObject *parentArg = 0; int consumedCount = 1; - if (ctx->callData->argc > 1) { - ScopedValue lastArg(scope, ctx->callData->args[ctx->callData->argc-1]); + if (ctx->d()->callData->argc > 1) { + ScopedValue lastArg(scope, ctx->d()->callData->args[ctx->d()->callData->argc-1]); // The second argument could be the mode enum - if (ctx->callData->args[1].isInteger()) { - int mode = ctx->callData->args[1].integerValue(); + if (ctx->d()->callData->args[1].isInteger()) { + int mode = ctx->d()->callData->args[1].integerValue(); if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous)) return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); compileMode = QQmlComponent::CompilationMode(mode); consumedCount += 1; } else { // The second argument could be the parent only if there are exactly two args - if ((ctx->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull())) + if ((ctx->d()->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull())) return ctx->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); } - if (consumedCount < ctx->callData->argc) { + if (consumedCount < ctx->d()->callData->argc) { if (lastArg->isObject()) { Scoped qobjectWrapper(scope, lastArg); if (qobjectWrapper) @@ -1136,7 +1136,7 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) QQmlData::get(c, true)->explicitIndestructibleSet = false; QQmlData::get(c)->indestructible = false; - return QV4::QObjectWrapper::wrap(ctx->engine, c); + return QV4::QObjectWrapper::wrap(ctx->d()->engine, c); } /*! @@ -1162,14 +1162,14 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) ReturnedValue QtObject::method_locale(CallContext *ctx) { QString code; - if (ctx->callData->argc > 1) + if (ctx->d()->callData->argc > 1) V4THROW_ERROR("locale() requires 0 or 1 argument"); - if (ctx->callData->argc == 1 && !ctx->callData->args[0].isString()) + if (ctx->d()->callData->argc == 1 && !ctx->d()->callData->args[0].isString()) V4THROW_TYPE("locale(): argument (locale code) must be a string"); - QV8Engine *v8engine = ctx->engine->v8Engine; - if (ctx->callData->argc == 1) - code = ctx->callData->args[0].toQStringNoThrow(); + QV8Engine *v8engine = ctx->d()->engine->v8Engine; + if (ctx->d()->callData->argc == 1) + code = ctx->d()->callData->args[0].toQStringNoThrow(); return QQmlLocale::locale(v8engine, code); } @@ -1250,20 +1250,20 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction); */ ReturnedValue QtObject::method_binding(CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_ERROR("binding() requires 1 argument"); - QV4::FunctionObject *f = ctx->callData->args[0].asFunctionObject(); + QV4::FunctionObject *f = ctx->d()->callData->args[0].asFunctionObject(); if (!f) V4THROW_TYPE("binding(): argument (binding expression) must be a function"); - return (new (ctx->engine->memoryManager) QQmlBindingFunction(f))->asReturnedValue(); + return (new (ctx->d()->engine->memoryManager) QQmlBindingFunction(f))->asReturnedValue(); } ReturnedValue QtObject::method_get_platform(CallContext *ctx) { // ### inefficient. Should be just a value based getter - Object *o = ctx->callData->thisObject.asObject(); + Object *o = ctx->d()->callData->thisObject.asObject(); if (!o) return ctx->throwTypeError(); QtObject *qt = o->as(); @@ -1272,15 +1272,15 @@ ReturnedValue QtObject::method_get_platform(CallContext *ctx) if (!qt->d()->platform) // Only allocate a platform object once - qt->d()->platform = new QQmlPlatform(ctx->engine->v8Engine->publicEngine()); + qt->d()->platform = new QQmlPlatform(ctx->d()->engine->v8Engine->publicEngine()); - return QV4::QObjectWrapper::wrap(ctx->engine, qt->d()->platform); + return QV4::QObjectWrapper::wrap(ctx->d()->engine, qt->d()->platform); } ReturnedValue QtObject::method_get_application(CallContext *ctx) { // ### inefficient. Should be just a value based getter - Object *o = ctx->callData->thisObject.asObject(); + Object *o = ctx->d()->callData->thisObject.asObject(); if (!o) return ctx->throwTypeError(); QtObject *qt = o->as(); @@ -1289,9 +1289,9 @@ ReturnedValue QtObject::method_get_application(CallContext *ctx) if (!qt->d()->application) // Only allocate an application object once - qt->d()->application = QQml_guiProvider()->application(ctx->engine->v8Engine->publicEngine()); + qt->d()->application = QQml_guiProvider()->application(ctx->d()->engine->v8Engine->publicEngine()); - return QV4::QObjectWrapper::wrap(ctx->engine, qt->d()->application); + return QV4::QObjectWrapper::wrap(ctx->d()->engine, qt->d()->application); } #ifndef QT_NO_IM @@ -1299,7 +1299,7 @@ ReturnedValue QtObject::method_get_inputMethod(CallContext *ctx) { QObject *o = QQml_guiProvider()->inputMethod(); QQmlEngine::setObjectOwnership(o, QQmlEngine::CppOwnership); - return QV4::QObjectWrapper::wrap(ctx->engine, o); + return QV4::QObjectWrapper::wrap(ctx->d()->engine, o); } #endif @@ -1363,16 +1363,16 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *c bool printStack = false) { QString result; - QV4::ExecutionEngine *v4 = ctx->engine; + QV4::ExecutionEngine *v4 = ctx->d()->engine; - for (int i = 0; i < ctx->callData->argc; ++i) { + for (int i = 0; i < ctx->d()->callData->argc; ++i) { if (i != 0) result.append(QLatin1Char(' ')); - if (ctx->callData->args[i].asArrayObject()) - result.append(QStringLiteral("[") + ctx->callData->args[i].toQStringNoThrow() + QStringLiteral("]")); + if (ctx->d()->callData->args[i].asArrayObject()) + result.append(QStringLiteral("[") + ctx->d()->callData->args[i].toQStringNoThrow() + QStringLiteral("]")); else - result.append(ctx->callData->args[i].toQStringNoThrow()); + result.append(ctx->d()->callData->args[i].toQStringNoThrow()); } if (printStack) { @@ -1422,7 +1422,7 @@ QV4::ReturnedValue ConsoleObject::method_log(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_profile(CallContext *ctx) { - QV4::ExecutionEngine *v4 = ctx->engine; + QV4::ExecutionEngine *v4 = ctx->d()->engine; QV4::StackFrame frame = v4->currentStackFrame(); const QByteArray baSource = frame.source.toUtf8(); @@ -1440,7 +1440,7 @@ QV4::ReturnedValue ConsoleObject::method_profile(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_profileEnd(CallContext *ctx) { - QV4::ExecutionEngine *v4 = ctx->engine; + QV4::ExecutionEngine *v4 = ctx->d()->engine; QV4::StackFrame frame = v4->currentStackFrame(); const QByteArray baSource = frame.source.toUtf8(); @@ -1459,24 +1459,24 @@ QV4::ReturnedValue ConsoleObject::method_profileEnd(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_time(CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_ERROR("console.time(): Invalid arguments"); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QString name = ctx->callData->args[0].toQStringNoThrow(); + QString name = ctx->d()->callData->args[0].toQStringNoThrow(); v8engine->startTimer(name); return QV4::Encode::undefined(); } QV4::ReturnedValue ConsoleObject::method_timeEnd(CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_ERROR("console.time(): Invalid arguments"); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QString name = ctx->callData->args[0].toQStringNoThrow(); + QString name = ctx->d()->callData->args[0].toQStringNoThrow(); bool wasRunning; qint64 elapsed = v8engine->stopTimer(name, &wasRunning); if (wasRunning) { @@ -1489,11 +1489,11 @@ QV4::ReturnedValue ConsoleObject::method_count(CallContext *ctx) { // first argument: name to print. Ignore any additional arguments QString name; - if (ctx->callData->argc > 0) - name = ctx->callData->args[0].toQStringNoThrow(); + if (ctx->d()->callData->argc > 0) + name = ctx->d()->callData->args[0].toQStringNoThrow(); - QV4::ExecutionEngine *v4 = ctx->engine; - QV8Engine *v8engine = ctx->engine->v8Engine; + QV4::ExecutionEngine *v4 = ctx->d()->engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; QV4::StackFrame frame = v4->currentStackFrame(); @@ -1511,10 +1511,10 @@ QV4::ReturnedValue ConsoleObject::method_count(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_trace(CallContext *ctx) { - if (ctx->callData->argc != 0) + if (ctx->d()->callData->argc != 0) V4THROW_ERROR("console.trace(): Invalid arguments"); - QV4::ExecutionEngine *v4 = ctx->engine; + QV4::ExecutionEngine *v4 = ctx->d()->engine; QString stack = jsStack(v4); @@ -1533,18 +1533,18 @@ QV4::ReturnedValue ConsoleObject::method_warn(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_assert(CallContext *ctx) { - if (ctx->callData->argc == 0) + if (ctx->d()->callData->argc == 0) V4THROW_ERROR("console.assert(): Missing argument"); - QV4::ExecutionEngine *v4 = ctx->engine; + QV4::ExecutionEngine *v4 = ctx->d()->engine; - if (!ctx->callData->args[0].toBoolean()) { + if (!ctx->d()->callData->args[0].toBoolean()) { QString message; - for (int i = 1; i < ctx->callData->argc; ++i) { + for (int i = 1; i < ctx->d()->callData->argc; ++i) { if (i != 1) message.append(QLatin1Char(' ')); - message.append(ctx->callData->args[i].toQStringNoThrow()); + message.append(ctx->d()->callData->args[i].toQStringNoThrow()); } QString stack = jsStack(v4); @@ -1560,7 +1560,7 @@ QV4::ReturnedValue ConsoleObject::method_assert(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_exception(CallContext *ctx) { - if (ctx->callData->argc == 0) + if (ctx->d()->callData->argc == 0) V4THROW_ERROR("console.exception(): Missing argument"); writeToConsole(Error, ctx, true); @@ -1618,36 +1618,36 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject) */ ReturnedValue GlobalExtensions::method_qsTranslate(CallContext *ctx) { - if (ctx->callData->argc < 2) + if (ctx->d()->callData->argc < 2) V4THROW_ERROR("qsTranslate() requires at least two arguments"); - if (!ctx->callData->args[0].isString()) + if (!ctx->d()->callData->args[0].isString()) V4THROW_ERROR("qsTranslate(): first argument (context) must be a string"); - if (!ctx->callData->args[1].isString()) + if (!ctx->d()->callData->args[1].isString()) V4THROW_ERROR("qsTranslate(): second argument (sourceText) must be a string"); - if ((ctx->callData->argc > 2) && !ctx->callData->args[2].isString()) + if ((ctx->d()->callData->argc > 2) && !ctx->d()->callData->args[2].isString()) V4THROW_ERROR("qsTranslate(): third argument (disambiguation) must be a string"); - QString context = ctx->callData->args[0].toQStringNoThrow(); - QString text = ctx->callData->args[1].toQStringNoThrow(); + QString context = ctx->d()->callData->args[0].toQStringNoThrow(); + QString text = ctx->d()->callData->args[1].toQStringNoThrow(); QString comment; - if (ctx->callData->argc > 2) comment = ctx->callData->args[2].toQStringNoThrow(); + if (ctx->d()->callData->argc > 2) comment = ctx->d()->callData->args[2].toQStringNoThrow(); int i = 3; - if (ctx->callData->argc > i && ctx->callData->args[i].isString()) { + if (ctx->d()->callData->argc > i && ctx->d()->callData->args[i].isString()) { qWarning("qsTranslate(): specifying the encoding as fourth argument is deprecated"); ++i; } int n = -1; - if (ctx->callData->argc > i) - n = ctx->callData->args[i].toInt32(); + if (ctx->d()->callData->argc > i) + n = ctx->d()->callData->args[i].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), comment.toUtf8().constData(), n); - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } /*! @@ -1674,9 +1674,9 @@ ReturnedValue GlobalExtensions::method_qsTranslate(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(CallContext *ctx) { - if (ctx->callData->argc < 2) + if (ctx->d()->callData->argc < 2) return QV4::Encode::undefined(); - return ctx->callData->args[1].asReturnedValue(); + return ctx->d()->callData->args[1].asReturnedValue(); } /*! @@ -1698,16 +1698,16 @@ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx) { - if (ctx->callData->argc < 1) + if (ctx->d()->callData->argc < 1) V4THROW_ERROR("qsTr() requires at least one argument"); - if (!ctx->callData->args[0].isString()) + if (!ctx->d()->callData->args[0].isString()) V4THROW_ERROR("qsTr(): first argument (sourceText) must be a string"); - if ((ctx->callData->argc > 1) && !ctx->callData->args[1].isString()) + if ((ctx->d()->callData->argc > 1) && !ctx->d()->callData->args[1].isString()) V4THROW_ERROR("qsTr(): second argument (disambiguation) must be a string"); - if ((ctx->callData->argc > 2) && !ctx->callData->args[2].isNumber()) + if ((ctx->d()->callData->argc > 2) && !ctx->d()->callData->args[2].isNumber()) V4THROW_ERROR("qsTr(): third argument (n) must be a number"); - QV8Engine *v8engine = ctx->engine->v8Engine; + QV8Engine *v8engine = ctx->d()->engine->v8Engine; QString context; if (QQmlContextData *ctxt = v8engine->callingContext()) { QString path = ctxt->url.toString(); @@ -1715,10 +1715,10 @@ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx) int lastDot = path.lastIndexOf(QLatin1Char('.')); int length = lastDot - (lastSlash + 1); context = (lastSlash > -1) ? path.mid(lastSlash + 1, (length > -1) ? length : -1) : QString(); - } else if (QV4::ExecutionContext *parentCtx = ctx->parent) { + } else if (QV4::ExecutionContext *parentCtx = ctx->d()->parent) { // The first non-empty source URL in the call stack determines the translation context. while (parentCtx && context.isEmpty()) { - if (QV4::CompiledData::CompilationUnit *unit = parentCtx->compilationUnit) { + if (QV4::CompiledData::CompilationUnit *unit = parentCtx->d()->compilationUnit) { QString fileName = unit->fileName(); QUrl url(unit->fileName()); if (url.isValid() && url.isRelative()) { @@ -1730,22 +1730,22 @@ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx) } context = QFileInfo(context).baseName(); } - parentCtx = parentCtx->parent; + parentCtx = parentCtx->d()->parent; } } - QString text = ctx->callData->args[0].toQStringNoThrow(); + QString text = ctx->d()->callData->args[0].toQStringNoThrow(); QString comment; - if (ctx->callData->argc > 1) - comment = ctx->callData->args[1].toQStringNoThrow(); + if (ctx->d()->callData->argc > 1) + comment = ctx->d()->callData->args[1].toQStringNoThrow(); int n = -1; - if (ctx->callData->argc > 2) - n = ctx->callData->args[2].toInt32(); + if (ctx->d()->callData->argc > 2) + n = ctx->d()->callData->args[2].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), comment.toUtf8().constData(), n); - return ctx->engine->newString(result)->asReturnedValue(); + return ctx->d()->engine->newString(result)->asReturnedValue(); } /*! @@ -1772,9 +1772,9 @@ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrNoOp(CallContext *ctx) { - if (ctx->callData->argc < 1) + if (ctx->d()->callData->argc < 1) return QV4::Encode::undefined(); - return ctx->callData->args[0].asReturnedValue(); + return ctx->d()->callData->args[0].asReturnedValue(); } /*! @@ -1809,18 +1809,18 @@ ReturnedValue GlobalExtensions::method_qsTrNoOp(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrId(CallContext *ctx) { - if (ctx->callData->argc < 1) + if (ctx->d()->callData->argc < 1) V4THROW_ERROR("qsTrId() requires at least one argument"); - if (!ctx->callData->args[0].isString()) + if (!ctx->d()->callData->args[0].isString()) V4THROW_TYPE("qsTrId(): first argument (id) must be a string"); - if (ctx->callData->argc > 1 && !ctx->callData->args[1].isNumber()) + if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isNumber()) V4THROW_TYPE("qsTrId(): second argument (n) must be a number"); int n = -1; - if (ctx->callData->argc > 1) - n = ctx->callData->args[1].toInt32(); + if (ctx->d()->callData->argc > 1) + n = ctx->d()->callData->args[1].toInt32(); - return ctx->engine->newString(qtTrId(ctx->callData->args[0].toQStringNoThrow().toUtf8().constData(), n))->asReturnedValue(); + return ctx->d()->engine->newString(qtTrId(ctx->d()->callData->args[0].toQStringNoThrow().toUtf8().constData(), n))->asReturnedValue(); } /*! @@ -1841,16 +1841,16 @@ ReturnedValue GlobalExtensions::method_qsTrId(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(CallContext *ctx) { - if (ctx->callData->argc < 1) + if (ctx->d()->callData->argc < 1) return QV4::Encode::undefined(); - return ctx->callData->args[0].asReturnedValue(); + return ctx->d()->callData->args[0].asReturnedValue(); } #endif // QT_NO_TRANSLATION QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx) { - ctx->engine->memoryManager->runGC(); + ctx->d()->engine->memoryManager->runGC(); return QV4::Encode::undefined(); } @@ -1859,21 +1859,21 @@ QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx) ReturnedValue GlobalExtensions::method_string_arg(CallContext *ctx) { - if (ctx->callData->argc != 1) + if (ctx->d()->callData->argc != 1) V4THROW_ERROR("String.arg(): Invalid arguments"); - QString value = ctx->callData->thisObject.toQString(); + QString value = ctx->d()->callData->thisObject.toQString(); QV4::Scope scope(ctx); - QV4::ScopedValue arg(scope, ctx->callData->args[0]); + QV4::ScopedValue arg(scope, ctx->d()->callData->args[0]); if (arg->isInteger()) - return ctx->engine->newString(value.arg(arg->integerValue()))->asReturnedValue(); + return ctx->d()->engine->newString(value.arg(arg->integerValue()))->asReturnedValue(); else if (arg->isDouble()) - return ctx->engine->newString(value.arg(arg->doubleValue()))->asReturnedValue(); + return ctx->d()->engine->newString(value.arg(arg->doubleValue()))->asReturnedValue(); else if (arg->isBoolean()) - return ctx->engine->newString(value.arg(arg->booleanValue()))->asReturnedValue(); + return ctx->d()->engine->newString(value.arg(arg->booleanValue()))->asReturnedValue(); - return ctx->engine->newString(value.arg(arg->toQString()))->asReturnedValue(); + return ctx->d()->engine->newString(value.arg(arg->toQString()))->asReturnedValue(); } diff --git a/src/qml/qml/v8/qv4domerrors_p.h b/src/qml/qml/v8/qv4domerrors_p.h index faf52ce1ad..c650ed810a 100644 --- a/src/qml/qml/v8/qv4domerrors_p.h +++ b/src/qml/qml/v8/qv4domerrors_p.h @@ -77,9 +77,9 @@ QT_BEGIN_NAMESPACE #define DOMEXCEPTION_TYPE_MISMATCH_ERR 17 #define V4THROW_DOM(error, string) { \ - QV4::ScopedValue v(scope, ctx->engine->newString(QStringLiteral(string))); \ - QV4::Scoped ex(scope, ctx->engine->newErrorObject(v)); \ - ex->put(QV4::ScopedString(scope, ctx->engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \ + QV4::ScopedValue v(scope, scope.engine->newString(QStringLiteral(string))); \ + QV4::Scoped ex(scope, scope.engine->newErrorObject(v)); \ + ex->put(QV4::ScopedString(scope, scope.engine->newIdentifier(QStringLiteral("code"))), QV4::ScopedValue(scope, QV4::Primitive::fromInt32(error))); \ return ctx->throwError(ex); \ } diff --git a/src/qml/qml/v8/qv8engine.cpp b/src/qml/qml/v8/qv8engine.cpp index 2c5d8191aa..e524b60d7f 100644 --- a/src/qml/qml/v8/qv8engine.cpp +++ b/src/qml/qml/v8/qv8engine.cpp @@ -261,7 +261,7 @@ QV4::ReturnedValue QV8Engine::fromVariant(const QVariant &variant) case QMetaType::Double: return QV4::Encode(*reinterpret_cast(ptr)); case QMetaType::QString: - return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast(ptr))->asReturnedValue(); + return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast(ptr))->asReturnedValue(); case QMetaType::Float: return QV4::Encode(*reinterpret_cast(ptr)); case QMetaType::Short: @@ -679,7 +679,7 @@ QV4::ReturnedValue QV8Engine::metaTypeToJS(int type, const void *data) case QMetaType::Double: return QV4::Encode(*reinterpret_cast(data)); case QMetaType::QString: - return m_v4Engine->currentContext()->engine->newString(*reinterpret_cast(data))->asReturnedValue(); + return m_v4Engine->currentContext()->d()->engine->newString(*reinterpret_cast(data))->asReturnedValue(); case QMetaType::Float: return QV4::Encode(*reinterpret_cast(data)); case QMetaType::Short: diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 3a3e5f55df..73cb1771a1 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1776,7 +1776,7 @@ int QQmlDelegateModelItemMetaType::parseGroups(const QV4::ValueRef groups) const QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); if (!o->d()->item->metaType->model) @@ -1788,7 +1788,7 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::CallContext *ctx) QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -1798,23 +1798,23 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::CallContext *ctx) groups.append(o->d()->item->metaType->groupNames.at(i - 1)); } - return ctx->engine->v8Engine->fromVariant(groups); + return scope.engine->v8Engine->fromVariant(groups); } QV4::ReturnedValue QQmlDelegateModelItem::set_groups(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) return ctx->throwTypeError(); if (!o->d()->item->metaType->model) return QV4::Encode::undefined(); QQmlDelegateModelPrivate *model = QQmlDelegateModelPrivate::get(o->d()->item->metaType->model); - const int groupFlags = model->m_cacheMetaType->parseGroups(ctx->callData->args[0]); + const int groupFlags = model->m_cacheMetaType->parseGroups(ctx->d()->callData->args[0]); const int cacheIndex = model->m_cache.indexOf(o->d()->item); Compositor::iterator it = model->m_compositor.find(Compositor::Cache, cacheIndex); model->setGroups(it, 1, Compositor::Cache, groupFlags); @@ -3224,21 +3224,21 @@ struct QQmlDelegateModelGroupChange : QV4::Object static QV4::ReturnedValue method_get_index(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped that(scope, ctx->callData->thisObject.as()); + QV4::Scoped that(scope, ctx->d()->callData->thisObject.as()); if (!that) return ctx->throwTypeError(); return QV4::Encode(that->d()->change.index); } static QV4::ReturnedValue method_get_count(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped that(scope, ctx->callData->thisObject.as()); + QV4::Scoped that(scope, ctx->d()->callData->thisObject.as()); if (!that) return ctx->throwTypeError(); return QV4::Encode(that->d()->change.count); } static QV4::ReturnedValue method_get_moveId(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped that(scope, ctx->callData->thisObject.as()); + QV4::Scoped that(scope, ctx->d()->callData->thisObject.as()); if (!that) return ctx->throwTypeError(); if (that->d()->change.moveId < 0) diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 4e842c5133..26b0bef030 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -283,12 +283,12 @@ QQuickWorkerScriptEnginePrivate::QQuickWorkerScriptEnginePrivate(QQmlEngine *eng QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::method_sendMessage(QV4::CallContext *ctx) { - WorkerEngine *engine = (WorkerEngine*)ctx->engine->v8Engine; + WorkerEngine *engine = (WorkerEngine*)ctx->engine()->v8Engine; - int id = ctx->callData->argc > 1 ? ctx->callData->args[1].toInt32() : 0; + int id = ctx->d()->callData->argc > 1 ? ctx->d()->callData->args[1].toInt32() : 0; QV4::Scope scope(ctx); - QV4::ScopedValue v(scope, ctx->callData->argument(2)); + QV4::ScopedValue v(scope, ctx->d()->callData->argument(2)); QByteArray data = QV4::Serialize::serialize(v, engine); QMutexLocker locker(&engine->p->m_lock); diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index 6b48b3d38a..c661a3b358 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -66,7 +66,7 @@ V8_DEFINE_EXTENSION(QQmlAdaptorModelEngineData, engineData) static QV4::ReturnedValue get_index(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -198,7 +198,7 @@ public: static QV4::ReturnedValue get_hasModelChildren(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -343,18 +343,18 @@ bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &, int idx) QV4::ReturnedValue QQmlDMCachedModelData::get_property(QV4::CallContext *ctx, uint propertyId) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); QQmlDMCachedModelData *modelData = static_cast(o->d()->item); if (o->d()->item->index == -1) { if (!modelData->cachedData.isEmpty()) { - return ctx->engine->v8Engine->fromVariant( + return ctx->d()->engine->v8Engine->fromVariant( modelData->cachedData.at(modelData->type->hasModelData ? 0 : propertyId)); } } else if (*modelData->type->model) { - return ctx->engine->v8Engine->fromVariant( + return ctx->d()->engine->v8Engine->fromVariant( modelData->value(modelData->type->propertyRoles.at(propertyId))); } return QV4::Encode::undefined(); @@ -363,20 +363,20 @@ QV4::ReturnedValue QQmlDMCachedModelData::get_property(QV4::CallContext *ctx, ui QV4::ReturnedValue QQmlDMCachedModelData::set_property(QV4::CallContext *ctx, uint propertyId) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) return ctx->throwTypeError(); if (o->d()->item->index == -1) { QQmlDMCachedModelData *modelData = static_cast(o->d()->item); if (!modelData->cachedData.isEmpty()) { if (modelData->cachedData.count() > 1) { - modelData->cachedData[propertyId] = ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid); + modelData->cachedData[propertyId] = scope.engine->v8Engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, 0); } else if (modelData->cachedData.count() == 1) { - modelData->cachedData[0] = ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid); + modelData->cachedData[0] = scope.engine->v8Engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 0, 0); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), 1, 0); } @@ -585,23 +585,23 @@ public: static QV4::ReturnedValue get_modelData(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); - return ctx->engine->v8Engine->fromVariant(static_cast(o->d()->item)->cachedData); + return scope.engine->v8Engine->fromVariant(static_cast(o->d()->item)->cachedData); } static QV4::ReturnedValue set_modelData(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped o(scope, ctx->callData->thisObject.as()); + QV4::Scoped o(scope, ctx->d()->callData->thisObject.as()); if (!o) return ctx->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->callData->argc) + if (!ctx->d()->callData->argc) return ctx->throwTypeError(); - static_cast(o->d()->item)->setModelData(ctx->engine->v8Engine->toVariant(ctx->callData->args[0], QVariant::Invalid)); + static_cast(o->d()->item)->setModelData(scope.engine->v8Engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid)); return QV4::Encode::undefined(); } -- cgit v1.2.3