From 47d4a1f545eb7f348e46d39230a73a1b465e57a4 Mon Sep 17 00:00:00 2001 From: Marcelo Lira Date: Mon, 31 May 2010 15:25:12 -0300 Subject: Generator improved to handle protected enums without the protected hack. --- shibokengenerator.cpp | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) (limited to 'shibokengenerator.cpp') diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index 64976d3dd..5b85ef43a 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -157,10 +157,19 @@ QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType* { QString result; - if (cType->isArray()) + if (cType->isArray()) { result = translateTypeForWrapperMethod(cType->arrayElementType(), context) + "[]"; - else - result = translateType(cType, context); + } else { +#ifdef AVOID_PROTECTED_HACK + if (cType->isEnum()) { + const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(cType); + if (metaEnum && metaEnum->isProtected()) + result = protectedEnumSurrogateName(metaEnum); + } + if (result.isEmpty()) +#endif + result = translateType(cType, context); + } return result; } @@ -188,6 +197,11 @@ QString ShibokenGenerator::wrapperName(const AbstractMetaClass* metaClass) } } +QString ShibokenGenerator::protectedEnumSurrogateName(const AbstractMetaEnum* metaEnum) +{ + return metaEnum->fullName().replace(".", "_") + "_Surrogate"; +} + QString ShibokenGenerator::cpythonFunctionName(const AbstractMetaFunction* func) { QString result; @@ -299,6 +313,13 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const TypeEntry* typ QString typeName = type->name(); if (type->isObject()) typeName.append('*'); +#ifdef AVOID_PROTECTED_HACK + if (type->isEnum()) { + const AbstractMetaEnum* metaEnum = findAbstractMetaEnum(type); + if (metaEnum && metaEnum->isProtected()) + typeName = protectedEnumSurrogateName(metaEnum); + } +#endif s << baseConversionString(typeName); } -- cgit v1.2.3