diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-12-02 19:03:51 -0300 |
---|---|---|
committer | Marcelo Lira <marcelo.lira@openbossa.org> | 2009-12-02 19:34:27 -0300 |
commit | bfde7a8074a86f547402bcf6deae3e407a8db3bb (patch) | |
tree | 7ce5683dde027aaf0d60569b0cee8ab4d7b8ca27 /shibokengenerator.cpp | |
parent | 2dbe941b2b0e163e49cffe6626b1f47a06b8a7c8 (diff) |
Fixed argument conversion writer and type translator to handle references to object-types.
Diffstat (limited to 'shibokengenerator.cpp')
-rw-r--r-- | shibokengenerator.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/shibokengenerator.cpp b/shibokengenerator.cpp index 94f745380..9f850c702 100644 --- a/shibokengenerator.cpp +++ b/shibokengenerator.cpp @@ -163,14 +163,14 @@ QString ShibokenGenerator::translateTypeForWrapperMethod(const AbstractMetaType* const AbstractMetaClass* context) const { QString result; + const TypeEntry* tentry = cType->typeEntry(); - if (cType->isValue() || cType->isValuePointer() || cType->isObject() - || (cType->isReference() && !cType->isContainer())) { - result = cType->typeEntry()->qualifiedCppName(); - if (cType->isObject() || cType->isQObject() || cType->isValuePointer()) - result.append('*'); - else if (cType->isValue() && cType->isReference()) + if (tentry->isValue() || tentry->isObject() || (cType->isReference() && !cType->isContainer())) { + result = tentry->qualifiedCppName(); + if (cType->isReference()) result.append('&'); + else if (tentry->isObject() || cType->isValuePointer()) + result.append('*'); } else if (cType->isArray()) { result = translateTypeForWrapperMethod(cType->arrayElementType(), context) + "[]"; } else { @@ -293,18 +293,18 @@ void ShibokenGenerator::writeBaseConversion(QTextStream& s, const AbstractMetaTy typeName = translateTypeForWrapperMethod(type, context); } + const TypeEntry* tentry = type->typeEntry(); - // If the type is an Object (and a pointer) remove its constness - // (len("const ") == 6) since it is already inserted for everyone - // in the generated converter declaration. - if ((type->isQObject() || type->isObject()) && typeName.startsWith("const ")) - typeName.remove(0, 6); + // 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, 6); + typeName.remove(0, sizeof("const ") / sizeof(char) - 1); - if (typeName.endsWith("&") && !(type->isValue() && type->isReference())) + if (typeName.endsWith("&") && (tentry->isPrimitive() || tentry->isContainer())) typeName.chop(1); s << baseConversionString(typeName); @@ -319,11 +319,8 @@ void ShibokenGenerator::writeToPythonConversion(QTextStream& s, const AbstractMe writeBaseConversion(s, type, context); s << "toPython"; - if (!argumentName.isEmpty()) { - bool isReferenceToObjectType = type->isObject() && type->isReference(); - s << '(' << (isReferenceToObjectType ? "&(" : "") << argumentName; - s << (isReferenceToObjectType ? ")" : "") << ')'; - } + if (!argumentName.isEmpty()) + s << '(' << argumentName << ')'; } void ShibokenGenerator::writeToCppConversion(QTextStream& s, const AbstractMetaType* type, |