aboutsummaryrefslogtreecommitdiffstats
path: root/abstractmetabuilder.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-06-03 16:47:55 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-09 19:10:04 -0300
commit89696d216b41239f950e599a88093e18bf2724c8 (patch)
tree938061fd21c94921071d42e17a707f5e1c07abb7 /abstractmetabuilder.cpp
parent644d7b74d18a5838a7f26de02bd0aa9a212de85c (diff)
Use qualified c++ names instead to do the topological sort.
Not using topological sort will generate an incorrect sorting when there are two or more classes with the same name in different scopes. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Ara├║jo <renato.araujo@openbossa.org>
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r--abstractmetabuilder.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index f51024b4..23864257 100644
--- a/abstractmetabuilder.cpp
+++ b/abstractmetabuilder.cpp
@@ -2512,7 +2512,7 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const Abstra
int i = 0;
foreach (AbstractMetaClass* clazz, classList) {
- map[clazz->name()] = i;
+ map[clazz->qualifiedCppName()] = i;
reverseMap[i] = clazz;
i++;
}
@@ -2524,12 +2524,13 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const Abstra
if (clazz->isInterface() || !clazz->typeEntry()->generateCode())
continue;
- if (clazz->enclosingClass() && map.contains(clazz->enclosingClass()->name()))
- graph.addEdge(map[clazz->enclosingClass()->name()], map[clazz->name()]);
+ if (clazz->enclosingClass() && map.contains(clazz->enclosingClass()->qualifiedCppName()))
+ graph.addEdge(map[clazz->enclosingClass()->qualifiedCppName()], map[clazz->qualifiedCppName()]);
- foreach(AbstractMetaClass* baseClass, getBaseClasses(clazz)) {
- if (map.contains(baseClass->name()))
- graph.addEdge(map[baseClass->name()], map[clazz->name()]);
+ AbstractMetaClassList bases = getBaseClasses(clazz);
+ foreach(AbstractMetaClass* baseClass, bases) {
+ if (map.contains(baseClass->qualifiedCppName()))
+ graph.addEdge(map[baseClass->qualifiedCppName()], map[clazz->qualifiedCppName()]);
}
foreach (AbstractMetaFunction* func, clazz->functions()) {
@@ -2543,8 +2544,27 @@ AbstractMetaClassList AbstractMetaBuilder::classesTopologicalSorted(const Abstra
defaultExpression.replace(regex1, "");
defaultExpression.replace(regex2, "");
}
- if (!defaultExpression.isEmpty() && defaultExpression != clazz->name() && map.contains(defaultExpression))
- graph.addEdge(map[defaultExpression], map[clazz->name()]);
+ if (!defaultExpression.isEmpty()) {
+ QString exprClassName = clazz->qualifiedCppName() + "::" + defaultExpression;
+ if (!map.contains(exprClassName)) {
+ bool found = false;
+ foreach(AbstractMetaClass* baseClass, bases) {
+ exprClassName = baseClass->qualifiedCppName() + "::" + defaultExpression;
+ if (map.contains(exprClassName)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ if (map.contains(defaultExpression))
+ exprClassName = defaultExpression;
+ else
+ exprClassName.clear();
+ }
+ }
+ if (!exprClassName.isEmpty() && exprClassName != clazz->qualifiedCppName())
+ graph.addEdge(map[exprClassName], map[clazz->qualifiedCppName()]);
+ }
}
}
}