summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2022-01-21 13:08:25 +0100
committerChristoph Reiter <reiter.christoph@gmail.com>2022-03-27 12:43:25 +0000
commit22c7b28d4395dbf7da9b9ff9a1ef6725c4d52399 (patch)
treef978135deea416ed97b191a8e444bb9dbcbf290d
parentfaa5c29f135ca8b70696b0a225542e0e7bd94416 (diff)
downloadpygobject-22c7b28d4395dbf7da9b9ff9a1ef6725c4d52399.tar.gz
info: Show which type/object callables are bound tobenzea/vfunc-bound-descr
-rw-r--r--gi/pygi-info.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/gi/pygi-info.c b/gi/pygi-info.c
index aee5d4db..08c76db5 100644
--- a/gi/pygi-info.c
+++ b/gi/pygi-info.c
@@ -560,6 +560,33 @@ _callable_info_call (PyGICallableInfo *self, PyObject *args, PyObject *kwargs)
}
}
+static PyObject *
+_callable_info_repr (PyGICallableInfo *self)
+{
+ PyObject *bound_repr_o = NULL;
+ const char *bound_repr = "None";
+ PyObject *res = NULL;
+
+ if (self->py_bound_arg) {
+ bound_repr_o = PyObject_Repr(self->py_bound_arg);
+ if (bound_repr_o == NULL)
+ goto out;
+
+ bound_repr = PyUnicode_AsUTF8(bound_repr_o);
+ if (bound_repr == NULL)
+ goto out;
+ }
+
+ res = PyUnicode_FromFormat ("%s(%s, bound=%s)",
+ Py_TYPE( (PyObject *) self)->tp_name,
+ _safe_base_info_get_name (self->base.info),
+ bound_repr);
+
+out:
+ Py_XDECREF(bound_repr_o);
+
+ return res;
+}
/* _function_info_call:
*
@@ -2303,6 +2330,7 @@ pygi_info_register_types (PyObject *m)
}
PyGICallableInfo_Type.tp_call = (ternaryfunc) _callable_info_call;
+ PyGICallableInfo_Type.tp_repr = (reprfunc) _callable_info_repr;
PyGICallableInfo_Type.tp_dealloc = (destructor) _callable_info_dealloc;
_PyGI_REGISTER_TYPE (m, PyGICallableInfo_Type, CallableInfo,
PyGIBaseInfo_Type);