diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-24 13:26:38 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-24 13:58:56 +0200 |
commit | 0de6e8bb1bf0ca6e4d7992be15ed31f87514e48a (patch) | |
tree | 29e0e58b32607a5edb6c309dd53645d5af4b8ee9 /src/qml/qml/qqmlproperty.cpp | |
parent | 74632fa02a5bd8653c02a4d84a1bcb6b1d5a88f5 (diff) |
Get rid of Get/SetHiddenValue in the v8 API
It was only used to mark an object as something to be used as a binding.
Simply use one of the free bits in QV4::Managed for that.
Also changed a bit more code over from v8 to v4.
Change-Id: I6e787e611041e058fe109df1d7a13598655f8eba
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlproperty.cpp')
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index f48a7973a1..cb3866a0dc 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -57,6 +57,7 @@ #include "qqmlexpression_p.h" #include "qqmlvaluetypeproxybinding_p.h" #include <private/qjsvalue_p.h> +#include <private/qv4functionobject_p.h> #include <QStringList> #include <private/qmetaobject_p.h> @@ -1459,7 +1460,7 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, const QQmlPropertyData &core, QQmlContextData *context, QQmlJavaScriptExpression *expression, - v8::Handle<v8::Value> result, bool isUndefined, + const QV4::Value &result, bool isUndefined, WriteFlags flags) { Q_ASSERT(object); @@ -1481,22 +1482,22 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, if (!isUndefined && !core.isValueTypeVirtual()) { switch (core.propType) { case QMetaType::Int: - if (result->IsInt32()) - QUICK_STORE(int, result->Int32Value()) - else if (result->IsNumber()) - QUICK_STORE(int, qRound(result->NumberValue())) + if (result.isInteger()) + QUICK_STORE(int, result.integerValue()) + else if (result.isNumber()) + QUICK_STORE(int, qRound(result.doubleValue())) break; case QMetaType::Double: - if (result->IsNumber()) - QUICK_STORE(double, result->NumberValue()) + if (result.isNumber()) + QUICK_STORE(double, result.asDouble()) break; case QMetaType::Float: - if (result->IsNumber()) - QUICK_STORE(float, result->NumberValue()) + if (result.isNumber()) + QUICK_STORE(float, result.asDouble()) break; case QMetaType::QString: - if (result->IsString()) - QUICK_STORE(QString, result->v4Value().toQString()) + if (result.isString()) + QUICK_STORE(QString, result.toQString()) break; default: break; @@ -1513,20 +1514,20 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, if (isUndefined) { } else if (core.isQList()) { - value = v8engine->toVariant(result->v4Value(), qMetaTypeId<QList<QObject *> >()); - } else if (result->IsNull() && core.isQObject()) { + value = v8engine->toVariant(result, qMetaTypeId<QList<QObject *> >()); + } else if (result.isNull() && core.isQObject()) { value = QVariant::fromValue((QObject *)0); } else if (core.propType == qMetaTypeId<QList<QUrl> >()) { - value = resolvedUrlSequence(v8engine->toVariant(result->v4Value(), qMetaTypeId<QList<QUrl> >()), context); + value = resolvedUrlSequence(v8engine->toVariant(result, qMetaTypeId<QList<QUrl> >()), context); } else if (!isVarProperty && type != qMetaTypeId<QJSValue>()) { - value = v8engine->toVariant(result->v4Value(), type); + value = v8engine->toVariant(result, type); } if (expression->hasError()) { return false; } else if (isVarProperty) { - if (!result.IsEmpty() && result->IsFunction() - && !result->ToObject()->GetHiddenValue(v8::Value::fromV4Value(v8engine->bindingFlagKey())).IsEmpty()) { + QV4::FunctionObject *f = result.asFunctionObject(); + if (f && f->bindingKeyFlag) { // 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. expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); @@ -1535,20 +1536,20 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, QQmlVMEMetaObject *vmemo = QQmlVMEMetaObject::get(object); Q_ASSERT(vmemo); - vmemo->setVMEProperty(core.coreIndex, result->v4Value()); + vmemo->setVMEProperty(core.coreIndex, result); } else if (isUndefined && core.isResettable()) { void *args[] = { 0 }; QMetaObject::metacall(object, QMetaObject::ResetProperty, core.coreIndex, args); } else if (isUndefined && type == qMetaTypeId<QVariant>()) { writeValueProperty(object, core, QVariant(), context, flags); } else if (type == qMetaTypeId<QJSValue>()) { - if (!result.IsEmpty() && result->IsFunction() - && !result->ToObject()->GetHiddenValue(v8::Value::fromV4Value(v8engine->bindingFlagKey())).IsEmpty()) { + QV4::FunctionObject *f = result.asFunctionObject(); + if (f && f->bindingKeyFlag) { expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); return false; } writeValueProperty(object, core, QVariant::fromValue( - QJSValue(new QJSValuePrivate(QV8Engine::getV4(v8engine), result->v4Value()))), + QJSValue(new QJSValuePrivate(QV8Engine::getV4(v8engine), result))), context, flags); } else if (isUndefined) { QString errorStr = QLatin1String("Unable to assign [undefined] to "); @@ -1558,8 +1559,8 @@ bool QQmlPropertyPrivate::writeBinding(QObject *object, errorStr += QLatin1String(QMetaType::typeName(type)); expression->delayedError()->setErrorDescription(errorStr); return false; - } else if (result->IsFunction()) { - if (!result->ToObject()->GetHiddenValue(v8::Value::fromV4Value(v8engine->bindingFlagKey())).IsEmpty()) + } else if (QV4::FunctionObject *f = result.asFunctionObject()) { + if (f->bindingKeyFlag) expression->delayedError()->setErrorDescription(QLatin1String("Invalid use of Qt.binding() in a binding declaration.")); else expression->delayedError()->setErrorDescription(QLatin1String("Unable to assign a function to a property of any type other than var.")); |