summaryrefslogtreecommitdiffstats
path: root/gobject/gobjectmodule.c
diff options
context:
space:
mode:
authorManish Singh <yosh@gimp.org>2005-11-03 19:15:23 +0000
committerJohan Dahlin <johan@src.gnome.org>2005-11-03 19:15:23 +0000
commit55d03f1c08d4f7624732fab642b4c25a0e76e9d3 (patch)
tree2a1828f654b93eba33dbbc8bfc22367ff7294340 /gobject/gobjectmodule.c
parentd0449bfb71c391fd5b4ac9bc7d344639eda80332 (diff)
downloadpygobject-55d03f1c08d4f7624732fab642b4c25a0e76e9d3.tar.gz
pygobject-55d03f1c08d4f7624732fab642b4c25a0e76e9d3.tar.xz
pygobject-55d03f1c08d4f7624732fab642b4c25a0e76e9d3.zip
reviewed by: Johan Dahlin <jdahlin@async.com.br>
2005-11-03 Manish Singh <yosh@gimp.org> reviewed by: Johan Dahlin <jdahlin@async.com.br> * gobject/gobjectmodule.c: (pyg_integer_richcompare): * gobject/pygenum.c: (pyg_enum_richcompare): * gobject/pygflags.c: (pyg_flags_richcompare): * gobject/pygobject-private.h: Prepare for Python 2.5 richcompare changes, fixes #320455.
Diffstat (limited to 'gobject/gobjectmodule.c')
-rw-r--r--gobject/gobjectmodule.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c
index 9895688..f2a7d2e 100644
--- a/gobject/gobjectmodule.c
+++ b/gobject/gobjectmodule.c
@@ -2619,6 +2619,29 @@ pyg_set_object_has_new_constructor(GType type)
g_type_set_qdata(type, pygobject_has_updated_constructor_key, GINT_TO_POINTER(1));
}
+#define GET_INT(x) (((PyIntObject*)x)->ob_ival)
+PyObject *
+pyg_integer_richcompare(PyObject *v, PyObject *w, int op)
+{
+ PyObject *result;
+ gboolean t;
+
+ switch (op) {
+ case Py_EQ: t = GET_INT(v) == GET_INT(w); break;
+ case Py_NE: t = GET_INT(v) != GET_INT(w); break;
+ case Py_LE: t = GET_INT(v) <= GET_INT(w); break;
+ case Py_GE: t = GET_INT(v) >= GET_INT(w); break;
+ case Py_LT: t = GET_INT(v) < GET_INT(w); break;
+ case Py_GT: t = GET_INT(v) > GET_INT(w); break;
+ default: g_assert_not_reached();
+ }
+
+ result = t ? Py_True : Py_False;
+ Py_INCREF(result);
+ return result;
+}
+#undef GET_INT
+
static void
_log_func(const gchar *log_domain,
GLogLevelFlags log_level,