aboutsummaryrefslogtreecommitdiffstats
path: root/generator/shibokengenerator.cpp
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2010-10-29 17:05:46 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:08:55 -0300
commit7e51b29827d887e8156e0cd48d864ffe356412cc (patch)
treecc5485d985622eff3377bfa8221b57789f3798aa /generator/shibokengenerator.cpp
parent78d5b68b37b206c81932f188e106b7f239b25cab (diff)
Don't use ref. on primitive types when using Converter<T>::toPython.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'generator/shibokengenerator.cpp')
-rw-r--r--generator/shibokengenerator.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp
index b93009e5e..ee4ccd338 100644
--- a/generator/shibokengenerator.cpp
+++ b/generator/shibokengenerator.cpp
@@ -515,7 +515,10 @@ void ShibokenGenerator::writeToPythonConversion(QTextStream& s, const AbstractMe
if (!type)
return;
- writeBaseConversion(s, type, context);
+ // exclude const on Objects
+ const TypeEntry* typeEntry = type->typeEntry();
+ Options flags = getConverterOptions(type);
+ writeBaseConversion(s, type, context, flags);
s << "toPython";
if (!argumentName.isEmpty())
@@ -789,7 +792,10 @@ QString ShibokenGenerator::cpythonCheckFunction(const AbstractMetaType* metaType
} else {
QString str;
QTextStream s(&str);
- writeBaseConversion(s, metaType, 0);
+ // exclude const on Objects
+ const TypeEntry* typeEntry = metaType->typeEntry();
+ Options flags = getConverterOptions(metaType);
+ writeBaseConversion(s, metaType, 0, flags);
s.flush();
return str + "checkType";
}
@@ -1645,3 +1651,18 @@ bool ShibokenGenerator::pythonFunctionWrapperUsesListOfArguments(const OverloadD
return usePyArgs;
}
+Generator::Options ShibokenGenerator::getConverterOptions(const AbstractMetaType* metaType)
+{
+ // exclude const on Objects
+ Options flags;
+ const TypeEntry* type = metaType->typeEntry();
+ bool isCStr = isCString(metaType);
+ if (metaType->indirections() && !isCStr)
+ flags = ExcludeConst;
+ else if (type->isPrimitive() && !isCStr)
+ flags = ExcludeConst | ExcludeReference;
+ else if (type->isValue() && metaType->isConstant() && metaType->isReference())
+ flags = ExcludeConst | ExcludeReference; // const refs become just the value, but pure refs must remain pure.
+ return flags;
+}
+