summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-11-23 15:36:38 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2010-11-23 15:40:37 -0200
commitfd81c050afca0ff3190e852062837be05017f00f (patch)
treeb63530b08f1bfbacf7c01d091cc5428c2b7885f8
parentcecb22759c6144c9e28921a18cb5255db9771e28 (diff)
downloadshiboken-fd81c050afca0ff3190e852062837be05017f00f.tar.gz
shiboken-fd81c050afca0ff3190e852062837be05017f00f.tar.xz
shiboken-fd81c050afca0ff3190e852062837be05017f00f.zip
Fix compilation without protect hack.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
-rw-r--r--generator/headergenerator.cpp27
-rw-r--r--generator/headergenerator.h1
2 files changed, 23 insertions, 5 deletions
diff --git a/generator/headergenerator.cpp b/generator/headergenerator.cpp
index 4775331c..3e242cc1 100644
--- a/generator/headergenerator.cpp
+++ b/generator/headergenerator.cpp
@@ -214,8 +214,8 @@ void HeaderGenerator::writeTypeConverterDecl(QTextStream& s, const TypeEntry* ty
}
bool isValueTypeWithImplConversions = type->isValue() && !implicitConvs.isEmpty();
bool hasCustomConversion = type->hasNativeConversionRule();
- QString typeT = "::" + type->qualifiedCppName() + (isAbstractOrObjectType ? "*" : "");
- QString typeName = "::" + type->qualifiedCppName();
+ QString typeT = type->qualifiedCppName() + (isAbstractOrObjectType ? "*" : "");
+ QString typeName = type->qualifiedCppName();
#ifdef AVOID_PROTECTED_HACK
const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(type);
@@ -224,6 +224,8 @@ void HeaderGenerator::writeTypeConverterDecl(QTextStream& s, const TypeEntry* ty
typeName = typeT;
}
#endif
+ typeT.prepend("::");
+ typeName.prepend("::");
s << "struct Converter< " << typeT << " >";
if (!hasCustomConversion) {
@@ -304,6 +306,8 @@ void HeaderGenerator::finishGeneration()
QTextStream typeFunctions(&sbkTypeFunctions);
QString converterImpl;
QTextStream convImpl(&converterImpl);
+ QString protectedEnumSurrogates;
+ QTextStream protEnumsSurrogates(&protectedEnumSurrogates);
Indentation indent(INDENT);
@@ -328,6 +332,7 @@ void HeaderGenerator::finishGeneration()
includes << cppEnum->typeEntry()->include();
writeTypeConverterDecl(convDecl, cppEnum->typeEntry());
convDecl << endl;
+ writeProtectedEnumSurrogate(protEnumsSurrogates, cppEnum);
writeSbkTypeFunction(typeFunctions, cppEnum);
}
@@ -349,6 +354,7 @@ void HeaderGenerator::finishGeneration()
if (flagsEntry)
writeTypeConverterDecl(convDecl, flagsEntry);
convDecl << endl;
+ writeProtectedEnumSurrogate(protEnumsSurrogates, cppEnum);
writeSbkTypeFunction(typeFunctions, cppEnum);
}
@@ -416,6 +422,11 @@ void HeaderGenerator::finishGeneration()
s << macros << endl;
+ if (!protectedEnumSurrogates.isEmpty()) {
+ s << "// Protected enum surrogates" << endl;
+ s << protectedEnumSurrogates << endl;
+ }
+
s << "namespace Shiboken" << endl << '{' << endl << endl;
s << "// PyType functions, to get the PyObjectType for a type T\n";
@@ -460,16 +471,22 @@ void HeaderGenerator::finishGeneration()
s << "#endif // " << includeShield << endl << endl;
}
+void HeaderGenerator::writeProtectedEnumSurrogate(QTextStream& s, const AbstractMetaEnum* cppEnum)
+{
+#ifdef AVOID_PROTECTED_HACK
+ if (cppEnum->isProtected())
+ s << "enum " << protectedEnumSurrogateName(cppEnum) << " {};" << endl;
+#endif
+}
+
void HeaderGenerator::writeSbkTypeFunction(QTextStream& s, const AbstractMetaEnum* cppEnum)
{
QString enumName = cppEnum->name();
if (cppEnum->enclosingClass())
enumName = cppEnum->enclosingClass()->qualifiedCppName() + "::" + enumName;
#ifdef AVOID_PROTECTED_HACK
- if (cppEnum->isProtected()) {
+ if (cppEnum->isProtected())
enumName = protectedEnumSurrogateName(cppEnum);
- s << "enum " << enumName << " {};" << endl;
- }
#endif
s << "template<> inline PyTypeObject* SbkType< ::" << enumName << " >() ";
diff --git a/generator/headergenerator.h b/generator/headergenerator.h
index 9802a104..96d63c64 100644
--- a/generator/headergenerator.h
+++ b/generator/headergenerator.h
@@ -51,6 +51,7 @@ private:
void writeTypeIndexDefineLine(QTextStream& s, const TypeEntry* typeEntry, int& idx);
void writeTypeIndexDefine(QTextStream& s, const AbstractMetaClass* metaClass, int& idx);
void writeTypeConverterImpl(QTextStream& s, const TypeEntry* type);
+ void writeProtectedEnumSurrogate(QTextStream& s, const AbstractMetaEnum* cppEnum);
};