From 8265cf08db5817c60f7427e21d85e1a8e8ae5508 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 28 Jun 2010 10:48:02 -0300 Subject: 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. --- abstractmetabuilder.cpp | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp index 2ceb7b247..e002b57ea 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; + } } } -- cgit v1.2.3