From 4978122812f82f351351767087d7fb9b8915c8c4 Mon Sep 17 00:00:00 2001 From: Matthew Woehlke Date: Tue, 17 Feb 2015 13:40:46 -0500 Subject: 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 --- ApiExtractor/parser/codemodel.cpp | 11 +++++++++-- ApiExtractor/parser/codemodel.h | 1 + 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::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; }; -- cgit v1.2.3