summaryrefslogtreecommitdiffstats
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>2010-10-29 17:25:18 -0200
commit6f6eabfc91d0b034be1b411c451dd1562519252d (patch)
tree8f96aebe2082557d2042e14a5b1de930e0060b33
parenta53c92a42b29e0c49d28e0cf53f33b9515d78622 (diff)
downloadshiboken-6f6eabfc91d0b034be1b411c451dd1562519252d.tar.gz
shiboken-6f6eabfc91d0b034be1b411c451dd1562519252d.tar.xz
shiboken-6f6eabfc91d0b034be1b411c451dd1562519252d.zip
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>
-rw-r--r--generator/cppgenerator.cpp10
-rw-r--r--generator/shibokengenerator.cpp25
-rw-r--r--generator/shibokengenerator.h5
3 files changed, 29 insertions, 11 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index d01beca9..1ea5b15d 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -1477,15 +1477,7 @@ void CppGenerator::writeArgumentConversion(QTextStream& s,
bool isWrappedCppClass = type->isValue() || type->isObject();
// exclude const on Objects
- Options flags;
- bool isCStr = isCString(argType);
- if (argType->indirections() && !isCStr)
- flags = ExcludeConst;
- else if (type->isPrimitive() && !isCStr)
- flags = ExcludeConst | ExcludeReference;
- else if (type->isValue() && argType->isConstant() && argType->isReference())
- flags = ExcludeConst | ExcludeReference; // const refs become just the value, but pure refs must remain pure.
-
+ Options flags = getConverterOptions(argType);
typeName = translateTypeForWrapperMethod(argType, context, flags).trimmed();
if (isWrappedCppClass)
diff --git a/generator/shibokengenerator.cpp b/generator/shibokengenerator.cpp
index b93009e5..ee4ccd33 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;
+}
+
diff --git a/generator/shibokengenerator.h b/generator/shibokengenerator.h
index 7695d112..74396eb0 100644
--- a/generator/shibokengenerator.h
+++ b/generator/shibokengenerator.h
@@ -318,6 +318,11 @@ public:
*/
AbstractMetaType* buildAbstractMetaTypeFromString(QString typeString);
+ /**
+ * Helper function to return the flags to be used by a meta type when
+ * it needs to write some converter code.
+ */
+ static Options getConverterOptions(const AbstractMetaType* metaType);
protected:
bool doSetup(const QMap<QString, QString>& args);
// verify whether the class is copyable