aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/pysideproperty.cpp
diff options
context:
space:
mode:
authorCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2020-03-30 10:07:56 +0200
committerCristian Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2020-03-30 10:07:56 +0200
commitd2be09eef06241cd4c9eb7a0ca1a993dc2355f02 (patch)
tree4cd15a74c0629e76a41b30d2e02d22e998fb509d /sources/pyside2/libpyside/pysideproperty.cpp
parentad73193e99fef8f5d1bcf095075596dca88949c1 (diff)
parentd47fb98e443e3ac5cb18850b2551143c713917f0 (diff)
Merge branch '5.14' into 5.14.2v5.14.2
Diffstat (limited to 'sources/pyside2/libpyside/pysideproperty.cpp')
-rw-r--r--sources/pyside2/libpyside/pysideproperty.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/sources/pyside2/libpyside/pysideproperty.cpp b/sources/pyside2/libpyside/pysideproperty.cpp
index 74a77e6c3..bdabf1202 100644
--- a/sources/pyside2/libpyside/pysideproperty.cpp
+++ b/sources/pyside2/libpyside/pysideproperty.cpp
@@ -61,6 +61,9 @@ static PyObject *qPropertyGetter(PyObject *, PyObject *);
static int qpropertyTraverse(PyObject *self, visitproc visit, void *arg);
static int qpropertyClear(PyObject *self);
+// Attributes
+static PyObject *qPropertyDocGet(PyObject *, void *);
+
static PyMethodDef PySidePropertyMethods[] = {
{"setter", (PyCFunction)qPropertySetter, METH_O, 0},
{"write", (PyCFunction)qPropertySetter, METH_O, 0},
@@ -69,6 +72,11 @@ static PyMethodDef PySidePropertyMethods[] = {
{0, 0, 0, 0}
};
+static PyGetSetDef PySidePropertyType_getset[] = {
+ {"__doc__", qPropertyDocGet, nullptr, nullptr, nullptr},
+ {nullptr, nullptr, nullptr, nullptr, nullptr}
+};
+
static PyType_Slot PySidePropertyType_slots[] = {
{Py_tp_dealloc, (void *)qpropertyDeAlloc},
{Py_tp_call, (void *)qPropertyCall},
@@ -77,6 +85,7 @@ static PyType_Slot PySidePropertyType_slots[] = {
{Py_tp_methods, (void *)PySidePropertyMethods},
{Py_tp_init, (void *)qpropertyTpInit},
{Py_tp_new, (void *)qpropertyTpNew},
+ {Py_tp_getset, PySidePropertyType_getset},
{0, 0}
};
// Dotted modulename is crucial for PyType_FromSpec to work. Is this name right?
@@ -265,6 +274,24 @@ PyObject *qPropertyGetter(PyObject *self, PyObject *callback)
return nullptr;
}
+static PyObject *qPropertyDocGet(PyObject *self, void *)
+{
+ auto data = reinterpret_cast<PySideProperty *>(self);
+ PySidePropertyPrivate *pData = data->d;
+
+ QByteArray doc(pData->doc);
+ if (!doc.isEmpty()) {
+#if PY_MAJOR_VERSION >= 3
+ return PyUnicode_FromString(doc);
+#else
+ return PyString_FromString(doc);
+#endif
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
static int qpropertyTraverse(PyObject *self, visitproc visit, void *arg)
{
PySidePropertyPrivate *data = reinterpret_cast<PySideProperty *>(self)->d;