diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-07-07 14:09:04 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:17 -0300 |
commit | 28510ddcf9d856c9ae351a30abb7593d418b7dd6 (patch) | |
tree | c193f938c1311371e5c257f3f4c1ee00fe1b694c /abstractmetabuilder.cpp | |
parent | 9aabb6c3a5505da1e44be2dbec366f51fb2249ba (diff) |
Check inconsistencies for enums and disable generation of private entities.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Renato Filho <renato.filho@openbossa.org>
Diffstat (limited to 'abstractmetabuilder.cpp')
-rw-r--r-- | abstractmetabuilder.cpp | 111 |
1 files changed, 65 insertions, 46 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp index 45ceab872..d8e5514c9 100644 --- a/abstractmetabuilder.cpp +++ b/abstractmetabuilder.cpp @@ -478,55 +478,64 @@ bool AbstractMetaBuilder::build(QIODevice* input) } ReportHandler::flush(); - QList<TypeEntry*> entries = types->entries().values(); - ReportHandler::setProgressReference(entries); - foreach (const TypeEntry *entry, entries) { - ReportHandler::progress("Detecting inconsistencies in typesystem..."); + TypeEntryHash allEntries = types->allEntries(); + ReportHandler::progress("Detecting inconsistencies in typesystem..."); + foreach (QList<TypeEntry*> entries, allEntries) { + foreach (TypeEntry* entry, entries) { - if (entry->isPrimitive()) - continue; + if (entry->isPrimitive()) + continue; - if (!types->supportedApiVersion(entry->version())) { - m_rejectedClasses.insert(entry->name(), ApiIncompatible); - continue; - } + if (!types->supportedApiVersion(entry->version())) { + m_rejectedClasses.insert(entry->name(), ApiIncompatible); + continue; + } - if ((entry->isValue() || entry->isObject()) - && !entry->isString() - && !entry->isChar() - && !entry->isContainer() - && !entry->isCustom() - && !entry->isVariant() - && !m_metaClasses.findClass(entry->qualifiedCppName())) { - ReportHandler::warning(QString("type '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.") - .arg(entry->qualifiedCppName())); - } else if (entry->generateCode() && entry->type() == TypeEntry::FunctionType) { - const FunctionTypeEntry* fte = static_cast<const FunctionTypeEntry*>(entry); - foreach (QString signature, fte->signatures()) { - bool ok = false; - foreach (AbstractMetaFunction* func, m_globalFunctions) { - if (signature == func->minimalSignature()) { - ok = true; - break; + if ((entry->isValue() || entry->isObject()) + && !entry->isString() + && !entry->isChar() + && !entry->isContainer() + && !entry->isCustom() + && !entry->isVariant() + && !m_metaClasses.findClass(entry->qualifiedCppName())) { + ReportHandler::warning(QString("type '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.") + .arg(entry->qualifiedCppName())); + } else if (entry->generateCode() && entry->type() == TypeEntry::FunctionType) { + const FunctionTypeEntry* fte = static_cast<const FunctionTypeEntry*>(entry); + foreach (QString signature, fte->signatures()) { + bool ok = false; + foreach (AbstractMetaFunction* func, m_globalFunctions) { + if (signature == func->minimalSignature()) { + ok = true; + break; + } + } + if (!ok) { + ReportHandler::warning(QString("Global function '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.") + .arg(signature)); } } - if (!ok) { - ReportHandler::warning(QString("Global function '%1' is specified in typesystem, but not defined. This could potentially lead to compilation errors.") - .arg(signature)); + } else if (entry->isEnum()) { + const QString name = ((EnumTypeEntry*) entry)->targetLangQualifier(); + AbstractMetaClass* cls = m_metaClasses.findClass(name); + + bool enumFound = false; + if (cls) { + enumFound = cls->findEnum(entry->targetLangName()); + } else { // Global enum + foreach (AbstractMetaEnum* metaEnum, m_enums) { + if (metaEnum->typeEntry() == entry) { + enumFound = true; + break; + } + } } - } - } else if (entry->isEnum()) { - QString pkg = entry->targetLangPackage(); - QString name = (pkg.isEmpty() ? QString() : pkg + ".") - + ((EnumTypeEntry*) entry)->targetLangQualifier(); - AbstractMetaClass* cls = m_metaClasses.findClass(name); - - if (cls) { - AbstractMetaEnum* e = cls->findEnum(entry->targetLangName()); - if (!e) - ReportHandler::warning(QString("enum '%1' is specified in typesystem, " - "but not declared") + if (!enumFound) { + entry->setCodeGeneration(TypeEntry::GenerateNothing); + ReportHandler::warning(QString("enum '%1' is specified in typesystem, but not declared") .arg(entry->qualifiedCppName())); + } + } } } @@ -945,6 +954,7 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst className = m_currentClass->typeEntry()->qualifiedCppName(); if (TypeDatabase::instance()->isEnumRejected(className, enumName)) { + typeEntry->setCodeGeneration(TypeEntry::GenerateNothing); m_rejectedEnums.insert(qualifiedName, GenerationDisabled); return 0; } @@ -958,6 +968,7 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst // Skipping api incompatible if (!TypeDatabase::instance()->supportedApiVersion(typeEntry->version())) { + typeEntry->setCodeGeneration(TypeEntry::GenerateNothing); m_rejectedEnums.insert(qualifiedName, ApiIncompatible); return 0; } @@ -970,10 +981,18 @@ AbstractMetaEnum* AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst metaEnum->setTypeEntry((EnumTypeEntry*) typeEntry); switch (enumItem->accessPolicy()) { - case CodeModel::Public: *metaEnum += AbstractMetaAttributes::Public; break; - case CodeModel::Protected: *metaEnum += AbstractMetaAttributes::Protected; break; - case CodeModel::Private: *metaEnum += AbstractMetaAttributes::Private; break; - default: break; + case CodeModel::Public: + *metaEnum += AbstractMetaAttributes::Public; + break; + case CodeModel::Protected: + *metaEnum += AbstractMetaAttributes::Protected; + break; + case CodeModel::Private: + *metaEnum += AbstractMetaAttributes::Private; + typeEntry->setCodeGeneration(TypeEntry::GenerateNothing); + break; + default: + break; } ReportHandler::debugMedium(QString(" - traversing enum %1").arg(metaEnum->fullName())); |