summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-28 10:53:41 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:06 -0300
commit28401810fe9be0dafea604a50b4139d10f75873a (patch)
tree4766647e24522dabfc46d6b4f73ab826b51846df
parent8265cf08db5817c60f7427e21d85e1a8e8ae5508 (diff)
Class members are traversed after the classes themselves.
To prevent a method that uses a type that was not ready at the moment of analysis, the classes are traversed separately and before the class members, namely fields and methods.
-rw-r--r--abstractmetabuilder.cpp37
-rw-r--r--abstractmetabuilder.h1
2 files changed, 34 insertions, 4 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index e002b57e..fe310cf1 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -385,6 +385,11 @@ bool AbstractMetaBuilder::build(QIODevice* input)
}
ReportHandler::flush();
+ foreach (ClassModelItem item, typeValues)
+ traverseClassMembers(model_dynamic_cast<ScopeModelItem>(item));
+ foreach (NamespaceModelItem namespaceItem, namespaceMap.values())
+ traverseClassMembers(model_dynamic_cast<ScopeModelItem>(namespaceItem));
+
// Global functions
foreach (FunctionModelItem func, m_dom->functions()) {
if (func->accessPolicy() != CodeModel::Public || func->name().startsWith("operator"))
@@ -629,8 +634,6 @@ AbstractMetaClass* AbstractMetaBuilder::traverseNamespace(NamespaceModelItem nam
.arg(namespaceItem->name()));
traverseEnums(model_dynamic_cast<ScopeModelItem>(namespaceItem), metaClass, namespaceItem->enumsDeclarations());
- traverseFunctions(model_dynamic_cast<ScopeModelItem>(namespaceItem), metaClass);
-// traverseClasses(model_dynamic_cast<ScopeModelItem>(namespace_item));
pushScope(model_dynamic_cast<ScopeModelItem>(namespaceItem));
m_namespacePrefix = currentScope()->qualifiedName().join("::");
@@ -1070,8 +1073,6 @@ AbstractMetaClass* AbstractMetaBuilder::traverseClass(ClassModelItem classItem)
parseQ_Property(metaClass, classItem->propertyDeclarations());
traverseEnums(model_dynamic_cast<ScopeModelItem>(classItem), metaClass, classItem->enumsDeclarations());
- traverseFields(model_dynamic_cast<ScopeModelItem>(classItem), metaClass);
- traverseFunctions(model_dynamic_cast<ScopeModelItem>(classItem), metaClass);
// Inner classes
{
@@ -1108,6 +1109,34 @@ AbstractMetaClass* AbstractMetaBuilder::traverseClass(ClassModelItem classItem)
return metaClass;
}
+void AbstractMetaBuilder::traverseClassMembers(ScopeModelItem scopeItem)
+{
+ QString className = stripTemplateArgs(scopeItem->name());
+ QString fullClassName = className;
+
+ // This is an inner class
+ if (m_currentClass)
+ fullClassName = stripTemplateArgs(m_currentClass->typeEntry()->qualifiedCppName()) + "::" + fullClassName;
+
+ AbstractMetaClass* metaClass = m_metaClasses.findClass(fullClassName);
+ if (!metaClass)
+ return;
+
+ AbstractMetaClass* oldCurrentClass = m_currentClass;
+ m_currentClass = metaClass;
+
+ traverseFields(scopeItem, metaClass);
+ traverseFunctions(scopeItem, metaClass);
+
+ {
+ QList<ClassModelItem> innerClasses = scopeItem->classMap().values();
+ foreach (const ClassModelItem& ci, innerClasses)
+ traverseClassMembers(model_dynamic_cast<ScopeModelItem>(ci));
+ }
+
+ m_currentClass = oldCurrentClass;
+}
+
AbstractMetaField* AbstractMetaBuilder::traverseField(VariableModelItem field, const AbstractMetaClass *cls)
{
QString fieldName = field->name();
diff --git a/abstractmetabuilder.h b/abstractmetabuilder.h
index 0d554b9a..afcb07fb 100644
--- a/abstractmetabuilder.h
+++ b/abstractmetabuilder.h
@@ -100,6 +100,7 @@ public:
void addAbstractMetaClass(AbstractMetaClass *cls);
AbstractMetaClass *traverseTypeAlias(TypeAliasModelItem item);
AbstractMetaClass *traverseClass(ClassModelItem item);
+ void traverseClassMembers(ScopeModelItem scopeItem);
bool setupInheritance(AbstractMetaClass *metaClass);
AbstractMetaClass *traverseNamespace(NamespaceModelItem item);
AbstractMetaEnum *traverseEnum(EnumModelItem item, AbstractMetaClass *enclosing, const QSet<QString> &enumsDeclarations);