summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.lima@openbossa.org>2010-04-14 14:15:55 -0300
committerHugo Parente Lima <hugo.lima@openbossa.org>2010-04-22 19:45:24 -0300
commit63bb4a282c30d7ceecf4f23465db48524a20ebf7 (patch)
treec11e71d1398f9d09a92aa018f5440c934e3d79a8
parent068ac86d025006256aa1edfcccf4304bcd280779 (diff)
downloadshiboken-63bb4a282c30d7ceecf4f23465db48524a20ebf7.tar.gz
shiboken-63bb4a282c30d7ceecf4f23465db48524a20ebf7.tar.xz
shiboken-63bb4a282c30d7ceecf4f23465db48524a20ebf7.zip
Add include headers of global enums.
-rw-r--r--cppgenerator.cpp22
-rw-r--r--headergenerator.cpp43
-rw-r--r--shibokengenerator.cpp1
3 files changed, 21 insertions, 45 deletions
diff --git a/cppgenerator.cpp b/cppgenerator.cpp
index 1ec1e44e..28809330 100644
--- a/cppgenerator.cpp
+++ b/cppgenerator.cpp
@@ -23,6 +23,7 @@
#include "cppgenerator.h"
#include <reporthandler.h>
+#include <typedatabase.h>
#include <QtCore/QDir>
#include <QtCore/QTextStream>
@@ -2862,7 +2863,7 @@ void CppGenerator::finishGeneration()
QString namespaceDefines;
QTextStream s_namespaceDefines(&namespaceDefines);
- QSet<QString> includes;
+ QSet<Include> includes;
QString globalFunctionImpl;
QTextStream s_globalFunctionImpl(&globalFunctionImpl);
QString globalFunctionDecl;
@@ -2873,16 +2874,6 @@ void CppGenerator::finishGeneration()
foreach (AbstractMetaFunctionList globalOverloads, getFunctionGroups().values()) {
AbstractMetaFunctionList overloads;
foreach (AbstractMetaFunction* func, globalOverloads) {
- // TODO: this is an ugly hack to avoid binding global
- // functions from outside the library beign processed.
- // The decent solution is to expand API Extractor so
- // that it support global function declarations on
- // type system files.
- QString incFile = func->includeFile();
- QRegExp regex("\\b(?:lib)?" + moduleName() + "\\b");
- if (!func->isUserAdded() && regex.indexIn(incFile) == -1)
- continue;
-
if (!func->isModifiedRemoved())
overloads.append(func);
}
@@ -2890,9 +2881,8 @@ void CppGenerator::finishGeneration()
if (overloads.isEmpty())
continue;
- QString includeFile = overloads.first()->includeFile();
- if (!includeFile.isEmpty())
- includes << includeFile;
+ if (overloads.first()->typeEntry())
+ includes << overloads.first()->typeEntry()->include();
writeMethodWrapper(s_globalFunctionImpl, overloads);
writeMethodDefinition(s_globalFunctionDef, overloads);
@@ -2928,8 +2918,8 @@ void CppGenerator::finishGeneration()
s << "#include <Python.h>" << endl;
s << "#include <shiboken.h>" << endl;
s << "#include \"" << getModuleHeaderFileName() << '"' << endl << endl;
- foreach (const QString& include, includes)
- s << "#include \"" << include << '\"' << endl;
+ foreach (const Include& include, includes)
+ s << include;
s << endl;
TypeSystemTypeEntry* moduleEntry = reinterpret_cast<TypeSystemTypeEntry*>(TypeDatabase::instance()->findType(packageName()));
diff --git a/headergenerator.cpp b/headergenerator.cpp
index a44e53ed..55dcfacb 100644
--- a/headergenerator.cpp
+++ b/headergenerator.cpp
@@ -22,6 +22,7 @@
*/
#include "headergenerator.h"
+#include <typedatabase.h>
#include <reporthandler.h>
#include <QtCore/QDir>
@@ -65,8 +66,7 @@ void HeaderGenerator::generateClass(QTextStream& s, const AbstractMetaClass* met
s << "#include <shiboken.h>" << endl << endl;
//Includes
- if (metaClass->typeEntry()->include().isValid())
- s << metaClass->typeEntry()->include().toString() << endl << endl;
+ s << metaClass->typeEntry()->include() << endl;
if (shouldGenerateCppWrapper(metaClass)) {
@@ -232,9 +232,7 @@ void HeaderGenerator::finishGeneration()
// Generate the main header for this module.
// This header should be included by binding modules
// extendind on top of this one.
- QString classIncludes;
- QTextStream s_cin(&classIncludes);
- QSet<QString> enumIncludes;
+ QSet<Include> includes;
QString pythonTypeStuff;
QTextStream s_pts(&pythonTypeStuff);
QString convertersDecl;
@@ -262,9 +260,7 @@ void HeaderGenerator::finishGeneration()
s_pts << "// Useful macros" << endl;
foreach (const AbstractMetaEnum* cppEnum, globalEnums()) {
- QString incFile = cppEnum->includeFile().split(QDir::separator()).takeLast();
- if (!incFile.isEmpty())
- enumIncludes << cppEnum->includeFile();
+ includes << cppEnum->typeEntry()->include();
writeTypeCheckMacro(s_pts, cppEnum->typeEntry());
FlagsTypeEntry* flags = cppEnum->typeEntry()->flags();
if (flags)
@@ -282,10 +278,10 @@ void HeaderGenerator::finishGeneration()
continue;
//Includes
- if (metaClass->typeEntry()->include().isValid())
- s_cin << metaClass->typeEntry()->include().toString() << endl;
+ includes << metaClass->typeEntry()->include();
foreach (const AbstractMetaEnum* cppEnum, metaClass->enums()) {
+ includes << cppEnum->typeEntry()->include();
writeTypeCheckMacro(s_pts, cppEnum->typeEntry());
writeTypeConverterDecl(convDecl, cppEnum->typeEntry());
FlagsTypeEntry* flagsEntry = cppEnum->typeEntry()->flags();
@@ -300,13 +296,12 @@ void HeaderGenerator::finishGeneration()
if (!metaClass->isNamespace()) {
writeSbkTypeFunction(typeFunctions, metaClass);
-
writeSbkCopyCppObjectFunction(convDecl, metaClass);
foreach (AbstractMetaClass* innerClass, metaClass->innerClasses()) {
if (shouldGenerate(innerClass)) {
+ includes << innerClass->typeEntry()->include();
writeSbkCopyCppObjectFunction(convDecl, innerClass);
- s_cin << innerClass->typeEntry()->include().toString() << endl;
writeTypeCheckMacro(s_pts, innerClass->typeEntry());
writeTypeConverterDecl(convDecl, innerClass->typeEntry());
writeTypeConverterImpl(convImpl, innerClass->typeEntry());
@@ -358,31 +353,21 @@ void HeaderGenerator::finishGeneration()
s << endl;
}
- s << "// Class Includes" << endl;
- s << classIncludes << endl;
-
- if (!enumIncludes.isEmpty()) {
- s << "// Enum Includes" << endl;
- foreach (const QString& include, enumIncludes)
- s << "#include <" << include << ">" << endl;
- s << endl;
- }
+ s << "// Binded library includes" << endl;
+ foreach (const Include& include, includes)
+ s << include;
if (!primitiveTypes().isEmpty()) {
s << "// Conversion Includes - Primitive Types" << endl;
- foreach (const PrimitiveTypeEntry* ptype, primitiveTypes()) {
- if (ptype->include().isValid())
- s << ptype->include().toString() << endl;
- }
+ foreach (const PrimitiveTypeEntry* ptype, primitiveTypes())
+ s << ptype->include();
s << endl;
}
if (!containerTypes().isEmpty()) {
s << "// Conversion Includes - Container Types" << endl;
- foreach (const ContainerTypeEntry* ctype, containerTypes()) {
- if (ctype->include().isValid())
- s << ctype->include().toString() << endl;
- }
+ foreach (const ContainerTypeEntry* ctype, containerTypes())
+ s << ctype->include();
s << endl;
}
diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp
index 81a05762..33c5ad65 100644
--- a/shibokengenerator.cpp
+++ b/shibokengenerator.cpp
@@ -24,6 +24,7 @@
#include "shibokengenerator.h"
#include "overloaddata.h"
#include <reporthandler.h>
+#include <typedatabase.h>
#include <QtCore/QDir>
#include <QtCore/QDebug>