diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-08-01 10:27:17 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-10 05:40:49 +0200 |
commit | 4350877d6deb58f36df24164c6edde3302a3f1a3 (patch) | |
tree | 5b1b121c1ce21aff1717de500282a5951f4e1267 /src/qml/qml/v4 | |
parent | 34ae6deb78c30a80570e0c0dda7b2f071abdbf68 (diff) |
Permit value types with metatype IDs >= QMetaType::User
Remove the assumption that value types must be types defined by
Qt, having metatype IDs below QMetaType::User.
Task-number: QTBUG-26352
Change-Id: Ib5a56ff2e7892e82adf17a3a1e7517a0c9fe0534
Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/qml/qml/v4')
-rw-r--r-- | src/qml/qml/v4/qv4bindings.cpp | 35 | ||||
-rw-r--r-- | src/qml/qml/v4/qv4bindings_p.h | 10 |
2 files changed, 22 insertions, 23 deletions
diff --git a/src/qml/qml/v4/qv4bindings.cpp b/src/qml/qml/v4/qv4bindings.cpp index 9b74c2aa72..02f2bfc863 100644 --- a/src/qml/qml/v4/qv4bindings.cpp +++ b/src/qml/qml/v4/qv4bindings.cpp @@ -298,15 +298,17 @@ QV4Bindings::~QV4Bindings() delete [] subscriptions; subscriptions = 0; } -QQmlAbstractBinding *QV4Bindings::configBinding(int index, int fallbackIndex, QObject *target, - QObject *scope, int property, - int line, int column) +QQmlAbstractBinding *QV4Bindings::configBinding(int index, int fallbackIndex, QObject *target, QObject *scope, + int property, int propType, int line, int column) { + Q_ASSERT(propType <= std::numeric_limits<quint16>::max()); + Binding *rv = bindings + index; rv->index = index; rv->fallbackIndex = fallbackIndex; rv->property = property; + rv->propType = propType; rv->target = target; rv->scope = scope; rv->line = line; @@ -352,8 +354,7 @@ int QV4Bindings::Binding::propertyIndex(const QQmlAbstractBinding *_This) const QV4Bindings::Binding *This = static_cast<const QV4Bindings::Binding *>(_This); if (This->target.hasValue()) return This->target.constValue()->targetProperty; - //mask out the type information set for value types - else return This->property & 0xFF00FFFF; + else return This->property; } QObject *QV4Bindings::Binding::object(const QQmlAbstractBinding *_This) @@ -421,15 +422,13 @@ void QV4Bindings::run(Binding *binding, QQmlPropertyPrivate::WriteFlags flags) if (binding->updating) { QString name; - if (binding->property & 0xFFFF0000) { - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine); - - QQmlValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF]; + if (binding->propType) { + QQmlValueType *vt = QQmlValueTypeFactory::valueType(binding->propType); Q_ASSERT(vt); - name = QLatin1String(binding->target->metaObject()->property(binding->property & 0xFFFF).name()); + name = QLatin1String(binding->target->metaObject()->property(binding->property & 0x0000FFFF).name()); name.append(QLatin1Char('.')); - name.append(QLatin1String(vt->metaObject()->property(binding->property >> 24).name())); + name.append(QLatin1String(vt->metaObject()->property(binding->property >> 16).name())); } else { name = QLatin1String(binding->target->metaObject()->property(binding->property).name()); } @@ -441,18 +440,16 @@ void QV4Bindings::run(Binding *binding, QQmlPropertyPrivate::WriteFlags flags) bool *inv = (binding->fallbackIndex != -1) ? &invalidated : 0; binding->updating = true; - if (binding->property & 0xFFFF0000) { - QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine); - - QQmlValueType *vt = ep->valueTypes[(binding->property >> 16) & 0xFF]; + if (binding->propType) { + QQmlValueType *vt = QQmlValueTypeFactory::valueType(binding->propType); Q_ASSERT(vt); - vt->read(*binding->target, binding->property & 0xFFFF); + vt->read(*binding->target, binding->property & 0x0000FFFF); QObject *target = vt; run(binding->index, binding->executedBlocks, context, binding, binding->scope, target, flags, inv); if (!invalidated) { - vt->write(*binding->target, binding->property & 0xFFFF, flags); + vt->write(*binding->target, binding->property & 0x0000FFFF, flags); } } else { QQmlData *data = QQmlData::get(*binding->target); @@ -1525,7 +1522,7 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine); QV8Engine *v8engine = ep->v8engine(); - QQmlValueType *vt = ep->valueTypes[QMetaType::QColor]; + QQmlValueType *vt = QQmlValueTypeFactory::valueType(QMetaType::QColor); v8::HandleScope handle_scope; v8::Context::Scope scope(v8engine->context()); new (output.getjsvalueptr()) QJSValue(v8engine->scriptValueFromInternal( @@ -1583,7 +1580,7 @@ void QV4Bindings::run(int instrIndex, quint32 &executedBlocks, } QQmlEnginePrivate *ep = QQmlEnginePrivate::get(context->engine); - QQmlValueType *vt = ep->valueTypes[QMetaType::QColor]; + QQmlValueType *vt = QQmlValueTypeFactory::valueType(QMetaType::QColor); new (output.gethandleptr()) v8::Handle<v8::Value>(ep->v8engine()->valueTypeWrapper()->newValueType(tmp, vt)); V8HANDLE_REGISTER(instr->unaryop.output); } diff --git a/src/qml/qml/v4/qv4bindings_p.h b/src/qml/qml/v4/qv4bindings_p.h index 0c92cc4b45..dd63f6d9f5 100644 --- a/src/qml/qml/v4/qv4bindings_p.h +++ b/src/qml/qml/v4/qv4bindings_p.h @@ -72,8 +72,8 @@ public: virtual ~QV4Bindings(); QQmlAbstractBinding *configBinding(int index, int fallbackIndex, QObject *target, - QObject *scope, int property, - int line, int column); + QObject *scope, int property, int propType, + int line, int column); #ifdef QML_THREADED_INTERPRETER static void **getDecodeInstrTable(); @@ -81,7 +81,7 @@ public: struct Binding : public QQmlAbstractBinding, public QQmlDelayedError { Binding() : QQmlAbstractBinding(V4), index(-1), fallbackIndex(-1), enabled(false), - updating(0), property(0), scope(0), target(0), executedBlocks(0), parent(0) {} + updating(0), property(0), propType(0), scope(0), target(0), executedBlocks(0), parent(0) {} // Inherited from QQmlAbstractBinding static void destroy(QQmlAbstractBinding *); @@ -101,9 +101,11 @@ public: bool enabled:1; bool updating:1; - // Encoding of property is coreIndex | (propType << 16) | (valueTypeIndex << 24) + // Encoding of property is: coreIndex | (valueTypeIndex << 16) // propType and valueTypeIndex are only set if the property is a value type property int property; + quint16 propType; + QObject *scope; int line; int column; |