[pywin32-checkins] pywin32/win32/src PyHANDLE.cpp, 1.19, 1.20 PyWinObjects.h, 1.16, 1.17
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: Mark H. <mha...@us...> - 2008-12-17 13:13:04
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv10480/win32/src Modified Files: PyHANDLE.cpp PyWinObjects.h Log Message: PyHANDLE objects get rich-comparison support. Index: PyWinObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinObjects.h,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** PyWinObjects.h 11 Dec 2008 00:25:40 -0000 1.16 --- PyWinObjects.h 17 Dec 2008 13:12:56 -0000 1.17 *************** *** 140,143 **** --- 140,145 ---- /* Python support */ int compare(PyObject *ob); + PyObject *richcompare(PyObject *other, int op); + int print(FILE *fp, int flags); PyObject *asStr(void); *************** *** 147,150 **** --- 149,153 ---- static int printFunc(PyObject *ob, FILE *fp, int flags); static int compareFunc(PyObject *ob1, PyObject *ob2); + static PyObject *richcompareFunc(PyObject *ob, PyObject *other, int op); static int nonzeroFunc(PyObject *ob); static long hashFunc(PyObject *ob); Index: PyHANDLE.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyHANDLE.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyHANDLE.cpp 11 Dec 2008 00:25:40 -0000 1.19 --- PyHANDLE.cpp 17 Dec 2008 13:12:56 -0000 1.20 *************** *** 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) |