From 1e04343e905c35efd58f85c9ba7105d209522278 Mon Sep 17 00:00:00 2001 From: Hugo Parente Lima Date: Wed, 3 Aug 2011 17:11:51 -0300 Subject: Find the package name even when no classes were found. Reviewer: Luciano Wolf Marcelo Lira --- generator.cpp | 23 ++++++++++++++++------- main.cpp | 6 ++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/generator.cpp b/generator.cpp index dc90f4b78..cc60be64a 100644 --- a/generator.cpp +++ b/generator.cpp @@ -30,6 +30,7 @@ #include #include #include +#include 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 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); } diff --git a/main.cpp b/main.cpp index 804faf7d1..0bd882056 100644 --- a/main.cpp +++ b/main.cpp @@ -317,10 +317,8 @@ int main(int argc, char *argv[]) if (!extractor.run()) return EXIT_FAILURE; - if (!extractor.classCount()) { - std::cerr << "No C++ classes found!" << std::endl; - return EXIT_FAILURE; - } + if (!extractor.classCount()) + ReportHandler::warning("No C++ classes found!"); foreach (Generator* g, generators) { g->setOutputDirectory(outputDirectory); -- cgit v1.2.3