diff options
author | Christian Tismer <tismer@stackless.com> | 2020-06-07 17:05:32 +0200 |
---|---|---|
committer | Christian Tismer <tismer@stackless.com> | 2020-06-15 10:04:39 +0200 |
commit | d7c52752eaa1f6017a4a8fc0218a0bdd8ea7ea0a (patch) | |
tree | 23152f460d1750ae50363978f79ed9e6e839abf0 /sources/shiboken2/libshiboken/basewrapper.cpp | |
parent | 3a1cf48137752ef3640ae7b1e2937e4bed34d3b2 (diff) |
Implement the QEnum/QFlag decorator, V2
This implementation allows module-level and scoped QEnums
which are Python enum types. Scoped types are registered in Qt's meta
object system.
Usage of QEnum/QFlag with decorator or function call:
from enum import Enum, Flag, auto
from PySide2.QtCore import QEnum, QFlag, QObject
class Compass(QObject):
@QEnum
class Orientation(Enum):
North, East, South, West = range(4)
class Color(Flag):
RED = auto()
BLUE = auto()
GREEN = auto()
WHITE = RED | BLUE | GREEN
QFlag(Color)
Fixes: PYSIDE-957
Change-Id: Ie15f45cbd932c816b50724a96eee0c14ae1fdee8
Task-number: PYSIDE-487
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/basewrapper.cpp')
-rw-r--r-- | sources/shiboken2/libshiboken/basewrapper.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp index 443d25cdf..d7184569b 100644 --- a/sources/shiboken2/libshiboken/basewrapper.cpp +++ b/sources/shiboken2/libshiboken/basewrapper.cpp @@ -486,7 +486,7 @@ void SbkObjectTypeDealloc(PyObject *pyObj) } } -PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *kwds) +static PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *kwds) { // Check if all bases are new style before calling type.tp_new // Was causing gc assert errors in test_bug704.py when @@ -513,7 +513,8 @@ PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *k #ifndef IS_PY3K if (PyClass_Check(baseType)) { PyErr_Format(PyExc_TypeError, "Invalid base class used in type %s. " - "PySide only support multiple inheritance from python new style class.", metatype->tp_name); + "PySide only supports multiple inheritance from Python new style classes.", + metatype->tp_name); return 0; } #endif @@ -579,7 +580,6 @@ PyObject *SbkObjectTypeTpNew(PyTypeObject *metatype, PyObject *args, PyObject *k if (PepType_SOTP(base)->subtype_init) PepType_SOTP(base)->subtype_init(newType, args, kwds); } - return reinterpret_cast<PyObject *>(newType); } |