aboutsummaryrefslogtreecommitdiffstats
path: root/libpyside
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-06-20 15:20:44 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:29 -0300
commitebaf95ca1aba9febe62cb98cd40fc9e710c45b12 (patch)
treefb31636e9a7701da2886f422625c513689bd7589 /libpyside
parentf549793a5ca68bc6cc213506df0b2ac3fc541413 (diff)
Removed glue code for QObject.inherits function.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'libpyside')
-rw-r--r--libpyside/pyside.cpp12
-rw-r--r--libpyside/pyside.h8
2 files changed, 20 insertions, 0 deletions
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp
index af763aa44..950e2da5f 100644
--- a/libpyside/pyside.cpp
+++ b/libpyside/pyside.cpp
@@ -284,5 +284,17 @@ PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* nam
return attr;
}
+bool inherits(PyTypeObject* objType, const char* class_name)
+{
+ if (strcmp(objType->tp_name, class_name) == 0)
+ return true;
+
+ PyTypeObject* base = (objType)->tp_base;
+ if (base == 0)
+ return false;
+
+ return inherits(base, class_name);
+}
+
} //namespace PySide
diff --git a/libpyside/pyside.h b/libpyside/pyside.h
index fae1b420f..747b08da8 100644
--- a/libpyside/pyside.h
+++ b/libpyside/pyside.h
@@ -102,6 +102,14 @@ PYSIDE_API void destroyQCoreApplication();
*/
PYSIDE_API PyObject* getMetaDataFromQObject(QObject* cppSelf, PyObject* self, PyObject* name);
+/**
+ * Check if self inherits from class_name
+ * \param self Python object
+ * \param class_name strict with the class name
+ * \return Returns true if self object inherits from class_name, otherwise returns false
+ */
+PYSIDE_API bool inherits(PyTypeObject* self, const char* class_name);
+
} //namespace PySide