aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/libpyside/pysideproperty.cpp
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2019-08-13 11:15:52 +0200
committerChristian Tismer <tismer@stackless.com>2019-08-21 03:30:23 +0200
commit01b43dc3d93e632c3c42fb8e1105f200b9cee2ae (patch)
treef4431f927b267835f940a761ee1bcfb76ac4a580 /sources/pyside2/libpyside/pysideproperty.cpp
parent86f56c1ea0846540b082c67d0dc3e942fd311208 (diff)
Add QtCore.Slot.__signature__ and much more manually
The signature of QtCore.Slot and other classes could not automatically be generated because the function is not generated by cppgenerator.cpp . We add it manually in the C++ code into the generation process. The case of QtCore.Slot had diverse follow-up issues to be solved: - Classes which did not inherit from Shiboken were not generated. This is a long-standing omission and creates very many new simple types. - The arity of Slot has default arguments after the varargs parameter "*types". This needed an extended Python parser analysis that fixes the arguments given to the inspect module, accordingly. - The signature generation was completely new implemented and relies no longer on the restricted syntax of a Python (2) function but generates signatures directly as Parameter instances. Implemented classes with hand-made signatures: QtCore.ClassInfo QtCore.MetaFunction, QtCore.MetaSignal QtCore.Property QtCore.Signal QtCore.SignalInstance QtCore.Slot QtQml.ListProperty QtQml.VolatileBool As a side effect, many more subtypes were published. Enums are done, which concludes this work. Fixes: PYSIDE-945 Fixes: PYSIDE-1052 Change-Id: Ic09f02ece3a90325519e42e4e39719beb0c27ae9 Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside2/libpyside/pysideproperty.cpp')
-rw-r--r--sources/pyside2/libpyside/pysideproperty.cpp20
1 files changed, 15 insertions, 5 deletions
diff --git a/sources/pyside2/libpyside/pysideproperty.cpp b/sources/pyside2/libpyside/pysideproperty.cpp
index a9cacf869..d9d15eb3b 100644
--- a/sources/pyside2/libpyside/pysideproperty.cpp
+++ b/sources/pyside2/libpyside/pysideproperty.cpp
@@ -45,8 +45,7 @@
#include "pysidesignal_p.h"
#include <shiboken.h>
-
-#define QPROPERTY_CLASS_NAME "Property"
+#include <signature.h>
extern "C"
{
@@ -82,7 +81,7 @@ static PyType_Slot PySidePropertyType_slots[] = {
};
// Dotted modulename is crucial for PyType_FromSpec to work. Is this name right?
static PyType_Spec PySidePropertyType_spec = {
- "PySide2.QtCore." QPROPERTY_CLASS_NAME,
+ "PySide2.QtCore.Property",
sizeof(PySideProperty),
0,
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_GC|Py_TPFLAGS_BASETYPE,
@@ -321,13 +320,24 @@ static PyObject *getFromType(PyTypeObject *type, PyObject *name)
namespace PySide { namespace Property {
+static const char *Property_SignatureStrings[] = {
+ "PySide2.QtCore.Property(type:type,fget:typing.Callable=None,fset:typing.Callable=None,"
+ "freset:typing.Callable=None,fdel:typing.Callable=None,doc:str=None,"
+ "notify:typing.Callable=None,designable:bool=True,scriptable:bool=True,"
+ "stored:bool=True,user:bool=False,constant:bool=False,final:bool=False)",
+ "PySide2.QtCore.Property.getter(func:typing.Callable)",
+ "PySide2.QtCore.Property.read(func:typing.Callable)",
+ "PySide2.QtCore.Property.setter(func:typing.Callable)",
+ "PySide2.QtCore.Property.write(func:typing.Callable)",
+ nullptr}; // Sentinel
+
void init(PyObject *module)
{
- if (PyType_Ready(PySidePropertyTypeF()) < 0)
+ if (SbkSpecial_Type_Ready(module, PySidePropertyTypeF(), Property_SignatureStrings) < 0)
return;
Py_INCREF(PySidePropertyTypeF());
- PyModule_AddObject(module, QPROPERTY_CLASS_NAME, reinterpret_cast<PyObject *>(PySidePropertyTypeF()));
+ PyModule_AddObject(module, "Property", reinterpret_cast<PyObject *>(PySidePropertyTypeF()));
}
bool checkType(PyObject *pyObj)