aboutsummaryrefslogtreecommitdiffstats
path: root/generator
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>2012-03-08 16:12:06 -0300
commit332dff4ad6a2942ad4415355a6b5f80015e5b9b7 (patch)
treee073b021e76e7835555edd18b381e925ce57caf1 /generator
parent152653a520eeaf534a0488810a165f0a7df4d434 (diff)
Fix compilation without protect hack.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'generator')
-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 4775331c2..3e242cc14 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 9802a104f..96d63c640 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);
};