diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-08-03 17:11:51 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-08-04 13:55:15 -0300 |
commit | 1e04343e905c35efd58f85c9ba7105d209522278 (patch) | |
tree | 51138c75a597ca06fa5c321f929c560e14b9c45c /generator.cpp | |
parent | 127ad5d710b3b584666efd6d939bf068b0b9d202 (diff) |
Find the package name even when no classes were found.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'generator.cpp')
-rw-r--r-- | generator.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/generator.cpp b/generator.cpp index dc90f4b78..cc60be64a 100644 --- a/generator.cpp +++ b/generator.cpp @@ -30,6 +30,7 @@ #include <QtCore/QFile> #include <QtCore/QFileInfo> #include <QDebug> +#include <typedatabase.h> struct Generator::GeneratorPrivate { const ApiExtractor* apiextractor; @@ -55,15 +56,23 @@ Generator::~Generator() bool Generator::setup(const ApiExtractor& extractor, const QMap< QString, QString > args) { m_d->apiextractor = &extractor; - // FIXME: Avoid this ugly hack to get the package name.. and... why the name "package"!? - foreach (const AbstractMetaClass* cppClass, m_d->apiextractor->classes()) { - if (m_d->packageName.isEmpty() - && cppClass->typeEntry()->generateCode() - && !cppClass->package().isEmpty()) { - m_d->packageName = cppClass->package(); - break; + TypeEntryHash allEntries = TypeDatabase::instance()->allEntries(); + TypeEntry* entryFound = 0; + foreach (QList<TypeEntry*> entryList, allEntries.values()) { + foreach (TypeEntry* entry, entryList) { + if (entry->type() == TypeEntry::TypeSystemType && entry->generateCode()) { + entryFound = entry; + break; + } } + if (entryFound) + break; } + + if (entryFound) + m_d->packageName = entryFound->name(); + else + ReportHandler::warning("Couldn't find the package name!!"); return doSetup(args); } |