summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-02-04 19:08:43 -0300
committerRenato Araujo Oliveira Filho <renato.filho@openbossa.org>2011-02-07 17:14:37 -0300
commit61035b494dd0b5d13ea8cd7f4af7e62b36bb27b8 (patch)
treeac098c0ab5cd5b9e2d76f79bd3cf1413b60799f5
parent4b3a9db31192820e9d36cdd901be5c46dfa491e6 (diff)
downloadshiboken-61035b494dd0b5d13ea8cd7f4af7e62b36bb27b8.tar.gz
shiboken-61035b494dd0b5d13ea8cd7f4af7e62b36bb27b8.tar.xz
shiboken-61035b494dd0b5d13ea8cd7f4af7e62b36bb27b8.zip
Fixed signal initialization for types with namespace and types defined
by typedef. Fixes bug #657. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
-rw-r--r--generator/cppgenerator.cpp37
1 files changed, 28 insertions, 9 deletions
diff --git a/generator/cppgenerator.cpp b/generator/cppgenerator.cpp
index 853f2927..95143371 100644
--- a/generator/cppgenerator.cpp
+++ b/generator/cppgenerator.cpp
@@ -249,12 +249,12 @@ void CppGenerator::generateClass(QTextStream &s, const AbstractMetaClass *metaCl
s << "#include \"" << getModuleHeaderFileName() << '"' << endl << endl;
QString headerfile = fileNameForClass(metaClass);
- headerfile.replace("cpp", "h");
+ headerfile.replace(".cpp", ".h");
s << "#include \"" << headerfile << '"' << endl;
foreach (AbstractMetaClass* innerClass, metaClass->innerClasses()) {
if (shouldGenerate(innerClass)) {
QString headerfile = fileNameForClass(innerClass);
- headerfile.replace("cpp", "h");
+ headerfile.replace(".cpp", ".h");
s << "#include \"" << headerfile << '"' << endl;
}
}
@@ -3132,7 +3132,8 @@ void CppGenerator::writeSignalInitialization(QTextStream& s, const AbstractMetaC
AbstractMetaArgument *a = cppSignal->arguments().at(i);
AbstractMetaType* type = a->type();
- QString cppSignature = SBK_NORMALIZED_TYPE(qPrintable(type->cppSignature()));
+
+ QString cppSignature = SBK_NORMALIZED_TYPE(qPrintable(type->cppSignature()));
QString originalSignature = SBK_NORMALIZED_TYPE(qPrintable(type->originalTypeDescription()));
if (!a->defaultValueExpression().isEmpty()) {
@@ -3142,17 +3143,35 @@ void CppGenerator::writeSignalInitialization(QTextStream& s, const AbstractMetaC
signatures[cppSignal->name()].append(sig);
}
- if ((cppSignature != originalSignature) && !knowTypes.contains(originalSignature)) {
- knowTypes << originalSignature;
- s << INDENT << "Shiboken::TypeResolver::createValueTypeResolver<"
- << translateType(type, metaClass, ExcludeReference | ExcludeConst) << " >"
- << "(\"" << skipNamespace(originalSignature) << "\"); // " << type->cppSignature() << "\n";
+ QString replacedTypeName = cppSignal->typeReplaced(i+1);
+ QString signalTypeName;
+
+ if (replacedTypeName.isEmpty())
+ signalTypeName = skipNamespace(type->originalTypeDescription());
+ else
+ signalTypeName = replacedTypeName;
+
+ if ((!replacedTypeName.isEmpty() || //replace type on typessystem
+ (cppSignature != originalSignature)) && //used a typedef value
+ !knowTypes.contains(signalTypeName)) {
+
+ knowTypes << signalTypeName;
+ QString originalType = translateType(type, metaClass, ExcludeReference | ExcludeConst);
+ bool isObjectType = originalType.endsWith('*');
+ if (isObjectType)
+ originalType = originalType.remove(originalType.size()-1, 1);
+
+ s << INDENT << "Shiboken::TypeResolver::" << (isObjectType ? "createObjectTypeResolver<" : "createValueTypeResolver<")
+ << originalType << " >"
+ << "(\"" << skipNamespace(signalTypeName) << "\");" << endl;
}
- signature += SBK_NORMALIZED_TYPE(skipNamespace(type->originalTypeDescription()).toAscii());
+
+ signature += SBK_NORMALIZED_TYPE(signalTypeName.toAscii());
}
} else {
signature = "void";
}
+
signatures[cppSignal->name()].append(SBK_NORMALIZED_SIGNATURE(signature.toAscii()));
}
}