aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2017-02-24 12:08:37 +0100
committerChristian Tismer <tismer@stackless.com>2017-02-24 12:08:46 +0000
commit2daee4615c01e6da9e0298df35999fe169323e74 (patch)
treeb03892c987b26893ac5467923835752fc18bccb4
parent01a312c455712f3fe3dcd65299fdd63bbce4ed2b (diff)
Add ‘getAllValidWrappers’ test function to shiboken
This function was developed in 2012 by John Ehresman. One of his bug reports uses this function. To be able to test the applicability of his issue PYSIDE-150, I thought it makes sense to add this function, again. Task-number: PYSIDE-150 Change-Id: Ie35b5a87ac9c0edfd303b1790eb8695a09b8d8e4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--shibokenmodule/typesystem_shiboken.xml20
-rw-r--r--tests/shibokenmodule/module_test.py6
2 files changed, 26 insertions, 0 deletions
diff --git a/shibokenmodule/typesystem_shiboken.xml b/shibokenmodule/typesystem_shiboken.xml
index 079ce35df..18ab52e80 100644
--- a/shibokenmodule/typesystem_shiboken.xml
+++ b/shibokenmodule/typesystem_shiboken.xml
@@ -83,6 +83,26 @@
</inject-code>
</add-function>
+ <add-function signature="getAllValidWrappers(void)" return-type="PyObject*">
+ <inject-code>
+ std::set&lt;PyObject*&gt; setAll = Shiboken::BindingManager::instance().getAllPyObjects();
+ PyObject* listAll = PyList_New(0);
+ if (listAll == NULL)
+ return NULL;
+
+ const std::set&lt;PyObject*&gt;::iterator end = setAll.end();
+ for (std::set&lt;PyObject*&gt;::iterator iter = setAll.begin(); iter != end; ++iter) {
+ if (*iter != NULL) {
+ if (PyList_Append(listAll, *iter) != 0) {
+ Py_DECREF(listAll);
+ return NULL;
+ }
+ }
+ }
+ return listAll;
+ </inject-code>
+ </add-function>
+
<extra-includes>
<include file-name="sbkversion.h" location="local"/>
</extra-includes>
diff --git a/tests/shibokenmodule/module_test.py b/tests/shibokenmodule/module_test.py
index a14052918..bc2931251 100644
--- a/tests/shibokenmodule/module_test.py
+++ b/tests/shibokenmodule/module_test.py
@@ -106,5 +106,11 @@ class TestShiboken(unittest.TestCase):
self.assertEqual(type(shiboken.__version_info__), tuple)
self.assertEqual(len(shiboken.__version_info__), 5)
+ def testAllWrappers(self):
+ obj = ObjectType()
+ self.assertTrue(obj in shiboken.getAllValidWrappers())
+ shiboken.delete(obj)
+ self.assertFalse(obj in shiboken.getAllValidWrappers())
+
if __name__ == '__main__':
unittest.main()