[pywin32-checkins] pywin32/com/win32com/src MiscTypes.cpp,1.3,1.4 PyIBase.cpp,1.3,1.4
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: <mha...@us...> - 2003-10-24 09:36:34
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1:/tmp/cvs-serv10436 Modified Files: MiscTypes.cpp PyIBase.cpp Log Message: Tighten up iterator semantics. Only interfaces that explicitly declare they are an enumerator get the iterator slots and flags. Our 2 interfaces that support iteration make this declaration. Index: MiscTypes.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/MiscTypes.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MiscTypes.cpp 23 Oct 2003 07:34:37 -0000 1.3 --- MiscTypes.cpp 23 Oct 2003 23:42:02 -0000 1.4 *************** *** 65,69 **** 0, /*tp_setattro */ 0, /* tp_as_buffer */ ! Py_TPFLAGS_HAVE_ITER, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ --- 65,69 ---- 0, /*tp_setattro */ 0, /* tp_as_buffer */ ! 0, /* tp_flags */ 0, /* tp_doc */ 0, /* tp_traverse */ *************** *** 71,76 **** 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ ! PyIBase::iter, /* tp_iter */ ! PyIBase::iternext, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ --- 71,76 ---- 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ ! 0, /* tp_iter */ ! 0, /* tp_iternext */ 0, /* tp_methods */ 0, /* tp_members */ *************** *** 107,110 **** --- 107,119 ---- ((PyTypeObject *)ob)->tp_base == &PyInterfaceType_Type; #endif + } + + // Our type for IEnum* interfaces + PyComEnumTypeObject::PyComEnumTypeObject( const char *name, PyComTypeObject *pBase, int typeSize, struct PyMethodDef* methodList, PyIUnknown * (* thector)(IUnknown *)) : + PyComTypeObject( name, pBase, typeSize, methodList, thector) + { + tp_iter = PyIBase::iter; + tp_iternext = PyIBase::iternext; + tp_flags |= Py_TPFLAGS_HAVE_ITER; } Index: PyIBase.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PyIBase.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIBase.cpp 23 Oct 2003 07:34:37 -0000 1.3 --- PyIBase.cpp 23 Oct 2003 23:42:02 -0000 1.4 *************** *** 60,70 **** "iternext must be overridden by objects supporting enumeration (type '%s').", ob_type->tp_name); } - PyObject * - PyIBase::iter() - { - return PyErr_Format(PyExc_TypeError, - "COM objects of type '%s' can not be iterated.", ob_type->tp_name); - } - /*static*/int PyIBase::setattr(PyObject *op, char *name, PyObject *v) --- 60,63 ---- *************** *** 101,104 **** --- 94,102 ---- { return ((PyIBase *)ob1)->compare(ob2); + } + + /*static*/ PyObject *PyIBase::iter(PyObject *self) + { + return ((PyIBase *)self)->iter(); } |