summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-28 10:48:02 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:06 -0300
commit8265cf08db5817c60f7427e21d85e1a8e8ae5508 (patch)
tree3f5b54f4254db1c748c1c5d59d85da24302b691d
parent509769c4d96752265f652ce2cc0f5931ebfae42b (diff)
Type translation now looks in the class' parent scope.
When trying to figure out a type the AbstractMetaBuilder::translateType method should also look in the class' parent scope.
-rw-r--r--abstractmetabuilder.cpp24
1 files changed, 20 insertions, 4 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 2ceb7b24..e002b57e 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -1711,6 +1711,17 @@ AbstractMetaType* AbstractMetaBuilder::translateType(double vr, const AddedFunct
return metaType;
}
+static const TypeEntry* findTypeEntryUsingContext(const AbstractMetaClass* metaClass, const QString& qualifiedName)
+{
+ const TypeEntry* type = 0;
+ QStringList context = metaClass->qualifiedCppName().split("::");
+ while(!type && (context.size() > 0) ) {
+ type = TypeDatabase::instance()->findType(context.join("::") + "::" + qualifiedName);
+ context.removeLast();
+ }
+ return type;
+}
+
AbstractMetaType* AbstractMetaBuilder::translateType(const TypeInfo& _typei, bool *ok, bool resolveType, bool resolveScope)
{
Q_ASSERT(ok);
@@ -1821,10 +1832,15 @@ AbstractMetaType* AbstractMetaBuilder::translateType(const TypeInfo& _typei, boo
// 5.1 - Try first using the current scope
if (m_currentClass) {
- QStringList context = m_currentClass->qualifiedCppName().split("::");
- while(!type && (context.size() > 0) ) {
- type = TypeDatabase::instance()->findType(context.join("::") + "::" + qualifiedName);
- context.removeLast();
+ type = findTypeEntryUsingContext(m_currentClass, qualifiedName);
+
+ // 5.1.1 - Try using the class parents' scopes
+ if (!type && !m_currentClass->baseClassNames().isEmpty()) {
+ foreach (const AbstractMetaClass* cls, getBaseClasses(m_currentClass)) {
+ type = findTypeEntryUsingContext(cls, qualifiedName);
+ if (type)
+ break;
+ }
}
}