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 | |
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>
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 18 | ||||
-rw-r--r-- | src/qml/qml/qqmlbinding_p.h | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 47 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4managed_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4serialize.cpp | 9 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4v8.cpp | 22 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4v8_p.h | 9 | ||||
-rw-r--r-- | src/qml/qml/v8/qqmlbuiltinfunctions.cpp | 10 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8contextwrapper.cpp | 8 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8contextwrapper_p.h | 4 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8engine_p.h | 12 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8qobjectwrapper.cpp | 5 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8valuetypewrapper.cpp | 5 | ||||
-rw-r--r-- | src/qml/types/qqmllistmodelworkeragent_p.h | 17 | ||||
-rw-r--r-- | src/qml/types/qquickworkerscript.cpp | 2 |
18 files changed, 66 insertions, 125 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index 209fac531d..32b20149e8 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -183,15 +183,7 @@ QQmlBinding::QQmlBinding(const QString &str, QObject *obj, v4function = qmlBinding(ctxt, obj, str, url, m_lineNumber); } -/*! - \internal - - To avoid exposing v8 in the public API, functionPtr must be a pointer to a v8::Handle<v8::Function>. - For example: - v8::Handle<v8::Function> function; - new QQmlBinding(&function, scope, ctxt); - */ -QQmlBinding::QQmlBinding(void *functionPtr, QObject *obj, QQmlContextData *ctxt, +QQmlBinding::QQmlBinding(const QV4::Value &functionPtr, QObject *obj, QQmlContextData *ctxt, const QString &url, quint16 lineNumber, quint16 columnNumber) : QQmlJavaScriptExpression(&QQmlBinding_jsvtable), QQmlAbstractBinding(Binding), m_url(url), m_lineNumber(lineNumber), m_columnNumber(columnNumber) @@ -200,7 +192,7 @@ QQmlBinding::QQmlBinding(void *functionPtr, QObject *obj, QQmlContextData *ctxt, QQmlAbstractExpression::setContext(ctxt); setScopeObject(obj); - v4function = (*(v8::Handle<v8::Function> *)functionPtr)->v4Value(); + v4function = functionPtr; } QQmlBinding::~QQmlBinding() @@ -261,7 +253,7 @@ void QQmlBinding::update(QQmlPropertyPrivate::WriteFlags flags) bool isUndefined = false; - v8::Handle<v8::Value> result = + QV4::Value result = QQmlJavaScriptExpression::evaluate(context(), v4function.value(), &isUndefined); trace.event("writing binding result"); @@ -302,12 +294,12 @@ QVariant QQmlBinding::evaluate() bool isUndefined = false; - v8::Handle<v8::Value> result = + QV4::Value result = QQmlJavaScriptExpression::evaluate(context(), v4function.value(), &isUndefined); ep->dereferenceScarceResources(); - return ep->v8engine()->toVariant(result->v4Value(), qMetaTypeId<QList<QObject*> >()); + return ep->v8engine()->toVariant(result, qMetaTypeId<QList<QObject*> >()); } QString QQmlBinding::expressionIdentifier(QQmlJavaScriptExpression *e) diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 87e9d5eb4e..7b2f84d523 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -70,6 +70,10 @@ QT_BEGIN_NAMESPACE +namespace QV4 { +struct Value; +} + class QQmlContext; class Q_QML_PRIVATE_EXPORT QQmlBinding : public QQmlJavaScriptExpression, public QQmlAbstractExpression, @@ -84,7 +88,7 @@ public: QQmlBinding(const QString &, QObject *, QQmlContextData *); QQmlBinding(const QString &, QObject *, QQmlContextData *, const QString &url, quint16 lineNumber, quint16 columnNumber); - QQmlBinding(void *, QObject *, QQmlContextData *, + QQmlBinding(const QV4::Value &, QObject *, QQmlContextData *, const QString &url, quint16 lineNumber, quint16 columnNumber); void setTarget(const QQmlProperty &); diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 0e733cb1d2..28abf5fa11 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -326,7 +326,7 @@ QQmlJavaScriptExpression::evalFunction(QQmlContextData *ctxt, QObject *scope, QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); QV4::ExecutionContext *ctx = v4->current; - QV4::Value scopeObject = ep->v8engine()->qmlScope(ctxt, scope)->v4Value(); + QV4::Value scopeObject = ep->v8engine()->qmlScope(ctxt, scope); QV4::Script script(v4, scopeObject.asObject(), code, filename, line); QV4::Value result; try { @@ -360,7 +360,7 @@ QV4::PersistentValue QQmlJavaScriptExpression::qmlBinding(QQmlContextData *ctxt, QV4::ExecutionEngine *v4 = QV8Engine::getV4(ep->v8engine()); QV4::ExecutionContext *ctx = v4->current; - QV4::Value scopeObject = ep->v8engine()->qmlScope(ctxt, scope)->v4Value(); + QV4::Value scopeObject = ep->v8engine()->qmlScope(ctxt, scope); QV4::Script script(v4, scopeObject.asObject(), code, filename, line); QV4::Value result; try { 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.")); diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h index e7c850fbdd..6482432a20 100644 --- a/src/qml/qml/qqmlproperty_p.h +++ b/src/qml/qml/qqmlproperty_p.h @@ -148,8 +148,8 @@ public: static bool write(const QQmlProperty &that, const QVariant &, WriteFlags); static bool writeBinding(QObject *, const QQmlPropertyData &, QQmlContextData *context, - QQmlJavaScriptExpression *expression, - v8::Handle<v8::Value> result, bool isUndefined, + QQmlJavaScriptExpression *expression, + const QV4::Value &result, bool isUndefined, WriteFlags flags); static int valueTypeCoreIndex(const QQmlProperty &that); static int bindingIndex(const QQmlProperty &that); diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index ea1316f601..192fc6fd12 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -1153,12 +1153,12 @@ QV4::PersistentValue QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *s if (!script->m_program) return QV4::PersistentValue(); - v8::Handle<v8::Object> qmlglobal = v8engine->qmlScope(ctxt, 0); + QV4::Value qmlglobal = v8engine->qmlScope(ctxt, 0); v8engine->contextWrapper()->takeContextOwnership(qmlglobal); QV4::ExecutionContext *ctx = QV8Engine::getV4(v8engine)->current; try { - script->m_program->qml = qmlglobal->v4Value().asObject(); + script->m_program->qml = qmlglobal.asObject(); script->m_program->run(); } catch (QV4::Exception &e) { e.accept(ctx); @@ -1168,7 +1168,7 @@ QV4::PersistentValue QQmlVME::run(QQmlContextData *parentCtxt, QQmlScriptData *s ep->warning(error); } - rv = qmlglobal->v4Value(); + rv = qmlglobal; if (shared) { script->m_value = rv; script->m_loaded = true; diff --git a/src/qml/qml/v4/qv4managed_p.h b/src/qml/qml/v4/qv4managed_p.h index 4cdbe4d6c5..0dfeb1980e 100644 --- a/src/qml/qml/v4/qv4managed_p.h +++ b/src/qml/qml/v4/qv4managed_p.h @@ -275,7 +275,8 @@ public: uint type : 5; mutable uint subtype : 3; uint externalComparison : 1; - uint unused : 15; + uint bindingKeyFlag : 1; + uint unused : 14; }; }; diff --git a/src/qml/qml/v4/qv4serialize.cpp b/src/qml/qml/v4/qv4serialize.cpp index 17995cde42..4e0efc788f 100644 --- a/src/qml/qml/v4/qv4serialize.cpp +++ b/src/qml/qml/v4/qv4serialize.cpp @@ -358,15 +358,10 @@ QV4::Value Serialize::deserialize(const char *&data, QV8Engine *engine) { void *ptr = popPtr(data); QQmlListModelWorkerAgent *agent = (QQmlListModelWorkerAgent *)ptr; - v8::Handle<v8::Value> rv = engine->newQObject(agent); - if (rv->IsObject()) { - QQmlListModelWorkerAgent::VariantRef ref(agent); - QVariant var = qVariantFromValue(ref); - rv->ToObject()->SetHiddenValue(v8::String::New("qml::ref"), engine->fromVariant(var)); - } + QV4::Value rv = engine->newQObject(agent); agent->release(); agent->setV8Engine(engine); - return rv->v4Value(); + return rv; } case WorkerSequence: { diff --git a/src/qml/qml/v4/qv4v8.cpp b/src/qml/qml/v4/qv4v8.cpp index 18662cceb1..8490d7fb48 100644 --- a/src/qml/qml/v4/qv4v8.cpp +++ b/src/qml/qml/v4/qv4v8.cpp @@ -623,28 +623,6 @@ int Object::GetIdentityHash() return (quintptr)ConstValuePtr(this)->asObject() >> 2; } -bool Object::SetHiddenValue(Handle<String> key, Handle<Value> value) -{ - QV4::Object *o = ConstValuePtr(this)->asObject(); - assert(o); - QString newKey = QStringLiteral("__hidden:"); - newKey += key->asQString(); - QV4::String* str = o->engine()->newString(newKey); - if (o->__hasProperty__(str)) - return false; - o->put(str, value->v4Value()); - return true; -} - -Handle<Value> Object::GetHiddenValue(Handle<String> key) -{ - QV4::Object *o = ConstValuePtr(this)->asObject(); - assert(o); - QString newKey = QStringLiteral("__hidden:"); - newKey += key->asQString(); - return o->get(o->engine()->newString(newKey)); -} - Handle<Object> Object::Clone() { Q_UNIMPLEMENTED(); diff --git a/src/qml/qml/v4/qv4v8_p.h b/src/qml/qml/v4/qv4v8_p.h index bfb1837996..0c3df028db 100644 --- a/src/qml/qml/v4/qv4v8_p.h +++ b/src/qml/qml/v4/qv4v8_p.h @@ -752,15 +752,6 @@ class V8EXPORT Object : public Value { int GetIdentityHash(); /** - * Access hidden properties on JavaScript objects. These properties are - * hidden from the executing JavaScript and only accessible through the V8 - * C++ API. Hidden properties introduced by V8 internally (for example the - * identity hash) are prefixed with "v8::". - */ - bool SetHiddenValue(Handle<String> key, Handle<Value> value); - Handle<Value> GetHiddenValue(Handle<String> key); - - /** * Clone this object with a fast but shallow copy. Values will point * to the same values as the original object. */ diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 31d89b726a..387a23f5a1 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -53,6 +53,7 @@ #include <private/qqmlglobal_p.h> #include <private/qv4engine_p.h> +#include <private/qv4functionobject_p.h> #include <QtCore/qstring.h> #include <QtCore/qdatetime.h> @@ -1584,13 +1585,14 @@ QV4::Value binding(const v8::Arguments &args) QString code; if (args.Length() != 1) V4THROW_ERROR("binding() requires 1 argument"); - if (!args[0]->IsFunction()) + QV4::FunctionObject *f = args[0]->v4Value().asFunctionObject(); + if (!f) V4THROW_TYPE("binding(): argument (binding expression) must be a function"); - v8::Handle<v8::Object> rv = args[0]->ToObject(); - if (!rv->SetHiddenValue(v8::Value::fromV4Value(V8ENGINE()->bindingFlagKey()), QV4::Value::fromBoolean(true))) + if (f->bindingKeyFlag) V4THROW_ERROR("function passed to binding() can only be bound once"); // FIXME: With v8 we cloned the binding argument - return rv->v4Value(); + f->bindingKeyFlag = true; + return QV4::Value::fromObject(f); } } // namespace QQmlBuiltinFunctions diff --git a/src/qml/qml/v8/qv8contextwrapper.cpp b/src/qml/qml/v8/qv8contextwrapper.cpp index b24b71ee29..7bafd78ddc 100644 --- a/src/qml/qml/v8/qv8contextwrapper.cpp +++ b/src/qml/qml/v8/qv8contextwrapper.cpp @@ -170,16 +170,16 @@ void QV8ContextWrapper::init(QV8Engine *engine) } } -v8::Handle<v8::Object> QV8ContextWrapper::qmlScope(QQmlContextData *ctxt, QObject *scope) +QV4::Value QV8ContextWrapper::qmlScope(QQmlContextData *ctxt, QObject *scope) { // XXX NewInstance() should be optimized v8::Handle<v8::Object> rv = m_constructor.value().asFunctionObject()->newInstance(); QV8ContextResource *r = new QV8ContextResource(m_engine, ctxt, scope); rv->SetExternalResource(r); - return rv; + return rv->v4Value(); } -v8::Handle<v8::Object> QV8ContextWrapper::urlScope(const QUrl &url) +QV4::Value QV8ContextWrapper::urlScope(const QUrl &url) { QQmlContextData *context = new QQmlContextData; context->url = url; @@ -190,7 +190,7 @@ v8::Handle<v8::Object> QV8ContextWrapper::urlScope(const QUrl &url) v8::Handle<v8::Object> rv = m_urlConstructor.value().asFunctionObject()->newInstance(); QV8ContextResource *r = new QV8ContextResource(m_engine, context, 0, true); rv->SetExternalResource(r); - return rv; + return rv->v4Value(); } void QV8ContextWrapper::setReadOnly(v8::Handle<v8::Object> qmlglobal, bool readOnly) diff --git a/src/qml/qml/v8/qv8contextwrapper_p.h b/src/qml/qml/v8/qv8contextwrapper_p.h index 57eb46de44..8a72489e6e 100644 --- a/src/qml/qml/v8/qv8contextwrapper_p.h +++ b/src/qml/qml/v8/qv8contextwrapper_p.h @@ -74,8 +74,8 @@ public: void init(QV8Engine *); void destroy(); - v8::Handle<v8::Object> qmlScope(QQmlContextData *ctxt, QObject *scope); - v8::Handle<v8::Object> urlScope(const QUrl &); + QV4::Value qmlScope(QQmlContextData *ctxt, QObject *scope); + QV4::Value urlScope(const QUrl &); void setReadOnly(v8::Handle<v8::Object>, bool); diff --git a/src/qml/qml/v8/qv8engine_p.h b/src/qml/qml/v8/qv8engine_p.h index 24096b7f68..619cce4fcd 100644 --- a/src/qml/qml/v8/qv8engine_p.h +++ b/src/qml/qml/v8/qv8engine_p.h @@ -293,7 +293,7 @@ public: QV4::Value fromVariant(const QVariant &); // Return the QML global "scope" object for the \a ctxt context and \a scope object. - inline v8::Handle<v8::Object> qmlScope(QQmlContextData *ctxt, QObject *scope); + inline QV4::Value qmlScope(QQmlContextData *ctxt, QObject *scope); // Return a JS wrapper for the given QObject \a object inline QV4::Value newQObject(QObject *object); @@ -313,9 +313,6 @@ public: // Create a new sequence type object inline QV4::Value newSequence(int sequenceType, QObject *, int coreIndex, bool *succeeded); - // Return the JS string key for the "function is a binding" flag - inline QV4::Value bindingFlagKey() const; - // Return the network access manager for this engine. By default this returns the network // access manager of the QQmlEngine. It is overridden in the case of a threaded v8 // instance (like in WorkerScript). @@ -442,7 +439,7 @@ private: Q_DISABLE_COPY(QV8Engine) }; -v8::Handle<v8::Object> QV8Engine::qmlScope(QQmlContextData *ctxt, QObject *scope) +QV4::Value QV8Engine::qmlScope(QQmlContextData *ctxt, QObject *scope) { return m_contextWrapper.qmlScope(ctxt, scope); } @@ -501,11 +498,6 @@ QV4::Value QV8Engine::newSequence(int sequenceType, QObject *object, int propert return QV4::SequencePrototype::newSequence(m_v4Engine, sequenceType, object, property, succeeded); } -QV4::Value QV8Engine::bindingFlagKey() const -{ - return m_bindingFlagKey; -} - QV8Engine::Deletable *QV8Engine::extensionData(int index) const { if (index < m_extensionData.count()) diff --git a/src/qml/qml/v8/qv8qobjectwrapper.cpp b/src/qml/qml/v8/qv8qobjectwrapper.cpp index 173c71acd0..36d4b1c528 100644 --- a/src/qml/qml/v8/qv8qobjectwrapper.cpp +++ b/src/qml/qml/v8/qv8qobjectwrapper.cpp @@ -727,7 +727,8 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropert { QQmlBinding *newBinding = 0; if (value->IsFunction()) { - if (value->ToObject()->GetHiddenValue(v8::Value::fromV4Value(engine->bindingFlagKey())).IsEmpty()) { + QV4::FunctionObject *f = value->v4Value().asFunctionObject(); + if (!f->bindingKeyFlag) { if (!property->isVarProperty() && property->propType != qMetaTypeId<QJSValue>()) { // assigning a JS function to a non var or QJSValue property or is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to "); @@ -746,7 +747,7 @@ static inline void StoreProperty(QV8Engine *engine, QObject *object, QQmlPropert QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); QV4::ExecutionEngine::StackFrame frame = v4->currentStackFrame(); - newBinding = new QQmlBinding(&function, object, context, frame.source.url(), + newBinding = new QQmlBinding(function->v4Value(), object, context, frame.source.url(), qmlSourceCoordinate(frame.line), qmlSourceCoordinate(frame.column)); newBinding->setTarget(object, *property, context); newBinding->setEvaluateFlags(newBinding->evaluateFlags() | diff --git a/src/qml/qml/v8/qv8valuetypewrapper.cpp b/src/qml/qml/v8/qv8valuetypewrapper.cpp index 9297df3d17..3218da4e38 100644 --- a/src/qml/qml/v8/qv8valuetypewrapper.cpp +++ b/src/qml/qml/v8/qv8valuetypewrapper.cpp @@ -373,7 +373,8 @@ v8::Handle<v8::Value> QV8ValueTypeWrapper::Setter(v8::Handle<v8::String> propert QQmlBinding *newBinding = 0; if (value->IsFunction()) { - if (value->ToObject()->GetHiddenValue(v8::Value::fromV4Value(r->engine->bindingFlagKey())).IsEmpty()) { + QV4::FunctionObject *f = value->v4Value().asFunctionObject(); + if (f->bindingKeyFlag) { // assigning a JS function to a non-var-property is not allowed. QString error = QLatin1String("Cannot assign JavaScript function to value-type property"); v8::ThrowException(v8::Exception::Error(r->engine->toString(error))); @@ -395,7 +396,7 @@ v8::Handle<v8::Value> QV8ValueTypeWrapper::Setter(v8::Handle<v8::String> propert QV4::ExecutionEngine *v4 = QV8Engine::getV4(r->engine); QV4::ExecutionEngine::StackFrame frame = v4->currentStackFrame(); - newBinding = new QQmlBinding(&function, reference->object, context, + newBinding = new QQmlBinding(function->v4Value(), reference->object, context, frame.source.url(), qmlSourceCoordinate(frame.line), qmlSourceCoordinate(frame.column)); newBinding->setTarget(reference->object, cacheData, context); newBinding->setEvaluateFlags(newBinding->evaluateFlags() | diff --git a/src/qml/types/qqmllistmodelworkeragent_p.h b/src/qml/types/qqmllistmodelworkeragent_p.h index 1299d81c56..80ed5d9a61 100644 --- a/src/qml/types/qqmllistmodelworkeragent_p.h +++ b/src/qml/types/qqmllistmodelworkeragent_p.h @@ -90,21 +90,6 @@ public: Q_INVOKABLE void move(int from, int to, int count); Q_INVOKABLE void sync(); - struct VariantRef - { - VariantRef() : a(0) {} - VariantRef(const VariantRef &r) : a(r.a) { if (a) a->addref(); } - VariantRef(QQmlListModelWorkerAgent *_a) : a(_a) { if (a) a->addref(); } - ~VariantRef() { if (a) a->release(); } - - VariantRef &operator=(const VariantRef &o) { - if (o.a) o.a->addref(); - if (a) a->release(); a = o.a; - return *this; - } - - QQmlListModelWorkerAgent *a; - }; void modelDestroyed(); protected: virtual bool event(QEvent *); @@ -150,7 +135,5 @@ private: QT_END_NAMESPACE -Q_DECLARE_METATYPE(QQmlListModelWorkerAgent::VariantRef) - #endif // QQUICKLISTMODELWORKERAGENT_P_H diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 1dce932dad..0ee2a06b69 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -295,7 +295,7 @@ QV4::Value QQuickWorkerScriptEnginePrivate::getWorker(WorkerScript *script) QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine); - script->object = workerEngine->contextWrapper()->urlScope(script->source)->v4Value(); + script->object = workerEngine->contextWrapper()->urlScope(script->source); workerEngine->contextWrapper()->setReadOnly(script->object.value(), false); |