diff options
author | Eike Ziller <eike.ziller@nokia.com> | 2011-11-01 18:16:38 +0100 |
---|---|---|
committer | Eike Ziller <eike.ziller@nokia.com> | 2011-11-01 18:16:38 +0100 |
commit | 912cd548c0b0950b3a1e80f2597c99b3bf898c83 (patch) | |
tree | c9eeb5ac857dcabcfb404f60356ad4522471d9ed /src/libs/qmljs/qmljsinterpreter.cpp | |
parent | ddde938174f03544182adb79179d192502b50e51 (diff) | |
parent | 002820867cc0f4f5c67c5ae976eec26157275d4f (diff) | |
download | qt-creator-912cd548c0b0950b3a1e80f2597c99b3bf898c83.tar.gz |
Merge remote-tracking branch 'origin/2.4'
Conflicts:
src/libs/qmljs/qmljsinterpreter.cpp
src/libs/qmljs/qmljsinterpreter.h
src/plugins/madde/maemopackagecreationstep.cpp
src/plugins/projectexplorer/buildmanager.cpp
src/plugins/qmljstools/qmljsqtstylecodeformatter.cpp
src/plugins/qmljstools/qmljsqtstylecodeformatter.h
tests/auto/qml/qmleditor/qmlcodeformatter/tst_qmlcodeformatter.cpp
Change-Id: I63ab2ba5dac006c37ccfbae55b023396a4676ff7
Diffstat (limited to 'src/libs/qmljs/qmljsinterpreter.cpp')
-rw-r--r-- | src/libs/qmljs/qmljsinterpreter.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/libs/qmljs/qmljsinterpreter.cpp b/src/libs/qmljs/qmljsinterpreter.cpp index 3a1ff62e8c..8d52e137d4 100644 --- a/src/libs/qmljs/qmljsinterpreter.cpp +++ b/src/libs/qmljs/qmljsinterpreter.cpp @@ -337,6 +337,22 @@ const CppComponentValue *CppComponentValue::prototype() const return static_cast<const CppComponentValue *>(_prototype); } +/*! + \returns a list started by this object and followed by all its prototypes + + Prefer to use this over calling prototype() in a loop, as it avoids cycles. +*/ +QList<const CppComponentValue *> CppComponentValue::prototypes() const +{ + QList<const CppComponentValue *> protos; + for (const CppComponentValue *it = this; it; it = it->prototype()) { + if (protos.contains(it)) + break; + protos += it; + } + return protos; +} + const CppComponentValue *CppComponentValue::attachedType() const { return _attachedType; @@ -366,7 +382,7 @@ QString CppComponentValue::defaultPropertyName() const QString CppComponentValue::propertyType(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -378,7 +394,7 @@ QString CppComponentValue::propertyType(const QString &propertyName) const bool CppComponentValue::isListProperty(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -390,7 +406,7 @@ bool CppComponentValue::isListProperty(const QString &propertyName) const FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppComponentValue **foundInScope) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; const int index = iter->enumeratorIndex(typeName); if (index != -1) { @@ -406,7 +422,7 @@ FakeMetaEnum CppComponentValue::getEnum(const QString &typeName, const CppCompon const QmlEnumValue *CppComponentValue::getEnumValue(const QString &typeName, const CppComponentValue **foundInScope) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { if (const QmlEnumValue *e = it->_enums.value(typeName)) { if (foundInScope) *foundInScope = it; @@ -455,7 +471,7 @@ const ObjectValue *CppComponentValue::signalScope(const QString &signalName) con bool CppComponentValue::isWritable(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -467,7 +483,7 @@ bool CppComponentValue::isWritable(const QString &propertyName) const bool CppComponentValue::isPointer(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -487,7 +503,7 @@ bool CppComponentValue::hasLocalProperty(const QString &typeName) const bool CppComponentValue::hasProperty(const QString &propertyName) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; int propIdx = iter->propertyIndex(propertyName); if (propIdx != -1) { @@ -499,7 +515,7 @@ bool CppComponentValue::hasProperty(const QString &propertyName) const bool CppComponentValue::isDerivedFrom(FakeMetaObject::ConstPtr base) const { - for (const CppComponentValue *it = this; it; it = it->prototype()) { + foreach (const CppComponentValue *it, prototypes()) { FakeMetaObject::ConstPtr iter = it->_metaObject; if (iter == base) return true; |