Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2009-09-03 05:52:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2009-09-03 05:52:10 +0400
commitac3f0695a2cf3d5706d8f49b1276579889997990 (patch)
treeae34b25fab82b9dd33313785cf600d26737de24f /source/gameengine/Ketsji/KX_PythonSeq.cpp
parent9004dc665cd303dc6bc84d1ea92716dc0c0020d3 (diff)
remove Py_CmpToRich (copy of py3.0 function), instead only support == and != for PyRNA and KX_PySequence types.
mesh1 > mesh2 # will raise an error.
Diffstat (limited to 'source/gameengine/Ketsji/KX_PythonSeq.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_PythonSeq.cpp32
1 files changed, 25 insertions, 7 deletions
diff --git a/source/gameengine/Ketsji/KX_PythonSeq.cpp b/source/gameengine/Ketsji/KX_PythonSeq.cpp
index 165a85e2c14..75a7c9b8aeb 100644
--- a/source/gameengine/Ketsji/KX_PythonSeq.cpp
+++ b/source/gameengine/Ketsji/KX_PythonSeq.cpp
@@ -340,24 +340,42 @@ static PyObject *KX_PythonSeq_nextIter(KX_PythonSeq *self)
}
-static int KX_PythonSeq_compare( KX_PythonSeq * a, KX_PythonSeq * b ) /* TODO - python3.x wants richcmp */
+static int KX_PythonSeq_compare( KX_PythonSeq * a, KX_PythonSeq * b )
{
return ( a->type == b->type && a->base == b->base) ? 0 : -1;
}
-extern PyObject *Py_CmpToRich(int op, int cmp);
-
static PyObject *KX_PythonSeq_richcmp(PyObject *a, PyObject *b, int op)
{
- int cmp_result= -1; /* assume false */
+ PyObject *res;
+ int ok= -1; /* zero is true */
+
+ if(BPy_KX_PythonSeq_Check(a) && BPy_KX_PythonSeq_Check(b))
+ ok= KX_PythonSeq_compare((KX_PythonSeq *)a, (KX_PythonSeq *)b);
- if(BPy_KX_PythonSeq_Check(a) && BPy_KX_PythonSeq_Check(b)) {
- cmp_result= KX_PythonSeq_compare((KX_PythonSeq *)a, (KX_PythonSeq *)b);
+ switch (op) {
+ case Py_NE:
+ ok = !ok; /* pass through */
+ case Py_EQ:
+ res = ok ? Py_False : Py_True;
+ break;
+
+ case Py_LT:
+ case Py_LE:
+ case Py_GT:
+ case Py_GE:
+ res = Py_NotImplemented;
+ break;
+ default:
+ PyErr_BadArgument();
+ return NULL;
}
- return Py_CmpToRich(op, cmp_result);
+ Py_INCREF(res);
+ return res;
}
+
/*
* repr function
* convert to a list and get its string value