summaryrefslogtreecommitdiffstats
path: root/glib/pygmaincontext.c
diff options
context:
space:
mode:
authorJohn Ehresman <jpe@wingware.com>2010-04-02 16:08:07 -0400
committerJohn Ehresman <jpe@wingware.com>2010-04-15 12:13:34 -0400
commit13a5da14842caa6a80e6ed7237422b984a152cd8 (patch)
treeaa4139bf93ffd7730850057c9f4de975068294a8 /glib/pygmaincontext.c
parent681832c3cd040433a488a400693b68f213bf7078 (diff)
downloadpygobject-13a5da14842caa6a80e6ed7237422b984a152cd8.tar.gz
pygobject-13a5da14842caa6a80e6ed7237422b984a152cd8.tar.xz
pygobject-13a5da14842caa6a80e6ed7237422b984a152cd8.zip
Use richcompare slot rather than old compare slot and Py_TYPE macro in preparation for py3k support
Diffstat (limited to 'glib/pygmaincontext.c')
-rw-r--r--glib/pygmaincontext.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/glib/pygmaincontext.c b/glib/pygmaincontext.c
index 186215a..2b02c6c 100644
--- a/glib/pygmaincontext.c
+++ b/glib/pygmaincontext.c
@@ -51,12 +51,17 @@ pyg_main_context_dealloc(PyGMainContext *self)
PyObject_Del(self);
}
-static int
-pyg_main_context_compare(PyGMainContext *self, PyGMainContext *v)
+static PyObject*
+pyg_main_context_richcompare(PyObject *self, PyObject *other, int op)
{
- if (self->context == v->context) return 0;
- if (self->context > v->context) return -1;
- return 1;
+ if (Py_TYPE(self) == Py_TYPE(other) && Py_TYPE(self) == &PyGMainContext_Type)
+ return _pyglib_generic_ptr_richcompare(((PyGMainContext*)self)->context,
+ ((PyGMainContext*)other)->context,
+ op);
+ else {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
}
static PyObject *
@@ -91,7 +96,7 @@ void
pyglib_maincontext_register_types(PyObject *d)
{
PyGMainContext_Type.tp_dealloc = (destructor)pyg_main_context_dealloc;
- PyGMainContext_Type.tp_compare = (cmpfunc)pyg_main_context_compare;
+ PyGMainContext_Type.tp_richcompare = pyg_main_context_richcompare;
PyGMainContext_Type.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE;
PyGMainContext_Type.tp_methods = _PyGMainContext_methods;
PyGMainContext_Type.tp_init = (initproc)pyg_main_context_init;