Update of /cvsroot/pywin32/pywin32/win32/src
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv26234
Modified Files:
Tag: py3k
PyHANDLE.cpp
Log Message:
add richcompare to handles
Index: PyHANDLE.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/win32/src/PyHANDLE.cpp,v
retrieving revision 1.16.2.5
retrieving revision 1.16.2.6
diff -C2 -d -r1.16.2.5 -r1.16.2.6
*** PyHANDLE.cpp 4 Dec 2008 00:07:22 -0000 1.16.2.5
--- PyHANDLE.cpp 11 Dec 2008 04:11:48 -0000 1.16.2.6
***************
*** 177,182 ****
// @pymeth __str__|Used when a string representation is required
PyHANDLE::strFunc, /* tp_str */
! 0, /* tp_getattro */
! 0, /* tp_setattro */
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
--- 177,182 ----
// @pymeth __str__|Used when a string representation is required
PyHANDLE::strFunc, /* tp_str */
! PyObject_GenericGetAttr, /* tp_getattro */
! PyObject_GenericSetAttr, /* tp_setattro */
0, /*tp_as_buffer*/
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */
***************
*** 184,188 ****
0, /* tp_traverse */
0, /* tp_clear */
! 0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
--- 184,188 ----
0, /* tp_traverse */
0, /* tp_clear */
! PyHANDLE::richcompareFunc, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
***************
*** 274,277 ****
--- 274,297 ----
}
+ PyObject *PyHANDLE::richcompare(PyObject *other, int op)
+ {
+ BOOL e;
+ if (PyHANDLE_Check(other))
+ e=compare((PyHANDLE *)other)==0;
+ else
+ e=FALSE;
+ PyObject *ret;
+ if (op==Py_EQ)
+ ret = e ? Py_True : Py_False;
+ else if (op==Py_NE)
+ ret = !e ? Py_True : Py_False;
+ else {
+ PyErr_SetString(PyExc_TypeError, "HANDLEs only compare equal or not equal");
+ ret = NULL;
+ }
+ Py_XINCREF(ret);
+ return ret;
+ }
+
// @pymethod |PyHANDLE|__int__|Used when the handle as an integer is required.
// @comm To get the underling win32 handle from a PyHANDLE object, use int(handleObject)
***************
*** 307,310 ****
--- 327,335 ----
}
+ PyObject *PyHANDLE::richcompareFunc(PyObject *ob, PyObject *other, int op)
+ {
+ return ((PyHANDLE *)ob)->richcompare(other, op);
+ }
+
// @pymethod int|PyHANDLE|__hash__|Used when the hash value of a HANDLE object is required
long PyHANDLE::hashFunc(PyObject *ob)
|