diff options
author | Christian Tismer <tismer@stackless.com> | 2018-07-14 15:10:56 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2018-10-11 09:47:47 +0000 |
commit | 66615a89ef66c39d62a502df3eb1ff629aa39154 (patch) | |
tree | a944523097505fb80b6c41ac8518e3fd02a3ca74 /sources/shiboken2/libshiboken/pep384impl.cpp | |
parent | c6395441a1df9b1cc59716b9dad18973bcb72c69 (diff) |
Prepare the Signature Module For More Applications
This is the preparation for a number of planned applications
and extensions using the signature module.
This general overhaul contains:
- Extraction of signature enumerations into enum_sigs.py,
- a list of current keyword errors in arguments which are unsolved
in shiboken, but temporarily fixed in parser.py (too many for XML),
- fix spurious duplications in multiple signatures
- corrections for keyword errors in function names which cannot be
fixed by Python (quite few),
- fixing "..." arguments into "*args",
- supporting the "slot wrapper" type. This is necessary for
methods like "__add__", "__mul__" etc.
- Create an extra function "get_signature" that has a parameter to
modify the appearance, i.e. without self, without returntype, etc.
Task-number: PYSIDE-510
Change-Id: If16f7bf02c6e7cbbdc970058bb630ea4db2b854a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/pep384impl.cpp')
-rw-r--r-- | sources/shiboken2/libshiboken/pep384impl.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sources/shiboken2/libshiboken/pep384impl.cpp b/sources/shiboken2/libshiboken/pep384impl.cpp index 4481f1cdd..18094c5c0 100644 --- a/sources/shiboken2/libshiboken/pep384impl.cpp +++ b/sources/shiboken2/libshiboken/pep384impl.cpp @@ -398,7 +398,10 @@ PyRun_String(const char *str, int start, PyObject *globals, PyObject *locals) return ret; } +#endif // Py_LIMITED_API + // This is only a simple local helper that returns a computed variable. +// Used also in Python 2. static PyObject * PepRun_GetResult(const char *command, const char *resvar) { @@ -415,6 +418,8 @@ PepRun_GetResult(const char *command, const char *resvar) return res; } +#ifdef Py_LIMITED_API + /***************************************************************************** * * Support for classobject.h @@ -499,13 +504,26 @@ PyTypeObject *PepStaticMethod_TypePtr = NULL; static PyTypeObject *getStaticMethodType(void) { + // this works for Python 3, only + // "StaticMethodType = type(str.__dict__['maketrans'])\n"; static const char prog[] = - "StaticMethodType = type(str.__dict__['maketrans'])\n"; - return (PyTypeObject *) PepRun_GetResult(prog, "StaticMethodType"); + "from xxsubtype import spamlist\n" + "StaticMethod_Type = type(spamlist.__dict__['staticmeth'])\n"; + return (PyTypeObject *) PepRun_GetResult(prog, "StaticMethod_Type"); } - #endif // Py_LIMITED_API +#if PY_VERSION_HEX < 0x03000000 +PyTypeObject *PepMethodDescr_TypePtr = NULL; + +static PyTypeObject *getMethodDescrType(void) +{ + static const char prog[] = + "MethodDescr_Type = type(str.split)\n"; + return (PyTypeObject *) PepRun_GetResult(prog, "MethodDescr_Type"); +} +#endif + /***************************************************************************** * * Common newly needed functions @@ -630,6 +648,9 @@ Pep384_Init() PepFunction_TypePtr = getFunctionType(); PepStaticMethod_TypePtr = getStaticMethodType(); #endif +#if PY_VERSION_HEX < 0x03000000 + PepMethodDescr_TypePtr = getMethodDescrType(); +#endif } } // extern "C" |