summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2010-06-29 17:19:44 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:06 -0300
commitd3435da2648113d21fa85dc93b5b4f65a80f1731 (patch)
tree936fa8e03bb2ea1cb06395b3e7d68a7375b6b579
parent007442264ec64071abceede296c47f3bbf162776 (diff)
Namespaces must be traversed recursively as they should.
-rw-r--r--abstractmetabuilder.cpp72
-rw-r--r--abstractmetabuilder.h5
2 files changed, 60 insertions, 17 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 41d49d00..9b57e1e1 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -392,9 +392,9 @@ 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));
+ traverseClassMembers(item);
+ foreach (NamespaceModelItem item, namespaceTypeValues)
+ traverseNamespaceMembers(item);
// Global functions
foreach (FunctionModelItem func, m_dom->functions()) {
@@ -667,7 +667,10 @@ AbstractMetaClass* AbstractMetaBuilder::traverseNamespace(NamespaceModelItem nam
}
// Traverse namespaces recursively
- QList<NamespaceModelItem> innerNamespaces = namespaceItem->namespaceMap().values();
+ NamespaceList innerNamespaces = namespaceItem->namespaceMap().values();
+ qSort(innerNamespaces);
+ NamespaceList::iterator it = std::unique(innerNamespaces.begin(), innerNamespaces.end());
+ innerNamespaces.erase(it, innerNamespaces.end());
foreach (const NamespaceModelItem &ni, innerNamespaces) {
AbstractMetaClass* mjc = traverseNamespace(ni);
if (mjc) {
@@ -1115,9 +1118,24 @@ AbstractMetaClass* AbstractMetaBuilder::traverseClass(ClassModelItem classItem)
return metaClass;
}
-void AbstractMetaBuilder::traverseClassMembers(ScopeModelItem scopeItem)
+void AbstractMetaBuilder::traverseScopeMembers(ScopeModelItem item, AbstractMetaClass* metaClass)
{
- QString className = stripTemplateArgs(scopeItem->name());
+ // Classes/Namespace members
+ traverseFields(item, metaClass);
+ traverseFunctions(item, metaClass);
+
+ // Inner classes
+ ClassList innerClasses = item->classMap().values();
+ qSort(innerClasses);
+ ClassList::iterator it = std::unique(innerClasses.begin(), innerClasses.end());
+ innerClasses.erase(it, innerClasses.end());
+ foreach (const ClassModelItem& ci, innerClasses)
+ traverseClassMembers(ci);
+}
+
+AbstractMetaClass* AbstractMetaBuilder::currentTraversedClass(ScopeModelItem item)
+{
+ QString className = stripTemplateArgs(item->name());
QString fullClassName = className;
// This is an inner class
@@ -1126,22 +1144,44 @@ void AbstractMetaBuilder::traverseClassMembers(ScopeModelItem scopeItem)
AbstractMetaClass* metaClass = m_metaClasses.findClass(fullClassName);
if (!metaClass)
+ metaClass = m_templates.findClass(fullClassName);
+ return metaClass;
+}
+
+void AbstractMetaBuilder::traverseClassMembers(ClassModelItem item)
+{
+ AbstractMetaClass* metaClass = currentTraversedClass(model_dynamic_cast<ScopeModelItem>(item));
+ if (!metaClass)
return;
AbstractMetaClass* oldCurrentClass = m_currentClass;
m_currentClass = metaClass;
- traverseFields(scopeItem, metaClass);
- traverseFunctions(scopeItem, metaClass);
+ // Class members
+ traverseScopeMembers(model_dynamic_cast<ScopeModelItem>(item), metaClass);
- {
- ClassList innerClasses = scopeItem->classMap().values();
- qSort(innerClasses);
- ClassList::iterator it = std::unique(innerClasses.begin(), innerClasses.end());
- innerClasses.erase(it, innerClasses.end());
- foreach (const ClassModelItem& ci, innerClasses)
- traverseClassMembers(model_dynamic_cast<ScopeModelItem>(ci));
- }
+ m_currentClass = oldCurrentClass;
+}
+
+void AbstractMetaBuilder::traverseNamespaceMembers(NamespaceModelItem item)
+{
+ AbstractMetaClass* metaClass = currentTraversedClass(model_dynamic_cast<ScopeModelItem>(item));
+ if (!metaClass)
+ return;
+
+ AbstractMetaClass* oldCurrentClass = m_currentClass;
+ m_currentClass = metaClass;
+
+ // Namespace members
+ traverseScopeMembers(model_dynamic_cast<ScopeModelItem>(item), metaClass);
+
+ // Inner namespaces
+ NamespaceList innerNamespaces = item->namespaceMap().values();
+ qSort(innerNamespaces);
+ NamespaceList::iterator it = std::unique(innerNamespaces.begin(), innerNamespaces.end());
+ innerNamespaces.erase(it, innerNamespaces.end());
+ foreach (const NamespaceModelItem &ni, innerNamespaces)
+ traverseNamespaceMembers(ni);
m_currentClass = oldCurrentClass;
}
diff --git a/abstractmetabuilder.h b/abstractmetabuilder.h
index afcb07fb..1bf252f9 100644
--- a/abstractmetabuilder.h
+++ b/abstractmetabuilder.h
@@ -100,7 +100,10 @@ public:
void addAbstractMetaClass(AbstractMetaClass *cls);
AbstractMetaClass *traverseTypeAlias(TypeAliasModelItem item);
AbstractMetaClass *traverseClass(ClassModelItem item);
- void traverseClassMembers(ScopeModelItem scopeItem);
+ AbstractMetaClass* currentTraversedClass(ScopeModelItem item);
+ void traverseScopeMembers(ScopeModelItem item, AbstractMetaClass* metaClass);
+ void traverseClassMembers(ClassModelItem scopeItem);
+ void traverseNamespaceMembers(NamespaceModelItem scopeItem);
bool setupInheritance(AbstractMetaClass *metaClass);
AbstractMetaClass *traverseNamespace(NamespaceModelItem item);
AbstractMetaEnum *traverseEnum(EnumModelItem item, AbstractMetaClass *enclosing, const QSet<QString> &enumsDeclarations);