diff options
author | Hugo Parente Lima <hugo.lima@openbossa.org> | 2010-04-15 18:45:40 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:00 -0300 |
commit | 8c03a55d03b2e63b760ec3be4a37285304b65b32 (patch) | |
tree | 4da79f7d8342ffdc5bc3fc6f317caad44f9f068e | |
parent | f267a89cfb4d5bf4e405db9ab1360d90ee70f867 (diff) |
Do not set the include file on TypeEntries when the include file does not exists or
it's the global header.
-rw-r--r-- | abstractmetabuilder.cpp | 41 | ||||
-rw-r--r-- | abstractmetabuilder.h | 12 | ||||
-rw-r--r-- | apiextractor.cpp | 1 |
3 files changed, 35 insertions, 19 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp index 994448b9a..797f76d2d 100644 --- a/abstractmetabuilder.cpp +++ b/abstractmetabuilder.cpp @@ -522,8 +522,7 @@ bool AbstractMetaBuilder::build(QIODevice* input) continue; } - QFileInfo info(func->fileName()); - funcEntry->setInclude(Include(Include::IncludePath, info.fileName())); + setInclude(funcEntry, func->fileName()); m_globalFunctions << metaFunc; } @@ -634,10 +633,8 @@ AbstractMetaClass *AbstractMetaBuilder::traverseNamespace(NamespaceModelItem nam popScope(); m_namespacePrefix = currentScope()->qualifiedName().join("::"); - if (!type->include().isValid()) { - QFileInfo info(namespaceItem->fileName()); - type->setInclude(Include(Include::IncludePath, info.fileName())); - } + if (!type->include().isValid()) + setInclude(type, namespaceItem->fileName()); return metaClass; } @@ -939,10 +936,9 @@ AbstractMetaEnum *AbstractMetaBuilder::traverseEnum(EnumModelItem enumItem, Abst m_enums << metaEnum; - if (!metaEnum->typeEntry()->include().isValid()) { - QFileInfo info(enumItem->fileName()); - metaEnum->typeEntry()->setInclude(Include(Include::IncludePath, info.fileName())); - } + if (!metaEnum->typeEntry()->include().isValid()) + setInclude(metaEnum->typeEntry(), enumItem->fileName()); + metaEnum->setOriginalAttributes(metaEnum->attributes()); return metaEnum; @@ -985,10 +981,8 @@ AbstractMetaClass* AbstractMetaBuilder::traverseTypeAlias(TypeAliasModelItem typ *metaClass += AbstractMetaAttributes::Public; // Set the default include file name - if (!type->include().isValid()) { - QFileInfo info(typeAlias->fileName()); - type->setInclude(Include(Include::IncludePath, info.fileName())); - } + if (!type->include().isValid()) + setInclude(type, typeAlias->fileName()); return metaClass; } @@ -1098,10 +1092,8 @@ AbstractMetaClass *AbstractMetaBuilder::traverseClass(ClassModelItem classItem) m_currentClass = oldCurrentClass; // Set the default include file name - if (!type->include().isValid()) { - QFileInfo info(classItem->fileName()); - type->setInclude(Include(Include::IncludePath, info.fileName())); - } + if (!type->include().isValid()) + setInclude(type, classItem->fileName()); return metaClass; } @@ -2749,3 +2741,16 @@ AbstractMetaArgumentList AbstractMetaBuilder::reverseList(const AbstractMetaArgu return ret; } + +void AbstractMetaBuilder::setGlobalHeader(const QString& globalHeader) +{ + m_globalHeader = QFileInfo(globalHeader); +} + +void AbstractMetaBuilder::setInclude(TypeEntry* te, const QString& fileName) const +{ + + QFileInfo info(fileName); + if (info.exists() && m_globalHeader != info) + te->setInclude(Include(Include::IncludePath, info.fileName())); +} diff --git a/abstractmetabuilder.h b/abstractmetabuilder.h index 9aef28a55..e676f1217 100644 --- a/abstractmetabuilder.h +++ b/abstractmetabuilder.h @@ -29,7 +29,8 @@ #include "typesystem.h" #include "typeparser.h" -#include <QtCore/QSet> +#include <QSet> +#include <QFileInfo> class TypeDatabase; @@ -170,6 +171,13 @@ public: return m_qmetatypeDeclaredTypenames; } + /** + * AbstractMetaBuilder should know what's the global header being used, + * so any class declared under this header wont have the include file + * filled. + */ + void setGlobalHeader(const QString& globalHeader); + protected: AbstractMetaClass *argumentToClass(ArgumentModelItem); @@ -213,6 +221,7 @@ protected: private: void sortLists(); AbstractMetaArgumentList reverseList(const AbstractMetaArgumentList& list); + void setInclude(TypeEntry* te, const QString& fileName) const; AbstractMetaClassList m_metaClasses; AbstractMetaClassList m_templates; @@ -242,6 +251,7 @@ private: QSet<QString> m_qmetatypeDeclaredTypenames; QString m_logDirectory; + QFileInfo m_globalHeader; }; #endif // ABSTRACTMETBUILDER_H diff --git a/apiextractor.cpp b/apiextractor.cpp index 2e16b8ec5..00734de8d 100644 --- a/apiextractor.cpp +++ b/apiextractor.cpp @@ -166,6 +166,7 @@ bool ApiExtractor::run() ppFile.seek(0); m_builder = new AbstractMetaBuilder; m_builder->setLogDirectory(m_logDirectory); + m_builder->setGlobalHeader(m_cppFileName); m_builder->build(&ppFile); return true; |