summaryrefslogtreecommitdiffstats
path: root/libpyside/qsignal.cpp
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-08-26 12:02:59 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-08-26 16:21:41 -0300
commit268bf7735b787d2310e18b3aed262bd27b9d24c6 (patch)
tree401a08d3dd8b4d7debb7c19a94d104e720a42604 /libpyside/qsignal.cpp
parent6914f21603fa32727af0d419b6f438e88413ed7f (diff)
downloadshiboken-268bf7735b787d2310e18b3aed262bd27b9d24c6.tar.gz
shiboken-268bf7735b787d2310e18b3aed262bd27b9d24c6.tar.xz
shiboken-268bf7735b787d2310e18b3aed262bd27b9d24c6.zip
Fixed signal signature parser.
Fixes bug #311. Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'libpyside/qsignal.cpp')
-rw-r--r--libpyside/qsignal.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/libpyside/qsignal.cpp b/libpyside/qsignal.cpp
index f465a7b9..6c542034 100644
--- a/libpyside/qsignal.cpp
+++ b/libpyside/qsignal.cpp
@@ -250,15 +250,21 @@ char* signal_get_type_name(PyObject* type)
char *typeName = NULL;
if (type->ob_type == &Shiboken::SbkBaseWrapperType_Type) {
Shiboken::SbkBaseWrapperType *objType = reinterpret_cast<Shiboken::SbkBaseWrapperType*>(type);
+ Q_ASSERT(objType->original_name);
typeName = strdup(objType->original_name);
} else {
- //tp_name return the full name
- Shiboken::AutoDecRef otypeName(PyObject_GetAttrString(type, "__name__"));
- typeName = strdup(PyString_AS_STRING(otypeName.object()));
- }
- if (Shiboken::TypeResolver::getType(typeName) == Shiboken::TypeResolver::ObjectType) {
- typeName = reinterpret_cast<char*>(realloc(typeName, strlen(typeName) + 1));
- typeName = strcat(typeName, "*");
+ // Translate python types to Qt names
+ PyTypeObject *objType = reinterpret_cast<PyTypeObject*>(type);
+ if (objType == &PyString_Type)
+ typeName = strdup("QString");
+ else if (objType == &PyInt_Type)
+ typeName = strdup("int");
+ else if (objType == &PyLong_Type)
+ typeName = strdup("long");
+ else if (objType == &PyFloat_Type)
+ typeName = strdup("qreal");
+ else
+ typeName = strdup("object");
}
return typeName;
} else if (PyString_Check(type)) {
@@ -277,7 +283,6 @@ char* signal_build_signature(const char *name, const char *signature)
char* signal_parse_signature(PyObject *args)
{
char *signature = 0;
-
if (args && (PyString_Check(args) || (!PySequence_Check(args) && (args != Py_None))))
return signal_get_type_name(args);