From 484abc815993040a3be60c657e079eee368bbcd2 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 13 Feb 2015 13:56:05 +0100 Subject: [PATCH] Get rid of asFunctionObject() Change-Id: Ib4858376dc0ec57fa473c80696abc66a570c90ec Reviewed-by: Simon Hausmann --- src/imports/localstorage/plugin.cpp | 4 ++-- src/qml/jsapi/qjsvalue.cpp | 8 ++++---- src/qml/jsruntime/qv4dateobject.cpp | 2 +- src/qml/jsruntime/qv4engine.cpp | 6 +++--- src/qml/jsruntime/qv4functionobject.cpp | 8 ++++---- src/qml/jsruntime/qv4functionobject_p.h | 15 +++++++++------ src/qml/jsruntime/qv4include.cpp | 4 ++-- src/qml/jsruntime/qv4jsonobject.cpp | 10 +++++----- src/qml/jsruntime/qv4managed_p.h | 6 ------ src/qml/jsruntime/qv4objectproto.cpp | 4 ++-- src/qml/jsruntime/qv4qobjectwrapper.cpp | 2 +- src/qml/jsruntime/qv4regexpobject.cpp | 2 +- src/qml/jsruntime/qv4runtime.cpp | 10 +++++----- src/qml/jsruntime/qv4sequenceobject.cpp | 2 +- src/qml/jsruntime/qv4serialize.cpp | 2 +- src/qml/jsruntime/qv4stringobject.cpp | 4 ++-- src/qml/jsruntime/qv4value_inl_p.h | 5 ----- src/qml/jsruntime/qv4value_p.h | 2 -- src/qml/qml/qqmlbinding.cpp | 4 ++-- src/qml/qml/qqmlcomponent.cpp | 4 ++-- src/qml/qml/qqmljavascriptexpression.cpp | 2 +- src/qml/qml/qqmlproperty.cpp | 6 +++--- src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 4 ++-- src/qml/qml/v8/qqmlbuiltinfunctions_p.h | 2 +- src/qmltest/quicktestresult.cpp | 2 +- 25 files changed, 55 insertions(+), 65 deletions(-) diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index c2335c8..239bda8 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -432,7 +432,7 @@ static ReturnedValue qmlsqldatabase_transaction_shared(CallContext *ctx, bool re if (!r || r->d()->type != Heap::QQmlSqlDatabaseWrapper::Database) V4THROW_REFERENCE("Not a SQLDatabase object"); - FunctionObject *callback = ctx->argc() ? ctx->args()[0].asFunctionObject() : 0; + const FunctionObject *callback = ctx->argc() ? ctx->args()[0].as() : 0; if (!callback) V4THROW_SQL(SQLEXCEPTION_UNKNOWN_ERR, QQmlEngine::tr("transaction: missing callback")); @@ -672,7 +672,7 @@ void QQuickLocalStorage::openDatabaseSync(QQmlV4Function *args) QString dbversion = (v = (*args)[1])->toQStringNoThrow(); QString dbdescription = (v = (*args)[2])->toQStringNoThrow(); int dbestimatedsize = (v = (*args)[3])->toInt32(); - FunctionObject *dbcreationCallback = (v = (*args)[4])->asFunctionObject(); + FunctionObject *dbcreationCallback = (v = (*args)[4])->as(); QCryptographicHash md5(QCryptographicHash::Md5); md5.addData(dbname.toUtf8()); diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index 5a0ee10..f6031d4 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -361,7 +361,7 @@ bool QJSValue::isCallable() const QV4::Value *val = QJSValuePrivate::getValue(this); if (!val) return false; - return val->asFunctionObject(); + return val->as(); } /*! @@ -626,7 +626,7 @@ QJSValue QJSValue::call(const QJSValueList &args) if (!val) return QJSValue(); - FunctionObject *f = val->asFunctionObject(); + FunctionObject *f = val->as(); if (!f) return QJSValue(); @@ -677,7 +677,7 @@ QJSValue QJSValue::callWithInstance(const QJSValue &instance, const QJSValueList if (!val) return QJSValue(); - FunctionObject *f = val->asFunctionObject(); + FunctionObject *f = val->as(); if (!f) return QJSValue(); @@ -731,7 +731,7 @@ QJSValue QJSValue::callAsConstructor(const QJSValueList &args) if (!val) return QJSValue(); - FunctionObject *f = val->asFunctionObject(); + FunctionObject *f = val->as(); if (!f) return QJSValue(); diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 7804007..cb48f08 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -1297,7 +1297,7 @@ ReturnedValue DatePrototype::method_toJSON(CallContext *ctx) ScopedString s(scope, ctx->d()->engine->newString(QStringLiteral("toISOString"))); ScopedValue v(scope, O->objectValue()->get(s)); - FunctionObject *toIso = v->asFunctionObject(); + FunctionObject *toIso = v->as(); if (!toIso) return ctx->engine()->throwTypeError(); diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 7e80bf0..9b9a234 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -410,7 +410,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory) globalObject()->defineDefaultProperty(QStringLiteral("DataView"), dataViewCtor); ScopedString str(scope); for (int i = 0; i < Heap::TypedArray::NTypes; ++i) - globalObject()->defineDefaultProperty((str = typedArrayCtors[i].asFunctionObject()->name())->toQString(), typedArrayCtors[i]); + globalObject()->defineDefaultProperty((str = typedArrayCtors[i].as()->name())->toQString(), typedArrayCtors[i]); ScopedObject o(scope); globalObject()->defineDefaultProperty(QStringLiteral("Math"), (o = memoryManager->alloc(this))); globalObject()->defineDefaultProperty(QStringLiteral("JSON"), (o = memoryManager->alloc(this))); @@ -1199,7 +1199,7 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int if (value.as()) { QV4::ScopedObject object(scope, value); if (typeHint == QMetaType::QJsonObject - && !value.as() && !value.asFunctionObject()) { + && !value.as() && !value.as()) { return QVariant::fromValue(QV4::JsonObject::toJsonObject(object)); } else if (QV4::QObjectWrapper *wrapper = object->as()) { return qVariantFromValue(wrapper->object()); @@ -1303,7 +1303,7 @@ static QVariant objectToVariant(QV4::ExecutionEngine *e, QV4::Object *o, V4Objec } result = list; - } else if (!o->asFunctionObject()) { + } else if (!o->as()) { QVariantMap map; QV4::Scope scope(e); QV4::ObjectIterator it(scope, o, QV4::ObjectIterator::EnumerableOnly); diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 3cb8a6c..f5db520 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -157,7 +157,7 @@ void FunctionObject::init(String *n, bool createProto) defineReadonlyProperty(s.engine->id_name, v); } -ReturnedValue FunctionObject::name() +ReturnedValue FunctionObject::name() const { return get(scope()->engine->id_name); } @@ -298,7 +298,7 @@ void FunctionPrototype::init(ExecutionEngine *engine, Object *ctor) ReturnedValue FunctionPrototype::method_toString(CallContext *ctx) { - FunctionObject *fun = ctx->thisObject().asFunctionObject(); + FunctionObject *fun = ctx->thisObject().as(); if (!fun) return ctx->engine()->throwTypeError(); @@ -308,7 +308,7 @@ ReturnedValue FunctionPrototype::method_toString(CallContext *ctx) ReturnedValue FunctionPrototype::method_apply(CallContext *ctx) { Scope scope(ctx); - ScopedFunctionObject o(scope, ctx->thisObject().asFunctionObject()); + ScopedFunctionObject o(scope, ctx->thisObject().as()); if (!o) return ctx->engine()->throwTypeError(); @@ -350,7 +350,7 @@ ReturnedValue FunctionPrototype::method_call(CallContext *ctx) { Scope scope(ctx); - ScopedFunctionObject o(scope, ctx->thisObject().asFunctionObject()); + ScopedFunctionObject o(scope, ctx->thisObject().as()); if (!o) return ctx->engine()->throwTypeError(); diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 094d180..108790a 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -114,7 +114,7 @@ struct Q_QML_EXPORT FunctionObject: Object { Heap::ExecutionContext *scope() const { return d()->scope; } Function *function() const { return d()->function; } - ReturnedValue name(); + ReturnedValue name() const; unsigned int formalParameterCount() { return d()->formalParameterCount(); } unsigned int varCount() { return d()->varCount(); } @@ -127,10 +127,6 @@ struct Q_QML_EXPORT FunctionObject: Object { static ReturnedValue construct(const Managed *that, CallData *); static ReturnedValue call(const Managed *that, CallData *d); - static FunctionObject *cast(const Value &v) { - return v.asFunctionObject(); - } - static Heap::FunctionObject *createScriptFunction(ExecutionContext *scope, Function *function, bool createProto = true); ReturnedValue protoProperty() { return memberData()->data[Heap::FunctionObject::Index_Prototype].asReturnedValue(); } @@ -145,9 +141,16 @@ struct Q_QML_EXPORT FunctionObject: Object { template<> inline const FunctionObject *Value::as() const { - return asFunctionObject(); + return isManaged() && m && m->vtable->isFunctionObject ? reinterpret_cast(this) : 0; } +template<> +inline FunctionObject *managed_cast(Managed *m) +{ + return m ? m->as() : 0; +} + + struct FunctionCtor: FunctionObject { V4_OBJECT2(FunctionCtor, FunctionObject) diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 2b44275..ed7ace9 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -54,7 +54,7 @@ QV4Include::QV4Include(const QUrl &url, QV4::ExecutionEngine *engine, QQmlContex : v4(engine), m_network(0), m_reply(0), m_url(url), m_redirectCount(0), m_context(context) { m_qmlglobal.set(engine, qmlglobal); - if (callback.asFunctionObject()) + if (callback.as()) m_callbackFunction.set(engine, callback); m_resultObject.set(v4, resultValue(v4)); @@ -184,7 +184,7 @@ QV4::ReturnedValue QV4Include::method_include(QV4::CallContext *ctx) QUrl url(scope.engine->resolvedUrl(ctx->args()[0].toQStringNoThrow())); QV4::ScopedValue callbackFunction(scope, QV4::Primitive::undefinedValue()); - if (ctx->argc() >= 2 && ctx->args()[1].asFunctionObject()) + if (ctx->argc() >= 2 && ctx->args()[1].as()) callbackFunction = ctx->args()[1]; QString localFile = QQmlFile::urlToLocalFileOrQrc(url); diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 8af9c19..74a2532 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -722,7 +722,7 @@ QString Stringify::Str(const QString &key, const Value &v) o = value->asReturnedValue(); if (o) { - if (!o->asFunctionObject()) { + if (!o->as()) { if (o->as()) { return JA(static_cast(o.getPointer())); } else { @@ -887,7 +887,7 @@ ReturnedValue JsonObject::method_stringify(CallContext *ctx) ScopedObject o(scope, ctx->argument(1)); if (o) { - stringify.replacerFunction = o->asFunctionObject(); + stringify.replacerFunction = o->as(); if (o->isArrayObject()) { uint arrayLen = o->getLength(); ScopedValue v(scope); @@ -984,7 +984,7 @@ QV4::ReturnedValue JsonObject::fromJsonObject(ExecutionEngine *engine, const QJs QJsonObject JsonObject::toJsonObject(Object *o, V4ObjectSet &visitedObjects) { QJsonObject result; - if (!o || o->asFunctionObject()) + if (!o || o->as()) return result; Scope scope(o->engine()); @@ -1007,7 +1007,7 @@ QJsonObject JsonObject::toJsonObject(Object *o, V4ObjectSet &visitedObjects) break; QString key = name->toQStringNoThrow(); - if (!val->asFunctionObject()) + if (!val->as()) result.insert(key, toJsonValue(val, visitedObjects)); } @@ -1050,7 +1050,7 @@ QJsonArray JsonObject::toJsonArray(ArrayObject *a, V4ObjectSet &visitedObjects) quint32 length = a->getLength(); for (quint32 i = 0; i < length; ++i) { v = a->getIndexed(i); - if (v->asFunctionObject()) + if (v->as()) v = Encode::null(); result.append(toJsonValue(v, visitedObjects)); } diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h index 6716662..ebbd2d6 100644 --- a/src/qml/jsruntime/qv4managed_p.h +++ b/src/qml/jsruntime/qv4managed_p.h @@ -150,7 +150,6 @@ public: }; Q_MANAGED_TYPE(Invalid) - FunctionObject *asFunctionObject() { return d()->vtable->isFunctionObject ? reinterpret_cast(this) : 0; } BooleanObject *asBooleanObject() { return d()->vtable->type == Type_BooleanObject ? reinterpret_cast(this) : 0; } ArgumentsObject *asArgumentsObject() { return d()->vtable->type == Type_ArgumentsObject ? reinterpret_cast(this) : 0; } @@ -205,11 +204,6 @@ inline Object *managed_cast(Managed *m) { return m ? m->as() : 0; } -template<> -inline FunctionObject *managed_cast(Managed *m) -{ - return m ? m->asFunctionObject() : 0; -} } diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index cc59ee0..8324a1a 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -580,7 +580,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value if (o->hasProperty(engine->id_get)) { ScopedValue get(scope, o->get(engine->id_get)); - FunctionObject *f = get->asFunctionObject(); + FunctionObject *f = get->as(); if (f || get->isUndefined()) { desc->value = get; } else { @@ -592,7 +592,7 @@ void ObjectPrototype::toPropertyDescriptor(ExecutionEngine *engine, const Value if (o->hasProperty(engine->id_set)) { ScopedValue set(scope, o->get(engine->id_set)); - FunctionObject *f = set->asFunctionObject(); + FunctionObject *f = set->as(); if (f || set->isUndefined()) { desc->set = set; } else { diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 5b8d35f..34414cd 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -520,7 +520,7 @@ void QObjectWrapper::setProperty(QObject *object, ExecutionContext *ctx, QQmlPro error += QLatin1String(QMetaType::typeName(property->propType)); ctx->engine()->throwError(error); return; - } else if (value.asFunctionObject()) { + } else if (value.as()) { // this is handled by the binding creation above } else if (property->propType == QMetaType::Int && value.isNumber()) { PROPERTY_STORE(int, value.asDouble()); diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index f6e558c..1948d04 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -425,7 +425,7 @@ ReturnedValue RegExpPrototype::method_compile(CallContext *ctx) ScopedCallData callData(scope, ctx->argc()); memcpy(callData->args, ctx->args(), ctx->argc()*sizeof(Value)); - Scoped re(scope, ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData)); + Scoped re(scope, ctx->d()->engine->regExpCtor.as()->construct(callData)); r->d()->value = re->value(); r->d()->global = re->global(); diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 008bc30..ae618ce 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -314,7 +314,7 @@ ReturnedValue Runtime::deleteName(ExecutionEngine *engine, int nameIndex) QV4::ReturnedValue Runtime::instanceof(ExecutionEngine *engine, const Value &left, const Value &right) { Scope scope(engine); - ScopedFunctionObject f(scope, right.asFunctionObject()); + ScopedFunctionObject f(scope, right.as()); if (!f) return engine->throwTypeError(); @@ -405,7 +405,7 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH callData->thisObject = *object; ScopedValue conv(scope, object->get(*meth1)); - if (FunctionObject *o = conv->asFunctionObject()) { + if (FunctionObject *o = conv->as()) { ScopedValue r(scope, o->call(callData)); if (r->isPrimitive()) return r->asReturnedValue(); @@ -415,7 +415,7 @@ ReturnedValue RuntimeHelpers::objectDefaultValue(const Object *object, int typeH return Encode::undefined(); conv = object->get(*meth2); - if (FunctionObject *o = conv->asFunctionObject()) { + if (FunctionObject *o = conv->as()) { ScopedValue r(scope, o->call(callData)); if (r->isPrimitive()) return r->asReturnedValue(); @@ -932,7 +932,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameI if (base) callData->thisObject = base; - FunctionObject *o = func->asFunctionObject(); + FunctionObject *o = func->as(); if (!o) { QString objectAsString = QStringLiteral("[null]"); if (base) @@ -1101,7 +1101,7 @@ ReturnedValue Runtime::typeofValue(ExecutionEngine *engine, const Value &value) case Value::Managed_Type: if (value.isString()) res = engine->id_string; - else if (value.objectValue()->asFunctionObject()) + else if (value.objectValue()->as()) res = engine->id_function; else res = engine->id_object; // ### implementation-defined diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index b1f2b69..79bd1db 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -419,7 +419,7 @@ public: } QV4::Scope scope(ctx); - if (ctx->argc() == 1 && ctx->args()[0].asFunctionObject()) { + if (ctx->argc() == 1 && ctx->args()[0].as()) { CompareFunctor cf(ctx, ctx->args()[0]); std::sort(d()->container.begin(), d()->container.end(), cf); } else { diff --git a/src/qml/jsruntime/qv4serialize.cpp b/src/qml/jsruntime/qv4serialize.cpp index a13b8b2..ddd7555 100644 --- a/src/qml/jsruntime/qv4serialize.cpp +++ b/src/qml/jsruntime/qv4serialize.cpp @@ -168,7 +168,7 @@ void Serialize::serialize(QByteArray &data, const QV4::Value &v, ExecutionEngine char *buffer = data.data() + offset; memcpy(buffer, qstr.constData(), length*sizeof(QChar)); - } else if (v.asFunctionObject()) { + } else if (v.as()) { // XXX TODO: Implement passing function objects between the main and // worker scripts push(data, valueheader(WorkerUndefined)); diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index 99911a9..f4a6e45 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -368,7 +368,7 @@ ReturnedValue StringPrototype::method_match(CallContext *context) if (!rx) { ScopedCallData callData(scope, 1); callData->args[0] = regexp; - rx = context->d()->engine->regExpCtor.asFunctionObject()->construct(callData); + rx = context->d()->engine->regExpCtor.as()->construct(callData); } if (!rx) @@ -593,7 +593,7 @@ ReturnedValue StringPrototype::method_search(CallContext *ctx) if (!regExp) { ScopedCallData callData(scope, 1); callData->args[0] = regExpValue; - regExpValue = ctx->d()->engine->regExpCtor.asFunctionObject()->construct(callData); + regExpValue = ctx->d()->engine->regExpCtor.as()->construct(callData); if (scope.engine->hasException) return Encode::undefined(); regExp = regExpValue->as(); diff --git a/src/qml/jsruntime/qv4value_inl_p.h b/src/qml/jsruntime/qv4value_inl_p.h index 9829b39..d150828 100644 --- a/src/qml/jsruntime/qv4value_inl_p.h +++ b/src/qml/jsruntime/qv4value_inl_p.h @@ -231,11 +231,6 @@ inline uint Value::asArrayLength(bool *ok) const return idx; } -inline FunctionObject *Value::asFunctionObject() const -{ - return isObject() ? managed()->asFunctionObject() : 0; -} - template<> inline ReturnedValue value_convert(ExecutionEngine *e, const Value &v) { diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index 260f3af..7f09fc7 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -304,8 +304,6 @@ struct Q_QML_PRIVATE_EXPORT Value return b; } - inline FunctionObject *asFunctionObject() const; - template const T *as() const { if (!m || !isManaged()) diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 157aa76..44bbe14 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -180,7 +180,7 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) lineNumber = loc.line; columnNumber = loc.column; } else { - QV4::Function *function = f->asFunctionObject()->function(); + QV4::Function *function = f->as()->function(); Q_ASSERT(function); url = function->sourceFile(); @@ -266,7 +266,7 @@ QString QQmlBinding::expressionIdentifier(QQmlJavaScriptExpression *e) QQmlEnginePrivate *ep = QQmlEnginePrivate::get(This->context()->engine); QV4::Scope scope(ep->v4engine()); QV4::ScopedValue f(scope, This->v4function.value()); - QV4::Function *function = f->asFunctionObject()->function(); + QV4::Function *function = f->as()->function(); QString url = function->sourceFile(); quint16 lineNumber = function->compiledFunction->location.line; diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index f605bbf..881726c 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -1242,12 +1242,12 @@ void QQmlComponent::createObject(QQmlV4Function *args) if (!valuemap->isUndefined()) { QV4::ScopedObject qmlglobal(scope, args->qmlGlobal()); QV4::ScopedValue f(scope, QV4::Script::evaluate(v4, QString::fromLatin1(INITIALPROPERTIES_SOURCE), qmlglobal)); - Q_ASSERT(f->asFunctionObject()); + Q_ASSERT(f->as()); QV4::ScopedCallData callData(scope, 2); callData->thisObject = v4->globalObject(); callData->args[0] = object; callData->args[1] = valuemap; - f->asFunctionObject()->call(callData); + f->as()->call(callData); } d->completeCreate(); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 3ac0f23..6411b56 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -154,7 +154,7 @@ QV4::ReturnedValue QQmlJavaScriptExpression::evaluate(QQmlContextData *context, callData->thisObject = value; } - result = function.asFunctionObject()->call(callData); + result = function.as()->call(callData); if (scope.hasException()) { if (watcher.wasDeleted()) scope.engine->catchException(); // ignore exception diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 931adb9..aef2bf0 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -1545,7 +1545,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, if (expression->hasError()) { return false; } else if (isVarProperty) { - QV4::FunctionObject *f = result.asFunctionObject(); + const QV4::FunctionObject *f = result.as(); if (f && f->isBinding()) { // we explicitly disallow this case to avoid confusion. Users can still store one // in an array in a var property if they need to, but the common case is user error. @@ -1563,7 +1563,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, } else if (isUndefined && type == qMetaTypeId()) { writeValueProperty(object, core, QVariant(), context, flags); } else if (type == qMetaTypeId()) { - QV4::FunctionObject *f = result.asFunctionObject(); + const QV4::FunctionObject *f = result.as(); if (f && f->isBinding()) { expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); expression->delayedError()->setErrorObject(object); @@ -1581,7 +1581,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, expression->delayedError()->setErrorDescription(errorStr); expression->delayedError()->setErrorObject(object); return false; - } else if (QV4::FunctionObject *f = result.asFunctionObject()) { + } else if (const QV4::FunctionObject *f = result.as()) { if (f->isBinding()) expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); else diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 1c64e15..39196e0 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1172,7 +1172,7 @@ ReturnedValue QtObject::method_locale(CallContext *ctx) return QQmlLocale::locale(ctx->engine(), code); } -Heap::QQmlBindingFunction::QQmlBindingFunction(QV4::FunctionObject *originalFunction) +Heap::QQmlBindingFunction::QQmlBindingFunction(const QV4::FunctionObject *originalFunction) : QV4::Heap::FunctionObject(originalFunction->scope(), originalFunction->name()) , originalFunction(originalFunction->d()) { @@ -1250,7 +1250,7 @@ ReturnedValue QtObject::method_binding(CallContext *ctx) { if (ctx->argc() != 1) V4THROW_ERROR("binding() requires 1 argument"); - QV4::FunctionObject *f = ctx->args()[0].asFunctionObject(); + const QV4::FunctionObject *f = ctx->args()[0].as(); if (!f) V4THROW_TYPE("binding(): argument (binding expression) must be a function"); diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h index 6763a74..b1b713d 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions_p.h +++ b/src/qml/qml/v8/qqmlbuiltinfunctions_p.h @@ -68,7 +68,7 @@ struct ConsoleObject : Object { }; struct QQmlBindingFunction : FunctionObject { - QQmlBindingFunction(QV4::FunctionObject *originalFunction); + QQmlBindingFunction(const QV4::FunctionObject *originalFunction); FunctionObject *originalFunction; // Set when the binding is created later QQmlSourceLocation bindingLocation; diff --git a/src/qmltest/quicktestresult.cpp b/src/qmltest/quicktestresult.cpp index 2ead2b8..e405a53 100644 --- a/src/qmltest/quicktestresult.cpp +++ b/src/qmltest/quicktestresult.cpp @@ -486,7 +486,7 @@ void QuickTestResult::stringify(QQmlV4Function *args) //Check for Object Type if (value->isObject() - && !value->asFunctionObject() + && !value->as() && !value->as()) { QVariant v = scope.engine->toVariant(value, QMetaType::UnknownType); if (v.isValid()) { -- 2.7.4