diff options
-rw-r--r-- | src/qml/qml/qqmlabstractbinding.cpp | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlabstractbinding_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcompiler.cpp | 148 | ||||
-rw-r--r-- | src/qml/qml/qqmlcompiler_p.h | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext.cpp | 10 | ||||
-rw-r--r-- | src/qml/qml/qqmlcontext_p.h | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlinstruction.cpp | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlinstruction_p.h | 8 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty.cpp | 26 | ||||
-rw-r--r-- | src/qml/qml/qqmlproperty_p.h | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlvme.cpp | 47 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8bindings.cpp | 319 | ||||
-rw-r--r-- | src/qml/qml/v8/qv8bindings_p.h | 161 | ||||
-rw-r--r-- | src/qml/qml/v8/v8.pri | 2 |
14 files changed, 10 insertions, 734 deletions
diff --git a/src/qml/qml/qqmlabstractbinding.cpp b/src/qml/qml/qqmlabstractbinding.cpp index 168d51935d..c01981b3d2 100644 --- a/src/qml/qml/qqmlabstractbinding.cpp +++ b/src/qml/qml/qqmlabstractbinding.cpp @@ -49,11 +49,9 @@ QT_BEGIN_NAMESPACE extern QQmlAbstractBinding::VTable QQmlBinding_vtable; extern QQmlAbstractBinding::VTable QQmlValueTypeProxyBinding_vtable; -extern QQmlAbstractBinding::VTable QV8Bindings_Binding_vtable; QQmlAbstractBinding::VTable *QQmlAbstractBinding::vTables[] = { &QQmlBinding_vtable, - &QV8Bindings_Binding_vtable, &QQmlValueTypeProxyBinding_vtable }; diff --git a/src/qml/qml/qqmlabstractbinding_p.h b/src/qml/qml/qqmlabstractbinding_p.h index 4182a5cc88..8b93ea057d 100644 --- a/src/qml/qml/qqmlabstractbinding_p.h +++ b/src/qml/qml/qqmlabstractbinding_p.h @@ -91,7 +91,7 @@ public: typedef QWeakPointer<QQmlAbstractBinding> Pointer; - enum BindingType { Binding = 0, V8 = 1, ValueTypeProxy = 2 }; + enum BindingType { Binding = 0, ValueTypeProxy = 1 }; inline BindingType bindingType() const; // Destroy the binding. Use this instead of calling delete. diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index a1da778dc8..7b5f195fc7 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -921,18 +921,6 @@ void QQmlCompiler::compileTree(QQmlScript::Object *tree) output->addInstruction(import); } - if (!compileState->v8BindingProgram.isEmpty()) { - Instruction::InitV8Bindings bindings; - int index = output->programs.count(); - - typedef QQmlCompiledData::V8Program V8Program; - output->programs.append(V8Program(compileState->v8BindingProgram, output)); - - bindings.programIndex = index; - bindings.line = compileState->v8BindingProgramLine; - output->addInstruction(bindings); - } - genObject(tree); Instruction::SetDefault def; @@ -1455,18 +1443,6 @@ void QQmlCompiler::genComponent(QQmlScript::Object *obj) init.compiledBinding = output->indexForByteArray(compileState->compiledBindingData); output->addInstruction(init); - if (!compileState->v8BindingProgram.isEmpty()) { - Instruction::InitV8Bindings bindings; - int index = output->programs.count(); - - typedef QQmlCompiledData::V8Program V8Program; - output->programs.append(V8Program(compileState->v8BindingProgram, output)); - - bindings.programIndex = index; - bindings.line = compileState->v8BindingProgramLine; - output->addInstruction(bindings); - } - genObject(root); Instruction::SetDefault def; @@ -3544,34 +3520,7 @@ void QQmlCompiler::genBindingAssignment(QQmlScript::Value *binding, output->addInstruction(store); } else #endif - if (ref.dataType == BindingReference::V8) { - const JSBindingReference &js = static_cast<const JSBindingReference &>(ref); - - Instruction::StoreV8Binding store; - store.value = js.sharedIndex; - store.context = js.bindingContext.stack; - store.owner = js.bindingContext.owner; - store.isAlias = prop->isAlias; - store.isSafe = js.isSafe; - if (valueTypeProperty) { - store.isRoot = (compileState->root == valueTypeProperty->parent); - } else { - store.isRoot = (compileState->root == obj); - } - store.isFallback = js.compiledIndex > -1; - store.line = binding->location.start.line; - store.column = binding->location.start.column; - - Q_ASSERT(js.bindingContext.owner == 0 || - (js.bindingContext.owner != 0 && valueTypeProperty)); - if (js.bindingContext.owner) { - store.property = genValueTypeData(prop, valueTypeProperty); - } else { - store.property = prop->core; - } - - output->addInstruction(store); - } else if (ref.dataType == BindingReference::QtScript) { + if (ref.dataType == BindingReference::QtScript) { const JSBindingReference &js = static_cast<const JSBindingReference &>(ref); Instruction::StoreBinding store; @@ -3635,8 +3584,6 @@ bool QQmlCompiler::completeComponentBuild() aliasObject = compileState->aliasingObjects.next(aliasObject)) COMPILE_CHECK(buildDynamicMetaAliases(aliasObject)); - QList<JSBindingReference*> sharedBindings; - for (JSBindingReference *b = compileState->bindings.first(); b; b = b->nextReference) { JSBindingReference &binding = *b; @@ -3651,61 +3598,12 @@ bool QQmlCompiler::completeComponentBuild() binding.rewrittenExpression = rewriteBinding(binding.expression.asAST(), expression, &isSharable, &isSafe); binding.isSafe = isSafe; - if (isSharable && binding.property->type != qMetaTypeId<QQmlBinding*>()) { - sharedBindings.append(b); - - binding.dataType = BindingReference::V8; - binding.compiledIndex = -1; - - if (componentStats) - componentStats->componentStat.sharedBindings.append(b->value->location); - } else { - binding.dataType = BindingReference::QtScript; - - if (componentStats) - componentStats->componentStat.scriptBindings.append(b->value->location); - } - } - - if (!sharedBindings.isEmpty()) { - struct Sort { - static bool lt(const JSBindingReference *lhs, const JSBindingReference *rhs) - { - return lhs->value->location.start.line < rhs->value->location.start.line; - } - }; - - qSort(sharedBindings.begin(), sharedBindings.end(), Sort::lt); + binding.dataType = BindingReference::QtScript; - int startLineNumber = sharedBindings.at(0)->value->location.start.line; - int lineNumber = startLineNumber; - - QByteArray functionArray("[", 1); - for (int ii = 0; ii < sharedBindings.count(); ++ii) { - - JSBindingReference *reference = sharedBindings.at(ii); - QQmlScript::Value *value = reference->value; - const QString &expression = reference->rewrittenExpression; - - if (ii != 0) functionArray.append(",", 1); - - while (lineNumber < value->location.start.line) { - lineNumber++; - functionArray.append("\n", 1); - } - - functionArray += expression.toUtf8(); - lineNumber += expression.count(QLatin1Char('\n')); - - reference->sharedIndex = ii; - } - functionArray.append("]", 1); - - compileState->v8BindingProgram = functionArray; - compileState->v8BindingProgramLine = startLineNumber; + if (componentStats) + componentStats->componentStat.scriptBindings.append(b->value->location); } - // Check pop()'s matched push()'s Q_ASSERT(compileState->objectDepth.depth() == 0); Q_ASSERT(compileState->listDepth.depth() == 0); @@ -3724,44 +3622,6 @@ void QQmlCompiler::dumpStats() qWarning().nospace() << " Component Line " << stat.lineNumber; qWarning().nospace() << " Total Objects: " << stat.objects; qWarning().nospace() << " IDs Used: " << stat.ids; - qWarning().nospace() << " Optimized Bindings: " << stat.optimizedBindings.count(); - - { - QByteArray output; - for (int ii = 0; ii < stat.optimizedBindings.count(); ++ii) { - if (0 == (ii % 10)) { - if (ii) output.append("\n"); - output.append(" "); - } - - output.append('('); - output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.line)); - output.append(':'); - output.append(QByteArray::number(stat.optimizedBindings.at(ii).start.column)); - output.append(") "); - } - if (!output.isEmpty()) - qWarning().nospace() << output.constData(); - } - - qWarning().nospace() << " Shared Bindings: " << stat.sharedBindings.count(); - { - QByteArray output; - for (int ii = 0; ii < stat.sharedBindings.count(); ++ii) { - if (0 == (ii % 10)) { - if (ii) output.append('\n'); - output.append(" "); - } - - output.append('('); - output.append(QByteArray::number(stat.sharedBindings.at(ii).start.line)); - output.append(':'); - output.append(QByteArray::number(stat.sharedBindings.at(ii).start.column)); - output.append(") "); - } - if (!output.isEmpty()) - qWarning().nospace() << output.constData(); - } qWarning().nospace() << " QScript Bindings: " << stat.scriptBindings.count(); { diff --git a/src/qml/qml/qqmlcompiler_p.h b/src/qml/qml/qqmlcompiler_p.h index b25850a9f3..1b2796248e 100644 --- a/src/qml/qml/qqmlcompiler_p.h +++ b/src/qml/qml/qqmlcompiler_p.h @@ -187,7 +187,7 @@ namespace QQmlCompilerTypes { struct BindingReference { - enum DataType { QtScript, V8, + enum DataType { QtScript, Tr, TrId }; DataType dataType; }; @@ -255,7 +255,7 @@ namespace QQmlCompilerTypes { { ComponentCompileState() : parserStatusCount(0), totalBindingsCount(0), pushedProperties(0), nested(false), - v8BindingProgramLine(-1), root(0) {} + root(0) {} IdList ids; int parserStatusCount; @@ -264,8 +264,6 @@ namespace QQmlCompilerTypes { bool nested; QByteArray compiledBindingData; - QByteArray v8BindingProgram; - int v8BindingProgramLine; DepthStack objectDepth; DepthStack listDepth; @@ -446,8 +444,6 @@ private: int ids; QList<QQmlScript::LocationSpan> scriptBindings; - QList<QQmlScript::LocationSpan> sharedBindings; - QList<QQmlScript::LocationSpan> optimizedBindings; int objects; }; struct ComponentStats : public QQmlPool::Class diff --git a/src/qml/qml/qqmlcontext.cpp b/src/qml/qml/qqmlcontext.cpp index 3899f45aaf..efe586eec1 100644 --- a/src/qml/qml/qqmlcontext.cpp +++ b/src/qml/qml/qqmlcontext.cpp @@ -48,7 +48,6 @@ #include "qqmlengine_p.h" #include "qqmlengine.h" #include "qqmlinfo.h" -#include <private/qv8bindings_p.h> #include <qjsengine.h> #include <QtCore/qvarlengtharray.h> @@ -517,8 +516,7 @@ QQmlContextData::QQmlContextData() publicContext(0), activeVMEData(0), propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0), expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), - componentAttached(0), - v8bindings(0) + componentAttached(0) { } @@ -528,8 +526,7 @@ QQmlContextData::QQmlContextData(QQmlContext *ctxt) publicContext(ctxt), activeVMEData(0), propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0), expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0), - componentAttached(0), - v8bindings(0) + componentAttached(0) { } @@ -637,9 +634,6 @@ void QQmlContextData::destroy() if (imports) imports->release(); - if (v8bindings) - v8bindings->release(); - delete [] idValues; if (isInternal) diff --git a/src/qml/qml/qqmlcontext_p.h b/src/qml/qml/qqmlcontext_p.h index 88e67f16ee..c977589931 100644 --- a/src/qml/qml/qqmlcontext_p.h +++ b/src/qml/qml/qqmlcontext_p.h @@ -75,7 +75,6 @@ QT_BEGIN_NAMESPACE -class QV8Bindings; class QQmlContext; class QQmlExpression; class QQmlEngine; @@ -210,8 +209,6 @@ public: // context QQmlComponentAttached *componentAttached; - QV8Bindings *v8bindings; - // Return the outermost id for obj, if any. QString findObjectId(const QObject *obj) const; diff --git a/src/qml/qml/qqmlinstruction.cpp b/src/qml/qml/qqmlinstruction.cpp index 8c321c82d3..c5a4e5d15c 100644 --- a/src/qml/qml/qqmlinstruction.cpp +++ b/src/qml/qml/qqmlinstruction.cpp @@ -221,15 +221,9 @@ void QQmlCompiledData::dump(QQmlInstruction *instr, int idx) case QQmlInstruction::AssignCustomType: qWarning().nospace() << idx << "\t\t" << "ASSIGN_CUSTOMTYPE\t" << instr->assignCustomType.propertyIndex << "\t" << instr->assignCustomType.primitive << "\t" << instr->assignCustomType.type; break; - case QQmlInstruction::InitV8Bindings: - qWarning().nospace() << idx << "\t\t" << "INIT_V8_BINDING\t" << instr->initV8Bindings.programIndex << "\t" << instr->initV8Bindings.line; - break; case QQmlInstruction::StoreBinding: qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context; break; - case QQmlInstruction::StoreV8Binding: - qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context; - break; case QQmlInstruction::StoreValueSource: qWarning().nospace() << idx << "\t\t" << "STORE_VALUE_SOURCE\t" << instr->assignValueSource.property.coreIndex << "\t" << instr->assignValueSource.castValue; break; diff --git a/src/qml/qml/qqmlinstruction_p.h b/src/qml/qml/qqmlinstruction_p.h index cae99e4634..3be18572e4 100644 --- a/src/qml/qml/qqmlinstruction_p.h +++ b/src/qml/qml/qqmlinstruction_p.h @@ -116,9 +116,7 @@ QT_BEGIN_NAMESPACE F(StoreImportedScript, storeScript) \ F(StoreScriptString, storeScriptString) \ F(BeginObject, begin) \ - F(InitV8Bindings, initV8Bindings) \ F(StoreBinding, assignBinding) \ - F(StoreV8Binding, assignBinding) \ F(StoreValueSource, assignValueSource) \ F(StoreValueInterceptor, assignValueInterceptor) \ F(StoreObjectQList, common) \ @@ -236,11 +234,6 @@ union QQmlInstruction QQmlPropertyRawData property; int castValue; }; - struct instr_initV8Bindings { - QML_INSTR_HEADER - ushort programIndex; - ushort line; - }; struct instr_assignBinding { QML_INSTR_HEADER QQmlPropertyRawData property; @@ -496,7 +489,6 @@ union QQmlInstruction instr_setId setId; instr_assignValueSource assignValueSource; instr_assignValueInterceptor assignValueInterceptor; - instr_initV8Bindings initV8Bindings; instr_assignBinding assignBinding; instr_fetch fetch; instr_fetchValue fetchValue; diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp index 8fd65bd1f3..56e63473e0 100644 --- a/src/qml/qml/qqmlproperty.cpp +++ b/src/qml/qml/qqmlproperty.cpp @@ -57,7 +57,6 @@ #include "qqmlexpression_p.h" #include "qqmlvaluetypeproxybinding_p.h" #include <private/qjsvalue_p.h> -#include <private/qv8bindings_p.h> #include <QStringList> #include <private/qmetaobject_p.h> @@ -942,31 +941,6 @@ QQmlPropertyPrivate::setBindingNoEnable(QObject *object, int coreIndex, int valu } /*! - Activates a shared binding which was previously created but not added to the - object. This is needed when an optimized binding is invalidated. -*/ -QQmlAbstractBinding *QQmlPropertyPrivate::activateSharedBinding(QQmlContextData *context, - int sharedIdx, WriteFlags flags) -{ - QQmlAbstractBinding *newBinding = 0; - newBinding = context->v8bindings->binding(sharedIdx); - - if (!newBinding) - return newBinding; - - // This binding now references the bindings object - context->v8bindings->addref(); - - QObject *object = newBinding->object(); - int pi = newBinding->propertyIndex(); - - int core = pi & 0x0000FFFF; - int vt = (pi & 0xFFFF0000)?(pi >> 16):-1; - - return setBinding(object, core, vt, newBinding, flags); -} - -/*! Returns the expression associated with this signal property, or 0 if no signal expression exists. */ diff --git a/src/qml/qml/qqmlproperty_p.h b/src/qml/qml/qqmlproperty_p.h index 108b98f3ca..e7c850fbdd 100644 --- a/src/qml/qml/qqmlproperty_p.h +++ b/src/qml/qml/qqmlproperty_p.h @@ -119,8 +119,6 @@ public: static QQmlAbstractBinding *setBindingNoEnable(QObject *, int coreIndex, int valueTypeIndex /* -1 */, QQmlAbstractBinding *); - static QQmlAbstractBinding *activateSharedBinding(QQmlContextData *context, - int sharedIdx, WriteFlags flags); static QQmlAbstractBinding *binding(QObject *, int coreIndex, int valueTypeIndex /* -1 */); diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp index 0c89e0a5ff..48bd4beb84 100644 --- a/src/qml/qml/qqmlvme.cpp +++ b/src/qml/qml/qqmlvme.cpp @@ -57,13 +57,13 @@ #include "qqmlcomponent_p.h" #include "qqmlvmemetaobject_p.h" #include "qqmlcontext_p.h" -#include <private/qv8bindings_p.h> #include "qqmlglobal_p.h" #include <private/qfinitestack_p.h> #include "qqmlscriptstring.h" #include "qqmlscriptstring_p.h" #include "qqmlpropertyvalueinterceptor_p.h" #include "qqmlvaluetypeproxybinding_p.h" +#include "qqmlexpression_p.h" #include <QStack> #include <QPointF> @@ -792,10 +792,6 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, status->classBegin(); QML_END_INSTR(BeginObject) - QML_BEGIN_INSTR(InitV8Bindings) - CTXT->v8bindings = new QV8Bindings(&PROGRAMS[instr.programIndex], instr.line, CTXT); - QML_END_INSTR(InitV8Bindings) - QML_BEGIN_INSTR(StoreBinding) QObject *target = objects.at(objects.count() - 1 - instr.owner); @@ -830,47 +826,6 @@ QObject *QQmlVME::run(QList<QQmlError> *errors, } QML_END_INSTR(StoreBinding) - QML_BEGIN_INSTR(StoreV8Binding) - QObject *target = - objects.at(objects.count() - 1 - instr.owner); - QObject *scope = - objects.at(objects.count() - 1 - instr.context); - - int coreIndex = instr.property.coreIndex; - - if (instr.isRoot && BINDINGSKIPLIST.testBit(coreIndex)) - QML_NEXT_INSTR(StoreV8Binding); - - QQmlAbstractBinding *binding = CTXT->v8bindings->configBinding(target, scope, - &instr); - if (binding && !instr.isFallback) { - bindValues.push(binding); - binding->m_mePtr = &bindValues.top(); - - if (instr.isAlias) { - QQmlAbstractBinding *old = - QQmlPropertyPrivate::setBindingNoEnable(target, coreIndex, - instr.property.getValueTypeCoreIndex(), - binding); - if (old) { old->destroy(); } - } else { - typedef QQmlPropertyPrivate QDPP; - Q_ASSERT(binding->propertyIndex() == QDPP::bindingIndex(instr.property)); - Q_ASSERT(binding->object() == target); - - CLEAN_PROPERTY(target, QDPP::bindingIndex(instr.property)); - - binding->addToObject(); - - if (instr.isSafe && !instr.property.isValueTypeVirtual()) { - QQmlData *data = QQmlData::get(target); - Q_ASSERT(data); - data->setPendingBindingBit(target, coreIndex); - } - } - } - QML_END_INSTR(StoreV8Binding) - QML_BEGIN_INSTR(StoreValueSource) QObject *obj = objects.pop(); QQmlPropertyValueSource *vs = reinterpret_cast<QQmlPropertyValueSource *>(reinterpret_cast<char *>(obj) + instr.castValue); diff --git a/src/qml/qml/v8/qv8bindings.cpp b/src/qml/qml/v8/qv8bindings.cpp deleted file mode 100644 index 9bdc25e949..0000000000 --- a/src/qml/qml/v8/qv8bindings.cpp +++ /dev/null @@ -1,319 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qv8bindings_p.h" - -#include <private/qv8_p.h> -#include <private/qqmlbinding_p.h> -#include <private/qqmlcompiler_p.h> -#include <private/qqmlproperty_p.h> -#include <private/qqmlexpression_p.h> -#include <private/qobject_p.h> -#include <private/qqmltrace_p.h> -#include <private/qqmlprofilerservice_p.h> - -#include <private/qv4object_p.h> -#include <private/qv4script_p.h> - -QT_BEGIN_NAMESPACE - -QQmlAbstractBinding::VTable QV8Bindings_Binding_vtable = { - QV8Bindings::Binding::destroy, - QQmlAbstractBinding::default_expression, - QV8Bindings::Binding::propertyIndex, - QV8Bindings::Binding::object, - QV8Bindings::Binding::setEnabled, - QV8Bindings::Binding::update, - QV8Bindings::Binding::retargetBinding -}; - -static QQmlJavaScriptExpression::VTable QV8Bindings_Binding_jsvtable = { - QV8Bindings::Binding::expressionIdentifier, - QV8Bindings::Binding::expressionChanged -}; - -QV8Bindings::Binding::Binding() -: QQmlJavaScriptExpression(&QV8Bindings_Binding_jsvtable), QQmlAbstractBinding(V8), parent(0) -{ -} - -void QV8Bindings::Binding::setEnabled(QQmlAbstractBinding *_This, bool e, - QQmlPropertyPrivate::WriteFlags flags) -{ - QV8Bindings::Binding *This = static_cast<QV8Bindings::Binding *>(_This); - - if (This->enabledFlag() != e) { - This->setEnabledFlag(e); - - if (e) This->update(flags); - } -} - -void QV8Bindings::refresh() -{ - QV4::ArrayObject *f = functions(); - int count = f ? f->arrayLength() : 0; - for (int ii = 0; ii < count; ++ii) - bindings[ii].refresh(); -} - -void QV8Bindings::Binding::refresh() -{ - update(); -} - -int QV8Bindings::Binding::propertyIndex(const QQmlAbstractBinding *_This) -{ - const QV8Bindings::Binding *This = static_cast<const QV8Bindings::Binding *>(_This); - if (This->target.hasValue()) return This->target.constValue()->targetProperty; - else return This->instruction->property.encodedIndex(); -} - -QObject *QV8Bindings::Binding::object(const QQmlAbstractBinding *_This) -{ - const QV8Bindings::Binding *This = static_cast<const QV8Bindings::Binding *>(_This); - - if (This->target.hasValue()) return This->target.constValue()->target; - else return *This->target; -} - -QObject *QV8Bindings::Binding::object() const -{ - if (target.hasValue()) return target.constValue()->target; - else return *target; -} - -void QV8Bindings::Binding::retargetBinding(QQmlAbstractBinding *_This, QObject *t, int i) -{ - QV8Bindings::Binding *This = static_cast<QV8Bindings::Binding *>(_This); - - This->target.value().target = t; - This->target.value().targetProperty = i; -} - -void QV8Bindings::Binding::update(QQmlAbstractBinding *_This, QQmlPropertyPrivate::WriteFlags flags) -{ - QV8Bindings::Binding *This = static_cast<QV8Bindings::Binding *>(_This); - This->update(flags); -} - -void QV8Bindings::Binding::dump() -{ - qWarning() << parent->url() << instruction->line << instruction->column; -} - -void QV8Bindings::Binding::update(QQmlPropertyPrivate::WriteFlags flags) -{ - if (!enabledFlag()) - return; - - QQmlContextData *context = parent->context(); - - if (!context || !context->isValid()) - return; - - // Check that the target has not been deleted - if (QQmlData::wasDeleted(object())) - return; - - int lineNo = qmlSourceCoordinate(instruction->line); - int columnNo = qmlSourceCoordinate(instruction->column); - - QQmlTrace trace("V8 Binding Update"); - trace.addDetail("URL", parent->url()); - trace.addDetail("Line", lineNo); - trace.addDetail("Column", columnNo); - - QQmlBindingProfiler prof(parent->urlString(), lineNo, columnNo, QQmlProfilerService::V8Binding); - - if (!updatingFlag()) { - setUpdatingFlag(true); - - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine); - - bool isUndefined = false; - - DeleteWatcher watcher(this); - ep->referenceScarceResources(); - - QV4::ArrayObject *f = parent->functions(); - v8::Handle<v8::Value> result = f ? - evaluate(context, - f->getIndexed(f->internalClass->engine->current, instruction->value), - &isUndefined) - : v8::Handle<v8::Value>(QV4::Value::undefinedValue()); - - trace.event("writing V8 result"); - bool needsErrorLocationData = false; - if (!watcher.wasDeleted() && !destroyedFlag() && !hasError()) { - typedef QQmlPropertyPrivate PP; - needsErrorLocationData = !PP::writeBinding(*target, instruction->property, context, this, result, - isUndefined, flags); - } - - if (!watcher.wasDeleted() && !destroyedFlag()) { - - if (needsErrorLocationData) - delayedError()->setErrorLocation(parent->url(), instruction->line, 0); - - if (hasError()) { - if (!delayedError()->addError(ep)) ep->warning(this->error(context->engine)); - } else { - clearError(); - } - - setUpdatingFlag(false); - } - - ep->dereferenceScarceResources(); - - } else { - QQmlProperty p = QQmlPropertyPrivate::restore(*target, instruction->property, context); - QQmlAbstractBinding::printBindingLoopError(p); - } -} - -QString QV8Bindings::Binding::expressionIdentifier(QQmlJavaScriptExpression *e) -{ - Binding *This = static_cast<Binding *>(e); - return This->parent->urlString() + QLatin1Char(':') + - QString::number(qmlSourceCoordinate(This->instruction->line)); -} - -void QV8Bindings::Binding::expressionChanged(QQmlJavaScriptExpression *e) -{ - Binding *This = static_cast<Binding *>(e); - This->update(QQmlPropertyPrivate::DontRemoveBinding); -} - -void QV8Bindings::Binding::destroy(QQmlAbstractBinding *_This, QQmlAbstractBinding::DestroyMode mode) -{ - QV8Bindings::Binding *This = static_cast<QV8Bindings::Binding *>(_This); - - if (mode == QQmlAbstractBinding::DisconnectBinding) - This->clearGuards(); - - This->setEnabledFlag(false); - This->setDestroyedFlag(true); - This->removeFromObject(); - This->clear(); - This->clearError(); - This->parent->release(); -} - -QV8Bindings::QV8Bindings(QQmlCompiledData::V8Program *program, - quint16 line, - QQmlContextData *context) -: program(program), bindings(0), refCount(1) -{ - QV8Engine *engine = QQmlEnginePrivate::getV8Engine(context->engine); - - if (program->bindings.isEmpty()) { - QV4::ExecutionEngine *v4 = QV8Engine::getV4(engine); - QString sourceCode = program->program; - QV4::Script script(v4, engine->contextWrapper()->sharedContext().asObject(), sourceCode, program->cdata->name, line); - QV4::ExecutionContext *ctx = v4->current; - try { - script.parse(); - QV4::Value result = script.run(); - if (result.asArrayObject()) { - program->bindings = result; - program->program.clear(); // We don't need the source anymore - } - } catch (QV4::Exception &e) { - e.accept(ctx); - } - } - - QV4::ArrayObject *f = functions(); - int bindingsCount = f ? f->arrayLength() : 0; - if (bindingsCount) bindings = new QV8Bindings::Binding[bindingsCount]; - - setContext(context); -} - -QV8Bindings::~QV8Bindings() -{ - program = 0; - - delete [] bindings; - bindings = 0; -} - -QQmlAbstractBinding * -QV8Bindings::configBinding(QObject *target, QObject *scope, - const QQmlInstruction::instr_assignBinding *i) -{ - if (!bindings) // initialization failed. - return 0; - - QV8Bindings::Binding *rv = bindings + i->value; - - rv->instruction = i; - rv->target = target; - rv->setScopeObject(scope); - rv->setUseSharedContext(true); - rv->setNotifyOnValueChanged(true); - rv->parent = this; - - if (!i->isFallback) - addref(); // This is decremented in Binding::destroy() - - return rv; -} - -const QUrl &QV8Bindings::url() const -{ - return program->cdata->url; -} - -const QString &QV8Bindings::urlString() const -{ - return program->cdata->name; -} - -QV4::ArrayObject *QV8Bindings::functions() const -{ - return program->bindings.value().asArrayObject(); -} - - -QT_END_NAMESPACE diff --git a/src/qml/qml/v8/qv8bindings_p.h b/src/qml/qml/v8/qv8bindings_p.h deleted file mode 100644 index 74fe04258f..0000000000 --- a/src/qml/qml/v8/qv8bindings_p.h +++ /dev/null @@ -1,161 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QV8BINDINGS_P_H -#define QV8BINDINGS_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <private/qpointervaluepair_p.h> -#include <private/qqmlpropertycache_p.h> -#include <private/qqmlinstruction_p.h> -#include <private/qqmlexpression_p.h> -#include <private/qqmlcompiler_p.h> -#include <private/qflagpointer_p.h> -#include <private/qqmlbinding_p.h> - -QT_BEGIN_NAMESPACE - -class QQmlCompiledData; - -class QV8BindingsPrivate; -class QV8Bindings : public QQmlAbstractExpression -{ -public: - QV8Bindings(QQmlCompiledData::V8Program *, - quint16 line, - QQmlContextData *context); - virtual ~QV8Bindings(); - - QQmlAbstractBinding *configBinding(QObject *target, QObject *scope, - const QQmlInstruction::instr_assignBinding *); - - // Inherited from QQmlAbstractExpression - virtual void refresh(); - - struct Binding : public QQmlJavaScriptExpression, - public QQmlAbstractBinding { - Binding(); - - void update() { QQmlAbstractBinding::update(); } - void refresh(); - - // "Inherited" from QQmlJavaScriptExpression - static QString expressionIdentifier(QQmlJavaScriptExpression *); - static void expressionChanged(QQmlJavaScriptExpression *); - - // "Inherited" from QQmlAbstractBinding - static void destroy(QQmlAbstractBinding *, QQmlAbstractBinding::DestroyMode mode); - static int propertyIndex(const QQmlAbstractBinding *); - static QObject *object(const QQmlAbstractBinding *); - static void setEnabled(QQmlAbstractBinding *, bool, QQmlPropertyPrivate::WriteFlags); - static void update(QQmlAbstractBinding *, QQmlPropertyPrivate::WriteFlags); - static void retargetBinding(QQmlAbstractBinding *, QObject *, int); - - QObject *object() const; - void update(QQmlPropertyPrivate::WriteFlags flags); - - void dump(); - - QV8Bindings *parent; - - struct Retarget { - QObject *target; - int targetProperty; - }; - - // To save memory, we store flags inside the instruction pointer. - // target.flag1: destroyed - // instruction.flag1: enabled - // instruction.flag2: updating - QPointerValuePair<QObject, Retarget> target; - QFlagPointer<const QQmlInstruction::instr_assignBinding> instruction; - - inline bool destroyedFlag() const { return target.flag(); } - inline void setDestroyedFlag(bool v) { return target.setFlagValue(v); } - inline bool enabledFlag() const { return instruction.flag(); } - inline void setEnabledFlag(bool v) { instruction.setFlagValue(v); } - inline bool updatingFlag() const { return instruction.flag2(); } - inline void setUpdatingFlag(bool v) { instruction.setFlag2Value(v); } - }; - - inline void addref(); - inline void release(); - - QQmlAbstractBinding *binding(int index) const { return bindings + index; } - -private: - Q_DISABLE_COPY(QV8Bindings) - - const QUrl &url() const; - const QString &urlString() const; - QV4::ArrayObject *functions() const; - - QQmlCompiledData::V8Program *program; - Binding *bindings; - int refCount; -}; - -void QV8Bindings::addref() -{ - ++refCount; -} - -void QV8Bindings::release() -{ - if (0 == --refCount) - delete this; -} - -QT_END_NAMESPACE - -#endif // QV8BINDINGS_P_H - - diff --git a/src/qml/qml/v8/v8.pri b/src/qml/qml/v8/v8.pri index f51537bedf..80e158dc76 100644 --- a/src/qml/qml/v8/v8.pri +++ b/src/qml/qml/v8/v8.pri @@ -12,7 +12,6 @@ HEADERS += \ $$PWD/qv8valuetypewrapper_p.h \ $$PWD/qv4jsonwrapper_p.h \ $$PWD/qv8include_p.h \ - $$PWD/qv8bindings_p.h \ $$PWD/qv4domerrors_p.h \ $$PWD/qv4sqlerrors_p.h \ $$PWD/qqmlbuiltinfunctions_p.h \ @@ -27,7 +26,6 @@ SOURCES += \ $$PWD/qv8valuetypewrapper.cpp \ $$PWD/qv4jsonwrapper.cpp \ $$PWD/qv8include.cpp \ - $$PWD/qv8bindings.cpp \ $$PWD/qv4domerrors.cpp \ $$PWD/qv4sqlerrors.cpp \ $$PWD/qqmlbuiltinfunctions.cpp |