diff options
author | Lars Knoll <lars.knoll@theqtcompany.com> | 2015-01-15 21:54:12 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@digia.com> | 2015-01-23 12:30:38 +0100 |
commit | ef6b4938b9ec309d5faf0c966cb2b58f3de2ca77 (patch) | |
tree | 3d946ad66defb1ec5c60a50e16b6e7883ec33862 /src/qml | |
parent | 3dbf4e9a6979802fff55e2f5e6aa54a14280e128 (diff) |
Cleanups
Simplify some code in BooleanObject
Simplify access to call arguments and thisObject
Change-Id: I2f8e844019bc587385608beb02f05b15f827535c
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml')
38 files changed, 735 insertions, 725 deletions
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index f48ab9e39d..82a6fd58e2 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -60,8 +60,8 @@ Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context) args->propertyAt(CallerPropertyIndex)->value = v4->thrower; args->propertyAt(CallerPropertyIndex)->set = v4->thrower; - args->arrayReserve(context->d()->callData->argc); - args->arrayPut(0, context->d()->callData->args, context->d()->callData->argc); + args->arrayReserve(context->argc()); + args->arrayPut(0, context->args(), context->argc()); args->d()->fullyCreated = true; } else { Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee)); diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 5d2c95bed4..e288023b80 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -123,7 +123,7 @@ void ArrayBufferPrototype::init(ExecutionEngine *engine, Object *ctor) ReturnedValue ArrayBufferPrototype::method_get_byteLength(CallContext *ctx) { Scope scope(ctx); - Scoped<ArrayBuffer> v(scope, ctx->d()->callData->thisObject); + Scoped<ArrayBuffer> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -133,13 +133,13 @@ ReturnedValue ArrayBufferPrototype::method_get_byteLength(CallContext *ctx) ReturnedValue ArrayBufferPrototype::method_slice(CallContext *ctx) { Scope scope(ctx); - Scoped<ArrayBuffer> a(scope, ctx->d()->callData->thisObject); + Scoped<ArrayBuffer> a(scope, ctx->thisObject()); if (!a) return scope.engine->throwTypeError(); - double start = ctx->d()->callData->argc > 0 ? ctx->d()->callData->args[0].toInteger() : 0; - double end = (ctx->d()->callData->argc < 2 || ctx->d()->callData->args[1].isUndefined()) ? - a->d()->data->size : ctx->d()->callData->args[1].toInteger(); + double start = ctx->argc() > 0 ? ctx->args()[0].toInteger() : 0; + double end = (ctx->argc() < 2 || ctx->args()[1].isUndefined()) ? + a->d()->data->size : ctx->args()[1].toInteger(); if (scope.engine->hasException) return Encode::undefined(); diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index 68c289a52d..d3239b6098 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -265,7 +265,7 @@ void SimpleArrayData::setAttribute(Object *o, uint index, PropertyAttributes att o->arrayData()->attrs[index] = attrs; } -void SimpleArrayData::push_front(Object *o, Value *values, uint n) +void SimpleArrayData::push_front(Object *o, const Value *values, uint n) { Heap::SimpleArrayData *dd = static_cast<Heap::SimpleArrayData *>(o->d()->arrayData); Q_ASSERT(!dd->attrs); @@ -484,7 +484,7 @@ void SparseArrayData::setAttribute(Object *o, uint index, PropertyAttributes att d->attrs[n->value] = attrs; } -void SparseArrayData::push_front(Object *o, Value *values, uint n) +void SparseArrayData::push_front(Object *o, const Value *values, uint n) { Heap::SparseArrayData *d = static_cast<Heap::SparseArrayData *>(o->d()->arrayData); Q_ASSERT(!d->attrs); diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h index 5ae3883647..7421b7b236 100644 --- a/src/qml/jsruntime/qv4arraydata_p.h +++ b/src/qml/jsruntime/qv4arraydata_p.h @@ -65,7 +65,7 @@ struct ArrayVTable bool (*putArray)(Object *o, uint index, const Value *values, uint n); bool (*del)(Object *o, uint index); void (*setAttribute)(Object *o, uint index, PropertyAttributes attrs); - void (*push_front)(Object *o, Value *values, uint n); + void (*push_front)(Object *o, const Value *values, uint n); ReturnedValue (*pop_front)(Object *o); uint (*truncate)(Object *o, uint newLen); uint (*length)(const Heap::ArrayData *d); @@ -228,7 +228,7 @@ struct Q_QML_EXPORT SimpleArrayData : public ArrayData static bool putArray(Object *o, uint index, const Value *values, uint n); static bool del(Object *o, uint index); static void setAttribute(Object *o, uint index, PropertyAttributes attrs); - static void push_front(Object *o, Value *values, uint n); + static void push_front(Object *o, const Value *values, uint n); static ReturnedValue pop_front(Object *o); static uint truncate(Object *o, uint newLen); static uint length(const Heap::ArrayData *d); @@ -257,7 +257,7 @@ struct Q_QML_EXPORT SparseArrayData : public ArrayData static bool putArray(Object *o, uint index, const Value *values, uint n); static bool del(Object *o, uint index); static void setAttribute(Object *o, uint index, PropertyAttributes attrs); - static void push_front(Object *o, Value *values, uint n); + static void push_front(Object *o, const Value *values, uint n); static ReturnedValue pop_front(Object *o); static uint truncate(Object *o, uint newLen); static uint length(const Heap::ArrayData *d); diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index 0361d0e628..6b39c4f68e 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -110,21 +110,21 @@ void ArrayPrototype::init(ExecutionEngine *engine, Object *ctor) ReturnedValue ArrayPrototype::method_isArray(CallContext *ctx) { - bool isArray = ctx->d()->callData->argc && ctx->d()->callData->args[0].asArrayObject(); + bool isArray = ctx->argc() && ctx->args()[0].asArrayObject(); return Encode(isArray); } ReturnedValue ArrayPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->d()->callData->thisObject, ScopedObject::Convert); + ScopedObject o(scope, ctx->thisObject(), ScopedObject::Convert); if (ctx->d()->engine->hasException) return Encode::undefined(); ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("join"))); ScopedFunctionObject f(scope, o->get(s)); if (!!f) { ScopedCallData d(scope, 0); - d->thisObject = ctx->d()->callData->thisObject; + d->thisObject = ctx->thisObject(); return f->call(d); } return ObjectPrototype::method_toString(ctx); @@ -140,7 +140,7 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx) Scope scope(ctx); ScopedObject result(scope, ctx->d()->engine->newArrayObject()); - ScopedObject thisObject(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject thisObject(scope, ctx->thisObject().toObject(scope.engine)); if (!thisObject) return Encode::undefined(); if (thisObject->isArrayObject()) { @@ -152,9 +152,9 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx) ScopedArrayObject elt(scope); ScopedObject eltAsObj(scope); ScopedValue entry(scope); - for (int i = 0; i < ctx->d()->callData->argc; ++i) { - eltAsObj = ctx->d()->callData->args[i]; - elt = ctx->d()->callData->args[i]; + for (int i = 0; i < ctx->argc(); ++i) { + eltAsObj = ctx->args()[i]; + elt = ctx->args()[i]; if (elt) { uint n = elt->getLength(); uint newLen = ArrayData::append(result, elt, n); @@ -166,7 +166,7 @@ ReturnedValue ArrayPrototype::method_concat(CallContext *ctx) result->putIndexed(startIndex + i, entry); } } else { - result->arraySet(result->getLength(), ctx->d()->callData->args[i]); + result->arraySet(result->getLength(), ctx->args()[i]); } } @@ -184,7 +184,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx) else r4 = arg->toQString(); - ScopedObject self(scope, ctx->d()->callData->thisObject); + ScopedObject self(scope, ctx->thisObject()); ScopedValue length(scope, self->get(ctx->d()->engine->id_length)); const quint32 r2 = length->isUndefined() ? 0 : length->toUInt32(); @@ -235,7 +235,7 @@ ReturnedValue ArrayPrototype::method_join(CallContext *ctx) ReturnedValue ArrayPrototype::method_pop(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); @@ -263,7 +263,7 @@ ReturnedValue ArrayPrototype::method_pop(CallContext *ctx) ReturnedValue ArrayPrototype::method_push(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -272,15 +272,15 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx) uint len = instance->getLength(); - if (len + ctx->d()->callData->argc < len) { + if (len + ctx->argc() < len) { // ughh... double l = len; ScopedString s(scope); - for (int i = 0; i < ctx->d()->callData->argc; ++i) { + for (int i = 0; i < ctx->argc(); ++i) { s = Primitive::fromDouble(l + i).toString(scope.engine); - instance->put(s, ctx->d()->callData->args[i]); + instance->put(s, ctx->args()[i]); } - double newLen = l + ctx->d()->callData->argc; + double newLen = l + ctx->argc(); if (!instance->isArrayObject()) instance->put(ctx->d()->engine->id_length, ScopedValue(scope, Primitive::fromDouble(newLen))); else { @@ -290,15 +290,15 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx) return Encode(newLen); } - if (!ctx->d()->callData->argc) + if (!ctx->argc()) ; else if (!instance->protoHasArray() && instance->arrayData()->length() <= len && instance->arrayData()->type == Heap::ArrayData::Simple) { - instance->arrayData()->vtable()->putArray(instance, len, ctx->d()->callData->args, ctx->d()->callData->argc); + instance->arrayData()->vtable()->putArray(instance, len, ctx->args(), ctx->argc()); len = instance->arrayData()->length(); } else { - for (int i = 0; i < ctx->d()->callData->argc; ++i) - instance->putIndexed(len + i, ctx->d()->callData->args[i]); - len += ctx->d()->callData->argc; + for (int i = 0; i < ctx->argc(); ++i) + instance->putIndexed(len + i, ctx->args()[i]); + len += ctx->argc(); } if (instance->isArrayObject()) instance->setArrayLengthUnchecked(len); @@ -311,7 +311,7 @@ ReturnedValue ArrayPrototype::method_push(CallContext *ctx) ReturnedValue ArrayPrototype::method_reverse(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); uint length = instance->getLength(); @@ -343,7 +343,7 @@ ReturnedValue ArrayPrototype::method_reverse(CallContext *ctx) ReturnedValue ArrayPrototype::method_shift(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -395,7 +395,7 @@ ReturnedValue ArrayPrototype::method_shift(CallContext *ctx) ReturnedValue ArrayPrototype::method_slice(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject o(scope, ctx->thisObject().toObject(scope.engine)); if (!o) return Encode::undefined(); @@ -410,8 +410,8 @@ ReturnedValue ArrayPrototype::method_slice(CallContext *ctx) else start = (uint) s; uint end = len; - if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) { - double e = ctx->d()->callData->args[1].toInteger(); + if (ctx->argc() > 1 && !ctx->args()[1].isUndefined()) { + double e = ctx->args()[1].toInteger(); if (e < 0) end = (uint)qMax(len + e, 0.); else if (e > len) @@ -437,7 +437,7 @@ ReturnedValue ArrayPrototype::method_slice(CallContext *ctx) ReturnedValue ArrayPrototype::method_sort(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -445,13 +445,13 @@ ReturnedValue ArrayPrototype::method_sort(CallContext *ctx) ScopedValue comparefn(scope, ctx->argument(0)); ArrayData::sort(scope.engine, instance, comparefn, len); - return ctx->d()->callData->thisObject.asReturnedValue(); + return ctx->thisObject().asReturnedValue(); } ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); @@ -479,7 +479,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) } newArray->setArrayLengthUnchecked(deleteCount); - uint itemCount = ctx->d()->callData->argc < 2 ? 0 : ctx->d()->callData->argc - 2; + uint itemCount = ctx->argc() < 2 ? 0 : ctx->argc() - 2; if (itemCount < deleteCount) { for (uint k = start; k < len - deleteCount; ++k) { @@ -517,7 +517,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) } for (uint i = 0; i < itemCount; ++i) { - instance->putIndexed(start + i, ctx->d()->callData->args[i + 2]); + instance->putIndexed(start + i, ctx->args()[i + 2]); if (scope.hasException()) return Encode::undefined(); } @@ -531,7 +531,7 @@ ReturnedValue ArrayPrototype::method_splice(CallContext *ctx) ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -542,22 +542,22 @@ ReturnedValue ArrayPrototype::method_unshift(CallContext *ctx) if (!instance->protoHasArray() && !instance->arrayData()->attrs && instance->arrayData()->length() <= len && instance->arrayData()->type != Heap::ArrayData::Custom) { - instance->arrayData()->vtable()->push_front(instance, ctx->d()->callData->args, ctx->d()->callData->argc); + instance->arrayData()->vtable()->push_front(instance, ctx->args(), ctx->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->d()->callData->argc - 1, v); + instance->putIndexed(k + ctx->argc() - 1, v); else - instance->deleteIndexedProperty(k + ctx->d()->callData->argc - 1); + instance->deleteIndexedProperty(k + ctx->argc() - 1); } - for (int i = 0; i < ctx->d()->callData->argc; ++i) - instance->putIndexed(i, ctx->d()->callData->args[i]); + for (int i = 0; i < ctx->argc(); ++i) + instance->putIndexed(i, ctx->args()[i]); } - uint newLen = len + ctx->d()->callData->argc; + uint newLen = len + ctx->argc(); if (instance->isArrayObject()) instance->setArrayLengthUnchecked(newLen); else @@ -570,18 +570,18 @@ ReturnedValue ArrayPrototype::method_indexOf(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); if (!len) return Encode(-1); - ScopedValue searchValue(scope, ctx->d()->callData->argument(0)); + ScopedValue searchValue(scope, ctx->argument(0)); uint fromIndex = 0; - if (ctx->d()->callData->argc >= 2) { - double f = ctx->d()->callData->args[1].toInteger(); + if (ctx->argc() >= 2) { + double f = ctx->args()[1].toInteger(); if (scope.hasException()) return Encode::undefined(); if (f >= len) @@ -639,7 +639,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); uint len = instance->getLength(); @@ -649,13 +649,13 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx) ScopedValue searchValue(scope); uint fromIndex = len; - if (ctx->d()->callData->argc >= 1) + if (ctx->argc() >= 1) searchValue = ctx->argument(0); else searchValue = Primitive::undefinedValue(); - if (ctx->d()->callData->argc >= 2) { - double f = ctx->d()->callData->args[1].toInteger(); + if (ctx->argc() >= 2) { + double f = ctx->args()[1].toInteger(); if (scope.hasException()) return Encode::undefined(); if (f > 0) @@ -684,7 +684,7 @@ ReturnedValue ArrayPrototype::method_lastIndexOf(CallContext *ctx) ReturnedValue ArrayPrototype::method_every(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -718,7 +718,7 @@ ReturnedValue ArrayPrototype::method_every(CallContext *ctx) ReturnedValue ArrayPrototype::method_some(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -752,7 +752,7 @@ ReturnedValue ArrayPrototype::method_some(CallContext *ctx) ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -783,7 +783,7 @@ ReturnedValue ArrayPrototype::method_forEach(CallContext *ctx) ReturnedValue ArrayPrototype::method_map(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -820,7 +820,7 @@ ReturnedValue ArrayPrototype::method_map(CallContext *ctx) ReturnedValue ArrayPrototype::method_filter(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -861,7 +861,7 @@ ReturnedValue ArrayPrototype::method_filter(CallContext *ctx) ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -875,7 +875,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx) ScopedValue acc(scope); ScopedValue v(scope); - if (ctx->d()->callData->argc > 1) { + if (ctx->argc() > 1) { acc = ctx->argument(1); } else { bool kPresent = false; @@ -911,7 +911,7 @@ ReturnedValue ArrayPrototype::method_reduce(CallContext *ctx) ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx) { Scope scope(ctx); - ScopedObject instance(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject instance(scope, ctx->thisObject().toObject(scope.engine)); if (!instance) return Encode::undefined(); @@ -922,7 +922,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx) return ctx->engine()->throwTypeError(); if (len == 0) { - if (ctx->d()->callData->argc == 1) + if (ctx->argc() == 1) return ctx->engine()->throwTypeError(); return ctx->argument(1); } @@ -930,7 +930,7 @@ ReturnedValue ArrayPrototype::method_reduceRight(CallContext *ctx) uint k = len; ScopedValue acc(scope); ScopedValue v(scope); - if (ctx->d()->callData->argc > 1) { + if (ctx->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 c606e37310..0287945700 100644 --- a/src/qml/jsruntime/qv4booleanobject.cpp +++ b/src/qml/jsruntime/qv4booleanobject.cpp @@ -47,8 +47,7 @@ ReturnedValue BooleanCtor::construct(Managed *m, CallData *callData) { Scope scope(static_cast<BooleanCtor *>(m)->engine()); bool n = callData->argc ? callData->args[0].toBoolean() : false; - ScopedValue b(scope, QV4::Primitive::fromBoolean(n)); - return Encode(scope.engine->newBooleanObject(b)); + return Encode(scope.engine->newBooleanObject(n)); } ReturnedValue BooleanCtor::call(Managed *, CallData *callData) @@ -71,14 +70,13 @@ void BooleanPrototype::init(ExecutionEngine *engine, Object *ctor) ReturnedValue BooleanPrototype::method_toString(CallContext *ctx) { bool result; - if (ctx->d()->callData->thisObject.isBoolean()) { - result = ctx->d()->callData->thisObject.booleanValue(); + if (ctx->thisObject().isBoolean()) { + result = ctx->thisObject().booleanValue(); } else { - Scope scope(ctx); - Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject); + BooleanObject *thisObject = ctx->thisObject().as<BooleanObject>(); if (!thisObject) return ctx->engine()->throwTypeError(); - result = thisObject->value().booleanValue(); + result = thisObject->value(); } return Encode(ctx->d()->engine->newString(QLatin1String(result ? "true" : "false"))); @@ -86,13 +84,12 @@ ReturnedValue BooleanPrototype::method_toString(CallContext *ctx) ReturnedValue BooleanPrototype::method_valueOf(CallContext *ctx) { - if (ctx->d()->callData->thisObject.isBoolean()) - return ctx->d()->callData->thisObject.asReturnedValue(); + if (ctx->thisObject().isBoolean()) + return ctx->thisObject().asReturnedValue(); - Scope scope(ctx); - Scoped<BooleanObject> thisObject(scope, ctx->d()->callData->thisObject); + BooleanObject *thisObject = ctx->thisObject().as<BooleanObject>(); if (!thisObject) return ctx->engine()->throwTypeError(); - return thisObject->value().asReturnedValue(); + return Encode(thisObject->value()); } diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp index 27d32bbcd3..8c637472a7 100644 --- a/src/qml/jsruntime/qv4context.cpp +++ b/src/qml/jsruntime/qv4context.cpp @@ -246,7 +246,7 @@ bool ExecutionContext::deleteProperty(String *name) bool CallContext::needsOwnArguments() const { - return d()->function->needsActivation() || d()->callData->argc < static_cast<int>(d()->function->formalParameterCount()); + return d()->function->needsActivation() || argc() < static_cast<int>(d()->function->formalParameterCount()); } void ExecutionContext::markObjects(Heap::Base *m, ExecutionEngine *engine) @@ -346,7 +346,7 @@ ReturnedValue ExecutionContext::getProperty(String *name) name->makeIdentifier(scope.engine); if (name->equals(d()->engine->id_this)) - return d()->callData->thisObject.asReturnedValue(); + return thisObject().asReturnedValue(); bool hasWith = false; bool hasCatchScope = false; @@ -413,7 +413,7 @@ ReturnedValue ExecutionContext::getPropertyAndBase(String *name, Heap::Object ** name->makeIdentifier(scope.engine); if (name->equals(d()->engine->id_this)) - return d()->callData->thisObject.asReturnedValue(); + return thisObject().asReturnedValue(); bool hasWith = false; bool hasCatchScope = false; diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h index 4d27b0456c..1431c5ac82 100644 --- a/src/qml/jsruntime/qv4context_p.h +++ b/src/qml/jsruntime/qv4context_p.h @@ -162,6 +162,19 @@ struct Q_QML_EXPORT ExecutionContext : public Managed Heap::FunctionObject *getFunctionObject() const; static void markObjects(Heap::Base *m, ExecutionEngine *e); + + const Value &thisObject() const { + return d()->callData->thisObject; + } + int argc() const { + return d()->callData->argc; + } + const Value *args() const { + return d()->callData->args; + } + ReturnedValue argument(int i) const { + return d()->callData->argument(i); + } }; struct CallContext : public ExecutionContext @@ -179,7 +192,7 @@ struct CallContext : public ExecutionContext }; inline ReturnedValue CallContext::argument(int i) { - return i < d()->callData->argc ? d()->callData->args[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); + return i < argc() ? args()[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue(); } struct GlobalContext : public ExecutionContext diff --git a/src/qml/jsruntime/qv4dataview.cpp b/src/qml/jsruntime/qv4dataview.cpp index 55a41a7c6c..09d4db59af 100644 --- a/src/qml/jsruntime/qv4dataview.cpp +++ b/src/qml/jsruntime/qv4dataview.cpp @@ -123,7 +123,7 @@ void DataViewPrototype::init(ExecutionEngine *engine, Object *ctor) ReturnedValue DataViewPrototype::method_get_buffer(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); + Scoped<DataView> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -133,7 +133,7 @@ ReturnedValue DataViewPrototype::method_get_buffer(CallContext *ctx) ReturnedValue DataViewPrototype::method_get_byteLength(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); + Scoped<DataView> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -143,7 +143,7 @@ ReturnedValue DataViewPrototype::method_get_byteLength(CallContext *ctx) ReturnedValue DataViewPrototype::method_get_byteOffset(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); + Scoped<DataView> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -154,10 +154,10 @@ template <typename T> ReturnedValue DataViewPrototype::method_getChar(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); - if (!v || ctx->d()->callData->argc < 1) + Scoped<DataView> v(scope, ctx->thisObject()); + if (!v || ctx->argc() < 1) return scope.engine->throwTypeError(); - double l = ctx->d()->callData->args[0].toNumber(); + double l = ctx->args()[0].toNumber(); uint idx = (uint)l; if (l != idx || idx + sizeof(T) > v->d()->byteLength) return scope.engine->throwTypeError(); @@ -172,16 +172,16 @@ template <typename T> ReturnedValue DataViewPrototype::method_get(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); - if (!v || ctx->d()->callData->argc < 1) + Scoped<DataView> v(scope, ctx->thisObject()); + if (!v || ctx->argc() < 1) return scope.engine->throwTypeError(); - double l = ctx->d()->callData->args[0].toNumber(); + double l = ctx->args()[0].toNumber(); uint idx = (uint)l; if (l != idx || idx + sizeof(T) > v->d()->byteLength) return scope.engine->throwTypeError(); idx += v->d()->byteOffset; - bool littleEndian = ctx->d()->callData->argc < 2 ? false : ctx->d()->callData->args[1].toBoolean(); + bool littleEndian = ctx->argc() < 2 ? false : ctx->args()[1].toBoolean(); T t = littleEndian ? qFromLittleEndian<T>((uchar *)v->d()->buffer->data->data() + idx) @@ -194,16 +194,16 @@ template <typename T> ReturnedValue DataViewPrototype::method_getFloat(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); - if (!v || ctx->d()->callData->argc < 1) + Scoped<DataView> v(scope, ctx->thisObject()); + if (!v || ctx->argc() < 1) return scope.engine->throwTypeError(); - double l = ctx->d()->callData->args[0].toNumber(); + double l = ctx->args()[0].toNumber(); uint idx = (uint)l; if (l != idx || idx + sizeof(T) > v->d()->byteLength) return scope.engine->throwTypeError(); idx += v->d()->byteOffset; - bool littleEndian = ctx->d()->callData->argc < 2 ? false : ctx->d()->callData->args[1].toBoolean(); + bool littleEndian = ctx->argc() < 2 ? false : ctx->args()[1].toBoolean(); if (sizeof(T) == 4) { // float @@ -232,16 +232,16 @@ template <typename T> ReturnedValue DataViewPrototype::method_setChar(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); - if (!v || ctx->d()->callData->argc < 1) + Scoped<DataView> v(scope, ctx->thisObject()); + if (!v || ctx->argc() < 1) return scope.engine->throwTypeError(); - double l = ctx->d()->callData->args[0].toNumber(); + double l = ctx->args()[0].toNumber(); uint idx = (uint)l; if (l != idx || idx + sizeof(T) > v->d()->byteLength) return scope.engine->throwTypeError(); idx += v->d()->byteOffset; - int val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInt32() : 0; + int val = ctx->argc() >= 2 ? ctx->args()[1].toInt32() : 0; v->d()->buffer->data->data()[idx] = (char)val; return Encode::undefined(); @@ -251,18 +251,18 @@ template <typename T> ReturnedValue DataViewPrototype::method_set(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); - if (!v || ctx->d()->callData->argc < 1) + Scoped<DataView> v(scope, ctx->thisObject()); + if (!v || ctx->argc() < 1) return scope.engine->throwTypeError(); - double l = ctx->d()->callData->args[0].toNumber(); + double l = ctx->args()[0].toNumber(); uint idx = (uint)l; if (l != idx || idx + sizeof(T) > v->d()->byteLength) return scope.engine->throwTypeError(); idx += v->d()->byteOffset; - int val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInt32() : 0; + int val = ctx->argc() >= 2 ? ctx->args()[1].toInt32() : 0; - bool littleEndian = ctx->d()->callData->argc < 3 ? false : ctx->d()->callData->args[2].toBoolean(); + bool littleEndian = ctx->argc() < 3 ? false : ctx->args()[2].toBoolean(); if (littleEndian) qToLittleEndian<T>(val, (uchar *)v->d()->buffer->data->data() + idx); @@ -276,17 +276,17 @@ template <typename T> ReturnedValue DataViewPrototype::method_setFloat(CallContext *ctx) { Scope scope(ctx); - Scoped<DataView> v(scope, ctx->d()->callData->thisObject); - if (!v || ctx->d()->callData->argc < 1) + Scoped<DataView> v(scope, ctx->thisObject()); + if (!v || ctx->argc() < 1) return scope.engine->throwTypeError(); - double l = ctx->d()->callData->args[0].toNumber(); + double l = ctx->args()[0].toNumber(); uint idx = (uint)l; if (l != idx || idx + sizeof(T) > v->d()->byteLength) return scope.engine->throwTypeError(); idx += v->d()->byteOffset; - double val = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toNumber() : qSNaN(); - bool littleEndian = ctx->d()->callData->argc < 3 ? false : ctx->d()->callData->args[2].toBoolean(); + double val = ctx->argc() >= 2 ? ctx->args()[1].toNumber() : qSNaN(); + bool littleEndian = ctx->argc() < 3 ? false : ctx->args()[2].toBoolean(); if (sizeof(T) == 4) { // float diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 423c36963f..d11118ee88 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -755,7 +755,7 @@ void DatePrototype::init(ExecutionEngine *engine, Object *ctor) double DatePrototype::getThisDate(ExecutionContext *ctx) { - if (DateObject *thisObject = ctx->d()->callData->thisObject.asDateObject()) + if (DateObject *thisObject = ctx->thisObject().asDateObject()) return thisObject->date().asDouble(); else { ctx->engine()->throwTypeError(); @@ -765,22 +765,22 @@ double DatePrototype::getThisDate(ExecutionContext *ctx) ReturnedValue DatePrototype::method_parse(CallContext *ctx) { - if (!ctx->d()->callData->argc) + if (!ctx->argc()) return Encode(qSNaN()); - return Encode(ParseString(ctx->d()->callData->args[0].toQString())); + return Encode(ParseString(ctx->args()[0].toQString())); } ReturnedValue DatePrototype::method_UTC(CallContext *ctx) { - const int numArgs = ctx->d()->callData->argc; + const int numArgs = ctx->argc(); if (numArgs >= 2) { - 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; + double year = ctx->args()[0].toNumber(); + double month = ctx->args()[1].toNumber(); + double day = numArgs >= 3 ? ctx->args()[2].toNumber() : 1; + double hours = numArgs >= 4 ? ctx->args()[3].toNumber() : 0; + double mins = numArgs >= 5 ? ctx->args()[4].toNumber() : 0; + double secs = numArgs >= 6 ? ctx->args()[5].toNumber() : 0; + double ms = numArgs >= 7 ? ctx->args()[6].toNumber() : 0; if (year >= 0 && year <= 99) year += 1900; double t = MakeDate(MakeDay(year, month, day), @@ -992,11 +992,11 @@ ReturnedValue DatePrototype::method_getTimezoneOffset(CallContext *ctx) ReturnedValue DatePrototype::method_setTime(CallContext *ctx) { Scope scope(ctx); - Scoped<DateObject> self(scope, ctx->d()->callData->thisObject); + Scoped<DateObject> self(scope, ctx->thisObject()); if (!self) return ctx->engine()->throwTypeError(); - double t = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double t = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); self->date().setDouble(TimeClip(t)); return self->date().asReturnedValue(); } @@ -1004,37 +1004,37 @@ ReturnedValue DatePrototype::method_setTime(CallContext *ctx) ReturnedValue DatePrototype::method_setMilliseconds(CallContext *ctx) { Scope scope(ctx); - Scoped<DateObject> self(scope, ctx->d()->callData->thisObject); + Scoped<DateObject> self(scope, ctx->thisObject()); if (!self) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double ms = ctx->argc() ? ctx->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->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); - double ms = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double ms = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); self->date().setDouble(TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), SecFromTime(t), ms)))); return self->date().asReturnedValue(); } ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date().asDouble()); - 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(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1042,13 +1042,13 @@ ReturnedValue DatePrototype::method_setSeconds(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); - 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(); + double sec = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double ms = (ctx->argc() < 2) ? msFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), MinFromTime(t), sec, ms))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1056,14 +1056,14 @@ ReturnedValue DatePrototype::method_setUTCSeconds(CallContext *ctx) ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date().asDouble()); - 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(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); + double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1071,14 +1071,14 @@ ReturnedValue DatePrototype::method_setMinutes(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); - 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(); + double min = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double sec = (ctx->argc() < 2) ? SecFromTime(t) : ctx->args()[1].toNumber(); + double ms = (ctx->argc() < 3) ? msFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(HourFromTime(t), min, sec, ms))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1086,15 +1086,15 @@ ReturnedValue DatePrototype::method_setUTCMinutes(CallContext *ctx) ReturnedValue DatePrototype::method_setHours(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date().asDouble()); - 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(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); + double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); + double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); t = TimeClip(UTC(MakeDate(Day(t), MakeTime(hour, min, sec, ms)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1102,15 +1102,15 @@ ReturnedValue DatePrototype::method_setHours(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); - 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(); + double hour = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double min = (ctx->argc() < 2) ? MinFromTime(t) : ctx->args()[1].toNumber(); + double sec = (ctx->argc() < 3) ? SecFromTime(t) : ctx->args()[2].toNumber(); + double ms = (ctx->argc() < 4) ? msFromTime(t) : ctx->args()[3].toNumber(); t = TimeClip(MakeDate(Day(t), MakeTime(hour, min, sec, ms))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1118,12 +1118,12 @@ ReturnedValue DatePrototype::method_setUTCHours(CallContext *ctx) ReturnedValue DatePrototype::method_setDate(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date().asDouble()); - double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1131,12 +1131,12 @@ ReturnedValue DatePrototype::method_setDate(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); - double date = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double date = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), MonthFromTime(t), date), TimeWithinDay(t))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1144,13 +1144,13 @@ ReturnedValue DatePrototype::method_setUTCDate(CallContext *ctx) ReturnedValue DatePrototype::method_setMonth(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date().asDouble()); - 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(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1158,13 +1158,13 @@ ReturnedValue DatePrototype::method_setMonth(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); - 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(); + double month = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double date = (ctx->argc() < 2) ? DateFromTime(t) : ctx->args()[1].toNumber(); t = TimeClip(MakeDate(MakeDay(YearFromTime(t), month, date), TimeWithinDay(t))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1172,7 +1172,7 @@ ReturnedValue DatePrototype::method_setUTCMonth(CallContext *ctx) ReturnedValue DatePrototype::method_setYear(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); @@ -1181,7 +1181,7 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx) t = 0; else t = LocalTime(t); - double year = ctx->d()->callData->argc ? ctx->d()->callData->args[0].toNumber() : qSNaN(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); double r; if (std::isnan(year)) { r = qSNaN(); @@ -1198,14 +1198,14 @@ ReturnedValue DatePrototype::method_setYear(CallContext *ctx) ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); - 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(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); + double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(MakeDate(MakeDay(year, month, date), TimeWithinDay(t))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1213,16 +1213,16 @@ ReturnedValue DatePrototype::method_setUTCFullYear(CallContext *ctx) ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = LocalTime(self->date().asDouble()); if (std::isnan(t)) t = 0; - 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(); + double year = ctx->argc() ? ctx->args()[0].toNumber() : qSNaN(); + double month = (ctx->argc() < 2) ? MonthFromTime(t) : ctx->args()[1].toNumber(); + double date = (ctx->argc() < 3) ? DateFromTime(t) : ctx->args()[2].toNumber(); t = TimeClip(UTC(MakeDate(MakeDay(year, month, date), TimeWithinDay(t)))); self->date().setDouble(t); return self->date().asReturnedValue(); @@ -1230,7 +1230,7 @@ ReturnedValue DatePrototype::method_setFullYear(CallContext *ctx) ReturnedValue DatePrototype::method_toUTCString(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); @@ -1253,13 +1253,13 @@ static void addZeroPrefixedInt(QString &str, int num, int nDigits) ReturnedValue DatePrototype::method_toISOString(CallContext *ctx) { - DateObject *self = ctx->d()->callData->thisObject.asDateObject(); + DateObject *self = ctx->thisObject().asDateObject(); if (!self) return ctx->engine()->throwTypeError(); double t = self->date().asDouble(); if (!std::isfinite(t)) - return ctx->engine()->throwRangeError(ctx->d()->callData->thisObject); + return ctx->engine()->throwRangeError(ctx->thisObject()); QString result; int year = (int)YearFromTime(t); @@ -1292,7 +1292,7 @@ ReturnedValue DatePrototype::method_toISOString(CallContext *ctx) ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) { Scope scope(ctx); - ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->d()->callData->thisObject)); + ScopedValue O(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject())); ScopedValue tv(scope, RuntimeHelpers::toPrimitive(O, NUMBER_HINT)); if (tv->isNumber() && !std::isfinite(tv->toNumber())) @@ -1306,7 +1306,7 @@ ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) return ctx->engine()->throwTypeError(); ScopedCallData callData(scope); - callData->thisObject = ctx->d()->callData->thisObject; + callData->thisObject = ctx->thisObject(); return toIso->call(callData); } diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 49d77863df..9579f3ddb1 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -547,10 +547,10 @@ Heap::Object *ExecutionEngine::newNumberObject(const Value &value) return object->d(); } -Heap::Object *ExecutionEngine::newBooleanObject(const Value &value) +Heap::Object *ExecutionEngine::newBooleanObject(bool b) { Scope scope(this); - ScopedObject object(scope, memoryManager->alloc<BooleanObject>(this, value)); + ScopedObject object(scope, memoryManager->alloc<BooleanObject>(this, b)); return object->d(); } diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index e482aeffa9..124f4e8e24 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -262,7 +262,7 @@ public: Heap::Object *newStringObject(const Value &value); Heap::Object *newNumberObject(const Value &value); - Heap::Object *newBooleanObject(const Value &value); + Heap::Object *newBooleanObject(bool b); Heap::ArrayObject *newArrayObject(int count = 0); Heap::ArrayObject *newArrayObject(const QStringList &list); diff --git a/src/qml/jsruntime/qv4errorobject.cpp b/src/qml/jsruntime/qv4errorobject.cpp index bdbec790ca..09aa41db61 100644 --- a/src/qml/jsruntime/qv4errorobject.cpp +++ b/src/qml/jsruntime/qv4errorobject.cpp @@ -148,7 +148,7 @@ Heap::ErrorObject::ErrorObject(InternalClass *ic, QV4::Object *prototype, const ReturnedValue ErrorObject::method_get_stack(CallContext *ctx) { Scope scope(ctx); - Scoped<ErrorObject> This(scope, ctx->d()->callData->thisObject); + Scoped<ErrorObject> This(scope, ctx->thisObject()); if (!This) return ctx->engine()->throwTypeError(); if (!This->d()->stack) { @@ -355,7 +355,7 @@ ReturnedValue ErrorPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - Object *o = ctx->d()->callData->thisObject.asObject(); + Object *o = ctx->thisObject().asObject(); if (!o) return ctx->engine()->throwTypeError(); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 1ead3b747f..63efb4f9f6 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -300,7 +300,7 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor) ReturnedValue FunctionPrototype::method_toString(CallContext *ctx) { - FunctionObject *fun = ctx->d()->callData->thisObject.asFunctionObject(); + FunctionObject *fun = ctx->thisObject().asFunctionObject(); if (!fun) return ctx->engine()->throwTypeError(); @@ -310,7 +310,7 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx) ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) { Scope scope(ctx); - ScopedFunctionObject o(scope, ctx->d()->callData->thisObject.asFunctionObject()); + ScopedFunctionObject o(scope, ctx->thisObject().asFunctionObject()); if (!o) return ctx->engine()->throwTypeError(); @@ -352,14 +352,14 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx) { Scope scope(ctx); - ScopedFunctionObject o(scope, ctx->d()->callData->thisObject.asFunctionObject()); + ScopedFunctionObject o(scope, ctx->thisObject().asFunctionObject()); if (!o) return ctx->engine()->throwTypeError(); - 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]; + ScopedCallData callData(scope, ctx->argc() ? ctx->argc() - 1 : 0); + if (ctx->argc()) { + for (int i = 1; i < ctx->argc(); ++i) + callData->args[i - 1] = ctx->args()[i]; } callData->thisObject = ctx->argument(0); return o->call(callData); @@ -368,16 +368,16 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx) ReturnedValue FunctionPrototype::method_bind(CallContext *ctx) { Scope scope(ctx); - ScopedFunctionObject target(scope, ctx->d()->callData->thisObject); + ScopedFunctionObject target(scope, ctx->thisObject()); if (!target) return ctx->engine()->throwTypeError(); ScopedValue boundThis(scope, ctx->argument(0)); Scoped<MemberData> boundArgs(scope, (Heap::MemberData *)0); - if (ctx->d()->callData->argc > 1) { - boundArgs = MemberData::reallocate(scope.engine, 0, ctx->d()->callData->argc - 1); - boundArgs->d()->size = ctx->d()->callData->argc - 1; - memcpy(boundArgs->data(), ctx->d()->callData->args + 1, (ctx->d()->callData->argc - 1)*sizeof(Value)); + if (ctx->argc() > 1) { + boundArgs = MemberData::reallocate(scope.engine, 0, ctx->argc() - 1); + boundArgs->d()->size = ctx->argc() - 1; + memcpy(boundArgs->data(), ctx->args() + 1, (ctx->argc() - 1)*sizeof(Value)); } ScopedContext global(scope, scope.engine->rootContext()); diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index 823eeda76d..b5b09afc36 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -385,7 +385,7 @@ ReturnedValue EvalFunction::evalCall(CallData *callData, bool directCall) if (function->isStrict() || (ctx->d()->strictMode)) { ScopedFunctionObject e(scope, FunctionObject::createScriptFunction(ctx, function)); ScopedCallData callData(scope, 0); - callData->thisObject = ctx->d()->callData->thisObject; + callData->thisObject = ctx->thisObject(); return e->call(callData); } @@ -537,38 +537,38 @@ ReturnedValue GlobalFunctions::method_parseFloat(CallContext *ctx) /// isNaN [15.1.2.4] ReturnedValue GlobalFunctions::method_isNaN(CallContext *ctx) { - if (!ctx->d()->callData->argc) + if (!ctx->argc()) // undefined gets converted to NaN return Encode(true); - if (ctx->d()->callData->args[0].integerCompatible()) + if (ctx->args()[0].integerCompatible()) return Encode(false); - double d = ctx->d()->callData->args[0].toNumber(); + double d = ctx->args()[0].toNumber(); return Encode((bool)std::isnan(d)); } /// isFinite [15.1.2.5] ReturnedValue GlobalFunctions::method_isFinite(CallContext *ctx) { - if (!ctx->d()->callData->argc) + if (!ctx->argc()) // undefined gets converted to NaN return Encode(false); - if (ctx->d()->callData->args[0].integerCompatible()) + if (ctx->args()[0].integerCompatible()) return Encode(true); - double d = ctx->d()->callData->args[0].toNumber(); + double d = ctx->args()[0].toNumber(); return Encode((bool)std::isfinite(d)); } /// decodeURI [15.1.3.1] ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context) { - if (context->d()->callData->argc == 0) + if (context->argc() == 0) return Encode::undefined(); - QString uriString = context->d()->callData->args[0].toQString(); + QString uriString = context->args()[0].toQString(); bool ok; QString out = decode(uriString, DecodeNonReserved, &ok); if (!ok) { @@ -583,10 +583,10 @@ ReturnedValue GlobalFunctions::method_decodeURI(CallContext *context) /// decodeURIComponent [15.1.3.2] ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context) { - if (context->d()->callData->argc == 0) + if (context->argc() == 0) return Encode::undefined(); - QString uriString = context->d()->callData->args[0].toQString(); + QString uriString = context->args()[0].toQString(); bool ok; QString out = decode(uriString, DecodeAll, &ok); if (!ok) { @@ -601,10 +601,10 @@ ReturnedValue GlobalFunctions::method_decodeURIComponent(CallContext *context) /// encodeURI [15.1.3.3] ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context) { - if (context->d()->callData->argc == 0) + if (context->argc() == 0) return Encode::undefined(); - QString uriString = context->d()->callData->args[0].toQString(); + QString uriString = context->args()[0].toQString(); bool ok; QString out = encode(uriString, uriUnescapedReserved, &ok); if (!ok) { @@ -619,10 +619,10 @@ ReturnedValue GlobalFunctions::method_encodeURI(CallContext *context) /// encodeURIComponent [15.1.3.4] ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context) { - if (context->d()->callData->argc == 0) + if (context->argc() == 0) return Encode::undefined(); - QString uriString = context->d()->callData->args[0].toQString(); + QString uriString = context->args()[0].toQString(); bool ok; QString out = encode(uriString, uriUnescaped, &ok); if (!ok) { @@ -636,18 +636,18 @@ ReturnedValue GlobalFunctions::method_encodeURIComponent(CallContext *context) ReturnedValue GlobalFunctions::method_escape(CallContext *context) { - if (!context->d()->callData->argc) + if (!context->argc()) return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); - QString str = context->d()->callData->args[0].toQString(); + QString str = context->args()[0].toQString(); return context->d()->engine->newString(escape(str))->asReturnedValue(); } ReturnedValue GlobalFunctions::method_unescape(CallContext *context) { - if (!context->d()->callData->argc) + if (!context->argc()) return context->d()->engine->newString(QStringLiteral("undefined"))->asReturnedValue(); - QString str = context->d()->callData->args[0].toQString(); + QString str = context->args()[0].toQString(); return context->d()->engine->newString(unescape(str))->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 814e6fbfe8..b74728da20 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -172,7 +172,7 @@ void QV4Include::finished() */ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) { - if (!ctx->d()->callData->argc) + if (!ctx->argc()) return QV4::Encode::undefined(); QV4::Scope scope(ctx->engine()); @@ -181,11 +181,11 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) if (!context || !context->isJSContext) V4THROW_ERROR("Qt.include(): Can only be called from JavaScript files"); - QUrl url(scope.engine->resolvedUrl(ctx->d()->callData->args[0].toQStringNoThrow())); + QUrl url(scope.engine->resolvedUrl(ctx->args()[0].toQStringNoThrow())); QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue()); - if (ctx->d()->callData->argc >= 2 && ctx->d()->callData->args[1].asFunctionObject()) - callbackFunction = ctx->d()->callData->args[1]; + if (ctx->argc() >= 2 && ctx->args()[1].asFunctionObject()) + callbackFunction = ctx->args()[1]; QString localFile = QQmlFile::urlToLocalFileOrQrc(url); diff --git a/src/qml/jsruntime/qv4mathobject.cpp b/src/qml/jsruntime/qv4mathobject.cpp index b0b50499d5..88097b212a 100644 --- a/src/qml/jsruntime/qv4mathobject.cpp +++ b/src/qml/jsruntime/qv4mathobject.cpp @@ -96,15 +96,15 @@ static double copySign(double x, double y) ReturnedValue MathObject::method_abs(CallContext *context) { - if (!context->d()->callData->argc) + if (!context->argc()) return Encode(qSNaN()); - if (context->d()->callData->args[0].isInteger()) { - int i = context->d()->callData->args[0].integerValue(); + if (context->args()[0].isInteger()) { + int i = context->args()[0].integerValue(); return Encode(i < 0 ? - i : i); } - double v = context->d()->callData->args[0].toNumber(); + double v = context->args()[0].toNumber(); if (v == 0) // 0 | -0 return Encode(0); @@ -113,7 +113,7 @@ ReturnedValue MathObject::method_abs(CallContext *context) ReturnedValue MathObject::method_acos(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2; + double v = context->argc() ? context->args()[0].toNumber() : 2; if (v > 1) return Encode(qSNaN()); @@ -122,7 +122,7 @@ ReturnedValue MathObject::method_acos(CallContext *context) ReturnedValue MathObject::method_asin(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : 2; + double v = context->argc() ? context->args()[0].toNumber() : 2; if (v > 1) return Encode(qSNaN()); else @@ -131,7 +131,7 @@ ReturnedValue MathObject::method_asin(CallContext *context) ReturnedValue MathObject::method_atan(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); if (v == 0.0) return Encode(v); else @@ -140,8 +140,8 @@ ReturnedValue MathObject::method_atan(CallContext *context) ReturnedValue MathObject::method_atan2(CallContext *context) { - 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(); + double v1 = context->argc() ? context->args()[0].toNumber() : qSNaN(); + double v2 = context->argc() > 1 ? context->args()[1].toNumber() : qSNaN(); if ((v1 < 0) && qIsFinite(v1) && qIsInf(v2) && (copySign(1.0, v2) == 1.0)) return Encode(copySign(0, -1.0)); @@ -158,7 +158,7 @@ ReturnedValue MathObject::method_atan2(CallContext *context) ReturnedValue MathObject::method_ceil(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); if (v < 0.0 && v > -1.0) return Encode(copySign(0, -1.0)); else @@ -167,13 +167,13 @@ ReturnedValue MathObject::method_ceil(CallContext *context) ReturnedValue MathObject::method_cos(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); return Encode(::cos(v)); } ReturnedValue MathObject::method_exp(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); if (qIsInf(v)) { if (copySign(1.0, v) == -1.0) return Encode(0); @@ -186,13 +186,13 @@ ReturnedValue MathObject::method_exp(CallContext *context) ReturnedValue MathObject::method_floor(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); return Encode(::floor(v)); } ReturnedValue MathObject::method_log(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); if (v < 0) return Encode(qSNaN()); else @@ -202,8 +202,8 @@ ReturnedValue MathObject::method_log(CallContext *context) ReturnedValue MathObject::method_max(CallContext *context) { double mx = -qInf(); - for (int i = 0; i < context->d()->callData->argc; ++i) { - double x = context->d()->callData->args[i].toNumber(); + for (int i = 0; i < context->argc(); ++i) { + double x = context->args()[i].toNumber(); if (x > mx || std::isnan(x)) mx = x; } @@ -213,8 +213,8 @@ ReturnedValue MathObject::method_max(CallContext *context) ReturnedValue MathObject::method_min(CallContext *context) { double mx = qInf(); - for (int i = 0; i < context->d()->callData->argc; ++i) { - double x = context->d()->callData->args[i].toNumber(); + for (int i = 0; i < context->argc(); ++i) { + double x = context->args()[i].toNumber(); if ((x == 0 && mx == x && copySign(1.0, x) == -1.0) || (x < mx) || std::isnan(x)) { mx = x; @@ -225,8 +225,8 @@ ReturnedValue MathObject::method_min(CallContext *context) ReturnedValue MathObject::method_pow(CallContext *context) { - 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(); + double x = context->argc() > 0 ? context->args()[0].toNumber() : qSNaN(); + double y = context->argc() > 1 ? context->args()[1].toNumber() : qSNaN(); if (std::isnan(y)) return Encode(qSNaN()); @@ -286,26 +286,26 @@ ReturnedValue MathObject::method_random(CallContext *context) ReturnedValue MathObject::method_round(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); v = copySign(::floor(v + 0.5), v); return Encode(v); } ReturnedValue MathObject::method_sin(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); return Encode(::sin(v)); } ReturnedValue MathObject::method_sqrt(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->args()[0].toNumber() : qSNaN(); return Encode(::sqrt(v)); } ReturnedValue MathObject::method_tan(CallContext *context) { - double v = context->d()->callData->argc ? context->d()->callData->args[0].toNumber() : qSNaN(); + double v = context->argc() ? context->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 dcde8f13f3..bbe6bb977c 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -52,7 +52,7 @@ Heap::NumberCtor::NumberCtor(QV4::ExecutionContext *scope) ReturnedValue NumberCtor::construct(Managed *m, CallData *callData) { - Scope scope(static_cast<NumberCtor *>(m)->engine()); + Scope scope(m->cast<NumberCtor>()->engine()); double dbl = callData->argc ? callData->args[0].toNumber() : 0.; ScopedValue d(scope, QV4::Primitive::fromDouble(dbl)); return Encode(scope.engine->newNumberObject(d)); @@ -96,9 +96,9 @@ void NumberPrototype::init(ExecutionEngine *engine, Object *ctor) inline ReturnedValue thisNumberValue(ExecutionContext *ctx) { - if (ctx->d()->callData->thisObject.isNumber()) - return ctx->d()->callData->thisObject.asReturnedValue(); - NumberObject *n = ctx->d()->callData->thisObject.asNumberObject(); + if (ctx->thisObject().isNumber()) + return ctx->thisObject().asReturnedValue(); + NumberObject *n = ctx->thisObject().asNumberObject(); if (!n) return ctx->engine()->throwTypeError(); return n->value().asReturnedValue(); @@ -106,9 +106,9 @@ inline ReturnedValue thisNumberValue(ExecutionContext *ctx) inline double thisNumber(ExecutionContext *ctx) { - if (ctx->d()->callData->thisObject.isNumber()) - return ctx->d()->callData->thisObject.asDouble(); - NumberObject *n = ctx->d()->callData->thisObject.asNumberObject(); + if (ctx->thisObject().isNumber()) + return ctx->thisObject().asDouble(); + NumberObject *n = ctx->thisObject().asNumberObject(); if (!n) return ctx->engine()->throwTypeError(); return n->value().asDouble(); @@ -121,8 +121,8 @@ ReturnedValue NumberPrototype::method_toString(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) { - int radix = ctx->d()->callData->args[0].toInt32(); + if (ctx->argc() && !ctx->args()[0].isUndefined()) { + int radix = ctx->args()[0].toInt32(); if (radix < 2 || radix > 36) return ctx->engine()->throwError(QString::fromLatin1("Number.prototype.toString: %0 is not a valid radix") .arg(radix)); @@ -191,14 +191,14 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) double fdigits = 0; - if (ctx->d()->callData->argc > 0) - fdigits = ctx->d()->callData->args[0].toInteger(); + if (ctx->argc() > 0) + fdigits = ctx->args()[0].toInteger(); if (std::isnan(fdigits)) fdigits = 0; if (fdigits < 0 || fdigits > 20) - return ctx->engine()->throwRangeError(ctx->d()->callData->thisObject); + return ctx->engine()->throwRangeError(ctx->thisObject()); QString str; if (std::isnan(v)) @@ -221,8 +221,8 @@ ReturnedValue NumberPrototype::method_toExponential(CallContext *ctx) int fdigits = -1; - if (ctx->d()->callData->argc && !ctx->d()->callData->args[0].isUndefined()) { - fdigits = ctx->d()->callData->args[0].toInt32(); + if (ctx->argc() && !ctx->args()[0].isUndefined()) { + fdigits = ctx->args()[0].toInt32(); if (fdigits < 0 || fdigits > 20) { ScopedString error(scope, scope.engine->newString(QStringLiteral("Number.prototype.toExponential: fractionDigits out of range"))); return ctx->engine()->throwRangeError(error); @@ -244,10 +244,10 @@ ReturnedValue NumberPrototype::method_toPrecision(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - if (!ctx->d()->callData->argc || ctx->d()->callData->args[0].isUndefined()) + if (!ctx->argc() || ctx->args()[0].isUndefined()) return RuntimeHelpers::toString(scope.engine, v); - double precision = ctx->d()->callData->args[0].toInt32(); + double precision = ctx->args()[0].toInt32(); if (precision < 1 || precision > 21) { ScopedString error(scope, scope.engine->newString(QStringLiteral("Number.prototype.toPrecision: precision out of range"))); return ctx->engine()->throwRangeError(error); diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h index 1c36f179b2..4e88cd785e 100644 --- a/src/qml/jsruntime/qv4object_p.h +++ b/src/qml/jsruntime/qv4object_p.h @@ -220,7 +220,7 @@ public: bool arrayPut(uint index, const Value &value) { return arrayData()->vtable()->put(this, index, value); } - bool arrayPut(uint index, Value *values, uint n) { + bool arrayPut(uint index, const Value *values, uint n) { return arrayData()->vtable()->putArray(this, index, values, n); } void setArrayAttributes(uint i, PropertyAttributes a) { @@ -333,17 +333,17 @@ namespace Heap { struct BooleanObject : Object { BooleanObject(InternalClass *ic, QV4::Object *prototype) - : Object(ic, prototype) + : Object(ic, prototype), + b(false) { - value = Encode((bool)false); } - BooleanObject(ExecutionEngine *engine, const Value &val) - : Object(engine->emptyClass, engine->booleanPrototype.asObject()) + BooleanObject(ExecutionEngine *engine, bool b) + : Object(engine->emptyClass, engine->booleanPrototype.asObject()), + b(b) { - value = val; } - Value value; + bool b; }; struct NumberObject : Object { @@ -383,7 +383,7 @@ struct BooleanObject: Object { V4_OBJECT2(BooleanObject, Object) Q_MANAGED_TYPE(BooleanObject) - Value value() const { return d()->value; } + bool value() const { return d()->b; } }; diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 289421e867..dce3c8124b 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -153,7 +153,7 @@ ReturnedValue ObjectPrototype::method_getOwnPropertyNames(CallContext *context) if (!O) return context->engine()->throwTypeError(); - ScopedArrayObject array(scope, getOwnPropertyNames(context->d()->engine, context->d()->callData->args[0])); + ScopedArrayObject array(scope, getOwnPropertyNames(context->d()->engine, context->args()[0])); return array.asReturnedValue(); } @@ -167,7 +167,7 @@ ReturnedValue ObjectPrototype::method_create(CallContext *ctx) ScopedObject newObject(scope, ctx->d()->engine->newObject()); newObject->setPrototype(O->asObject()); - if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isUndefined()) { + if (ctx->argc() > 1 && !ctx->args()[1].isUndefined()) { ctx->d()->callData->args[0] = newObject.asReturnedValue(); return method_defineProperties(ctx); } @@ -385,12 +385,12 @@ ReturnedValue ObjectPrototype::method_keys(CallContext *ctx) ReturnedValue ObjectPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - if (ctx->d()->callData->thisObject.isUndefined()) { + if (ctx->thisObject().isUndefined()) { return ctx->d()->engine->newString(QStringLiteral("[object Undefined]"))->asReturnedValue(); - } else if (ctx->d()->callData->thisObject.isNull()) { + } else if (ctx->thisObject().isNull()) { return ctx->d()->engine->newString(QStringLiteral("[object Null]"))->asReturnedValue(); } else { - ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ctx->d()->callData->thisObject)); + ScopedObject obj(scope, RuntimeHelpers::toObject(scope.engine, ctx->thisObject())); QString className = obj->className(); return ctx->d()->engine->newString(QString::fromLatin1("[object %1]").arg(className))->asReturnedValue(); } @@ -399,7 +399,7 @@ ReturnedValue ObjectPrototype::method_toString(CallContext *ctx) ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedObject o(scope, ctx->thisObject().toObject(scope.engine)); if (!o) return Encode::undefined(); ScopedFunctionObject f(scope, o->get(ctx->d()->engine->id_toString)); @@ -413,7 +413,7 @@ ReturnedValue ObjectPrototype::method_toLocaleString(CallContext *ctx) ReturnedValue ObjectPrototype::method_valueOf(CallContext *ctx) { Scope scope(ctx); - ScopedValue v(scope, ctx->d()->callData->thisObject.toObject(scope.engine)); + ScopedValue v(scope, ctx->thisObject().toObject(scope.engine)); if (ctx->d()->engine->hasException) return Encode::undefined(); return v->asReturnedValue(); @@ -425,7 +425,7 @@ ReturnedValue ObjectPrototype::method_hasOwnProperty(CallContext *ctx) ScopedString P(scope, ctx->argument(0), ScopedString::Convert); if (scope.engine->hasException) return Encode::undefined(); - ScopedObject O(scope, ctx->d()->callData->thisObject, ScopedObject::Convert); + ScopedObject O(scope, ctx->thisObject(), ScopedObject::Convert); if (scope.engine->hasException) return Encode::undefined(); bool r = O->hasOwnProperty(P); @@ -441,7 +441,7 @@ ReturnedValue ObjectPrototype::method_isPrototypeOf(CallContext *ctx) if (!V) return Encode(false); - ScopedObject O(scope, ctx->d()->callData->thisObject, ScopedObject::Convert); + ScopedObject O(scope, ctx->thisObject(), ScopedObject::Convert); if (scope.engine->hasException) return Encode::undefined(); ScopedObject proto(scope, V->prototype()); @@ -460,7 +460,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - ScopedObject o(scope, ctx->d()->callData->thisObject, ScopedObject::Convert); + ScopedObject o(scope, ctx->thisObject(), ScopedObject::Convert); if (scope.engine->hasException) return Encode::undefined(); PropertyAttributes attrs; @@ -470,7 +470,7 @@ ReturnedValue ObjectPrototype::method_propertyIsEnumerable(CallContext *ctx) ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) { - if (ctx->d()->callData->argc < 2) + if (ctx->argc() < 2) return ctx->engine()->throwTypeError(); Scope scope(ctx); @@ -482,9 +482,9 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - ScopedObject o(scope, ctx->d()->callData->thisObject); + ScopedObject o(scope, ctx->thisObject()); if (!o) { - if (!ctx->d()->callData->thisObject.isUndefined()) + if (!ctx->thisObject().isUndefined()) return Encode::undefined(); o = ctx->d()->engine->globalObject(); } @@ -498,7 +498,7 @@ ReturnedValue ObjectPrototype::method_defineGetter(CallContext *ctx) ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) { - if (ctx->d()->callData->argc < 2) + if (ctx->argc() < 2) return ctx->engine()->throwTypeError(); Scope scope(ctx); @@ -510,9 +510,9 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) if (scope.engine->hasException) return Encode::undefined(); - ScopedObject o(scope, ctx->d()->callData->thisObject); + ScopedObject o(scope, ctx->thisObject()); if (!o) { - if (!ctx->d()->callData->thisObject.isUndefined()) + if (!ctx->thisObject().isUndefined()) return Encode::undefined(); o = ctx->d()->engine->globalObject(); } @@ -527,7 +527,7 @@ ReturnedValue ObjectPrototype::method_defineSetter(CallContext *ctx) ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->d()->callData->thisObject.asObject()); + ScopedObject o(scope, ctx->thisObject().asObject()); if (!o) return ctx->engine()->throwTypeError(); @@ -537,16 +537,16 @@ ReturnedValue ObjectPrototype::method_get_proto(CallContext *ctx) ReturnedValue ObjectPrototype::method_set_proto(CallContext *ctx) { Scope scope(ctx); - ScopedObject o(scope, ctx->d()->callData->thisObject); - if (!o || !ctx->d()->callData->argc) + ScopedObject o(scope, ctx->thisObject()); + if (!o || !ctx->argc()) return ctx->engine()->throwTypeError(); - if (ctx->d()->callData->args[0].isNull()) { + if (ctx->args()[0].isNull()) { o->setPrototype(0); return Encode::undefined(); } - ScopedObject p(scope, ctx->d()->callData->args[0]); + ScopedObject p(scope, ctx->args()[0]); bool ok = false; if (!!p) { if (o->prototype() == p->d()) { diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index c65b7b6d55..f0c94d2d0e 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -886,10 +886,10 @@ struct QObjectSlotDispatcher : public QtPrivate::QSlotObjectBase ReturnedValue QObjectWrapper::method_connect(CallContext *ctx) { - if (ctx->d()->callData->argc == 0) + if (ctx->argc() == 0) V4THROW_ERROR("Function.prototype.connect: no arguments given"); - QPair<QObject *, int> signalInfo = extractQtSignal(ctx->d()->callData->thisObject); + QPair<QObject *, int> signalInfo = extractQtSignal(ctx->thisObject()); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; // in method range, not signal range! @@ -906,11 +906,11 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx) QV4::ScopedFunctionObject f(scope); QV4::ScopedValue thisObject (scope, QV4::Encode::undefined()); - 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 (ctx->argc() == 1) { + f = ctx->args()[0]; + } else if (ctx->argc() >= 2) { + thisObject = ctx->args()[0]; + f = ctx->args()[1]; } if (!f) @@ -937,12 +937,12 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx) ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx) { - if (ctx->d()->callData->argc == 0) + if (ctx->argc() == 0) V4THROW_ERROR("Function.prototype.disconnect: no arguments given"); QV4::Scope scope(ctx); - QPair<QObject *, int> signalInfo = extractQtSignal(ctx->d()->callData->thisObject); + QPair<QObject *, int> signalInfo = extractQtSignal(ctx->thisObject()); QObject *signalObject = signalInfo.first; int signalIndex = signalInfo.second; @@ -958,11 +958,11 @@ ReturnedValue QObjectWrapper::method_disconnect(CallContext *ctx) QV4::ScopedFunctionObject functionValue(scope); QV4::ScopedValue functionThisValue(scope, QV4::Encode::undefined()); - 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 (ctx->argc() == 1) { + functionValue = ctx->args()[0]; + } else if (ctx->argc() >= 2) { + functionThisValue = ctx->args()[0]; + functionValue = ctx->args()[1]; } if (!functionValue) diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 0736056838..c0e4f137ad 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -345,7 +345,7 @@ void RegExpPrototype::init(ExecutionEngine *engine, Object *constructor) ReturnedValue RegExpPrototype::method_exec(CallContext *ctx) { Scope scope(ctx); - Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>()); + Scoped<RegExpObject> r(scope, ctx->thisObject().as<RegExpObject>()); if (!r) return ctx->engine()->throwTypeError(); @@ -409,7 +409,7 @@ ReturnedValue RegExpPrototype::method_test(CallContext *ctx) ReturnedValue RegExpPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>()); + Scoped<RegExpObject> r(scope, ctx->thisObject().as<RegExpObject>()); if (!r) return ctx->engine()->throwTypeError(); @@ -419,12 +419,12 @@ ReturnedValue RegExpPrototype::method_toString(CallContext *ctx) ReturnedValue RegExpPrototype::method_compile(CallContext *ctx) { Scope scope(ctx); - Scoped<RegExpObject> r(scope, ctx->d()->callData->thisObject.as<RegExpObject>()); + Scoped<RegExpObject> r(scope, ctx->thisObject().as<RegExpObject>()); if (!r) return ctx->engine()->throwTypeError(); - ScopedCallData callData(scope, ctx->d()->callData->argc); - memcpy(callData->args, ctx->d()->callData->args, ctx->d()->callData->argc*sizeof(Value)); + ScopedCallData callData(scope, ctx->argc()); + memcpy(callData->args, ctx->args(), ctx->argc()*sizeof(Value)); Scoped<RegExpObject> re(scope, ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData)); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 4bbbb6f401..4167823c6b 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -435,7 +435,7 @@ Heap::Object *RuntimeHelpers::convertToObject(ExecutionEngine *engine, const Val engine->throwTypeError(); return 0; case Value::Boolean_Type: - return engine->newBooleanObject(value); + return engine->newBooleanObject(value.booleanValue()); case Value::Managed_Type: Q_ASSERT(value.isString()); return engine->newStringObject(value); diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 83fd2efa60..046f7f62b1 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -375,8 +375,8 @@ public: } QV4::Scope scope(ctx); - if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].asFunctionObject()) { - CompareFunctor cf(ctx, ctx->d()->callData->args[0]); + if (ctx->argc() == 1 && ctx->args()[0].asFunctionObject()) { + CompareFunctor cf(ctx, ctx->args()[0]); std::sort(d()->container.begin(), d()->container.end(), cf); } else { DefaultCompareFunctor cf; @@ -390,7 +390,7 @@ public: static QV4::ReturnedValue method_get_length(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >()); + QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->thisObject().as<QQmlSequence<Container> >()); if (!This) return ctx->engine()->throwTypeError(); @@ -405,11 +405,11 @@ public: static QV4::ReturnedValue method_set_length(QV4::CallContext* ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->d()->callData->thisObject.as<QQmlSequence<Container> >()); + QV4::Scoped<QQmlSequence<Container> > This(scope, ctx->thisObject().as<QQmlSequence<Container> >()); if (!This) return ctx->engine()->throwTypeError(); - quint32 newLength = ctx->d()->callData->args[0].toUInt32(); + quint32 newLength = ctx->args()[0].toUInt32(); /* Qt containers have int (rather than uint) allowable indexes. */ if (newLength > INT_MAX) { generateWarning(scope.engine, QLatin1String("Index out of range during length set")); @@ -558,11 +558,11 @@ void SequencePrototype::init() QV4::ReturnedValue SequencePrototype::method_sort(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::ScopedObject o(scope, ctx->d()->callData->thisObject); + QV4::ScopedObject o(scope, ctx->thisObject()); if (!o || !o->isListType()) return ctx->engine()->throwTypeError(); - if (ctx->d()->callData->argc >= 2) + if (ctx->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 0009fa45fa..3cd56a65d6 100644 --- a/src/qml/jsruntime/qv4sequenceobject_p.h +++ b/src/qml/jsruntime/qv4sequenceobject_p.h @@ -62,7 +62,7 @@ struct SequencePrototype : public QV4::Object static ReturnedValue method_valueOf(QV4::CallContext *ctx) { - return ctx->d()->callData->thisObject.toString(ctx->engine())->asReturnedValue(); + return ctx->thisObject().toString(ctx->engine())->asReturnedValue(); } static ReturnedValue method_sort(QV4::CallContext *ctx); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 55bc3c58db..6eb74e3a82 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -220,7 +220,7 @@ void StringPrototype::init(ExecutionEngine *engine, Object *ctor) static QString getThisString(ExecutionContext *ctx) { Scope scope(ctx); - ScopedValue t(scope, ctx->d()->callData->thisObject); + ScopedValue t(scope, ctx->thisObject()); if (t->isString()) return t->stringValue()->toQString(); if (StringObject *thisString = t->asStringObject()) @@ -234,10 +234,10 @@ static QString getThisString(ExecutionContext *ctx) ReturnedValue StringPrototype::method_toString(CallContext *context) { - if (context->d()->callData->thisObject.isString()) - return context->d()->callData->thisObject.asReturnedValue(); + if (context->thisObject().isString()) + return context->thisObject().asReturnedValue(); - StringObject *o = context->d()->callData->thisObject.asStringObject(); + StringObject *o = context->thisObject().asStringObject(); if (!o) return context->engine()->throwTypeError(); return o->d()->value.asReturnedValue(); @@ -250,8 +250,8 @@ ReturnedValue StringPrototype::method_charAt(CallContext *context) return Encode::undefined(); int pos = 0; - if (context->d()->callData->argc > 0) - pos = (int) context->d()->callData->args[0].toInteger(); + if (context->argc() > 0) + pos = (int) context->args()[0].toInteger(); QString result; if (pos >= 0 && pos < str.length()) @@ -267,8 +267,8 @@ ReturnedValue StringPrototype::method_charCodeAt(CallContext *context) return Encode::undefined(); int pos = 0; - if (context->d()->callData->argc > 0) - pos = (int) context->d()->callData->args[0].toInteger(); + if (context->argc() > 0) + pos = (int) context->args()[0].toInteger(); if (pos >= 0 && pos < str.length()) @@ -286,8 +286,8 @@ ReturnedValue StringPrototype::method_concat(CallContext *context) return Encode::undefined(); ScopedValue v(scope); - for (int i = 0; i < context->d()->callData->argc; ++i) { - v = RuntimeHelpers::toString(scope.engine, context->d()->callData->args[i]); + for (int i = 0; i < context->argc(); ++i) { + v = RuntimeHelpers::toString(scope.engine, context->args()[i]); if (scope.hasException()) return Encode::undefined(); Q_ASSERT(v->isString()); @@ -304,12 +304,12 @@ ReturnedValue StringPrototype::method_indexOf(CallContext *context) return Encode::undefined(); QString searchString; - if (context->d()->callData->argc) - searchString = context->d()->callData->args[0].toQString(); + if (context->argc()) + searchString = context->args()[0].toQString(); int pos = 0; - if (context->d()->callData->argc > 1) - pos = (int) context->d()->callData->args[1].toInteger(); + if (context->argc() > 1) + pos = (int) context->args()[1].toInteger(); int index = -1; if (! value.isEmpty()) @@ -327,8 +327,8 @@ ReturnedValue StringPrototype::method_lastIndexOf(CallContext *context) return Encode::undefined(); QString searchString; - if (context->d()->callData->argc) - searchString = context->d()->callData->args[0].toQString(); + if (context->argc()) + searchString = context->args()[0].toQString(); ScopedValue posArg(scope, context->argument(1)); double position = RuntimeHelpers::toNumber(posArg); @@ -353,20 +353,20 @@ ReturnedValue StringPrototype::method_localeCompare(CallContext *context) if (scope.engine->hasException) return Encode::undefined(); - ScopedValue v(scope, context->d()->callData->argument(0)); + ScopedValue v(scope, context->argument(0)); const QString that = v->toQString(); return Encode(QString::localeAwareCompare(value, that)); } ReturnedValue StringPrototype::method_match(CallContext *context) { - if (context->d()->callData->thisObject.isUndefined() || context->d()->callData->thisObject.isNull()) + if (context->thisObject().isUndefined() || context->thisObject().isNull()) return context->engine()->throwTypeError(); Scope scope(context); - ScopedString s(scope, context->d()->callData->thisObject.toString(scope.engine)); + ScopedString s(scope, context->thisObject().toString(scope.engine)); - ScopedValue regexp(scope, context->d()->callData->argument(0)); + ScopedValue regexp(scope, context->argument(0)); Scoped<RegExpObject> rx(scope, regexp); if (!rx) { ScopedCallData callData(scope, 1); @@ -473,10 +473,10 @@ ReturnedValue StringPrototype::method_replace(CallContext *ctx) { Scope scope(ctx); QString string; - if (StringObject *thisString = ctx->d()->callData->thisObject.asStringObject()) + if (StringObject *thisString = ctx->thisObject().asStringObject()) string = thisString->d()->value.stringValue()->toQString(); else - string = ctx->d()->callData->thisObject.toQString(); + string = ctx->thisObject().toQString(); int numCaptures = 0; int numStringMatches = 0; @@ -618,9 +618,9 @@ ReturnedValue StringPrototype::method_slice(CallContext *ctx) const double length = text.length(); - 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(); + double start = ctx->argc() ? ctx->args()[0].toInteger() : 0; + double end = (ctx->argc() < 2 || ctx->args()[1].isUndefined()) + ? length : ctx->args()[1].toInteger(); if (start < 0) start = qMax(length + start, 0.); @@ -728,12 +728,12 @@ ReturnedValue StringPrototype::method_substr(CallContext *context) return Encode::undefined(); double start = 0; - if (context->d()->callData->argc > 0) - start = context->d()->callData->args[0].toInteger(); + if (context->argc() > 0) + start = context->args()[0].toInteger(); double length = +qInf(); - if (context->d()->callData->argc > 1) - length = context->d()->callData->args[1].toInteger(); + if (context->argc() > 1) + length = context->args()[1].toInteger(); double count = value.length(); if (start < 0) @@ -756,8 +756,8 @@ ReturnedValue StringPrototype::method_substring(CallContext *context) double start = 0; double end = length; - if (context->d()->callData->argc > 0) - start = context->d()->callData->args[0].toInteger(); + if (context->argc() > 0) + start = context->args()[0].toInteger(); Scope scope(context); ScopedValue endValue(scope, context->argument(1)); @@ -815,10 +815,10 @@ ReturnedValue StringPrototype::method_toLocaleUpperCase(CallContext *ctx) ReturnedValue StringPrototype::method_fromCharCode(CallContext *context) { - QString str(context->d()->callData->argc, Qt::Uninitialized); + QString str(context->argc(), Qt::Uninitialized); QChar *ch = str.data(); - for (int i = 0; i < context->d()->callData->argc; ++i) { - *ch = QChar(context->d()->callData->args[i].toUInt16()); + for (int i = 0; i < context->argc(); ++i) { + *ch = QChar(context->args()[i].toUInt16()); ++ch; } return context->d()->engine->newString(str)->asReturnedValue(); diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index 1b9c5d58e4..ba3ebdd60c 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -404,7 +404,7 @@ void TypedArrayPrototype::init(ExecutionEngine *engine, TypedArrayCtor *ctor) ReturnedValue TypedArrayPrototype::method_get_buffer(CallContext *ctx) { Scope scope(ctx); - Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject); + Scoped<TypedArray> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -414,7 +414,7 @@ ReturnedValue TypedArrayPrototype::method_get_buffer(CallContext *ctx) ReturnedValue TypedArrayPrototype::method_get_byteLength(CallContext *ctx) { Scope scope(ctx); - Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject); + Scoped<TypedArray> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -424,7 +424,7 @@ ReturnedValue TypedArrayPrototype::method_get_byteLength(CallContext *ctx) ReturnedValue TypedArrayPrototype::method_get_byteOffset(CallContext *ctx) { Scope scope(ctx); - Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject); + Scoped<TypedArray> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -434,7 +434,7 @@ ReturnedValue TypedArrayPrototype::method_get_byteOffset(CallContext *ctx) ReturnedValue TypedArrayPrototype::method_get_length(CallContext *ctx) { Scope scope(ctx); - Scoped<TypedArray> v(scope, ctx->d()->callData->thisObject); + Scoped<TypedArray> v(scope, ctx->thisObject()); if (!v) return scope.engine->throwTypeError(); @@ -444,14 +444,14 @@ ReturnedValue TypedArrayPrototype::method_get_length(CallContext *ctx) ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx) { Scope scope(ctx); - Scoped<TypedArray> a(scope, ctx->d()->callData->thisObject); + Scoped<TypedArray> a(scope, ctx->thisObject()); if (!a) return scope.engine->throwTypeError(); Scoped<ArrayBuffer> buffer(scope, a->d()->buffer); if (!buffer) scope.engine->throwTypeError(); - double doffset = ctx->d()->callData->argc >= 2 ? ctx->d()->callData->args[1].toInteger() : 0; + double doffset = ctx->argc() >= 2 ? ctx->args()[1].toInteger() : 0; if (scope.engine->hasException) return Encode::undefined(); @@ -460,10 +460,10 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx) uint offset = (uint)doffset; uint elementSize = a->d()->type->bytesPerElement; - Scoped<TypedArray> srcTypedArray(scope, ctx->d()->callData->args[0]); + Scoped<TypedArray> srcTypedArray(scope, ctx->args()[0]); if (!srcTypedArray) { // src is a regular object - ScopedObject o(scope, ctx->d()->callData->args[0].toObject(scope.engine)); + ScopedObject o(scope, ctx->args()[0].toObject(scope.engine)); if (scope.engine->hasException || !o) return scope.engine->throwTypeError(); @@ -533,7 +533,7 @@ ReturnedValue TypedArrayPrototype::method_set(CallContext *ctx) ReturnedValue TypedArrayPrototype::method_subarray(CallContext *ctx) { Scope scope(ctx); - Scoped<TypedArray> a(scope, ctx->d()->callData->thisObject); + Scoped<TypedArray> a(scope, ctx->thisObject()); if (!a) return scope.engine->throwTypeError(); @@ -543,12 +543,12 @@ ReturnedValue TypedArrayPrototype::method_subarray(CallContext *ctx) return scope.engine->throwTypeError(); int len = a->length(); - double b = ctx->d()->callData->argc > 0 ? ctx->d()->callData->args[0].toInteger() : 0; + double b = ctx->argc() > 0 ? ctx->args()[0].toInteger() : 0; if (b < 0) b = len + b; uint begin = (uint)qBound(0., b, (double)len); - double e = ctx->d()->callData->argc < 2 || ctx->d()->callData->args[1].isUndefined() ? len : ctx->d()->callData->args[1].toInteger(); + double e = ctx->argc() < 2 || ctx->args()[1].isUndefined() ? len : ctx->args()[1].toInteger(); if (e < 0) e = len + e; uint end = (uint)qBound(0., e, (double)len); diff --git a/src/qml/jsruntime/qv4variantobject.cpp b/src/qml/jsruntime/qv4variantobject.cpp index a1339bb90a..cf323fc6bc 100644 --- a/src/qml/jsruntime/qv4variantobject.cpp +++ b/src/qml/jsruntime/qv4variantobject.cpp @@ -103,7 +103,7 @@ void VariantPrototype::init() QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx) { Scope scope(ctx); - Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>()); + Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>()); if (o && o->d()->isScarce()) o->d()->node.remove(); return Encode::undefined(); @@ -112,7 +112,7 @@ QV4::ReturnedValue VariantPrototype::method_preserve(CallContext *ctx) QV4::ReturnedValue VariantPrototype::method_destroy(CallContext *ctx) { Scope scope(ctx); - Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>()); + Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>()); if (o) { if (o->d()->isScarce()) o->d()->node.remove(); @@ -124,7 +124,7 @@ QV4::ReturnedValue VariantPrototype::method_destroy(CallContext *ctx) QV4::ReturnedValue VariantPrototype::method_toString(CallContext *ctx) { Scope scope(ctx); - Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>()); + Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>()); if (!o) return Encode::undefined(); QString result = o->d()->data.toString(); @@ -136,7 +136,7 @@ QV4::ReturnedValue VariantPrototype::method_toString(CallContext *ctx) QV4::ReturnedValue VariantPrototype::method_valueOf(CallContext *ctx) { Scope scope(ctx); - Scoped<VariantObject> o(scope, ctx->d()->callData->thisObject.as<QV4::VariantObject>()); + Scoped<VariantObject> o(scope, ctx->thisObject().as<QV4::VariantObject>()); if (o) { QVariant v = o->d()->data; switch (v.type()) { @@ -157,7 +157,7 @@ QV4::ReturnedValue VariantPrototype::method_valueOf(CallContext *ctx) break; } } - return ctx->d()->callData->thisObject.asReturnedValue(); + return ctx->thisObject().asReturnedValue(); } QT_END_NAMESPACE diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index 87b1387eed..6f1838728e 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -627,7 +627,7 @@ QV4::ReturnedValue VME::run(ExecutionEngine *engine, const uchar *code MOTH_END_INSTR(Debug) MOTH_BEGIN_INSTR(LoadThis) - VALUE(instr.result) = context->d()->callData->thisObject; + VALUE(instr.result) = context->thisObject(); MOTH_END_INSTR(LoadThis) MOTH_BEGIN_INSTR(LoadQmlIdArray) diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 0b76c0f176..428c59767b 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1420,7 +1420,7 @@ QQmlComponentExtension::QQmlComponentExtension(QV4::ExecutionEngine *v4) QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->thisObject().as<QmlIncubatorObject>()); if (!o) return ctx->engine()->throwTypeError(); @@ -1430,7 +1430,7 @@ QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_object(QV4::CallContext * QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->thisObject().as<QmlIncubatorObject>()); if (!o) return ctx->engine()->throwTypeError(); @@ -1442,7 +1442,7 @@ QV4::ReturnedValue QV4::QmlIncubatorObject::method_forceCompletion(QV4::CallCont QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_status(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->thisObject().as<QmlIncubatorObject>()); if (!o) return ctx->engine()->throwTypeError(); @@ -1452,7 +1452,7 @@ QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_status(QV4::CallContext * QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_statusChanged(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->thisObject().as<QmlIncubatorObject>()); if (!o) return ctx->engine()->throwTypeError(); @@ -1462,12 +1462,12 @@ QV4::ReturnedValue QV4::QmlIncubatorObject::method_get_statusChanged(QV4::CallCo QV4::ReturnedValue QV4::QmlIncubatorObject::method_set_statusChanged(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QmlIncubatorObject> o(scope, ctx->d()->callData->thisObject.as<QmlIncubatorObject>()); - if (!o || ctx->d()->callData->argc < 1) + QV4::Scoped<QmlIncubatorObject> o(scope, ctx->thisObject().as<QmlIncubatorObject>()); + if (!o || ctx->argc() < 1) return ctx->engine()->throwTypeError(); - o->d()->statusChanged = ctx->d()->callData->args[0]; + o->d()->statusChanged = ctx->args()[0]; return QV4::Encode::undefined(); } diff --git a/src/qml/qml/qqmllocale.cpp b/src/qml/qml/qqmllocale.cpp index 5a27739156..34fb585309 100644 --- a/src/qml/qml/qqmllocale.cpp +++ b/src/qml/qml/qqmllocale.cpp @@ -76,36 +76,36 @@ void QQmlDateExtension::registerExtension(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc > 2) + if (ctx->argc() > 2) return QV4::DatePrototype::method_toLocaleString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *date = ctx->d()->callData->thisObject.asDateObject(); + QV4::DateObject *date = ctx->thisObject().asDateObject(); if (!date) return QV4::DatePrototype::method_toLocaleString(ctx); QDateTime dt = date->toQDateTime(); - if (ctx->d()->callData->argc == 0) { + if (ctx->argc() == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return ctx->d()->engine->newString(locale.toString(dt))->asReturnedValue(); } - if (!isLocaleObject(ctx->d()->callData->args[0])) + if (!isLocaleObject(ctx->args()[0])) return QV4::DatePrototype::method_toLocaleString(ctx); // Use the default Date toLocaleString() - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDt; - if (ctx->d()->callData->argc == 2) { - if (ctx->d()->callData->args[1].isString()) { - QString format = ctx->d()->callData->args[1].stringValue()->toQString(); + if (ctx->argc() == 2) { + if (ctx->args()[1].isString()) { + QString format = ctx->args()[1].stringValue()->toQString(); formattedDt = r->d()->locale.toString(dt, format); - } else if (ctx->d()->callData->args[1].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[1].toNumber(); + } else if (ctx->args()[1].isNumber()) { + quint32 intFormat = ctx->args()[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDt = r->d()->locale.toString(dt, format); } else { @@ -120,37 +120,37 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleString(QV4::CallContext *ct QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc > 2) + if (ctx->argc() > 2) return QV4::DatePrototype::method_toLocaleTimeString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *date = ctx->d()->callData->thisObject.asDateObject(); + QV4::DateObject *date = ctx->thisObject().asDateObject(); if (!date) return QV4::DatePrototype::method_toLocaleTimeString(ctx); QDateTime dt = date->toQDateTime(); QTime time = dt.time(); - if (ctx->d()->callData->argc == 0) { + if (ctx->argc() == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return ctx->d()->engine->newString(locale.toString(time))->asReturnedValue(); } - if (!isLocaleObject(ctx->d()->callData->args[0])) + if (!isLocaleObject(ctx->args()[0])) return QV4::DatePrototype::method_toLocaleTimeString(ctx); // Use the default Date toLocaleTimeString() - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedTime; - if (ctx->d()->callData->argc == 2) { - if (ctx->d()->callData->args[1].isString()) { - QString format = ctx->d()->callData->args[1].stringValue()->toQString(); + if (ctx->argc() == 2) { + if (ctx->args()[1].isString()) { + QString format = ctx->args()[1].stringValue()->toQString(); formattedTime = r->d()->locale.toString(time, format); - } else if (ctx->d()->callData->args[1].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[1].toNumber(); + } else if (ctx->args()[1].isNumber()) { + quint32 intFormat = ctx->args()[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedTime = r->d()->locale.toString(time, format); } else { @@ -165,37 +165,37 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleTimeString(QV4::CallContext QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc > 2) + if (ctx->argc() > 2) return QV4::DatePrototype::method_toLocaleDateString(ctx); QV4::Scope scope(ctx); - QV4::DateObject *dateObj = ctx->d()->callData->thisObject.asDateObject(); + QV4::DateObject *dateObj = ctx->thisObject().asDateObject(); if (!dateObj) return QV4::DatePrototype::method_toLocaleDateString(ctx); QDateTime dt = dateObj->toQDateTime(); QDate date = dt.date(); - if (ctx->d()->callData->argc == 0) { + if (ctx->argc() == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return ctx->d()->engine->newString(locale.toString(date))->asReturnedValue(); } - if (!isLocaleObject(ctx->d()->callData->args[0])) + if (!isLocaleObject(ctx->args()[0])) return QV4::DatePrototype::method_toLocaleDateString(ctx); // Use the default Date toLocaleDateString() - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QString formattedDate; - if (ctx->d()->callData->argc == 2) { - if (ctx->d()->callData->args[1].isString()) { - QString format = ctx->d()->callData->args[1].stringValue()->toQString(); + if (ctx->argc() == 2) { + if (ctx->args()[1].isString()) { + QString format = ctx->args()[1].stringValue()->toQString(); formattedDate = r->d()->locale.toString(date, format); - } else if (ctx->d()->callData->args[1].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[1].toNumber(); + } else if (ctx->args()[1].isNumber()) { + quint32 intFormat = ctx->args()[1].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); formattedDate = r->d()->locale.toString(date, format); } else { @@ -211,29 +211,29 @@ QV4::ReturnedValue QQmlDateExtension::method_toLocaleDateString(QV4::CallContext QV4::ReturnedValue QQmlDateExtension::method_fromLocaleString(QV4::CallContext *ctx) { QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) { + if (ctx->argc() == 1 && ctx->args()[0].isString()) { QLocale locale; - QString dateString = ctx->d()->callData->args[0].stringValue()->toQString(); + QString dateString = ctx->args()[0].stringValue()->toQString(); QDateTime dt = locale.toDateTime(dateString); return QV4::Encode(engine->newDateObject(dt)); } QV4::Scope scope(ctx); - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0])) + if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0])) V4THROW_ERROR("Locale: Date.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDateTime dt; - 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(); + QString dateString = ctx->args()[1].toQStringNoThrow(); + if (ctx->argc() == 3) { + if (ctx->args()[2].isString()) { + QString format = ctx->args()[2].stringValue()->toQString(); dt = r->d()->locale.toDateTime(dateString, format); - } else if (ctx->d()->callData->args[2].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[2].toNumber(); + } else if (ctx->args()[2].isNumber()) { + quint32 intFormat = ctx->args()[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->d()->locale.toDateTime(dateString, format); } else { @@ -250,31 +250,31 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleTimeString(QV4::CallConte { QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) { + if (ctx->argc() == 1 && ctx->args()[0].isString()) { QLocale locale; - QString timeString = ctx->d()->callData->args[0].stringValue()->toQString(); + QString timeString = ctx->args()[0].stringValue()->toQString(); QTime time = locale.toTime(timeString); QDateTime dt = QDateTime::currentDateTime(); dt.setTime(time); return QV4::Encode(engine->newDateObject(dt)); } - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0])) + if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0])) V4THROW_ERROR("Locale: Date.fromLocaleTimeString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QTime tm; - 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(); + QString dateString = ctx->args()[1].toQStringNoThrow(); + if (ctx->argc() == 3) { + if (ctx->args()[2].isString()) { + QString format = ctx->args()[2].stringValue()->toQString(); tm = r->d()->locale.toTime(dateString, format); - } else if (ctx->d()->callData->args[2].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[2].toNumber(); + } else if (ctx->args()[2].isNumber()) { + quint32 intFormat = ctx->args()[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); tm = r->d()->locale.toTime(dateString, format); } else { @@ -297,29 +297,29 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte { QV4::ExecutionEngine * const engine = ctx->d()->engine; - if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isString()) { + if (ctx->argc() == 1 && ctx->args()[0].isString()) { QLocale locale; - QString dateString = ctx->d()->callData->args[0].stringValue()->toQString(); + QString dateString = ctx->args()[0].stringValue()->toQString(); QDate date = locale.toDate(dateString); return QV4::Encode(engine->newDateObject(QDateTime(date))); } - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3 || !isLocaleObject(ctx->d()->callData->args[0])) + if (ctx->argc() < 1 || ctx->argc() > 3 || !isLocaleObject(ctx->args()[0])) V4THROW_ERROR("Locale: Date.fromLocaleDateString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); QLocale::FormatType enumFormat = QLocale::LongFormat; QDate dt; - 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(); + QString dateString = ctx->args()[1].toQStringNoThrow(); + if (ctx->argc() == 3) { + if (ctx->args()[2].isString()) { + QString format = ctx->args()[2].stringValue()->toQString(); dt = r->d()->locale.toDate(dateString, format); - } else if (ctx->d()->callData->args[2].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[2].toNumber(); + } else if (ctx->args()[2].isNumber()) { + quint32 intFormat = ctx->args()[2].toNumber(); QLocale::FormatType format = QLocale::FormatType(intFormat); dt = r->d()->locale.toDate(dateString, format); } else { @@ -334,7 +334,7 @@ QV4::ReturnedValue QQmlDateExtension::method_fromLocaleDateString(QV4::CallConte QV4::ReturnedValue QQmlDateExtension::method_timeZoneUpdated(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 0) + if (ctx->argc() != 0) V4THROW_ERROR("Locale: Date.timeZoneUpdated(): Invalid arguments"); QV4::DatePrototype::timezoneUpdated(); @@ -354,37 +354,37 @@ void QQmlNumberExtension::registerExtension(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc > 3) + if (ctx->argc() > 3) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - double number = ctx->d()->callData->thisObject.toNumber(); + double number = ctx->thisObject().toNumber(); - if (ctx->d()->callData->argc == 0) { + if (ctx->argc() == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return ctx->d()->engine->newString(locale.toString(number))->asReturnedValue(); } - if (!isLocaleObject(ctx->d()->callData->args[0])) + if (!isLocaleObject(ctx->args()[0])) return QV4::NumberPrototype::method_toLocaleString(ctx); // Use the default Number toLocaleString() QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); quint16 format = 'f'; - if (ctx->d()->callData->argc > 1) { - if (!ctx->d()->callData->args[1].isString()) + if (ctx->argc() > 1) { + if (!ctx->args()[1].isString()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - QString fs = ctx->d()->callData->args[1].toQString(); + QString fs = ctx->args()[1].toQString(); if (fs.length()) format = fs.at(0).unicode(); } int prec = 2; - if (ctx->d()->callData->argc > 2) { - if (!ctx->d()->callData->args[2].isNumber()) + if (ctx->argc() > 2) { + if (!ctx->args()[2].isNumber()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - prec = ctx->d()->callData->args[2].toInt32(); + prec = ctx->args()[2].toInt32(); } return ctx->d()->engine->newString(r->d()->locale.toString(number, (char)format, prec))->asReturnedValue(); @@ -392,29 +392,29 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleString(QV4::CallContext * QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc > 2) + if (ctx->argc() > 2) V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); - double number = ctx->d()->callData->thisObject.toNumber(); + double number = ctx->thisObject().toNumber(); - if (ctx->d()->callData->argc == 0) { + if (ctx->argc() == 0) { // Use QLocale for standard toLocaleString() function QLocale locale; return ctx->d()->engine->newString(locale.toString(number))->asReturnedValue(); } - if (!isLocaleObject(ctx->d()->callData->args[0])) + if (!isLocaleObject(ctx->args()[0])) V4THROW_ERROR("Locale: Number.toLocaleCurrencyString(): Invalid arguments"); QV4::Scope scope(ctx); - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); QString symbol; - if (ctx->d()->callData->argc > 1) { - if (!ctx->d()->callData->args[1].isString()) + if (ctx->argc() > 1) { + if (!ctx->args()[1].isString()) V4THROW_ERROR("Locale: Number.toLocaleString(): Invalid arguments"); - symbol = ctx->d()->callData->args[1].toQStringNoThrow(); + symbol = ctx->args()[1].toQStringNoThrow(); } return ctx->d()->engine->newString(r->d()->locale.toCurrencyString(number, symbol))->asReturnedValue(); @@ -422,7 +422,7 @@ QV4::ReturnedValue QQmlNumberExtension::method_toLocaleCurrencyString(QV4::CallC QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) + if (ctx->argc() < 1 || ctx->argc() > 2) V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); int numberIdx = 0; @@ -430,17 +430,17 @@ QV4::ReturnedValue QQmlNumberExtension::method_fromLocaleString(QV4::CallContext QV4::Scope scope(ctx); - if (ctx->d()->callData->argc == 2) { - if (!isLocaleObject(ctx->d()->callData->args[0])) + if (ctx->argc() == 2) { + if (!isLocaleObject(ctx->args()[0])) V4THROW_ERROR("Locale: Number.fromLocaleString(): Invalid arguments"); - GET_LOCALE_DATA_RESOURCE(ctx->d()->callData->args[0]); + GET_LOCALE_DATA_RESOURCE(ctx->args()[0]); locale = r->d()->locale; numberIdx = 1; } - QString ns = ctx->d()->callData->args[numberIdx].toQString(); + QString ns = ctx->args()[numberIdx].toQString(); if (!ns.length()) return QV4::Encode(Q_QNAN); @@ -531,12 +531,12 @@ QV4::ReturnedValue QQmlLocaleData::method_currencySymbol(QV4::CallContext *ctx) if (!locale) return QV4::Encode::undefined(); - if (ctx->d()->callData->argc > 1) + if (ctx->argc() > 1) V4THROW_ERROR("Locale: currencySymbol(): Invalid arguments"); QLocale::CurrencySymbolFormat format = QLocale::CurrencySymbol; - if (ctx->d()->callData->argc == 1) { - quint32 intFormat = ctx->d()->callData->args[0].toNumber(); + if (ctx->argc() == 1) { + quint32 intFormat = ctx->args()[0].toNumber(); format = QLocale::CurrencySymbolFormat(intFormat); } @@ -548,11 +548,11 @@ QV4::ReturnedValue QQmlLocaleData::method_ ##FUNC (QV4::CallContext *ctx) { \ QLocale *locale = getThisLocale(ctx); \ if (!locale) \ return QV4::Encode::undefined(); \ - if (ctx->d()->callData->argc > 1) \ + if (ctx->argc() > 1) \ V4THROW_ERROR("Locale: " #FUNC "(): Invalid arguments"); \ QLocale::FormatType format = QLocale::LongFormat;\ - if (ctx->d()->callData->argc == 1) { \ - quint32 intFormat = ctx->d()->callData->args[0].toUInt32(); \ + if (ctx->argc() == 1) { \ + quint32 intFormat = ctx->args()[0].toUInt32(); \ format = QLocale::FormatType(intFormat); \ } \ return ctx->engine()->newString(locale-> FUNC (format))->asReturnedValue(); \ @@ -568,16 +568,16 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) { QLocale *locale = getThisLocale(ctx); \ if (!locale) \ return QV4::Encode::undefined(); \ - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) \ + if (ctx->argc() < 1 || ctx->argc() > 2) \ V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = ctx->d()->callData->args[0].toInt32() + 1; \ + int idx = ctx->args()[0].toInt32() + 1; \ if (idx < 1 || idx > 12) \ V4THROW_ERROR("Locale: Invalid month"); \ QString name; \ - if (ctx->d()->callData->argc == 2) { \ - if (ctx->d()->callData->args[1].isNumber()) { \ - quint32 intFormat = ctx->d()->callData->args[1].toUInt32(); \ + if (ctx->argc() == 2) { \ + if (ctx->args()[1].isNumber()) { \ + quint32 intFormat = ctx->args()[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale-> VARIABLE(idx, format); \ } else { \ @@ -595,17 +595,17 @@ QV4::ReturnedValue QQmlLocaleData::method_ ## VARIABLE (QV4::CallContext *ctx) { QLocale *locale = getThisLocale(ctx); \ if (!locale) \ return QV4::Encode::undefined(); \ - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) \ + if (ctx->argc() < 1 || ctx->argc() > 2) \ V4THROW_ERROR("Locale: " #VARIABLE "(): Invalid arguments"); \ QLocale::FormatType enumFormat = QLocale::LongFormat; \ - int idx = ctx->d()->callData->args[0].toInt32(); \ + int idx = ctx->args()[0].toInt32(); \ if (idx < 0 || idx > 7) \ V4THROW_ERROR("Locale: Invalid day"); \ if (idx == 0) idx = 7; \ QString name; \ - if (ctx->d()->callData->argc == 2) { \ - if (ctx->d()->callData->args[1].isNumber()) { \ - quint32 intFormat = ctx->d()->callData->args[1].toUInt32(); \ + if (ctx->argc() == 2) { \ + if (ctx->args()[1].isNumber()) { \ + quint32 intFormat = ctx->args()[1].toUInt32(); \ QLocale::FormatType format = QLocale::FormatType(intFormat); \ name = locale-> VARIABLE(idx, format); \ } else { \ @@ -820,14 +820,14 @@ void QQmlLocale::registerStringLocaleCompare(QV4::ExecutionEngine *engine) QV4::ReturnedValue QQmlLocale::method_localeCompare(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 1 || (!ctx->d()->callData->args[0].isString() && !ctx->d()->callData->args[0].asStringObject())) + if (ctx->argc() != 1 || (!ctx->args()[0].isString() && !ctx->args()[0].asStringObject())) return QV4::StringPrototype::method_localeCompare(ctx); - if (!ctx->d()->callData->thisObject.isString() && !ctx->d()->callData->thisObject.asStringObject()) + if (!ctx->thisObject().isString() && !ctx->thisObject().asStringObject()) return QV4::StringPrototype::method_localeCompare(ctx); - QString thisString = ctx->d()->callData->thisObject.toQStringNoThrow(); - QString thatString = ctx->d()->callData->args[0].toQStringNoThrow(); + QString thisString = ctx->thisObject().toQStringNoThrow(); + QString thatString = ctx->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 1b9afd1c81..169eab4dde 100644 --- a/src/qml/qml/qqmllocale_p.h +++ b/src/qml/qml/qqmllocale_p.h @@ -137,7 +137,7 @@ struct QQmlLocaleData : public QV4::Object V4_NEEDS_DESTROY static QLocale *getThisLocale(QV4::CallContext *ctx) { - QV4::Object *o = ctx->d()->callData->thisObject.asObject(); + QV4::Object *o = ctx->thisObject().asObject(); QQmlLocaleData *thisObject = o ? o->as<QQmlLocaleData>() : 0; if (!thisObject) { ctx->engine()->throwTypeError(); diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp index b80472559b..271b986a34 100644 --- a/src/qml/qml/qqmlvaluetypewrapper.cpp +++ b/src/qml/qml/qqmlvaluetypewrapper.cpp @@ -250,7 +250,7 @@ bool QQmlValueTypeWrapper::isEqual(const QVariant& value) ReturnedValue QQmlValueTypeWrapper::method_toString(CallContext *ctx) { - Object *o = ctx->d()->callData->thisObject.asObject(); + Object *o = ctx->thisObject().asObject(); if (!o) return ctx->engine()->throwTypeError(); QQmlValueTypeWrapper *w = o->as<QQmlValueTypeWrapper>(); diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 527e9c8446..e05d83364d 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -418,7 +418,7 @@ void NodeImpl::release() ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -443,7 +443,7 @@ ReturnedValue NodePrototype::method_get_nodeName(CallContext *ctx) ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -462,7 +462,7 @@ ReturnedValue NodePrototype::method_get_nodeValue(CallContext *ctx) ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -472,7 +472,7 @@ ReturnedValue NodePrototype::method_get_nodeType(CallContext *ctx) ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -485,7 +485,7 @@ ReturnedValue NodePrototype::method_get_parentNode(CallContext *ctx) ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -495,7 +495,7 @@ ReturnedValue NodePrototype::method_get_childNodes(CallContext *ctx) ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -508,7 +508,7 @@ ReturnedValue NodePrototype::method_get_firstChild(CallContext *ctx) ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -521,7 +521,7 @@ ReturnedValue NodePrototype::method_get_lastChild(CallContext *ctx) ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -543,7 +543,7 @@ ReturnedValue NodePrototype::method_get_previousSibling(CallContext *ctx) ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -565,7 +565,7 @@ ReturnedValue NodePrototype::method_get_nextSibling(CallContext *ctx) ReturnedValue NodePrototype::method_get_attributes(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return ctx->engine()->throwTypeError(); @@ -656,7 +656,7 @@ ReturnedValue Attr::prototype(ExecutionEngine *engine) ReturnedValue Attr::method_name(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return Encode::undefined(); @@ -666,7 +666,7 @@ ReturnedValue Attr::method_name(CallContext *ctx) ReturnedValue Attr::method_value(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return Encode::undefined(); @@ -676,7 +676,7 @@ ReturnedValue Attr::method_value(CallContext *ctx) ReturnedValue Attr::method_ownerElement(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return Encode::undefined(); @@ -686,7 +686,7 @@ ReturnedValue Attr::method_ownerElement(CallContext *ctx) ReturnedValue CharacterData::method_length(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return Encode::undefined(); @@ -712,7 +712,7 @@ ReturnedValue CharacterData::prototype(ExecutionEngine *v4) ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return Encode::undefined(); return Encode(r->d()->d->data.trimmed().isEmpty()); @@ -721,7 +721,7 @@ ReturnedValue Text::method_isElementContentWhitespace(CallContext *ctx) ReturnedValue Text::method_wholeText(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r) return Encode::undefined(); @@ -956,7 +956,7 @@ ReturnedValue NodeList::create(ExecutionEngine *v4, NodeImpl *data) ReturnedValue Document::method_documentElement(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); @@ -966,7 +966,7 @@ ReturnedValue Document::method_documentElement(CallContext *ctx) ReturnedValue Document::method_xmlStandalone(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); @@ -976,7 +976,7 @@ ReturnedValue Document::method_xmlStandalone(CallContext *ctx) ReturnedValue Document::method_xmlVersion(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); @@ -986,7 +986,7 @@ ReturnedValue Document::method_xmlVersion(CallContext *ctx) ReturnedValue Document::method_xmlEncoding(CallContext *ctx) { Scope scope(ctx); - Scoped<Node> r(scope, ctx->d()->callData->thisObject.as<Node>()); + Scoped<Node> r(scope, ctx->thisObject().as<Node>()); if (!r || r->d()->d->type != NodeImpl::Document) return Encode::undefined(); @@ -1704,16 +1704,16 @@ void QQmlXMLHttpRequestCtor::setupProto() ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->d()->callData->argc < 2 || ctx->d()->callData->argc > 5) + if (ctx->argc() < 2 || ctx->argc() > 5) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); // Argument 0 - Method - QString method = ctx->d()->callData->args[0].toQStringNoThrow().toUpper(); + QString method = ctx->args()[0].toQStringNoThrow().toUpper(); if (method != QLatin1String("GET") && method != QLatin1String("PUT") && method != QLatin1String("HEAD") && @@ -1723,23 +1723,23 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Unsupported HTTP method type"); // Argument 1 - URL - QUrl url = QUrl(ctx->d()->callData->args[1].toQStringNoThrow()); + QUrl url = QUrl(ctx->args()[1].toQStringNoThrow()); if (url.isRelative()) url = scope.engine->v8Engine->callingContext()->resolvedUrl(url); bool async = true; // Argument 2 - async (optional) - if (ctx->d()->callData->argc > 2) { - async = ctx->d()->callData->args[2].booleanValue(); + if (ctx->argc() > 2) { + async = ctx->args()[2].booleanValue(); } // Argument 3/4 - user/pass (optional) QString username, password; - 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(); + if (ctx->argc() > 3) + username = ctx->args()[3].toQStringNoThrow(); + if (ctx->argc() > 4) + password = ctx->args()[4].toQStringNoThrow(); // Clear the fragment (if any) url.setFragment(QString()); @@ -1748,26 +1748,26 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_open(CallContext *ctx) if (!username.isNull()) url.setUserName(username); if (!password.isNull()) url.setPassword(password); - ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, scope.engine)); + ScopedValue meObject(scope, constructMeObject(ctx->thisObject(), scope.engine)); return r->open(meObject, method, url, async ? QQmlXMLHttpRequest::AsynchronousLoad : QQmlXMLHttpRequest::SynchronousLoad); } ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->d()->callData->argc != 2) + if (ctx->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->d()->callData->args[0].toQStringNoThrow(); - QString value = ctx->d()->callData->args[1].toQStringNoThrow(); + QString name = ctx->args()[0].toQStringNoThrow(); + QString value = ctx->args()[1].toQStringNoThrow(); // ### Check that name and value are well formed @@ -1802,7 +1802,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_setRequestHeader(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_send(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1812,34 +1812,34 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_send(CallContext *ctx) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); QByteArray data; - if (ctx->d()->callData->argc > 0) - data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8(); + if (ctx->argc() > 0) + data = ctx->args()[0].toQStringNoThrow().toUtf8(); - ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, scope.engine)); + ScopedValue meObject(scope, constructMeObject(ctx->thisObject(), scope.engine)); return r->send(meObject, data); } ReturnedValue QQmlXMLHttpRequestCtor::method_abort(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - ScopedValue meObject(scope, constructMeObject(ctx->d()->callData->thisObject, scope.engine)); + ScopedValue meObject(scope, constructMeObject(ctx->thisObject(), scope.engine)); return r->abort(meObject); } ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1847,18 +1847,18 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getResponseHeader(CallContext *ctx) r->readyState() != QQmlXMLHttpRequest::HeadersReceived) V4THROW_DOM(DOMEXCEPTION_INVALID_STATE_ERR, "Invalid state"); - return QV4::Encode(scope.engine->newString(r->header(ctx->d()->callData->args[0].toQStringNoThrow()))); + return QV4::Encode(scope.engine->newString(r->header(ctx->args()[0].toQStringNoThrow()))); } ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; - if (ctx->d()->callData->argc != 0) + if (ctx->argc() != 0) V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); if (r->readyState() != QQmlXMLHttpRequest::Loading && @@ -1873,7 +1873,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_getAllResponseHeaders(CallContext * ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1884,7 +1884,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_readyState(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1902,7 +1902,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_status(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1920,7 +1920,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_statusText(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; @@ -1935,7 +1935,7 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseText(CallContext *ctx) ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx) { Scope scope(ctx); - Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->d()->callData->thisObject.as<QQmlXMLHttpRequestWrapper>()); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); if (!w) V4THROW_REFERENCE("Not an XMLHttpRequest object"); QQmlXMLHttpRequest *r = w->d()->request; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 0878063f2e..cd1387b5b4 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -150,10 +150,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->d()->callData->argc == 0) + if (ctx->argc() == 0) return QV4::Encode(false); - return QV4::Encode(ctx->d()->callData->args[0].as<QV4::QObjectWrapper>() != 0); + return QV4::Encode(ctx->args()[0].as<QV4::QObjectWrapper>() != 0); } /*! @@ -164,14 +164,14 @@ All components should be in the range 0-1 inclusive. */ ReturnedValue QtObject::method_rgba(QV4::CallContext *ctx) { - int argCount = ctx->d()->callData->argc; + int argCount = ctx->argc(); if (argCount < 3 || argCount > 4) V4THROW_ERROR("Qt.rgba(): Invalid arguments"); - 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; + double r = ctx->args()[0].toNumber(); + double g = ctx->args()[1].toNumber(); + double b = ctx->args()[2].toNumber(); + double a = (argCount == 4) ? ctx->args()[3].toNumber() : 1; if (r < 0.0) r=0.0; if (r > 1.0) r=1.0; @@ -193,14 +193,14 @@ All components should be in the range 0-1 inclusive. */ ReturnedValue QtObject::method_hsla(QV4::CallContext *ctx) { - int argCount = ctx->d()->callData->argc; + int argCount = ctx->argc(); if (argCount < 3 || argCount > 4) V4THROW_ERROR("Qt.hsla(): Invalid arguments"); - 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; + double h = ctx->args()[0].toNumber(); + double s = ctx->args()[1].toNumber(); + double l = ctx->args()[2].toNumber(); + double a = (argCount == 4) ? ctx->args()[3].toNumber() : 1; if (h < 0.0) h=0.0; if (h > 1.0) h=1.0; @@ -224,12 +224,12 @@ basic type. */ ReturnedValue QtObject::method_colorEqual(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 2) + if (ctx->argc() != 2) V4THROW_ERROR("Qt.colorEqual(): Invalid arguments"); bool ok = false; - QVariant lhs = ctx->d()->engine->toVariant(ctx->d()->callData->args[0], -1); + QVariant lhs = ctx->d()->engine->toVariant(ctx->args()[0], -1); if (lhs.userType() == QVariant::String) { lhs = QQmlStringConverters::colorFromString(lhs.toString(), &ok); if (!ok) { @@ -239,7 +239,7 @@ ReturnedValue QtObject::method_colorEqual(QV4::CallContext *ctx) V4THROW_ERROR("Qt.colorEqual(): Invalid arguments"); } - QVariant rhs = ctx->engine()->toVariant(ctx->d()->callData->args[1], -1); + QVariant rhs = ctx->engine()->toVariant(ctx->args()[1], -1); if (rhs.userType() == QVariant::String) { rhs = QQmlStringConverters::colorFromString(rhs.toString(), &ok); if (!ok) { @@ -262,13 +262,13 @@ 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->d()->callData->argc != 4) + if (ctx->argc() != 4) V4THROW_ERROR("Qt.rect(): Invalid arguments"); - 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(); + double x = ctx->args()[0].toNumber(); + double y = ctx->args()[1].toNumber(); + double w = ctx->args()[2].toNumber(); + double h = ctx->args()[3].toNumber(); return ctx->engine()->fromVariant(QVariant::fromValue(QRectF(x, y, w, h))); } @@ -279,11 +279,11 @@ Returns a Point with the specified \c x and \c y coordinates. */ ReturnedValue QtObject::method_point(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 2) + if (ctx->argc() != 2) V4THROW_ERROR("Qt.point(): Invalid arguments"); - double x = ctx->d()->callData->args[0].toNumber(); - double y = ctx->d()->callData->args[1].toNumber(); + double x = ctx->args()[0].toNumber(); + double y = ctx->args()[1].toNumber(); return ctx->engine()->fromVariant(QVariant::fromValue(QPointF(x, y))); } @@ -294,11 +294,11 @@ Returns a Size with the specified \c width and \c height. */ ReturnedValue QtObject::method_size(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 2) + if (ctx->argc() != 2) V4THROW_ERROR("Qt.size(): Invalid arguments"); - double w = ctx->d()->callData->args[0].toNumber(); - double h = ctx->d()->callData->args[1].toNumber(); + double w = ctx->args()[0].toNumber(); + double h = ctx->args()[1].toNumber(); return ctx->engine()->fromVariant(QVariant::fromValue(QSizeF(w, h))); } @@ -313,12 +313,12 @@ Invalid keys will be ignored. */ ReturnedValue QtObject::method_font(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 1 || !ctx->d()->callData->args[0].isObject()) + if (ctx->argc() != 1 || !ctx->args()[0].isObject()) V4THROW_ERROR("Qt.font(): Invalid arguments"); QV4::ExecutionEngine *v4 = ctx->d()->engine; bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->d()->callData->args[0]), v4, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QFont, QQmlV4Handle(ctx->args()[0]), v4, &ok); if (!ok) V4THROW_ERROR("Qt.font(): Invalid argument: no valid font subproperties specified"); return ctx->engine()->fromVariant(v); @@ -332,12 +332,12 @@ Returns a Vector2D with the specified \c x and \c y. */ ReturnedValue QtObject::method_vector2d(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 2) + if (ctx->argc() != 2) V4THROW_ERROR("Qt.vector2d(): Invalid arguments"); float xy[3]; // qvector2d uses float internally - xy[0] = ctx->d()->callData->args[0].toNumber(); - xy[1] = ctx->d()->callData->args[1].toNumber(); + xy[0] = ctx->args()[0].toNumber(); + xy[1] = ctx->args()[1].toNumber(); const void *params[] = { xy }; return ctx->engine()->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector2D, 1, params)); @@ -349,13 +349,13 @@ Returns a Vector3D with the specified \c x, \c y and \c z. */ ReturnedValue QtObject::method_vector3d(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 3) + if (ctx->argc() != 3) V4THROW_ERROR("Qt.vector3d(): Invalid arguments"); float xyz[3]; // qvector3d uses float internally - xyz[0] = ctx->d()->callData->args[0].toNumber(); - xyz[1] = ctx->d()->callData->args[1].toNumber(); - xyz[2] = ctx->d()->callData->args[2].toNumber(); + xyz[0] = ctx->args()[0].toNumber(); + xyz[1] = ctx->args()[1].toNumber(); + xyz[2] = ctx->args()[2].toNumber(); const void *params[] = { xyz }; return ctx->engine()->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector3D, 1, params)); @@ -367,14 +367,14 @@ Returns a Vector4D with the specified \c x, \c y, \c z and \c w. */ ReturnedValue QtObject::method_vector4d(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 4) + if (ctx->argc() != 4) V4THROW_ERROR("Qt.vector4d(): Invalid arguments"); float xyzw[4]; // qvector4d uses float internally - 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(); + xyzw[0] = ctx->args()[0].toNumber(); + xyzw[1] = ctx->args()[1].toNumber(); + xyzw[2] = ctx->args()[2].toNumber(); + xyzw[3] = ctx->args()[3].toNumber(); const void *params[] = { xyzw }; return ctx->engine()->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QVector4D, 1, params)); @@ -386,14 +386,14 @@ Returns a Quaternion with the specified \c scalar, \c x, \c y, and \c z. */ ReturnedValue QtObject::method_quaternion(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 4) + if (ctx->argc() != 4) V4THROW_ERROR("Qt.quaternion(): Invalid arguments"); qreal sxyz[4]; // qquaternion uses qreal internally - 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(); + sxyz[0] = ctx->args()[0].toNumber(); + sxyz[1] = ctx->args()[1].toNumber(); + sxyz[2] = ctx->args()[2].toNumber(); + sxyz[3] = ctx->args()[3].toNumber(); const void *params[] = { sxyz }; return ctx->engine()->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QQuaternion, 1, params)); @@ -410,34 +410,34 @@ ReturnedValue QtObject::method_matrix4x4(QV4::CallContext *ctx) { QV4::ExecutionEngine *v4 = ctx->d()->engine; - if (ctx->d()->callData->argc == 1 && ctx->d()->callData->args[0].isObject()) { + if (ctx->argc() == 1 && ctx->args()[0].isObject()) { bool ok = false; - QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->d()->callData->args[0]), v4, &ok); + QVariant v = QQml_valueTypeProvider()->createVariantFromJsObject(QMetaType::QMatrix4x4, QQmlV4Handle(ctx->args()[0]), v4, &ok); if (!ok) V4THROW_ERROR("Qt.matrix4x4(): Invalid argument: not a valid matrix4x4 values array"); return ctx->engine()->fromVariant(v); } - if (ctx->d()->callData->argc != 16) + if (ctx->argc() != 16) V4THROW_ERROR("Qt.matrix4x4(): Invalid arguments"); qreal vals[16]; // qmatrix4x4 uses qreal internally - 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(); + vals[0] = ctx->args()[0].toNumber(); + vals[1] = ctx->args()[1].toNumber(); + vals[2] = ctx->args()[2].toNumber(); + vals[3] = ctx->args()[3].toNumber(); + vals[4] = ctx->args()[4].toNumber(); + vals[5] = ctx->args()[5].toNumber(); + vals[6] = ctx->args()[6].toNumber(); + vals[7] = ctx->args()[7].toNumber(); + vals[8] = ctx->args()[8].toNumber(); + vals[9] = ctx->args()[9].toNumber(); + vals[10] = ctx->args()[10].toNumber(); + vals[11] = ctx->args()[11].toNumber(); + vals[12] = ctx->args()[12].toNumber(); + vals[13] = ctx->args()[13].toNumber(); + vals[14] = ctx->args()[14].toNumber(); + vals[15] = ctx->args()[15].toNumber(); const void *params[] = { vals }; return ctx->engine()->fromVariant(QQml_valueTypeProvider()->createValueType(QMetaType::QMatrix4x4, 1, params)); @@ -459,10 +459,10 @@ If \c factor is not supplied, returns a color 50% lighter than \c baseColor (fac */ ReturnedValue QtObject::method_lighter(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 1 && ctx->d()->callData->argc != 2) + if (ctx->argc() != 1 && ctx->argc() != 2) V4THROW_ERROR("Qt.lighter(): Invalid arguments"); - QVariant v = ctx->engine()->toVariant(ctx->d()->callData->args[0], -1); + QVariant v = ctx->engine()->toVariant(ctx->args()[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -474,8 +474,8 @@ ReturnedValue QtObject::method_lighter(QV4::CallContext *ctx) } qreal factor = 1.5; - if (ctx->d()->callData->argc == 2) - factor = ctx->d()->callData->args[1].toNumber(); + if (ctx->argc() == 2) + factor = ctx->args()[1].toNumber(); return ctx->engine()->fromVariant(QQml_colorProvider()->lighter(v, factor)); } @@ -497,10 +497,10 @@ If \c factor is not supplied, returns a color 50% darker than \c baseColor (fact */ ReturnedValue QtObject::method_darker(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 1 && ctx->d()->callData->argc != 2) + if (ctx->argc() != 1 && ctx->argc() != 2) V4THROW_ERROR("Qt.darker(): Invalid arguments"); - QVariant v = ctx->engine()->toVariant(ctx->d()->callData->args[0], -1); + QVariant v = ctx->engine()->toVariant(ctx->args()[0], -1); if (v.userType() == QVariant::String) { bool ok = false; v = QQmlStringConverters::colorFromString(v.toString(), &ok); @@ -512,8 +512,8 @@ ReturnedValue QtObject::method_darker(QV4::CallContext *ctx) } qreal factor = 2.0; - if (ctx->d()->callData->argc == 2) - factor = ctx->d()->callData->args[1].toNumber(); + if (ctx->argc() == 2) + factor = ctx->args()[1].toNumber(); return ctx->engine()->fromVariant(QQml_colorProvider()->darker(v, factor)); } @@ -544,11 +544,11 @@ ReturnedValue QtObject::method_darker(QV4::CallContext *ctx) */ ReturnedValue QtObject::method_tint(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 2) + if (ctx->argc() != 2) V4THROW_ERROR("Qt.tint(): Invalid arguments"); // base color - QVariant v1 = ctx->engine()->toVariant(ctx->d()->callData->args[0], -1); + QVariant v1 = ctx->engine()->toVariant(ctx->args()[0], -1); if (v1.userType() == QVariant::String) { bool ok = false; v1 = QQmlStringConverters::colorFromString(v1.toString(), &ok); @@ -560,7 +560,7 @@ ReturnedValue QtObject::method_tint(QV4::CallContext *ctx) } // tint color - QVariant v2 = ctx->engine()->toVariant(ctx->d()->callData->args[1], -1); + QVariant v2 = ctx->engine()->toVariant(ctx->args()[1], -1); if (v2.userType() == QVariant::String) { bool ok = false; v2 = QQmlStringConverters::colorFromString(v2.toString(), &ok); @@ -592,20 +592,20 @@ If \a format is not specified, \a date is formatted using */ ReturnedValue QtObject::method_formatDate(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) + if (ctx->argc() < 1 || ctx->argc() > 2) V4THROW_ERROR("Qt.formatDate(): Invalid arguments"); QV4::Scope scope(ctx); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDate date = ctx->engine()->toVariant(ctx->d()->callData->args[0], -1).toDateTime().date(); + QDate date = ctx->engine()->toVariant(ctx->args()[0], -1).toDateTime().date(); QString formattedDate; - if (ctx->d()->callData->argc == 2) { - QV4::ScopedString s(scope, ctx->d()->callData->args[1]); + if (ctx->argc() == 2) { + QV4::ScopedString s(scope, ctx->args()[1]); if (s) { QString format = s->toQString(); formattedDate = date.toString(format); - } else if (ctx->d()->callData->args[1].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[1].asDouble(); + } else if (ctx->args()[1].isNumber()) { + quint32 intFormat = ctx->args()[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDate = date.toString(format); } else { @@ -635,26 +635,26 @@ If \a format is not specified, \a time is formatted using */ ReturnedValue QtObject::method_formatTime(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) + if (ctx->argc() < 1 || ctx->argc() > 2) V4THROW_ERROR("Qt.formatTime(): Invalid arguments"); QV4::Scope scope(ctx); - QVariant argVariant = ctx->engine()->toVariant(ctx->d()->callData->args[0], -1); + QVariant argVariant = ctx->engine()->toVariant(ctx->args()[0], -1); QTime time; - if (ctx->d()->callData->args[0].asDateObject() || (argVariant.type() == QVariant::String)) + if (ctx->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->d()->callData->argc == 2) { - QV4::ScopedString s(scope, ctx->d()->callData->args[1]); + if (ctx->argc() == 2) { + QV4::ScopedString s(scope, ctx->args()[1]); if (s) { QString format = s->toQString(); formattedTime = time.toString(format); - } else if (ctx->d()->callData->args[1].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[1].asDouble(); + } else if (ctx->args()[1].isNumber()) { + quint32 intFormat = ctx->args()[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedTime = time.toString(format); } else { @@ -759,20 +759,20 @@ with the \a format values below to produce the following results: */ ReturnedValue QtObject::method_formatDateTime(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 2) + if (ctx->argc() < 1 || ctx->argc() > 2) V4THROW_ERROR("Qt.formatDateTime(): Invalid arguments"); QV4::Scope scope(ctx); Qt::DateFormat enumFormat = Qt::DefaultLocaleShortDate; - QDateTime dt = ctx->engine()->toVariant(ctx->d()->callData->args[0], -1).toDateTime(); + QDateTime dt = ctx->engine()->toVariant(ctx->args()[0], -1).toDateTime(); QString formattedDt; - if (ctx->d()->callData->argc == 2) { - QV4::ScopedString s(scope, ctx->d()->callData->args[1]); + if (ctx->argc() == 2) { + QV4::ScopedString s(scope, ctx->args()[1]); if (s) { QString format = s->toQString(); formattedDt = dt.toString(format); - } else if (ctx->d()->callData->args[1].isNumber()) { - quint32 intFormat = ctx->d()->callData->args[1].asDouble(); + } else if (ctx->args()[1].isNumber()) { + quint32 intFormat = ctx->args()[1].asDouble(); Qt::DateFormat format = Qt::DateFormat(intFormat); formattedDt = dt.toString(format); } else { @@ -791,7 +791,7 @@ Attempts to open the specified \c target url in an external application, based o */ ReturnedValue QtObject::method_openUrlExternally(QV4::CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) return QV4::Encode(false); QUrl url(Value::fromReturnedValue(method_resolvedUrl(ctx)).toQStringNoThrow()); @@ -806,7 +806,7 @@ ReturnedValue QtObject::method_resolvedUrl(QV4::CallContext *ctx) { QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QUrl url = ctx->engine()->toVariant(ctx->d()->callData->args[0], -1).toUrl(); + QUrl url = ctx->engine()->toVariant(ctx->args()[0], -1).toUrl(); QQmlEngine *e = v8engine->engine(); QQmlEnginePrivate *p = 0; if (e) p = QQmlEnginePrivate::get(e); @@ -827,7 +827,7 @@ Returns a list of the font families available to the application. */ ReturnedValue QtObject::method_fontFamilies(CallContext *ctx) { - if (ctx->d()->callData->argc != 0) + if (ctx->argc() != 0) V4THROW_ERROR("Qt.fontFamilies(): Invalid arguments"); return ctx->engine()->fromVariant(QVariant(QQml_guiProvider()->fontFamilies())); @@ -839,10 +839,10 @@ Returns a hex string of the md5 hash of \c data. */ ReturnedValue QtObject::method_md5(CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_ERROR("Qt.md5(): Invalid arguments"); - QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8(); + QByteArray data = ctx->args()[0].toQStringNoThrow().toUtf8(); QByteArray result = QCryptographicHash::hash(data, QCryptographicHash::Md5); return ctx->d()->engine->newString(QLatin1String(result.toHex()))->asReturnedValue(); } @@ -853,10 +853,10 @@ Binary to ASCII - this function returns a base64 encoding of \c data. */ ReturnedValue QtObject::method_btoa(CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_ERROR("Qt.btoa(): Invalid arguments"); - QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toUtf8(); + QByteArray data = ctx->args()[0].toQStringNoThrow().toUtf8(); return ctx->d()->engine->newString(QLatin1String(data.toBase64()))->asReturnedValue(); } @@ -867,10 +867,10 @@ ASCII to binary - this function returns a base64 decoding of \c data. */ ReturnedValue QtObject::method_atob(CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_ERROR("Qt.atob(): Invalid arguments"); - QByteArray data = ctx->d()->callData->args[0].toQStringNoThrow().toLatin1(); + QByteArray data = ctx->args()[0].toQStringNoThrow().toLatin1(); return ctx->d()->engine->newString(QString::fromUtf8(QByteArray::fromBase64(data)))->asReturnedValue(); } @@ -915,7 +915,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->d()->callData->argc < 2 || ctx->d()->callData->argc > 3) + if (ctx->argc() < 2 || ctx->argc() > 3) V4THROW_ERROR("Qt.createQmlObject(): Invalid arguments"); struct Error { @@ -957,13 +957,13 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) effectiveContext = context->asQQmlContext(); Q_ASSERT(effectiveContext); - QString qml = ctx->d()->callData->args[0].toQStringNoThrow(); + QString qml = ctx->args()[0].toQStringNoThrow(); if (qml.isEmpty()) return QV4::Encode::null(); QUrl url; - if (ctx->d()->callData->argc > 2) - url = QUrl(ctx->d()->callData->args[2].toQStringNoThrow()); + if (ctx->argc() > 2) + url = QUrl(ctx->args()[2].toQStringNoThrow()); else url = QUrl(QLatin1String("inline")); @@ -971,7 +971,7 @@ ReturnedValue QtObject::method_createQmlObject(CallContext *ctx) url = context->resolvedUrl(url); QObject *parentArg = 0; - QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, ctx->d()->callData->args[1]); + QV4::Scoped<QV4::QObjectWrapper> qobjectWrapper(scope, ctx->args()[1]); if (!!qobjectWrapper) parentArg = qobjectWrapper->object(); if (!parentArg) @@ -1047,7 +1047,7 @@ use \l{QtQml::Qt::createQmlObject()}{Qt.createQmlObject()}. */ ReturnedValue QtObject::method_createComponent(CallContext *ctx) { - if (ctx->d()->callData->argc < 1 || ctx->d()->callData->argc > 3) + if (ctx->argc() < 1 || ctx->argc() > 3) return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); Scope scope(ctx); @@ -1061,7 +1061,7 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) if (context->isPragmaLibraryContext) effectiveContext = 0; - QString arg = ctx->d()->callData->args[0].toQStringNoThrow(); + QString arg = ctx->args()[0].toQStringNoThrow(); if (arg.isEmpty()) return QV4::Encode::null(); @@ -1069,23 +1069,23 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) QObject *parentArg = 0; int consumedCount = 1; - if (ctx->d()->callData->argc > 1) { - ScopedValue lastArg(scope, ctx->d()->callData->args[ctx->d()->callData->argc-1]); + if (ctx->argc() > 1) { + ScopedValue lastArg(scope, ctx->args()[ctx->argc()-1]); // The second argument could be the mode enum - if (ctx->d()->callData->args[1].isInteger()) { - int mode = ctx->d()->callData->args[1].integerValue(); + if (ctx->args()[1].isInteger()) { + int mode = ctx->args()[1].integerValue(); if (mode != int(QQmlComponent::PreferSynchronous) && mode != int(QQmlComponent::Asynchronous)) return ctx->engine()->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->d()->callData->argc != 2) || !(lastArg->isObject() || lastArg->isNull())) + if ((ctx->argc() != 2) || !(lastArg->isObject() || lastArg->isNull())) return ctx->engine()->throwError(QStringLiteral("Qt.createComponent(): Invalid arguments")); } - if (consumedCount < ctx->d()->callData->argc) { + if (consumedCount < ctx->argc()) { if (lastArg->isObject()) { Scoped<QObjectWrapper> qobjectWrapper(scope, lastArg); if (qobjectWrapper) @@ -1132,13 +1132,13 @@ ReturnedValue QtObject::method_createComponent(CallContext *ctx) ReturnedValue QtObject::method_locale(CallContext *ctx) { QString code; - if (ctx->d()->callData->argc > 1) + if (ctx->argc() > 1) V4THROW_ERROR("locale() requires 0 or 1 argument"); - if (ctx->d()->callData->argc == 1 && !ctx->d()->callData->args[0].isString()) + if (ctx->argc() == 1 && !ctx->args()[0].isString()) V4THROW_TYPE("locale(): argument (locale code) must be a string"); - if (ctx->d()->callData->argc == 1) - code = ctx->d()->callData->args[0].toQStringNoThrow(); + if (ctx->argc() == 1) + code = ctx->args()[0].toQStringNoThrow(); return QQmlLocale::locale(ctx->engine(), code); } @@ -1219,9 +1219,9 @@ DEFINE_OBJECT_VTABLE(QQmlBindingFunction); */ ReturnedValue QtObject::method_binding(CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_ERROR("binding() requires 1 argument"); - QV4::FunctionObject *f = ctx->d()->callData->args[0].asFunctionObject(); + QV4::FunctionObject *f = ctx->args()[0].asFunctionObject(); if (!f) V4THROW_TYPE("binding(): argument (binding expression) must be a function"); @@ -1232,7 +1232,7 @@ ReturnedValue QtObject::method_binding(CallContext *ctx) ReturnedValue QtObject::method_get_platform(CallContext *ctx) { // ### inefficient. Should be just a value based getter - Object *o = ctx->d()->callData->thisObject.asObject(); + Object *o = ctx->thisObject().asObject(); if (!o) return ctx->engine()->throwTypeError(); QtObject *qt = o->as<QtObject>(); @@ -1249,7 +1249,7 @@ ReturnedValue QtObject::method_get_platform(CallContext *ctx) ReturnedValue QtObject::method_get_application(CallContext *ctx) { // ### inefficient. Should be just a value based getter - Object *o = ctx->d()->callData->thisObject.asObject(); + Object *o = ctx->thisObject().asObject(); if (!o) return ctx->engine()->throwTypeError(); QtObject *qt = o->as<QtObject>(); @@ -1340,14 +1340,14 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *c QString result; QV4::ExecutionEngine *v4 = ctx->d()->engine; - for (int i = 0; i < ctx->d()->callData->argc; ++i) { + for (int i = 0; i < ctx->argc(); ++i) { if (i != 0) result.append(QLatin1Char(' ')); - if (ctx->d()->callData->args[i].asArrayObject()) - result.append(QStringLiteral("[") + ctx->d()->callData->args[i].toQStringNoThrow() + QStringLiteral("]")); + if (ctx->args()[i].asArrayObject()) + result.append(QStringLiteral("[") + ctx->args()[i].toQStringNoThrow() + QStringLiteral("]")); else - result.append(ctx->d()->callData->args[i].toQStringNoThrow()); + result.append(ctx->args()[i].toQStringNoThrow()); } if (printStack) { @@ -1442,24 +1442,24 @@ QV4::ReturnedValue ConsoleObject::method_profileEnd(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_time(CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_ERROR("console.time(): Invalid arguments"); QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QString name = ctx->d()->callData->args[0].toQStringNoThrow(); + QString name = ctx->args()[0].toQStringNoThrow(); v8engine->startTimer(name); return QV4::Encode::undefined(); } QV4::ReturnedValue ConsoleObject::method_timeEnd(CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_ERROR("console.time(): Invalid arguments"); QV8Engine *v8engine = ctx->d()->engine->v8Engine; - QString name = ctx->d()->callData->args[0].toQStringNoThrow(); + QString name = ctx->args()[0].toQStringNoThrow(); bool wasRunning; qint64 elapsed = v8engine->stopTimer(name, &wasRunning); if (wasRunning) { @@ -1472,8 +1472,8 @@ QV4::ReturnedValue ConsoleObject::method_count(CallContext *ctx) { // first argument: name to print. Ignore any additional arguments QString name; - if (ctx->d()->callData->argc > 0) - name = ctx->d()->callData->args[0].toQStringNoThrow(); + if (ctx->argc() > 0) + name = ctx->args()[0].toQStringNoThrow(); QV4::ExecutionEngine *v4 = ctx->d()->engine; QV8Engine *v8engine = ctx->d()->engine->v8Engine; @@ -1494,7 +1494,7 @@ QV4::ReturnedValue ConsoleObject::method_count(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_trace(CallContext *ctx) { - if (ctx->d()->callData->argc != 0) + if (ctx->argc() != 0) V4THROW_ERROR("console.trace(): Invalid arguments"); QV4::ExecutionEngine *v4 = ctx->d()->engine; @@ -1516,18 +1516,18 @@ QV4::ReturnedValue ConsoleObject::method_warn(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_assert(CallContext *ctx) { - if (ctx->d()->callData->argc == 0) + if (ctx->argc() == 0) V4THROW_ERROR("console.assert(): Missing argument"); QV4::ExecutionEngine *v4 = ctx->d()->engine; - if (!ctx->d()->callData->args[0].toBoolean()) { + if (!ctx->args()[0].toBoolean()) { QString message; - for (int i = 1; i < ctx->d()->callData->argc; ++i) { + for (int i = 1; i < ctx->argc(); ++i) { if (i != 1) message.append(QLatin1Char(' ')); - message.append(ctx->d()->callData->args[i].toQStringNoThrow()); + message.append(ctx->args()[i].toQStringNoThrow()); } QString stack = jsStack(v4); @@ -1543,7 +1543,7 @@ QV4::ReturnedValue ConsoleObject::method_assert(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_exception(CallContext *ctx) { - if (ctx->d()->callData->argc == 0) + if (ctx->argc() == 0) V4THROW_ERROR("console.exception(): Missing argument"); writeToConsole(Error, ctx, true); @@ -1601,29 +1601,29 @@ void QV4::GlobalExtensions::init(QQmlEngine *qmlEngine, Object *globalObject) */ ReturnedValue GlobalExtensions::method_qsTranslate(CallContext *ctx) { - if (ctx->d()->callData->argc < 2) + if (ctx->argc() < 2) V4THROW_ERROR("qsTranslate() requires at least two arguments"); - if (!ctx->d()->callData->args[0].isString()) + if (!ctx->args()[0].isString()) V4THROW_ERROR("qsTranslate(): first argument (context) must be a string"); - if (!ctx->d()->callData->args[1].isString()) + if (!ctx->args()[1].isString()) V4THROW_ERROR("qsTranslate(): second argument (sourceText) must be a string"); - if ((ctx->d()->callData->argc > 2) && !ctx->d()->callData->args[2].isString()) + if ((ctx->argc() > 2) && !ctx->args()[2].isString()) V4THROW_ERROR("qsTranslate(): third argument (disambiguation) must be a string"); - QString context = ctx->d()->callData->args[0].toQStringNoThrow(); - QString text = ctx->d()->callData->args[1].toQStringNoThrow(); + QString context = ctx->args()[0].toQStringNoThrow(); + QString text = ctx->args()[1].toQStringNoThrow(); QString comment; - if (ctx->d()->callData->argc > 2) comment = ctx->d()->callData->args[2].toQStringNoThrow(); + if (ctx->argc() > 2) comment = ctx->args()[2].toQStringNoThrow(); int i = 3; - if (ctx->d()->callData->argc > i && ctx->d()->callData->args[i].isString()) { + if (ctx->argc() > i && ctx->args()[i].isString()) { qWarning("qsTranslate(): specifying the encoding as fourth argument is deprecated"); ++i; } int n = -1; - if (ctx->d()->callData->argc > i) - n = ctx->d()->callData->args[i].toInt32(); + if (ctx->argc() > i) + n = ctx->args()[i].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), @@ -1657,9 +1657,9 @@ ReturnedValue GlobalExtensions::method_qsTranslate(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(CallContext *ctx) { - if (ctx->d()->callData->argc < 2) + if (ctx->argc() < 2) return QV4::Encode::undefined(); - return ctx->d()->callData->args[1].asReturnedValue(); + return ctx->args()[1].asReturnedValue(); } /*! @@ -1681,13 +1681,13 @@ ReturnedValue GlobalExtensions::method_qsTranslateNoOp(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx) { - if (ctx->d()->callData->argc < 1) + if (ctx->argc() < 1) V4THROW_ERROR("qsTr() requires at least one argument"); - if (!ctx->d()->callData->args[0].isString()) + if (!ctx->args()[0].isString()) V4THROW_ERROR("qsTr(): first argument (sourceText) must be a string"); - if ((ctx->d()->callData->argc > 1) && !ctx->d()->callData->args[1].isString()) + if ((ctx->argc() > 1) && !ctx->args()[1].isString()) V4THROW_ERROR("qsTr(): second argument (disambiguation) must be a string"); - if ((ctx->d()->callData->argc > 2) && !ctx->d()->callData->args[2].isNumber()) + if ((ctx->argc() > 2) && !ctx->args()[2].isNumber()) V4THROW_ERROR("qsTr(): third argument (n) must be a number"); Scope scope(ctx); @@ -1719,13 +1719,13 @@ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx) } } - QString text = ctx->d()->callData->args[0].toQStringNoThrow(); + QString text = ctx->args()[0].toQStringNoThrow(); QString comment; - if (ctx->d()->callData->argc > 1) - comment = ctx->d()->callData->args[1].toQStringNoThrow(); + if (ctx->argc() > 1) + comment = ctx->args()[1].toQStringNoThrow(); int n = -1; - if (ctx->d()->callData->argc > 2) - n = ctx->d()->callData->args[2].toInt32(); + if (ctx->argc() > 2) + n = ctx->args()[2].toInt32(); QString result = QCoreApplication::translate(context.toUtf8().constData(), text.toUtf8().constData(), comment.toUtf8().constData(), n); @@ -1757,9 +1757,9 @@ ReturnedValue GlobalExtensions::method_qsTr(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrNoOp(CallContext *ctx) { - if (ctx->d()->callData->argc < 1) + if (ctx->argc() < 1) return QV4::Encode::undefined(); - return ctx->d()->callData->args[0].asReturnedValue(); + return ctx->args()[0].asReturnedValue(); } /*! @@ -1794,18 +1794,18 @@ ReturnedValue GlobalExtensions::method_qsTrNoOp(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrId(CallContext *ctx) { - if (ctx->d()->callData->argc < 1) + if (ctx->argc() < 1) V4THROW_ERROR("qsTrId() requires at least one argument"); - if (!ctx->d()->callData->args[0].isString()) + if (!ctx->args()[0].isString()) V4THROW_TYPE("qsTrId(): first argument (id) must be a string"); - if (ctx->d()->callData->argc > 1 && !ctx->d()->callData->args[1].isNumber()) + if (ctx->argc() > 1 && !ctx->args()[1].isNumber()) V4THROW_TYPE("qsTrId(): second argument (n) must be a number"); int n = -1; - if (ctx->d()->callData->argc > 1) - n = ctx->d()->callData->args[1].toInt32(); + if (ctx->argc() > 1) + n = ctx->args()[1].toInt32(); - return ctx->d()->engine->newString(qtTrId(ctx->d()->callData->args[0].toQStringNoThrow().toUtf8().constData(), n))->asReturnedValue(); + return ctx->d()->engine->newString(qtTrId(ctx->args()[0].toQStringNoThrow().toUtf8().constData(), n))->asReturnedValue(); } /*! @@ -1826,9 +1826,9 @@ ReturnedValue GlobalExtensions::method_qsTrId(CallContext *ctx) */ ReturnedValue GlobalExtensions::method_qsTrIdNoOp(CallContext *ctx) { - if (ctx->d()->callData->argc < 1) + if (ctx->argc() < 1) return QV4::Encode::undefined(); - return ctx->d()->callData->args[0].asReturnedValue(); + return ctx->args()[0].asReturnedValue(); } #endif // QT_NO_TRANSLATION @@ -1844,13 +1844,13 @@ QV4::ReturnedValue GlobalExtensions::method_gc(CallContext *ctx) ReturnedValue GlobalExtensions::method_string_arg(CallContext *ctx) { - if (ctx->d()->callData->argc != 1) + if (ctx->argc() != 1) V4THROW_ERROR("String.arg(): Invalid arguments"); - QString value = ctx->d()->callData->thisObject.toQString(); + QString value = ctx->thisObject().toQString(); QV4::Scope scope(ctx); - QV4::ScopedValue arg(scope, ctx->d()->callData->args[0]); + QV4::ScopedValue arg(scope, ctx->args()[0]); if (arg->isInteger()) return ctx->d()->engine->newString(value.arg(arg->integerValue()))->asReturnedValue(); else if (arg->isDouble()) diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp index 96f5b008b1..81210b2036 100644 --- a/src/qml/types/qqmldelegatemodel.cpp +++ b/src/qml/types/qqmldelegatemodel.cpp @@ -1802,7 +1802,7 @@ int QQmlDelegateModelItemMetaType::parseGroups(const QV4::Value &groups) const QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); if (!o->d()->item->metaType->model) @@ -1814,7 +1814,7 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_model(QV4::CallContext *ctx) QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -1830,17 +1830,17 @@ QV4::ReturnedValue QQmlDelegateModelItem::get_groups(QV4::CallContext *ctx) QV4::ReturnedValue QQmlDelegateModelItem::set_groups(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->d()->callData->argc) + if (!ctx->argc()) return ctx->engine()->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->d()->callData->args[0]); + const int groupFlags = model->m_cacheMetaType->parseGroups(ctx->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); @@ -3236,21 +3236,21 @@ struct QQmlDelegateModelGroupChange : QV4::Object static QV4::ReturnedValue method_get_index(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>()); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->thisObject().as<QQmlDelegateModelGroupChange>()); if (!that) return ctx->engine()->throwTypeError(); return QV4::Encode(that->d()->change.index); } static QV4::ReturnedValue method_get_count(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>()); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->thisObject().as<QQmlDelegateModelGroupChange>()); if (!that) return ctx->engine()->throwTypeError(); return QV4::Encode(that->d()->change.count); } static QV4::ReturnedValue method_get_moveId(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelGroupChange>()); + QV4::Scoped<QQmlDelegateModelGroupChange> that(scope, ctx->thisObject().as<QQmlDelegateModelGroupChange>()); if (!that) return ctx->engine()->throwTypeError(); if (that->d()->change.moveId < 0) diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 651f1f9231..b2767e5dbf 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -277,10 +277,10 @@ QV4::ReturnedValue QQuickWorkerScriptEnginePrivate::method_sendMessage(QV4::Call { WorkerEngine *engine = (WorkerEngine*)ctx->engine()->v8Engine; - int id = ctx->d()->callData->argc > 1 ? ctx->d()->callData->args[1].toInt32() : 0; + int id = ctx->argc() > 1 ? ctx->args()[1].toInt32() : 0; QV4::Scope scope(ctx); - QV4::ScopedValue v(scope, ctx->d()->callData->argument(2)); + QV4::ScopedValue v(scope, ctx->argument(2)); QByteArray data = QV4::Serialize::serialize(v, scope.engine); QMutexLocker locker(&engine->p->m_lock); diff --git a/src/qml/util/qqmladaptormodel.cpp b/src/qml/util/qqmladaptormodel.cpp index 4cf34ae078..a14d397e35 100644 --- a/src/qml/util/qqmladaptormodel.cpp +++ b/src/qml/util/qqmladaptormodel.cpp @@ -58,7 +58,7 @@ V4_DEFINE_EXTENSION(QQmlAdaptorModelEngineData, engineData) static QV4::ReturnedValue get_index(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -190,7 +190,7 @@ public: static QV4::ReturnedValue get_hasModelChildren(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -338,7 +338,7 @@ bool QQmlDMCachedModelData::resolveIndex(const QQmlAdaptorModel &, int idx) QV4::ReturnedValue QQmlDMCachedModelData::get_property(QV4::CallContext *ctx, uint propertyId) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -358,20 +358,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<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->d()->callData->argc) + if (!ctx->argc()) return ctx->engine()->throwTypeError(); if (o->d()->item->index == -1) { QQmlDMCachedModelData *modelData = static_cast<QQmlDMCachedModelData *>(o->d()->item); if (!modelData->cachedData.isEmpty()) { if (modelData->cachedData.count() > 1) { - modelData->cachedData[propertyId] = scope.engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid); + modelData->cachedData[propertyId] = scope.engine->toVariant(ctx->args()[0], QVariant::Invalid); QMetaObject::activate(o->d()->item, o->d()->item->metaObject(), propertyId, 0); } else if (modelData->cachedData.count() == 1) { - modelData->cachedData[0] = scope.engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid); + modelData->cachedData[0] = scope.engine->toVariant(ctx->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); } @@ -580,7 +580,7 @@ public: static QV4::ReturnedValue get_modelData(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); @@ -590,13 +590,13 @@ public: static QV4::ReturnedValue set_modelData(QV4::CallContext *ctx) { QV4::Scope scope(ctx); - QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->d()->callData->thisObject.as<QQmlDelegateModelItemObject>()); + QV4::Scoped<QQmlDelegateModelItemObject> o(scope, ctx->thisObject().as<QQmlDelegateModelItemObject>()); if (!o) return ctx->engine()->throwTypeError(QStringLiteral("Not a valid VisualData object")); - if (!ctx->d()->callData->argc) + if (!ctx->argc()) return ctx->engine()->throwTypeError(); - static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(scope.engine->toVariant(ctx->d()->callData->args[0], QVariant::Invalid)); + static_cast<QQmlDMListAccessorData *>(o->d()->item)->setModelData(scope.engine->toVariant(ctx->args()[0], QVariant::Invalid)); return QV4::Encode::undefined(); } |