aboutsummaryrefslogtreecommitdiffstats
path: root/shibokengenerator.cpp
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-07-27 15:58:38 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-07-27 17:42:39 -0300
commit419499bbaf4c6e4f55a0083d8ec65749440a38de (patch)
tree60493de8574fabe61f96b890f0495e9ca2522f84 /shibokengenerator.cpp
parent21460348ae4a73877ecbcc610d5ccd66a390d0c1 (diff)
Create a new copy from object when convert from PyObject to const ref.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'shibokengenerator.cpp')
-rw-r--r--shibokengenerator.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp
index f5349d299..3efd59f0e 100644
--- a/shibokengenerator.cpp
+++ b/shibokengenerator.cpp
@@ -170,12 +170,13 @@ void ShibokenGenerator::initPrimitiveTypesCorrespondences()
}
QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType* cType,
- const AbstractMetaClass* context) const
+ const AbstractMetaClass* context,
+ Options options) const
{
QString result;
if (cType->isArray()) {
- result = translateTypeForWrapperMethod(cType->arrayElementType(), context) + "[]";
+ result = translateTypeForWrapperMethod(cType->arrayElementType(), context, options) + "[]";
} else {
#ifdef AVOID_PROTECTED_HACK
if (cType->isEnum()) {
@@ -185,7 +186,7 @@ QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType*
}
if (result.isEmpty())
#endif
- result = translateType(cType, context);
+ result = translateType(cType, context, options);
}
return result;
@@ -497,24 +498,14 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const AbstractMetaTy
if (ptype->basicAliasedTypeEntry())
ptype = ptype->basicAliasedTypeEntry();
typeName = ptype->name();
- } else {
- typeName = translateTypeForWrapperMethod(type, context);
+ } else {
+ if (type->isObject() || (type->isValue() && !type->isReference()))
+ options |= Generator::ExcludeConst;
+ if (type->isContainer() )
+ options |= Generator::ExcludeReference | Generator::ExcludeConst;
+ typeName = translateTypeForWrapperMethod(type, context, options);
}
- const TypeEntry* tentry = type->typeEntry();
-
- // If the type is an Object (and a pointer) remove its constness since it
- // is already declared as const in the signature of the generated converter.
- if (tentry->isObject() && typeName.startsWith("const "))
- typeName.remove(0, sizeof("const ") / sizeof(char) - 1);
-
- // Remove the constness, if any
- if (typeName.startsWith("const ") && type->name() != "char")
- typeName.remove(0, sizeof("const ") / sizeof(char) - 1);
-
- if ((options & ExcludeReference || tentry->isPrimitive() || tentry->isContainer()) && typeName.endsWith('&'))
- typeName.chop(1);
-
s << baseConversionString(typeName);
}