diff options
author | Christian Tismer <tismer@stackless.com> | 2017-05-23 17:10:26 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2017-09-20 21:52:50 +0000 |
commit | 30a1c9c41e5e6d4166f171b9477c6f46cafa782f (patch) | |
tree | 7aaa7b100d3fcc0cb8ad2f583928148b6abfbee5 /sources/shiboken2/libshiboken/basewrapper.cpp | |
parent | 6678fc1a6353e596965f0daff74afec9d1605c57 (diff) |
Implement introspection with __signature__ package
The signature module was turned into a package under
'PySide2/support/signature'. The package is completely isolated
so that nothing is leaking into the normal import machinery.
The package is also not initialized unless a __signature__ attribute
is accessed. The only change to Python during a PySide run is
the existence of the __signature__ attribute.
As a side effect, all tests run at the same speed as before
this extension.
The module does not actively import PySide modules. Instead,
it inspects sys.modules and reloads its mapping.py if needed.
Example usage:
>>> PySide2.QtWidgets.QGraphicsAnchorLayout.addAnchors.__signature__
>>> PySide2.QtWidgets.QGraphicsAnchorLayout.__signature__
The module has been thoroughly tested on macOS.
I consider this ready.
Task-number: PYSIDE-510
Change-Id: Ibb231a7fbb4ccc1a7249df55e3881a4e21a19c0d
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/shiboken2/libshiboken/basewrapper.cpp')
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.cpp | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index b319fea7e..3f3bcc7f5 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -51,6 +51,7 @@ #include <sstream> #include <algorithm> #include "threadstatesaver.h" +#include "signature.h" namespace { void _destroyParentInfo(SbkObject* obj, bool keepReference); @@ -723,10 +724,12 @@ void initPrivateData(SbkObjectType* self) memset(self->d, 0, sizeof(SbkObjectTypePrivate)); } -bool introduceWrapperType(PyObject* enclosingObject, - const char* typeName, const char* originalName, - SbkObjectType* type, ObjectDestructor cppObjDtor, - SbkObjectType* baseType, PyObject* baseTypes, +bool introduceWrapperType(PyObject *enclosingObject, + const char *typeName, const char *originalName, + SbkObjectType *type, + const char *signaturesString, + ObjectDestructor cppObjDtor, + SbkObjectType *baseType, PyObject *baseTypes, bool isInnerClass) { initPrivateData(type); @@ -744,7 +747,9 @@ bool introduceWrapperType(PyObject* enclosingObject, } } - if (PyType_Ready(reinterpret_cast<PyTypeObject *>(type)) < 0) + // PySide-510 + // here is the single change to support signatures. + if (SbkSpecial_Type_Ready(enclosingObject, reinterpret_cast<PyTypeObject *>(type), signaturesString) < 0) return false; if (isInnerClass) |