aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Woehlke <matthew.woehlke@kitware.com>2015-02-17 13:40:46 -0500
committerJohn Cummings <jcummings2@users.sf.net>2015-02-19 13:42:38 +0000
commit4978122812f82f351351767087d7fb9b8915c8c4 (patch)
tree201654c65dee5c7bbb119712f198ce3321a62531
parent4e0031258b9098c5dc02b34e5eb570e54307e6b5 (diff)
Return enums in declaration order (order added)
Modify _ScopeModelItem to return enums (from the enums() method) in the order that they were added (which presumably is the order in which they were declared). We must do this because we must process enumerations in the same order in order to resolve values, as later declared enums may refer to values from earlier declared enums (and in fact, this is exactly the case in the 'testenum' test), and the order we get just from QHash may not match declaration order. Change-Id: I15a05df98a2cee7ecccb6c82d3f9017735281245 Reviewed-by: John Cummings <jcummings2@users.sf.net>
-rw-r--r--ApiExtractor/parser/codemodel.cpp11
-rw-r--r--ApiExtractor/parser/codemodel.h1
2 files changed, 10 insertions, 2 deletions
diff --git a/ApiExtractor/parser/codemodel.cpp b/ApiExtractor/parser/codemodel.cpp
index 43a8c7ec5..7e3468a4b 100644
--- a/ApiExtractor/parser/codemodel.cpp
+++ b/ApiExtractor/parser/codemodel.cpp
@@ -406,7 +406,10 @@ FunctionDefinitionList _ScopeModelItem::functionDefinitions() const
EnumList _ScopeModelItem::enums() const
{
- return _M_enums.values();
+ EnumList result;
+ foreach (const QString& name, _M_enumNames)
+ result.append(_M_enums.value(name));
+ return result;
}
void _ScopeModelItem::addClass(ClassModelItem item)
@@ -440,7 +443,9 @@ void _ScopeModelItem::addTypeAlias(TypeAliasModelItem item)
void _ScopeModelItem::addEnum(EnumModelItem item)
{
+ _M_enumNames.removeOne(item->name());
_M_enums.insert(item->name(), item);
+ _M_enumNames.append(item->name());
}
void _ScopeModelItem::removeClass(ClassModelItem item)
@@ -499,8 +504,10 @@ void _ScopeModelItem::removeEnum(EnumModelItem item)
{
QHash<QString, EnumModelItem>::Iterator it = _M_enums.find(item->name());
- if (it != _M_enums.end() && it.value() == item)
+ if (it != _M_enums.end() && it.value() == item) {
+ _M_enumNames.removeOne(item->name());
_M_enums.erase(it);
+ }
}
ClassModelItem _ScopeModelItem::findClass(const QString &name) const
diff --git a/ApiExtractor/parser/codemodel.h b/ApiExtractor/parser/codemodel.h
index 3b3571f6b..82de75bee 100644
--- a/ApiExtractor/parser/codemodel.h
+++ b/ApiExtractor/parser/codemodel.h
@@ -401,6 +401,7 @@ private:
_ScopeModelItem(const _ScopeModelItem &other);
void operator = (const _ScopeModelItem &other);
+ QStringList _M_enumNames;
QStringList _M_enumsDeclarations;
};