diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-15 13:22:27 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2016-06-17 04:03:15 +0000 |
commit | 2997b7ea99906801c9cb92a7e095c8044c86dc0a (patch) | |
tree | 451f527138fad7aa098ed7d1d9f94e74fff6b840 /src/qml | |
parent | cc297f8eadd4decf640a8bf1d09d14d3e3fac48e (diff) |
Added iterator interfaces to QV4::CompiledData::*
These interfaces are required in order to be able to use the
QQmlPropertyCacheCreator template.
Change-Id: I371e7102aac00fd607fc6a8ad7ffc18996608758
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qv4compileddata_p.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index b24d93d995..fb82b2bcbb 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -95,6 +95,19 @@ struct Lookup; struct RegExp; struct Unit; +template <typename ItemType, typename Container, const ItemType *(Container::*IndexedGetter)(int index) const> +struct TableIterator +{ + TableIterator(const Container *container, int index) : container(container), index(index) {} + const Container *container; + int index; + + const ItemType *operator->() { return (container->*IndexedGetter)(index); } + void operator++() { ++index; } + bool operator==(const TableIterator &rhs) const { return index == rhs.index; } + bool operator!=(const TableIterator &rhs) const { return index != rhs.index; } +}; + #if defined(Q_CC_MSVC) || defined(Q_CC_GNU) #pragma pack(push, 1) #endif @@ -205,6 +218,11 @@ struct Function const quint32 *qmlContextPropertiesDependencyTable() const { return reinterpret_cast<const quint32 *>(reinterpret_cast<const char *>(this) + dependingContextPropertiesOffset); } const quint32 *qmlScopePropertiesDependencyTable() const { return reinterpret_cast<const quint32 *>(reinterpret_cast<const char *>(this) + dependingScopePropertiesOffset); } + // --- QQmlPropertyCacheCreator interface + const quint32 *formalsBegin() const { return formalsTable(); } + const quint32 *formalsEnd() const { return formalsTable() + nFormals; } + // --- + inline bool hasQmlDependencies() const { return nDependingIdObjects > 0 || nDependingContextProperties > 0 || nDependingScopeProperties > 0; } static int calculateSize(int nFormals, int nLocals, int nInnerfunctions, int nIdObjectDependencies, int nPropertyDependencies) { @@ -355,6 +373,12 @@ struct Signal + nParameters * sizeof(Parameter) + 7) & ~0x7; } + + // --- QQmlPropertyCacheCceatorInterface + const Parameter *parametersBegin() const { return parameterAt(0); } + const Parameter *parametersEnd() const { return parameterAt(nParameters); } + int parameterCount() const { return nParameters; } + // --- }; struct Property @@ -481,6 +505,26 @@ struct Object { return reinterpret_cast<const quint32*>(reinterpret_cast<const char *>(this) + offsetToNamedObjectsInComponent); } + + // --- QQmlPropertyCacheCreator interface + int propertyCount() const { return nProperties; } + int aliasCount() const { return nAliases; } + int signalCount() const { return nSignals; } + int functionCount() const { return nFunctions; } + + const Binding *bindingsBegin() const { return bindingTable(); } + const Binding *bindingsEnd() const { return bindingTable() + nBindings; } + + const Property *propertiesBegin() const { return propertyTable(); } + const Property *propertiesEnd() const { return propertyTable() + nProperties; } + + const Alias *aliasesBegin() const { return aliasTable(); } + const Alias *aliasesEnd() const { return aliasTable() + nAliases; } + + typedef TableIterator<Signal, Object, &Object::signalAt> SignalIterator; + SignalIterator signalsBegin() const { return SignalIterator(this, 0); } + SignalIterator signalsEnd() const { return SignalIterator(this, nSignals); } + // --- }; struct Import @@ -754,6 +798,29 @@ struct Q_QML_PRIVATE_EXPORT CompilationUnit : public QQmlRefCount bool isRegisteredWithEngine; + // --- interface for QQmlPropertyCacheCreator + typedef Object CompiledObject; + int objectCount() const { return data->nObjects; } + int rootObjectIndex() const { return data->indexOfRootObject; } + const Object *objectAt(int index) const { return data->objectAt(index); } + QString stringAt(int index) const { return data->stringAt(index); } + + struct FunctionIterator + { + FunctionIterator(const Unit *unit, const Object *object, int index) : unit(unit), object(object), index(index) {} + const Unit *unit; + const Object *object; + int index; + + const Function *operator->() const { return unit->functionAt(object->functionOffsetTable()[index]); } + void operator++() { ++index; } + bool operator==(const FunctionIterator &rhs) const { return index == rhs.index; } + bool operator!=(const FunctionIterator &rhs) const { return index != rhs.index; } + }; + FunctionIterator objectFunctionsBegin(const Object *object) const { return FunctionIterator(data, object, 0); } + FunctionIterator objectFunctionsEnd(const Object *object) const { return FunctionIterator(data, object, object->nFunctions); } + // --- + QV4::Function *linkToEngine(QV4::ExecutionEngine *engine); void unlink(); |