Update of /cvsroot/pywin32/pywin32/com/win32com/src/extensions
In directory ddv4jf1.ch3.sourceforge.com:/tmp/cvs-serv16066/win32com/src/extensions
Modified Files:
PyFUNCDESC.cpp PySTGMEDIUM.cpp PyTYPEATTR.cpp PyVARDESC.cpp
Log Message:
Merge more of Roger's type modernizations for win32com; tp_getattro,
inheritance (finally!) using Python builtin mechanisms, rich comparisons, etc.
All tests pass on py3k and py2k.
Index: PyTYPEATTR.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyTYPEATTR.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PyTYPEATTR.cpp 3 Dec 2008 22:34:20 -0000 1.4
--- PyTYPEATTR.cpp 19 Dec 2008 02:28:48 -0000 1.5
***************
*** 29,33 ****
// @object TYPEATTR|A TYPEATTR object represents a COM TYPEATTR structure.
! static struct PyMethodDef PyTYPEATTR_methods[] = {
{NULL}
};
--- 29,33 ----
// @object TYPEATTR|A TYPEATTR object represents a COM TYPEATTR structure.
! struct PyMethodDef PyTYPEATTR::methods[] = {
{NULL}
};
***************
*** 55,60 ****
PyTYPEATTR::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! PyTYPEATTR::getattr, /* tp_getattr */
! PyTYPEATTR::setattr, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
--- 55,60 ----
PyTYPEATTR::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! 0, /* tp_getattr */
! 0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
***************
*** 65,73 ****
0, /* tp_call */
0, /* tp_str */
};
#define OFF(e) offsetof(PyTYPEATTR, e)
! /*static*/ struct memberlist PyTYPEATTR::memberlist[] = {
{"iid", T_OBJECT,OFF(iid)},// @prop <o PyIID>|iid|The IID
{"lcid", T_INT, OFF(lcid)}, // @prop int|lcid|The lcid
--- 65,95 ----
0, /* tp_call */
0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ PyObject_GenericSetAttr, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PyTYPEATTR::methods, /* tp_methods */
+ PyTYPEATTR::members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};
#define OFF(e) offsetof(PyTYPEATTR, e)
! /*static*/ struct PyMemberDef PyTYPEATTR::members[] = {
{"iid", T_OBJECT,OFF(iid)},// @prop <o PyIID>|iid|The IID
{"lcid", T_INT, OFF(lcid)}, // @prop int|lcid|The lcid
***************
*** 151,174 ****
}
- PyObject *PyTYPEATTR::getattr(PyObject *self, char *name)
- {
- PyObject *res;
-
- res = Py_FindMethod(PyTYPEATTR_methods, self, name);
- if (res != NULL)
- return res;
- PyErr_Clear();
- return PyMember_Get((char *)self, memberlist, name);
- }
-
- int PyTYPEATTR::setattr(PyObject *self, char *name, PyObject *v)
- {
- if (v == NULL) {
- PyErr_SetString(PyExc_AttributeError, "can't delete PyTYPEATTR attributes");
- return -1;
- }
- return PyMember_Set((char *)self, memberlist, name, v);
- }
-
/*static*/ void PyTYPEATTR::deallocFunc(PyObject *ob)
{
--- 173,176 ----
Index: PySTGMEDIUM.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PySTGMEDIUM.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** PySTGMEDIUM.cpp 3 Dec 2008 22:34:20 -0000 1.10
--- PySTGMEDIUM.cpp 19 Dec 2008 02:28:48 -0000 1.11
***************
*** 99,103 ****
// @object PySTGMEDIUM|A STGMEDIUM object represents a COM STGMEDIUM structure.
! static struct PyMethodDef PySTGMEDIUM_methods[] = {
{"set", PySet, 1}, // @pymeth set|Sets the type and data of the object
{NULL}
--- 99,103 ----
// @object PySTGMEDIUM|A STGMEDIUM object represents a COM STGMEDIUM structure.
! struct PyMethodDef PySTGMEDIUM::methods[] = {
{"set", PySet, 1}, // @pymeth set|Sets the type and data of the object
{NULL}
***************
*** 112,116 ****
PySTGMEDIUM::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! PySTGMEDIUM::getattr, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
--- 112,116 ----
PySTGMEDIUM::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! 0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
***************
*** 122,125 ****
--- 122,147 ----
0, /* tp_call */
0, /* tp_str */
+ PySTGMEDIUM::getattro, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PySTGMEDIUM::methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};
***************
*** 209,220 ****
}
! PyObject *PySTGMEDIUM::getattr(PyObject *self, char *name)
{
! PyObject *res;
PySTGMEDIUM *ps = (PySTGMEDIUM *)self;
- res = Py_FindMethod(PySTGMEDIUM_methods, self, name);
- if (res != NULL)
- return res;
- PyErr_Clear();
// @prop int|tymed|An integer indicating the type of data in the stgmedium
if (strcmp(name, "tymed")==0)
--- 231,241 ----
}
! PyObject *PySTGMEDIUM::getattro(PyObject *self, PyObject *obname)
{
! char *name=PYWIN_ATTR_CONVERT(obname);
! if (name==NULL)
! return NULL;
!
PySTGMEDIUM *ps = (PySTGMEDIUM *)self;
// @prop int|tymed|An integer indicating the type of data in the stgmedium
if (strcmp(name, "tymed")==0)
***************
*** 293,297 ****
}
}
! return PyErr_Format(PyExc_AttributeError, "STGMEDIUM objects have no attribute '%s'", name);
}
--- 314,318 ----
}
}
! return PyObject_GenericGetAttr(self, obname);
}
Index: PyVARDESC.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyVARDESC.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** PyVARDESC.cpp 3 Dec 2008 22:34:21 -0000 1.7
--- PyVARDESC.cpp 19 Dec 2008 02:28:48 -0000 1.8
***************
*** 25,29 ****
// @object VARDESC|A VARDESC object represents a COM VARDESC structure.
! static struct PyMethodDef PyVARDESC_methods[] = {
{NULL}
};
--- 25,29 ----
// @object VARDESC|A VARDESC object represents a COM VARDESC structure.
! struct PyMethodDef PyVARDESC::methods[] = {
{NULL}
};
***************
*** 102,107 ****
PyVARDESC::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! PyVARDESC::getattr, /* tp_getattr */
! PyVARDESC::setattr, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
--- 102,107 ----
PyVARDESC::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! 0, /* tp_getattr */
! 0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
***************
*** 112,120 ****
0, /* tp_call */
0, /* tp_str */
};
#define OFF(e) offsetof(PyVARDESC, e)
! /*static*/ struct memberlist PyVARDESC::memberlist[] = {
{"memid", T_INT, OFF(memid)}, // @prop int|memid|The dispid of the member
{"value", T_OBJECT,OFF(value)}, // @prop int/object|value|A value for the variant. If PERINSTANCE then an offset into the instance, otherwise a variant converted to a Python object.
--- 112,142 ----
0, /* tp_call */
0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ PyObject_GenericSetAttr, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PyVARDESC::methods, /* tp_methods */
+ PyVARDESC::members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};
#define OFF(e) offsetof(PyVARDESC, e)
! /*static*/ struct PyMemberDef PyVARDESC::members[] = {
{"memid", T_INT, OFF(memid)}, // @prop int|memid|The dispid of the member
{"value", T_OBJECT,OFF(value)}, // @prop int/object|value|A value for the variant. If PERINSTANCE then an offset into the instance, otherwise a variant converted to a Python object.
***************
*** 195,218 ****
}
- PyObject *PyVARDESC::getattr(PyObject *self, char *name)
- {
- PyObject *res;
-
- res = Py_FindMethod(PyVARDESC_methods, self, name);
- if (res != NULL)
- return res;
- PyErr_Clear();
- return PyMember_Get((char *)self, memberlist, name);
- }
-
- int PyVARDESC::setattr(PyObject *self, char *name, PyObject *v)
- {
- if (v == NULL) {
- PyErr_SetString(PyExc_AttributeError, "can't delete PyVARDESC attributes");
- return -1;
- }
- return PyMember_Set((char *)self, memberlist, name, v);
- }
-
/*static*/ void PyVARDESC::deallocFunc(PyObject *ob)
{
--- 217,220 ----
Index: PyFUNCDESC.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/extensions/PyFUNCDESC.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** PyFUNCDESC.cpp 3 Dec 2008 22:34:20 -0000 1.3
--- PyFUNCDESC.cpp 19 Dec 2008 02:28:48 -0000 1.4
***************
*** 100,104 ****
// The object itself.
! static struct PyMethodDef PyFUNCDESC_methods[] = {
{NULL}
};
--- 100,104 ----
// The object itself.
! struct PyMethodDef PyFUNCDESC::methods[] = {
{NULL}
};
***************
*** 128,133 ****
PyFUNCDESC::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! PyFUNCDESC::getattr, /* tp_getattr */
! PyFUNCDESC::setattr, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
--- 128,133 ----
PyFUNCDESC::deallocFunc, /* tp_dealloc */
0, /* tp_print */
! 0, /* tp_getattr */
! 0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
***************
*** 138,146 ****
0, /* tp_call */
0, /* tp_str */
};
#define OFF(e) offsetof(PyFUNCDESC, e)
! /*static*/ struct memberlist PyFUNCDESC::memberlist[] = {
{"memid", T_INT, OFF(memid)}, // @prop integer|memid|
{"scodeArray", T_OBJECT,OFF(scodeArray)}, // @prop (int, ...)|scodeArray|
--- 138,168 ----
0, /* tp_call */
0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ PyObject_GenericSetAttr, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ PyFUNCDESC::methods, /* tp_methods */
+ PyFUNCDESC::members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ 0, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
};
#define OFF(e) offsetof(PyFUNCDESC, e)
! /*static*/ struct PyMemberDef PyFUNCDESC::members[] = {
{"memid", T_INT, OFF(memid)}, // @prop integer|memid|
{"scodeArray", T_OBJECT,OFF(scodeArray)}, // @prop (int, ...)|scodeArray|
***************
*** 193,216 ****
}
- PyObject *PyFUNCDESC::getattr(PyObject *self, char *name)
- {
- PyObject *res;
-
- res = Py_FindMethod(PyFUNCDESC_methods, self, name);
- if (res != NULL)
- return res;
- PyErr_Clear();
- return PyMember_Get((char *)self, memberlist, name);
- }
-
- int PyFUNCDESC::setattr(PyObject *self, char *name, PyObject *v)
- {
- if (v == NULL) {
- PyErr_SetString(PyExc_AttributeError, "can't delete PyFUNCDESC attributes");
- return -1;
- }
- return PyMember_Set((char *)self, memberlist, name, v);
- }
-
/*static*/ void PyFUNCDESC::deallocFunc(PyObject *ob)
{
--- 215,218 ----
|