aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken/pep384impl.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-01-13 17:56:00 +0100
committerChristian Tismer <tismer@stackless.com>2019-01-15 13:33:08 +0000
commitb7707a51337cd7982d298041fa3db2ed225bfc54 (patch)
treed264067b87e9a466d275e73843921ef8f966045a /sources/shiboken2/libshiboken/pep384impl.cpp
parentaef6a443a241756e9dfaff192b69d51eaa235ef6 (diff)
Support help() using the Signature Module
The signature module will be used to generate automated documentation by using the function signatures as docstrings. This functionality should be low-hanging fruit. Actually, it was a bit tricky to get this working. The crucial point was to use PyType_Modified(). The function works fine on methods. Supporting types needs some more effort. It is not clear why the __signature__ attribute can be added, but the change to __doc__ is not recognized. May be related to the absence of Py_TPFLAGS_HAVE_VERSION_TAG ? This will be addressed another time. Task-number: PYSIDE-908 Change-Id: If8faa87927899f4c072d42b91eafd8f7658c6abc Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/pep384impl.cpp')
-rw-r--r--sources/shiboken2/libshiboken/pep384impl.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp
index 7cca03c84..7b333f4ff 100644
--- a/sources/shiboken2/libshiboken/pep384impl.cpp
+++ b/sources/shiboken2/libshiboken/pep384impl.cpp
@@ -77,17 +77,22 @@ static struct PyMethodDef probe_methoddef[] = {
{0}
};
+static PyGetSetDef probe_getseters[] = {
+ {0} /* Sentinel */
+};
+
#define probe_tp_call make_dummy(1)
#define probe_tp_str make_dummy(2)
#define probe_tp_traverse make_dummy(3)
#define probe_tp_clear make_dummy(4)
#define probe_tp_methods probe_methoddef
-#define probe_tp_descr_get make_dummy(6)
-#define probe_tp_init make_dummy(7)
-#define probe_tp_alloc make_dummy(8)
-#define probe_tp_new make_dummy(9)
-#define probe_tp_free make_dummy(10)
-#define probe_tp_is_gc make_dummy(11)
+#define probe_tp_getset probe_getseters
+#define probe_tp_descr_get make_dummy(7)
+#define probe_tp_init make_dummy(8)
+#define probe_tp_alloc make_dummy(9)
+#define probe_tp_new make_dummy(10)
+#define probe_tp_free make_dummy(11)
+#define probe_tp_is_gc make_dummy(12)
#define probe_tp_name "type.probe"
#define probe_tp_basicsize make_dummy_int(42)
@@ -98,6 +103,7 @@ static PyType_Slot typeprobe_slots[] = {
{Py_tp_traverse, probe_tp_traverse},
{Py_tp_clear, probe_tp_clear},
{Py_tp_methods, probe_tp_methods},
+ {Py_tp_getset, probe_tp_getset},
{Py_tp_descr_get, probe_tp_descr_get},
{Py_tp_init, probe_tp_init},
{Py_tp_alloc, probe_tp_alloc},
@@ -138,6 +144,7 @@ check_PyTypeObject_valid(void)
|| probe_tp_clear != check->tp_clear
|| probe_tp_weakrefoffset != typetype->tp_weaklistoffset
|| probe_tp_methods != check->tp_methods
+ || probe_tp_getset != check->tp_getset
|| probe_tp_base != typetype->tp_base
|| !PyDict_Check(check->tp_dict)
|| !PyDict_GetItemString(check->tp_dict, "dummy")