aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--abstractmetabuilder.cpp41
-rw-r--r--abstractmetabuilder.h12
-rw-r--r--apiextractor.cpp1
3 files changed, 35 insertions, 19 deletions
diff --git a/abstractmetabuilder.cpp b/abstractmetabuilder.cpp
index 994448b9..797f76d2 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 9aef28a5..e676f121 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 2e16b8ec..00734de8 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;