aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken2/libshiboken
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-10 12:42:25 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2020-09-10 12:45:26 +0200
commitd4bc1ade3a8aae42915c1c71f4bac10414644ae0 (patch)
tree94496a73808d58db1505a4034a4eedc0c8a3930d /sources/shiboken2/libshiboken
parent8f7de769636f36bcf371c472480adab75a32e0bf (diff)
parent074e52bccfba94c97cc132060e7087f830756b26 (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Diffstat (limited to 'sources/shiboken2/libshiboken')
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.cpp27
-rw-r--r--sources/shiboken2/libshiboken/basewrapper.h3
2 files changed, 30 insertions, 0 deletions
diff --git a/sources/shiboken2/libshiboken/basewrapper.cpp b/sources/shiboken2/libshiboken/basewrapper.cpp
index 61c4ae984..05f8a4fb8 100644
--- a/sources/shiboken2/libshiboken/basewrapper.cpp
+++ b/sources/shiboken2/libshiboken/basewrapper.cpp
@@ -809,6 +809,33 @@ PyObject *SbkType_FromSpecWithBases(PyType_Spec *spec, PyObject *bases)
return type;
}
+// PYSIDE-74: Fallback used in all types now.
+PyObject *FallbackRichCompare(PyObject *self, PyObject *other, int op)
+{
+ // This is a very simple implementation that supplies a simple identity.
+ static const char * const opstrings[] = {"<", "<=", "==", "!=", ">", ">="};
+ PyObject *res;
+
+ switch (op) {
+
+ case Py_EQ:
+ res = (self == other) ? Py_True : Py_False;
+ break;
+ case Py_NE:
+ res = (self != other) ? Py_True : Py_False;
+ break;
+ default:
+ PyErr_Format(PyExc_TypeError,
+ "'%s' not supported between instances of '%.100s' and '%.100s'",
+ opstrings[op],
+ self->ob_type->tp_name,
+ other->ob_type->tp_name);
+ return NULL;
+ }
+ Py_INCREF(res);
+ return res;
+}
+
} //extern "C"
diff --git a/sources/shiboken2/libshiboken/basewrapper.h b/sources/shiboken2/libshiboken/basewrapper.h
index b233c02b4..267759daa 100644
--- a/sources/shiboken2/libshiboken/basewrapper.h
+++ b/sources/shiboken2/libshiboken/basewrapper.h
@@ -135,6 +135,9 @@ LIBSHIBOKEN_API PyObject *SbkDummyNew(PyTypeObject *type, PyObject *, PyObject *
LIBSHIBOKEN_API PyObject *SbkType_FromSpec(PyType_Spec *);
LIBSHIBOKEN_API PyObject *SbkType_FromSpecWithBases(PyType_Spec *, PyObject *);
+/// PYSIDE-74: Fallback used in all types now.
+LIBSHIBOKEN_API PyObject *FallbackRichCompare(PyObject *self, PyObject *other, int op);
+
} // extern "C"
namespace Shiboken