diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-11-23 15:36:38 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-11-23 15:40:37 -0200 |
commit | fd81c050afca0ff3190e852062837be05017f00f (patch) | |
tree | b63530b08f1bfbacf7c01d091cc5428c2b7885f8 /generator/headergenerator.cpp | |
parent | cecb22759c6144c9e28921a18cb5255db9771e28 (diff) | |
download | shiboken-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>
Diffstat (limited to 'generator/headergenerator.cpp')
-rw-r--r-- | generator/headergenerator.cpp | 27 |
1 files changed, 22 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 << " >() "; |