summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-06-20 15:20:44 -0300
committerRenato Filho <renato.filho@openbossa.org>2011-06-20 17:20:50 -0300
commit7f611d1c53511e730abca92f34376a7cca7789a7 (patch)
treedab5bd18b758dd46272f8ede48ba43ede8f37019
parentaa9e8ca7efc026238b0b7c75b166dc568b69bef4 (diff)
downloadpyside-7f611d1c53511e730abca92f34376a7cca7789a7.tar.gz
pyside-7f611d1c53511e730abca92f34376a7cca7789a7.tar.xz
pyside-7f611d1c53511e730abca92f34376a7cca7789a7.zip
Removed glue code for QObject.inherits function.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
-rw-r--r--PySide/QtCore/typesystem_core.xml19
-rw-r--r--libpyside/pyside.cpp12
-rw-r--r--libpyside/pyside.h8
3 files changed, 20 insertions, 19 deletions
diff --git a/PySide/QtCore/typesystem_core.xml b/PySide/QtCore/typesystem_core.xml
index 2b997b3..1185542 100644
--- a/PySide/QtCore/typesystem_core.xml
+++ b/PySide/QtCore/typesystem_core.xml
@@ -1390,25 +1390,6 @@
%PYARG_0 = %CONVERTTOPYTHON[bool](qobjectDisconnectCallback(%1, %2, %3));
</inject-code>
</add-function>
- <inject-code class="native" position="beginning">
- static bool
- qobjectInheritsInternal(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 qobjectInheritsInternal(base, class_name);
- }
- </inject-code>
- <modify-function signature="inherits(const char*) const">
- <inject-code class="target" position="beginning">
- bool retval = qobjectInheritsInternal(self->ob_type, %1) ? true : %CPPSELF.%FUNCTION_NAME(%1);
- %PYARG_0 = %CONVERTTOPYTHON[bool](retval);
- </inject-code>
- </modify-function>
<inject-code class="native" file="glue/qobject_findchild.cpp"/>
<add-function signature="findChild(PyTypeObject*, const QString&amp;)" return-type="PyObject*">
<inject-code class="target" position="beginning">
diff --git a/libpyside/pyside.cpp b/libpyside/pyside.cpp
index af763aa..950e2da 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 fae1b42..747b08d 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